Fixed duplicated updateShortcut calls
This commit is contained in:
parent
139ed2d77a
commit
a57b2f742e
@ -9,6 +9,7 @@ import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -99,6 +100,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void updateUserInterface(Intent intent) {
|
||||
Log.d("MainActivity", "Updating user interface");
|
||||
int launchAction = intent.getIntExtra(LAUNCH_ACTION, LAUNCH_ACTION_NONE);
|
||||
if (launchAction == LAUNCH_ACTION_ACTIVATE) {
|
||||
Daedalus.updateShortcut(this);
|
||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import org.itxtech.daedalus.Daedalus;
|
||||
import org.itxtech.daedalus.R;
|
||||
import org.itxtech.daedalus.activity.MainActivity;
|
||||
import org.itxtech.daedalus.activity.SettingsActivity;
|
||||
@ -32,6 +33,7 @@ public class StatusBarBroadcastReceiver extends BroadcastReceiver {
|
||||
Intent serviceIntent = new Intent(context, DaedalusVpnService.class);
|
||||
context.startService(serviceIntent.setAction(DaedalusVpnService.ACTION_DEACTIVATE));
|
||||
context.stopService(serviceIntent);
|
||||
Daedalus.updateShortcut(context);
|
||||
if (MainActivity.getInstance() != null) {
|
||||
((Button) MainActivity.getInstance().findViewById(R.id.button_activate)).setText(R.string.button_text_activate);
|
||||
}
|
||||
|
@ -140,12 +140,14 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void stopThread() {
|
||||
boolean shouldRefresh = false;
|
||||
try {
|
||||
if (this.descriptor != null) {
|
||||
this.descriptor.close();
|
||||
this.descriptor = null;
|
||||
}
|
||||
if (this.mThread != null) {
|
||||
shouldRefresh = true;
|
||||
this.running = false;
|
||||
this.mThread.interrupt();
|
||||
if (mInterruptFd != null) {
|
||||
@ -166,9 +168,9 @@ public class DaedalusVpnService extends VpnService implements Runnable {
|
||||
}
|
||||
stopSelf();
|
||||
|
||||
if (MainActivity.getInstance() != null && MainActivity.getInstance().isAppOnForeground()) {
|
||||
if (shouldRefresh && MainActivity.getInstance() != null && MainActivity.getInstance().isAppOnForeground()) {
|
||||
startActivity(new Intent(this, MainActivity.class).putExtra(MainActivity.LAUNCH_ACTION, MainActivity.LAUNCH_ACTION_NONE));
|
||||
} else {
|
||||
} else if (shouldRefresh) {
|
||||
Daedalus.updateShortcut(this);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user