commit 233abf8ed54328b8ffa8bd36bc13d3d07115b133 Author: bim dsnake@protonmail.com Date: Tue Aug 4 00:33:00 2020 -0400
Start tor/VPN when VPN permissions are first granted and VPN switch is set to on (orbot starts everytime the switch is pressed on, just wasn't after the initial time you grant VPN permissions) --- .../org/torproject/android/OrbotMainActivity.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index 199a5177..a3824041 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -523,9 +523,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan if (intentVPN != null) startActivityForResult(intentVPN, REQUEST_VPN); else { - drawAppShortcuts(true); - sendIntentToService(ACTION_START); - sendIntentToService(ACTION_START_VPN); + startVpn(); }
} else { @@ -535,6 +533,12 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan
}
+ private void startVpn() { + drawAppShortcuts(true); + sendIntentToService(ACTION_START); + sendIntentToService(ACTION_START_VPN); + } + private void enableHiddenServicePort( String hsName, final int hsPort, int hsRemotePort, final String backupToPackage, final Uri hsKeyPath, @@ -805,8 +809,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan refreshVPNApps();
} else if (request == REQUEST_VPN && response == RESULT_OK) { - drawAppShortcuts(true); - sendIntentToService(ACTION_START_VPN); + startVpn(); } else if (request == REQUEST_VPN && response == RESULT_CANCELED) { mBtnVPN.setChecked(false); } @@ -1239,13 +1242,7 @@ public class OrbotMainActivity extends AppCompatActivity implements OrbotConstan iv.setLayoutParams(params); iv.setImageDrawable(getResources().getDrawable(R.drawable.ic_settings_white_24dp)); llBoxShortcuts.addView(iv); - iv.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startActivityForResult(new Intent(OrbotMainActivity.this, AppManagerActivity.class), REQUEST_VPN_APPS_SELECT); - - } - }); + iv.setOnClickListener(v -> startActivityForResult(new Intent(OrbotMainActivity.this, AppManagerActivity.class), REQUEST_VPN_APPS_SELECT)); }