commit 8ebd53835ac9381e82e7aa6d4066d3cccad6fcbd Author: n8fr8 nathan@freitas.net Date: Fri May 11 23:02:22 2018 -0400
add NEWNYM feature back into main app screen --- .../org/torproject/android/OrbotMainActivity.java | 26 ++++++++++++++++++++-- app/src/main/res/menu/orbot_main.xml | 10 ++++++++- 2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java index c8a329c3..6fc5c456 100644 --- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java +++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java @@ -25,6 +25,7 @@ import org.torproject.android.service.util.TorServiceUtils; import org.torproject.android.settings.LocaleHelper; import org.torproject.android.settings.SettingsPreferences; import org.torproject.android.ui.AppManagerActivity; +import org.torproject.android.ui.Rotate3dAnimation; import org.torproject.android.ui.onboarding.BridgeWizardActivity; import org.torproject.android.ui.onboarding.OnboardingActivity; import org.torproject.android.ui.hiddenservices.ClientCookiesActivity; @@ -75,6 +76,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnLongClickListener; +import android.view.animation.AccelerateInterpolator; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; @@ -432,8 +434,12 @@ public class OrbotMainActivity extends AppCompatActivity
@Override public boolean onOptionsItemSelected(MenuItem item) { - - if (item.getItemId() == R.id.menu_settings) + + if (item.getItemId() == R.id.menu_newnym) + { + requestNewTorIdentity(); + } + else if (item.getItemId() == R.id.menu_settings) { Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class); startActivityForResult(intent, REQUEST_SETTINGS); @@ -1316,6 +1322,22 @@ public class OrbotMainActivity extends AppCompatActivity
}**/
+ private static final float ROTATE_FROM = 0.0f; + private static final float ROTATE_TO = 360.0f*4f;// 3.141592654f * 32.0f; + + private void requestNewTorIdentity () + { + sendIntentToService (TorServiceConstants.CMD_NEWNYM); + + Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO, imgStatus.getWidth()/2f,imgStatus.getWidth()/2f,20f,false); + rotation.setFillAfter(true); + rotation.setInterpolator(new AccelerateInterpolator()); + rotation.setDuration((long) 2*1000); + rotation.setRepeatCount(0); + imgStatus.startAnimation(rotation); + lblStatus.setText(getString(R.string.newnym)); + } + private void addAppShortcuts () { LinearLayout llBoxShortcuts = (LinearLayout)findViewById(R.id.boxAppShortcuts); diff --git a/app/src/main/res/menu/orbot_main.xml b/app/src/main/res/menu/orbot_main.xml index deed1a61..f965514c 100644 --- a/app/src/main/res/menu/orbot_main.xml +++ b/app/src/main/res/menu/orbot_main.xml @@ -21,7 +21,15 @@ xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
- <item android:id="@+id/menu_settings" + + <item android:id="@+id/menu_newnym" + android:title="@string/newnym" + android:icon="@drawable/ic_refresh_white_24dp" + yourapp:showAsAction="always" + /> + + + <item android:id="@+id/menu_settings" android:title="@string/menu_settings" android:icon="@drawable/ic_action_settings" yourapp:showAsAction="never"
tor-commits@lists.torproject.org