commit c53204f9c346332a7dc4757fb1a3ccbd67a79301 Author: n8fr8 nathan@freitas.net Date: Tue Oct 31 11:11:46 2017 -0400
only refresh VPN settings if app selection changes --- .../org/torproject/android/OrbotMainActivity.java | 12 ++++-- .../torproject/android/ui/AppManagerActivity.java | 44 +++++++++++----------- .../android/service/vpn/OrbotVpnManager.java | 1 - .../android/service/vpn/TorVpnService.java | 6 --- 4 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index 2c45d0f6..60a3a2c5 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -609,6 +609,12 @@ public class OrbotMainActivity extends AppCompatActivity
}
+ private void refreshVPNApps () + { + stopVpnService(); + startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class)); + } + private void enableVPN (boolean enable) { Prefs.putUseVpn(enable); @@ -798,10 +804,8 @@ public class OrbotMainActivity extends AppCompatActivity
case INTENT_ACTION_REQUEST_START_TOR: autoStartFromIntent = true; - startTor();
- break; case Intent.ACTION_VIEW: String urlString = intent.getDataString(); @@ -967,7 +971,9 @@ public class OrbotMainActivity extends AppCompatActivity } else if (request == REQUEST_VPN_APPS_SELECT) { - startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class)); + if (response == RESULT_OK) + refreshVPNApps(); + }
IntentResult scanResult = IntentIntegrator.parseActivityResult(request, response, data); diff --git a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java index 9d909f54..0f8e2f06 100644 --- a/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java +++ b/app/src/main/java/org/torproject/android/ui/AppManagerActivity.java @@ -18,6 +18,7 @@ import org.torproject.android.service.vpn.TorifiedApp;
import android.app.ProgressDialog; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.pm.ApplicationInfo; @@ -41,7 +42,7 @@ import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.TextView;
-public class AppManagerActivity extends AppCompatActivity implements OnCheckedChangeListener, OnClickListener, OrbotConstants { +public class AppManagerActivity extends AppCompatActivity implements OnClickListener, OrbotConstants {
private GridView listApps; private ListAdapter adapterApps; @@ -132,8 +133,6 @@ public class AppManagerActivity extends AppCompatActivity implements OnCheckedCh entry.icon = (ImageView) convertView.findViewById(R.id.itemicon); entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck); entry.text = (TextView) convertView.findViewById(R.id.itemtext); - - convertView.setTag(entry);
@@ -146,9 +145,7 @@ public class AppManagerActivity extends AppCompatActivity implements OnCheckedCh try { entry.icon.setImageDrawable(pMgr.getApplicationIcon(app.getPackageName())); entry.icon.setOnClickListener(AppManagerActivity.this); - - if (entry.box != null) - entry.icon.setTag(entry.box); + entry.icon.setTag(entry.box); } catch (Exception e) { @@ -159,17 +156,12 @@ public class AppManagerActivity extends AppCompatActivity implements OnCheckedCh if (entry.text != null) { entry.text.setText(app.getName()); entry.text.setOnClickListener(AppManagerActivity.this); - - if (entry.box != null) - entry.text.setTag(entry.box); + entry.text.setTag(entry.box); }
- if (entry.box != null) { - entry.box.setOnCheckedChangeListener(AppManagerActivity.this); - entry.box.setTag(app); + entry.box.setOnClickListener(AppManagerActivity.this); entry.box.setChecked(app.isTorified()); - }
return convertView; @@ -307,6 +299,7 @@ public class AppManagerActivity extends AppCompatActivity implements OnCheckedCh {
StringBuilder tordApps = new StringBuilder(); + Intent response = new Intent();
for (TorifiedApp tApp:mApps) { @@ -314,6 +307,7 @@ public class AppManagerActivity extends AppCompatActivity implements OnCheckedCh { tordApps.append(tApp.getUsername()); tordApps.append("|"); + response.putExtra(tApp.getUsername(),true); } }
@@ -321,12 +315,14 @@ public class AppManagerActivity extends AppCompatActivity implements OnCheckedCh edit.putString(PREFS_KEY_TORIFIED, tordApps.toString()); edit.commit();
+ setResult(RESULT_OK,response); }
/** * Called an application is check/unchecked */ + /** public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { final TorifiedApp app = (TorifiedApp) buttonView.getTag(); if (app != null) { @@ -335,23 +331,29 @@ public class AppManagerActivity extends AppCompatActivity implements OnCheckedCh
saveAppSettings(this);
- } + }**/
public void onClick(View v) {
- CheckBox cbox = (CheckBox)v.getTag(); + CheckBox cbox = null;
- final TorifiedApp app = (TorifiedApp)cbox.getTag(); - if (app != null) { - app.setTorified(!app.isTorified()); - cbox.setChecked(app.isTorified()); - } + if (v instanceof CheckBox) + cbox = (CheckBox)v; + else if (v.getTag() instanceof CheckBox) + cbox = (CheckBox)v.getTag();
- saveAppSettings(this); + if (cbox != null) { + final TorifiedApp app = (TorifiedApp) cbox.getTag(); + if (app != null) { + app.setTorified(!app.isTorified()); + cbox.setChecked(app.isTorified()); + }
+ saveAppSettings(this); + } }
diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java index 3d54e888..bbae15ea 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java +++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java @@ -114,7 +114,6 @@ public class OrbotVpnManager implements Handler.Callback { if (!mIsLollipop) { - startSocksBypass(); } diff --git a/orbotservice/src/main/java/org/torproject/android/service/vpn/TorVpnService.java b/orbotservice/src/main/java/org/torproject/android/service/vpn/TorVpnService.java index f396860d..7d18ffd8 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/vpn/TorVpnService.java +++ b/orbotservice/src/main/java/org/torproject/android/service/vpn/TorVpnService.java @@ -5,12 +5,6 @@ import android.app.Service; import android.content.Intent; import android.net.VpnService; import android.os.Build; -import android.text.TextUtils; -import android.util.Log; - -import org.torproject.android.service.OrbotConstants; -import org.torproject.android.service.TorServiceConstants; -import org.torproject.android.service.util.Prefs;
/** * Created by n8fr8 on 9/26/16.
tor-commits@lists.torproject.org