[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [orbot/master] make the VPN/apps mode have a better UI flow
commit 28f1dbf7ddeee85c438fad6e72f9c4bf235fec08
Author: Nathan Freitas <nathan@xxxxxxxxxxx>
Date: Mon Oct 24 14:30:46 2016 -0400
make the VPN/apps mode have a better UI flow
---
app/build.gradle | 1 +
app/src/main/AndroidManifest.xml | 4 +-
.../org/torproject/android/OrbotMainActivity.java | 28 +++++++++---
.../java/org/torproject/android/ui/AppManager.java | 51 +++++++++++-----------
app/src/main/res/drawable/rounded_button.xml | 13 ++++++
app/src/main/res/layout/layout_apps.xml | 15 ++-----
app/src/main/res/layout/layout_apps_item.xml | 1 +
app/src/main/res/layout/layout_main.xml | 12 +++--
app/src/main/res/menu/orbot_main.xml | 17 ++++----
app/src/main/res/values/colors.xml | 1 +
app/src/main/res/values/strings.xml | 2 +-
.../android/service/util/TorServiceUtils.java | 11 ++---
12 files changed, 93 insertions(+), 63 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 1b029de..8b7fbb6 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -30,4 +30,5 @@ dependencies {
compile project(':orbotservice')
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
+
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9b65a34..d0df9e3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -86,7 +86,9 @@
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
- <activity android:name=".ui.AppManager" android:label="@string/app_name"/>
+ <activity android:name=".ui.AppManager" android:label="@string/app_name"
+ android:theme="@style/Theme.AppCompat"
+ />
<service
android:name=".service.TorService"
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 5aa4cec..202cff5 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -22,6 +22,7 @@ import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.util.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences;
+import org.torproject.android.ui.AppManager;
import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.PromoAppsActivity;
import org.torproject.android.ui.Rotate3dAnimation;
@@ -111,6 +112,9 @@ public class OrbotMainActivity extends AppCompatActivity
private final static int REQUEST_VPN = 8888;
private final static int REQUEST_SETTINGS = 0x9874;
+ private final static int REQUEST_VPN_APPS_SELECT = 8889;
+
+ private final static boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
// message types for mStatusUpdateHandler
private final static int STATUS_UPDATE = 1;
@@ -169,7 +173,8 @@ public class OrbotMainActivity extends AppCompatActivity
private void stopTor() {
- imgStatus.setImageResource(R.drawable.torstarting);
+ requestTorStatus();
+
Intent torService = new Intent(OrbotMainActivity.this, TorService.class);
stopService(torService);
@@ -320,8 +325,12 @@ public class OrbotMainActivity extends AppCompatActivity
Prefs.putUseVpn(isChecked);
- if (isChecked)
- startActivity(new Intent(OrbotMainActivity.this,VPNEnableActivity.class));
+ if (isChecked) {
+ if (mIsLollipop) //let the user choose the apps
+ startActivityForResult(new Intent(OrbotMainActivity.this, AppManager.class),REQUEST_VPN_APPS_SELECT);
+ else
+ startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class));
+ }
else
stopVpnService();
}
@@ -434,11 +443,12 @@ public class OrbotMainActivity extends AppCompatActivity
Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class);
startActivityForResult(intent, REQUEST_SETTINGS);
}
+ /**
else if (item.getItemId() == R.id.menu_promo_apps)
{
startActivity(new Intent(OrbotMainActivity.this, PromoAppsActivity.class));
- }
+ }*/
else if (item.getItemId() == R.id.menu_exit)
{
//exit app
@@ -859,6 +869,10 @@ public class OrbotMainActivity extends AppCompatActivity
}
}
+ else if (request == REQUEST_VPN_APPS_SELECT)
+ {
+ startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class));
+ }
IntentResult scanResult = IntentIntegrator.parseActivityResult(request, response, data);
if (scanResult != null) {
@@ -1190,8 +1204,10 @@ public class OrbotMainActivity extends AppCompatActivity
}
else
lblStatus.setText(getString(R.string.status_starting_up));
-
- mBtnBrowser.setEnabled(false);
+
+ mBtnStart.setText("...");
+
+ mBtnBrowser.setEnabled(false);
} else if (torStatus == TorServiceConstants.STATUS_STOPPING) {
diff --git a/app/src/main/java/org/torproject/android/ui/AppManager.java b/app/src/main/java/org/torproject/android/ui/AppManager.java
index 82a20b3..84af48d 100644
--- a/app/src/main/java/org/torproject/android/ui/AppManager.java
+++ b/app/src/main/java/org/torproject/android/ui/AppManager.java
@@ -23,6 +23,8 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -38,7 +40,7 @@ import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
-public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, OrbotConstants {
+public class AppManager extends AppCompatActivity implements OnCheckedChangeListener, OnClickListener, OrbotConstants {
private ListView listApps;
private final static String TAG = "Orbot";
@@ -47,6 +49,8 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_apps);
+ setTitle(R.string.apps_mode);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Button buttonSelectAll, buttonSelectNone, buttonInvert;
@@ -108,15 +112,16 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
app = (TorifiedApp) adapter.getItem(i);
currentView = adapter.getView(i, parentView, viewGroup);
box = (CheckBox) currentView.findViewById(R.id.itemcheck);
+
if (this.status == 0){
- if (!box.isChecked())
- box.performClick();
+ app.setTorified(true);
}else if (this.status == 1){
- if (box.isChecked())
- box.performClick();
+ app.setTorified(false);
}else {
- box.performClick();
+ app.setTorified(!app.isTorified());
}
+
+ box.setChecked(app.isTorified());
}
saveAppSettings(context);
loadApps(prefs);
@@ -128,15 +133,6 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
super.onResume();
listApps = (ListView)findViewById(R.id.applistview);
- Button btnSave = (Button)findViewById(R.id.btnsave);
- btnSave.setOnClickListener(new OnClickListener()
- {
-
- public void onClick(View v) {
- finish();
- }
- });
-
mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
loadApps(mPrefs);
}
@@ -161,11 +157,18 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
final LayoutInflater inflater = getLayoutInflater();
ListAdapter adapter = new ArrayAdapter<TorifiedApp>(this, R.layout.layout_apps_item, R.id.itemtext,mApps) {
+
public View getView(int position, View convertView, ViewGroup parent) {
- ListEntry entry;
- if (convertView == null) {
- // Inflate a new view
+
+ ListEntry entry = null;
+
+ if (convertView == null)
convertView = inflater.inflate(R.layout.layout_apps_item, parent, false);
+ else
+ entry = (ListEntry) convertView.getTag();;
+
+ if (entry == null) {
+ // Inflate a new view
entry = new ListEntry();
entry.icon = (ImageView) convertView.findViewById(R.id.itemicon);
entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
@@ -177,19 +180,15 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
convertView.setTag(entry);
entry.box.setOnCheckedChangeListener(AppManager.this);
- } else {
- // Convert an existing view
- entry = (ListEntry) convertView.getTag();
}
-
-
+
final TorifiedApp app = mApps.get(position);
-
- if (app.getIcon() != null)
+
+ if (app.getIcon() != null && entry.icon != null)
entry.icon.setImageDrawable(app.getIcon());
else
entry.icon.setVisibility(View.GONE);
-
+
entry.text.setText(app.getName());
final CheckBox box = entry.box;
diff --git a/app/src/main/res/drawable/rounded_button.xml b/app/src/main/res/drawable/rounded_button.xml
new file mode 100644
index 0000000..528cc41
--- /dev/null
+++ b/app/src/main/res/drawable/rounded_button.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+
+ <corners android:radius="15dp"/> // if you want clear round shape then make radius size is half of your button`s height.
+ <solid android:color="#78af52"/> // Button Colour
+ <padding
+ android:bottom="3dp"
+ android:left="3dp"
+ android:right="3dp"
+ android:top="3dp"/>
+
+</shape>
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_apps.xml b/app/src/main/res/layout/layout_apps.xml
index d3633a0..00d46d6 100644
--- a/app/src/main/res/layout/layout_apps.xml
+++ b/app/src/main/res/layout/layout_apps.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:duplicateParentState="true">
@@ -25,20 +25,11 @@
</ListView>
- <Button
- android:id="@+id/btnsave"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentStart="true"
- android:layout_alignParentLeft="true"
- android:text="@string/button_close" />
-
<RelativeLayout
android:id="@+id/layout_button_filters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_above="@+id/btnsave"
+ android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
diff --git a/app/src/main/res/layout/layout_apps_item.xml b/app/src/main/res/layout/layout_apps_item.xml
index 9d16efd..c16d1cd 100644
--- a/app/src/main/res/layout/layout_apps_item.xml
+++ b/app/src/main/res/layout/layout_apps_item.xml
@@ -5,6 +5,7 @@
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
+
<ImageView android:id="@+id/itemicon" android:layout_width="50dip" android:layout_height="50dip" android:padding="3dip"></ImageView>
<TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages" android:textSize="18sp" android:padding="3dip"></TextView>
diff --git a/app/src/main/res/layout/layout_main.xml b/app/src/main/res/layout/layout_main.xml
index 8692bc1..2759cf5 100644
--- a/app/src/main/res/layout/layout_main.xml
+++ b/app/src/main/res/layout/layout_main.xml
@@ -4,7 +4,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
-
+
+ android:background="@color/dark_purple"
>
<android.support.v7.widget.Toolbar
@@ -67,9 +68,10 @@ android:layout_gravity="center_horizontal|center_vertical"/>
>
<Button
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="40dp"
android:text="@string/menu_start"
android:id="@+id/btnStart"
+ android:background="@drawable/rounded_button"
/>
@@ -77,11 +79,13 @@ android:layout_gravity="center_horizontal|center_vertical"/>
<Button
android:id="@+id/btnBrowser"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="40dp"
android:text="@string/menu_browse"
android:ellipsize="end"
android:singleLine="true"
- />
+ android:background="@drawable/rounded_button"
+ android:layout_marginLeft="10dp"
+ />
</LinearLayout>
</LinearLayout>
diff --git a/app/src/main/res/menu/orbot_main.xml b/app/src/main/res/menu/orbot_main.xml
index 9f97a81..54d2493 100644
--- a/app/src/main/res/menu/orbot_main.xml
+++ b/app/src/main/res/menu/orbot_main.xml
@@ -24,46 +24,47 @@
<item android:id="@+id/menu_settings"
android:title="@string/menu_settings"
android:icon="@drawable/ic_action_settings"
- yourapp:showAsAction="always"
+ yourapp:showAsAction="never"
/>
<item
android:title="@string/menu_qr"
- android:showAsAction="never"
+ yourapp:showAsAction="never"
>
<menu>
<item android:id="@+id/menu_scan"
android:title="@string/menu_scan"
- android:showAsAction="never"
+ yourapp:showAsAction="never"
/>
<item android:id="@+id/menu_share_bridge"
android:title="@string/menu_share_bridge"
- android:showAsAction="never"
+ yourapp:showAsAction="never"
/>
</menu>
</item>
-
+ <!--
<item android:id="@+id/menu_promo_apps"
android:title="@string/menu_promo_apps"
android:icon="@drawable/ic_menu_goto"
- android:showAsAction="never"
+ yourapp:showAsAction="never"
/>
+ -->
<item android:id="@+id/menu_about"
android:title="@string/menu_about"
android:icon="@drawable/ic_menu_about"
- android:showAsAction="never"
+ yourapp:showAsAction="never"
/>
<item android:id="@+id/menu_exit"
android:title="@string/menu_exit"
android:icon="@drawable/ic_menu_exit"
- android:showAsAction="never"
+ yourapp:showAsAction="never"
/>
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 19e06e7..af92426 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -5,4 +5,5 @@
<color name="panel_background_main">#efefef</color>
<color name="bright_green">#ccff2a</color>
<color name="dark_green">#669901</color>
+ <color name="dark_purple">#3f2b4f</color>
</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bef8abe..7f4f15a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -335,5 +335,5 @@
<string name="note_only_standard_tor_bridges_work_on_intel_x86_atom_devices">NOTE: Only standard Tor bridges work on Intel X86/ATOM devices</string>
- <string name="vpn_default_world">World</string>
+ <string name="vpn_default_world">World (Location)</string>
</resources>
diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
index 9fa8bb8..764bc9e 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
@@ -146,11 +146,12 @@ public class TorServiceUtils implements TorServiceConstants {
shell = Shell.startShell();
}*/
- Runtime.getRuntime().exec("busybox killall " + signal + " " + fileProcBin.getName());
- Runtime.getRuntime().exec("toolbox kill " + signal + " " + pidString);
- Runtime.getRuntime().exec("busybox kill " + signal + " " + pidString);
- Runtime.getRuntime().exec("kill " + signal + " " + pidString);
- try {
+ try { Runtime.getRuntime().exec("busybox killall " + signal + " " + fileProcBin.getName());}catch(IOException ioe){}
+ try { Runtime.getRuntime().exec("toolbox kill " + signal + " " + pidString);}catch(IOException ioe){}
+ try { Runtime.getRuntime().exec("busybox kill " + signal + " " + pidString);}catch(IOException ioe){}
+ try { Runtime.getRuntime().exec("kill " + signal + " " + pidString);}catch(IOException ioe){}
+
+ try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignored
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits