Fixed some bugs
This commit is contained in:
parent
08eedbe121
commit
4ba7c7c5a3
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
|
||||
@ -32,7 +33,7 @@ public class ProxyUtils {
|
||||
mI2PHelper = new I2PAndroidHelper(context);
|
||||
}
|
||||
|
||||
public static ProxyUtils getInstance(Context context) {
|
||||
public static ProxyUtils getInstance(@NonNull Context context) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new ProxyUtils(context);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.InputFilter;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
@ -244,6 +245,15 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
||||
View v = mActivity.getLayoutInflater().inflate(R.layout.picker_manual_proxy, null);
|
||||
final EditText eProxyHost = (EditText) v.findViewById(R.id.proxyHost);
|
||||
final EditText eProxyPort = (EditText) v.findViewById(R.id.proxyPort);
|
||||
|
||||
// Limit the number of characters since the port needs to be of type int
|
||||
// Use input filters to limite the EditText length and determine the max
|
||||
// length by using length of integer MAX_VALUE
|
||||
int maxCharacters = Integer.toString(Integer.MAX_VALUE).length();
|
||||
InputFilter[] filterArray = new InputFilter[1];
|
||||
filterArray[0] = new InputFilter.LengthFilter(maxCharacters - 1);
|
||||
eProxyPort.setFilters(filterArray);
|
||||
|
||||
eProxyHost.setText(mPreferences.getProxyHost());
|
||||
eProxyPort.setText(Integer.toString(mPreferences.getProxyPort()));
|
||||
|
||||
@ -254,13 +264,19 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
String proxyHost = eProxyHost.getText().toString();
|
||||
int proxyPort = Integer.parseInt(eProxyPort.getText().toString());
|
||||
int proxyPort;
|
||||
try {
|
||||
// Try/Catch in case the user types an empty string or a number
|
||||
// larger than max integer
|
||||
proxyPort = Integer.parseInt(eProxyPort.getText().toString());
|
||||
} catch (NumberFormatException ignored) {
|
||||
proxyPort = mPreferences.getProxyPort();
|
||||
}
|
||||
mPreferences.setProxyHost(proxyHost);
|
||||
mPreferences.setProxyPort(proxyPort);
|
||||
proxy.setSummary(proxyHost + ":" + proxyPort);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}).show();
|
||||
}
|
||||
|
||||
private void searchDialog() {
|
||||
|
@ -96,6 +96,8 @@ public final class Utils {
|
||||
}
|
||||
|
||||
public static String getDomainName(String url) {
|
||||
if (url == null || url.isEmpty()) return "";
|
||||
|
||||
boolean ssl = url.startsWith(Constants.HTTPS);
|
||||
int index = url.indexOf('/', 8);
|
||||
if (index != -1) {
|
||||
@ -103,12 +105,13 @@ public final class Utils {
|
||||
}
|
||||
|
||||
URI uri;
|
||||
String domain = null;
|
||||
String domain;
|
||||
try {
|
||||
uri = new URI(url);
|
||||
domain = uri.getHost();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
domain = null;
|
||||
}
|
||||
|
||||
if (domain == null || domain.isEmpty()) {
|
||||
|
@ -543,12 +543,6 @@ public class LightningView {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache(boolean disk) {
|
||||
if (mWebView != null) {
|
||||
mWebView.clearCache(disk);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload() {
|
||||
// Check if configured proxy is available
|
||||
if (mBrowserController.proxyIsNotReady()) {
|
||||
@ -562,6 +556,8 @@ public class LightningView {
|
||||
}
|
||||
|
||||
private void cacheFavicon(Bitmap icon) {
|
||||
if (icon == null) return;
|
||||
|
||||
String hash = String.valueOf(Utils.getDomainName(getUrl()).hashCode());
|
||||
Log.d(Constants.TAG, "Caching icon for " + Utils.getDomainName(getUrl()));
|
||||
FileOutputStream fos = null;
|
||||
@ -577,8 +573,6 @@ public class LightningView {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressLint("NewApi")
|
||||
public synchronized void find(String text) {
|
||||
if (mWebView != null) {
|
||||
if (API > 16) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user