diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1340ea2..013c916 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="2.5.0.4" > @@ -110,7 +110,7 @@ diff --git a/res/drawable-xhdpi/bg_inactive.9.png b/res/drawable-xhdpi/bg_inactive.9.png index a46cc89..f8b3ac4 100644 Binary files a/res/drawable-xhdpi/bg_inactive.9.png and b/res/drawable-xhdpi/bg_inactive.9.png differ diff --git a/res/drawable-xhdpi/bg_press.9.png b/res/drawable-xhdpi/bg_press.9.png index 0458ed7..5e25a00 100644 Binary files a/res/drawable-xhdpi/bg_press.9.png and b/res/drawable-xhdpi/bg_press.9.png differ diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml index 7137aa5..3dcf6f8 100644 --- a/res/layout/activity_main.xml +++ b/res/layout/activity_main.xml @@ -17,7 +17,7 @@ @@ -119,7 +119,6 @@ android:layout_centerVertical="true" android:indeterminate="true" /> - @@ -148,6 +149,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/urlBar" > + \ No newline at end of file diff --git a/res/layout/advanced_settings.xml b/res/layout/advanced_settings.xml index e2f5964..b094465 100644 --- a/res/layout/advanced_settings.xml +++ b/res/layout/advanced_settings.xml @@ -346,6 +346,30 @@ android:layout_alignParentRight="true" android:layout_centerVertical="true"/> + + + + + + + Search Use wide viewport Load pages in overview mode + Restore lost tabs on start \ 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 417b80c..d3f8c9d 100644 --- a/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java +++ b/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java @@ -3,9 +3,9 @@ package acr.browser.barebones.activities; import java.io.File; import acr.browser.barebones.R; -import acr.browser.barebones.variables.BookmarkPageVariables; -import acr.browser.barebones.variables.FinalVariables; -import acr.browser.barebones.variables.Utils; +import acr.browser.barebones.utilities.BookmarkPageVariables; +import acr.browser.barebones.utilities.FinalVariables; +import acr.browser.barebones.utilities.Utils; import acr.browser.barebones.activities.BarebonesActivity; import android.os.Bundle; import android.provider.Browser; @@ -40,8 +40,8 @@ public class AdvancedSettingsActivity extends Activity { static final String preferences = "settings"; static SharedPreferences settings; static SharedPreferences.Editor edit; - static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12; - static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9; + 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; @Override protected void onCreate(Bundle savedInstanceState) { @@ -66,6 +66,7 @@ public class AdvancedSettingsActivity extends Activity { r10 = (RelativeLayout) findViewById(R.id.r10); r11 = (RelativeLayout) findViewById(R.id.r11); r12 = (RelativeLayout) findViewById(R.id.r12); + r13 = (RelativeLayout) findViewById(R.id.r13); cb1 = (CheckBox) findViewById(R.id.cb1); cb2 = (CheckBox) findViewById(R.id.cb2); @@ -76,6 +77,7 @@ public class AdvancedSettingsActivity extends Activity { cb7 = (CheckBox) findViewById(R.id.cb7); cb8 = (CheckBox) findViewById(R.id.cb8); cb9 = (CheckBox) findViewById(R.id.cb9); + cb10 = (CheckBox) findViewById(R.id.cb10); cb1.setChecked(settings.getBoolean("passwords", true)); cb2.setChecked(settings.getBoolean("cache", false)); @@ -86,6 +88,7 @@ public class AdvancedSettingsActivity extends Activity { cb7.setChecked(settings.getBoolean("cookies", true)); cb8.setChecked(settings.getBoolean("wideviewport", true)); cb9.setChecked(settings.getBoolean("overviewmode", true)); + cb10.setChecked(settings.getBoolean("restoreclosed", true)); r1(r1); r2(r2); @@ -99,6 +102,7 @@ public class AdvancedSettingsActivity extends Activity { r10(r10); r11(r11); r12(r12); + r13(r13); cb1(cb1); cb2(cb2); cb3(cb3); @@ -108,6 +112,7 @@ public class AdvancedSettingsActivity extends Activity { cb7(cb7); cb8(cb8); cb9(cb9); + cb10(cb10); back(); TextView importBookmarks = (TextView)findViewById(R.id.isImportAvailable); @@ -247,6 +252,19 @@ public class AdvancedSettingsActivity extends Activity { }); } + + void cb10(CheckBox view) { + view.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + edit.putBoolean("restoreclosed", isChecked); + edit.commit(); + } + + }); + } void r1(RelativeLayout view) { view.setOnClickListener(new OnClickListener() { @@ -402,6 +420,18 @@ public class AdvancedSettingsActivity extends Activity { }); } + void r13(RelativeLayout view) { + view.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + cb10.setChecked(!cb10.isChecked()); + } + + }); + } + @SuppressWarnings("deprecation") public void clearHistory() { CookieManager c = CookieManager.getInstance(); diff --git a/src/acr/browser/barebones/activities/BarebonesActivity.java b/src/acr/browser/barebones/activities/BarebonesActivity.java index 1336f3d..2a06eac 100644 --- a/src/acr/browser/barebones/activities/BarebonesActivity.java +++ b/src/acr/browser/barebones/activities/BarebonesActivity.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; @@ -16,10 +17,10 @@ import acr.browser.barebones.R; import acr.browser.barebones.customwebview.CustomWebView; import acr.browser.barebones.databases.DatabaseHandler; import acr.browser.barebones.databases.SpaceTokenizer; -import acr.browser.barebones.variables.BookmarkPageVariables; -import acr.browser.barebones.variables.FinalVariables; -import acr.browser.barebones.variables.HistoryPageVariables; -import acr.browser.barebones.variables.Utils; +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; @@ -123,6 +124,13 @@ public class BarebonesActivity extends Activity { } + @Override + public void onProgressChanged(WebView view, int newProgress) { + + + super.onProgressChanged(view, newProgress); + } + @Override public void onReachedMaxAppCacheSize(long requiredStorage, long quota, QuotaUpdater quotaUpdater) { @@ -336,7 +344,7 @@ public class BarebonesActivity extends Activity { public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimetype, long contentLength) { - if (url.endsWith(".mp4")) { + if (url.endsWith(".mp4")||url.endsWith(".m4a")) { AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); builder.setTitle("Open as..."); @@ -468,6 +476,7 @@ public class BarebonesActivity extends Activity { view.invalidate(); progressBar.setVisibility(View.GONE); refresh.setVisibility(View.VISIBLE); + if (showFullScreen && uBar.isShown()) { uBar.startAnimation(slideUp); } @@ -494,7 +503,6 @@ public class BarebonesActivity extends Activity { if (view.isShown()) { refresh.setVisibility(View.INVISIBLE); progressBar.setVisibility(View.VISIBLE); - setUrlText(url); } @@ -1031,7 +1039,7 @@ public class BarebonesActivity extends Activity { public static Drawable active; public static LinearLayout tabLayout; - + public static String[] GetArray(String input) { return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|"); } @@ -1055,7 +1063,6 @@ public class BarebonesActivity extends Activity { CustomWebView browserSettings(CustomWebView view) { view.setAnimationCacheEnabled(false); view.setDrawingCacheEnabled(true); - view.setBackgroundColor(getResources().getColor(android.R.color.white)); view.setDrawingCacheBackgroundColor(getResources().getColor( android.R.color.white)); @@ -1079,7 +1086,7 @@ public class BarebonesActivity extends Activity { // or // disable } - + webViewSettings.setAllowFileAccess(true); if (API < 14) { switch (settings.getInt("textsize", 3)) { @@ -1166,9 +1173,8 @@ public class BarebonesActivity extends Activity { .getAbsolutePath() + "/databases"); webViewSettings.setUserAgentString(userAgent); - - webViewSettings.setBuiltInZoomControls(true); webViewSettings.setSupportZoom(true); + webViewSettings.setBuiltInZoomControls(true); webViewSettings.setUseWideViewPort(settings.getBoolean("wideviewport", true)); webViewSettings.setLoadWithOverviewMode(settings.getBoolean( @@ -1596,6 +1602,7 @@ public class BarebonesActivity extends Activity { cookieManager.setAcceptCookie(settings.getBoolean("cookies", true)); progressBar = (ProgressBar) findViewById(R.id.progressBar1); + if (API >= 11) { progressBar.setIndeterminateDrawable(getResources().getDrawable( R.drawable.ics_animation)); @@ -2214,6 +2221,11 @@ public class BarebonesActivity extends Activity { public boolean onKeyLongPress(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { + if(!settings.getBoolean("restoreclosed", true)){ + for(int n = 0; n webview = Class.forName("android.webkit.WebView"); Method method = webview.getMethod("getZoomButtonsController"); - zoomControl = (ZoomButtonsController) method.invoke(this, (Object) null); + + zoomControl = (ZoomButtonsController) method.invoke(this, (Object[])null); if (zoomControl != null) { zoomShouldDie = true; } @@ -88,5 +89,5 @@ public final class CustomWebView extends WebView { } } } - +*/ } diff --git a/src/acr/browser/barebones/customwebview/IncognitoWebView.java b/src/acr/browser/barebones/customwebview/IncognitoWebView.java index e56b2f2..7d92c37 100644 --- a/src/acr/browser/barebones/customwebview/IncognitoWebView.java +++ b/src/acr/browser/barebones/customwebview/IncognitoWebView.java @@ -3,7 +3,7 @@ package acr.browser.barebones.customwebview; import java.lang.reflect.Method; import acr.browser.barebones.activities.IncognitoModeActivity; -import acr.browser.barebones.variables.FinalVariables; +import acr.browser.barebones.utilities.FinalVariables; import android.content.Context; import android.view.MotionEvent; import android.view.View; diff --git a/src/acr/browser/barebones/utilities/BookmarkPageVariables.java b/src/acr/browser/barebones/utilities/BookmarkPageVariables.java new file mode 100644 index 0000000..a029fe9 --- /dev/null +++ b/src/acr/browser/barebones/utilities/BookmarkPageVariables.java @@ -0,0 +1,24 @@ +package acr.browser.barebones.utilities; + +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/utilities/FinalVariables.java b/src/acr/browser/barebones/utilities/FinalVariables.java new file mode 100644 index 0000000..cd34a25 --- /dev/null +++ b/src/acr/browser/barebones/utilities/FinalVariables.java @@ -0,0 +1,26 @@ +package acr.browser.barebones.utilities; + +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/utilities/HistoryPageVariables.java b/src/acr/browser/barebones/utilities/HistoryPageVariables.java new file mode 100644 index 0000000..52e9aeb --- /dev/null +++ b/src/acr/browser/barebones/utilities/HistoryPageVariables.java @@ -0,0 +1,19 @@ +package acr.browser.barebones.utilities; + +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/utilities/Utils.java b/src/acr/browser/barebones/utilities/Utils.java new file mode 100644 index 0000000..6be37e8 --- /dev/null +++ b/src/acr/browser/barebones/utilities/Utils.java @@ -0,0 +1,180 @@ +package acr.browser.barebones.utilities; + +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 DatabaseHandler historyHandler; + public static SQLiteDatabase history; + + public static void createInformativeDialog(Context context, String title, + String message) { + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setTitle(title); + builder.setMessage(message) + .setCancelable(true) + .setPositiveButton("Ok", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); + 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); + historyHandler = new DatabaseHandler( + context); + 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) { + + } + } + +}