From 17934e6b338e37e1f80c721dbe9c60757db008a6 Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Thu, 8 May 2014 09:52:11 -0400 Subject: [PATCH] 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 bdfdc5be..e7a491f7 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; @@ -604,6 +604,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 {