Browse Source

Moved proxy code to utility class, remove proxy from lite version to reduce apk size

master
Anthony Restaino 10 years ago
parent
commit
d8b8d2c047
  1. 50
      app/app.iml
  2. 13
      app/build.gradle
  3. 219
      app/src/LightningPlus/java/acr/browser/lightning/utils/ProxyUtils.java
  4. 0
      app/src/lightningLite/assets/hosts.txt
  5. 58
      app/src/lightningLite/java/acr/browser/lightning/utils/ProxyUtils.java
  6. 172
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  7. 22
      app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java
  8. 77
      app/src/main/res/layout/settings.xml
  9. 1
      app/src/main/res/values-de/strings.xml
  10. 1
      app/src/main/res/values-es/strings.xml
  11. 1
      app/src/main/res/values-gr/strings.xml
  12. 1
      app/src/main/res/values-hu/strings.xml
  13. 1
      app/src/main/res/values-it/strings.xml
  14. 1
      app/src/main/res/values-ja/strings.xml
  15. 1
      app/src/main/res/values-pl/strings.xml
  16. 1
      app/src/main/res/values-pt/strings.xml
  17. 1
      app/src/main/res/values-ru/strings.xml
  18. 1
      app/src/main/res/values-sr/strings.xml
  19. 1
      app/src/main/res/values-tr/strings.xml
  20. 1
      app/src/main/res/values-zh-rCN/strings.xml
  21. 2
      app/src/main/res/values/strings.xml

50
app/app.iml

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="LightningPlusDebug" />
<option name="SELECTED_BUILD_VARIANT" value="lightningPlusDebug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleLightningPlusDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileLightningPlusDebugSources" />
@ -25,34 +25,34 @@ @@ -25,34 +25,34 @@
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/LightningPlus/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/LightningPlus/debug" />
<output url="file://$MODULE_DIR$/build/intermediates/classes/lightningPlus/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/lightningPlus/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/LightningPlus/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/LightningPlus/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/LightningPlus/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/LightningPlus/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/lightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/lightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/lightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/lightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/lightningPlus/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/lightningPlus/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/lightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/lightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/lightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/lightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/lightningPlus/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/lightningPlus/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlus/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/res" type="java-test-resource" />
@ -93,6 +93,7 @@ @@ -93,6 +93,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@ -110,6 +111,7 @@ @@ -110,6 +111,7 @@
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="client-0.7" level="project" />
<orderEntry type="library" exported="" name="palette-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />

13
app/build.gradle

