commit 6a19bf6c8e6de9057f217addc72eff69c2b09508 Author: n8fr8 nathan@freitas.net Date: Thu Dec 7 16:58:16 2017 -0500
update UI tweaks for next release --- .../org/torproject/android/OrbotMainActivity.java | 108 +++++++-------- app/src/main/res/layout-land/layout_main.xml | 153 --------------------- app/src/main/res/layout/layout_main.xml | 112 ++++++++------- app/src/main/res/layout/layout_orbot_control.xml | 11 -- .../org/torproject/android/service/TorService.java | 2 +- 5 files changed, 104 insertions(+), 282 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index dcae5305..e53c8841 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -57,6 +57,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.RemoteException; +import android.support.design.widget.Snackbar; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarDrawerToggle; @@ -64,6 +65,7 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SwitchCompat; import android.support.v7.widget.Toolbar; import android.text.Html; +import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; @@ -102,8 +104,7 @@ public class OrbotMainActivity extends AppCompatActivity private TextView downloadText = null; private TextView uploadText = null; private TextView mTxtOrbotLog = null; - - private Button mBtnBrowser = null; + private Button mBtnStart = null;
private SwitchCompat mBtnVPN = null; @@ -308,19 +309,6 @@ public class OrbotMainActivity extends AppCompatActivity } });
- mBtnBrowser = (Button)findViewById(R.id.btnBrowser); - mBtnBrowser.setOnClickListener(new View.OnClickListener () - { - - @Override - public void onClick(View v) { - doTorCheck(); - - } - - }); - - mBtnBrowser.setEnabled(false);
mBtnVPN = (SwitchCompat)findViewById(R.id.btnVPN); @@ -757,7 +745,7 @@ public class OrbotMainActivity extends AppCompatActivity } }
- private synchronized void handleIntents() { + private void handleIntents() { if (getIntent() == null) return;
@@ -832,7 +820,7 @@ public class OrbotMainActivity extends AppCompatActivity break; }
- updateStatus(null); + updateStatus(null, torStatus);
setIntent(null);
@@ -1183,7 +1171,7 @@ public class OrbotMainActivity extends AppCompatActivity
requestTorStatus();
- updateStatus(null); + updateStatus(null, torStatus);
if (Prefs.useTransparentProxying()) { @@ -1234,27 +1222,32 @@ public class OrbotMainActivity extends AppCompatActivity * Update the layout_main UI based on the status of {@link TorService}. * {@code torServiceMsg} must never be {@code null} */ - private void updateStatus(String torServiceMsg) { + private void updateStatus(String torServiceMsg, String newTorStatus) { + + if (!TextUtils.isEmpty(torServiceMsg)) + { + if (torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_HEADER)) { + lblStatus.setText(torServiceMsg); + } + + mTxtOrbotLog.append(torServiceMsg + '\n'); + + } + + if (torStatus == null || newTorStatus.equals(torStatus)) { + torStatus = newTorStatus; + return; + } + else + torStatus = newTorStatus;
- if (torStatus == null) - return; //UI not init'd yet - if (torStatus == TorServiceConstants.STATUS_ON) { imgStatus.setImageResource(R.drawable.toron);
- mBtnBrowser.setEnabled(true); - mBtnStart.setText(R.string.menu_stop); - - if (torServiceMsg != null) - { - if (torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_HEADER)) { - lblStatus.setText(torServiceMsg); - } - } - else - lblStatus.setText(getString(R.string.status_activated)); + mBtnStart.setText(R.string.menu_stop);
+ lblStatus.setText(getString(R.string.status_activated));
boolean showFirstTime = mPrefs.getBoolean("connect_first_time", true);
@@ -1266,21 +1259,32 @@ public class OrbotMainActivity extends AppCompatActivity showAlert(getString(R.string.status_activated), getString(R.string.connect_first_time), true); } + else + { + Snackbar sb = Snackbar.make(findViewById(R.id.frameMain),getString(R.string.status_activated),Snackbar.LENGTH_LONG); + sb.setAction(R.string.menu_browse, new View.OnClickListener() { + @Override + public void onClick(View v) { + doTorCheck(); + } + }); + sb.show(); + }
if (autoStartFromIntent) { autoStartFromIntent = false; Intent resultIntent = lastStatusIntent;
- if (resultIntent == null) - resultIntent = new Intent(TorServiceConstants.ACTION_START); + if (resultIntent == null) + resultIntent = new Intent(TorServiceConstants.ACTION_START);
- resultIntent.putExtra( - TorServiceConstants.EXTRA_STATUS, - torStatus == null?TorServiceConstants.STATUS_OFF:torStatus - ); + resultIntent.putExtra( + TorServiceConstants.EXTRA_STATUS, + torStatus == null?TorServiceConstants.STATUS_OFF:torStatus + );
- setResult(RESULT_OK, resultIntent); + setResult(RESULT_OK, resultIntent);
finish(); Log.d(TAG, "autoStartFromIntent finish"); @@ -1302,8 +1306,6 @@ public class OrbotMainActivity extends AppCompatActivity
mBtnStart.setText("...");
- mBtnBrowser.setEnabled(false); - } else if (torStatus == TorServiceConstants.STATUS_STOPPING) {
if (torServiceMsg != null && torServiceMsg.contains(TorServiceConstants.LOG_NOTICE_HEADER)) @@ -1311,22 +1313,16 @@ public class OrbotMainActivity extends AppCompatActivity imgStatus.setImageResource(R.drawable.torstarting); lblStatus.setText(torServiceMsg); - mBtnBrowser.setEnabled(false);
} else if (torStatus == TorServiceConstants.STATUS_OFF) {
imgStatus.setImageResource(R.drawable.toroff); - // lblStatus.setText(getString(R.string.press_to_start)); - mBtnBrowser.setEnabled(false);
mBtnStart.setText(R.string.menu_start);
}
- if (torServiceMsg != null && torServiceMsg.length() > 0) - { - mTxtOrbotLog.append(torServiceMsg + '\n'); - } + }
/** @@ -1385,22 +1381,16 @@ public class OrbotMainActivity extends AppCompatActivity
if (torStatus == null && newTorStatus != null) //first time status { - torStatus = newTorStatus; findViewById(R.id.frameMain).setVisibility(View.VISIBLE); - updateStatus(log); + updateStatus(log, newTorStatus); //now you can handle the intents properly handleIntents(); } - else if (newTorStatus != null && !torStatus.equals(newTorStatus)) //status changed - { - torStatus = newTorStatus; - updateStatus(log); - } - else if (log != null) //it is just a log - updateStatus(log); - + else + updateStatus(log, newTorStatus); + switch (msg.what) { case MESSAGE_TRAFFIC_COUNT:
diff --git a/app/src/main/res/layout-land/layout_main.xml b/app/src/main/res/layout-land/layout_main.xml deleted file mode 100644 index fc8b2447..00000000 --- a/app/src/main/res/layout-land/layout_main.xml +++ /dev/null @@ -1,153 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout android:gravity="center_vertical|center_horizontal" - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - - android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="match_parent" - - android:background="@color/dark_purple" - > - - <android.support.v7.widget.Toolbar - android:id="@+id/toolbar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="?attr/actionBarSize" /> - <android.support.v4.widget.DrawerLayout - android:id="@+id/drawer_layout" - android:layout_width="match_parent" - android:layout_height="match_parent" - > - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:id="@+id/content_frame" - - > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="400dp" - android:id="@+id/frameMain" - android:visibility="visible" - android:orientation="vertical" - android:layout_centerVertical="true" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true"> - <org.torproject.android.ui.ImageProgressView - android:id="@+id/imgStatus" - android:layout_width="match_parent" - android:layout_height="180dp" - android:padding="0dp" - android:layout_margin="0dp" - android:src="@drawable/toroff" /> - - - <LinearLayout android:gravity="center_horizontal" - android:orientation="horizontal" android:layout_width="match_parent" - android:layout_height="wrap_content" - - > - <Button - android:layout_width="wrap_content" - android:layout_height="40dp" - android:text="@string/menu_start" - android:id="@+id/btnStart" - android:background="@drawable/rounded_button" - - /> - - - <Button - android:id="@+id/btnBrowser" - android:layout_width="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" - /> - <Button - android:id="@+id/btnApps" - android:layout_width="wrap_content" - android:layout_height="40dp" - android:text="@string/menu_apps" - android:ellipsize="end" - android:singleLine="true" - android:background="@drawable/rounded_button" - android:layout_marginLeft="10dp" - /> - </LinearLayout> - - </LinearLayout> - - - <TextView - android:id="@+id/lblStatus" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textSize="14sp" - android:fontFamily="sans-serif-light" - android:text="" - android:lines="1" - android:maxLines="1" - android:layout_margin="12dp" - android:layout_alignParentBottom="true" - android:gravity="center" - android:ellipsize="end" - /> - - </RelativeLayout> - - - <LinearLayout - android:layout_width="250dp" - android:layout_height="match_parent" - android:orientation="vertical" - android:id="@+id/left_drawer" - android:layout_gravity="start" - android:background="#333333" - > - - <include layout="@layout/layout_orbot_control"/> - - - </LinearLayout> - - <LinearLayout - android:layout_width="320dp" - android:layout_height="match_parent" - android:orientation="vertical" - android:id="@+id/right_drawer" - android:layout_gravity="end" - android:background="#333333" - android:padding="6dp" - > - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="@string/menu_log" - android:textAppearance="?android:attr/textAppearanceMedium" - /> - <TextView - android:id="@+id/orbotLog" - android:textSize="12sp" - android:gravity="start" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_marginTop="10dp" - android:textIsSelectable="true" - android:fontFamily="monospace" - /> - </LinearLayout> - - </android.support.v4.widget.DrawerLayout> - -</LinearLayout> - - diff --git a/app/src/main/res/layout/layout_main.xml b/app/src/main/res/layout/layout_main.xml index e8c93336..20237bdf 100644 --- a/app/src/main/res/layout/layout_main.xml +++ b/app/src/main/res/layout/layout_main.xml @@ -1,12 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:gravity="center_vertical|center_horizontal" - xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="match_parent" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"
android:background="@color/dark_purple" - > + xmlns:app="http://schemas.android.com/apk/res-auto%22%3E
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" @@ -26,87 +27,82 @@
>
- <LinearLayout + <FrameLayout android:layout_width="match_parent" - android:layout_height="400dp" + android:layout_height="250dp" android:id="@+id/frameMain" android:visibility="visible" android:orientation="vertical" - android:layout_centerVertical="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" + android:layout_marginTop="20dp" android:weightSum="1"> <org.torproject.android.ui.ImageProgressView android:id="@+id/imgStatus" android:layout_width="match_parent" - android:layout_height="275dp" - + android:layout_height="225dp" android:padding="0dp" android:layout_margin="0dp" android:src="@drawable/toroff" /> +<Button + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/btnStart" + android:text="@string/menu_start" + android:layout_gravity="center" + />
+ </FrameLayout>
- </LinearLayout>
+ <TextView + android:id="@+id/lblStatus" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="14sp" + android:fontFamily="sans-serif-light" + android:lines="1" + android:text="---" + android:maxLines="1" + android:layout_margin="12dp" + android:ellipsize="end" + android:layout_gravity="top|center" + android:gravity="center" + android:layout_below="@+id/frameMain" + />
- <TextView - android:id="@+id/lblStatus" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:textSize="14sp" - android:fontFamily="sans-serif-light" - android:text="" - android:lines="1" - android:maxLines="1" - android:layout_margin="12dp" - android:layout_above="@+id/button_row" - android:gravity="center" - android:ellipsize="end" - />
<LinearLayout - android:id="@+id/button_row" + android:id="@+id/row_vpn" android:gravity="center_horizontal|bottom" android:layout_gravity="bottom" android:orientation="horizontal" android:layout_width="match_parent" - android:layout_alignParentBottom="true" - android:layout_margin="6dp" android:layout_height="wrap_content" - + android:layout_alignParentBottom="true" > - <Button - android:layout_width="wrap_content" - android:layout_height="40dp" - android:text="@string/menu_start" - android:id="@+id/btnStart" - android:background="@drawable/rounded_button" - - /> - - - <Button - android:id="@+id/btnBrowser" - android:layout_width="wrap_content" - android:layout_height="40dp" - android:text="@string/menu_browse" - android:ellipsize="end" - android:maxLines="1" - android:background="@drawable/rounded_button" - android:layout_marginLeft="10dp" - /> - <Button - android:id="@+id/btnApps" - android:layout_width="wrap_content" - android:layout_height="40dp" - android:text="@string/menu_apps" - android:ellipsize="end" - android:maxLines="1" - android:background="@drawable/rounded_button" - android:layout_marginLeft="10dp" - /> + <android.support.v7.widget.SwitchCompat + android:id="@+id/btnVPN" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/apps_mode" + android:layout_margin="12dp" + android:layout_gravity="center" + app:switchPadding="9dp" + + /> + <Button + android:id="@+id/btnApps" + android:layout_width="wrap_content" + android:layout_height="40dp" + android:text="@string/menu_apps" + android:ellipsize="end" + android:maxLines="1" + android:layout_gravity="center" + + /> </LinearLayout>
diff --git a/app/src/main/res/layout/layout_orbot_control.xml b/app/src/main/res/layout/layout_orbot_control.xml index bfe50cd7..4df63591 100644 --- a/app/src/main/res/layout/layout_orbot_control.xml +++ b/app/src/main/res/layout/layout_orbot_control.xml @@ -13,17 +13,6 @@
<android.support.v7.widget.SwitchCompat - android:id="@+id/btnVPN" - android:layout_width="200dp" - android:layout_height="wrap_content" - android:text="@string/apps_mode" - android:layout_margin="12dp" - android:singleLine="true" - app:switchPadding="9dp" - /> - - - <android.support.v7.widget.SwitchCompat android:id="@+id/btnBridges" android:layout_width="200dp" android:layout_height="wrap_content" diff --git a/orbotservice/src/main/java/org/torproject/android/service/TorService.java b/orbotservice/src/main/java/org/torproject/android/service/TorService.java index e90123f6..077cc702 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/TorService.java +++ b/orbotservice/src/main/java/org/torproject/android/service/TorService.java @@ -635,7 +635,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon OtherResourceInstaller oInstaller = new OtherResourceInstaller(this, appBinHome); oInstaller.installResources(); } - +
updateTorConfigFile (); isTorUpgradeAndConfigComplete = true;
tor-commits@lists.torproject.org