a little bit of code re-org and new package for wizard

This commit is contained in:
Nathan Freitas 2015-03-28 00:39:58 -04:00
parent 1a66924c39
commit 6a7c593353
14 changed files with 63 additions and 52 deletions

View File

@ -88,8 +88,8 @@
/> />
<activity android:name=".ui.TipsAndTricks" android:exported="false"/> <activity android:name="org.torproject.android.ui.wizard.TipsAndTricks" android:exported="false"/>
<activity android:name=".ui.ChooseLocaleWizardActivity" android:exported="false"/> org.torproject.android.ui.wizard.ChooseLocaleWizardActivityui.ChooseLocaleWizardActivity" android:exported="false"/>
<activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/> <activity android:name=".settings.SettingsPreferences" android:label="@string/app_name"/>
<activity android:name=".settings.AppManager" android:label="@string/app_name"/> <activity android:name=".settings.AppManager" android:label="@string/app_name"/>

View File

@ -26,6 +26,11 @@
yourapp:showAsAction="always" yourapp:showAsAction="always"
/> />
<item
android:title="@string/menu_qr"
yourapp:showAsAction="never"
>
<menu>
<item android:id="@+id/menu_scan" <item android:id="@+id/menu_scan"
android:title="@string/menu_scan" android:title="@string/menu_scan"
yourapp:showAsAction="never" yourapp:showAsAction="never"
@ -35,7 +40,8 @@
android:title="@string/menu_share_bridge" android:title="@string/menu_share_bridge"
yourapp:showAsAction="never" yourapp:showAsAction="never"
/> />
</menu>
</item>
<!-- <!--
<item android:id="@+id/menu_verify" <item android:id="@+id/menu_verify"

View File

@ -316,4 +316,6 @@
<string name="bridges_updated">Bridges Updated</string> <string name="bridges_updated">Bridges Updated</string>
<string name="restart_orbot_to_use_this_bridge_">"Restart Orbot to use these bridges: "</string> <string name="restart_orbot_to_use_this_bridge_">"Restart Orbot to use these bridges: "</string>
<string name="menu_qr">QR Codes</string>
</resources> </resources>

View File

