|
|
|
@ -10,6 +10,9 @@ import android.app.AlertDialog;
@@ -10,6 +10,9 @@ import android.app.AlertDialog;
|
|
|
|
|
import android.content.*; |
|
|
|
|
import android.graphics.Bitmap; |
|
|
|
|
import android.graphics.BitmapFactory; |
|
|
|
|
import android.graphics.ColorMatrix; |
|
|
|
|
import android.graphics.ColorMatrixColorFilter; |
|
|
|
|
import android.graphics.Paint; |
|
|
|
|
import android.net.MailTo; |
|
|
|
|
import android.net.Uri; |
|
|
|
|
import android.net.http.SslError; |
|
|
|
@ -35,34 +38,26 @@ import java.net.*;
@@ -35,34 +38,26 @@ import java.net.*;
|
|
|
|
|
public class LightningView { |
|
|
|
|
|
|
|
|
|
private Title mTitle; |
|
|
|
|
|
|
|
|
|
private WebView mWebView; |
|
|
|
|
|
|
|
|
|
private BrowserController mBrowserController; |
|
|
|
|
|
|
|
|
|
private GestureDetector mGestureDetector; |
|
|
|
|
|
|
|
|
|
private Activity mActivity; |
|
|
|
|
|
|
|
|
|
private WebSettings mSettings; |
|
|
|
|
|
|
|
|
|
private static int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
|
|
|
|
|
|
private static String mHomepage; |
|
|
|
|
|
|
|
|
|
private static String mDefaultUserAgent; |
|
|
|
|
|
|
|
|
|
private static Bitmap mWebpageBitmap; |
|
|
|
|
|
|
|
|
|
private static SharedPreferences mPreferences; |
|
|
|
|
|
|
|
|
|
private static boolean mWideViewPort; |
|
|
|
|
|
|
|
|
|
private AdBlock mAdBlock; |
|
|
|
|
|
|
|
|
|
private boolean isForegroundTab; |
|
|
|
|
|
|
|
|
|
private IntentUtils mIntentUtils; |
|
|
|
|
private Paint mPaint = new Paint(); |
|
|
|
|
private static final float[] mNegativeColorArray = { -1.0f, 0, 0, 0, 255, // red
|
|
|
|
|
0, -1.0f, 0, 0, 255, // green
|
|
|
|
|
0, 0, -1.0f, 0, 255, // blue
|
|
|
|
|
0, 0, 0, 1.0f, 0 // alpha
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
|
@SuppressLint("NewApi") |
|
|
|
@ -88,6 +83,8 @@ public class LightningView {
@@ -88,6 +83,8 @@ public class LightningView {
|
|
|
|
|
mWebView.setAnimationCacheEnabled(false); |
|
|
|
|
mWebView.setDrawingCacheEnabled(true); |
|
|
|
|
mWebView.setBackgroundColor(activity.getResources().getColor(android.R.color.white)); |
|
|
|
|
mWebView.setBackground(null); |
|
|
|
|
|
|
|
|
|
if (API > 15) { |
|
|
|
|
mWebView.getRootView().setBackground(null); |
|
|
|
|
} else { |
|
|
|
@ -137,12 +134,12 @@ public class LightningView {
@@ -137,12 +134,12 @@ public class LightningView {
|
|
|
|
|
mSettings = mWebView.getSettings(); |
|
|
|
|
initializeSettings(mWebView.getSettings(), activity); |
|
|
|
|
initializePreferences(activity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (url != null) { |
|
|
|
|
if (!url.trim().isEmpty()) { |
|
|
|
|
mWebView.loadUrl(url); |
|
|
|
|
} else { |
|
|
|
|
//don't load anything, the user is looking for a blank tab
|
|
|
|
|
// don't load anything, the user is looking for a blank tab
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (mHomepage.startsWith("about:home")) { |
|
|
|
@ -160,87 +157,87 @@ public class LightningView {
@@ -160,87 +157,87 @@ public class LightningView {
|
|
|
|
|
String home; |
|
|
|
|
home = HomepageVariables.HEAD; |
|
|
|
|
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) { |
|
|
|
|
case 0: |
|
|
|
|
// CUSTOM SEARCH
|
|
|
|
|
home = home + "file:///android_asset/lightning.png"; |
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home |
|
|
|
|
+ mPreferences.getString(PreferenceConstants.SEARCH_URL, |
|
|
|
|
Constants.GOOGLE_SEARCH); |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
// GOOGLE_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/google.png"; |
|
|
|
|
// + "https://www.google.com/images/srpr/logo11w.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.GOOGLE_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
// ANDROID SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/lightning.png"; |
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.ANDROID_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 3: |
|
|
|
|
// BING_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/bing.png"; |
|
|
|
|
// +
|
|
|
|
|
// "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.BING_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
// YAHOO_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/yahoo.png"; |
|
|
|
|
// +
|
|
|
|
|
// "http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.YAHOO_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 5: |
|
|
|
|
// STARTPAGE_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/startpage.png"; |
|
|
|
|
// + "https://startpage.com/graphics/startp_logo.gif";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.STARTPAGE_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 6: |
|
|
|
|
// STARTPAGE_MOBILE
|
|
|
|
|
home = home + "file:///android_asset/startpage.png"; |
|
|
|
|
// + "https://startpage.com/graphics/startp_logo.gif";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.STARTPAGE_MOBILE_SEARCH; |
|
|
|
|
case 7: |
|
|
|
|
// DUCK_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/duckduckgo.png"; |
|
|
|
|
// +
|
|
|
|
|
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.DUCK_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 8: |
|
|
|
|
// DUCK_LITE_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/duckduckgo.png"; |
|
|
|
|
// +
|
|
|
|
|
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.DUCK_LITE_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 9: |
|
|
|
|
// BAIDU_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/baidu.png"; |
|
|
|
|
// + "http://www.baidu.com/img/bdlogo.gif";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.BAIDU_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 10: |
|
|
|
|
// YANDEX_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/yandex.png"; |
|
|
|
|
// +
|
|
|
|
|
// "http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.YANDEX_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 0: |
|
|
|
|
// CUSTOM SEARCH
|
|
|
|
|
home = home + "file:///android_asset/lightning.png"; |
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home |
|
|
|
|
+ mPreferences.getString(PreferenceConstants.SEARCH_URL, |
|
|
|
|
Constants.GOOGLE_SEARCH); |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
// GOOGLE_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/google.png"; |
|
|
|
|
// + "https://www.google.com/images/srpr/logo11w.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.GOOGLE_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
// ANDROID SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/lightning.png"; |
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.ANDROID_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 3: |
|
|
|
|
// BING_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/bing.png"; |
|
|
|
|
// +
|
|
|
|
|
// "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.BING_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
// YAHOO_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/yahoo.png"; |
|
|
|
|
// +
|
|
|
|
|
// "http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.YAHOO_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 5: |
|
|
|
|
// STARTPAGE_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/startpage.png"; |
|
|
|
|
// + "https://startpage.com/graphics/startp_logo.gif";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.STARTPAGE_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 6: |
|
|
|
|
// STARTPAGE_MOBILE
|
|
|
|
|
home = home + "file:///android_asset/startpage.png"; |
|
|
|
|
// + "https://startpage.com/graphics/startp_logo.gif";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.STARTPAGE_MOBILE_SEARCH; |
|
|
|
|
case 7: |
|
|
|
|
// DUCK_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/duckduckgo.png"; |
|
|
|
|
// +
|
|
|
|
|
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.DUCK_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 8: |
|
|
|
|
// DUCK_LITE_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/duckduckgo.png"; |
|
|
|
|
// +
|
|
|
|
|
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.DUCK_LITE_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 9: |
|
|
|
|
// BAIDU_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/baidu.png"; |
|
|
|
|
// + "http://www.baidu.com/img/bdlogo.gif";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.BAIDU_SEARCH; |
|
|
|
|
break; |
|
|
|
|
case 10: |
|
|
|
|
// YANDEX_SEARCH;
|
|
|
|
|
home = home + "file:///android_asset/yandex.png"; |
|
|
|
|
// +
|
|
|
|
|
// "http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png";
|
|
|
|
|
home = home + HomepageVariables.MIDDLE; |
|
|
|
|
home = home + Constants.YANDEX_SEARCH; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -273,38 +270,38 @@ public class LightningView {
@@ -273,38 +270,38 @@ public class LightningView {
|
|
|
|
|
.getBoolean(PreferenceConstants.LOCATION, false)); |
|
|
|
|
if (API < 19) { |
|
|
|
|
switch (mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0)) { |
|
|
|
|
case 0: |
|
|
|
|
mSettings.setPluginState(PluginState.OFF); |
|
|
|
|
break; |
|
|
|
|
case 0: |
|
|
|
|
mSettings.setPluginState(PluginState.OFF); |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
mSettings.setPluginState(PluginState.ON_DEMAND); |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
mSettings.setPluginState(PluginState.ON); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) { |
|
|
|
|
case 1: |
|
|
|
|
mSettings.setPluginState(PluginState.ON_DEMAND); |
|
|
|
|
if (API > 16) { |
|
|
|
|
mSettings.setUserAgentString(WebSettings.getDefaultUserAgent(context)); |
|
|
|
|
} else { |
|
|
|
|
mSettings.setUserAgentString(mDefaultUserAgent); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
mSettings.setPluginState(PluginState.ON); |
|
|
|
|
mSettings.setUserAgentString(Constants.DESKTOP_USER_AGENT); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
case 3: |
|
|
|
|
mSettings.setUserAgentString(Constants.MOBILE_USER_AGENT); |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
mSettings.setUserAgentString(mPreferences.getString( |
|
|
|
|
PreferenceConstants.USER_AGENT_STRING, mDefaultUserAgent)); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) { |
|
|
|
|
case 1: |
|
|
|
|
if (API > 16) { |
|
|
|
|
mSettings.setUserAgentString(WebSettings.getDefaultUserAgent(context)); |
|
|
|
|
} else { |
|
|
|
|
mSettings.setUserAgentString(mDefaultUserAgent); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
mSettings.setUserAgentString(Constants.DESKTOP_USER_AGENT); |
|
|
|
|
break; |
|
|
|
|
case 3: |
|
|
|
|
mSettings.setUserAgentString(Constants.MOBILE_USER_AGENT); |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
mSettings.setUserAgentString(mPreferences.getString( |
|
|
|
|
PreferenceConstants.USER_AGENT_STRING, mDefaultUserAgent)); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mPreferences.getBoolean(PreferenceConstants.SAVE_PASSWORDS, false)) { |
|
|
|
@ -337,27 +334,28 @@ public class LightningView {
@@ -337,27 +334,28 @@ public class LightningView {
|
|
|
|
|
mSettings.setLoadWithOverviewMode(mPreferences.getBoolean( |
|
|
|
|
PreferenceConstants.OVERVIEW_MODE, true)); |
|
|
|
|
switch (mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3)) { |
|
|
|
|
case 1: |
|
|
|
|
mSettings.setTextZoom(200); |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
mSettings.setTextZoom(150); |
|
|
|
|
break; |
|
|
|
|
case 3: |
|
|
|
|
mSettings.setTextZoom(100); |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
mSettings.setTextZoom(75); |
|
|
|
|
break; |
|
|
|
|
case 5: |
|
|
|
|
mSettings.setTextZoom(50); |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
mSettings.setTextZoom(200); |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
mSettings.setTextZoom(150); |
|
|
|
|
break; |
|
|
|
|
case 3: |
|
|
|
|
mSettings.setTextZoom(100); |
|
|
|
|
break; |
|
|
|
|
case 4: |
|
|
|
|
mSettings.setTextZoom(75); |
|
|
|
|
break; |
|
|
|
|
case 5: |
|
|
|
|
mSettings.setTextZoom(50); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
|
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) |
|
|
|
|
public void initializeSettings(WebSettings settings, Context context) { |
|
|
|
|
this.setNormalRendering(); |
|
|
|
|
if (API < 18) { |
|
|
|
|
settings.setAppCacheMaxSize(Long.MAX_VALUE); |
|
|
|
|
} |
|
|
|
@ -427,6 +425,33 @@ public class LightningView {
@@ -427,6 +425,33 @@ public class LightningView {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setHardwareRendering() { |
|
|
|
|
mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, mPaint); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setNormalRendering() { |
|
|
|
|
mWebView.setLayerType(View.LAYER_TYPE_NONE, mPaint); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setColorMode(int mode) { |
|
|
|
|
switch (mode) { |
|
|
|
|
case 0: |
|
|
|
|
mPaint.setColorFilter(null); |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
ColorMatrixColorFilter filterInvert = new ColorMatrixColorFilter( |
|
|
|
|
mNegativeColorArray); |
|
|
|
|
mPaint.setColorFilter(filterInvert); |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
ColorMatrix cm = new ColorMatrix(); |
|
|
|
|
cm.setSaturation(0); |
|
|
|
|
ColorMatrixColorFilter filterGray = new ColorMatrixColorFilter(cm); |
|
|
|
|
mPaint.setColorFilter(filterGray); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public synchronized void pauseTimers() { |
|
|
|
|
if (mWebView != null) { |
|
|
|
|
mWebView.pauseTimers(); |
|
|
|
|