@ -25,13 +25,13 @@ android { @@ -25,13 +25,13 @@ android {
}
productFlavors {
LightningPlus {
lightningPlus {
buildConfigField "boolean", "FULL_VERSION", "true"
applicationId "acr.browser.lightning"
versionCode 78
}
LightningFree {
lightningLite {
buildConfigField "boolean", "FULL_VERSION", "false"
applicationId "acr.browser.barebones"
versionCode 81
@ -44,13 +44,10 @@ android { @@ -44,13 +44,10 @@ android {
}
dependencies {
compile(project(':libnetcipher')) {
// Exclude any support-v4 modules because appcompat-v7 will import the latest
exclude module: 'support-v4'
exclude module: 'android-support-v4'
}
compile 'com.android.support:palette-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'org.jsoup:jsoup:1.8.1'
compile 'net.i2p.android:client:0.7@aar'
lightningPlusCompile 'net.i2p.android:client:0.7'
lightningPlusCompile(project(':libnetcipher'))
}

219
app/src/LightningPlus/java/acr/browser/lightning/utils/ProxyUtils.java

@ -0,0 +1,219 @@ @@ -0,0 +1,219 @@
package acr.browser.lightning.utils;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import net.i2p.android.ui.I2PAndroidHelper;
import acr.browser.lightning.R;
import acr.browser.lightning.activity.BrowserApp;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager;
import info.guardianproject.onionkit.ui.OrbotHelper;
import info.guardianproject.onionkit.web.WebkitProxy;
/**
* 6/4/2015 Anthony Restaino
*/
public class ProxyUtils {
// Helper
private static I2PAndroidHelper mI2PHelper;
private static boolean mI2PHelperBound;
private static boolean mI2PProxyInitialized;
private static PreferenceManager mPreferences;
private static ProxyUtils mInstance;
private ProxyUtils(Context context) {
mPreferences = PreferenceManager.getInstance();
mI2PHelper = new I2PAndroidHelper(context);
}
public static ProxyUtils getInstance(Context context) {
if (mInstance == null) {
mInstance = new ProxyUtils(context);
}
return mInstance;
}
/*
* If Orbot/Tor or I2P is installed, prompt the user if they want to enable
* proxying for this session
*/
public void checkForProxy(final Activity activity) {
boolean useProxy = mPreferences.getUseProxy();
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext());
final boolean orbotInstalled = oh.isOrbotInstalled();
boolean orbotChecked = mPreferences.getCheckedForTor();
boolean orbot = orbotInstalled && !orbotChecked;
boolean i2pInstalled = mI2PHelper.isI2PAndroidInstalled();
boolean i2pChecked = mPreferences.getCheckedForI2P();
boolean i2p = i2pInstalled && !i2pChecked;
// TODO Is the idea to show this per-session, or only once?
if (!useProxy && (orbot || i2p)) {
if (orbot) mPreferences.setCheckedForTor(true);
if (i2p) mPreferences.setCheckedForI2P(true);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
if (orbotInstalled && i2pInstalled) {
String[] proxyChoices = activity.getResources().getStringArray(R.array.proxy_choices_array);
builder.setTitle(activity.getResources().getString(R.string.http_proxy))
.setSingleChoiceItems(proxyChoices, mPreferences.getProxyChoice(),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferences.setProxyChoice(which);
}
})
.setNeutralButton(activity.getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mPreferences.getUseProxy())
initializeProxy(activity);
}
});
} else {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
mPreferences.setProxyChoice(orbotInstalled ?
Constants.PROXY_ORBOT : Constants.PROXY_I2P);
initializeProxy(activity);
break;
case DialogInterface.BUTTON_NEGATIVE:
mPreferences.setProxyChoice(Constants.NO_PROXY);
break;
}
}
};
builder.setMessage(orbotInstalled ? R.string.use_tor_prompt : R.string.use_i2p_prompt)
.setPositiveButton(R.string.yes, dialogClickListener)
.setNegativeButton(R.string.no, dialogClickListener);
}
builder.show();
}
}
/*
* Initialize WebKit Proxying
*/
private void initializeProxy(Activity activity) {
String host;
int port;
switch (mPreferences.getProxyChoice()) {
case Constants.NO_PROXY:
// We shouldn't be here
return;
case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext());
if (!oh.isOrbotRunning()) {
oh.requestOrbotStart(activity);
}
host = "localhost";
port = 8118;
break;
case Constants.PROXY_I2P:
mI2PProxyInitialized = true;
if (mI2PHelperBound && !mI2PHelper.isI2PAndroidRunning()) {
mI2PHelper.requestI2PAndroidStart(activity);
}
host = "localhost";
port = 4444;
break;
default:
host = mPreferences.getProxyHost();
port = mPreferences.getProxyPort();
}
try {
WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(),
host, port);
} catch (Exception e) {
Log.d(Constants.TAG, "error enabling web proxying", e);
}
}
public boolean isProxyReady(Context context) {
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
if (!mI2PHelper.isI2PAndroidRunning()) {
Utils.showToast(context, context.getString(R.string.i2p_not_running));
return false;
} else if (!mI2PHelper.areTunnelsActive()) {
Utils.showToast(context, context.getString(R.string.i2p_tunnels_not_ready));
return false;
}
}
return true;
}
public void updateProxySettings(Activity activity) {
if (mPreferences.getUseProxy()) {
initializeProxy(activity);
} else {
try {
WebkitProxy.resetProxy(BrowserApp.class.getName(),
activity.getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
}
mI2PProxyInitialized = false;
}
}
public void onStop() {
mI2PHelper.unbind();
mI2PHelperBound = false;
}
public void onStart(final Activity activity) {
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
// Try to bind to I2P Android
mI2PHelper.bind(new I2PAndroidHelper.Callback() {
@Override
public void onI2PAndroidBound() {
mI2PHelperBound = true;
if (mI2PProxyInitialized && !mI2PHelper.isI2PAndroidRunning())
mI2PHelper.requestI2PAndroidStart(activity);
}
});
}
}
public int setProxyChoice(int choice, Activity activity) {
switch (choice) {
case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(activity.getApplicationContext());
if (!oh.isOrbotInstalled()) {
choice = Constants.NO_PROXY;
Utils.showToast(activity, activity.getResources().getString(R.string.install_orbot));
}
break;
case Constants.PROXY_I2P:
I2PAndroidHelper ih = new I2PAndroidHelper(activity.getApplicationContext());
if (!ih.isI2PAndroidInstalled()) {
choice = Constants.NO_PROXY;
ih.promptToInstall(activity);
}
break;
case Constants.PROXY_MANUAL:
break;
}
return choice;
}
}

