Browse Source

remove unused proguard definitions, remove orbot checker

master
R4SAS 6 years ago
parent
commit
3c0932b473
  1. 19
      app/proguard-project.txt
  2. 1
      app/src/main/java/org/purplei2p/lightning/browser/activity/BrowserActivity.java
  3. 18
      app/src/main/java/org/purplei2p/lightning/preference/PreferenceManager.java
  4. 79
      app/src/main/java/org/purplei2p/lightning/utils/ProxyUtils.java
  5. 2
      build.gradle

19
app/proguard-project.txt

@ -33,15 +33,15 @@
-keep public class * extends android.content.ContentProvider -keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference -keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService #-keep public class com.android.vending.licensing.ILicensingService
-keep public class org.purplei2p.lightning.reading.* -keep public class org.purplei2p.lightning.reading.*
-keep class org.lucasr.twowayview.** { *; } #-keep class org.lucasr.twowayview.** { *; }
-keepattributes *Annotation* -keepattributes *Annotation*
-keepclassmembers class ** { #-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *; # @com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *; # @com.squareup.otto.Produce public *;
} #}
-assumenosideeffects class android.util.Log { -assumenosideeffects class android.util.Log {
public static *** d(...); public static *** d(...);
@ -68,7 +68,7 @@
} }
# Without this rule, openFileChooser does not get called on KitKat # Without this rule, openFileChooser does not get called on KitKat
-keep class org.purplei2p.lightning.view.LightningView$LightningChromeClient { -keep class org.purplei2p.lightning.view.LightningChromeClient {
void openFileChooser(android.webkit.ValueCallback); void openFileChooser(android.webkit.ValueCallback);
void openFileChooser(android.webkit.ValueCallback, java.lang.String); void openFileChooser(android.webkit.ValueCallback, java.lang.String);
void openFileChooser(android.webkit.ValueCallback, java.lang.String, java.lang.String); void openFileChooser(android.webkit.ValueCallback, java.lang.String, java.lang.String);
@ -104,9 +104,8 @@
# platform version. We know about them, and they are safe. # platform version. We know about them, and they are safe.
-dontwarn android.support.** -dontwarn android.support.**
-dontwarn org.apache.http.conn.ssl.DefaultHostnameVerifier #-dontwarn org.apache.http.conn.ssl.DefaultHostnameVerifier
#-dontwarn org.apache.http.HttpHost
-dontwarn org.apache.http.HttpHost
# Needed for okhttp # Needed for okhttp
-dontwarn okio.** -dontwarn okio.**

1
app/src/main/java/org/purplei2p/lightning/browser/activity/BrowserActivity.java

@ -430,7 +430,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
mPresenter.setupTabs(intent); mPresenter.setupTabs(intent);
setIntent(null); setIntent(null);
mProxyUtils.checkForProxy(this);
} }
} }

18
app/src/main/java/org/purplei2p/lightning/preference/PreferenceManager.java

@ -61,8 +61,6 @@ public class PreferenceManager {
static final String PROXY_CHOICE = "proxyChoice"; static final String PROXY_CHOICE = "proxyChoice";
static final String USE_PROXY_HOST = "useProxyHost"; static final String USE_PROXY_HOST = "useProxyHost";
static final String USE_PROXY_PORT = "useProxyPort"; static final String USE_PROXY_PORT = "useProxyPort";
static final String INITIAL_CHECK_FOR_TOR = "checkForTor";
static final String INITIAL_CHECK_FOR_I2P = "checkForI2P";
static final String LEAK_CANARY = "leakCanary"; static final String LEAK_CANARY = "leakCanary";
} }
@ -115,14 +113,6 @@ public class PreferenceManager {
return mPrefs.getBoolean(Name.BLOCK_THIRD_PARTY, false); return mPrefs.getBoolean(Name.BLOCK_THIRD_PARTY, false);
} }
public boolean getCheckedForTor() {
return mPrefs.getBoolean(Name.INITIAL_CHECK_FOR_TOR, false);
}
public boolean getCheckedForI2P() {
return mPrefs.getBoolean(Name.INITIAL_CHECK_FOR_I2P, false);
}
public boolean getClearCacheExit() { public boolean getClearCacheExit() {
return mPrefs.getBoolean(Name.CLEAR_CACHE_EXIT, false); return mPrefs.getBoolean(Name.CLEAR_CACHE_EXIT, false);
} }
@ -344,14 +334,6 @@ public class PreferenceManager {
putBoolean(Name.BLOCK_THIRD_PARTY, enable); putBoolean(Name.BLOCK_THIRD_PARTY, enable);
} }
public void setCheckedForTor(boolean check) {
putBoolean(Name.INITIAL_CHECK_FOR_TOR, check);
}
public void setCheckedForI2P(boolean check) {
putBoolean(Name.INITIAL_CHECK_FOR_I2P, check);
}
public void setClearCacheExit(boolean enable) { public void setClearCacheExit(boolean enable) {
putBoolean(Name.CLEAR_CACHE_EXIT, enable); putBoolean(Name.CLEAR_CACHE_EXIT, enable);
} }

