Actually fix app shortcuts

This commit is contained in:
Alexander Bakker 2017-12-25 20:01:58 +01:00
parent 456069fbc7
commit 89c61eab3e
2 changed files with 22 additions and 16 deletions

View file

@ -19,7 +19,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme.Default.NoActionBar" android:theme="@style/AppTheme.Default.NoActionBar"
android:alwaysRetainTaskState="true" android:alwaysRetainTaskState="true"
android:relinquishTaskIdentity="false"> android:launchMode="singleTask">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>

View file

@ -53,7 +53,6 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
private DatabaseManager _db; private DatabaseManager _db;
private KeyProfileView _keyProfileView; private KeyProfileView _keyProfileView;
private String _pendingAction = null;
private boolean _nightMode = false; private boolean _nightMode = false;
private Menu _menu; private Menu _menu;
@ -68,9 +67,8 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
// init the app shortcuts and execute any pending actions // init the app shortcuts
initializeAppShortcuts(); initializeAppShortcuts();
doShortcutActions();
// set up the key profile view // set up the key profile view
_keyProfileView = (KeyProfileView) getSupportFragmentManager().findFragmentById(R.id.key_profiles); _keyProfileView = (KeyProfileView) getSupportFragmentManager().findFragmentById(R.id.key_profiles);
@ -115,6 +113,16 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
} }
} }
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (!doShortcutActions()) {
startAuthActivity();
}
}
@Override @Override
protected void setPreferredTheme(boolean nightMode) { protected void setPreferredTheme(boolean nightMode) {
if (nightMode) { if (nightMode) {
@ -127,6 +135,10 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data == null) {
return;
}
switch (requestCode) { switch (requestCode) {
case CODE_GET_KEYINFO: case CODE_GET_KEYINFO:
onGetKeyInfoResult(resultCode, data); onGetKeyInfoResult(resultCode, data);
@ -373,20 +385,11 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
startActivityForResult(scannerActivity, CODE_GET_KEYINFO); startActivityForResult(scannerActivity, CODE_GET_KEYINFO);
} }
private void doShortcutActions() { private boolean doShortcutActions() {
Intent intent = getIntent(); Intent intent = getIntent();
String action = intent.getStringExtra("action"); String action = intent.getStringExtra("action");
intent.removeExtra("action"); if (action == null || _db.isLocked()) {
if (action == null) { return false;
if (_pendingAction == null) {
return;
} else {
action = _pendingAction;
}
}
if (_db.isLocked()) {
_pendingAction = action;
return;
} }
switch (action) { switch (action) {
@ -394,6 +397,9 @@ public class MainActivity extends AegisActivity implements KeyProfileView.Listen
startScanActivity(); startScanActivity();
break; break;
} }
intent.removeExtra("action");
return true;
} }
public void startActivityForResult(Intent intent, int requestCode) { public void startActivityForResult(Intent intent, int requestCode) {