commit e84ee7101d50ba94aea419a9c2044eeab693c534 Author: Nathan Freitas nathan@freitas.net Date: Fri Aug 23 12:47:31 2013 -0400
added GUI support for flinging to a newnym identity --- res/drawable/torstarting.png | Bin 74011 -> 77523 bytes res/raw/torrc | 6 ++- res/values/strings.xml | 1 + src/org/torproject/android/Orbot.java | 68 +++++++++++++++++++++++++++++++-- 4 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/res/drawable/torstarting.png b/res/drawable/torstarting.png index 31c4dd7..7cbf9fe 100644 Binary files a/res/drawable/torstarting.png and b/res/drawable/torstarting.png differ diff --git a/res/raw/torrc b/res/raw/torrc index fd5b506..e7dc4b2 100644 --- a/res/raw/torrc +++ b/res/raw/torrc @@ -4,11 +4,13 @@ SafeSocks 0 TestSocks 1 WarnUnsafeSocks 1 Log notice stdout -ControlPort 9051 ControlListenAddress 127.0.0.1 +ControlPort 9051 CookieAuthentication 1 TransPort 9040 TransListenAddress 127.0.0.1 DNSPort 5400 DNSListenAddress 127.0.0.1 -AvoidDiskWrites 1 \ No newline at end of file +AvoidDiskWrites 1 +AutomapHostsOnResolve 1 +VirtualAddrNetwork 10.192.0.0/10 \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index bca3086..2d0c671 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -240,4 +240,5 @@ <string name="up">up</string> <string name="pref_disable_network_title">Network Auto-Sleep</string> <string name="pref_disable_network_summary">Put Tor to sleep when there is no network connectivity</string> + <string name="newnym">You've switched to a new Tor identity!</string> </resources> diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java index 9f4229b..1ac1656 100644 --- a/src/org/torproject/android/Orbot.java +++ b/src/org/torproject/android/Orbot.java @@ -27,7 +27,6 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; -import android.drm.DrmStore.Action; import android.net.Uri; import android.os.Bundle; import android.os.Handler; @@ -39,11 +38,15 @@ import android.text.ClipboardManager; import android.text.Layout; import android.text.method.ScrollingMovementMethod; import android.util.Log; +import android.view.GestureDetector; +import android.view.GestureDetector.SimpleOnGestureListener; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnLongClickListener; import android.view.View.OnTouchListener; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.Animation; import android.widget.Button; import android.widget.SlidingDrawer; import android.widget.TextView; @@ -55,7 +58,7 @@ import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem;
-public class Orbot extends SherlockActivity implements TorConstants, OnLongClickListener, OnSharedPreferenceChangeListener +public class Orbot extends SherlockActivity implements TorConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener { /* Useful UI bits */ private TextView lblStatus = null; //the main text display widget @@ -125,6 +128,8 @@ public class Orbot extends SherlockActivity implements TorConstants, OnLongClick imgStatus = (ImageProgressView)findViewById(R.id.imgStatus); imgStatus.setOnLongClickListener(this); + imgStatus.setOnTouchListener(this); + downloadText = (TextView)findViewById(R.id.trafficDown); uploadText = (TextView)findViewById(R.id.trafficUp); mTxtOrbotLog = (TextView)findViewById(R.id.orbotLog); @@ -168,8 +173,22 @@ public class Orbot extends SherlockActivity implements TorConstants, OnLongClick uploadText.setText(formatCount(0) + " / " + formatTotal(0)); updateStatus(""); + + + // Gesture detection + mGestureDetector = new GestureDetector(this, new MyGestureDetector()); + } + + GestureDetector mGestureDetector;
+ + @Override + public boolean onTouch(View v, MotionEvent event) { + return mGestureDetector.onTouchEvent(event); + + } + private void appendLogTextAndScroll(String text) { if(mTxtOrbotLog != null){ @@ -1202,5 +1221,48 @@ public class Orbot extends SherlockActivity implements TorConstants, OnLongClick } - + + private static final float ROTATE_FROM = 0.0f; + private static final float ROTATE_TO = 360.0f*4f;// 3.141592654f * 32.0f; + + public void spinOrbot (float direction) + { + try { + mService.newIdentity(); //request a new identity + + Toast.makeText(this, R.string.newnym, Toast.LENGTH_SHORT).show(); + + // Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); + Rotate3dAnimation rotation = new Rotate3dAnimation(ROTATE_FROM, ROTATE_TO*direction, 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); + + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + class MyGestureDetector extends SimpleOnGestureListener { + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { + try { + if (torStatus == TorServiceConstants.STATUS_ON) + { + float direction = 1f; + if (velocityX < 0) + direction = -1f; + spinOrbot (direction); + } + } catch (Exception e) { + // nothing + } + return false; + } + + } + }
tor-commits@lists.torproject.org