0
app/src/LightningFree/assets/hosts.txt → app/src/lightningLite/assets/hosts.txt

58
app/src/lightningLite/java/acr/browser/lightning/utils/ProxyUtils.java

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
package acr.browser.lightning.utils;
import android.app.Activity;
import android.content.Context;
/**
* 6/4/2015 Anthony Restaino
*/
public class ProxyUtils {
private static ProxyUtils mInstance;
private ProxyUtils(Context context) {
}
public static ProxyUtils getInstance(Context context) {
if (mInstance == null) {
mInstance = new ProxyUtils(context);
}
return mInstance;
}
/*
* If Orbot/Tor or I2P is installed, prompt the user if they want to enable
* proxying for this session
*/
public void checkForProxy(final Activity activity) {
}
/*
* Initialize WebKit Proxying
*/
private void initializeProxy(Activity activity) {
}
public boolean isProxyReady(Context context) {
return true;
}
public void updateProxySettings(Activity activity) {
}
public void onStop() {
}
public void onStart(final Activity activity) {
}
public int setProxyChoice(int choice, Activity activity) {
return choice;
}
}

172
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -92,8 +92,6 @@ import android.widget.TextView.OnEditorActionListener; @@ -92,8 +92,6 @@ import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
import android.widget.VideoView;
import net.i2p.android.ui.I2PAndroidHelper;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
@ -124,11 +122,10 @@ import acr.browser.lightning.object.ClickHandler; @@ -124,11 +122,10 @@ import acr.browser.lightning.object.ClickHandler;
import acr.browser.lightning.object.DrawerArrowDrawable;
import acr.browser.lightning.object.SearchAdapter;
import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.ProxyUtils;
import acr.browser.lightning.utils.Utils;
import acr.browser.lightning.view.AnimatedProgressBar;
import acr.browser.lightning.view.LightningView;
import info.guardianproject.onionkit.ui.OrbotHelper;
import info.guardianproject.onionkit.web.WebkitProxy;
public class BrowserActivity extends ThemableActivity implements BrowserController, OnClickListener {
@ -165,7 +162,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -165,7 +162,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
// Context
private Activity mActivity;
// Native
// Primatives
private boolean mSystemBrowser = false, mIsNewIntent = false, mFullScreen, mColorMode,
mDarkTheme;
private int mOriginalOrientation, mBackgroundColor, mIdGenerator;
@ -182,10 +179,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -182,10 +179,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
private Drawable mDeleteIcon, mRefreshIcon, mCopyIcon, mIcon;
private DrawerArrowDrawable mArrowDrawable;
// Helper
private I2PAndroidHelper mI2PHelper;
private boolean mI2PHelperBound;
private boolean mI2PProxyInitialized;
// Proxy
private ProxyUtils mProxyUtils;
// Constant
private static final int API = android.os.Build.VERSION.SDK_INT;
@ -269,7 +264,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -269,7 +264,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
R.id.arrow_button);
arrowButton.setOnClickListener(this);
mI2PHelper = new I2PAndroidHelper(this);
mProxyUtils = ProxyUtils.getInstance(this);
RelativeLayout back = (RelativeLayout) findViewById(R.id.action_back);
back.setOnClickListener(this);
@ -354,7 +349,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -354,7 +349,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
}
checkForProxy();
mProxyUtils.checkForProxy(this);
}
private class SearchClass {
@ -543,129 +538,6 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -543,129 +538,6 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
/*
* If Orbot/Tor or I2P is installed, prompt the user if they want to enable
* proxying for this session
*/
private void checkForProxy() {
boolean useProxy = mPreferences.getUseProxy();
OrbotHelper oh = new OrbotHelper(this);
final boolean orbotInstalled = oh.isOrbotInstalled();
boolean orbotChecked = mPreferences.getCheckedForTor();
boolean orbot = orbotInstalled && !orbotChecked;
boolean i2pInstalled = mI2PHelper.isI2PAndroidInstalled();
boolean i2pChecked = mPreferences.getCheckedForI2P();
boolean i2p = i2pInstalled && !i2pChecked;
// TODO Is the idea to show this per-session, or only once?
if (!useProxy && (orbot || i2p)) {
if (orbot) mPreferences.setCheckedForTor(true);
if (i2p) mPreferences.setCheckedForI2P(true);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
if (orbotInstalled && i2pInstalled) {
String[] proxyChoices = this.getResources().getStringArray(R.array.proxy_choices_array);
builder.setTitle(getResources().getString(R.string.http_proxy))
.setSingleChoiceItems(proxyChoices, mPreferences.getProxyChoice(),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferences.setProxyChoice(which);
}
})
.setNeutralButton(getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (mPreferences.getUseProxy())
initializeProxy();
}
});
} else {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
mPreferences.setProxyChoice(orbotInstalled ?
Constants.PROXY_ORBOT : Constants.PROXY_I2P);
initializeProxy();
break;
case DialogInterface.BUTTON_NEGATIVE:
mPreferences.setProxyChoice(Constants.NO_PROXY);
break;
}
}
};
builder.setMessage(orbotInstalled ? R.string.use_tor_prompt : R.string.use_i2p_prompt)
.setPositiveButton(R.string.yes, dialogClickListener)
.setNegativeButton(R.string.no, dialogClickListener);
}
builder.show();
}
}
/*
* Initialize WebKit Proxying
*/
private void initializeProxy() {
String host;
int port;
switch (mPreferences.getProxyChoice()) {
case Constants.NO_PROXY:
// We shouldn't be here
return;
case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(this);
if (!oh.isOrbotRunning()) {
oh.requestOrbotStart(this);
}
host = "localhost";
port = 8118;
break;
case Constants.PROXY_I2P:
mI2PProxyInitialized = true;
if (mI2PHelperBound && !mI2PHelper.isI2PAndroidRunning()) {
mI2PHelper.requestI2PAndroidStart(this);
}
host = "localhost";
port = 4444;
break;
default:
host = mPreferences.getProxyHost();
port = mPreferences.getProxyPort();
}
try {
WebkitProxy.setProxy(BrowserApp.class.getName(), getApplicationContext(),
host, port);
} catch (Exception e) {
Log.d(Constants.TAG, "error enabling web proxying", e);
}
}
public boolean isProxyReady() {
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
if (!mI2PHelper.isI2PAndroidRunning()) {
Utils.showToast(this, getString(R.string.i2p_not_running));
return false;
} else if (!mI2PHelper.areTunnelsActive()) {
Utils.showToast(this, getString(R.string.i2p_tunnels_not_ready));
return false;
}
}
return true;
}
private boolean isTablet() {
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
}
@ -817,17 +689,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -817,17 +689,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
updateCookiePreference();
if (mPreferences.getUseProxy()) {
initializeProxy();
} else {
try {
WebkitProxy.resetProxy(BrowserApp.class.getName(),
getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
}
mI2PProxyInitialized = false;
}
mProxyUtils.updateProxySettings(this);
}
/*
@ -1487,8 +1349,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1487,8 +1349,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override
protected void onStop() {
super.onStop();
mI2PHelper.unbind();
mI2PHelperBound = false;
mProxyUtils.onStop();
}
@Override
@ -1503,17 +1364,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1503,17 +1364,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override
protected void onStart() {
super.onStart();
if (mPreferences.getProxyChoice() == Constants.PROXY_I2P) {
// Try to bind to I2P Android
mI2PHelper.bind(new I2PAndroidHelper.Callback() {
@Override
public void onI2PAndroidBound() {
mI2PHelperBound = true;
if (mI2PProxyInitialized && !mI2PHelper.isI2PAndroidRunning())
mI2PHelper.requestI2PAndroidStart(BrowserActivity.this);
}
});
}
mProxyUtils.onStart(this);
}
@Override
@ -2025,6 +1876,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -2025,6 +1876,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
return false;
}
@Override
public boolean isProxyReady() {
return mProxyUtils.isProxyReady(this);
}
/**
* function that opens the HTML history page in the browser
*/

