- Swipe gestures to go back and forth - Reverted to old icon :( - ability to hide the status bar - progress bar indicating page load progress - clear cookies button - added proguard file - bugfixes/random stuff I changedmaster
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 123 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 21 KiB |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
# To enable ProGuard in your project, edit project.properties |
||||
# to define the proguard.config property as described in that file. |
||||
# |
||||
# Add project specific ProGuard rules here. |
||||
# By default, the flags in this file are appended to flags specified |
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt |
||||
# You can edit the include path and order by changing the ProGuard |
||||
# include property in project.properties. |
||||
# |
||||
# For more details, see |
||||
# http://developer.android.com/guide/developing/tools/proguard.html |
||||
|
||||
# Add any project specific keep options here: |
||||
|
||||
# If your project uses WebView with JS, uncomment the following |
||||
# and specify the fully qualified class name to the JavaScript interface |
||||
# class: |
||||
-keepclassmembers class fqcn.of.javascript.interface.for.webview { |
||||
public *; |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.webviewclasses.CustomChromeClient{ |
||||
public *; |
||||
private *; |
||||
protected *; |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.webviewclasses.CustomWebViewClient{ |
||||
public *; |
||||
private *; |
||||
protected *; |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.customwebview.CustomWebView{ |
||||
public *; |
||||
private *; |
||||
protected *; |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.activities.BrowserActivity{ |
||||
public void browserSettings(...); |
||||
public void makeTab(...); |
||||
public void newTab(...); |
||||
public void onLongClick(...); |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.incognitoclasses.IncognitoChromeClient{ |
||||
public *; |
||||
private *; |
||||
protected *; |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.incognitoclasses.IncognitoWebViewClient{ |
||||
public *; |
||||
private *; |
||||
protected *; |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.customwebview.IncognitoWebView{ |
||||
public *; |
||||
private *; |
||||
protected *; |
||||
} |
||||
|
||||
-keep class acr.browser.barebones.activities.IncognitoModeActivity{ |
||||
public void browserSettings(...); |
||||
public void makeTab(...); |
||||
public void newTab(...); |
||||
} |
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 179 B |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 20 KiB |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
|
||||
<item android:id="@android:id/background" |
||||
android:drawable="@drawable/progress_bar_bg" /> |
||||
|
||||
<item android:id="@android:id/secondaryProgress"> |
||||
<scale android:scaleWidth="100%" |
||||
android:drawable="@drawable/progress_bar" /> |
||||
</item> |
||||
|
||||
<item android:id="@android:id/progress"> |
||||
<scale android:scaleWidth="100%" |
||||
android:drawable="@drawable/progress_bar" /> |
||||
</item> |
||||
|
||||
</layer-list> |
@ -1,26 +1,57 @@
@@ -1,26 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
|
||||
<string name="app_name">Lightning</string> |
||||
<string name="google">Google</string> |
||||
<string name="settings">瀏覽器設定</string> |
||||
<string name="location">允許網頁存取您的位置資訊</string> |
||||
<string name="password">儲存密碼</string> |
||||
<string name="agent">使用者代理</string> |
||||
<string name="history">退出時清除歷史記錄(自動清理緩存)</string> |
||||
<string name="email">電郵給開發者</string> |
||||
<string name="flash">啓用 Adobe Flash(若已安裝)</string> |
||||
<string name="mobile">以手機版檢視</string> |
||||
<string name="desk">以電腦桌面版檢視</string> |
||||
<string name="custom">自定義使用者代理</string> |
||||
<string name="settings">瀏覽器設置</string> |
||||
<string name="location">允許站點訪問地理位置</string> |
||||
<string name="password">保存密碼</string> |
||||
<string name="agent">User Agent</string> |
||||
<string name="history">清空歷史記錄</string> |
||||
<string name="email">郵件開發者</string> |
||||
<string name="flash">啟用 Adobe Flash</string> |
||||
<string name="mobile">作為移動設備訪問</string> |
||||
<string name="desk">作為桌面設備訪問</string> |
||||
<string name="custom">自定義 User Agent</string> |
||||
<string name="home">首頁</string> |
||||
<string name="settingshelp">設定僅套用於新的標簽頁</string> |
||||
<string name="fullscreen">啓用全螢幕模式</string> |
||||
<string name="java">啓用 JavaScript</string> |
||||
<string name="menu_history">History</string> |
||||
<string name="menu_add">加入到書簽</string> |
||||
<string name="menu_bookmarks">我的書簽</string> |
||||
<string name="settingshelp">設置僅將應用於新標簽頁</string> |
||||
<string name="fullscreen">啟用全屏模式</string> |
||||
<string name="java">啟用 JavaScript</string> |
||||
<string name="saveTab">恢復丟失標簽</string> |
||||
<string name="settings_title">設置</string> |
||||
<string name="download">下載位置</string> |
||||
<string name="advanced">高級設置</string> |
||||
<string name="source">源碼</string> |
||||
<string name="license">許可證</string> |
||||
<string name="github">github.com/anthonycr/Lightning-Browser</string> |
||||
<string name="apache">Apache License 2.0</string> |
||||
<string name="title_activity_new_settings">NewSettings</string> |
||||
<string name="action_settings">設置</string> |
||||
<string name="version">應用版本</string> |
||||
<string name="cache">退出時清理緩存</string> |
||||
<string name="reflow">啟用文本重排</string> |
||||
<string name="block">屏蔽網頁圖像</string> |
||||
<string name="window">允許站點打開新窗口</string> |
||||
<string name="cookies">啟用 Cookies</string> |
||||
<string name="importbookmarks">從瀏覽器中導入書簽</string> |
||||
<string name="size">頁面文本尺寸</string> |
||||
<string name="title_activity_advanced_settings">AdvancedSettings</string> |
||||
<string name="hello_world">Hello world!</string> |
||||
<string name="recommended">(推薦)</string> |
||||
<string name="weird_look">(部分網頁可能看起來很奇怪)</string> |
||||
<string name="search">搜索引擎</string> |
||||
<string name="search_hint">搜索</string> |
||||
<string name="wideViewPort">使用寬視圖</string> |
||||
<string name="overViewMode">使用概覽模式載入頁面</string> |
||||
<string name="restore">啟動時恢復丟失頁面</string> |
||||
<string name="menu_history">歷史記錄</string> |
||||
<string name="menu_add">添加書簽</string> |
||||
<string name="menu_bookmarks">書簽列表</string> |
||||
<string name="menu_share">分享頁面</string> |
||||
<string name="menu_settings">設定</string> |
||||
<string name="menu_incognito">Incognito tab</string> |
||||
<string name="menu_new_tab">New tab</string> |
||||
</resources> |
||||
<string name="menu_settings">應用設置</string> |
||||
<string name="menu_incognito">隱身標簽</string> |
||||
<string name="menu_new_tab">新建標簽</string> |
||||
<string name="stock_browser_unavailable">(尚未檢測到原生瀏覽器)</string> |
||||
<string name="stock_browser_available">(檢測到已支持的原生瀏覽器)</string> |
||||
|
||||
</resources> |
@ -0,0 +1,216 @@
@@ -0,0 +1,216 @@
|
||||
package acr.browser.barebones.incognitoclasses; |
||||
|
||||
import acr.browser.barebones.R; |
||||
import acr.browser.barebones.activities.IncognitoModeActivity; |
||||
import android.annotation.SuppressLint; |
||||
import android.app.Activity; |
||||
import android.app.AlertDialog; |
||||
import android.content.Context; |
||||
import android.content.DialogInterface; |
||||
import android.graphics.Bitmap; |
||||
import android.graphics.BitmapFactory; |
||||
import android.net.Uri; |
||||
import android.os.Message; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.webkit.GeolocationPermissions; |
||||
import android.webkit.ValueCallback; |
||||
import android.webkit.WebChromeClient; |
||||
import android.webkit.WebView; |
||||
import android.webkit.WebStorage.QuotaUpdater; |
||||
import android.widget.FrameLayout; |
||||
|
||||
@SuppressLint("SetJavaScriptEnabled") |
||||
public class IncognitoChromeClient extends WebChromeClient { |
||||
private static Context context; |
||||
private static Activity browserActivity; |
||||
private static View mCustomView; |
||||
private static CustomViewCallback mCustomViewCallback; |
||||
public IncognitoChromeClient(IncognitoModeActivity activity){ |
||||
context = activity; |
||||
browserActivity = activity; |
||||
} |
||||
public Bitmap mDefaultVideoPoster; |
||||
public View mVideoProgressView; |
||||
public FrameLayout fullScreenContainer; |
||||
public int orientation; |
||||
|
||||
@Override |
||||
public void onExceededDatabaseQuota(String url, |
||||
String databaseIdentifier, long quota, |
||||
long estimatedDatabaseSize, long totalQuota, |
||||
QuotaUpdater quotaUpdater) { |
||||
quotaUpdater.updateQuota(totalQuota + estimatedDatabaseSize); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onProgressChanged(WebView view, int newProgress) { |
||||
IncognitoModeActivity.onProgressChanged(view.getId(), newProgress); |
||||
super.onProgressChanged(view, newProgress); |
||||
} |
||||
|
||||
@Override |
||||
public void onReachedMaxAppCacheSize(long requiredStorage, long quota, |
||||
QuotaUpdater quotaUpdater) { |
||||
quotaUpdater.updateQuota(quota + requiredStorage); |
||||
} |
||||
|
||||
@Override |
||||
public Bitmap getDefaultVideoPoster() { |
||||
if (mDefaultVideoPoster == null) { |
||||
mDefaultVideoPoster = BitmapFactory.decodeResource( |
||||
context.getResources(), android.R.color.black); |
||||
} |
||||
return mDefaultVideoPoster; |
||||
} |
||||
|
||||
@Override |
||||
public View getVideoLoadingProgressView() { |
||||
if (mVideoProgressView == null) { |
||||
LayoutInflater inflater = LayoutInflater.from(context); |
||||
mVideoProgressView = inflater.inflate( |
||||
android.R.layout.simple_spinner_item, null); |
||||
} |
||||
return mVideoProgressView; |
||||
} |
||||
|
||||
@Override |
||||
public void onCloseWindow(WebView window) { |
||||
Message msg = Message.obtain(); |
||||
msg.what = 3; |
||||
msg.arg1 = window.getId(); |
||||
IncognitoModeActivity.browserHandler.sendMessage(msg); |
||||
super.onCloseWindow(window); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onCreateWindow(WebView view, boolean isDialog, |
||||
boolean isUserGesture, final Message resultMsg) { |
||||
|
||||
if (isUserGesture) { |
||||
IncognitoModeActivity.onCreateWindow(resultMsg); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void onGeolocationPermissionsShowPrompt(final String origin, |
||||
final GeolocationPermissions.Callback callback) { |
||||
final boolean remember = true; |
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Location Access"); |
||||
String org = null; |
||||
if (origin.length() > 50) { |
||||
org = (String) origin.subSequence(0, 50) + "..."; |
||||
} else { |
||||
org = origin; |
||||
} |
||||
builder.setMessage(org + "\nWould like to use your Location ") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Allow", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
callback.invoke(origin, true, remember); |
||||
} |
||||
}) |
||||
.setNegativeButton("Don't Allow", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
callback.invoke(origin, false, remember); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onHideCustomView() { |
||||
if (mCustomView == null && mCustomViewCallback == null) { |
||||
return; |
||||
} |
||||
mCustomView = null; |
||||
mCustomView.setKeepScreenOn(false); |
||||
IncognitoModeActivity.onHideCustomView(fullScreenContainer, mCustomViewCallback, orientation); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedIcon(WebView view, Bitmap favicon) { |
||||
IncognitoModeActivity.setFavicon(view.getId(), favicon); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedTitle(final WebView view, final String title) { |
||||
IncognitoModeActivity.onReceivedTitle(view.getId(), title); |
||||
super.onReceivedTitle(view, title); |
||||
} |
||||
|
||||
@Override |
||||
public void onShowCustomView(View view, int requestedOrientation, |
||||
CustomViewCallback callback) { |
||||
if (mCustomView != null) { |
||||
callback.onCustomViewHidden(); |
||||
return; |
||||
} |
||||
view.setKeepScreenOn(true); |
||||
orientation = browserActivity.getRequestedOrientation(); |
||||
FrameLayout screen = (FrameLayout) browserActivity.getWindow().getDecorView(); |
||||
fullScreenContainer = new FrameLayout(context); |
||||
fullScreenContainer.setBackgroundColor(context.getResources().getColor( |
||||
R.color.black)); |
||||
IncognitoModeActivity.onShowCustomView(); |
||||
fullScreenContainer.addView(view, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
screen.addView(fullScreenContainer, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
mCustomView = view; |
||||
mCustomViewCallback = callback; |
||||
browserActivity.setRequestedOrientation(requestedOrientation); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onShowCustomView(View view, |
||||
WebChromeClient.CustomViewCallback callback) { |
||||
if (mCustomView != null) { |
||||
callback.onCustomViewHidden(); |
||||
return; |
||||
} |
||||
view.setKeepScreenOn(true); |
||||
orientation = browserActivity.getRequestedOrientation(); |
||||
FrameLayout screen = (FrameLayout) browserActivity.getWindow().getDecorView(); |
||||
fullScreenContainer = new FrameLayout(context); |
||||
fullScreenContainer.setBackgroundColor(context.getResources().getColor( |
||||
R.color.black)); |
||||
IncognitoModeActivity.onShowCustomView(); |
||||
fullScreenContainer.addView(view, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
screen.addView(fullScreenContainer, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
mCustomView = view; |
||||
mCustomViewCallback = callback; |
||||
browserActivity.setRequestedOrientation(browserActivity.getRequestedOrientation()); |
||||
} |
||||
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg) { |
||||
IncognitoModeActivity.openFileChooser(uploadMsg); |
||||
} |
||||
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, |
||||
String acceptType) { |
||||
IncognitoModeActivity.openFileChooser(uploadMsg); |
||||
} |
||||
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, |
||||
String acceptType, String capture) { |
||||
IncognitoModeActivity.openFileChooser(uploadMsg); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
package acr.browser.barebones.incognitoclasses; |
||||
|
||||
import acr.browser.barebones.activities.IncognitoModeActivity; |
||||
import acr.browser.barebones.utilities.Utils; |
||||
import android.app.AlertDialog; |
||||
import android.content.Context; |
||||
import android.content.DialogInterface; |
||||
import android.content.Intent; |
||||
import android.net.Uri; |
||||
import android.webkit.DownloadListener; |
||||
|
||||
public class IncognitoDownloadListener implements DownloadListener { |
||||
private static Context context; |
||||
public IncognitoDownloadListener(IncognitoModeActivity activity){ |
||||
context = activity; |
||||
} |
||||
@Override |
||||
public void onDownloadStart(final String url, String userAgent, |
||||
final String contentDisposition, final String mimetype, |
||||
long contentLength) { |
||||
if (url.endsWith(".mp4") || url.endsWith(".m4a")) { |
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Open as..."); |
||||
builder.setMessage( |
||||
"Do you want to download this video or watch it in an app?") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Download", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
Utils.downloadFile(context, url, |
||||
contentDisposition, mimetype); |
||||
} |
||||
}) |
||||
.setNegativeButton("Watch", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
Intent intent = new Intent( |
||||
Intent.ACTION_VIEW); |
||||
intent.setDataAndType(Uri.parse(url), |
||||
"video/mp4"); |
||||
intent.putExtra( |
||||
"acr.browser.barebones.Download", |
||||
1); |
||||
context.startActivity(intent); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
|
||||
} else { |
||||
Utils.downloadFile(context, url, contentDisposition, mimetype); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
package acr.browser.barebones.incognitoclasses; |
||||
|
||||
import acr.browser.barebones.activities.IncognitoModeActivity; |
||||
import android.view.View; |
||||
import android.view.View.OnLongClickListener; |
||||
|
||||
public class IncognitoLongClickListener implements OnLongClickListener{ |
||||
|
||||
@Override |
||||
public boolean onLongClick(View v) { |
||||
return IncognitoModeActivity.onLongClick(v.getId()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,202 @@
@@ -0,0 +1,202 @@
|
||||
package acr.browser.barebones.incognitoclasses; |
||||
|
||||
import acr.browser.barebones.activities.IncognitoModeActivity; |
||||
import acr.browser.barebones.utilities.Utils; |
||||
import android.app.AlertDialog; |
||||
import android.content.Context; |
||||
import android.content.DialogInterface; |
||||
import android.content.Intent; |
||||
import android.graphics.Bitmap; |
||||
import android.net.MailTo; |
||||
import android.net.Uri; |
||||
import android.net.http.SslError; |
||||
import android.os.Message; |
||||
import android.text.InputType; |
||||
import android.text.TextUtils; |
||||
import android.text.method.PasswordTransformationMethod; |
||||
import android.util.Log; |
||||
import android.webkit.HttpAuthHandler; |
||||
import android.webkit.SslErrorHandler; |
||||
import android.webkit.WebView; |
||||
import android.webkit.WebViewClient; |
||||
import android.widget.EditText; |
||||
import android.widget.LinearLayout; |
||||
|
||||
public class IncognitoWebViewClient extends WebViewClient { |
||||
private static Context context; |
||||
public IncognitoWebViewClient(IncognitoModeActivity browserActivity){ |
||||
context = browserActivity; |
||||
} |
||||
|
||||
@Override |
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) { |
||||
if (url.startsWith("market://") |
||||
|| url.startsWith("http://play.google.com") |
||||
|| url.startsWith("https://play.google.com")) { |
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, |
||||
Uri.parse(url)); |
||||
urlIntent.putExtra("acr.browser.barebones.Origin", |
||||
view.getId() + 1); |
||||
context.startActivity(urlIntent); |
||||
return true; |
||||
} else if (url.startsWith("http://www.youtube.com") |
||||
|| url.startsWith("https://www.youtube.com")) { |
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, |
||||
Uri.parse(url)); |
||||
urlIntent.putExtra("acr.browser.barebones.Origin", |
||||
view.getId() + 1); |
||||
context.startActivity(urlIntent); |
||||
return true; |
||||
} else if (url.startsWith("http://maps.google.com") |
||||
|| url.startsWith("https://maps.google.com")) { |
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, |
||||
Uri.parse(url)); |
||||
urlIntent.putExtra("acr.browser.barebones.Origin", |
||||
view.getId() + 1); |
||||
context.startActivity(urlIntent); |
||||
return true; |
||||
} else if (url.contains("tel:") || TextUtils.isDigitsOnly(url)) { |
||||
context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url))); |
||||
return true; |
||||
} else if (url.contains("mailto:")) { |
||||
MailTo mailTo = MailTo.parse(url); |
||||
Intent i = Utils.newEmailIntent(context, |
||||
mailTo.getTo(), mailTo.getSubject(), mailTo.getBody(), |
||||
mailTo.getCc()); |
||||
context.startActivity(i); |
||||
view.reload(); |
||||
return true; |
||||
} |
||||
return super.shouldOverrideUrlLoading(view, url); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedHttpAuthRequest(final WebView view, |
||||
final HttpAuthHandler handler, final String host, |
||||
final String realm) { |
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
final EditText name = new EditText(context); |
||||
final EditText password = new EditText(context); |
||||
LinearLayout passLayout = new LinearLayout(context); |
||||
passLayout.setOrientation(LinearLayout.VERTICAL); |
||||
|
||||
passLayout.addView(name); |
||||
passLayout.addView(password); |
||||
|
||||
name.setHint("Username"); |
||||
password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); |
||||
password.setTransformationMethod(new PasswordTransformationMethod()); |
||||
password.setHint("Password"); |
||||
builder.setTitle("Sign in"); |
||||
builder.setView(passLayout); |
||||
builder.setCancelable(true) |
||||
.setPositiveButton("Sign in", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
String user = name.getText().toString(); |
||||
String pass = password.getText().toString(); |
||||
handler.proceed(user.trim(), pass.trim()); |
||||
Log.i("Lightning", "Request Login"); |
||||
|
||||
} |
||||
}) |
||||
.setNegativeButton("Cancel", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
handler.cancel(); |
||||
|
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onScaleChanged(WebView view, float oldScale, float newScale) { |
||||
if (view.isShown()) { |
||||
view.invalidate(); |
||||
} |
||||
super.onScaleChanged(view, oldScale, newScale); |
||||
} |
||||
|
||||
@Override |
||||
public void onPageFinished(WebView view, String url) { |
||||
IncognitoModeActivity.onPageFinished(view, url); |
||||
super.onPageFinished(view, url); |
||||
} |
||||
|
||||
@Override |
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) { |
||||
IncognitoModeActivity.onPageStarted(view, url, favicon); |
||||
super.onPageStarted(view, url, favicon); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedSslError(WebView view, |
||||
final SslErrorHandler handler, SslError error) { |
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Warning"); |
||||
builder.setMessage( |
||||
"The certificate of the site is not trusted. Proceed anyway?") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Yes", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
handler.proceed(); |
||||
} |
||||
}) |
||||
.setNegativeButton("No", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
handler.cancel(); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
if (error.getPrimaryError() == SslError.SSL_UNTRUSTED) { |
||||
alert.show(); |
||||
} else { |
||||
handler.proceed(); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onFormResubmission(WebView view, final Message dontResend, |
||||
final Message resend) { |
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Form Resubmission"); |
||||
builder.setMessage("Would you like to resend the data?") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Yes", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
|
||||
resend.sendToTarget(); |
||||
} |
||||
}) |
||||
.setNegativeButton("No", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
|
||||
dontResend.sendToTarget(); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
super.onFormResubmission(view, dontResend, resend); |
||||
} |
||||
} |
@ -0,0 +1,216 @@
@@ -0,0 +1,216 @@
|
||||
package acr.browser.barebones.webviewclasses; |
||||
|
||||
import acr.browser.barebones.R; |
||||
import acr.browser.barebones.activities.BrowserActivity; |
||||
import android.annotation.SuppressLint; |
||||
import android.app.Activity; |
||||
import android.app.AlertDialog; |
||||
import android.content.Context; |
||||
import android.content.DialogInterface; |
||||
import android.graphics.Bitmap; |
||||
import android.graphics.BitmapFactory; |
||||
import android.net.Uri; |
||||
import android.os.Message; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.webkit.GeolocationPermissions; |
||||
import android.webkit.ValueCallback; |
||||
import android.webkit.WebChromeClient; |
||||
import android.webkit.WebView; |
||||
import android.webkit.WebStorage.QuotaUpdater; |
||||
import android.widget.FrameLayout; |
||||
|
||||
@SuppressLint("SetJavaScriptEnabled") |
||||
public class CustomChromeClient extends WebChromeClient { |
||||
private static Context context; |
||||
private static Activity browserActivity; |
||||
private static View mCustomView; |
||||
private static CustomViewCallback mCustomViewCallback; |
||||
public CustomChromeClient(BrowserActivity activity){ |
||||
context = activity; |
||||
browserActivity = activity; |
||||
} |
||||
public Bitmap mDefaultVideoPoster; |
||||
public View mVideoProgressView; |
||||
public FrameLayout fullScreenContainer; |
||||
public int orientation; |
||||
|
||||
@Override |
||||
public void onExceededDatabaseQuota(String url, |
||||
String databaseIdentifier, long quota, |
||||
long estimatedDatabaseSize, long totalQuota, |
||||
QuotaUpdater quotaUpdater) { |
||||
quotaUpdater.updateQuota(totalQuota + estimatedDatabaseSize); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onProgressChanged(WebView view, int newProgress) { |
||||
BrowserActivity.onProgressChanged(view.getId(), newProgress); |
||||
super.onProgressChanged(view, newProgress); |
||||
} |
||||
|
||||
@Override |
||||
public void onReachedMaxAppCacheSize(long requiredStorage, long quota, |
||||
QuotaUpdater quotaUpdater) { |
||||
quotaUpdater.updateQuota(quota + requiredStorage); |
||||
} |
||||
|
||||
@Override |
||||
public Bitmap getDefaultVideoPoster() { |
||||
if (mDefaultVideoPoster == null) { |
||||
mDefaultVideoPoster = BitmapFactory.decodeResource( |
||||
context.getResources(), android.R.color.black); |
||||
} |
||||
return mDefaultVideoPoster; |
||||
} |
||||
|
||||
@Override |
||||
public View getVideoLoadingProgressView() { |
||||
if (mVideoProgressView == null) { |
||||
LayoutInflater inflater = LayoutInflater.from(context); |
||||
mVideoProgressView = inflater.inflate( |
||||
android.R.layout.simple_spinner_item, null); |
||||
} |
||||
return mVideoProgressView; |
||||
} |
||||
|
||||
@Override |
||||
public void onCloseWindow(WebView window) { |
||||
Message msg = Message.obtain(); |
||||
msg.what = 3; |
||||
msg.arg1 = window.getId(); |
||||
BrowserActivity.browserHandler.sendMessage(msg); |
||||
super.onCloseWindow(window); |
||||
} |
||||
|
||||
@Override |
||||
public boolean onCreateWindow(WebView view, boolean isDialog, |
||||
boolean isUserGesture, final Message resultMsg) { |
||||
|
||||
if (isUserGesture) { |
||||
BrowserActivity.onCreateWindow(resultMsg); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void onGeolocationPermissionsShowPrompt(final String origin, |
||||
final GeolocationPermissions.Callback callback) { |
||||
final boolean remember = true; |
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Location Access"); |
||||
String org = null; |
||||
if (origin.length() > 50) { |
||||
org = (String) origin.subSequence(0, 50) + "..."; |
||||
} else { |
||||
org = origin; |
||||
} |
||||
builder.setMessage(org + "\nWould like to use your Location ") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Allow", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
callback.invoke(origin, true, remember); |
||||
} |
||||
}) |
||||
.setNegativeButton("Don't Allow", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
callback.invoke(origin, false, remember); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onHideCustomView() { |
||||
if (mCustomView == null && mCustomViewCallback == null) { |
||||
return; |
||||
} |
||||
mCustomView = null; |
||||
mCustomView.setKeepScreenOn(false); |
||||
BrowserActivity.onHideCustomView(fullScreenContainer, mCustomViewCallback, orientation); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedIcon(WebView view, Bitmap favicon) { |
||||
BrowserActivity.setFavicon(view.getId(), favicon); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedTitle(final WebView view, final String title) { |
||||
BrowserActivity.onReceivedTitle(view.getId(), title); |
||||
super.onReceivedTitle(view, title); |
||||
} |
||||
|
||||
@Override |
||||
public void onShowCustomView(View view, int requestedOrientation, |
||||
CustomViewCallback callback) { |
||||
if (mCustomView != null) { |
||||
callback.onCustomViewHidden(); |
||||
return; |
||||
} |
||||
view.setKeepScreenOn(true); |
||||
orientation = browserActivity.getRequestedOrientation(); |
||||
FrameLayout screen = (FrameLayout) browserActivity.getWindow().getDecorView(); |
||||
fullScreenContainer = new FrameLayout(context); |
||||
fullScreenContainer.setBackgroundColor(context.getResources().getColor( |
||||
R.color.black)); |
||||
BrowserActivity.onShowCustomView(); |
||||
fullScreenContainer.addView(view, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
screen.addView(fullScreenContainer, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
mCustomView = view; |
||||
mCustomViewCallback = callback; |
||||
browserActivity.setRequestedOrientation(requestedOrientation); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onShowCustomView(View view, |
||||
WebChromeClient.CustomViewCallback callback) { |
||||
if (mCustomView != null) { |
||||
callback.onCustomViewHidden(); |
||||
return; |
||||
} |
||||
view.setKeepScreenOn(true); |
||||
orientation = browserActivity.getRequestedOrientation(); |
||||
FrameLayout screen = (FrameLayout) browserActivity.getWindow().getDecorView(); |
||||
fullScreenContainer = new FrameLayout(context); |
||||
fullScreenContainer.setBackgroundColor(context.getResources().getColor( |
||||
R.color.black)); |
||||
BrowserActivity.onShowCustomView(); |
||||
fullScreenContainer.addView(view, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
screen.addView(fullScreenContainer, |
||||
ViewGroup.LayoutParams.MATCH_PARENT); |
||||
mCustomView = view; |
||||
mCustomViewCallback = callback; |
||||
browserActivity.setRequestedOrientation(browserActivity.getRequestedOrientation()); |
||||
} |
||||
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg) { |
||||
BrowserActivity.openFileChooser(uploadMsg); |
||||
} |
||||
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, |
||||
String acceptType) { |
||||
BrowserActivity.openFileChooser(uploadMsg); |
||||
} |
||||
|
||||
public void openFileChooser(ValueCallback<Uri> uploadMsg, |
||||
String acceptType, String capture) { |
||||
BrowserActivity.openFileChooser(uploadMsg); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
package acr.browser.barebones.webviewclasses; |
||||
|
||||
import acr.browser.barebones.activities.BrowserActivity; |
||||
import acr.browser.barebones.utilities.Utils; |
||||
import android.app.AlertDialog; |
||||
import android.content.Context; |
||||
import android.content.DialogInterface; |
||||
import android.content.Intent; |
||||
import android.net.Uri; |
||||
import android.webkit.DownloadListener; |
||||
|
||||
public class CustomDownloadListener implements DownloadListener { |
||||
private static Context context; |
||||
public CustomDownloadListener(BrowserActivity activity){ |
||||
context = activity; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void onDownloadStart(final String url, String userAgent, |
||||
final String contentDisposition, final String mimetype, |
||||
long contentLength) { |
||||
if (url.endsWith(".mp4") || url.endsWith(".m4a")) { |
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Open as..."); |
||||
builder.setMessage( |
||||
"Do you want to download this video or watch it in an app?") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Download", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
Utils.downloadFile(context, url, |
||||
contentDisposition, mimetype); |
||||
} |
||||
}) |
||||
.setNegativeButton("Watch", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
Intent intent = new Intent( |
||||
Intent.ACTION_VIEW); |
||||
intent.setDataAndType(Uri.parse(url), |
||||
"video/mp4"); |
||||
intent.putExtra( |
||||
"acr.browser.barebones.Download", |
||||
1); |
||||
context.startActivity(intent); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
|
||||
} else { |
||||
Utils.downloadFile(context, url, contentDisposition, mimetype); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,202 @@
@@ -0,0 +1,202 @@
|
||||
package acr.browser.barebones.webviewclasses; |
||||
|
||||
import acr.browser.barebones.activities.BrowserActivity; |
||||
import acr.browser.barebones.utilities.Utils; |
||||
import android.app.AlertDialog; |
||||
import android.content.Context; |
||||
import android.content.DialogInterface; |
||||
import android.content.Intent; |
||||
import android.graphics.Bitmap; |
||||
import android.net.MailTo; |
||||
import android.net.Uri; |
||||
import android.net.http.SslError; |
||||
import android.os.Message; |
||||
import android.text.InputType; |
||||
import android.text.TextUtils; |
||||
import android.text.method.PasswordTransformationMethod; |
||||
import android.util.Log; |
||||
import android.webkit.HttpAuthHandler; |
||||
import android.webkit.SslErrorHandler; |
||||
import android.webkit.WebView; |
||||
import android.webkit.WebViewClient; |
||||
import android.widget.EditText; |
||||
import android.widget.LinearLayout; |
||||
|
||||
public class CustomWebViewClient extends WebViewClient { |
||||
private static Context context; |
||||
public CustomWebViewClient(BrowserActivity browserActivity){ |
||||
context = browserActivity; |
||||
} |
||||
|
||||
@Override |
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) { |
||||
if (url.startsWith("market://") |
||||
|| url.startsWith("http://play.google.com") |
||||
|| url.startsWith("https://play.google.com")) { |
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, |
||||
Uri.parse(url)); |
||||
urlIntent.putExtra("acr.browser.barebones.Origin", |
||||
view.getId() + 1); |
||||
context.startActivity(urlIntent); |
||||
return true; |
||||
} else if (url.startsWith("http://www.youtube.com") |
||||
|| url.startsWith("https://www.youtube.com")) { |
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, |
||||
Uri.parse(url)); |
||||
urlIntent.putExtra("acr.browser.barebones.Origin", |
||||
view.getId() + 1); |
||||
context.startActivity(urlIntent); |
||||
return true; |
||||
} else if (url.startsWith("http://maps.google.com") |
||||
|| url.startsWith("https://maps.google.com")) { |
||||
Intent urlIntent = new Intent(Intent.ACTION_VIEW, |
||||
Uri.parse(url)); |
||||
urlIntent.putExtra("acr.browser.barebones.Origin", |
||||
view.getId() + 1); |
||||
context.startActivity(urlIntent); |
||||
return true; |
||||
} else if (url.contains("tel:") || TextUtils.isDigitsOnly(url)) { |
||||
context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url))); |
||||
return true; |
||||
} else if (url.contains("mailto:")) { |
||||
MailTo mailTo = MailTo.parse(url); |
||||
Intent i = Utils.newEmailIntent(context, |
||||
mailTo.getTo(), mailTo.getSubject(), mailTo.getBody(), |
||||
mailTo.getCc()); |
||||
context.startActivity(i); |
||||
view.reload(); |
||||
return true; |
||||
} |
||||
return super.shouldOverrideUrlLoading(view, url); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedHttpAuthRequest(final WebView view, |
||||
final HttpAuthHandler handler, final String host, |
||||
final String realm) { |
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
final EditText name = new EditText(context); |
||||
final EditText password = new EditText(context); |
||||
LinearLayout passLayout = new LinearLayout(context); |
||||
passLayout.setOrientation(LinearLayout.VERTICAL); |
||||
|
||||
passLayout.addView(name); |
||||
passLayout.addView(password); |
||||
|
||||
name.setHint("Username"); |
||||
password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); |
||||
password.setTransformationMethod(new PasswordTransformationMethod()); |
||||
password.setHint("Password"); |
||||
builder.setTitle("Sign in"); |
||||
builder.setView(passLayout); |
||||
builder.setCancelable(true) |
||||
.setPositiveButton("Sign in", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
String user = name.getText().toString(); |
||||
String pass = password.getText().toString(); |
||||
handler.proceed(user.trim(), pass.trim()); |
||||
Log.i("Lightning", "Request Login"); |
||||
|
||||
} |
||||
}) |
||||
.setNegativeButton("Cancel", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
handler.cancel(); |
||||
|
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onScaleChanged(WebView view, float oldScale, float newScale) { |
||||
if (view.isShown()) { |
||||
view.invalidate(); |
||||
} |
||||
super.onScaleChanged(view, oldScale, newScale); |
||||
} |
||||
|
||||
@Override |
||||
public void onPageFinished(WebView view, String url) { |
||||
BrowserActivity.onPageFinished(view, url); |
||||
super.onPageFinished(view, url); |
||||
} |
||||
|
||||
@Override |
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) { |
||||
BrowserActivity.onPageStarted(view, url, favicon); |
||||
super.onPageStarted(view, url, favicon); |
||||
} |
||||
|
||||
@Override |
||||
public void onReceivedSslError(WebView view, |
||||
final SslErrorHandler handler, SslError error) { |
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Warning"); |
||||
builder.setMessage( |
||||
"The certificate of the site is not trusted. Proceed anyway?") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Yes", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
handler.proceed(); |
||||
} |
||||
}) |
||||
.setNegativeButton("No", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
handler.cancel(); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
if (error.getPrimaryError() == SslError.SSL_UNTRUSTED) { |
||||
alert.show(); |
||||
} else { |
||||
handler.proceed(); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void onFormResubmission(WebView view, final Message dontResend, |
||||
final Message resend) { |
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); |
||||
builder.setTitle("Form Resubmission"); |
||||
builder.setMessage("Would you like to resend the data?") |
||||
.setCancelable(true) |
||||
.setPositiveButton("Yes", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
|
||||
resend.sendToTarget(); |
||||
} |
||||
}) |
||||
.setNegativeButton("No", |
||||
new DialogInterface.OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, |
||||
int id) { |
||||
|
||||
dontResend.sendToTarget(); |
||||
} |
||||
}); |
||||
AlertDialog alert = builder.create(); |
||||
alert.show(); |
||||
super.onFormResubmission(view, dontResend, resend); |
||||
} |
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
package acr.browser.barebones.webviewclasses; |
||||
|
||||
import acr.browser.barebones.activities.BrowserActivity; |
||||
import android.view.View; |
||||
import android.view.View.OnLongClickListener; |
||||
|
||||
public class WebPageLongClickListener implements OnLongClickListener{ |
||||
|
||||
@Override |
||||
public boolean onLongClick(View v) { |
||||
return BrowserActivity.onLongClick(v.getId()); |
||||
} |
||||
|
||||
} |