Fixed shortcut

This commit is contained in:
PeratX 2018-02-05 18:15:05 +08:00
parent 6a0d7c0f3c
commit acc9c725f0
3 changed files with 5 additions and 5 deletions

View File

@ -241,7 +241,7 @@ public class Daedalus extends Application {
.setShortLabel(notice)
.setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher))
.setIntent(new Intent(context, MainActivity.class).setAction(Intent.ACTION_VIEW)
.putExtra(MainActivity.LAUNCH_ACTION, activate ? MainActivity.LAUNCH_ACTION_ACTIVATE : MainActivity.LAUNCH_ACTION_DEACTIVATE))
.putExtra(MainActivity.LAUNCH_ACTION, activate ? MainActivity.LAUNCH_ACTION_DEACTIVATE : MainActivity.LAUNCH_ACTION_ACTIVATE))
.build();
ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(SHORTCUT_SERVICE);
shortcutManager.addDynamicShortcuts(Collections.singletonList(info));

View File

@ -180,7 +180,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
DaedalusVpnService.secondaryServer = DNSServerHelper.getAddressById(DNSServerHelper.getSecondary());
Daedalus.getInstance().startService(Daedalus.getServiceIntent(getApplicationContext()).setAction(DaedalusVpnService.ACTION_ACTIVATE));
updateMainButton(R.string.button_text_deactivate);
Daedalus.updateShortcut(Daedalus.getInstance());
Daedalus.updateShortcut(getApplicationContext());
}
}
@ -192,14 +192,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
private void updateUserInterface(Intent intent) {
Log.d(TAG, "Updating user interface");
int launchAction = intent.getIntExtra(LAUNCH_ACTION, LAUNCH_ACTION_NONE);
Log.d(TAG, "Updating user interface with Launch Action " + String.valueOf(launchAction));
if (launchAction == LAUNCH_ACTION_ACTIVATE) {
this.activateService();
} else if (launchAction == LAUNCH_ACTION_DEACTIVATE) {
Daedalus.deactivateService(getApplicationContext());
} else if (launchAction == LAUNCH_ACTION_SERVICE_DONE) {
Daedalus.updateShortcut(this.getApplicationContext());
Daedalus.updateShortcut(getApplicationContext());
if (DaedalusVpnService.isActivated()) {
updateMainButton(R.string.button_text_deactivate);
} else {

View File

@ -119,7 +119,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
this.running = true;
this.mThread.start();
}
Daedalus.updateShortcut(this.getApplicationContext());
Daedalus.updateShortcut(getApplicationContext());
if (MainActivity.getInstance() != null) {
MainActivity.getInstance().startActivity(new Intent(getApplicationContext(), MainActivity.class)
.putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_SERVICE_DONE));