22
app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java

@ -26,13 +26,11 @@ import android.widget.LinearLayout; @@ -26,13 +26,11 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import net.i2p.android.ui.I2PAndroidHelper;
import acr.browser.lightning.R;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.ProxyUtils;
import acr.browser.lightning.utils.Utils;
import info.guardianproject.onionkit.ui.OrbotHelper;
public class SettingsActivity extends ThemableSettingsActivity {
@ -180,6 +178,9 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -180,6 +178,9 @@ public class SettingsActivity extends ThemableSettingsActivity {
}
});
if (Constants.FULL_VERSION == false) {
layoutProxyChoice.setEnabled(false);
}
layoutProxyChoice.setOnClickListener(new OnClickListener() {
@Override
@ -324,23 +325,14 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -324,23 +325,14 @@ public class SettingsActivity extends ThemableSettingsActivity {
}
private void setProxyChoice(int choice) {
ProxyUtils utils = ProxyUtils.getInstance(this);
switch (choice) {
case Constants.PROXY_ORBOT:
OrbotHelper oh = new OrbotHelper(this);
if (!oh.isOrbotInstalled()) {
choice = Constants.NO_PROXY;
Utils.showToast(mContext, getResources().getString(R.string.install_orbot));
}
choice = utils.setProxyChoice(choice, this);
break;
case Constants.PROXY_I2P:
I2PAndroidHelper ih = new I2PAndroidHelper(this);
if (!ih.isI2PAndroidInstalled()) {
choice = Constants.NO_PROXY;
ih.promptToInstall(this);
}
choice = utils.setProxyChoice(choice, this);
break;
case Constants.PROXY_MANUAL:
manualProxyPicker();
break;

77
app/src/main/res/layout/settings.xml

@ -10,12 +10,12 @@ @@ -10,12 +10,12 @@
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
android:orientation="vertical">
<RelativeLayout
android:id="@+id/layoutFlash"
@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:id="@+id/textView1"
@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:layout_width="wrap_content"
@ -96,7 +96,7 @@ @@ -96,7 +96,7 @@
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:id="@+id/textView2"
@ -132,7 +132,7 @@ @@ -132,7 +132,7 @@
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:id="@+id/textView3"
@ -160,32 +160,34 @@ @@ -160,32 +160,34 @@
android:layout_marginRight="10dp"
android:background="?attr/dividerColor" />
<LinearLayout
android:id="@+id/layoutProxyChoice"
<RelativeLayout
android:id="@+id/layoutColorMode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
android:paddingRight="10dp"
android:paddingTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingLeft="16dp"
android:text="@string/http_proxy"
android:paddingRight="60dp"
android:text="@string/color_mode"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/proxyChoiceName"
<CheckBox
android:id="@+id/cbColorMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light"
tools:text="Disabled" />
</LinearLayout>
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
@ -194,33 +196,32 @@ @@ -194,33 +196,32 @@
android:layout_marginRight="10dp"
android:background="?attr/dividerColor" />
<RelativeLayout
android:id="@+id/layoutColorMode"
<LinearLayout
android:id="@+id/layoutProxyChoice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingLeft="16dp"
android:paddingRight="60dp"
android:text="@string/color_mode"
android:text="@string/http_proxy"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/cbColorMode"
<TextView
android:id="@+id/proxyChoiceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
</RelativeLayout>
android:paddingLeft="16dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light"
tools:text="Disabled" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
@ -236,7 +237,7 @@ @@ -236,7 +237,7 @@
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:id="@+id/textView7"
@ -263,7 +264,7 @@ @@ -263,7 +264,7 @@
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:layout_width="wrap_content"
@ -289,7 +290,7 @@ @@ -289,7 +290,7 @@
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:id="@+id/textView8"
@ -316,7 +317,7 @@ @@ -316,7 +317,7 @@
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:id="@+id/textView9"
@ -343,7 +344,7 @@ @@ -343,7 +344,7 @@
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<TextView
android:id="@+id/textView10"
@ -370,14 +371,14 @@ @@ -370,14 +371,14 @@
android:background="?attr/listChoiceBackgroundIndicator"
android:minHeight="60dp"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
android:paddingTop="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
android:orientation="vertical">
<TextView
android:id="@+id/textView11"

1
app/src/main/res/values-de/strings.xml

@ -158,7 +158,6 @@ @@ -158,7 +158,6 @@
<string name="powered_by_google">Unterstützt durch Google</string>
<string name="title_adblock">Werbeblocker</string>
<string name="message_adblock">Der Werbeblocker ist nur in Lightning Browser+ verfügbar und kann im Google Play Store gekauft werden!</string>
<string name="enable_orbot">Orbot aktivieren</string>
<string name="use_tor_prompt">Orbot ist installiert. Soll Tor verwendet werden?</string>
<string name="install_orbot">Um Tor verwenden zu können, muss Orbot installiert sein!</string>
<string name="yes">Ja</string>

1
app/src/main/res/values-es/strings.xml

@ -141,7 +141,6 @@ @@ -141,7 +141,6 @@
<string name="powered_by_google">Proporcionadas por Google</string>
<string name="title_adblock">AdBlock</string>
<string name="message_adblock">El bloqueador de publicidad AdBlock sólo está disponible en la versión de pago del navegador, Lightning Browser+. Puede descargarla en Google Play.</string>
<string name="enable_orbot">Habilitar Orbot</string>
<string name="use_tor_prompt">Parece que tienes Orbot instalado. ¿Quieres usar Tor?</string>
<string name="install_orbot">Por favor, instala Orbot para usar Tor.</string>
<string name="yes"></string>

1
app/src/main/res/values-gr/strings.xml

@ -142,7 +142,6 @@ @@ -142,7 +142,6 @@
<string name="powered_by_google">Powered by Google</string>
<string name="title_adblock">AdBlock</string>
<string name="message_adblock">Το AdBlock είναι προς το παρόν διαθέσιμο μόνο στην πληρωμένη έκδοση του browser, Lightning Browser+. Είναι διαθέσιμη για κατέβασμα στο Google Play.</string>
<string name="enable_orbot">Ενεργοποίηση Orbot</string>
<string name="use_tor_prompt">Φαίνεται οτι έχετε εγκατεστημένο το Orbot. Θα θέλατε να χρησιμοποιήσετε το Tor?</string>
<string name="install_orbot">Παρακαλώ εγκαταστήστε το Orbot για να χρησιμοποιήσετε το Tor.</string>
<string name="yes">Ναι</string>

1
app/src/main/res/values-hu/strings.xml

@ -158,7 +158,6 @@ @@ -158,7 +158,6 @@
<string name="powered_by_google">A Google támogatásával</string>
<string name="title_adblock">AdBlock</string>
<string name="message_adblock">Az AdBlock jelenleg csak a Lightning Browser + fizetős változatban érhető el.Ez letölthető a Google Play Áruházból.</string>
<string name="enable_orbot">Orbot bekapcsolása</string>
<string name="use_tor_prompt">Úgy tűnik, hogy önnek telepítve van az Orbot.Szeretné használni Tor-t?</string>
<string name="install_orbot">Kérjük telepítse az Orbot-ot annak érdekében, hogy működjön a proxy a Tor-ral.</string>
<string name="yes">Igen</string>

1
app/src/main/res/values-it/strings.xml

@ -93,7 +93,6 @@ @@ -93,7 +93,6 @@
<string name="message_text_copied">Testo copiato negli appunti</string>
<string name="message_link_copied">Link copiato negli appunti</string>
<string name="block_ads">Blocca Annunci</string>
<string name="enable_orbot">Abilita Orbot</string>
<string name="sync_history">Sincronizza cronologia con Google</string>
<string name="export_bookmarks">Esporta segnalibri</string>
<string name="import_backup">Importa segnalibri da backup</string>

1
app/src/main/res/values-ja/strings.xml

@ -155,7 +155,6 @@ @@ -155,7 +155,6 @@
<string name="powered_by_google">Powered by Google</string>
<string name="title_adblock">広告ブロック</string>
<string name="message_adblock">広告ブロックは有料版のLightning Browser+でのみ利用可能です。Google Playからダウンロードできます。</string>
<string name="enable_orbot">Orbot</string>
<string name="use_tor_prompt">Orbotがインストールされています。Torを使用しますか?</string>
<string name="install_orbot">Torでプロキシを有効にするにはOrbotをインストールしてください</string>
<string name="yes">はい</string>

1
app/src/main/res/values-pl/strings.xml

@ -141,7 +141,6 @@ @@ -141,7 +141,6 @@
<string name="powered_by_google">Dostarczane przez Google</string>
<string name="title_adblock">Blokowanie reklam</string>
<string name="message_adblock">Blokowanie reklam jest obecnie dostępne tylko w płatnej wersji przeglądarki, Lightning Browser+. Jest ona dostępna do pobrania w sklepie Google Play.</string>
<string name="enable_orbot">Włącz Orbota</string>
<string name="use_tor_prompt">Wygląda na to że Orbot jest zainstalowany. Chciałbyś go włączyć i użyć sieci Tor do łączenia się z internetem?</string>
<string name="install_orbot">Zanistaluj Orbota by móc używać sieci Tor do łączenia się z internetem.</string>
<string name="yes">Tak</string>

1
app/src/main/res/values-pt/strings.xml

@ -158,7 +158,6 @@ @@ -158,7 +158,6 @@
<string name="powered_by_google">Disponibilizado por Google</string>
<string name="title_adblock">AdBlock</string>
<string name="message_adblock">O AdBlock apenas está disponível na versão paga, o Lightning Browser+. Esta versão está disponível na loja Google.</string>
<string name="enable_orbot">Ativar Orbot</string>
<string name="use_tor_prompt">Parece que você tem o Orbot instalado. Gostaria de utilizar a rede Tor?</string>
<string name="install_orbot">Por favor instale o Orbot para poder utilizar a rede Tor.</string>
<string name="yes">Sim</string>

1
app/src/main/res/values-ru/strings.xml

@ -141,7 +141,6 @@ @@ -141,7 +141,6 @@
<string name="powered_by_google">Используя Google</string>
<string name="title_adblock">AdBlock</string>
<string name="message_adblock">AdBlock в настоящее время доступен только в платной версии браузера Lightning Browser+. Он доступен для загрузки в Google Play.</string>
<string name="enable_orbot">Использовать Orbot</string>
<string name="use_tor_prompt">Похоже, установлен Orbot. Вы хотите использовать Tor?</string>
<string name="install_orbot">Пожалуйста, установите Orbot для проксирования через Tor.</string>
<string name="yes">Да</string>

1
app/src/main/res/values-sr/strings.xml

@ -155,7 +155,6 @@ @@ -155,7 +155,6 @@
<string name="powered_by_google">Погоњено Гуглом</string>
<string name="title_adblock">Адблок</string>
<string name="message_adblock">Адблок је доступан само у плаћеном издању прегледача, „Lightning Browser+“. Доступан је за преузимање на Гугловом Плеју.</string>
<string name="enable_orbot">Омогући Орбот</string>
<string name="use_tor_prompt">Изгледа да имате Орбот инсталиран. Желите ли да користите Тор?</string>
<string name="install_orbot">Инсталирајте Орбот да бисте користили Тор.</string>
<string name="yes">Да</string>

1
app/src/main/res/values-tr/strings.xml

@ -142,7 +142,6 @@ @@ -142,7 +142,6 @@
<string name="powered_by_google">Powered by Google</string>
<string name="title_adblock">AdBlock</string>
<string name="message_adblock">AdBlock şu anda yalnızca ücretli sürüm olan Lightning Browser+ ile kullanılabilir. Ücretli sürümü Google Play aracılığı ile indirebilirsin.</string>
<string name="enable_orbot">Orbot\'u kullan</string>
<string name="use_tor_prompt">Cihazında Orbot yüklü görünüyor. Tor kullanmak ister misin?</string>
<string name="install_orbot">Tor proxy ağı ile gezinmek için Orbot yüklemelisin.</string>
<string name="yes">Evet</string>

1
app/src/main/res/values-zh-rCN/strings.xml

@ -142,7 +142,6 @@ @@ -142,7 +142,6 @@
<string name="powered_by_google">由 Google 提供支持</string>
<string name="title_adblock">广告拦截</string>
<string name="message_adblock">广告拦截现在只能在付费版的浏览器 - Lightning Browser+ 中使用。你可以在 Google Play 中下载它。</string>
<string name="enable_orbot">启用 Orbot</string>
<string name="use_tor_prompt">看起来你已经安装了 Orbot. 你想要使用 Tor 吗?</string>
<string name="install_orbot">请安装 Orbot 以便通过 Tor 全使用代理。</string>
<string name="yes"></string>

2
app/src/main/res/values/strings.xml

@ -158,7 +158,7 @@ @@ -158,7 +158,7 @@
<string name="powered_by_google">Powered by Google</string>
<string name="title_adblock">AdBlock</string>
<string name="message_adblock">AdBlock is currently only available in the browser\'s paid version, Lightning Browser+. It is available to download on Google Play.</string>
<string name="http_proxy">HTTP proxy</string>
<string name="http_proxy">HTTP Proxy</string>
<string-array name="proxy_choices_array">
<item>None</item>
<item>Orbot</item>

Loading…
Cancel
Save