2.5.0.4 Release Code

- Fixed a several bugs with UI
- moved strings from menu.xml into strings.xml for easier translation
- updated Incognito code
This commit is contained in:
Anthony Restaino 2013-08-03 11:34:53 -04:00
parent 8edc7aa3a1
commit 1d49f83aa7
29 changed files with 437 additions and 650 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acr.browser.barebones"
android:versionCode="44"
android:versionCode="45"
android:versionName="2.5.0.4" >
<uses-sdk

View File

@ -402,7 +402,7 @@
android:layout_centerVertical="true"
android:text="@string/importbookmarks"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="?android:attr/textAppearance" />
<TextView
android:id="@+id/isImportAvailable"

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:title="Verlauf" android:titleCondensed="Verlauf" android:orderInCategory="1"></item>
<item android:id="@+id/bookmark" android:title="Zu Lesezeichen hinzufügen" android:titleCondensed="Zu Lesezeichen hinzufügen" android:orderInCategory="2"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="Lesezeichen" android:title="Lesezeichen" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:title="Teilen" android:titleCondensed="Teilen" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:title="Einstellungen" android:titleCondensed="Einstellungen" android:orderInCategory="6"></item>
<item android:id="@+id/forward" android:title="Vorwärts" android:orderInCategory="5" android:titleCondensed="Vorwärts"></item>
</menu>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@id/history" android:orderInCategory="1" android:title="History" android:titleCondensed="History" />
<item android:id="@id/bookmark" android:orderInCategory="2" android:title="Anadir a Marcadores" android:titleCondensed="Anadir a Marcadores" />
<item android:id="@id/allBookmarks" android:orderInCategory="3" android:title="Marcadores" android:titleCondensed="Marcadores" />
<item android:id="@id/share" android:orderInCategory="4" android:title="Compartir" android:titleCondensed="Compartir" />
<item android:id="@id/settings" android:orderInCategory="5" android:title="Ajustes" android:titleCondensed="Ajustes" />
<item android:id="@+id/forward" android:title="Adelante" android:orderInCategory="5" android:titleCondensed="Adelante"></item>
</menu>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:title="History" android:titleCondensed="History" android:orderInCategory="1"></item>
<item android:id="@+id/bookmark" android:title="Ajouter aux favoris" android:titleCondensed="Aj. Favoris" android:orderInCategory="2"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="Favoris" android:title="Favoris" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:title="Partager..." android:titleCondensed="Partager" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:title="Paramètres" android:titleCondensed="Paramètres" android:orderInCategory="6"></item>
<item android:id="@+id/forward" android:title="Suivant" android:orderInCategory="5" android:titleCondensed="Suivant"></item>
</menu>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:title="History" android:titleCondensed="History" android:orderInCategory="1"></item>
<item android:id="@+id/bookmark" android:title="Aggiungi ai preferiti" android:titleCondensed="Aggiungi ai preferiti" android:orderInCategory="2"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="Segnalibri" android:title="Segnalibri" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:title="Azione" android:titleCondensed="Azione" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:title="Impostazioni" android:titleCondensed="Impostazioni" android:orderInCategory="6"></item>
<item android:id="@+id/forward" android:title="Avanti" android:orderInCategory="5" android:titleCondensed="Avanti"></item>
</menu>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:titleCondensed="History" android:title="History" android:orderInCategory="1"></item>
<item android:id="@+id/bookmark" android:titleCondensed="添加书签" android:title="添加书签" android:orderInCategory="2"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="书签列表" android:title="书签" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:titleCondensed="分享页面" android:title="分享" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:titleCondensed="应用设置" android:title="设置" android:orderInCategory="6"></item>
<item android:id="@+id/tabs" android:titleCondensed="显示以及隐藏标签" android:title="显示/隐藏标签" android:orderInCategory="5"></item>
<item android:id="@+id/forward" android:titleCondensed="前进页面" android:title="前进" android:orderInCategory="7"></item>
</menu>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@id/history" android:orderInCategory="1" android:title="History" android:titleCondensed="History" />
<item android:id="@id/bookmark" android:orderInCategory="2" android:title="加入到書簽" android:titleCondensed="加入書簽" />
<item android:id="@id/allBookmarks" android:orderInCategory="3" android:title="我的書簽" android:titleCondensed="我的書簽清單" />
<item android:id="@id/share" android:orderInCategory="4" android:title="分享頁面" android:titleCondensed="分享頁面" />
<item android:id="@id/settings" android:orderInCategory="6" android:title="設定" android:titleCondensed="瀏覽器設定" />
<item android:id="@id/forward" android:orderInCategory="5" android:title="前往下個頁面" android:titleCondensed="前往下個頁面" />
</menu>

View File

@ -1,9 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:title="History" android:titleCondensed="History" android:orderInCategory="1"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="Bookmarks" android:title="Bookmarks" android:orderInCategory="3"></item>
<item android:id="@+id/incognito" android:title="New Tab" android:orderInCategory="5" android:titleCondensed="New Tab"></item>
<item android:id="@+id/history" android:title="@string/menu_history" android:titleCondensed="@string/menu_history" android:orderInCategory="1"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="@string/menu_bookmarks" android:title="@string/menu_bookmarks" android:orderInCategory="3"></item>
<item android:id="@+id/incognito" android:title="@string/menu_new_tab" android:orderInCategory="5" android:titleCondensed="@string/menu_new_tab"></item>
</menu>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/history" android:title="History" android:titleCondensed="History" android:orderInCategory="1"></item>
<item android:id="@+id/bookmark" android:title="Add to bookmarks" android:titleCondensed="Add bookmark" android:orderInCategory="2"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="Bookmarks" android:title="Bookmarks" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:title="Share" android:titleCondensed="Share" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:title="Settings" android:titleCondensed="Settings" android:orderInCategory="6"></item>
<item android:id="@+id/incognito" android:title="Incognito Tab" android:orderInCategory="5" android:titleCondensed="Incognito Tab"></item>
<item android:id="@+id/history" android:title="@string/menu_history" android:titleCondensed="@string/menu_history" android:orderInCategory="1"></item>
<item android:id="@+id/bookmark" android:title="@string/menu_add" android:titleCondensed="@string/menu_add" android:orderInCategory="2"></item>
<item android:id="@+id/allBookmarks" android:titleCondensed="@string/menu_bookmarks" android:title="@string/menu_bookmarks" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:title="@string/menu_share" android:titleCondensed="@string/menu_share" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:title="@string/menu_settings" android:titleCondensed="@string/menu_settings" android:orderInCategory="6"></item>
<item android:id="@+id/incognito" android:title="@string/menu_incognito" android:orderInCategory="5" android:titleCondensed="@string/menu_incognito"></item>
</menu>

