Added new layout algorithm option and formatted code
This commit is contained in:
parent
62430ce72e
commit
25818dd8e9
@ -67,8 +67,7 @@ public class LightningView {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public LightningView(Activity activity, String url,
|
public LightningView(Activity activity, String url, CookieManager cookieManager) {
|
||||||
CookieManager cookieManager) {
|
|
||||||
|
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mWebView = new WebView(activity);
|
mWebView = new WebView(activity);
|
||||||
@ -81,8 +80,7 @@ public class LightningView {
|
|||||||
try {
|
try {
|
||||||
mBrowserController = (BrowserController) activity;
|
mBrowserController = (BrowserController) activity;
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new ClassCastException(activity
|
throw new ClassCastException(activity + " must implement BrowserController");
|
||||||
+ " must implement BrowserController");
|
|
||||||
}
|
}
|
||||||
mIntentUtils = new IntentUtils(mBrowserController);
|
mIntentUtils = new IntentUtils(mBrowserController);
|
||||||
mWebView.setDrawingCacheBackgroundColor(0x00000000);
|
mWebView.setDrawingCacheBackgroundColor(0x00000000);
|
||||||
@ -90,8 +88,7 @@ public class LightningView {
|
|||||||
mWebView.setFocusable(true);
|
mWebView.setFocusable(true);
|
||||||
mWebView.setAnimationCacheEnabled(false);
|
mWebView.setAnimationCacheEnabled(false);
|
||||||
mWebView.setDrawingCacheEnabled(true);
|
mWebView.setDrawingCacheEnabled(true);
|
||||||
mWebView.setBackgroundColor(activity.getResources().getColor(
|
mWebView.setBackgroundColor(activity.getResources().getColor(android.R.color.white));
|
||||||
android.R.color.white));
|
|
||||||
if (API > 15) {
|
if (API > 15) {
|
||||||
mWebView.getRootView().setBackground(null);
|
mWebView.getRootView().setBackground(null);
|
||||||
} else {
|
} else {
|
||||||
@ -105,8 +102,7 @@ public class LightningView {
|
|||||||
mWebView.setWebChromeClient(new LightningChromeClient(activity));
|
mWebView.setWebChromeClient(new LightningChromeClient(activity));
|
||||||
mWebView.setWebViewClient(new LightningWebClient(activity));
|
mWebView.setWebViewClient(new LightningWebClient(activity));
|
||||||
mWebView.setDownloadListener(new LightningDownloadListener(activity));
|
mWebView.setDownloadListener(new LightningDownloadListener(activity));
|
||||||
mGestureDetector = new GestureDetector(activity,
|
mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
|
||||||
new CustomGestureListener());
|
|
||||||
mWebView.setOnTouchListener(new OnTouchListener() {
|
mWebView.setOnTouchListener(new OnTouchListener() {
|
||||||
|
|
||||||
float mLocation;
|
float mLocation;
|
||||||
@ -115,6 +111,7 @@ public class LightningView {
|
|||||||
|
|
||||||
int mAction;
|
int mAction;
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent arg1) {
|
public boolean onTouch(View view, MotionEvent arg1) {
|
||||||
if (view != null && !view.hasFocus()) {
|
if (view != null && !view.hasFocus()) {
|
||||||
@ -213,14 +210,16 @@ public class LightningView {
|
|||||||
case 7:
|
case 7:
|
||||||
// DUCK_SEARCH;
|
// DUCK_SEARCH;
|
||||||
home = home + "file:///android_asset/duckduckgo.png";
|
home = home + "file:///android_asset/duckduckgo.png";
|
||||||
// + "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
// +
|
||||||
|
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
||||||
home = home + HomepageVariables.MIDDLE;
|
home = home + HomepageVariables.MIDDLE;
|
||||||
home = home + Constants.DUCK_SEARCH;
|
home = home + Constants.DUCK_SEARCH;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
// DUCK_LITE_SEARCH;
|
// DUCK_LITE_SEARCH;
|
||||||
home = home + "file:///android_asset/duckduckgo.png";
|
home = home + "file:///android_asset/duckduckgo.png";
|
||||||
// + "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
// +
|
||||||
|
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
|
||||||
home = home + HomepageVariables.MIDDLE;
|
home = home + HomepageVariables.MIDDLE;
|
||||||
home = home + Constants.DUCK_LITE_SEARCH;
|
home = home + Constants.DUCK_LITE_SEARCH;
|
||||||
break;
|
break;
|
||||||
@ -259,21 +258,18 @@ public class LightningView {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
|
@SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
|
||||||
public synchronized void initializePreferences(Context context) {
|
public synchronized void initializePreferences(Context context) {
|
||||||
mPreferences = context.getSharedPreferences(
|
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
|
||||||
PreferenceConstants.PREFERENCES, 0);
|
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
|
||||||
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE,
|
|
||||||
Constants.HOMEPAGE);
|
|
||||||
mAdBlock.updatePreference();
|
mAdBlock.updatePreference();
|
||||||
if (mSettings == null && mWebView != null) {
|
if (mSettings == null && mWebView != null) {
|
||||||
mSettings = mWebView.getSettings();
|
mSettings = mWebView.getSettings();
|
||||||
} else if (mSettings == null) {
|
} else if (mSettings == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mSettings.setGeolocationEnabled(mPreferences.getBoolean(
|
mSettings.setGeolocationEnabled(mPreferences
|
||||||
PreferenceConstants.LOCATION, false));
|
.getBoolean(PreferenceConstants.LOCATION, false));
|
||||||
if (API < 19) {
|
if (API < 19) {
|
||||||
switch (mPreferences.getInt(
|
switch (mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0)) {
|
||||||
PreferenceConstants.ADOBE_FLASH_SUPPORT, 0)) {
|
|
||||||
case 0:
|
case 0:
|
||||||
mSettings.setPluginState(PluginState.OFF);
|
mSettings.setPluginState(PluginState.OFF);
|
||||||
break;
|
break;
|
||||||
@ -291,8 +287,7 @@ public class LightningView {
|
|||||||
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) {
|
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) {
|
||||||
case 1:
|
case 1:
|
||||||
if (API > 16) {
|
if (API > 16) {
|
||||||
mSettings.setUserAgentString(WebSettings
|
mSettings.setUserAgentString(WebSettings.getDefaultUserAgent(context));
|
||||||
.getDefaultUserAgent(context));
|
|
||||||
} else {
|
} else {
|
||||||
mSettings.setUserAgentString(mDefaultUserAgent);
|
mSettings.setUserAgentString(mDefaultUserAgent);
|
||||||
}
|
}
|
||||||
@ -316,25 +311,26 @@ public class LightningView {
|
|||||||
mSettings.setSaveFormData(true);
|
mSettings.setSaveFormData(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPreferences.getBoolean("java", true)) {
|
if (mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, true)) {
|
||||||
mSettings.setJavaScriptEnabled(true);
|
mSettings.setJavaScriptEnabled(true);
|
||||||
mSettings.setJavaScriptCanOpenWindowsAutomatically(true);
|
mSettings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPreferences.getBoolean("textreflow", false)) {
|
if (mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, false)) {
|
||||||
mSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
|
mSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
|
||||||
|
} else if (API >= android.os.Build.VERSION_CODES.KITKAT) {
|
||||||
|
mSettings.setLayoutAlgorithm(LayoutAlgorithm.TEXT_AUTOSIZING);
|
||||||
} else {
|
} else {
|
||||||
mSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
|
mSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSettings.setBlockNetworkImage(mPreferences.getBoolean(
|
mSettings.setBlockNetworkImage(mPreferences.getBoolean(PreferenceConstants.BLOCK_IMAGES,
|
||||||
PreferenceConstants.BLOCK_IMAGES, false));
|
false));
|
||||||
mSettings.setSupportMultipleWindows(mPreferences.getBoolean(
|
mSettings.setSupportMultipleWindows(mPreferences.getBoolean(PreferenceConstants.POPUPS,
|
||||||
PreferenceConstants.POPUPS, true));
|
true));
|
||||||
mSettings.setUseWideViewPort(mPreferences.getBoolean(
|
mSettings.setUseWideViewPort(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT,
|
||||||
PreferenceConstants.USE_WIDE_VIEWPORT, true));
|
true));
|
||||||
mWideViewPort = mPreferences.getBoolean(
|
mWideViewPort = mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, true);
|
||||||
PreferenceConstants.USE_WIDE_VIEWPORT, true);
|
|
||||||
mSettings.setLoadWithOverviewMode(mPreferences.getBoolean(
|
mSettings.setLoadWithOverviewMode(mPreferences.getBoolean(
|
||||||
PreferenceConstants.OVERVIEW_MODE, true));
|
PreferenceConstants.OVERVIEW_MODE, true));
|
||||||
switch (mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3)) {
|
switch (mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3)) {
|
||||||
@ -357,7 +353,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@SuppressLint({"SetJavaScriptEnabled", "NewApi"})
|
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
|
||||||
public void initializeSettings(WebSettings settings, Context context) {
|
public void initializeSettings(WebSettings settings, Context context) {
|
||||||
if (API < 18) {
|
if (API < 18) {
|
||||||
settings.setAppCacheMaxSize(Long.MAX_VALUE);
|
settings.setAppCacheMaxSize(Long.MAX_VALUE);
|
||||||
@ -369,15 +365,13 @@ public class LightningView {
|
|||||||
settings.setMediaPlaybackRequiresUserGesture(true);
|
settings.setMediaPlaybackRequiresUserGesture(true);
|
||||||
}
|
}
|
||||||
if (API < 19) {
|
if (API < 19) {
|
||||||
settings.setDatabasePath(context.getFilesDir().getAbsolutePath()
|
settings.setDatabasePath(context.getFilesDir().getAbsolutePath() + "/databases");
|
||||||
+ "/databases");
|
|
||||||
}
|
}
|
||||||
settings.setDomStorageEnabled(true);
|
settings.setDomStorageEnabled(true);
|
||||||
settings.setAppCachePath(context.getCacheDir().toString());
|
settings.setAppCachePath(context.getCacheDir().toString());
|
||||||
settings.setAppCacheEnabled(true);
|
settings.setAppCacheEnabled(true);
|
||||||
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||||
settings.setGeolocationDatabasePath(context.getCacheDir()
|
settings.setGeolocationDatabasePath(context.getCacheDir().getAbsolutePath());
|
||||||
.getAbsolutePath());
|
|
||||||
settings.setAllowFileAccess(true);
|
settings.setAllowFileAccess(true);
|
||||||
settings.setDatabaseEnabled(true);
|
settings.setDatabaseEnabled(true);
|
||||||
settings.setSupportZoom(true);
|
settings.setSupportZoom(true);
|
||||||
@ -564,15 +558,13 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WebResourceResponse shouldInterceptRequest(WebView view,
|
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
|
||||||
String url) {
|
|
||||||
if (mAdBlock.isAd(url)) {
|
if (mAdBlock.isAd(url)) {
|
||||||
ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
||||||
return new WebResourceResponse("text/plain", "utf-8", EMPTY);
|
return new WebResourceResponse("text/plain", "utf-8", EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useProxy = mPreferences.getBoolean(
|
boolean useProxy = mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false);
|
||||||
PreferenceConstants.USE_PROXY, false);
|
|
||||||
boolean mDoLeakHardening = false;
|
boolean mDoLeakHardening = false;
|
||||||
|
|
||||||
if (!useProxy) {
|
if (!useProxy) {
|
||||||
@ -590,19 +582,15 @@ public class LightningView {
|
|||||||
|
|
||||||
Proxy proxy = null;
|
Proxy proxy = null;
|
||||||
|
|
||||||
String host = mPreferences.getString(
|
String host = mPreferences.getString(PreferenceConstants.USE_PROXY_HOST,
|
||||||
PreferenceConstants.USE_PROXY_HOST, "localhost");
|
"localhost");
|
||||||
int port = mPreferences.getInt(
|
int port = mPreferences.getInt(PreferenceConstants.USE_PROXY_PORT, 8118);
|
||||||
PreferenceConstants.USE_PROXY_PORT, 8118);
|
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
|
||||||
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host,
|
|
||||||
port));
|
|
||||||
|
|
||||||
HttpURLConnection.setFollowRedirects(true);
|
HttpURLConnection.setFollowRedirects(true);
|
||||||
HttpURLConnection conn = (HttpURLConnection) uURl
|
HttpURLConnection conn = (HttpURLConnection) uURl.openConnection(proxy);
|
||||||
.openConnection(proxy);
|
|
||||||
conn.setInstanceFollowRedirects(true);
|
conn.setInstanceFollowRedirects(true);
|
||||||
conn.setRequestProperty("User-Agent",
|
conn.setRequestProperty("User-Agent", mSettings.getUserAgentString());
|
||||||
mSettings.getUserAgentString());
|
|
||||||
|
|
||||||
// conn.setRequestProperty("Transfer-Encoding", "chunked");
|
// conn.setRequestProperty("Transfer-Encoding", "chunked");
|
||||||
// conn.setUseCaches(false);
|
// conn.setUseCaches(false);
|
||||||
@ -633,8 +621,7 @@ public class LightningView {
|
|||||||
if (cType != null && cType.startsWith("text")) {
|
if (cType != null && cType.startsWith("text")) {
|
||||||
InputStream fStream;
|
InputStream fStream;
|
||||||
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(
|
BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());
|
||||||
conn.getInputStream());
|
|
||||||
ByteArrayBuffer baf = new ByteArrayBuffer(connLen);
|
ByteArrayBuffer baf = new ByteArrayBuffer(connLen);
|
||||||
int read;
|
int read;
|
||||||
int bufSize = 2048;
|
int bufSize = 2048;
|
||||||
@ -650,17 +637,16 @@ public class LightningView {
|
|||||||
|
|
||||||
fStream = new ByteArrayInputStream(plainText);
|
fStream = new ByteArrayInputStream(plainText);
|
||||||
|
|
||||||
fStream = new ReplacingInputStream(
|
fStream = new ReplacingInputStream(new ByteArrayInputStream(plainText),
|
||||||
new ByteArrayInputStream(plainText),
|
|
||||||
"poster=".getBytes(), "foo=".getBytes());
|
"poster=".getBytes(), "foo=".getBytes());
|
||||||
fStream = new ReplacingInputStream(fStream,
|
fStream = new ReplacingInputStream(fStream, "Poster=".getBytes(),
|
||||||
"Poster=".getBytes(), "foo=".getBytes());
|
"foo=".getBytes());
|
||||||
fStream = new ReplacingInputStream(fStream,
|
fStream = new ReplacingInputStream(fStream, "Poster=".getBytes(),
|
||||||
"Poster=".getBytes(), "foo=".getBytes());
|
"foo=".getBytes());
|
||||||
fStream = new ReplacingInputStream(fStream,
|
fStream = new ReplacingInputStream(fStream, ".poster".getBytes(),
|
||||||
".poster".getBytes(), ".foo".getBytes());
|
".foo".getBytes());
|
||||||
fStream = new ReplacingInputStream(fStream,
|
fStream = new ReplacingInputStream(fStream, "\"poster\"".getBytes(),
|
||||||
"\"poster\"".getBytes(), "\"foo\"".getBytes());
|
"\"foo\"".getBytes());
|
||||||
|
|
||||||
return new WebResourceResponse(cType, cEnc, fStream);
|
return new WebResourceResponse(cType, cEnc, fStream);
|
||||||
}/**
|
}/**
|
||||||
@ -676,8 +662,7 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(Constants.TAG, "Error filtering stream", e);
|
Log.e(Constants.TAG, "Error filtering stream", e);
|
||||||
ByteArrayInputStream EMPTY = new ByteArrayInputStream(
|
ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes());
|
||||||
"".getBytes());
|
|
||||||
return new WebResourceResponse("text/plain", "utf-8", EMPTY);
|
return new WebResourceResponse("text/plain", "utf-8", EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -711,9 +696,8 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedHttpAuthRequest(final WebView view,
|
public void onReceivedHttpAuthRequest(final WebView view, final HttpAuthHandler handler,
|
||||||
final HttpAuthHandler handler, final String host,
|
final String host, final String realm) {
|
||||||
final String realm) {
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
final EditText name = new EditText(mActivity);
|
final EditText name = new EditText(mActivity);
|
||||||
@ -731,12 +715,10 @@ public class LightningView {
|
|||||||
builder.setTitle(mActivity.getString(R.string.title_sign_in));
|
builder.setTitle(mActivity.getString(R.string.title_sign_in));
|
||||||
builder.setView(passLayout);
|
builder.setView(passLayout);
|
||||||
builder.setCancelable(true)
|
builder.setCancelable(true)
|
||||||
.setPositiveButton(
|
.setPositiveButton(mActivity.getString(R.string.title_sign_in),
|
||||||
mActivity.getString(R.string.title_sign_in),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
String user = name.getText().toString();
|
String user = name.getText().toString();
|
||||||
String pass = password.getText().toString();
|
String pass = password.getText().toString();
|
||||||
handler.proceed(user.trim(), pass.trim());
|
handler.proceed(user.trim(), pass.trim());
|
||||||
@ -744,12 +726,10 @@ public class LightningView {
|
|||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(
|
.setNegativeButton(mActivity.getString(R.string.action_cancel),
|
||||||
mActivity.getString(R.string.action_cancel),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
handler.cancel();
|
handler.cancel();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -767,27 +747,22 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedSslError(WebView view,
|
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
|
||||||
final SslErrorHandler handler, SslError error) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
builder.setTitle(mActivity.getString(R.string.title_warning));
|
builder.setTitle(mActivity.getString(R.string.title_warning));
|
||||||
builder.setMessage(
|
builder.setMessage(mActivity.getString(R.string.message_untrusted_certificate))
|
||||||
mActivity.getString(R.string.message_untrusted_certificate))
|
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(
|
.setPositiveButton(mActivity.getString(R.string.action_yes),
|
||||||
mActivity.getString(R.string.action_yes),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
handler.proceed();
|
handler.proceed();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(mActivity.getString(R.string.action_no),
|
.setNegativeButton(mActivity.getString(R.string.action_no),
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
handler.cancel();
|
handler.cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -801,29 +776,23 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFormResubmission(WebView view, final Message dontResend,
|
public void onFormResubmission(WebView view, final Message dontResend, final Message resend) {
|
||||||
final Message resend) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
|
||||||
builder.setTitle(mActivity
|
builder.setTitle(mActivity.getString(R.string.title_form_resubmission));
|
||||||
.getString(R.string.title_form_resubmission));
|
builder.setMessage(mActivity.getString(R.string.message_form_resubmission))
|
||||||
builder.setMessage(
|
|
||||||
mActivity.getString(R.string.message_form_resubmission))
|
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(
|
.setPositiveButton(mActivity.getString(R.string.action_yes),
|
||||||
mActivity.getString(R.string.action_yes),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
|
|
||||||
resend.sendToTarget();
|
resend.sendToTarget();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton("No",
|
.setNegativeButton(mActivity.getString(R.string.action_no),
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
|
|
||||||
dontResend.sendToTarget();
|
dontResend.sendToTarget();
|
||||||
}
|
}
|
||||||
@ -839,8 +808,8 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
if (url.contains("mailto:")) {
|
if (url.contains("mailto:")) {
|
||||||
MailTo mailTo = MailTo.parse(url);
|
MailTo mailTo = MailTo.parse(url);
|
||||||
Intent i = Utils.newEmailIntent(mActivity, mailTo.getTo(),
|
Intent i = Utils.newEmailIntent(mActivity, mailTo.getTo(), mailTo.getSubject(),
|
||||||
mailTo.getSubject(), mailTo.getBody(), mailTo.getCc());
|
mailTo.getBody(), mailTo.getCc());
|
||||||
mActivity.startActivity(i);
|
mActivity.startActivity(i);
|
||||||
view.reload();
|
view.reload();
|
||||||
return true;
|
return true;
|
||||||
@ -908,24 +877,19 @@ public class LightningView {
|
|||||||
} else {
|
} else {
|
||||||
org = origin;
|
org = origin;
|
||||||
}
|
}
|
||||||
builder.setMessage(
|
builder.setMessage(org + mActivity.getString(R.string.message_location))
|
||||||
org + mActivity.getString(R.string.message_location))
|
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(
|
.setPositiveButton(mActivity.getString(R.string.action_allow),
|
||||||
mActivity.getString(R.string.action_allow),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
callback.invoke(origin, true, remember);
|
callback.invoke(origin, true, remember);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(
|
.setNegativeButton(mActivity.getString(R.string.action_dont_allow),
|
||||||
mActivity.getString(R.string.action_dont_allow),
|
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
int id) {
|
|
||||||
callback.invoke(origin, false, remember);
|
callback.invoke(origin, false, remember);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -935,8 +899,8 @@ public class LightningView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateWindow(WebView view, boolean isDialog,
|
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture,
|
||||||
boolean isUserGesture, Message resultMsg) {
|
Message resultMsg) {
|
||||||
mBrowserController.onCreateWindow(isUserGesture, resultMsg);
|
mBrowserController.onCreateWindow(isUserGesture, resultMsg);
|
||||||
return isUserGesture;
|
return isUserGesture;
|
||||||
}
|
}
|
||||||
@ -951,13 +915,11 @@ public class LightningView {
|
|||||||
mBrowserController.openFileChooser(uploadMsg);
|
mBrowserController.openFileChooser(uploadMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openFileChooser(ValueCallback<Uri> uploadMsg,
|
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
|
||||||
String acceptType) {
|
|
||||||
mBrowserController.openFileChooser(uploadMsg);
|
mBrowserController.openFileChooser(uploadMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openFileChooser(ValueCallback<Uri> uploadMsg,
|
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
|
||||||
String acceptType, String capture) {
|
|
||||||
mBrowserController.openFileChooser(uploadMsg);
|
mBrowserController.openFileChooser(uploadMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,7 +942,8 @@ public class LightningView {
|
|||||||
@Override
|
@Override
|
||||||
public void onShowCustomView(View view, CustomViewCallback callback) {
|
public void onShowCustomView(View view, CustomViewCallback callback) {
|
||||||
// While these lines might look like they work, in practice,
|
// While these lines might look like they work, in practice,
|
||||||
// Full-screen videos won't work correctly. I may test this out some more
|
// Full-screen videos won't work correctly. I may test this out some
|
||||||
|
// more
|
||||||
// if (view instanceof FrameLayout) {
|
// if (view instanceof FrameLayout) {
|
||||||
// FrameLayout frame = (FrameLayout) view;
|
// FrameLayout frame = (FrameLayout) view;
|
||||||
// if (frame.getFocusedChild() instanceof VideoView) {
|
// if (frame.getFocusedChild() instanceof VideoView) {
|
||||||
@ -991,8 +954,7 @@ public class LightningView {
|
|||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
Activity activity = mBrowserController.getActivity();
|
Activity activity = mBrowserController.getActivity();
|
||||||
mBrowserController.onShowCustomView(view,
|
mBrowserController.onShowCustomView(view, activity.getRequestedOrientation(), callback);
|
||||||
activity.getRequestedOrientation(), callback);
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -1004,7 +966,8 @@ public class LightningView {
|
|||||||
public void onShowCustomView(View view, int requestedOrientation,
|
public void onShowCustomView(View view, int requestedOrientation,
|
||||||
CustomViewCallback callback) {
|
CustomViewCallback callback) {
|
||||||
// While these lines might look like they work, in practice,
|
// While these lines might look like they work, in practice,
|
||||||
// Full-screen videos won't work correctly. I may test this out some more
|
// Full-screen videos won't work correctly. I may test this out some
|
||||||
|
// more
|
||||||
// if (view instanceof FrameLayout) {
|
// if (view instanceof FrameLayout) {
|
||||||
// FrameLayout frame = (FrameLayout) view;
|
// FrameLayout frame = (FrameLayout) view;
|
||||||
// if (frame.getFocusedChild() instanceof VideoView) {
|
// if (frame.getFocusedChild() instanceof VideoView) {
|
||||||
@ -1014,8 +977,7 @@ public class LightningView {
|
|||||||
// video.setVisibility(View.GONE);
|
// video.setVisibility(View.GONE);
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
mBrowserController.onShowCustomView(view, requestedOrientation,
|
mBrowserController.onShowCustomView(view, requestedOrientation, callback);
|
||||||
callback);
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user