79
app/src/main/java/org/purplei2p/lightning/utils/ProxyUtils.java

@ -15,7 +15,6 @@ import org.purplei2p.lightning.BrowserApp;
import org.purplei2p.lightning.constant.Constants; import org.purplei2p.lightning.constant.Constants;
import org.purplei2p.lightning.dialog.BrowserDialog; import org.purplei2p.lightning.dialog.BrowserDialog;
import org.purplei2p.lightning.preference.PreferenceManager; import org.purplei2p.lightning.preference.PreferenceManager;
import info.guardianproject.netcipher.proxy.OrbotHelper;
import info.guardianproject.netcipher.webkit.WebkitProxy; import info.guardianproject.netcipher.webkit.WebkitProxy;
@Singleton @Singleton
@ -30,71 +29,6 @@ public class ProxyUtils {
BrowserApp.getAppComponent().inject(this); BrowserApp.getAppComponent().inject(this);
} }
/*
* If Orbot/Tor or I2P is installed, prompt the user if they want to enable
* proxying for this session
*/
public void checkForProxy(@NonNull final Activity activity) {
boolean useProxy = mPreferences.getUseProxy();
final boolean orbotInstalled = OrbotHelper.isOrbotInstalled(activity);
boolean orbotChecked = mPreferences.getCheckedForTor();
boolean orbot = orbotInstalled && !orbotChecked;
boolean i2pInstalled = true;
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);
}
})
.setPositiveButton(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);
}
Dialog dialog = builder.show();
BrowserDialog.setDialogSize(activity, dialog);
}
}
/* /*
* Initialize WebKit Proxying * Initialize WebKit Proxying
*/ */
@ -107,9 +41,6 @@ public class ProxyUtils {
// We shouldn't be here // We shouldn't be here
return; return;
case Constants.PROXY_ORBOT: case Constants.PROXY_ORBOT:
if (!OrbotHelper.isOrbotRunning(activity)) {
OrbotHelper.requestStartTor(activity);
}
host = "localhost"; host = "localhost";
port = 8118; port = 8118;
break; break;
@ -117,17 +48,15 @@ public class ProxyUtils {
host = "localhost"; host = "localhost";
port = 4444; port = 4444;
break; break;
default:
host = mPreferences.getProxyHost();
port = mPreferences.getProxyPort();
break;
case Constants.PROXY_MANUAL: case Constants.PROXY_MANUAL:
default:
host = mPreferences.getProxyHost(); host = mPreferences.getProxyHost();
port = mPreferences.getProxyPort(); port = mPreferences.getProxyPort();
break; break;
} }
try { try {
Log.i(TAG, "trying enable web proxying with host = " + host + " and port = " + port);
WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), null, host, port); WebkitProxy.setProxy(BrowserApp.class.getName(), activity.getApplicationContext(), null, host, port);
} catch (Exception e) { } catch (Exception e) {
Log.d(TAG, "error enabling web proxying", e); Log.d(TAG, "error enabling web proxying", e);
@ -155,10 +84,6 @@ public class ProxyUtils {
public static int setProxyChoice(int choice, @NonNull Activity activity) { public static int setProxyChoice(int choice, @NonNull Activity activity) {
switch (choice) { switch (choice) {
case Constants.PROXY_ORBOT: case Constants.PROXY_ORBOT:
if (!OrbotHelper.isOrbotInstalled(activity)) {
choice = Constants.NO_PROXY;
Utils.showSnackbar(activity, R.string.install_orbot);
}
break; break;
case Constants.PROXY_I2P: case Constants.PROXY_I2P:
break; break;

2
build.gradle

@ -21,7 +21,7 @@ allprojects {
ext { ext {
minSdkVersion = 14 minSdkVersion = 14
targetSdkVersion = 26 targetSdkVersion = 26
buildToolsVersion = '26.0.0' buildToolsVersion = '26.0.3'
versionName = '4.5.1' versionName = '4.5.1'
versionCode_lite = 98 versionCode_lite = 98

Loading…
Cancel
Save