From 1d49f83aa7fa1bc459ab72ed42a2834a52af4c03 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Sat, 3 Aug 2013 11:34:53 -0400 Subject: [PATCH] 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 --- AndroidManifest.xml | 2 +- res/layout/advanced_settings.xml | 2 +- res/menu-de/menu.xml | 11 - res/menu-es/menu.xml | 10 - res/menu-fr/menu.xml | 11 - res/menu-it/menu.xml | 11 - res/menu-zh-rCN/menu.xml | 12 - res/menu-zh-rTW/menu.xml | 10 - res/menu/advanced_settings.xml | 9 - res/menu/incognito_menu.xml | 6 +- res/menu/menu.xml | 12 +- res/menu/new_settings.xml | 9 - res/values-de/strings.xml | 9 +- res/values-es/strings.xml | 12 +- res/values-fr/strings.xml | 11 +- res/values-it/strings.xml | 9 +- res/values-zh-rCN/strings.xml | 9 +- res/values-zh-rTW/strings.xml | 9 +- res/values/strings.xml | 11 +- .../activities/AdvancedSettingsActivity.java | 39 +- .../activities/BarebonesActivity.java | 17 +- .../activities/IncognitoModeActivity.java | 581 ++++++++++-------- .../customwebview/IncognitoWebView.java | 25 +- .../barebones/utilities/FinalVariables.java | 2 +- .../browser/barebones/utilities/Utils.java | 5 + .../variables/BookmarkPageVariables.java | 24 - .../barebones/variables/FinalVariables.java | 26 - .../variables/HistoryPageVariables.java | 19 - .../browser/barebones/variables/Utils.java | 174 ------ 29 files changed, 437 insertions(+), 650 deletions(-) delete mode 100644 res/menu-de/menu.xml delete mode 100644 res/menu-es/menu.xml delete mode 100644 res/menu-fr/menu.xml delete mode 100644 res/menu-it/menu.xml delete mode 100644 res/menu-zh-rCN/menu.xml delete mode 100644 res/menu-zh-rTW/menu.xml delete mode 100644 res/menu/advanced_settings.xml delete mode 100644 res/menu/new_settings.xml delete mode 100644 src/acr/browser/barebones/variables/BookmarkPageVariables.java delete mode 100644 src/acr/browser/barebones/variables/FinalVariables.java delete mode 100644 src/acr/browser/barebones/variables/HistoryPageVariables.java delete mode 100644 src/acr/browser/barebones/variables/Utils.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 013c916..26b5b8e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:textAppearance="?android:attr/textAppearance" /> - - - - - - - - - - diff --git a/res/menu-es/menu.xml b/res/menu-es/menu.xml deleted file mode 100644 index 382547e..0000000 --- a/res/menu-es/menu.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/res/menu-fr/menu.xml b/res/menu-fr/menu.xml deleted file mode 100644 index bc76997..0000000 --- a/res/menu-fr/menu.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/res/menu-it/menu.xml b/res/menu-it/menu.xml deleted file mode 100644 index 598c1d7..0000000 --- a/res/menu-it/menu.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/res/menu-zh-rCN/menu.xml b/res/menu-zh-rCN/menu.xml deleted file mode 100644 index 0b585ed..0000000 --- a/res/menu-zh-rCN/menu.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/res/menu-zh-rTW/menu.xml b/res/menu-zh-rTW/menu.xml deleted file mode 100644 index af22832..0000000 --- a/res/menu-zh-rTW/menu.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/res/menu/advanced_settings.xml b/res/menu/advanced_settings.xml deleted file mode 100644 index c002028..0000000 --- a/res/menu/advanced_settings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/res/menu/incognito_menu.xml b/res/menu/incognito_menu.xml index 25f63c9..5596a0d 100644 --- a/res/menu/incognito_menu.xml +++ b/res/menu/incognito_menu.xml @@ -1,8 +1,8 @@ - - - + + + \ No newline at end of file diff --git a/res/menu/menu.xml b/res/menu/menu.xml index 56f6c43..4d4cfdf 100644 --- a/res/menu/menu.xml +++ b/res/menu/menu.xml @@ -1,11 +1,11 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/res/menu/new_settings.xml b/res/menu/new_settings.xml deleted file mode 100644 index c002028..0000000 --- a/res/menu/new_settings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 082c438..7cba7e6 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -9,7 +9,7 @@ User-Agent Verlauf beim Beenden leeren Kontakt - Adobe Flash aktivieren (falls installiert) + Adobe Flash aktivieren Mobile Ansicht Desktop Ansicht Benutzerdefinierte Ansicht @@ -38,5 +38,12 @@ Suchdienst Suche Seiten in der Übersicht öffnen + Verlauf + Zu Lesezeichen hinzufügen + Lesezeichen + Teilen + Einstellungen + Incognito tab + New tab diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 0e6fe07..59629dd 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -3,12 +3,12 @@ Lightning Google Ajustes del navegador - Permitir a webs acceder a tu ubicacion + Acceder a tu ubicacion Guardar contrasenas Agente de usuario Borrar historial al salir Enviame un Email - Habilitar Adobe Flash (por demanda) + Habilitar Adobe Flash Ver como movil Ver como ordenador Ver con agente de usuario distinto @@ -16,4 +16,12 @@ Solo aplicados a nuevas pestanas Enable fullscreen mode Enable JavaScript + History + Anadir a Marcadores + Marcadores + Compartir + Ajustes + Incognito tab + New tab + diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index a8e427f..b56c1fe 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -2,12 +2,12 @@ Lightning Google Paramètres - Autoriser les sites à accéder à ma position + Accéder à ma position Enregistrer les mots de passe User Agent Effacer l\'historique à la sortie Contactez moi - Activer Adobe Flash Player (s\'il est installé) + Activer Adobe Flash Player Voir la version mobile Voir la version ordinateur Utiliser un User Agent personnalisé @@ -15,4 +15,11 @@ Les paramètres ne s\'appliqueront qu\'aux nouveaux onglets Activer le mode plein écran Activer JavaScript + History + Aj. Favoris + Favoris + Partager + Paramètres + Incognito tab + New tab \ No newline at end of file diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 6f5be6c..b7afe9b 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -4,7 +4,7 @@ Lightning Google Impostazioni del browser - Consenti ai siti di accedere alla tua posizione + Accedere alla tua posizione Salva le tue password User Agent Clear history on exit @@ -17,5 +17,12 @@ Impostazioni valgono solo per le nuove schede Enable fullscreen mode Enable JavaScript + History + Aggiungi ai preferiti + Segnalibri + Azione + Impostazioni + Incognito tab + New tab \ No newline at end of file diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 67c0bf6..c1de95f 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -1,7 +1,7 @@ - Lightning+ + Lightning Google 浏览器设置 允许站点访问您地理位置 @@ -17,5 +17,12 @@ 设置仅将应用于新标签页 启用全屏模式 启用 JavaScript + History + 添加书签 + 书签列表 + 分享页面 + 应用设置 + Incognito tab + New tab \ No newline at end of file diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 9ae223a..25a8334 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -1,6 +1,6 @@ - Lightning+ + Lightning Google 瀏覽器設定 允許網頁存取您的位置資訊 @@ -16,4 +16,11 @@ 設定僅套用於新的標簽頁 啓用全螢幕模式 啓用 JavaScript + History + 加入到書簽 + 我的書簽 + 分享頁面 + 設定 + Incognito tab + New tab diff --git a/res/values/strings.xml b/res/values/strings.xml index 2fba66a..974ccca 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -33,7 +33,7 @@ Block Images Allow sites to open new windows Enable Cookies - Import bookmarks from Stock Browser + Import bookmarks from Browser Text size AdvancedSettings Hello world! @@ -44,5 +44,14 @@ Use wide viewport Load pages in overview mode Restore lost tabs on start + History + Add bookmark + Bookmarks + Share + Settings + Incognito tab + New tab + (No stock browser detected) + (Supported stock browser detected) \ No newline at end of file diff --git a/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java b/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java index d3f8c9d..39daa12 100644 --- a/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java +++ b/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java @@ -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,13 +125,29 @@ 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() { ImageView back = (ImageView) findViewById(R.id.advanced_back); back.setBackgroundResource(R.drawable.button); @@ -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."); } } diff --git a/src/acr/browser/barebones/activities/BarebonesActivity.java b/src/acr/browser/barebones/activities/BarebonesActivity.java index 2a06eac..4f97c96 100644 --- a/src/acr/browser/barebones/activities/BarebonesActivity.java +++ b/src/acr/browser/barebones/activities/BarebonesActivity.java @@ -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(); diff --git a/src/acr/browser/barebones/activities/IncognitoModeActivity.java b/src/acr/browser/barebones/activities/IncognitoModeActivity.java index 019c124..bd09f56 100644 --- a/src/acr/browser/barebones/activities/IncognitoModeActivity.java +++ b/src/acr/browser/barebones/activities/IncognitoModeActivity.java @@ -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,30 +1078,53 @@ 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) { + .getAbsolutePath() + "/cache"); - } - webViewSettings.setGeolocationEnabled(false); - webViewSettings.setGeolocationDatabasePath(getApplicationContext() - .getFilesDir().getAbsolutePath()); - webViewSettings.setDatabaseEnabled(true); - webViewSettings.setDatabasePath(getApplicationContext().getFilesDir() - .getAbsolutePath() + "/databases"); - switch (settings.getInt("enableflash", 0)) { case 0: break; @@ -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: @@ -2242,26 +2306,23 @@ public class IncognitoModeActivity extends Activity { void searchTheWeb(String query) { 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) { - - } - } } \ No newline at end of file diff --git a/src/acr/browser/barebones/customwebview/IncognitoWebView.java b/src/acr/browser/barebones/customwebview/IncognitoWebView.java index 7d92c37..1b5cbfe 100644 --- a/src/acr/browser/barebones/customwebview/IncognitoWebView.java +++ b/src/acr/browser/barebones/customwebview/IncognitoWebView.java @@ -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(); - } - } - } } diff --git a/src/acr/browser/barebones/utilities/FinalVariables.java b/src/acr/browser/barebones/utilities/FinalVariables.java index cd34a25..bc601e2 100644 --- a/src/acr/browser/barebones/utilities/FinalVariables.java +++ b/src/acr/browser/barebones/utilities/FinalVariables.java @@ -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"; diff --git a/src/acr/browser/barebones/utilities/Utils.java b/src/acr/browser/barebones/utilities/Utils.java index 6be37e8..e7f41dd 100644 --- a/src/acr/browser/barebones/utilities/Utils.java +++ b/src/acr/browser/barebones/utilities/Utils.java @@ -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(); + } + } diff --git a/src/acr/browser/barebones/variables/BookmarkPageVariables.java b/src/acr/browser/barebones/variables/BookmarkPageVariables.java deleted file mode 100644 index 5dd24d9..0000000 --- a/src/acr/browser/barebones/variables/BookmarkPageVariables.java +++ /dev/null @@ -1,24 +0,0 @@ -package acr.browser.barebones.variables; - -public class BookmarkPageVariables { - public static final String Heading = "" - + "" - + "Bookmarks"; - public static final String Part1 = "
" - + "
" + "

" + ""+ - ""; - public static final String Part4 = "

"; - public static final String End = ""; -} diff --git a/src/acr/browser/barebones/variables/FinalVariables.java b/src/acr/browser/barebones/variables/FinalVariables.java deleted file mode 100644 index 00148d0..0000000 --- a/src/acr/browser/barebones/variables/FinalVariables.java +++ /dev/null @@ -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; - - - -} diff --git a/src/acr/browser/barebones/variables/HistoryPageVariables.java b/src/acr/browser/barebones/variables/HistoryPageVariables.java deleted file mode 100644 index 7cd1759..0000000 --- a/src/acr/browser/barebones/variables/HistoryPageVariables.java +++ /dev/null @@ -1,19 +0,0 @@ -package acr.browser.barebones.variables; - -public class HistoryPageVariables { - public static final String Heading = "" - + "History"; - - public static final String Part1 = "

"; - public static final String Part3 = "

"; - public static final String Part4 = "

"; - public static final String End = ""; -} diff --git a/src/acr/browser/barebones/variables/Utils.java b/src/acr/browser/barebones/variables/Utils.java deleted file mode 100644 index 0b02460..0000000 --- a/src/acr/browser/barebones/variables/Utils.java +++ /dev/null @@ -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) { - - } - } - -}