make the VPN/apps mode have a better UI flow

This commit is contained in:
Nathan Freitas 2016-10-24 14:30:46 -04:00
parent c1ffdbb4e7
commit 28f1dbf7dd
12 changed files with 93 additions and 63 deletions

View File

@ -30,4 +30,5 @@ dependencies {
compile project(':orbotservice') compile project(':orbotservice')
compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:appcompat-v7:23.4.0'
} }

View File

@ -86,7 +86,9 @@
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/> <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 <service
android:name=".service.TorService" android:name=".service.TorService"

View File

@ -22,6 +22,7 @@ import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants; import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.util.TorServiceUtils; import org.torproject.android.service.util.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences; import org.torproject.android.settings.SettingsPreferences;
import org.torproject.android.ui.AppManager;
import org.torproject.android.ui.ImageProgressView; import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.PromoAppsActivity; import org.torproject.android.ui.PromoAppsActivity;
import org.torproject.android.ui.Rotate3dAnimation; 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_VPN = 8888;
private final static int REQUEST_SETTINGS = 0x9874; 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 // message types for mStatusUpdateHandler
private final static int STATUS_UPDATE = 1; private final static int STATUS_UPDATE = 1;
@ -169,7 +173,8 @@ public class OrbotMainActivity extends AppCompatActivity
private void stopTor() { private void stopTor() {
imgStatus.setImageResource(R.drawable.torstarting); requestTorStatus();
Intent torService = new Intent(OrbotMainActivity.this, TorService.class); Intent torService = new Intent(OrbotMainActivity.this, TorService.class);
stopService(torService); stopService(torService);
@ -320,8 +325,12 @@ public class OrbotMainActivity extends AppCompatActivity
Prefs.putUseVpn(isChecked); Prefs.putUseVpn(isChecked);
if (isChecked) 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)); startActivity(new Intent(OrbotMainActivity.this, VPNEnableActivity.class));
}
else else
stopVpnService(); stopVpnService();
} }
@ -434,11 +443,12 @@ public class OrbotMainActivity extends AppCompatActivity
Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class); Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class);
startActivityForResult(intent, REQUEST_SETTINGS); startActivityForResult(intent, REQUEST_SETTINGS);
} }
/**
else if (item.getItemId() == R.id.menu_promo_apps) else if (item.getItemId() == R.id.menu_promo_apps)
{ {
startActivity(new Intent(OrbotMainActivity.this, PromoAppsActivity.class)); startActivity(new Intent(OrbotMainActivity.this, PromoAppsActivity.class));
} }*/
else if (item.getItemId() == R.id.menu_exit) else if (item.getItemId() == R.id.menu_exit)
{ {
//exit app //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); IntentResult scanResult = IntentIntegrator.parseActivityResult(request, response, data);
if (scanResult != null) { if (scanResult != null) {
@ -1191,6 +1205,8 @@ public class OrbotMainActivity extends AppCompatActivity
else else
lblStatus.setText(getString(R.string.status_starting_up)); lblStatus.setText(getString(R.string.status_starting_up));
mBtnStart.setText("...");
mBtnBrowser.setEnabled(false); mBtnBrowser.setEnabled(false);
} else if (torStatus == TorServiceConstants.STATUS_STOPPING) { } else if (torStatus == TorServiceConstants.STATUS_STOPPING) {

View File

@ -23,6 +23,8 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -38,7 +40,7 @@ import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; 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 ListView listApps;
private final static String TAG = "Orbot"; private final static String TAG = "Orbot";
@ -47,6 +49,8 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_apps); this.setContentView(R.layout.layout_apps);
setTitle(R.string.apps_mode);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Button buttonSelectAll, buttonSelectNone, buttonInvert; Button buttonSelectAll, buttonSelectNone, buttonInvert;
@ -108,15 +112,16 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
app = (TorifiedApp) adapter.getItem(i); app = (TorifiedApp) adapter.getItem(i);
currentView = adapter.getView(i, parentView, viewGroup); currentView = adapter.getView(i, parentView, viewGroup);
box = (CheckBox) currentView.findViewById(R.id.itemcheck); box = (CheckBox) currentView.findViewById(R.id.itemcheck);
if (this.status == 0){ if (this.status == 0){
if (!box.isChecked()) app.setTorified(true);
box.performClick();
}else if (this.status == 1){ }else if (this.status == 1){
if (box.isChecked()) app.setTorified(false);
box.performClick();
}else { }else {
box.performClick(); app.setTorified(!app.isTorified());
} }
box.setChecked(app.isTorified());
} }
saveAppSettings(context); saveAppSettings(context);
loadApps(prefs); loadApps(prefs);
@ -128,15 +133,6 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
super.onResume(); super.onResume();
listApps = (ListView)findViewById(R.id.applistview); 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()); mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
loadApps(mPrefs); loadApps(mPrefs);
} }
@ -161,11 +157,18 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
final LayoutInflater inflater = getLayoutInflater(); final LayoutInflater inflater = getLayoutInflater();
ListAdapter adapter = new ArrayAdapter<TorifiedApp>(this, R.layout.layout_apps_item, R.id.itemtext,mApps) { ListAdapter adapter = new ArrayAdapter<TorifiedApp>(this, R.layout.layout_apps_item, R.id.itemtext,mApps) {
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
ListEntry entry;
if (convertView == null) { ListEntry entry = null;
// Inflate a new view
if (convertView == null)
convertView = inflater.inflate(R.layout.layout_apps_item, parent, false); 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 = new ListEntry();
entry.icon = (ImageView) convertView.findViewById(R.id.itemicon); entry.icon = (ImageView) convertView.findViewById(R.id.itemicon);
entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck); entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
@ -177,15 +180,11 @@ public class AppManager extends Activity implements OnCheckedChangeListener, OnC
convertView.setTag(entry); convertView.setTag(entry);
entry.box.setOnCheckedChangeListener(AppManager.this); entry.box.setOnCheckedChangeListener(AppManager.this);
} else {
// Convert an existing view
entry = (ListEntry) convertView.getTag();
} }
final TorifiedApp app = mApps.get(position); final TorifiedApp app = mApps.get(position);
if (app.getIcon() != null) if (app.getIcon() != null && entry.icon != null)
entry.icon.setImageDrawable(app.getIcon()); entry.icon.setImageDrawable(app.getIcon());
else else
entry.icon.setVisibility(View.GONE); entry.icon.setVisibility(View.GONE);

