[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] more work on app-mini user interface for configuration
commit e73d16c0982eecaa0d1ffe56d7f2f708a35a0458
Author: n8fr8 <nathan@xxxxxxxxxxxxxxxxxxxx>
Date: Wed Sep 4 17:07:53 2019 -0400
more work on app-mini user interface for configuration
---
app-mini/build.gradle | 6 +-
.../torproject/android/mini/MiniMainActivity.java | 21 ++++--
.../android/mini/ui/AppConfigActivity.java | 81 ++++++++++++++++++++--
.../src/main/res/layout/content_app_config.xml | 6 ++
app-mini/src/main/res/values/strings.xml | 4 +-
5 files changed, 101 insertions(+), 17 deletions(-)
diff --git a/app-mini/build.gradle b/app-mini/build.gradle
index ea8a8d22..678a70e6 100644
--- a/app-mini/build.gradle
+++ b/app-mini/build.gradle
@@ -20,12 +20,12 @@ android {
}
}
- compileSdkVersion 28
+ compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "org.torproject.android.mini"
minSdkVersion 16
- targetSdkVersion 28
+ targetSdkVersion 29
}
lintOptions {
checkReleaseBuilds false
@@ -55,7 +55,7 @@ android {
applicationId 'org.torproject.android.mini'
targetSdkVersion 28
versionCode 10010000
- versionName '1.0.0-BETA-1-tor-0.4.0.4-rc'
+ versionName 'mini-1.0.0-BETA-1-tor-0.4.0.4-rc'
archivesBaseName = "Orbot-mini-$versionName"
}
}
diff --git a/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java b/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
index e6f33ba0..54cf23a9 100644
--- a/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
+++ b/app-mini/src/main/java/org/torproject/android/mini/MiniMainActivity.java
@@ -487,13 +487,20 @@ public class MiniMainActivity extends AppCompatActivity
private void enableVPN (boolean enable)
{
- Prefs.putUseVpn(enable);
-
- if (enable) {
- startActivityForResult(new Intent(MiniMainActivity.this, VPNEnableActivity.class), REQUEST_VPN);
- } else
- stopVpnService();
+ if (enable && pkgIds.size() == 0)
+ {
+ showAppPicker();
+ }
+ else {
+ Prefs.putUseVpn(enable);
+ if (enable) {
+ startActivityForResult(new Intent(MiniMainActivity.this, VPNEnableActivity.class), REQUEST_VPN);
+ } else {
+ stopVpnService();
+ stopTor();
+ }
+ }
}
@@ -1169,7 +1176,7 @@ public class MiniMainActivity extends AppCompatActivity
{
Intent data = new Intent(this, AppConfigActivity.class);
data.putExtra(Intent.EXTRA_PACKAGE_NAME,pkgId);
- startActivity(data);
+ startActivityForResult(data,REQUEST_VPN_APPS_SELECT);
}
diff --git a/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java b/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java
index f4dcc6c6..d57674d3 100644
--- a/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java
+++ b/app-mini/src/main/java/org/torproject/android/mini/ui/AppConfigActivity.java
@@ -12,9 +12,13 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.CompoundButton;
+import android.widget.Switch;
+import org.torproject.android.mini.MainConstants;
import org.torproject.android.mini.MiniMainActivity;
import org.torproject.android.mini.R;
+import org.torproject.android.service.OrbotConstants;
import org.torproject.android.service.util.TorServiceUtils;
import org.torproject.android.service.vpn.TorifiedApp;
@@ -25,6 +29,12 @@ public class AppConfigActivity extends AppCompatActivity {
TorifiedApp mApp;
+ private boolean mAppTor = false;
+ private boolean mAppData = false;
+ private boolean mAppWifi = false;
+
+ private SharedPreferences mPrefs;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -34,7 +44,9 @@ public class AppConfigActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- String pkgId = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
+ final String pkgId = getIntent().getStringExtra(Intent.EXTRA_PACKAGE_NAME);
+
+ mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
ApplicationInfo aInfo = null;
try {
@@ -47,27 +59,85 @@ public class AppConfigActivity extends AppCompatActivity {
}
catch (Exception e){}
+ mAppTor = mPrefs.getBoolean(pkgId + OrbotConstants.APP_TOR_KEY,true);
+ mAppData = mPrefs.getBoolean(pkgId + OrbotConstants.APP_DATA_KEY,false);
+ mAppWifi = mPrefs.getBoolean(pkgId + OrbotConstants.APP_WIFI_KEY,false);
+
+ Switch switchAppTor = findViewById(R.id.switch_app_tor);
+ switchAppTor.setChecked(mAppTor);
+ switchAppTor.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mPrefs.edit().putBoolean(pkgId + OrbotConstants.APP_TOR_KEY,isChecked).commit();
+
+ Intent response = new Intent();
+ setResult(RESULT_OK,response);
+ }
+ });
+
+ Switch switchAppData = findViewById(R.id.switch_app_data);
+ switchAppData.setChecked(mAppData);
+ switchAppData.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mPrefs.edit().putBoolean(pkgId + OrbotConstants.APP_DATA_KEY,isChecked).commit();
+
+ Intent response = new Intent();
+ setResult(RESULT_OK,response);
+ }
+ });
+ switchAppData.setEnabled(false);
+
+ Switch switchAppWifi = findViewById(R.id.switch_app_wifi);
+ switchAppWifi.setChecked(mAppWifi);
+ switchAppWifi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mPrefs.edit().putBoolean(pkgId + OrbotConstants.APP_WIFI_KEY,isChecked).commit();
+
+ Intent response = new Intent();
+ setResult(RESULT_OK,response);
+ }
+ });
+ switchAppWifi.setEnabled(false);
+
+
+
}
+ private void addApp ()
+ {
+ mApp.setTorified(true);
+
+ String tordAppString = mPrefs.getString(PREFS_KEY_TORIFIED, "");
+
+ tordAppString = tordAppString += mApp.getPackageName()+"|";
+
+ SharedPreferences.Editor edit = mPrefs.edit();
+ edit.putString(PREFS_KEY_TORIFIED, tordAppString);
+ edit.commit();
+
+ Intent response = new Intent();
+ setResult(RESULT_OK,response);
+
+ }
private void removeApp ()
{
mApp.setTorified(false);
- SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
- String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
+ String tordAppString = mPrefs.getString(PREFS_KEY_TORIFIED, "");
tordAppString = tordAppString.replace(mApp.getPackageName()+"|","");
- SharedPreferences.Editor edit = prefs.edit();
+ SharedPreferences.Editor edit = mPrefs.edit();
edit.putString(PREFS_KEY_TORIFIED, tordAppString);
edit.commit();
Intent response = new Intent();
setResult(RESULT_OK,response);
- finish();
}
/*
@@ -91,6 +161,7 @@ public class AppConfigActivity extends AppCompatActivity {
}
else if (item.getItemId() == R.id.menu_remove_app) {
removeApp();
+ finish();
}
return super.onOptionsItemSelected(item);
diff --git a/app-mini/src/main/res/layout/content_app_config.xml b/app-mini/src/main/res/layout/content_app_config.xml
index 8e7b727e..3a8c41a8 100644
--- a/app-mini/src/main/res/layout/content_app_config.xml
+++ b/app-mini/src/main/res/layout/content_app_config.xml
@@ -33,6 +33,7 @@
/>
<Switch
+ android:id="@+id/switch_app_tor"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
@@ -64,6 +65,8 @@
android:layout_below="@+id/off_apps_title"
/>
<Switch
+ android:id="@+id/switch_app_data"
+
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
@@ -96,6 +99,9 @@
/>
<Switch
+
+ android:id="@+id/switch_app_wifi"
+
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
diff --git a/app-mini/src/main/res/values/strings.xml b/app-mini/src/main/res/values/strings.xml
index c7ae3edd..810ced96 100644
--- a/app-mini/src/main/res/values/strings.xml
+++ b/app-mini/src/main/res/values/strings.xml
@@ -264,8 +264,8 @@
<string name="title_boost_your_privacy">Boost Your Privacy</string>
<string name="send_your_app_traffic_over_tor">Send app data over Tor</string>
<string name="turn_off_apps">Turn off app data</string>
- <string name="stop_apps_from_using_the_network">Stop app from using the network</string>
+ <string name="stop_apps_from_using_the_network">Stop app from using the network (coming soon!)</string>
<string name="wifi_only">Wifi only</string>
- <string name="keep_your_apps_from_using_mobile_data">Only allow connection over wifi</string>
+ <string name="keep_your_apps_from_using_mobile_data">Only allow connection over wifi (coming soon!)</string>
<string name="remove">Remove</string>
</resources>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits