[tor-commits] [orbot/master] initial support for setting bridge through URL

n8fr8 at torproject.org n8fr8 at torproject.org
Thu May 8 13:56:29 UTC 2014


commit 17934e6b338e37e1f80c721dbe9c60757db008a6
Author: Nathan Freitas <nathan at freitas.net>
Date:   Thu May 8 09:52:11 2014 -0400

    initial support for setting bridge through URL
---
 src/org/torproject/android/Orbot.java |   23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/org/torproject/android/Orbot.java b/src/org/torproject/android/Orbot.java
index bdfdc5b..e7a491f 100644
--- a/src/org/torproject/android/Orbot.java
+++ b/src/org/torproject/android/Orbot.java
@@ -5,6 +5,7 @@ package org.torproject.android;
 
 import static org.torproject.android.TorConstants.TAG;
 
+import java.net.URLDecoder;
 import java.util.Locale;
 
 import org.torproject.android.service.ITorService;
@@ -546,7 +547,6 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 	    String action = intent.getAction();
 	    String type = intent.getType();
 		
-		
 		if (action == null)
 			return;
 		
@@ -605,6 +605,27 @@ public class Orbot extends ActionBarActivity implements TorConstants, OnLongClic
 			
 			
 		}
+		else if (action.equals(Intent.ACTION_VIEW))
+		{
+			String urlString = intent.getDataString();
+			
+			if (urlString != null)
+			{
+				
+				if (urlString.toLowerCase().startsWith("bridge://"))
+				{
+					String newBridgeValue = urlString.substring(9); //remove the bridge protocol piece
+					newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here
+					
+					SharedPreferences mPrefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
+					Editor pEdit = mPrefs.edit();
+					
+					pEdit.putString(TorConstants.PREF_BRIDGES_LIST,newBridgeValue); //set the string to a preference
+				
+					pEdit.commit();
+				}
+			}
+		}
 		else
 		{
 		





More information about the tor-commits mailing list