View File

@ -1,9 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

View File

@ -9,7 +9,7 @@
<string name="agent">User-Agent</string>
<string name="history">Verlauf beim Beenden leeren</string>
<string name="email">Kontakt</string>
<string name="flash">Adobe Flash aktivieren (falls installiert)</string>
<string name="flash">Adobe Flash aktivieren</string>
<string name="mobile">Mobile Ansicht</string>
<string name="desk">Desktop Ansicht</string>
<string name="custom">Benutzerdefinierte Ansicht</string>
@ -38,5 +38,12 @@
<string name="search">Suchdienst</string>
<string name="search_hint">Suche</string>
<string name="overViewMode">Seiten in der Übersicht öffnen</string>
<string name="menu_history">Verlauf</string>
<string name="menu_add">Zu Lesezeichen hinzufügen</string>
<string name="menu_bookmarks">Lesezeichen</string>
<string name="menu_share">Teilen</string>
<string name="menu_settings">Einstellungen</string>
<string name="menu_incognito">Incognito tab</string>
<string name="menu_new_tab">New tab</string>
</resources>

View File

@ -3,12 +3,12 @@
<string name="app_name">Lightning</string>
<string name="google">Google</string>
<string name="settings">Ajustes del navegador</string>
<string name="location">Permitir a webs acceder a tu ubicacion</string>
<string name="location">Acceder a tu ubicacion</string>
<string name="password">Guardar contrasenas</string>
<string name="agent">Agente de usuario</string>
<string name="history">Borrar historial al salir</string>
<string name="email">Enviame un Email</string>
<string name="flash">Habilitar Adobe Flash (por demanda)</string>
<string name="flash">Habilitar Adobe Flash</string>
<string name="mobile">Ver como movil</string>
<string name="desk">Ver como ordenador</string>
<string name="custom">Ver con agente de usuario distinto</string>
@ -16,4 +16,12 @@
<string name="settingshelp">Solo aplicados a nuevas pestanas</string>
<string name="fullscreen">Enable fullscreen mode</string>
<string name="java">Enable JavaScript</string>
<string name="menu_history">History</string>
<string name="menu_add">Anadir a Marcadores</string>
<string name="menu_bookmarks">Marcadores</string>
<string name="menu_share">Compartir</string>
<string name="menu_settings">Ajustes</string>
<string name="menu_incognito">Incognito tab</string>
<string name="menu_new_tab">New tab</string>
</resources>

View File

