2.5.0.11
- 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 changed
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="acr.browser.barebones"
|
||||
android:versionCode="48"
|
||||
android:versionName="2.5.0.7" >
|
||||
android:versionCode="53"
|
||||
android:versionName="2.5.0.11" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
@ -22,7 +22,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name=".activities.BarebonesActivity"
|
||||
android:name=".activities.BrowserActivity"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/app_name"
|
||||
@ -94,7 +94,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BAREBONESINCOGNITO" />
|
||||
<action android:name="android.intent.action.BROWSER_INCOGNITO" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
@ -114,7 +114,7 @@
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/title_activity_advanced_settings" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.ADVANCEDSETTINGS" />
|
||||
<action android:name="android.intent.action.ADVANCED_SETTINGS" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
BIN
ic_launcher.png
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 123 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 21 KiB |
69
proguard-project.txt
Normal file
@ -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 |
BIN
res/drawable-xhdpi/progress_bar.9.png
Normal file
After Width: | Height: | Size: 199 B |
BIN
res/drawable-xhdpi/progress_bar_bg.9.png
Normal file
After Width: | Height: | Size: 179 B |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 20 KiB |
18
res/drawable/progress.xml
Normal file
@ -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>
|
@ -151,5 +151,18 @@
|
||||
android:layout_below="@+id/urlBar" >
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:indeterminate="false"
|
||||
android:indeterminateOnly="false"
|
||||
android:progressDrawable="@drawable/progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:maxHeight="5dp"
|
||||
android:minHeight="5dp"/>
|
||||
|
||||
</RelativeLayout>
|
@ -370,6 +370,30 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/r14"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/blueback"
|
||||
android:paddingRight="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/fullScreenOption"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cb11"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/r8"
|
||||
@ -388,6 +412,23 @@
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/r15"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/blueback" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/clear_cookies"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/r9"
|
||||
@ -402,7 +443,7 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/importbookmarks"
|
||||
android:paddingLeft="10dp"
|
||||
android:textAppearance="?android:attr/textAppearance" />
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/isImportAvailable"
|
||||
|
57
res/values-tr/strings.xml
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Lightning</string>
|
||||
<string name="google">Google</string>
|
||||
<string name="settings">Taray<EFBFBD>c<EFBFBD> ayarlar<61></string>
|
||||
<string name="location">Konum eri<72>imi</string>
|
||||
<string name="password">Parolar<EFBFBD>n<EFBFBD>z<EFBFBD> kaydetme</string>
|
||||
<string name="agent">Kullan<EFBFBD>c<EFBFBD> aray<61>z<EFBFBD></string>
|
||||
<string name="history">Ge<EFBFBD>mi<EFBFBD>i temizle</string>
|
||||
<string name="email">Bana e-posta</string>
|
||||
<string name="flash">Adobe Flash aktif</string>
|
||||
<string name="mobile">Mobil G<>r<EFBFBD>n<EFBFBD>m</string>
|
||||
<string name="desk">Masa<EFBFBD>st<EFBFBD> G<>r<EFBFBD>n<EFBFBD>m</string>
|
||||
<string name="custom"><EFBFBD>zel kullan<61>c<EFBFBD> arac<61>s<EFBFBD> olarak g<>r<EFBFBD>nt<6E>leme</string>
|
||||
<string name="home">Ana sayfa</string>
|
||||
<string name="settingshelp">Ayarlar sadece yeni sekmeler i<>in ge<67>erli</string>
|
||||
<string name="fullscreen">Tam ekran modu</string>
|
||||
<string name="java">JavaScript aktif</string>
|
||||
<string name="saveTab">Kaybedilen sekmeleri geri y<>kle</string>
|
||||
<string name="settings_title">Ayarlar</string>
|
||||
<string name="download">Y<EFBFBD>kleme Yeri</string>
|
||||
<string name="advanced">Geli<EFBFBD>mi<EFBFBD> Ayarlar</string>
|
||||
<string name="source">Kaynak kodu</string>
|
||||
<string name="license">Lisans</string>
|
||||
<string name="github">github.com/anthonycr/Lightning-Browser</string>
|
||||
<string name="apache">Apache License 2.0</string>
|
||||
<string name="title_activity_new_settings">YeniAyarlar</string>
|
||||
<string name="action_settings">Ayarlar</string>
|
||||
<string name="version">Uygulama Versiyonu</string>
|
||||
<string name="cache"><EFBFBD><EFBFBD>k<EFBFBD><EFBFBD>ta <20>nbelle<6C>i temizleme</string>
|
||||
<string name="reflow">Metin ak<61><6B><EFBFBD>n<EFBFBD> etkinle<6C>tirme</string>
|
||||
<string name="block">Resimleri engelleme</string>
|
||||
<string name="window">Siteleri yeni pencerede a<>ma</string>
|
||||
<string name="cookies"><EFBFBD>erezleri etkinle<6C>tirme</string>
|
||||
<string name="importbookmarks">Taray<EFBFBD>c<EFBFBD> yer imlerini i<>e aktarma</string>
|
||||
<string name="size">Metin boyutu</string>
|
||||
<string name="title_activity_advanced_settings">Geli<EFBFBD>mi<EFBFBD>Ayarlar</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="recommended">(<28>nerilen)</string>
|
||||
<string name="weird_look">(Web siteleri garip g<>r<EFBFBD>nebilir)</string>
|
||||
<string name="search">Arama Motoru</string>
|
||||
<string name="search_hint">Arama</string>
|
||||
<string name="wideViewPort">Geni<EFBFBD> g<>r<EFBFBD>n<EFBFBD>m kullanma</string>
|
||||
<string name="overViewMode">Genel bak<61><6B> modunda sayfalar<61> y<>kleme</string>
|
||||
<string name="restore">Kaybolan pencereleri ba<62>lang<6E><67>ta y<>kleme</string>
|
||||
<string name="menu_history">Ge<EFBFBD>mi<EFBFBD></string>
|
||||
<string name="menu_add">Yer imi ekle</string>
|
||||
<string name="menu_bookmarks">Yer imleri</string>
|
||||
<string name="menu_share">Payla<EFBFBD></string>
|
||||
<string name="menu_settings">Ayarlar</string>
|
||||
<string name="menu_incognito">Gizli sekme</string>
|
||||
<string name="menu_new_tab">Yeni pencere</string>
|
||||
<string name="stock_browser_unavailable">(Hi<48>bir stok taray<61>c<EFBFBD> tespit edilemedi)</string>
|
||||
<string name="stock_browser_available">(Desteklenen stok taray<61>c<EFBFBD> tespit edildi)</string>
|
||||
|
||||
</resources>
|
@ -54,4 +54,4 @@
|
||||
<string name="stock_browser_unavailable">(没有检测到系统自带浏览器)</string>
|
||||
<string name="stock_browser_available">(检测到系统自带浏览器)</string>
|
||||
|
||||
</resources>
|
||||
</resources>
|
@ -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>
|
@ -53,5 +53,7 @@
|
||||
<string name="menu_new_tab">New tab</string>
|
||||
<string name="stock_browser_unavailable">(No stock browser detected)</string>
|
||||
<string name="stock_browser_available">(Supported stock browser detected)</string>
|
||||
<string name="fullScreenOption">Hide status bar while browsing</string>
|
||||
<string name="clear_cookies">Clear browser cookies</string>
|
||||
|
||||
</resources>
|
@ -3,10 +3,9 @@ package acr.browser.barebones.activities;
|
||||
import java.io.File;
|
||||
|
||||
import acr.browser.barebones.R;
|
||||
import acr.browser.barebones.utilities.BookmarkPageVariables;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import acr.browser.barebones.utilities.Utils;
|
||||
import acr.browser.barebones.activities.BarebonesActivity;
|
||||
import acr.browser.barebones.activities.BrowserActivity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
@ -17,9 +16,8 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
@ -31,8 +29,8 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
// settings variables
|
||||
@ -41,8 +39,8 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
static final String preferences = "settings";
|
||||
static SharedPreferences settings;
|
||||
static SharedPreferences.Editor edit;
|
||||
static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13;
|
||||
static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10;
|
||||
static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15;
|
||||
static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb11;
|
||||
static Context CONTEXT;
|
||||
Handler messageHandler;
|
||||
|
||||
@ -51,6 +49,10 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.advanced_settings);
|
||||
settings = getSharedPreferences(preferences, 0);
|
||||
if (settings.getBoolean("hidestatus", false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
edit = settings.edit();
|
||||
CONTEXT = this;
|
||||
initialize();
|
||||
@ -72,6 +74,8 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
r11 = (RelativeLayout) findViewById(R.id.r11);
|
||||
r12 = (RelativeLayout) findViewById(R.id.r12);
|
||||
r13 = (RelativeLayout) findViewById(R.id.r13);
|
||||
r14 = (RelativeLayout) findViewById(R.id.r14);
|
||||
r15 = (RelativeLayout) findViewById(R.id.r15);
|
||||
|
||||
cb1 = (CheckBox) findViewById(R.id.cb1);
|
||||
cb2 = (CheckBox) findViewById(R.id.cb2);
|
||||
@ -83,6 +87,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
cb8 = (CheckBox) findViewById(R.id.cb8);
|
||||
cb9 = (CheckBox) findViewById(R.id.cb9);
|
||||
cb10 = (CheckBox) findViewById(R.id.cb10);
|
||||
cb11 = (CheckBox) findViewById(R.id.cb11);
|
||||
|
||||
cb1.setChecked(settings.getBoolean("passwords", true));
|
||||
cb2.setChecked(settings.getBoolean("cache", false));
|
||||
@ -94,6 +99,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
cb8.setChecked(settings.getBoolean("wideviewport", true));
|
||||
cb9.setChecked(settings.getBoolean("overviewmode", true));
|
||||
cb10.setChecked(settings.getBoolean("restoreclosed", true));
|
||||
cb11.setChecked(settings.getBoolean("hidestatus", false));
|
||||
|
||||
r1(r1);
|
||||
r2(r2);
|
||||
@ -108,6 +114,8 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
r11(r11);
|
||||
r12(r12);
|
||||
r13(r13);
|
||||
r14(r14);
|
||||
r15(r15);
|
||||
cb1(cb1);
|
||||
cb2(cb2);
|
||||
cb3(cb3);
|
||||
@ -118,11 +126,12 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
cb8(cb8);
|
||||
cb9(cb9);
|
||||
cb10(cb10);
|
||||
cb11(cb11);
|
||||
back();
|
||||
|
||||
TextView importBookmarks = (TextView)findViewById(R.id.isImportAvailable);
|
||||
|
||||
if(BarebonesActivity.noStockBrowser){
|
||||
if(BrowserActivity.noStockBrowser){
|
||||
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
|
||||
}
|
||||
else{
|
||||
@ -140,6 +149,9 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
case 1:
|
||||
Utils.showToast(CONTEXT, "History Cleared");
|
||||
break;
|
||||
case 2:
|
||||
Utils.showToast(CONTEXT, "Cookies Cleared");
|
||||
break;
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
@ -286,6 +298,19 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void cb11(CheckBox view) {
|
||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
edit.putBoolean("hidestatus", isChecked);
|
||||
edit.commit();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void r1(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@ -446,20 +471,71 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
cb10.setChecked(!cb10.isChecked());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
void r14(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cb11.setChecked(!cb11.isChecked());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void r15(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||
AdvancedSettingsActivity.this); // dialog
|
||||
builder.setTitle("Clear Cookies");
|
||||
builder.setMessage(
|
||||
"Would you like to clear all browser cookies?")
|
||||
.setPositiveButton("Yes",
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface arg0,
|
||||
int arg1) {
|
||||
Thread clear = new Thread(
|
||||
new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
clearCookies();
|
||||
}
|
||||
|
||||
});
|
||||
clear.start();
|
||||
}
|
||||
|
||||
})
|
||||
.setNegativeButton("No",
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface arg0,
|
||||
int arg1) {
|
||||
|
||||
}
|
||||
|
||||
}).show();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void clearHistory() {
|
||||
CookieManager c = CookieManager.getInstance();
|
||||
CookieSyncManager.createInstance(this);
|
||||
c.removeAllCookie();
|
||||
AdvancedSettingsActivity.this.deleteDatabase("historyManager");
|
||||
BarebonesActivity.main[0].clearCache(true);
|
||||
WebViewDatabase m = WebViewDatabase
|
||||
.getInstance(AdvancedSettingsActivity.this);
|
||||
m.clearFormData();
|
||||
@ -468,7 +544,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
m.clearUsernamePassword();
|
||||
WebIconDatabase.getInstance().removeAllIcons();
|
||||
}
|
||||
if (!BarebonesActivity.noStockBrowser) {
|
||||
if (!BrowserActivity.noStockBrowser) {
|
||||
try {
|
||||
Browser.clearHistory(getContentResolver());
|
||||
} catch (NullPointerException ignored) {
|
||||
@ -478,7 +554,12 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
messageHandler.sendEmptyMessage(1);
|
||||
}
|
||||
|
||||
|
||||
public void clearCookies(){
|
||||
CookieManager c = CookieManager.getInstance();
|
||||
CookieSyncManager.createInstance(this);
|
||||
c.removeAllCookie();
|
||||
messageHandler.sendEmptyMessage(2);
|
||||
}
|
||||
|
||||
void r9(RelativeLayout view) {
|
||||
|
||||
@ -559,7 +640,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
}
|
||||
|
||||
public void importFromStockBrowser() {
|
||||
if (!BarebonesActivity.noStockBrowser) {
|
||||
if (!BrowserActivity.noStockBrowser) {
|
||||
try {
|
||||
String[] proj = new String[] { Browser.BookmarkColumns.TITLE,
|
||||
Browser.BookmarkColumns.URL };
|
||||
|
2150
src/acr/browser/barebones/activities/BrowserActivity.java
Normal file
@ -1,9 +1,6 @@
|
||||
package acr.browser.barebones.activities;
|
||||
|
||||
import acr.browser.barebones.R;
|
||||
import acr.browser.barebones.R.drawable;
|
||||
import acr.browser.barebones.R.id;
|
||||
import acr.browser.barebones.R.layout;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import acr.browser.barebones.utilities.Utils;
|
||||
import android.net.Uri;
|
||||
@ -19,23 +16,21 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.Color;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class SettingsActivity extends Activity {
|
||||
static int API = FinalVariables.API;
|
||||
@ -44,6 +39,7 @@ public class SettingsActivity extends Activity {
|
||||
static int agentChoice;
|
||||
static String homepage;
|
||||
static TextView agentText;
|
||||
static String agent;
|
||||
static TextView download;
|
||||
static int egg = 0;
|
||||
static String downloadLocation;
|
||||
@ -55,6 +51,7 @@ public class SettingsActivity extends Activity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.settings);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@ -62,6 +59,10 @@ public class SettingsActivity extends Activity {
|
||||
public void init() {
|
||||
// settings storage
|
||||
settings = getSharedPreferences(preferences, 0);
|
||||
if (settings.getBoolean("hidestatus", false)) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
edit = settings.edit();
|
||||
|
||||
// initialize UI
|
||||
@ -91,6 +92,9 @@ public class SettingsActivity extends Activity {
|
||||
case 6:
|
||||
searchText.setText("Baidu");
|
||||
break;
|
||||
case 7:
|
||||
searchText.setText("Yandex");
|
||||
break;
|
||||
}
|
||||
|
||||
back.setBackgroundResource(R.drawable.button);
|
||||
@ -104,9 +108,10 @@ public class SettingsActivity extends Activity {
|
||||
agentChoice = settings.getInt("agentchoose", 1);
|
||||
homepage = settings.getString("home", FinalVariables.HOMEPAGE);
|
||||
downloadLocation = settings.getString("download",
|
||||
FinalVariables.DOWNLOAD_LOCATION);
|
||||
Environment.DIRECTORY_DOWNLOADS);
|
||||
|
||||
download.setText(downloadLocation);
|
||||
download.setText(FinalVariables.EXTERNAL_STORAGE + "/"
|
||||
+ downloadLocation);
|
||||
|
||||
String code = "HOLO";
|
||||
|
||||
@ -133,13 +138,19 @@ public class SettingsActivity extends Activity {
|
||||
switch (agentChoice) {
|
||||
case 1:
|
||||
agentText.setText("Default");
|
||||
agent = BrowserActivity.defaultUser;
|
||||
break;
|
||||
case 2:
|
||||
agentText.setText("Desktop");
|
||||
agent = FinalVariables.DESKTOP_USER_AGENT;
|
||||
break;
|
||||
case 3:
|
||||
agentText.setText("Mobile");
|
||||
agent = FinalVariables.MOBILE_USER_AGENT;
|
||||
break;
|
||||
case 4:
|
||||
agentText.setText("Custom");
|
||||
agent = settings.getString("userAgentString", BrowserActivity.defaultUser);
|
||||
}
|
||||
RelativeLayout r1, r2, r3;
|
||||
r1 = (RelativeLayout) findViewById(R.id.setR1);
|
||||
@ -214,7 +225,7 @@ public class SettingsActivity extends Activity {
|
||||
SettingsActivity.this);
|
||||
picker.setTitle("Search Engine");
|
||||
CharSequence[] chars = { "Google (Suggested)", "Bing", "Yahoo",
|
||||
"StartPage", "DuckDuckGo (Privacy)" ,"Baidu"};
|
||||
"StartPage", "DuckDuckGo (Privacy)" , "Baidu (Chinese)", "Yandex (Russian)"};
|
||||
|
||||
int n = settings.getInt("search", 1);
|
||||
|
||||
@ -245,6 +256,9 @@ public class SettingsActivity extends Activity {
|
||||
case 6:
|
||||
searchText.setText("Baidu");
|
||||
break;
|
||||
case 7:
|
||||
searchText.setText("Yandex");
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -329,9 +343,8 @@ public class SettingsActivity extends Activity {
|
||||
public void onClick(View v) {
|
||||
egg++;
|
||||
if (egg == 10) {
|
||||
startActivity(new Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("http://imgs.xkcd.com/comics/compiling.png")));
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri
|
||||
.parse("http://imgs.xkcd.com/comics/compiling.png")));
|
||||
finish();
|
||||
egg = 0;
|
||||
}
|
||||
@ -502,12 +515,20 @@ public class SettingsActivity extends Activity {
|
||||
switch (which + 1) {
|
||||
case 1:
|
||||
agentText.setText("Default");
|
||||
agent = BrowserActivity.defaultUser;
|
||||
break;
|
||||
case 2:
|
||||
agentText.setText("Desktop");
|
||||
agent = FinalVariables.DESKTOP_USER_AGENT;
|
||||
break;
|
||||
case 3:
|
||||
agentText.setText("Mobile");
|
||||
agent = FinalVariables.MOBILE_USER_AGENT;
|
||||
break;
|
||||
case 4:
|
||||
agentText.setText("Custom");
|
||||
agent = settings.getString("userAgentString", BrowserActivity.defaultUser);
|
||||
agentPicker();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -538,6 +559,27 @@ public class SettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void agentPicker() {
|
||||
final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(
|
||||
SettingsActivity.this);
|
||||
|
||||
agentStringPicker.setTitle("Custom Agent");
|
||||
final EditText getAgent = new EditText(SettingsActivity.this);
|
||||
agentStringPicker.setView(getAgent);
|
||||
agentStringPicker.setPositiveButton("OK",
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String text = getAgent.getText().toString();
|
||||
edit.putString("userAgentString", text);
|
||||
edit.commit();
|
||||
agentText.setText("Custom");
|
||||
}
|
||||
});
|
||||
agentStringPicker.show();
|
||||
}
|
||||
|
||||
public void download(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@ -550,9 +592,9 @@ public class SettingsActivity extends Activity {
|
||||
picker.setTitle("Download Location");
|
||||
CharSequence[] chars = { "Default", "Custom" };
|
||||
downloadLocation = settings.getString("download",
|
||||
FinalVariables.DOWNLOAD_LOCATION);
|
||||
Environment.DIRECTORY_DOWNLOADS);
|
||||
int n = -1;
|
||||
if (downloadLocation.contains(FinalVariables.DOWNLOAD_LOCATION)) {
|
||||
if (downloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
|
||||
n = 1;
|
||||
} else {
|
||||
n = 2;
|
||||
@ -568,9 +610,11 @@ public class SettingsActivity extends Activity {
|
||||
switch (which + 1) {
|
||||
case 1:
|
||||
edit.putString("download",
|
||||
FinalVariables.DOWNLOAD_LOCATION);
|
||||
Environment.DIRECTORY_DOWNLOADS);
|
||||
edit.commit();
|
||||
download.setText(FinalVariables.DOWNLOAD_LOCATION);
|
||||
download.setText(FinalVariables.EXTERNAL_STORAGE
|
||||
+ "/"
|
||||
+ Environment.DIRECTORY_DOWNLOADS);
|
||||
break;
|
||||
case 2:
|
||||
downPicker();
|
||||
@ -620,15 +664,42 @@ public class SettingsActivity extends Activity {
|
||||
homePicker.show();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void downPicker() {
|
||||
final AlertDialog.Builder downLocationPicker = new AlertDialog.Builder(
|
||||
SettingsActivity.this);
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
downLocationPicker.setTitle("Custom Location");
|
||||
final EditText getDownload = new EditText(SettingsActivity.this);
|
||||
getDownload.setBackgroundResource(0);
|
||||
downloadLocation = settings.getString("download",
|
||||
FinalVariables.DOWNLOAD_LOCATION);
|
||||
Environment.DIRECTORY_DOWNLOADS);
|
||||
int padding = Utils.convertDensityPixesl(this, 10);
|
||||
|
||||
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
|
||||
getDownload.setLayoutParams(lparams);
|
||||
getDownload.setTextColor(Color.DKGRAY);
|
||||
getDownload.setText(downloadLocation);
|
||||
downLocationPicker.setView(getDownload);
|
||||
getDownload.setPadding(0, padding, padding, padding);
|
||||
|
||||
TextView v = new TextView(this);
|
||||
v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
||||
v.setTextColor(Color.DKGRAY);
|
||||
v.setText(FinalVariables.EXTERNAL_STORAGE + "/");
|
||||
v.setPadding(padding, padding, 0, padding);
|
||||
layout.addView(v);
|
||||
layout.addView(getDownload);
|
||||
if (API < 16) {
|
||||
layout.setBackgroundDrawable(getResources().getDrawable(
|
||||
android.R.drawable.edit_text));
|
||||
} else {
|
||||
layout.setBackground(getResources().getDrawable(
|
||||
android.R.drawable.edit_text));
|
||||
}
|
||||
downLocationPicker.setView(layout);
|
||||
downLocationPicker.setPositiveButton("OK",
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@ -637,7 +708,8 @@ public class SettingsActivity extends Activity {
|
||||
String text = getDownload.getText().toString();
|
||||
edit.putString("download", text);
|
||||
edit.commit();
|
||||
download.setText(text);
|
||||
download.setText(FinalVariables.EXTERNAL_STORAGE + "/"
|
||||
+ text);
|
||||
}
|
||||
});
|
||||
downLocationPicker.show();
|
||||
@ -708,7 +780,7 @@ public class SettingsActivity extends Activity {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(
|
||||
"android.intent.action.ADVANCEDSETTINGS"));
|
||||
FinalVariables.ADVANCED_SETTINGS_INTENT));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1,59 +1,95 @@
|
||||
package acr.browser.barebones.customwebview;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import acr.browser.barebones.activities.BarebonesActivity;
|
||||
import acr.browser.barebones.activities.BrowserActivity;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.graphics.Point;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ZoomButtonsController;
|
||||
|
||||
public final class CustomWebView extends WebView {
|
||||
private float location;
|
||||
private boolean first = false;
|
||||
final int API = FinalVariables.API;
|
||||
final boolean showFullScreen = BarebonesActivity.showFullScreen;
|
||||
final View uBar = BarebonesActivity.uBar;
|
||||
final Animation slideUp = BarebonesActivity.slideUp;
|
||||
final Animation slideDown = BarebonesActivity.slideDown;
|
||||
private ZoomButtonsController zoomControl;
|
||||
private boolean zoomShouldDie = false;
|
||||
final boolean showFullScreen = BrowserActivity.showFullScreen;
|
||||
final View uBar = BrowserActivity.uBar;
|
||||
final Animation slideUp = BrowserActivity.slideUp;
|
||||
final Animation slideDown = BrowserActivity.slideDown;
|
||||
static Context CONTEXT;
|
||||
|
||||
public CustomWebView(Context context) {
|
||||
super(context);
|
||||
this.setBackgroundResource(0);
|
||||
|
||||
//getControls();
|
||||
mGestureDetector = new GestureDetector(context,
|
||||
new CustomGestureListener());
|
||||
CONTEXT = context;
|
||||
WebSettings settings = this.getSettings();
|
||||
browserInitialization(context);
|
||||
settingsInitialization(context, settings);
|
||||
}
|
||||
|
||||
public void browserInitialization(Context context) {
|
||||
this.setDrawingCacheBackgroundColor(0x00000000);
|
||||
this.setFocusableInTouchMode(true);
|
||||
this.setFocusable(true);
|
||||
this.setAnimationCacheEnabled(false);
|
||||
this.setDrawingCacheEnabled(true);
|
||||
this.setBackgroundColor(context.getResources().getColor(
|
||||
android.R.color.white));
|
||||
this.setWillNotCacheDrawing(false);
|
||||
this.setAlwaysDrawnWithCacheEnabled(true);
|
||||
this.setScrollbarFadingEnabled(true);
|
||||
this.setSaveEnabled(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void settingsInitialization(Context context, WebSettings settings) {
|
||||
settings.setDomStorageEnabled(true);
|
||||
settings.setAppCacheEnabled(true);
|
||||
settings.setAppCachePath(context.getFilesDir().getAbsolutePath()
|
||||
+ "/cache");
|
||||
if (API < 18) {
|
||||
settings.setLightTouchEnabled(true);
|
||||
}
|
||||
settings.setAllowFileAccess(true);
|
||||
settings.setDatabaseEnabled(true);
|
||||
settings.setDatabasePath(context.getFilesDir().getAbsolutePath()
|
||||
+ "/databases");
|
||||
settings.setSupportZoom(true);
|
||||
settings.setBuiltInZoomControls(true);
|
||||
if (API >= 11) {
|
||||
settings.setDisplayZoomControls(false);
|
||||
settings.setAllowContentAccess(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
/*if (zoomShouldDie) {
|
||||
try {
|
||||
zoomControl.getZoomControls().setVisibility(View.INVISIBLE);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}*/
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN: {
|
||||
first = true;
|
||||
if (API <= 10 && !this.hasFocus()) {
|
||||
this.requestFocus();
|
||||
if (API <= 10 && !hasFocus()) {
|
||||
requestFocus();
|
||||
}
|
||||
location = event.getY();
|
||||
break;
|
||||
}
|
||||
case MotionEvent.ACTION_UP: {
|
||||
|
||||
if (showFullScreen && first) {
|
||||
if (uBar.isShown() && this.getScrollY() < 5) {
|
||||
if (uBar.isShown() && getScrollY() < 5) {
|
||||
uBar.startAnimation(slideUp);
|
||||
} else if (event.getY() > location && !uBar.isShown()) {
|
||||
} else if ((event.getY() - location) > 20.0 && !uBar.isShown()) {
|
||||
uBar.startAnimation(slideDown);
|
||||
} else if (event.getY() < location && uBar.isShown()) {
|
||||
} else if ((event.getY() - location) < -20.0 && uBar.isShown()) {
|
||||
uBar.startAnimation(slideUp);
|
||||
}
|
||||
first = false;
|
||||
@ -61,33 +97,67 @@ public final class CustomWebView extends WebView {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mGestureDetector.onTouchEvent(event);
|
||||
return super.onTouchEvent(event);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onWindowVisibilityChanged(int visibility) {
|
||||
if(API >= 11){
|
||||
if (API >= 11) {
|
||||
this.setActivated(visibility == View.VISIBLE);
|
||||
}
|
||||
this.setEnabled(visibility == View.VISIBLE);
|
||||
super.onWindowVisibilityChanged(visibility);
|
||||
}
|
||||
/*
|
||||
private void getControls() {
|
||||
if (API < 11) {
|
||||
|
||||
private final GestureDetector mGestureDetector;
|
||||
|
||||
private class CustomGestureListener extends SimpleOnGestureListener {
|
||||
private final int SWIPE_THRESHOLD = 100;
|
||||
private final int SWIPE_VELOCITY_THRESHOLD = 100;
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
||||
float velocityY) {
|
||||
try {
|
||||
Class<?> webview = Class.forName("android.webkit.WebView");
|
||||
Method method = webview.getMethod("getZoomButtonsController");
|
||||
|
||||
zoomControl = (ZoomButtonsController) method.invoke(this, (Object[])null);
|
||||
if (zoomControl != null) {
|
||||
zoomShouldDie = true;
|
||||
|
||||
int width;
|
||||
if (API < 13) {
|
||||
DisplayMetrics metrics = CONTEXT.getResources()
|
||||
.getDisplayMetrics();
|
||||
width = metrics.widthPixels;
|
||||
} else {
|
||||
WindowManager wm = (WindowManager) CONTEXT
|
||||
.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
display.getSize(size);
|
||||
width = size.x;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
if ((width - e1.getX() < width/12) || (e1.getX() < width/12)) {
|
||||
float diffY = e2.getY() - e1.getY();
|
||||
float diffX = e2.getX() - e1.getX();
|
||||
if (Math.abs(diffX) > Math.abs(diffY)) {
|
||||
if (Math.abs(diffX) > SWIPE_THRESHOLD
|
||||
&& Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
if (diffX > 0) {
|
||||
BrowserActivity.goBack();
|
||||
return false;
|
||||
} else {
|
||||
BrowserActivity.goForward();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,16 @@ package acr.browser.barebones.customwebview;
|
||||
import acr.browser.barebones.activities.IncognitoModeActivity;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
public final class IncognitoWebView extends WebView {
|
||||
@ -13,34 +20,76 @@ public final class IncognitoWebView extends WebView {
|
||||
private boolean first = false;
|
||||
final int API = FinalVariables.API;
|
||||
final boolean showFullScreen = IncognitoModeActivity.showFullScreen;
|
||||
final View uBar = IncognitoModeActivity.uBar;
|
||||
final View uBar = IncognitoModeActivity.urlBar;
|
||||
final Animation slideUp = IncognitoModeActivity.slideUp;
|
||||
final Animation slideDown = IncognitoModeActivity.slideDown;
|
||||
|
||||
static Context CONTEXT;
|
||||
|
||||
public IncognitoWebView(Context context) {
|
||||
super(context);
|
||||
mGestureDetector = new GestureDetector(context,
|
||||
new CustomGestureListener());
|
||||
CONTEXT = context;
|
||||
WebSettings settings = this.getSettings();
|
||||
browserInitialization(context);
|
||||
settingsInitialization(context, settings);
|
||||
}
|
||||
|
||||
public void browserInitialization(Context context) {
|
||||
this.setDrawingCacheBackgroundColor(0x00000000);
|
||||
this.setFocusableInTouchMode(true);
|
||||
this.setFocusable(true);
|
||||
this.setAnimationCacheEnabled(false);
|
||||
this.setDrawingCacheEnabled(true);
|
||||
this.setBackgroundColor(context.getResources().getColor(
|
||||
android.R.color.white));
|
||||
this.setWillNotCacheDrawing(false);
|
||||
this.setAlwaysDrawnWithCacheEnabled(true);
|
||||
this.setScrollbarFadingEnabled(true);
|
||||
this.setSaveEnabled(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void settingsInitialization(Context context, WebSettings settings) {
|
||||
settings.setDomStorageEnabled(true);
|
||||
settings.setAppCacheEnabled(true);
|
||||
settings.setAppCachePath(context.getFilesDir().getAbsolutePath()
|
||||
+ "/cache");
|
||||
if (API < 18) {
|
||||
settings.setLightTouchEnabled(true);
|
||||
}
|
||||
settings.setAllowFileAccess(true);
|
||||
settings.setDatabaseEnabled(true);
|
||||
settings.setDatabasePath(context.getFilesDir().getAbsolutePath()
|
||||
+ "/databases");
|
||||
settings.setSupportZoom(true);
|
||||
settings.setBuiltInZoomControls(true);
|
||||
if (API >= 11) {
|
||||
settings.setDisplayZoomControls(false);
|
||||
settings.setAllowContentAccess(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN: {
|
||||
first = true;
|
||||
if (API <= 10 && !this.hasFocus()) {
|
||||
this.requestFocus();
|
||||
if (API <= 10 && !hasFocus()) {
|
||||
requestFocus();
|
||||
}
|
||||
location = event.getY();
|
||||
break;
|
||||
}
|
||||
case MotionEvent.ACTION_UP: {
|
||||
|
||||
if (showFullScreen && first) {
|
||||
if (uBar.isShown() && this.getScrollY() < 5) {
|
||||
if (uBar.isShown() && getScrollY() < 5) {
|
||||
uBar.startAnimation(slideUp);
|
||||
} else if (event.getY() > location && !uBar.isShown()) {
|
||||
} else if ((event.getY() - location) > 20.0 && !uBar.isShown()) {
|
||||
uBar.startAnimation(slideDown);
|
||||
} else if (event.getY() < location && uBar.isShown()) {
|
||||
} else if ((event.getY() - location) < -20.0 && uBar.isShown()) {
|
||||
uBar.startAnimation(slideUp);
|
||||
}
|
||||
first = false;
|
||||
@ -48,8 +97,67 @@ public final class IncognitoWebView extends WebView {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mGestureDetector.onTouchEvent(event)
|
||||
|| super.onTouchEvent(event);
|
||||
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onWindowVisibilityChanged(int visibility) {
|
||||
if (API >= 11) {
|
||||
this.setActivated(visibility == View.VISIBLE);
|
||||
}
|
||||
this.setEnabled(visibility == View.VISIBLE);
|
||||
super.onWindowVisibilityChanged(visibility);
|
||||
}
|
||||
|
||||
private final GestureDetector mGestureDetector;
|
||||
|
||||
private class CustomGestureListener extends SimpleOnGestureListener {
|
||||
private final int SWIPE_THRESHOLD = 100;
|
||||
private final int SWIPE_VELOCITY_THRESHOLD = 100;
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
||||
float velocityY) {
|
||||
try {
|
||||
|
||||
int width;
|
||||
if (API < 13) {
|
||||
DisplayMetrics metrics = CONTEXT.getResources()
|
||||
.getDisplayMetrics();
|
||||
width = metrics.widthPixels;
|
||||
} else {
|
||||
WindowManager wm = (WindowManager) CONTEXT
|
||||
.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
display.getSize(size);
|
||||
width = size.x;
|
||||
}
|
||||
|
||||
if ((width - e1.getX() < width/12) || (e1.getX() < width/12)) {
|
||||
float diffY = e2.getY() - e1.getY();
|
||||
float diffX = e2.getX() - e1.getX();
|
||||
if (Math.abs(diffX) > Math.abs(diffY)) {
|
||||
if (Math.abs(diffX) > SWIPE_THRESHOLD
|
||||
&& Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
if (diffX > 0) {
|
||||
IncognitoModeActivity.goBack();
|
||||
return false;
|
||||
} else {
|
||||
IncognitoModeActivity.goForward();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@
|
||||
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 @@
|
||||
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 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ public class BookmarkPageVariables {
|
||||
public static final String Part1 = "<div class=\"clickable\">"
|
||||
+ "<div class=\"shadow\">" + "<p class=\"font\">" + "<a href=\"";
|
||||
public static final String Part2 = "\"></a>"+
|
||||
"<img height=\"15px\" width=\"15px\" src='https://www.google.com/s2/favicons?domain=";
|
||||
"<img height=\"15px\" width=\"15px\" src='https://www.google.com/s2/favicons?domain_url=";
|
||||
public static final String Part3 = "'/>";
|
||||
public static final String Part4 = "</p></div></div>";
|
||||
public static final String End = "</body></html>";
|
||||
|
@ -15,13 +15,13 @@ public class FinalVariables {
|
||||
public static final String GOOGLE_SEARCH = "https://www.google.com/search?client=lightning&q=";
|
||||
public static final String BING_SEARCH = "http://www.bing.com/search?q=";
|
||||
public static final String DUCK_SEARCH = "https://duckduckgo.com/?t=lightning&q=";
|
||||
public static final String BAIDU_SEARCH = "http://www.baidu.com/s?wd=";
|
||||
public static final String STARTPAGE_SEARCH = "https://startpage.com/do/metasearch.pl?language=english&cat=web&query=";
|
||||
public static final String HOMEPAGE = "https://www.google.com/";
|
||||
public static final String BAIDU_SEARCH = "http://www.baidu.com/s?wd=";
|
||||
public static final String YANDEX_SEARCH = "http://yandex.ru/yandsearch?lr=21411&text=";
|
||||
public static final String ADVANCED_SETTINGS_INTENT = "android.intent.action.ADVANCED_SETTINGS";
|
||||
public static final String SETTINGS_INTENT = "android.intent.action.SETTINGS";
|
||||
public static final String INCOGNITO_INTENT = "android.intent.action.BAREBONESINCOGNITO";
|
||||
public static final String DOWNLOAD_LOCATION = Environment.getExternalStorageDirectory().toString()+"/"+Environment.DIRECTORY_DOWNLOADS;
|
||||
|
||||
|
||||
public static final String INCOGNITO_INTENT = "android.intent.action.BROWSER_INCOGNITO";
|
||||
public static final String EXTERNAL_STORAGE = Environment.getExternalStorageDirectory().toString();
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import acr.browser.barebones.activities.AdvancedSettingsActivity;
|
||||
import acr.browser.barebones.databases.DatabaseHandler;
|
||||
import acr.browser.barebones.databases.HistoryItem;
|
||||
import android.annotation.SuppressLint;
|
||||
@ -31,25 +29,21 @@ import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
|
||||
public class Utils {
|
||||
|
||||
|
||||
public static DatabaseHandler historyHandler;
|
||||
public static SQLiteDatabase history;
|
||||
|
||||
|
||||
public static void createInformativeDialog(Context context, String title,
|
||||
String message) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(title);
|
||||
builder.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton("Ok",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
builder.setMessage(message).setCancelable(true)
|
||||
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
@ -108,12 +102,11 @@ public class Utils {
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder("url" + " = ");
|
||||
DatabaseUtils.appendEscapedSQLString(sb, url);
|
||||
historyHandler = new DatabaseHandler(
|
||||
context);
|
||||
historyHandler = new DatabaseHandler(context);
|
||||
history = historyHandler.getReadableDatabase();
|
||||
Cursor cursor = history.query("history", new String[] { "id",
|
||||
"url", "title" }, sb.toString(), null, null, null,
|
||||
null);
|
||||
Cursor cursor = history.query("history", new String[] {
|
||||
"id", "url", "title" }, sb.toString(), null, null,
|
||||
null, null);
|
||||
if (!cursor.moveToFirst()) {
|
||||
historyHandler.addHistoryItem(new HistoryItem(url,
|
||||
title));
|
||||
@ -140,15 +133,17 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
|
||||
public static void downloadFile(final Context context, final String url, final String contentDisposition, final String mimetype){
|
||||
public static void downloadFile(final Context context, final String url,
|
||||
final String contentDisposition, final String mimetype) {
|
||||
try {
|
||||
Thread downloader = new Thread(new Runnable() {
|
||||
@SuppressLint("InlinedApi")
|
||||
@Override
|
||||
public void run() {
|
||||
DownloadManager download = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
DownloadManager download = (DownloadManager) context
|
||||
.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
Uri nice = Uri.parse(url);
|
||||
DownloadManager.Request it = new DownloadManager.Request(
|
||||
nice);
|
||||
@ -158,9 +153,10 @@ public class Utils {
|
||||
it.allowScanningByMediaScanner();
|
||||
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
}
|
||||
|
||||
it.setDestinationInExternalPublicDir(
|
||||
Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
String location = context.getSharedPreferences("settings",
|
||||
0).getString("download",
|
||||
Environment.DIRECTORY_DOWNLOADS);
|
||||
it.setDestinationInExternalPublicDir(location, fileName);
|
||||
Log.i("Barebones", "Downloading" + fileName);
|
||||
download.enqueue(it);
|
||||
}
|
||||
@ -178,18 +174,26 @@ public class Utils {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void showToast(Context context, String message){
|
||||
|
||||
public static void showToast(Context context, String message) {
|
||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static Intent newEmailIntent(Context context, String address, String subject, String body, String cc) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
|
||||
intent.putExtra(Intent.EXTRA_TEXT, body);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||
intent.putExtra(Intent.EXTRA_CC, cc);
|
||||
intent.setType("message/rfc822");
|
||||
return intent;
|
||||
|
||||
public static Intent newEmailIntent(Context context, String address,
|
||||
String subject, String body, String cc) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
|
||||
intent.putExtra(Intent.EXTRA_TEXT, body);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||
intent.putExtra(Intent.EXTRA_CC, cc);
|
||||
intent.setType("message/rfc822");
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static int convertDensityPixesl(Context context, int densityPixels) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
int pixels = (int) (densityPixels * scale + 0.5f);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
}
|
||||
|
216
src/acr/browser/barebones/webviewclasses/CustomChromeClient.java
Normal file
@ -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 @@
|
||||
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 @@
|
||||
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 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|