View File

@ -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>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:orientation="vertical"
android:duplicateParentState="true"> android:duplicateParentState="true">
@ -25,20 +25,11 @@
</ListView> </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 <RelativeLayout
android:id="@+id/layout_button_filters" android:id="@+id/layout_button_filters"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/btnsave" android:layout_alignParentBottom="true"
android:orientation="horizontal" > android:orientation="horizontal" >
<Button <Button

View File

@ -5,6 +5,7 @@
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:stretchColumns="1"> android:stretchColumns="1">
<TableRow> <TableRow>
<ImageView android:id="@+id/itemicon" android:layout_width="50dip" android:layout_height="50dip" android:padding="3dip"></ImageView> <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> <TextView android:layout_height="wrap_content" android:id="@+id/itemtext" android:text="uid:packages" android:textSize="18sp" android:padding="3dip"></TextView>

View File

@ -5,6 +5,7 @@
android:orientation="vertical" android:layout_width="match_parent" android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/dark_purple"
> >
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
@ -67,9 +68,10 @@ android:layout_gravity="center_horizontal|center_vertical"/>
> >
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="40dp"
android:text="@string/menu_start" android:text="@string/menu_start"
android:id="@+id/btnStart" android:id="@+id/btnStart"
android:background="@drawable/rounded_button"
/> />
@ -77,10 +79,12 @@ android:layout_gravity="center_horizontal|center_vertical"/>
<Button <Button
android:id="@+id/btnBrowser" android:id="@+id/btnBrowser"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="40dp"
android:text="@string/menu_browse" android:text="@string/menu_browse"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:background="@drawable/rounded_button"
android:layout_marginLeft="10dp"
/> />
</LinearLayout> </LinearLayout>