@ -2,12 +2,12 @@
<string name="app_name">Lightning</string>
<string name="google">Google</string>
<string name="settings">Paramètres</string>
<string name="location">Autoriser les sites à accéder à ma position</string>
<string name="location">Accéder à ma position</string>
<string name="password">Enregistrer les mots de passe</string>
<string name="agent">User Agent</string>
<string name="history">Effacer l\'historique à la sortie</string>
<string name="email">Contactez moi</string>
<string name="flash">Activer Adobe Flash Player (s\'il est installé)</string>
<string name="flash">Activer Adobe Flash Player</string>
<string name="mobile">Voir la version mobile</string>
<string name="desk">Voir la version ordinateur</string>
<string name="custom">Utiliser un User Agent personnalisé</string>
@ -15,4 +15,11 @@
<string name="settingshelp">Les paramètres ne s\'appliqueront qu\'aux nouveaux onglets</string>
<string name="fullscreen">Activer le mode plein écran</string>
<string name="java">Activer JavaScript</string>
<string name="menu_history">History</string>
<string name="menu_add">Aj. Favoris</string>
<string name="menu_bookmarks">Favoris</string>
<string name="menu_share">Partager</string>
<string name="menu_settings">Paramètres</string>
<string name="menu_incognito">Incognito tab</string>
<string name="menu_new_tab">New tab</string>
</resources>

View File

@ -4,7 +4,7 @@
<string name="app_name">Lightning</string>
<string name="google">Google</string>
<string name="settings">Impostazioni del browser</string>
<string name="location">Consenti ai siti di accedere alla tua posizione</string>
<string name="location">Accedere alla tua posizione</string>
<string name="password">Salva le tue password</string>
<string name="agent">User Agent</string>
<string name="history">Clear history on exit</string>
@ -17,5 +17,12 @@
<string name="settingshelp">Impostazioni valgono solo per le nuove schede</string>
<string name="fullscreen">Enable fullscreen mode</string>
<string name="java">Enable JavaScript</string>
<string name="menu_history">History</string>
<string name="menu_add">Aggiungi ai preferiti</string>
<string name="menu_bookmarks">Segnalibri</string>
<string name="menu_share">Azione</string>
<string name="menu_settings">Impostazioni</string>
<string name="menu_incognito">Incognito tab</string>
<string name="menu_new_tab">New tab</string>
</resources>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Lightning+</string>
<string name="app_name">Lightning</string>
<string name="google">Google</string>
<string name="settings">浏览器设置</string>
<string name="location">允许站点访问您地理位置</string>
@ -17,5 +17,12 @@
<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="menu_share">分享页面</string>
<string name="menu_settings">应用设置</string>
<string name="menu_incognito">Incognito tab</string>
<string name="menu_new_tab">New tab</string>
</resources>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Lightning+</string>
<string name="app_name">Lightning</string>
<string name="google">Google</string>
<string name="settings">瀏覽器設定</string>
<string name="location">允許網頁存取您的位置資訊</string>
@ -16,4 +16,11 @@
<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="menu_share">分享頁面</string>
<string name="menu_settings">設定</string>
<string name="menu_incognito">Incognito tab</string>
<string name="menu_new_tab">New tab</string>
</resources>

View File

@ -33,7 +33,7 @@
<string name="block">Block Images</string>
<string name="window">Allow sites to open new windows</string>
<string name="cookies">Enable Cookies</string>
<string name="importbookmarks">Import bookmarks from Stock Browser</string>
<string name="importbookmarks">Import bookmarks from Browser</string>
<string name="size">Text size</string>
<string name="title_activity_advanced_settings">AdvancedSettings</string>
<string name="hello_world">Hello world!</string>
@ -44,5 +44,14 @@
<string name="wideViewPort">Use wide viewport</string>
<string name="overViewMode">Load pages in overview mode</string>
<string name="restore">Restore lost tabs on start</string>
<string name="menu_history">History</string>
<string name="menu_add">Add bookmark</string>
<string name="menu_bookmarks">Bookmarks</string>
<string name="menu_share">Share</string>
<string name="menu_settings">Settings</string>
<string name="menu_incognito">Incognito tab</string>
<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>
</resources>

View File

@ -8,6 +8,8 @@ import acr.browser.barebones.utilities.FinalVariables;
import acr.browser.barebones.utilities.Utils;
import acr.browser.barebones.activities.BarebonesActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Browser;
import android.app.Activity;
import android.app.AlertDialog;
@ -29,6 +31,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
public class AdvancedSettingsActivity extends Activity {
@ -42,6 +45,8 @@ public class AdvancedSettingsActivity extends Activity {
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 Context CONTEXT;
Handler messageHandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -49,7 +54,9 @@ public class AdvancedSettingsActivity extends Activity {
setContentView(R.layout.advanced_settings);
settings = getSharedPreferences(preferences, 0);
edit = settings.edit();
CONTEXT = this;
initialize();
}
void initialize() {
@ -118,11 +125,27 @@ public class AdvancedSettingsActivity extends Activity {
TextView importBookmarks = (TextView)findViewById(R.id.isImportAvailable);
if(BarebonesActivity.noStockBrowser){
importBookmarks.setText("(No Browser Available)");
importBookmarks.setText(getResources().getString(R.string.stock_browser_unavailable));
}
else{
importBookmarks.setText("(Supported Browser Detected)");
importBookmarks.setText(getResources().getString(R.string.stock_browser_available));
}
messageHandler = new MessageHandler();
}
static class MessageHandler extends Handler{
@Override
public void handleMessage(Message msg) {
switch(msg.what){
case 1:
Utils.showToast(CONTEXT, "History Cleared");
break;
}
super.handleMessage(msg);
}
}
void back() {
@ -454,8 +477,11 @@ public class AdvancedSettingsActivity extends Activity {
}
}
trimCache(AdvancedSettingsActivity.this);
messageHandler.sendEmptyMessage(1);
}
void r9(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() {
@ -550,23 +576,24 @@ public class AdvancedSettingsActivity extends Activity {
String title = "";
String url = "";
int number = 0;
if (mCur.moveToFirst() && mCur.getCount() > 0) {
while (mCur.isAfterLast() == false) {
number++;
title = mCur.getString(mCur
.getColumnIndex(Browser.BookmarkColumns.TITLE));
url = mCur.getString(mCur
.getColumnIndex(Browser.BookmarkColumns.URL));
Utils.addBookmark(getBaseContext(),title,url);
Utils.addBookmark(CONTEXT,title,url);
mCur.moveToNext();
}
}
Utils.showToast(CONTEXT, number + " Bookmarks were imported");
} catch (NullPointerException ignored) {
}
}
else{
Utils.createInformativeDialog(getBaseContext(), "Error", "No browser was detected to import bookmarks from.");
Utils.createInformativeDialog(CONTEXT, "Error", "No browser was detected to import bookmarks from.");
}
}

View File

@ -664,10 +664,12 @@ public class BarebonesActivity extends Activity {
}
public void setUrlText(String url) {
if (!url.startsWith("file://")) {
getUrl.setText(url);
} else {
getUrl.setText("");
if (url != null) {
if (!url.startsWith("file://")) {
getUrl.setText(url);
} else {
getUrl.setText("");
}
}
}
@ -2134,13 +2136,12 @@ public class BarebonesActivity extends Activity {
@Override
public void onBackPressed() {
if (showFullScreen && !uBar.isShown()) {
uBar.startAnimation(slideDown);
}
if (main[pageId] != null && main[pageId].canGoBack()) {
main[pageId].stopLoading();
main[pageId].goBack();
if (showFullScreen && !uBar.isShown()) {
uBar.startAnimation(slideDown);
}
} else {
deleteTab(pageId);
uBar.bringToFront();

View File

@ -8,6 +8,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -19,10 +20,10 @@ import acr.browser.barebones.databases.SpaceTokenizer;
import acr.browser.barebones.utilities.BookmarkPageVariables;
import acr.browser.barebones.utilities.FinalVariables;
import acr.browser.barebones.utilities.HistoryPageVariables;
import acr.browser.barebones.utilities.Utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@ -42,9 +43,9 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.Browser;
import android.text.InputType;
import android.text.TextUtils;
import android.text.method.PasswordTransformationMethod;
@ -75,7 +76,6 @@ import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.SslErrorHandler;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebChromeClient.CustomViewCallback;
@ -105,6 +105,7 @@ import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
@SuppressWarnings("deprecation")
public class IncognitoModeActivity extends Activity {
@SuppressLint("SetJavaScriptEnabled")
@ -120,22 +121,19 @@ public class IncognitoModeActivity extends Activity {
long estimatedDatabaseSize, long totalQuota,
QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(totalQuota + estimatedDatabaseSize);
super.onExceededDatabaseQuota(url, databaseIdentifier, quota,
estimatedDatabaseSize, totalQuota, quotaUpdater);
}
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
}
@Override
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(quota + requiredStorage);
super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
}
@Override
public void onCloseWindow(WebView window) {
closeWindow = window.getId();
browserHandler.sendEmptyMessage(2);
super.onCloseWindow(window);
}
@Override
@ -157,6 +155,15 @@ public class IncognitoModeActivity extends Activity {
return mVideoProgressView;
}
@Override
public void onCloseWindow(WebView window) {
Message msg = Message.obtain();
msg.what = 3;
msg.arg1 = window.getId();
browserHandler.sendMessage(msg);
super.onCloseWindow(window);
}
@Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, final Message resultMsg) {
@ -241,7 +248,6 @@ public class IncognitoModeActivity extends Activity {
@Override
public void onReceivedTitle(final WebView view, final String title) {
numberPage = view.getId();
if (title != null && title.length() != 0) {
urlTitle[numberPage].setText(title);
urlToLoad[numberPage][1] = title;
@ -335,45 +341,76 @@ public class IncognitoModeActivity extends Activity {
public void onDownloadStart(final String url, String userAgent,
final String contentDisposition, final String mimetype,
long contentLength) {
try {
Thread downloader = new Thread(new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Uri nice = Uri.parse(url);
DownloadManager.Request it = new DownloadManager.Request(
nice);
String fileName = URLUtil.guessFileName(url,
contentDisposition, mimetype);
if (API >= 11) {
it.allowScanningByMediaScanner();
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
if (url.endsWith(".mp4") || url.endsWith(".m4a")) {
it.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, fileName);
Log.i("IncognitoMode", "Downloading" + fileName);
download.enqueue(it);
}
});
downloader.run();
} catch (NullPointerException e) {
Log.e("IncognitoMode", "Problem downloading");
Toast.makeText(CONTEXT, "Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (IllegalArgumentException e) {
Log.e("IncognitoMode", "Problem downloading");
Toast.makeText(CONTEXT, "Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (SecurityException ignored) {
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);
startActivity(intent);
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
Utils.downloadFile(CONTEXT, url, contentDisposition, mimetype);
}
}
}
public class CustomWebViewClient extends WebViewClient {
public class IncognitoWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent urlIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
urlIntent
.putExtra("acr.browser.barebones.Origin", view.getId() + 1);
if (url.startsWith("market://")
|| url.startsWith("http://play.google.com")
|| url.startsWith("https://play.google.com")) {
startActivity(urlIntent);
return true;
} else if (url.startsWith("http://www.youtube.com")
|| url.startsWith("https://www.youtube.com")) {
startActivity(urlIntent);
return true;
} else if (url.startsWith("http://maps.google.com")
|| url.startsWith("https://maps.google.com")) {
startActivity(urlIntent);
return true;
} else if (url.contains("tel:") || TextUtils.isDigitsOnly(url)) {
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
return true;
} else if (url.contains("mailto:")) {
startActivity(new Intent(Intent.ACTION_SEND, Uri.parse(url)));
return true;
}
return false;
}
@Override
public void onReceivedHttpAuthRequest(final WebView view,
@ -432,20 +469,19 @@ public class IncognitoModeActivity extends Activity {
@Override
public void onPageFinished(WebView view, final String url) {
if (view.isShown()) {
view.invalidate();
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
if (showFullScreen && uBar.isShown()) {
uBar.startAnimation(slideUp);
}
}
view.getSettings()
.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
Log.i("Lightning", "Page Finished");
loadTime = System.currentTimeMillis() - loadTime;
Log.i("Lightning", "Load Time: "+loadTime);
Log.i("Lightning", "Load Time: " + loadTime);
super.onPageFinished(view, url);
}
@ -464,7 +500,6 @@ public class IncognitoModeActivity extends Activity {
if (view.isShown()) {
refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
setUrlText(url);
}
@ -626,16 +661,17 @@ public class IncognitoModeActivity extends Activity {
}
public void setUrlText(String url) {
if (!url.startsWith("file:///")) {
getUrl.setText(url);
} else {
getUrl.setText("");
if (url != null) {
if (!url.startsWith("file://")) {
getUrl.setText(url);
} else {
getUrl.setText("");
}
}
}
public class TabTouchListener implements OnTouchListener {
@SuppressWarnings("deprecation")
@Override
public boolean onTouch(View v, MotionEvent event) {
id = v.getId();
@ -835,52 +871,10 @@ public class IncognitoModeActivity extends Activity {
}
case DialogInterface.BUTTON_NEUTRAL: {
if (API > 8) {
try {
Thread down = new Thread(
new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
String url = result.getExtra();
DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Uri nice = Uri.parse(result
.getExtra());
DownloadManager.Request it = new DownloadManager.Request(
nice);
String fileName = URLUtil.guessFileName(
result.getExtra(),
null, null);
Utils.downloadFile(CONTEXT, url, null, null);
if (API >= 11) {
it.allowScanningByMediaScanner();
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
it.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS,
fileName);
Log.i("IncognitoMode",
"Downloading"
+ fileName);
download.enqueue(it);
}
});
down.run();
} catch (NullPointerException e) {
Log.e("IncognitoMode",
"Problem downloading");
Toast.makeText(CONTEXT,
"Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (IllegalArgumentException e) {
Log.e("IncognitoMode",
"Problem downloading");
Toast.makeText(CONTEXT,
"Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (SecurityException ignored) {
}
}
break;
}
@ -901,7 +895,6 @@ public class IncognitoModeActivity extends Activity {
} else {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@SuppressWarnings("deprecation")
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
@ -970,9 +963,11 @@ public class IncognitoModeActivity extends Activity {
public static ImageView refresh;
public static ProgressBar progressBar;
public static String defaultUser;
public static Drawable webpageOther;
public static Drawable incognitoPage;
public static Drawable exitTab;
public static int numberPage;
public static long loadTime = 0;
public static int number;
public static int pageId = 0;
public static int agentPicker;
@ -990,7 +985,6 @@ public class IncognitoModeActivity extends Activity {
public static int urlColumn;
public static int titleColumn;
public static int closeWindow;
public static long loadTime = 0;
public static View mCustomView = null;
public static CustomViewCallback mCustomViewCallback;
public static boolean isPhone = false;
@ -999,6 +993,7 @@ public class IncognitoModeActivity extends Activity {
public static boolean deleteHistory;
public static boolean saveTabs;
public static boolean showFullScreen;
public static boolean noStockBrowser = true;
public static SharedPreferences settings;
public static SharedPreferences.Editor edit;
public static String desktop;
@ -1006,6 +1001,7 @@ public class IncognitoModeActivity extends Activity {
public static String user;
public static String urlA;
public static String title;
public static String[] memoryURL = new String[MAX_TABS];
public static final String[] bUrl = new String[MAX_BOOKMARKS];
public static final String[] bTitle = new String[MAX_BOOKMARKS];
public static String[] columns;
@ -1043,10 +1039,6 @@ public class IncognitoModeActivity extends Activity {
public static LinearLayout tabLayout;
public static String[] GetArray(String input) {
return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|");
}
@SuppressWarnings("unused")
public static void setFavicon(int id, Bitmap favicon) {
Drawable icon = null;
@ -1068,13 +1060,13 @@ public class IncognitoModeActivity extends Activity {
android.R.color.white));
view.setWillNotCacheDrawing(false);
view.setLongClickable(true);
view.setAlwaysDrawnWithCacheEnabled(true);
view.setScrollbarFadingEnabled(true);
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.setSaveEnabled(true);
view.setBackgroundColor(0xFFFFFFFF);
WebSettings webViewSettings = view.getSettings();
if (settings.getBoolean("java", true)) {
webViewSettings.setJavaScriptEnabled(true);
webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true); // TODO
@ -1086,29 +1078,52 @@ public class IncognitoModeActivity extends Activity {
// or
// disable
}
webViewSettings.setBlockNetworkImage(false);
webViewSettings.setAllowFileAccess(true);
webViewSettings.setLightTouchEnabled(true);
if (API < 14) {
switch (settings.getInt("textsize", 3)) {
case 1:
webViewSettings.setTextSize(WebSettings.TextSize.LARGEST);
break;
case 2:
webViewSettings.setTextSize(WebSettings.TextSize.LARGER);
break;
case 3:
webViewSettings.setTextSize(WebSettings.TextSize.NORMAL);
break;
case 4:
webViewSettings.setTextSize(WebSettings.TextSize.SMALLER);
break;
case 5:
webViewSettings.setTextSize(WebSettings.TextSize.SMALLEST);
break;
}
} else {
switch (settings.getInt("textsize", 3)) {
case 1:
webViewSettings.setTextZoom(200);
break;
case 2:
webViewSettings.setTextZoom(150);
break;
case 3:
webViewSettings.setTextZoom(100);
break;
case 4:
webViewSettings.setTextZoom(75);
break;
case 5:
webViewSettings.setTextZoom(50);
break;
}
}
webViewSettings.setSupportMultipleWindows(settings.getBoolean(
"newwindow", true));
webViewSettings.setDomStorageEnabled(true);
webViewSettings.setAppCacheEnabled(true);
webViewSettings.setAppCachePath(getApplicationContext().getFilesDir()
.getAbsolutePath() + "/incognito_cache");
try {
webViewSettings.setRenderPriority(RenderPriority.HIGH); // TODO do I
// want this
// here or
// at normal
} catch (SecurityException ignored) {
}
webViewSettings.setGeolocationEnabled(false);
webViewSettings.setGeolocationDatabasePath(getApplicationContext()
.getFilesDir().getAbsolutePath());
webViewSettings.setDatabaseEnabled(true);
webViewSettings.setDatabasePath(getApplicationContext().getFilesDir()
.getAbsolutePath() + "/databases");
.getAbsolutePath() + "/cache");
switch (settings.getInt("enableflash", 0)) {
case 0:
@ -1125,15 +1140,37 @@ public class IncognitoModeActivity extends Activity {
break;
}
if (API < 18) {
if (settings.getBoolean("passwords", false)) {
webViewSettings.setSavePassword(true);
webViewSettings.setSaveFormData(true);
}
try {
webViewSettings.setLightTouchEnabled(true);
webViewSettings.setRenderPriority(RenderPriority.HIGH);
} catch (SecurityException ignored) {
}
} else {
if (settings.getBoolean("passwords", false)) {
webViewSettings.setSaveFormData(true);
}
}
webViewSettings.setGeolocationEnabled(true);
webViewSettings.setGeolocationDatabasePath(getApplicationContext()
.getFilesDir().getAbsolutePath());
webViewSettings.setDatabaseEnabled(true);
webViewSettings.setDatabasePath(getApplicationContext().getFilesDir()
.getAbsolutePath() + "/databases");
webViewSettings.setUserAgentString(userAgent);
webViewSettings.setSavePassword(false);
webViewSettings.setSaveFormData(false);
webViewSettings.setBuiltInZoomControls(true);
webViewSettings.setSupportZoom(true);
webViewSettings.setUseWideViewPort(true);
webViewSettings.setLoadWithOverviewMode(true);
webViewSettings.setBuiltInZoomControls(true);
webViewSettings.setUseWideViewPort(settings.getBoolean("wideviewport",
true));
webViewSettings.setLoadWithOverviewMode(settings.getBoolean(
"overviewmode", true));
if (API >= 11) {
webViewSettings.setDisplayZoomControls(false);
webViewSettings.setAllowContentAccess(true);
@ -1144,41 +1181,28 @@ public class IncognitoModeActivity extends Activity {
webViewSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
}
webViewSettings.setBlockNetworkImage(settings.getBoolean("blockimages",
false));
webViewSettings.setLoadsImagesAutomatically(true);
return view;
}
boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (String aChildren : children) {
boolean success = deleteDir(new File(dir, aChildren));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
@SuppressWarnings("deprecation")
void deleteTab(final int del) {
if (API >= 11) {
main[del].onPause();
}
main[del].stopLoading();
main[del].clearHistory();
main[del].freeMemory();
edit.putString("oldPage", urlToLoad[del][0]);
edit.commit();
urlToLoad[del][0] = null;
urlToLoad[del][1] = null;
if (API < 16) {
urlTitle[del].setBackgroundDrawable(active);
} else {
urlTitle[del].setBackground(active);
}
urlTitle[del].setPadding(leftPad, 0, rightPad, 0);
Animation yolo = AnimationUtils.loadAnimation(this, R.anim.down);
yolo.setAnimationListener(new AnimationListener() {
@ -1203,7 +1227,6 @@ public class IncognitoModeActivity extends Activity {
uBar.bringToFront();
}
@SuppressWarnings("deprecation")
void findNewView(int id) {
int leftId = id;
boolean right = false, left = false;
@ -1369,9 +1392,29 @@ public class IncognitoModeActivity extends Activity {
@Override
public void run() {
Cursor c = null;
Cursor managedCursor = null;
columns = new String[] { "url", "title" };
try {
bookmarks = Browser.BOOKMARKS_URI;
c = getContentResolver().query(bookmarks, columns, null,
null, null);
} catch (SQLiteException ignored) {
} catch (IllegalStateException ignored) {
} catch (NullPointerException ignored) {
}
if (c != null) {
noStockBrowser = false;
Log.i("Barebones", "detected AOSP browser");
} else {
noStockBrowser = true;
Log.e("Barebones", "did not detect AOSP browser");
}
if (c != null) {
c.close();
}
try {
managedCursor = null;
@ -1438,14 +1481,13 @@ public class IncognitoModeActivity extends Activity {
String url;
url = ((TextView) arg1.findViewById(R.id.url)).getText()
.toString();
main[pageId].loadUrl(url);
setUrlText(url);
searchTheWeb(url);
url = null;
getUrl.setPadding(tenPad, 0, tenPad, 0);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
} catch (NullPointerException e) {
Log.e("IncognitoMode Error: ",
Log.e("Barebones Error: ",
"NullPointerException on item click");
}
}
@ -1493,9 +1535,9 @@ public class IncognitoModeActivity extends Activity {
public void finish() {
background.clearDisappearingChildren();
tabScroll.clearDisappearingChildren();
main[pageId].clearCache(true);
Log.i("Lightning", "Cache Cleared");
super.finish();
main[0].clearCache(true);
}
void forward() {
@ -1550,6 +1592,7 @@ public class IncognitoModeActivity extends Activity {
cookieManager.setAcceptCookie(false);
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
if (API >= 11) {
progressBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.ics_animation));
@ -1564,9 +1607,11 @@ public class IncognitoModeActivity extends Activity {
slideUp = AnimationUtils.loadAnimation(this, R.anim.slide_up);
slideDown = AnimationUtils.loadAnimation(this, R.anim.slide_down);
fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
fadeOut.setDuration(250);
fadeIn = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
mShortAnimationDuration = getResources().getInteger(
android.R.integer.config_mediumAnimTime);
// mShortAnimationDuration = getResources().getInteger(
// android.R.integer.config_mediumAnimTime);
mShortAnimationDuration = 250;
slideUp.setAnimationListener(new AnimationListener() {
@Override
@ -1610,7 +1655,11 @@ public class IncognitoModeActivity extends Activity {
refreshLayout.setBackgroundResource(R.drawable.button);
// user agent
user = new WebView(CONTEXT).getSettings().getUserAgentString();
if (API < 17) {
user = new WebView(CONTEXT).getSettings().getUserAgentString();
} else {
user = WebSettings.getDefaultUserAgent(this);
}
background = (FrameLayout) findViewById(R.id.holder);
defaultUser = user; // setting mobile user
@ -1676,6 +1725,7 @@ public class IncognitoModeActivity extends Activity {
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
// opens icondatabase so that favicons can be stored
WebIconDatabase.getInstance().open(
getDir("icons", MODE_PRIVATE).getPath());
@ -1700,9 +1750,9 @@ public class IncognitoModeActivity extends Activity {
tenPad = (int) (10 * scale + 0.5f);
number = 0;
webpageOther = getResources().getDrawable(R.drawable.webpage);
incognitoPage = getResources().getDrawable(R.drawable.incognito);
webpageOther.setBounds(0, 0, width / 2, height / 2);
incognitoPage.setBounds(0, 0, width / 2, height / 2);
exitTab.setBounds(0, 0, width * 2 / 3, height * 2 / 3);
@ -1710,7 +1760,7 @@ public class IncognitoModeActivity extends Activity {
@Override
public void run() {
initializeTabs(); // restores old tabs or creates a new one
reopenOldTabs(); // restores old tabs or creates a new one
}
@ -1733,6 +1783,27 @@ public class IncognitoModeActivity extends Activity {
}
});
newTab.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (settings.getString("oldPage", "").length() > 0) {
newTab(number, settings.getString("oldPage", ""), true,
false);
edit.putString("oldPage", "");
edit.commit();
tabScroll.postDelayed(new Runnable() {
@Override
public void run() {
tabScroll.smoothScrollTo(
urlTitle[pageId].getLeft(), 0);
}
}, 100L);
}
return true;
}
});
refresh = (ImageView) findViewById(R.id.refresh);
refreshLayout.setOnClickListener(new OnClickListener() {
@ -1753,41 +1824,38 @@ public class IncognitoModeActivity extends Activity {
bg.removeView(uBar);
background.addView(uBar);
}
browserHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1: {
main[pageId].loadUrl(getUrl.getText().toString());
break;
}
case 2: {
deleteTab(closeWindow);
break;
}
case 3: {
main[pageId].invalidate();
break;
}
}
}
};
browserHandler = new Handle();
}
void initializeTabs() {
Intent url = getIntent();
String URL = url.getDataString();
if (URL != null) {
// opens a new tab with the URL if its there
newTab(number, URL, true, false);
main[number - 1].resumeTimers();
} else {
// otherwise it opens the home-page
newTab(number, homepage, true, false);
main[number - 1].resumeTimers();
class Handle extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1: {
main[pageId].loadUrl(getUrl.getText().toString());
break;
}
case 2: {
deleteTab(msg.arg1);
break;
}
case 3: {
main[pageId].invalidate();
break;
}
}
super.handleMessage(msg);
}
}
void reopenOldTabs() {
// it opens the home-page
newTab(number, homepage, true, false);
main[number - 1].resumeTimers();
}
public IncognitoWebView makeTab(final int pageToView, String Url,
@ -1795,7 +1863,7 @@ public class IncognitoModeActivity extends Activity {
IncognitoWebView view = new IncognitoWebView(CONTEXT);
view.setId(pageToView);
allowLocation = settings.getBoolean("location", false);
view.setWebViewClient(new CustomWebViewClient());
view.setWebViewClient(new IncognitoWebViewClient());
view.setWebChromeClient(new CustomChromeClient());
if (API > 8) {
view.setDownloadListener(new CustomDownloadListener());
@ -1833,7 +1901,7 @@ public class IncognitoModeActivity extends Activity {
view.loadUrl(Url);
}
Log.i("IncognitoMode", "tab complete");
Log.i("Barebones", "tab complete");
return view;
}
@ -1842,10 +1910,9 @@ public class IncognitoModeActivity extends Activity {
}
// new tab method, takes the id of the tab to be created and the url to load
@SuppressWarnings("deprecation")
int newTab(int theId, final String theUrl, final boolean display,
final boolean incognito_mode) {
Log.i("IncognitoMode", "making tab");
Log.i("Barebones", "making tab");
int finalID = 0;
homepage = settings.getString("home", HOMEPAGE);
@ -1897,8 +1964,8 @@ public class IncognitoModeActivity extends Activity {
urlTitle[pageId].setBackground(inactive);
}
}
urlTitle[num].setCompoundDrawables(incognitoPage, null, exitTab,
null);
urlTitle[num].setCompoundDrawables(incognitoPage, null,
exitTab, null);
urlTitle[num].setPadding(leftPad, 0, rightPad, 0);
urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0);
main[num] = makeTab(num, theUrl, display);
@ -1951,7 +2018,7 @@ public class IncognitoModeActivity extends Activity {
title.setId(number);
title.setGravity(Gravity.CENTER_VERTICAL);
title.setCompoundDrawables(incognitoPage, null, exitTab, null);
title.setCompoundDrawables(webpageOther, null, exitTab, null);
Drawable[] drawables = title.getCompoundDrawables();
bounds = drawables[2].getBounds();
@ -2013,13 +2080,12 @@ public class IncognitoModeActivity extends Activity {
@Override
public void onBackPressed() {
if (showFullScreen && !uBar.isShown()) {
uBar.startAnimation(slideDown);
}
if (main[pageId] != null && main[pageId].canGoBack()) {
main[pageId].stopLoading();
main[pageId].goBack();
if (showFullScreen && !uBar.isShown()) {
uBar.startAnimation(slideDown);
}
} else {
deleteTab(pageId);
uBar.bringToFront();
@ -2030,8 +2096,7 @@ public class IncognitoModeActivity extends Activity {
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO
main[pageId].getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
super.onConfigurationChanged(newConfig);
if (settings.getBoolean("textreflow", false)) {
main[pageId].getSettings().setLayoutAlgorithm(
LayoutAlgorithm.NARROW_COLUMNS);
@ -2039,7 +2104,7 @@ public class IncognitoModeActivity extends Activity {
main[pageId].getSettings().setLayoutAlgorithm(
LayoutAlgorithm.NORMAL);
}
super.onConfigurationChanged(newConfig);
}
@Override
@ -2065,33 +2130,6 @@ public class IncognitoModeActivity extends Activity {
isPhone = sizeInInches < 6.5;
forward();// forward button
back();
int first = settings.getInt("first", 0);
if (first == 0) { // This dialog alerts the user to some navigation
// techniques
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); // dialog
builder.setTitle("Browser Tips");
builder.setMessage(
"\nLong-press back button to exit browser"
+ "\n\nSet your homepage in settings to about:blank to set a blank page as your default"
+ "\n\nSet the homepage to about:home to set bookmarks as your homepage"
+ "\n\nLong-press a link to open in a new tab"
+ "\n\nCheck out the settings for more stuff!")
.setPositiveButton("Ok", dialogClickListener).show();
edit.putInt("first", 1);
edit.commit();
}
}
@Override
@ -2107,6 +2145,11 @@ public class IncognitoModeActivity extends Activity {
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (!settings.getBoolean("restoreclosed", true)) {
for (int n = 0; n < MAX_TABS; n++) {
urlToLoad[n][0] = null;
}
}
finish();
return true;
} else
@ -2120,17 +2163,24 @@ public class IncognitoModeActivity extends Activity {
case R.id.history:
generateHistory(main[pageId]);
return true;
case R.id.settings:
newSettings();
return true;
case R.id.allBookmarks:
if (!urlToLoad[pageId][1].equals("Bookmarks")) {
if (urlToLoad[pageId][1] == null) {
goBookmarks(main[pageId]);
} else if (!urlToLoad[pageId][1].equals("Bookmarks")) {
goBookmarks(main[pageId]);
}
return true;
case R.id.incognito:
newTab(number,homepage,true,true);
startActivity(new Intent(FinalVariables.INCOGNITO_INTENT));
// newTab(number, homepage, true, true);
return true;
default:
return false;
return super.onOptionsItemSelected(item);
}
}
@ -2143,20 +2193,26 @@ public class IncognitoModeActivity extends Activity {
}
main[pageId].pauseTimers();
}
}
@Override
protected void onResume() {
super.onResume();
if (main[pageId].getProgress() == 100) {
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
}
if (API >= 11) {
main[pageId].onResume();
}
main[0].resumeTimers();
main[pageId].resumeTimers();
}
void openBookmarks(IncognitoWebView view) {
String bookmarkHtml = BookmarkPageVariables.Heading;
for (int n = 0; n < MAX_BOOKMARKS; n++) {
if (bUrl[n] != null) {
bookmarkHtml += (BookmarkPageVariables.Part1 + bUrl[n]
@ -2205,13 +2261,21 @@ public class IncognitoModeActivity extends Activity {
case R.id.history:
generateHistory(main[pageId]);
return true;
case R.id.settings:
newSettings();
return true;
case R.id.allBookmarks:
if (!urlToLoad[pageId][1].equals("Bookmarks")) {
if (urlToLoad[pageId][1] == null) {
goBookmarks(main[pageId]);
} else if (!urlToLoad[pageId][1]
.equals("Bookmarks")) {
goBookmarks(main[pageId]);
}
return true;
case R.id.incognito:
newTab(number,homepage,true,true);
startActivity(new Intent(
FinalVariables.INCOGNITO_INTENT));
// newTab(number, homepage, true, true);
return true;
default:
@ -2243,25 +2307,22 @@ public class IncognitoModeActivity extends Activity {
query = query.trim();
main[pageId].stopLoading();
if(query.startsWith("www.")){
if (query.startsWith("www.")) {
query = "http://" + query;
}
else if(query.startsWith("ftp.")){
} else if (query.startsWith("ftp.")) {
query = "ftp://" + query;
}
boolean containsPeriod = query.contains(".");
boolean isIPAddress = (TextUtils.isDigitsOnly(query.replace(".", ""))&&(query.replace(".", "").length()>=4));
boolean isIPAddress = (TextUtils.isDigitsOnly(query.replace(".", "")) && (query
.replace(".", "").length() >= 4));
boolean aboutScheme = query.contains("about:");
boolean validURL = (query.startsWith("ftp://")||
query.startsWith("http://")||
query.startsWith("file://")||
query.startsWith("https://"))||
isIPAddress;
boolean validURL = (query.startsWith("ftp://")
|| query.startsWith("http://") || query.startsWith("file://") || query
.startsWith("https://")) || isIPAddress;
boolean isSearch = ((query.contains(" ") || !containsPeriod) && !aboutScheme);
if (query.contains("about:home")
|| query.contains("about:bookmarks")) {
if (query.contains("about:home") || query.contains("about:bookmarks")) {
goBookmarks(main[pageId]);
} else if (query.contains("about:history")) {
generateHistory(main[pageId]);
@ -2274,16 +2335,4 @@ public class IncognitoModeActivity extends Activity {
main[pageId].loadUrl(query);
}
}
void trimCache(Context context) {
try {
File dir = context.getCacheDir();
if (dir != null && dir.isDirectory()) {
deleteDir(dir);
}
} catch (Exception ignored) {
}
}
}

View File

@ -1,7 +1,5 @@
package acr.browser.barebones.customwebview;
import java.lang.reflect.Method;
import acr.browser.barebones.activities.IncognitoModeActivity;
import acr.browser.barebones.utilities.FinalVariables;
import android.content.Context;
@ -9,7 +7,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.webkit.WebView;
import android.widget.ZoomButtonsController;
public final class IncognitoWebView extends WebView {
private float location;
@ -19,22 +16,15 @@ public final class IncognitoWebView extends WebView {
final View uBar = IncognitoModeActivity.uBar;
final Animation slideUp = IncognitoModeActivity.slideUp;
final Animation slideDown = IncognitoModeActivity.slideDown;
private ZoomButtonsController zoomControl;
public IncognitoWebView(Context context) {
super(context);
getControls();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (API < 11 && zoomControl != null) {
try {
zoomControl.getZoomControls().setVisibility(View.INVISIBLE);
} catch (IllegalArgumentException ignored) {
}
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
first = true;
@ -62,15 +52,4 @@ public final class IncognitoWebView extends WebView {
return super.onTouchEvent(event);
}
private void getControls() {
if (API < 11) {
try {
Class<?> webview = Class.forName("android.webkit.WebView");
Method method = webview.getMethod("getZoomButtonsController");
zoomControl = (ZoomButtonsController) method.invoke(this, null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -6,7 +6,7 @@ import android.os.Environment;
public class FinalVariables {
public static final int MAX_TABS = 5;
public static final int MAX_BOOKMARKS = 50;
public static final int MAX_BOOKMARKS = 100;
public static final boolean PAID_VERSION = false;
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17";
public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7";

View File

@ -8,6 +8,7 @@ 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;
@ -177,4 +178,8 @@ public class Utils {
}
}
public static void showToast(Context context, String message){
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
}

View File

@ -1,24 +0,0 @@
package acr.browser.barebones.variables;
public class BookmarkPageVariables {
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
+ "<head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />"
+ "<title>Bookmarks</title></head><style>"
+ "div.shadow{-moz-box-shadow: 0px 0px 6px #111;-webkit-box-shadow: 0px 0px 6px #111;box-shadow: 0px 0px 6px #111;}"
+ "body{color: gray;text-size: 10px}"
+ "div {vertical-align: middle;background-color: #ffffff;}"
+ "div.clickable {position:relative;}"
+ "p.font{font-size: 1em;font-family: \"Lucida Console\"}"
+ "div.clickable a {position:absolute;width:100%;height:100%;top:0;left:0;text-decoration:none; z-index:10; background-color:white;opacity: 0; filter: alpha(opacity=1);}"
+ "div.space {height: 0.7em;}"
+ "p{padding-top: 0.5em;padding-bottom: 0.5em;padding-right: 0.5em;padding-left: 0.5em;}"
+ "img{padding-left: 0em;padding-right: 0.5em;}"
+ "</style><body bgcolor = #f2f2f2>";
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=";
public static final String Part3 = "'/>";
public static final String Part4 = "</p></div></div>";
public static final String End = "</body></html>";
}

View File

@ -1,26 +0,0 @@
package acr.browser.barebones.variables;
import android.os.Environment;
public class FinalVariables {
public static final int MAX_TABS = 5;
public static final int MAX_BOOKMARKS = 50;
public static final boolean PAID_VERSION = false;
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17";
public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7";
public static final int API = android.os.Build.VERSION.SDK_INT;
public static final String YAHOO_SEARCH = "http://search.yahoo.com/search?p=";
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 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 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;
}

View File

@ -1,19 +0,0 @@
package acr.browser.barebones.variables;
public class HistoryPageVariables {
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
+ "<head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><title>History</title></head><style>"
+ "div.shadow {-moz-box-shadow: 0px 0px 6px #111;-webkit-box-shadow: 0px 0px 6px #111;box-shadow: 0px 0px 6px #111;}"
+ "body{color: gray;text-size: 10px}div.space {height: 0.7em;} div.extra{text-align: center;}div {vertical-align: middle;}"
+ "div {background-color: #ffffff;}div.clickable {position:relative;}p.black{color: black;font-size: 1em;font-family: \"Lucida Console\"}"
+ "p.font{font-size: 1em;font-family: \"Lucida Console\"}p.black{padding-left: 0.5em;padding-right: 0.5em;padding-top: 0.5em;padding-bottom: 0em;}"
+ "p.font{padding-left: 0.5em;padding-right: 0.5em;padding-top: 0em;padding-bottom: 0.5em;}"
+ "div.clickable a {position:absolute; width:100%;height:100%;top:0;left:0;text-decoration:none; z-index:10; background-color:white;opacity: 0;filter: alpha(opacity=1);}"
+ "</style><body bgcolor = #f2f2f2>";
public static final String Part1 = "<div class=\"clickable\"><div class=\"shadow\"><a href=\"";
public static final String Part2 = "\"></a><p class=\"black\">";
public static final String Part3 = "</p><p class=\"font\">";
public static final String Part4 = "</p></div></div>";
public static final String End = "</body></html>";
}

View File

@ -1,174 +0,0 @@
package acr.browser.barebones.variables;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import acr.browser.barebones.databases.DatabaseHandler;
import acr.browser.barebones.databases.HistoryItem;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.Browser;
import android.util.Log;
import android.webkit.URLUtil;
import android.widget.Toast;
public class Utils {
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) {
}
});
AlertDialog alert = builder.create();
alert.show();
}
public static void addBookmark(Context context, String title, String url) {
File book = new File(context.getFilesDir(), "bookmarks");
File bookUrl = new File(context.getFilesDir(), "bookurl");
try {
BufferedReader readUrlRead = new BufferedReader(new FileReader(
bookUrl));
String u;
int n = 0;
while ((u = readUrlRead.readLine()) != null
&& n < FinalVariables.MAX_BOOKMARKS) {
if (u.contentEquals(url)) {
readUrlRead.close();
return;
}
n++;
}
readUrlRead.close();
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {
} catch (NullPointerException ignored) {
}
try {
BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book,
true));
BufferedWriter urlWriter = new BufferedWriter(new FileWriter(
bookUrl, true));
bookWriter.write(title);
urlWriter.write(url);
bookWriter.newLine();
urlWriter.newLine();
bookWriter.close();
urlWriter.close();
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {
} catch (NullPointerException ignored) {
}
}
public static void updateHistory(final Context context,
final ContentResolver content, final boolean noStockBrowser,
final String url, final String title) {
Runnable update = new Runnable() {
@Override
public void run() {
if (!noStockBrowser) {
try {
Browser.updateVisitedHistory(content, url, true);
} catch (NullPointerException ignored) {
}
}
try {
StringBuilder sb = new StringBuilder("url" + " = ");
DatabaseUtils.appendEscapedSQLString(sb, url);
DatabaseHandler historyHandler = new DatabaseHandler(
context);
SQLiteDatabase history = historyHandler.getReadableDatabase();
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));
} else {
historyHandler.delete(url);
historyHandler.addHistoryItem(new HistoryItem(url,
title));
}
historyHandler.close();
cursor.close();
history.close();
} catch (IllegalStateException e) {
Log.e("Barebones", "IllegalStateException in updateHistory");
} catch (NullPointerException e) {
Log.e("Barebones", "NullPointerException in updateHistory");
} catch (SQLiteException e) {
Log.e("Barebones", "SQLiteException in updateHistory");
}
}
};
if (url != null) {
if (!url.startsWith("file://")) {
new Thread(update).start();
}
}
}
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
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);
Uri nice = Uri.parse(url);
DownloadManager.Request it = new DownloadManager.Request(
nice);
String fileName = URLUtil.guessFileName(url,
contentDisposition, mimetype);
if (FinalVariables.API >= 11) {
it.allowScanningByMediaScanner();
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
it.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, fileName);
Log.i("Barebones", "Downloading" + fileName);
download.enqueue(it);
}
});
downloader.run();
} catch (NullPointerException e) {
Log.e("Barebones", "Problem downloading");
Toast.makeText(context, "Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (IllegalArgumentException e) {
Log.e("Barebones", "Problem downloading");
Toast.makeText(context, "Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (SecurityException ignored) {
}
}
}