@ -9,7 +9,7 @@ import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
public class OrbotApp extends Application implements TorConstants public class OrbotApp extends Application implements OrbotConstants
{ {
private Locale locale; private Locale locale;

View File

@ -3,7 +3,7 @@
package org.torproject.android; package org.torproject.android;
public interface TorConstants { public interface OrbotConstants {
public final static String TAG = "Orbot"; public final static String TAG = "Orbot";

View File

@ -13,10 +13,10 @@ import org.torproject.android.service.TorService;
import org.torproject.android.service.TorServiceConstants; import org.torproject.android.service.TorServiceConstants;
import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorServiceUtils;
import org.torproject.android.settings.SettingsPreferences; import org.torproject.android.settings.SettingsPreferences;
import org.torproject.android.ui.ChooseLocaleWizardActivity;
import org.torproject.android.ui.ImageProgressView; import org.torproject.android.ui.ImageProgressView;
import org.torproject.android.ui.Rotate3dAnimation; import org.torproject.android.ui.Rotate3dAnimation;
import org.torproject.android.ui.TipsAndTricks; import org.torproject.android.ui.wizard.ChooseLocaleWizardActivity;
import org.torproject.android.ui.wizard.TipsAndTricks;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
@ -67,7 +67,7 @@ import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult; import com.google.zxing.integration.android.IntentResult;
public class OrbotMainActivity extends Activity implements TorConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener public class OrbotMainActivity extends Activity implements OrbotConstants, OnLongClickListener, OnTouchListener, OnSharedPreferenceChangeListener
{ {
/* Useful UI bits */ /* Useful UI bits */
private TextView lblStatus = null; //the main text display widget private TextView lblStatus = null; //the main text display widget
@ -417,8 +417,10 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
else if (item.getItemId() == R.id.menu_share_bridge) else if (item.getItemId() == R.id.menu_share_bridge)
{ {
String bridges = mPrefs.getString(TorConstants.PREF_BRIDGES_LIST, null); String bridges = mPrefs.getString(OrbotConstants.PREF_BRIDGES_LIST, null);
if (bridges != null && bridges.length() > 0)
{
try { try {
bridges = "bridge://" + URLEncoder.encode(bridges,"UTF-8"); bridges = "bridge://" + URLEncoder.encode(bridges,"UTF-8");
@ -429,6 +431,7 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
}
} }
@ -652,8 +655,8 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
Editor pEdit = mPrefs.edit(); Editor pEdit = mPrefs.edit();
pEdit.putString(TorConstants.PREF_BRIDGES_LIST,newBridgeValue); //set the string to a preference pEdit.putString(OrbotConstants.PREF_BRIDGES_LIST,newBridgeValue); //set the string to a preference
pEdit.putBoolean(TorConstants.PREF_BRIDGES_ENABLED,true); pEdit.putBoolean(OrbotConstants.PREF_BRIDGES_ENABLED,true);
pEdit.commit(); pEdit.commit();

View File

@ -20,7 +20,7 @@ import java.util.zip.ZipInputStream;
import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.R; import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
@ -265,7 +265,7 @@ public class TorResourceInstaller implements TorServiceConstants {
} catch (IOException ex) { } catch (IOException ex) {
Log.e(TorConstants.TAG, "error copying binary", ex); Log.e(OrbotConstants.TAG, "error copying binary", ex);
} }
} }

View File

@ -51,7 +51,7 @@ import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.OrbotMainActivity; import org.torproject.android.OrbotMainActivity;
import org.torproject.android.R; import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import org.torproject.android.settings.AppManager; import org.torproject.android.settings.AppManager;
import org.torproject.android.settings.TorifiedApp; import org.torproject.android.settings.TorifiedApp;
import org.torproject.android.vpn.OrbotVpnService; import org.torproject.android.vpn.OrbotVpnService;
@ -79,7 +79,7 @@ import android.support.v4.content.LocalBroadcastManager;
import android.util.Log; import android.util.Log;
import android.widget.RemoteViews; import android.widget.RemoteViews;
public class TorService extends Service implements TorServiceConstants, TorConstants, EventHandler public class TorService extends Service implements TorServiceConstants, OrbotConstants, EventHandler
{ {
public static boolean ENABLE_DEBUG_LOG = true; public static boolean ENABLE_DEBUG_LOG = true;
@ -783,7 +783,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false); ENABLE_DEBUG_LOG = prefs.getBoolean("pref_enable_logging",false);
Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG); Log.i(TAG,"debug logging:" + ENABLE_DEBUG_LOG);
prefPersistNotifications = prefs.getBoolean(TorConstants.PREF_PERSIST_NOTIFICATIONS, true); prefPersistNotifications = prefs.getBoolean(OrbotConstants.PREF_PERSIST_NOTIFICATIONS, true);
mUseVPN = prefs.getBoolean("pref_vpn", false); mUseVPN = prefs.getBoolean("pref_vpn", false);
} }
@ -811,7 +811,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
ArrayList<String> customEnv = new ArrayList<String>(); ArrayList<String> customEnv = new ArrayList<String>();
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false); boolean useBridges = prefs.getBoolean(OrbotConstants.PREF_BRIDGES_ENABLED, false);
if (useBridges) if (useBridges)
if (mUseVPN && !mIsLollipop) if (mUseVPN && !mIsLollipop)
@ -1185,7 +1185,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
String socksPortPref = prefs.getString(TorConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT); String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS, TorServiceConstants.PORT_SOCKS_DEFAULT);
if (socksPortPref.indexOf(':')!=-1) if (socksPortPref.indexOf(':')!=-1)
socksPortPref = socksPortPref.split(":")[1]; socksPortPref = socksPortPref.split(":")[1];
@ -2043,7 +2043,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext()); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(getApplicationContext());
boolean doNetworKSleep = prefs.getBoolean(TorConstants.PREF_DISABLE_NETWORK, true); boolean doNetworKSleep = prefs.getBoolean(OrbotConstants.PREF_DISABLE_NETWORK, true);
final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo netInfo = cm.getActiveNetworkInfo(); final NetworkInfo netInfo = cm.getActiveNetworkInfo();
@ -2114,10 +2114,10 @@ public class TorService extends Service implements TorServiceConstants, TorConst
enableTransProxyAndDNSPorts(transPort, dnsPort); enableTransProxyAndDNSPorts(transPort, dnsPort);
*/ */
boolean useBridges = prefs.getBoolean(TorConstants.PREF_BRIDGES_ENABLED, false); boolean useBridges = prefs.getBoolean(OrbotConstants.PREF_BRIDGES_ENABLED, false);
boolean becomeRelay = prefs.getBoolean(TorConstants.PREF_OR, false); boolean becomeRelay = prefs.getBoolean(OrbotConstants.PREF_OR, false);
boolean ReachableAddresses = prefs.getBoolean(TorConstants.PREF_REACHABLE_ADDRESSES,false); boolean ReachableAddresses = prefs.getBoolean(OrbotConstants.PREF_REACHABLE_ADDRESSES,false);
boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false); boolean enableHiddenServices = prefs.getBoolean("pref_hs_enable", false);
boolean enableStrictNodes = prefs.getBoolean("pref_strict_nodes", false); boolean enableStrictNodes = prefs.getBoolean("pref_strict_nodes", false);
@ -2182,7 +2182,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
updateConfiguration("UseBridges", "1", false); updateConfiguration("UseBridges", "1", false);
String bridgeList = prefs.getString(TorConstants.PREF_BRIDGES_LIST,null); String bridgeList = prefs.getString(OrbotConstants.PREF_BRIDGES_LIST,null);
if (bridgeList != null && bridgeList.length() > 1) //longer then 1 = some real values here if (bridgeList != null && bridgeList.length() > 1) //longer then 1 = some real values here
{ {
@ -2302,7 +2302,7 @@ public class TorService extends Service implements TorServiceConstants, TorConst
if (ReachableAddresses) if (ReachableAddresses)
{ {
String ReachableAddressesPorts = String ReachableAddressesPorts =
prefs.getString(TorConstants.PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443"); prefs.getString(OrbotConstants.PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
updateConfiguration("ReachableAddresses", ReachableAddressesPorts, false); updateConfiguration("ReachableAddresses", ReachableAddressesPorts, false);
@ -2323,8 +2323,8 @@ public class TorService extends Service implements TorServiceConstants, TorConst
{ {
if (becomeRelay && (!useBridges) && (!ReachableAddresses)) if (becomeRelay && (!useBridges) && (!ReachableAddresses))
{ {
int ORPort = Integer.parseInt(prefs.getString(TorConstants.PREF_OR_PORT, "9001")); int ORPort = Integer.parseInt(prefs.getString(OrbotConstants.PREF_OR_PORT, "9001"));
String nickname = prefs.getString(TorConstants.PREF_OR_NICKNAME, "Orbot"); String nickname = prefs.getString(OrbotConstants.PREF_OR_NICKNAME, "Orbot");
String dnsFile = writeDNSFile (); String dnsFile = writeDNSFile ();

View File

@ -9,7 +9,7 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@ -117,9 +117,9 @@ public class TorServiceUtils implements TorServiceConstants {
public static SharedPreferences getSharedPrefs (Context context) public static SharedPreferences getSharedPrefs (Context context)
{ {
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB)
return context.getSharedPreferences(TorConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS); return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,0 | Context.MODE_MULTI_PROCESS);
else else
return context.getSharedPreferences(TorConstants.PREF_TOR_SHARED_PREFS,Context.MODE_PRIVATE); return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS,Context.MODE_PRIVATE);
} }
} }

View File

@ -7,7 +7,7 @@ import java.util.concurrent.TimeoutException;
import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.sufficientlysecure.rootcommands.command.SimpleCommand;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import org.torproject.android.settings.TorifiedApp; import org.torproject.android.settings.TorifiedApp;
import android.content.Context; import android.content.Context;
@ -49,7 +49,7 @@ public class TorTransProxy implements TorServiceConstants {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
useSystemIpTables = prefs.getBoolean(TorConstants.PREF_USE_SYSTEM_IPTABLES, false); useSystemIpTables = prefs.getBoolean(OrbotConstants.PREF_USE_SYSTEM_IPTABLES, false);
if (useSystemIpTables) if (useSystemIpTables)
{ {
@ -72,7 +72,7 @@ public class TorTransProxy implements TorServiceConstants {
SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context); SharedPreferences prefs = TorServiceUtils.getSharedPrefs(context);
useSystemIpTables = prefs.getBoolean(TorConstants.PREF_USE_SYSTEM_IPTABLES, false); useSystemIpTables = prefs.getBoolean(OrbotConstants.PREF_USE_SYSTEM_IPTABLES, false);
if (useSystemIpTables) if (useSystemIpTables)
{ {

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.torproject.android.R; import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorServiceUtils;
import android.app.Activity; import android.app.Activity;
@ -38,7 +38,7 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
//import android.R; //import android.R;
public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, TorConstants { public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, OrbotConstants {
private ListView listApps; private ListView listApps;
private final static String TAG = "Orbot"; private final static String TAG = "Orbot";

View File

@ -3,7 +3,7 @@
package org.torproject.android.ui; package org.torproject.android.ui;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@ -14,7 +14,7 @@ import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
public class OrbotLogActivity extends Activity implements TorConstants public class OrbotLogActivity extends Activity implements OrbotConstants
{ {
/** Called when the activity is first created. */ /** Called when the activity is first created. */

View File

@ -1,9 +1,9 @@
package org.torproject.android.ui; package org.torproject.android.ui.wizard;
import java.util.Locale; import java.util.Locale;
import org.torproject.android.R; import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import org.torproject.android.service.TorServiceUtils; import org.torproject.android.service.TorServiceUtils;
import android.app.Activity; import android.app.Activity;
@ -21,7 +21,7 @@ import android.widget.Button;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast; import android.widget.Toast;
public class ChooseLocaleWizardActivity extends Activity implements TorConstants { public class ChooseLocaleWizardActivity extends Activity implements OrbotConstants {
private int flag = 0; private int flag = 0;
private ListView listLocales; private ListView listLocales;

View File

@ -1,7 +1,7 @@
package org.torproject.android.ui; package org.torproject.android.ui.wizard;
import org.torproject.android.R; import org.torproject.android.R;
import org.torproject.android.TorConstants; import org.torproject.android.OrbotConstants;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@ -13,7 +13,7 @@ import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
public class TipsAndTricks extends Activity implements TorConstants { public class TipsAndTricks extends Activity implements OrbotConstants {
protected void onCreate(Bundle savedInstanceState) protected void onCreate(Bundle savedInstanceState)
{ {