View File

@ -24,46 +24,47 @@
<item android:id="@+id/menu_settings" <item android:id="@+id/menu_settings"
android:title="@string/menu_settings" android:title="@string/menu_settings"
android:icon="@drawable/ic_action_settings" android:icon="@drawable/ic_action_settings"
yourapp:showAsAction="always" yourapp:showAsAction="never"
/> />
<item <item
android:title="@string/menu_qr" android:title="@string/menu_qr"
android:showAsAction="never" yourapp:showAsAction="never"
> >
<menu> <menu>
<item android:id="@+id/menu_scan" <item android:id="@+id/menu_scan"
android:title="@string/menu_scan" android:title="@string/menu_scan"
android:showAsAction="never" yourapp:showAsAction="never"
/> />
<item android:id="@+id/menu_share_bridge" <item android:id="@+id/menu_share_bridge"
android:title="@string/menu_share_bridge" android:title="@string/menu_share_bridge"
android:showAsAction="never" yourapp:showAsAction="never"
/> />
</menu> </menu>
</item> </item>
<!--
<item android:id="@+id/menu_promo_apps" <item android:id="@+id/menu_promo_apps"
android:title="@string/menu_promo_apps" android:title="@string/menu_promo_apps"
android:icon="@drawable/ic_menu_goto" android:icon="@drawable/ic_menu_goto"
android:showAsAction="never" yourapp:showAsAction="never"
/> />
-->
<item android:id="@+id/menu_about" <item android:id="@+id/menu_about"
android:title="@string/menu_about" android:title="@string/menu_about"
android:icon="@drawable/ic_menu_about" android:icon="@drawable/ic_menu_about"
android:showAsAction="never" yourapp:showAsAction="never"
/> />
<item android:id="@+id/menu_exit" <item android:id="@+id/menu_exit"
android:title="@string/menu_exit" android:title="@string/menu_exit"
android:icon="@drawable/ic_menu_exit" android:icon="@drawable/ic_menu_exit"
android:showAsAction="never" yourapp:showAsAction="never"
/> />

View File

@ -5,4 +5,5 @@
<color name="panel_background_main">#efefef</color> <color name="panel_background_main">#efefef</color>
<color name="bright_green">#ccff2a</color> <color name="bright_green">#ccff2a</color>
<color name="dark_green">#669901</color> <color name="dark_green">#669901</color>
<color name="dark_purple">#3f2b4f</color>
</resources> </resources>

View File

@ -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="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> </resources>

View File

@ -146,10 +146,11 @@ public class TorServiceUtils implements TorServiceConstants {
shell = Shell.startShell(); shell = Shell.startShell();
}*/ }*/
Runtime.getRuntime().exec("busybox killall " + signal + " " + fileProcBin.getName()); try { Runtime.getRuntime().exec("busybox killall " + signal + " " + fileProcBin.getName());}catch(IOException ioe){}
Runtime.getRuntime().exec("toolbox kill " + signal + " " + pidString); try { Runtime.getRuntime().exec("toolbox kill " + signal + " " + pidString);}catch(IOException ioe){}
Runtime.getRuntime().exec("busybox kill " + signal + " " + pidString); try { Runtime.getRuntime().exec("busybox kill " + signal + " " + pidString);}catch(IOException ioe){}
Runtime.getRuntime().exec("kill " + signal + " " + pidString); try { Runtime.getRuntime().exec("kill " + signal + " " + pidString);}catch(IOException ioe){}
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {