Actually fix app shortcuts

pull/41/head
Alexander Bakker 7 years ago
parent 456069fbc7
commit 89c61eab3e

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

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

Loading…
Cancel
Save