Browse Source

Fix for I2PAndroidHelper.isI2PAndroidRunning() always returning false

Requires v0.7 of the I2P client library, which will be released once I2P 0.9.20
is released.
master
str4d 10 years ago
parent
commit
6e8da9f6d3
  1. 2
      app/build.gradle
  2. 7
      app/proguard-project.txt
  3. 16
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

2
app/build.gradle

@ -39,5 +39,5 @@ dependencies {
compile 'com.android.support:palette-v7:22.1.1' compile 'com.android.support:palette-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.android.support:appcompat-v7:22.1.1'
compile 'org.jsoup:jsoup:1.8.1' compile 'org.jsoup:jsoup:1.8.1'
compile 'net.i2p.android:client:0.6@aar' compile 'net.i2p.android:client:0.7@aar'
} }

7
app/proguard-project.txt

@ -78,7 +78,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.**
# The I2P Java API bundled inside the I2P Android client library contains a # The I2P Java API bundled inside the I2P Android client library contains
# method that references classes in javax.naming that Android doesn't have. But # references to javax.naming classes that Android doesn't have. But those
# the method never uses those classes on Android, and is safe. # classes are never used on Android, and it is safe to ignore the warnings.
-dontwarn net.i2p.crypto.CertUtil -dontwarn net.i2p.crypto.CertUtil
-dontwarn org.apache.http.conn.ssl.DefaultHostnameVerifier

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

@ -184,6 +184,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
// Helper // Helper
private I2PAndroidHelper mI2PHelper; private I2PAndroidHelper mI2PHelper;
private boolean mI2PHelperBound;
private boolean mI2PProxyInitialized;
// Constant // Constant
private static final int API = android.os.Build.VERSION.SDK_INT; private static final int API = android.os.Build.VERSION.SDK_INT;
@ -626,7 +628,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
break; break;
case 2: case 2:
if (!mI2PHelper.isI2PAndroidRunning()) { mI2PProxyInitialized = true;
if (mI2PHelperBound && !mI2PHelper.isI2PAndroidRunning()) {
mI2PHelper.requestI2PAndroidStart(this); mI2PHelper.requestI2PAndroidStart(this);
} }
host = "localhost"; host = "localhost";
@ -807,6 +810,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
mI2PProxyInitialized = false;
} }
} }
@ -1468,6 +1472,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
mI2PHelper.unbind(); mI2PHelper.unbind();
mI2PHelperBound = false;
} }
@Override @Override
@ -1484,7 +1489,14 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
super.onStart(); super.onStart();
if (mPreferences.getProxyChoice() == 2) { if (mPreferences.getProxyChoice() == 2) {
// Try to bind to I2P Android // Try to bind to I2P Android
mI2PHelper.bind(); mI2PHelper.bind(new I2PAndroidHelper.Callback() {
@Override
public void onI2PAndroidBound() {
mI2PHelperBound = true;
if (mI2PProxyInitialized && !mI2PHelper.isI2PAndroidRunning())
mI2PHelper.requestI2PAndroidStart(BrowserActivity.this);
}
});
} }
} }

Loading…
Cancel
Save