diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 161dc40..75951c4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="43" + android:versionName="2.5.0.0" > + + + + + + + + + + + + \ No newline at end of file diff --git a/res/anim/up.xml b/res/anim/up.xml new file mode 100644 index 0000000..4f8e748 --- /dev/null +++ b/res/anim/up.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png index 3b9f85e..4f30b97 100644 Binary files a/res/drawable-hdpi/ic_launcher.png and b/res/drawable-hdpi/ic_launcher.png differ diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png index b68acba..dcbf910 100644 Binary files a/res/drawable-mdpi/ic_launcher.png and b/res/drawable-mdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png index af26936..487c59b 100644 Binary files a/res/drawable-xhdpi/ic_launcher.png and b/res/drawable-xhdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/incognito.png b/res/drawable-xhdpi/incognito.png new file mode 100644 index 0000000..0d1b4b7 Binary files /dev/null and b/res/drawable-xhdpi/incognito.png differ diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml index 4c1141e..4aecd7f 100644 --- a/res/layout/activity_main.xml +++ b/res/layout/activity_main.xml @@ -33,7 +33,8 @@ + android:layout_height="match_parent" + android:orientation="horizontal"> @@ -103,7 +104,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" - android:layout_toRightOf="@+id/forward" android:paddingBottom="10dp" android:paddingLeft="10dp" android:paddingRight="10dp" diff --git a/res/layout/settings.xml b/res/layout/settings.xml index f7343af..f8bc446 100644 --- a/res/layout/settings.xml +++ b/res/layout/settings.xml @@ -27,7 +27,7 @@ android:layout_height="wrap_content"> - + diff --git a/res/menu-es/menu.xml b/res/menu-es/menu.xml index d872064..382547e 100644 --- a/res/menu-es/menu.xml +++ b/res/menu-es/menu.xml @@ -1,7 +1,7 @@ - + diff --git a/res/menu-fr/menu.xml b/res/menu-fr/menu.xml index 427d597..bc76997 100644 --- a/res/menu-fr/menu.xml +++ b/res/menu-fr/menu.xml @@ -1,6 +1,6 @@ - + diff --git a/res/menu-it/menu.xml b/res/menu-it/menu.xml index 5b5df5a..598c1d7 100644 --- a/res/menu-it/menu.xml +++ b/res/menu-it/menu.xml @@ -1,6 +1,6 @@ - + diff --git a/res/menu-zh-rCN/menu.xml b/res/menu-zh-rCN/menu.xml index 50c8aa1..0b585ed 100644 --- a/res/menu-zh-rCN/menu.xml +++ b/res/menu-zh-rCN/menu.xml @@ -1,6 +1,6 @@ - + diff --git a/res/menu-zh-rTW/menu.xml b/res/menu-zh-rTW/menu.xml index b3a6137..af22832 100644 --- a/res/menu-zh-rTW/menu.xml +++ b/res/menu-zh-rTW/menu.xml @@ -1,7 +1,7 @@ - + diff --git a/res/menu/incognito_menu.xml b/res/menu/incognito_menu.xml new file mode 100644 index 0000000..25f63c9 --- /dev/null +++ b/res/menu/incognito_menu.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/res/menu/menu.xml b/res/menu/menu.xml index bd946f1..56f6c43 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/values-fr/strings.xml b/res/values-fr/strings.xml index 7c006dc..a8e427f 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -15,4 +15,4 @@ Les paramètres ne s\'appliqueront qu\'aux nouveaux onglets Activer le mode plein écran Activer JavaScript - + \ No newline at end of file diff --git a/src/acr/browser/barebones/Barebones.java b/src/acr/browser/barebones/Barebones.java index ce05767..c992c6d 100644 --- a/src/acr/browser/barebones/Barebones.java +++ b/src/acr/browser/barebones/Barebones.java @@ -39,9 +39,6 @@ import android.os.Environment; import android.os.Handler; import android.os.Message; import android.provider.Browser; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.view.Gravity; @@ -56,16 +53,15 @@ import android.view.View.OnClickListener; import android.view.View.OnKeyListener; import android.view.View.OnLongClickListener; import android.view.View.OnTouchListener; -import android.view.ViewGroup; import android.view.WindowManager; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; +import android.webkit.CookieManager; import android.webkit.DownloadListener; import android.webkit.GeolocationPermissions; -import android.webkit.HttpAuthHandler; import android.webkit.SslErrorHandler; import android.webkit.URLUtil; import android.webkit.ValueCallback; @@ -80,6 +76,7 @@ import android.webkit.WebStorage.QuotaUpdater; import android.webkit.WebView; import android.webkit.WebView.HitTestResult; import android.webkit.WebViewClient; +import android.webkit.WebViewDatabase; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.FrameLayout; @@ -87,12 +84,10 @@ import android.widget.HorizontalScrollView; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.MultiAutoCompleteTextView; -import android.widget.MultiAutoCompleteTextView.Tokenizer; import android.widget.PopupMenu; import android.widget.PopupMenu.OnMenuItemClickListener; import android.widget.ProgressBar; import android.widget.RelativeLayout; -import android.widget.ScrollView; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; @@ -101,24 +96,44 @@ import android.widget.Toast; public class Barebones extends Activity { @SuppressLint("SetJavaScriptEnabled") - public class AnthonyChromeClient extends WebChromeClient { + public class CustomChromeClient extends WebChromeClient { private Bitmap mDefaultVideoPoster; private View mVideoProgressView; + @Override + public void onExceededDatabaseQuota(String url, + String databaseIdentifier, long quota, + long estimatedDatabaseSize, long totalQuota, + QuotaUpdater quotaUpdater) { + quotaUpdater.updateQuota(totalQuota + estimatedDatabaseSize); + super.onExceededDatabaseQuota(url, databaseIdentifier, quota, + estimatedDatabaseSize, totalQuota, quotaUpdater); + } + + @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) { + browserHandler.sendEmptyMessage(2); + super.onCloseWindow(window); + } + @Override public Bitmap getDefaultVideoPoster() { - // Log.i(LOGTAG, "here in on getDefaultVideoPoster"); if (mDefaultVideoPoster == null) { mDefaultVideoPoster = BitmapFactory.decodeResource( getResources(), android.R.color.black); } return mDefaultVideoPoster; - } + } @Override public View getVideoLoadingProgressView() { - // Log.i(LOGTAG, "here in on getVideoLoadingPregressView"); - if (mVideoProgressView == null) { LayoutInflater inflater = LayoutInflater.from(getBaseContext()); mVideoProgressView = inflater.inflate( @@ -127,26 +142,30 @@ public class Barebones extends Activity { return mVideoProgressView; } - @Override - public void onCloseWindow(WebView window) { - super.onCloseWindow(window); - } - @Override public boolean onCreateWindow(WebView view, boolean isDialog, - boolean isUserGesture, Message resultMsg) { - return true; + boolean isUserGesture, final Message resultMsg) { + + newTab(number,"",true,false); + WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj; + transport.setWebView(main[pageId]); + resultMsg.sendToTarget(); + browserHandler.postDelayed(new Runnable() { + public void run() { + main[pageId].loadUrl(getUrl.getText().toString()); + } + }, 500); + return true; } @Override public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) { - if (allowLocation == true) { - callback.invoke(origin, true, false); - } else if (allowLocation == false) { + if (!allowLocation) { callback.invoke(origin, false, false); - } else { + } + if (allowLocation) { Log.i("Barebones: ", "onGeolocationPermissionsShowPrompt()"); @@ -161,7 +180,6 @@ public class Barebones extends Activity { @Override public void onClick(DialogInterface dialog, int id) { - // origin, allow, remember callback.invoke(origin, true, remember); } }) @@ -170,12 +188,11 @@ public class Barebones extends Activity { @Override public void onClick(DialogInterface dialog, int id) { - // origin, allow, remember callback.invoke(origin, false, remember); } }); AlertDialog alert = builder.create(); - // alert.show(); + alert.show(); } } @@ -192,6 +209,7 @@ public class Barebones extends Activity { background.removeView(mCustomView); mCustomView = null; background.setVisibility(View.VISIBLE); + uBar.setVisibility(View.VISIBLE); mCustomViewCallback.onCustomViewHidden(); main[pageId].setVisibility(View.VISIBLE); @@ -199,29 +217,11 @@ public class Barebones extends Activity { // Log.i(LOGTAG, "set it to webVew"); } - @Override - public void onProgressChanged(WebView view, int newProgress) { - /* - * int num = view.getId(); if (num == pageId) { if (newProgress == - * 100) { progressBar.setVisibility(View.GONE); - * refresh.setVisibility(View.VISIBLE); - * main[num].getSettings().setCacheMode( WebSettings.LOAD_DEFAULT); - * - * } else { refresh.setVisibility(View.INVISIBLE); - * progressBar.setVisibility(View.VISIBLE); } } - */ - super.onProgressChanged(view, newProgress); - } - - @Override - public void onReachedMaxAppCacheSize(long requiredStorage, long quota, - QuotaUpdater quotaUpdater) { - super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater); - } - @Override public void onReceivedIcon(WebView view, Bitmap favicon) { - setFavicon(view.getId(), favicon); + if (!incognito[view.getId()]) { + setFavicon(view.getId(), favicon); + } super.onReceivedIcon(view, favicon); } @@ -230,7 +230,7 @@ public class Barebones extends Activity { numberPage = view.getId(); urlTitle[numberPage].setText(title); urlToLoad[numberPage][1] = title; - if (title != null) { + if (title != null && !incognito[numberPage]) { updateHistory(urlToLoad[numberPage][0], title); } super.onReceivedTitle(view, title); @@ -241,7 +241,7 @@ public class Barebones extends Activity { CustomViewCallback callback) { // Log.i(LOGTAG, "here in on ShowCustomView"); main[pageId].setVisibility(View.GONE); - + uBar.setVisibility(View.GONE); // if a view already exists then immediately terminate the new one if (mCustomView != null) { callback.onCustomViewHidden(); @@ -259,12 +259,12 @@ public class Barebones extends Activity { WebChromeClient.CustomViewCallback callback) { // Log.i(LOGTAG, "here in on ShowCustomView"); main[pageId].setVisibility(View.GONE); + uBar.setVisibility(View.GONE); // if a view already exists then immediately terminate the new one if (mCustomView != null) { callback.onCustomViewHidden(); return; } - background.addView(view); mCustomView = view; mCustomViewCallback = callback; @@ -279,7 +279,7 @@ public class Barebones extends Activity { i.setType("image/*"); Barebones.this.startActivityForResult( Intent.createChooser(i, "Image Browser"), - FILECHOOSER_RESULTCODE); + 1); } public void openFileChooser(ValueCallback uploadMsg, @@ -290,7 +290,7 @@ public class Barebones extends Activity { i.setType("image/*"); Barebones.this.startActivityForResult( Intent.createChooser(i, "Image Browser"), - FILECHOOSER_RESULTCODE); + 1); } public void openFileChooser(ValueCallback uploadMsg, @@ -301,11 +301,11 @@ public class Barebones extends Activity { i.setType("image/*"); Barebones.this.startActivityForResult( Intent.createChooser(i, "Image Browser"), - FILECHOOSER_RESULTCODE); + 1); } } - public class AnthonyDownload implements DownloadListener { + private class CustomDownloadListener implements DownloadListener { @Override public void onDownloadStart(final String url, String userAgent, @@ -342,7 +342,7 @@ public class Barebones extends Activity { Log.e("Barebones", "Problem downloading"); Toast.makeText(CONTEXT, "Error Downloading File", Toast.LENGTH_SHORT).show(); - } catch (SecurityException e) { + } catch (SecurityException ignored) { } } @@ -351,66 +351,96 @@ public class Barebones extends Activity { } - public class AnthonyWebViewClient extends WebViewClient { + private class CustomWebViewClient extends WebViewClient { @Override - public void doUpdateVisitedHistory(WebView view, final String url, - final boolean isReload) { + public boolean shouldOverrideUrlLoading(WebView view, String url) { + if (url.contains("market://") + || url.contains("play.google.com")) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } else if (url.contains("youtube.com")) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } else if (url.contains("maps.google.com")) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } + return false; } @Override public void onPageFinished(WebView view, final String url) { - progressBar.setVisibility(View.INVISIBLE); - refresh.setVisibility(View.VISIBLE); + 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_DEFAULT); + pageIsLoading = false; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { - refresh.setVisibility(View.INVISIBLE); - progressBar.setVisibility(View.VISIBLE); - pageIsLoading = true; + numberPage = view.getId(); if (view.isShown()) { - getUrl.setText(url); - + refresh.setVisibility(View.INVISIBLE); + progressBar.setVisibility(View.VISIBLE); + setUrlText(url); + pageIsLoading = true; } - urlTitle[numberPage].setCompoundDrawables(webpageOther, null, - exitTab, null); - if (favicon != null) { - setFavicon(view.getId(), favicon); + if (incognito[numberPage]) { + urlTitle[numberPage].setCompoundDrawables(incognitoPage, null, + exitTab, null); + } else { + urlTitle[numberPage].setCompoundDrawables(webpageOther, null, + exitTab, null); + if (favicon != null) { + setFavicon(view.getId(), favicon); + } } getUrl.setPadding(tenPad, 0, tenPad, 0); urlToLoad[numberPage][0] = url; - if (uBarShows == false) { + if (!uBar.isShown()&&showFullScreen) { uBar.startAnimation(slideDown); - uBarShows = true; } } @Override - public void onReceivedHttpAuthRequest(WebView view, - HttpAuthHandler handler, String host, String realm) { - // handler.proceed(username, password); - super.onReceivedHttpAuthRequest(view, handler, host, realm); - } - - @Override - public void onReceivedLoginRequest(WebView view, String realm, - String account, String args) { - - super.onReceivedLoginRequest(view, realm, account, args); - } - - @Override - public void onReceivedSslError(WebView view, SslErrorHandler handler, + public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { - - handler.proceed(); + AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); + builder.setTitle("Warning"); + builder.setMessage( + "The certificate of the site is not trusted. Proceed anyway?") + .setCancelable(true) + .setPositiveButton("Yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int id) { + handler.proceed(); + } + }) + .setNegativeButton("No", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int id) { + handler.cancel(); + } + }); + AlertDialog alert = builder.create(); + alert.show(); super.onReceivedSslError(view, handler, error); } @@ -418,384 +448,314 @@ public class Barebones extends Activity { public void onScaleChanged(WebView view, float oldScale, float newScale) { view.getSettings().setLayoutAlgorithm( - LayoutAlgorithm.NARROW_COLUMNS); + LayoutAlgorithm.NORMAL); super.onScaleChanged(view, oldScale, newScale); } - } - - static public class BookmarkListener implements OnClickListener { @Override - public void onClick(View arg0) { - int number = arg0.getId(); - background.addView(main[pageId]); - pageIdIsVisible = true; - main[pageId].startAnimation(fadeIn); - if (showFullScreen) { - background.addView(uBar); - uBar.startAnimation(fadeIn); - } - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - isBookmarkShowing = false; - - uBar.bringToFront(); - main[pageId].loadUrl(bUrl[number]); + public void onFormResubmission(WebView view, final Message dontResend, + final Message resend) { + AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); + builder.setTitle("Resend Data"); + builder.setMessage( + "Would you like to resend data?") + .setCancelable(true) + .setPositiveButton("Yes", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int id) { + + resend.sendToTarget(); + } + }) + .setNegativeButton("No", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int id) { + + dontResend.sendToTarget(); + } + }); + AlertDialog alert = builder.create(); + alert.show(); + super.onFormResubmission(view, dontResend, resend); } - } - public class BookmarkLongClick implements OnLongClickListener { + private void generateHistory(final CustomWebView view) { - @Override - public boolean onLongClick(final View arg0) { - DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - switch (which) { - case DialogInterface.BUTTON_POSITIVE: { - int delete = arg0.getId(); - File book = new File(getBaseContext().getFilesDir(), - "bookmarks"); - File bookUrl = new File(getBaseContext().getFilesDir(), - "bookurl"); - int n = 0; - try { - BufferedWriter bookWriter = new BufferedWriter( - new FileWriter(book)); - BufferedWriter urlWriter = new BufferedWriter( - new FileWriter(bookUrl)); - while (bUrl[n] != null && n < (MAX_BOOKMARKS - 1)) { - if (delete != n) { - bookWriter.write(bTitle[n]); - urlWriter.write(bUrl[n]); - bookWriter.newLine(); - urlWriter.newLine(); - } - n++; - } - bookWriter.close(); - urlWriter.close(); - } catch (FileNotFoundException e) { - } catch (IOException e) { - } - for (int p = 0; p < MAX_BOOKMARKS; p++) { - bUrl[p] = null; - bTitle[p] = null; - } - try { - BufferedReader readBook = new BufferedReader( - new FileReader(book)); - BufferedReader readUrl = new BufferedReader( - new FileReader(bookUrl)); - String t, u; - int z = 0; - while ((t = readBook.readLine()) != null - && (u = readUrl.readLine()) != null - && z < MAX_BOOKMARKS) { - bUrl[z] = u; - bTitle[z] = t; - z++; - } - readBook.close(); - readUrl.close(); - } catch (FileNotFoundException e) { - } catch (IOException e) { - } - // scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - isBookmarkShowing = false; - openBookmarks(); + Thread history = new Thread(new Runnable() { - break; - } - case DialogInterface.BUTTON_NEGATIVE: { + @Override + public void run() { + String historyHtml = HistoryPage.Heading; + Cursor historyCursor = null; + String[][] h = new String[50][3]; - break; - } - default: + try { + SQLiteDatabase s = historyHandler.getReadableDatabase(); + historyCursor = s.query("history", // URI + // of + columns, // Which columns to return + null, // Which rows to return (all rows) + null, // Selection arguments (none) + null, null, null); - break; - } + handler.sendEmptyMessage(1); + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { } - }; - - AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); // dialog - builder.setMessage("Do you want to delete this bookmark?") - .setPositiveButton("Yes", dialogClickListener) - .setNegativeButton("No", dialogClickListener).show(); - return allowLocation; - - } - - } - - public class SpaceTokenizer implements Tokenizer { - @Override - public int findTokenEnd(CharSequence text, int cursor) { - int i = cursor; - int len = text.length(); + list = new ArrayList>(); + try { + if (historyCursor != null) { + if (historyCursor.moveToLast()) { + // Variable for holding the retrieved URL + urlColumn = historyCursor.getColumnIndex("url"); + titleColumn = historyCursor.getColumnIndex("title"); + // Reference to the the column containing the URL + int n = 0; + do { - while (i < len) { - if (text.charAt(i) == ' ') { - return i; - } else { - i++; + h[n][0] = historyCursor.getString(urlColumn); + h[n][2] = h[n][0].substring(0, + Math.min(100, h[n][0].length())) + + "..."; + h[n][1] = historyCursor.getString(titleColumn); + historyHtml += (HistoryPage.Part1 + h[n][0] + + HistoryPage.Part2 + h[n][1] + + HistoryPage.Part3 + h[n][2] + HistoryPage.Part4); + n++; + } while (n < 49 && historyCursor.moveToPrevious()); + } + } + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { } - } - return len; - } - - @Override - public int findTokenStart(CharSequence text, int cursor) { - int i = cursor; - - while (i > 0 && text.charAt(i - 1) != ' ') { - i--; - } - while (i < cursor && text.charAt(i) == ' ') { - i++; - } - - return i; - } - - @Override - public CharSequence terminateToken(CharSequence text) { - int i = text.length(); - - while (i > 0 && text.charAt(i - 1) == ' ') { - i--; - } - - if (i > 0 && text.charAt(i - 1) == ' ') { - return text; - } else { - if (text instanceof Spanned) { - SpannableString sp = new SpannableString(text + " "); - TextUtils.copySpansFrom((Spanned) text, 0, text.length(), - Object.class, sp, 0); - return sp; - } else { - return text + " "; + historyHtml += BookmarkPage.End; + File historyWebPage = new File(getBaseContext().getFilesDir(), + "history.html"); + try { + FileWriter hWriter = new FileWriter(historyWebPage, false); + hWriter.write(historyHtml); + hWriter.close(); + } catch (IOException e) { + e.printStackTrace(); } - } - } - } - - public class TabClick implements OnClickListener { - - @SuppressWarnings("deprecation") - @Override - public void onClick(View v) { - id = v.getId(); - if (API < 16) { - urlTitle[pageId].setBackgroundDrawable(inactive); - } else if (API > 15) { - urlTitle[pageId].setBackground(inactive); - } - urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); - - if (isBookmarkShowing) { - - background.addView(main[id]); - main[id].startAnimation(fadeIn); - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - isBookmarkShowing = false; - uBar.bringToFront(); - } else if (!isBookmarkShowing) { - if (!showFullScreen) { - background.addView(main[id]); - main[id].startAnimation(fadeIn); - main[pageId].startAnimation(fadeOut); - pageIdIsVisible = false; - background.removeView(main[pageId]); - uBar.bringToFront(); - } else if (API >= 12) { - pageIdIsVisible = false; - main[id].setAlpha(0f); - main[id].clearAnimation(); - background.addView(main[id]); - main[id].animate().alpha(1f) - .setDuration(mShortAnimationDuration); - main[id].clearAnimation(); - background.removeView(main[pageId]); - uBar.bringToFront(); - } else { - pageIdIsVisible = false; - background.removeView(main[pageId]); - background.addView(main[id]); + if (uBar.isShown()) { + urlTitle[pageId].setText("History"); + setUrlText(""); + getUrl.setPadding(tenPad, 0, tenPad, 0); } - uBar.bringToFront(); - } - pageId = id; - pageIdIsVisible = true; - getUrl.setText(urlToLoad[pageId][0]); - getUrl.setPadding(tenPad, 0, tenPad, 0); - if (API < 16) { - urlTitle[pageId].setBackgroundDrawable(active); - } else if (API > 15) { - urlTitle[pageId].setBackground(active); + + view.loadUrl("file:///" + historyWebPage); } - urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); - } + }); + history.run(); } - public class TabLongClick implements OnLongClickListener { - - @Override - public boolean onLongClick(View v) { - int id = v.getId(); - if (pageId == id && isBookmarkShowing) { - - background.addView(main[pageId]); - // main[pageId].startAnimation(fadeIn); - if (showFullScreen) { - background.addView(uBar); - // uBar.startAnimation(fadeIn); - } - // scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - uBar.bringToFront(); - isBookmarkShowing = false; - } - pageIdIsVisible = true; - deleteTab(id); - - return true; + private void setUrlText(String url) { + if (!url.contains("file:///" + getBaseContext().getFilesDir() + + "/bookmarks.html") + && !url.contains("file:///" + getBaseContext().getFilesDir() + + "/history.html")) { + getUrl.setText(url); + } else { + getUrl.setText(""); } - } - public class TabTouch implements OnTouchListener { + private class TabTouchListener implements OnTouchListener { @SuppressWarnings("deprecation") @Override public boolean onTouch(View v, MotionEvent event) { - pageIdIsVisible = false; id = v.getId(); - main[id].clearAnimation(); - main[pageId].clearAnimation(); - xPress = false; - x = (int) event.getX(); - y = (int) event.getY(); - edge = new Rect(); + background.clearDisappearingChildren(); + boolean xPress = false; + int x = (int) event.getX(); + int y = (int) event.getY(); + Rect edge = new Rect(); v.getLocalVisibleRect(edge); - if (x >= (edge.right - bounds.width() - v.getPaddingRight() - fuzz*3/2) - && x <= (edge.right - v.getPaddingRight() + fuzz*3/2) - && y >= (v.getPaddingTop() - fuzz/2) - && y <= (v.getHeight() - v.getPaddingBottom() + fuzz/2)) { - xPress = true; - } - urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); if (event.getAction() == MotionEvent.ACTION_UP) { + if (x >= (edge.right - bounds.width() - v.getPaddingRight() - fuzz * 3 / 2) + && x <= (edge.right - v.getPaddingRight() + fuzz * 3 / 2) + && y >= (v.getPaddingTop() - fuzz / 2) + && y <= (v.getHeight() - v.getPaddingBottom() + fuzz / 2)) { + xPress = true; + } if (id == pageId) { if (xPress) { - if (isBookmarkShowing) { - background.removeView(scrollBookmarks); - isBookmarkShowing = false; - - } else if (!isBookmarkShowing) { - - } deleteTab(id); uBar.bringToFront(); - } else if (!xPress) { - } } else if (id != pageId) { if (xPress) { deleteTab(id); - } else if (!xPress) { + } else { if (API < 16) { urlTitle[pageId].setBackgroundDrawable(inactive); } else if (API > 15) { urlTitle[pageId].setBackground(inactive); } urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); - - if (isBookmarkShowing) { - + if (!showFullScreen) { background.addView(main[id]); main[id].startAnimation(fadeIn); - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - isBookmarkShowing = false; + main[pageId].startAnimation(fadeOut); + background.removeView(main[pageId]); uBar.bringToFront(); - } else if (!isBookmarkShowing) { - if (!showFullScreen) { - background.addView(main[id]); - main[id].startAnimation(fadeIn); - main[pageId].startAnimation(fadeOut); - pageIdIsVisible = false; - background.removeView(main[pageId]); - uBar.bringToFront(); - } else if (API >= 12) { - pageIdIsVisible = false; - main[id].setAlpha(0f); - main[id].clearAnimation(); - background.addView(main[id]); + } else if (API >= 12) { + main[id].setAlpha(0f); + background.addView(main[id]); + try { main[id].animate().alpha(1f) .setDuration(mShortAnimationDuration); - main[pageId].clearAnimation(); - background.removeView(main[pageId]); - - uBar.bringToFront(); - } else { - pageIdIsVisible = false; - background.removeView(main[pageId]); - background.addView(main[id]); + } catch (NullPointerException ignored) { } + background.removeView(main[pageId]); uBar.bringToFront(); + } else { + background.removeView(main[pageId]); + background.addView(main[id]); } + uBar.bringToFront(); + pageId = id; - pageIdIsVisible = true; - getUrl.setText(urlToLoad[pageId][0]); + setUrlText(urlToLoad[pageId][0]); getUrl.setPadding(tenPad, 0, tenPad, 0); + if (API < 16) { + urlTitle[pageId].setBackgroundDrawable(active); + } else if (API > 15) { + urlTitle[pageId].setBackground(active); + } + if (main[pageId].getProgress() < 100) { + refresh.setVisibility(View.INVISIBLE); + progressBar.setVisibility(View.VISIBLE); + } else { + progressBar.setVisibility(View.GONE); + refresh.setVisibility(View.VISIBLE); + } + tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0); + main[pageId].invalidate(); } } - if (API < 16) { - urlTitle[pageId].setBackgroundDrawable(active); - } else if (API > 15) { - urlTitle[pageId].setBackground(active); - } } uBar.bringToFront(); urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); - - pageIdIsVisible = true; return true; } } - public class WebPageLongClick implements OnLongClickListener { + private void deleteBookmark(String url) { + File book = new File(getBaseContext().getFilesDir(), "bookmarks"); + File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); + int n = 0; + try { + BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book)); + BufferedWriter urlWriter = new BufferedWriter(new FileWriter( + bookUrl)); + while (bUrl[n] != null && n < (MAX_BOOKMARKS - 1)) { + if (!bUrl[n].equalsIgnoreCase(url)) { + bookWriter.write(bTitle[n]); + urlWriter.write(bUrl[n]); + bookWriter.newLine(); + urlWriter.newLine(); + } + n++; + } + bookWriter.close(); + urlWriter.close(); + } catch (FileNotFoundException e) { + } catch (IOException e) { + } + for (int p = 0; p < MAX_BOOKMARKS; p++) { + bUrl[p] = null; + bTitle[p] = null; + } + try { + BufferedReader readBook = new BufferedReader(new FileReader(book)); + BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl)); + String t, u; + int z = 0; + while ((t = readBook.readLine()) != null + && (u = readUrl.readLine()) != null && z < MAX_BOOKMARKS) { + bUrl[z] = u; + bTitle[z] = t; + z++; + } + readBook.close(); + readUrl.close(); + } catch (IOException ignored) { + } + openBookmarks(main[pageId]); + } + + private class WebPageLongClickListener implements OnLongClickListener { @Override public boolean onLongClick(View v) { final HitTestResult result = main[pageId].getHitTestResult(); - boolean image = false; - if (result.getType() == HitTestResult.IMAGE_TYPE && API > 8) { - image = true; - } + if (main[pageId].getUrl().contains( + "file:///" + getBaseContext().getFilesDir() + + "/bookmarks.html")) { + if (result.getExtra() != null) { + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case DialogInterface.BUTTON_POSITIVE: { + int num = pageId; + newTab(number, result.getExtra(), false, false); + // urlTitle[num].performClick(); + pageId = num; + break; + } + case DialogInterface.BUTTON_NEGATIVE: { + main[pageId].loadUrl(result.getExtra()); + break; + } + case DialogInterface.BUTTON_NEUTRAL: { - if (result.getExtra() != null) { - if (image) { + deleteBookmark(result.getExtra()); + break; + } + } + } + }; + + AlertDialog.Builder builder = new AlertDialog.Builder( + CONTEXT); // dialog + builder.setMessage( + "What would you like to do with this link?") + .setPositiveButton("Open in New Tab", + dialogClickListener) + .setNegativeButton("Open Normally", + dialogClickListener) + .setNeutralButton("Delete", dialogClickListener) + .show(); + } + return true; + } else if (result.getExtra() != null) { + if (result.getType() == 5 && API > 8) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: { int num = pageId; - newTab(number, result.getExtra(), false); + newTab(number, result.getExtra(), false, false); // urlTitle[num].performClick(); pageId = num; break; @@ -849,7 +809,7 @@ public class Barebones extends Activity { Toast.makeText(CONTEXT, "Error Downloading File", Toast.LENGTH_SHORT).show(); - } catch (SecurityException e) { + } catch (SecurityException ignored) { } } @@ -878,7 +838,7 @@ public class Barebones extends Activity { switch (which) { case DialogInterface.BUTTON_POSITIVE: { int num = pageId; - newTab(number, result.getExtra(), false); + newTab(number, result.getExtra(), false, false); // urlTitle[num].performClick(); pageId = num; break; @@ -924,105 +884,110 @@ public class Barebones extends Activity { } // variables to differentiate free from paid - static final int MAX_TABS = FinalVars.MAX_TABS; - static final int MAX_BOOKMARKS = FinalVars.MAX_BOOKMARKS; - static final boolean PAID_VERSION = FinalVars.PAID_VERSION; - public final Context CONTEXT = Barebones.this; - public static final String HOMEPAGE = FinalVars.HOMEPAGE; - public static final String SEARCH = FinalVars.GOOGLE_SEARCH; - // variable declaration - static Rect edge; - static SimpleAdapter adapter; - static MultiAutoCompleteTextView getUrl; - static final TextView[] urlTitle = new TextView[MAX_TABS]; - static final AnthonyWebView[] main = new AnthonyWebView[MAX_TABS]; - static Rect bounds; - static private ValueCallback mUploadMessage; - static ImageView refresh; - static ProgressBar progressBar; - static Drawable icon; - static Drawable webpage, webpageOther; - static Drawable exitTab; - static final int FILECHOOSER_RESULTCODE = 1; - static int numberPage, x, y; - static final int fuzz = 10; - static int number, pageId = 0, agentPicker; - static int enableFlash, lastVisibleWebView; - static int height56, height32; - static int height, width, pixels, leftPad, rightPad, pixelHeight; - static int bookHeight; - static final int API = FinalVars.API; - static int mShortAnimationDuration; - static int id, tenPad; - static int hitTest; - static int urlColumn, titleColumn; - static View mCustomView = null; - static CustomViewCallback mCustomViewCallback; - static boolean xPress; - static boolean tabsAreDisplayed = true, isPhone = false; - static boolean pageIsLoading = false, java; - static boolean allowLocation, savePasswords, deleteHistory, saveTabs; - static boolean showFullScreen, pageIdIsVisible = true; - static boolean urlBarShows = true; - static boolean isBookmarkShowing = false; - static boolean uBarShows = true; - static boolean noStockBrowser = true; - static SharedPreferences settings; - static SharedPreferences.Editor edit; - static String desktop, mobile, user; - static String urlA, title; - static String[] memoryURL = new String[MAX_TABS]; - static final String[] bUrl = new String[MAX_BOOKMARKS]; - static final String[] bTitle = new String[MAX_BOOKMARKS]; - static String[] columns; - static String homepage, str; - static final String preferences = "settings"; - static String query, userAgent; - static final String[][] urlToLoad = new String[MAX_TABS][2]; - static FrameLayout background; - static ScrollView scrollBookmarks; - static RelativeLayout uBar, bg; - static RelativeLayout refreshLayout; - static HorizontalScrollView tabScroll; + private static final int MAX_TABS = FinalVars.MAX_TABS; + private static final int MAX_BOOKMARKS = FinalVars.MAX_BOOKMARKS; + private static final boolean PAID_VERSION = FinalVars.PAID_VERSION; + private final Context CONTEXT = Barebones.this; + private static final String HOMEPAGE = FinalVars.HOMEPAGE; + private static final String SEARCH = FinalVars.GOOGLE_SEARCH; + private static SimpleAdapter adapter; + private static MultiAutoCompleteTextView getUrl; + private static final TextView[] urlTitle = new TextView[MAX_TABS]; + private static final CustomWebView[] main = new CustomWebView[MAX_TABS]; + private static Rect bounds; + private static ValueCallback mUploadMessage; + private static ImageView refresh; + private static ProgressBar progressBar; + private static Drawable webpageOther; + private static Drawable incognitoPage; + private static Drawable exitTab; + private static int numberPage; + private static final int fuzz = 10; + private static int number; + private static int pageId = 0; + private static int agentPicker; + private static int enableFlash; + private static int height32; + private static int height; + private static int width; + private static int pixels; + private static int leftPad; + private static int rightPad; + private static final int API = FinalVars.API; + private static int mShortAnimationDuration; + private static int id; + private static int tenPad; + private static int urlColumn; + private static int titleColumn; + private static int closeWindow; + private static View mCustomView = null; + private static CustomViewCallback mCustomViewCallback; + private static final boolean[] incognito = new boolean[MAX_TABS]; + private static boolean isPhone = false; + private static boolean pageIsLoading = false; + private static boolean allowLocation; + private static boolean savePasswords; + private static boolean deleteHistory; + private static boolean saveTabs; + static boolean showFullScreen; + private static boolean noStockBrowser = true; + private static SharedPreferences settings; + private static SharedPreferences.Editor edit; + private static String desktop; + private static String mobile; + private static String user; + private static String urlA; + private static String title; + private static String[] memoryURL = new String[MAX_TABS]; + private static final String[] bUrl = new String[MAX_BOOKMARKS]; + private static final String[] bTitle = new String[MAX_BOOKMARKS]; + private static String[] columns; + private static String homepage; + private static String str; + private static final String preferences = "settings"; + private static String query; + private static String userAgent; + private static final String[][] urlToLoad = new String[MAX_TABS][2]; + private static FrameLayout background; + static RelativeLayout uBar; + private static HorizontalScrollView tabScroll; static Animation slideUp; static Animation slideDown; - static Animation fadeOut, fadeIn; - static long clock = 0; - static long timeBetweenDownPress = System.currentTimeMillis(); - static TextView txt; + private static Animation fadeOut; + private static Animation fadeIn; + private static TextView txt; - static Uri bookmarks; - static List> list; - static Map map; + private static CookieManager cookieManager; - static Handler handler; + private static Uri bookmarks; + private static List> list; + private static Map map; - static DatabaseHandler historyHandler; + private static Handler handler, browserHandler; - static StringBuilder sb; + private static DatabaseHandler historyHandler; - static Runnable update; + private static StringBuilder sb; - static SQLiteDatabase s; + private static Runnable update; - static float widthInInches, heightInInches; + private static SQLiteDatabase s; - static double sizeInInches; + private static Drawable inactive; - public static Drawable inactive; + private static Drawable active; - public static Drawable active; + private static LinearLayout tabLayout; - public static LinearLayout tabLayout; - - public static String[] GetArray(String input, String delimiter) { - return input.split(delimiter); + private static String[] GetArray(String input) { + return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|"); } - public static void setFavicon(int id, Bitmap favicon) { - icon = null; + @SuppressWarnings("unused") + private static void setFavicon(int id, Bitmap favicon) { + Drawable icon = null; icon = new BitmapDrawable(null, favicon); - icon.setBounds(0, 0, width * 1 / 2, height * 1 / 2); + icon.setBounds(0, 0, width / 2, height / 2); if (icon != null) { urlTitle[id].setCompoundDrawables(icon, null, exitTab, null); } else { @@ -1031,13 +996,25 @@ public class Barebones extends Activity { } } - public Barebones() { - super(); - } - - public void addBookmark() { + void addBookmark() { File book = new File(getBaseContext().getFilesDir(), "bookmarks"); File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); + try { + BufferedReader readUrlRead = new BufferedReader(new FileReader(bookUrl)); + String u; + int n = 0; + while ((u = readUrlRead.readLine()) != null && n < MAX_BOOKMARKS) { + if(u.contentEquals(urlToLoad[pageId][0])){ + + readUrlRead.close(); + return; + } + n++; + } + readUrlRead.close(); + } catch (FileNotFoundException ignored) { + } catch (IOException ignored) { + } try { BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book, true)); @@ -1049,20 +1026,20 @@ public class Barebones extends Activity { urlWriter.newLine(); bookWriter.close(); urlWriter.close(); - } catch (FileNotFoundException e) { - } catch (IOException e) { - } catch (NullPointerException e) { + } catch (FileNotFoundException ignored) { + } catch (IOException ignored) { + } catch (NullPointerException ignored) { } } @SuppressLint("SetJavaScriptEnabled") - public AnthonyWebView BrowserSettings(AnthonyWebView view) { + CustomWebView browserSettings(CustomWebView view) { view.setAnimationCacheEnabled(false); view.setDrawingCacheEnabled(false); view.setDrawingCacheBackgroundColor(getResources().getColor( android.R.color.background_light)); // view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); - // view.setAlwaysDrawnWithCacheEnabled(true); + view.setWillNotCacheDrawing(true); view.setFocusable(true); view.setFocusableInTouchMode(true); @@ -1070,14 +1047,15 @@ public class Barebones extends Activity { WebSettings webViewSettings = view.getSettings(); - java = settings.getBoolean("java", true); + boolean java = settings.getBoolean("java", true); if (java) { webViewSettings.setJavaScriptEnabled(true); - webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true); + webViewSettings.setJavaScriptCanOpenWindowsAutomatically(false); } + webViewSettings.setBlockNetworkImage(false); webViewSettings.setAllowFileAccess(true); webViewSettings.setLightTouchEnabled(true); - webViewSettings.setSupportMultipleWindows(false); + webViewSettings.setSupportMultipleWindows(true); webViewSettings.setDomStorageEnabled(true); webViewSettings.setAppCacheEnabled(true); webViewSettings.setAppCachePath(getApplicationContext().getFilesDir() @@ -1107,8 +1085,9 @@ public class Barebones extends Activity { webViewSettings.setUserAgentString(userAgent); savePasswords = settings.getBoolean("passwords", false); - if (savePasswords == true) { + if (savePasswords) { webViewSettings.setSavePassword(true); + webViewSettings.setSaveFormData(true); } webViewSettings.setBuiltInZoomControls(true); @@ -1121,17 +1100,16 @@ public class Barebones extends Activity { webViewSettings.setDisplayZoomControls(false); webViewSettings.setAllowContentAccess(true); } - webViewSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS); + webViewSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL); webViewSettings.setLoadsImagesAutomatically(true); - // webViewSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); return view; } - public boolean deleteDir(File dir) { + boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) { String[] children = dir.list(); - for (int i = 0; i < children.length; i++) { - boolean success = deleteDir(new File(dir, children[i])); + for (String aChildren : children) { + boolean success = deleteDir(new File(dir, aChildren)); if (!success) { return false; } @@ -1143,40 +1121,54 @@ public class Barebones extends Activity { } @SuppressWarnings("deprecation") - public void deleteTab(int id) { - int leftId = id; - pageIdIsVisible = false; - main[id].stopLoading(); - main[id].clearHistory(); - urlToLoad[id][0] = null; - urlToLoad[id][1] = null; + void deleteTab(final int del) { + main[del].stopLoading(); + main[del].clearHistory(); + main[del].clearView(); + urlToLoad[del][0] = null; + urlToLoad[del][1] = null; if (API >= 11) { - main[id].onPause(); + main[del].onPause(); } - main[id].clearView(); - boolean right = false, left = false; + // background.clearDisappearingChildren(); if (API < 16) { - urlTitle[id].setBackgroundDrawable(active); + urlTitle[del].setBackgroundDrawable(active); } else { - urlTitle[id].setBackground(active); + urlTitle[del].setBackground(active); } - urlTitle[id].setPadding(leftPad, 0, rightPad, 0); - urlTitle[id].setVisibility(View.GONE); - if (id == pageId) { + urlTitle[del].setPadding(leftPad, 0, rightPad, 0); + Animation yolo = AnimationUtils.loadAnimation(this, R.anim.down); - if (isBookmarkShowing) { - if (showFullScreen) { - background.addView(uBar); - // uBar.startAnimation(fadeIn); - uBar.bringToFront(); - } - // scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - uBar.bringToFront(); - isBookmarkShowing = false; + yolo.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationEnd(Animation animation) { + urlTitle[del].setVisibility(View.GONE); + findNewView(del); + main[del] = null; + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationStart(Animation animation) { + } - } else if (main[id].isShown()) { + }); + urlTitle[del].startAnimation(yolo); + + } + + @SuppressWarnings("deprecation") + void findNewView(int id) { + int leftId = id; + boolean right = false, left = false; + if (id == pageId) { + + if (main[id].isShown()) { background.removeView(main[id]); } for (; id <= (number - 1); id++) { @@ -1191,14 +1183,14 @@ public class Barebones extends Activity { } urlTitle[id].setPadding(leftPad, 0, rightPad, 0); pageId = id; - getUrl.setText(urlToLoad[pageId][0]); + setUrlText(urlToLoad[pageId][0]); getUrl.setPadding(tenPad, 0, tenPad, 0); right = true; break; } } - if (right == false) { + if (!right) { for (; leftId >= 0; leftId--) { if (urlTitle[leftId].isShown()) { @@ -1212,7 +1204,7 @@ public class Barebones extends Activity { } urlTitle[leftId].setPadding(leftPad, 0, rightPad, 0); pageId = leftId; - getUrl.setText(urlToLoad[pageId][0]); + setUrlText(urlToLoad[pageId][0]); getUrl.setPadding(tenPad, 0, tenPad, 0); left = true; break; @@ -1226,16 +1218,13 @@ public class Barebones extends Activity { right = left = true; } - if (right == false && left == false) { + if (!(right || left)) { finish(); - } else { - pageIdIsVisible = true; - // main[pageId].invalidate(); } - + tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0); } - public void enter() { + void enter() { getUrl.setOnKeyListener(new OnKeyListener() { @Override @@ -1279,7 +1268,7 @@ public class Barebones extends Activity { } @SuppressLint("HandlerLeak") - public void enterUrl() { + void enterUrl() { getUrl = (MultiAutoCompleteTextView) findViewById(R.id.enterUrl); getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setTextColor(getResources().getColor(android.R.color.black)); @@ -1296,9 +1285,8 @@ public class Barebones extends Activity { R.layout.two_line_autocomplete, new String[] { "title", "url" }, new int[] { R.id.title, R.id.url }); - if (adapter != null) { - getUrl.setAdapter(adapter); - } + + getUrl.setAdapter(adapter); break; } @@ -1323,9 +1311,9 @@ public class Barebones extends Activity { bookmarks = Browser.BOOKMARKS_URI; c = getContentResolver().query(bookmarks, columns, null, null, null); - } catch (SQLiteException e) { - } catch (IllegalStateException e) { - } catch (NullPointerException e) { + } catch (SQLiteException ignored) { + } catch (IllegalStateException ignored) { + } catch (NullPointerException ignored) { } if (c != null) { @@ -1335,7 +1323,7 @@ public class Barebones extends Activity { noStockBrowser = true; Log.e("Barebones", "did not detect AOSP browser"); } - + c.close(); try { managedCursor = null; @@ -1349,16 +1337,16 @@ public class Barebones extends Activity { handler.sendEmptyMessage(1); - } catch (SQLiteException e) { - } catch (NullPointerException e) { - } catch (IllegalStateException e) { + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { } list = new ArrayList>(); try { if (managedCursor != null) { - if (managedCursor.moveToFirst()) { + if (managedCursor.moveToLast()) { // Variable for holding the retrieved URL @@ -1372,22 +1360,23 @@ public class Barebones extends Activity { map.put("title", title); map.put("url", urlA); list.add(map); - } while (managedCursor.moveToNext()); + } while (managedCursor.moveToPrevious()); } } - } catch (SQLiteException e) { - } catch (NullPointerException e) { - } catch (IllegalStateException e) { + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { } - + managedCursor.close(); } }); + updateAutoComplete.setPriority(3); try { updateAutoComplete.start(); - } catch (NullPointerException e) { - } catch (SQLiteMisuseException e) { - } catch (IllegalStateException e) { + } catch (NullPointerException ignored) { + } catch (SQLiteMisuseException ignored) { + } catch (IllegalStateException ignored) { } getUrl.setThreshold(2); @@ -1400,15 +1389,8 @@ public class Barebones extends Activity { try { txt = (TextView) arg1.findViewById(R.id.url); str = txt.getText().toString(); - if (!pageIdIsVisible && isBookmarkShowing) { - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - background.addView(main[pageId]); - pageIdIsVisible = true; - isBookmarkShowing = false; - } main[pageId].loadUrl(str); - getUrl.setText(str); + setUrlText(str); getUrl.setPadding(tenPad, 0, tenPad, 0); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); @@ -1425,7 +1407,7 @@ public class Barebones extends Activity { // clicked } - public void exit() { + void back() { ImageView exit = (ImageView) findViewById(R.id.exit); exit.setBackgroundResource(R.drawable.button); if (isPhone) { @@ -1436,24 +1418,13 @@ public class Barebones extends Activity { @Override public void onClick(View v) { - if (isBookmarkShowing) { - background.addView(main[pageId]); - main[pageId].startAnimation(fadeIn); - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - uBar.bringToFront(); - urlTitle[pageId].setText(urlToLoad[pageId][1]); - getUrl.setText(urlToLoad[pageId][0]); - getUrl.setPadding(tenPad, 0, tenPad, 0); - pageIdIsVisible = true; - isBookmarkShowing = false; + + if (main[pageId].canGoBack()) { + main[pageId].goBack(); } else { - if (main[pageId].canGoBack()) { - main[pageId].goBack(); - } else { - deleteTab(pageId); - } + deleteTab(pageId); } + } }); @@ -1471,27 +1442,35 @@ public class Barebones extends Activity { @Override public void finish() { - pageIdIsVisible = false; + background.clearDisappearingChildren(); + tabScroll.clearDisappearingChildren(); try { - deleteHistory = settings.getBoolean("history", false); - if (deleteHistory == true) { + if (deleteHistory) { + cookieManager.removeAllCookie(); + main[0].clearCache(true); + WebViewDatabase m = WebViewDatabase.getInstance(this); + m.clearFormData(); + m.clearHttpAuthUsernamePassword(); + m.clearUsernamePassword(); CONTEXT.deleteDatabase("historyManager"); if (!noStockBrowser) { - Browser.clearHistory(getContentResolver()); + try { + Browser.clearHistory(getContentResolver()); + } catch (NullPointerException ignored) { + } } + trimCache(CONTEXT); } - trimCache(CONTEXT); + } catch (Exception e) { + Log.e("Lightning", "Error Clearing data"); } - main[pageId].pauseTimers(); - if (API >= 11) { - main[pageId].onPause(); - } + super.finish(); } - public void forward() { + void forward() { ImageView forward = (ImageView) findViewById(R.id.forward); forward.setBackgroundResource(R.drawable.button); if (isPhone) { @@ -1504,15 +1483,13 @@ public class Barebones extends Activity { public void onClick(View v) { if (main[pageId].canGoForward()) { main[pageId].goForward(); - } else { - } } }); } - public void goBookmarks() { + void goBookmarks(CustomWebView view) { File book = new File(getBaseContext().getFilesDir(), "bookmarks"); File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); try { @@ -1524,22 +1501,24 @@ public class Barebones extends Activity { && (u = readUrl.readLine()) != null && n < MAX_BOOKMARKS) { bUrl[n] = u; bTitle[n] = t; + n++; } readBook.close(); readUrl.close(); - } catch (FileNotFoundException e) { - } catch (IOException e) { + } catch (FileNotFoundException ignored) { + } catch (IOException ignored) { } - openBookmarks(); + openBookmarks(view); } @SuppressLint("InlinedApi") - public void init() { + void init() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); historyHandler = new DatabaseHandler(this); - + cookieManager = CookieManager.getInstance(); + progressBar = (ProgressBar) findViewById(R.id.progressBar1); if (API >= 11) { progressBar.setIndeterminateDrawable(getResources().getDrawable( @@ -1551,7 +1530,7 @@ public class Barebones extends Activity { showFullScreen = settings.getBoolean("fullscreen", false); uBar = (RelativeLayout) findViewById(R.id.urlBar); - bg = (RelativeLayout) findViewById(R.id.background); + RelativeLayout bg = (RelativeLayout) findViewById(R.id.background); 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); @@ -1597,18 +1576,16 @@ public class Barebones extends Activity { }); - refreshLayout = (RelativeLayout) findViewById(R.id.refreshLayout); + RelativeLayout refreshLayout = (RelativeLayout) findViewById(R.id.refreshLayout); refreshLayout.setBackgroundResource(R.drawable.button); - // get settings - WebView test = new WebView(CONTEXT); // getting default webview - + // user agent - user = test.getSettings().getUserAgentString(); - + user = new WebView(CONTEXT).getSettings().getUserAgentString(); + background = (FrameLayout) findViewById(R.id.holder); mobile = user; // setting mobile user // agent - desktop = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17"; // setting + desktop = FinalVars.DESKTOP_USER_AGENT; // setting // desktop user agent exitTab = getResources().getDrawable(R.drawable.stop); // user // agent @@ -1618,7 +1595,6 @@ public class Barebones extends Activity { // homepage // variable - test.destroy(); userAgent = settings.getString("agent", mobile); // initializing // useragent string allowLocation = settings.getBoolean("location", false); // initializing @@ -1660,11 +1636,7 @@ public class Barebones extends Activity { tabScroll.setHorizontalScrollBarEnabled(false); if (API > 8) { tabScroll.setOverScrollMode(View.OVER_SCROLL_NEVER); // disallow - // overscroll - // (only - // available - // in 2.3 - // and up) + //overscroll } // image dimensions and initialization @@ -1672,22 +1644,29 @@ public class Barebones extends Activity { final float scale = getApplicationContext().getResources() .getDisplayMetrics().density; pixels = (int) (dps * scale + 0.5f); - pixelHeight = (int) (36 * scale + 0.5f); - bookHeight = (int) (48 * scale + 0.5f); - height56 = (int) (56 * scale + 0.5f); leftPad = (int) (17 * scale + 0.5f); rightPad = (int) (15 * scale + 0.5f); height32 = (int) (32 * scale + 0.5f); tenPad = (int) (10 * scale + 0.5f); number = 0; - webpage = getResources().getDrawable(R.drawable.webpage); + webpageOther = getResources().getDrawable(R.drawable.webpage); - webpage.setBounds(0, 0, width * 2 / 3, height * 2 / 3); - webpageOther.setBounds(0, 0, width * 1 / 2, height * 1 / 2); + 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); - initializeTabs(); // restores old tabs or creates a new one + Thread startup = new Thread(new Runnable() { + + @Override + public void run() { + initializeTabs(); // restores old tabs or creates a new one + + } + + }); + startup.run(); // new tab button ImageView newTab = (ImageView) findViewById(R.id.newTab); @@ -1695,10 +1674,10 @@ public class Barebones extends Activity { newTab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - newTab(number, homepage, true); + newTab(number, homepage, true, false); tabScroll.postDelayed(new Runnable() { public void run() { - tabScroll.fullScroll(HorizontalScrollView.FOCUS_RIGHT); + tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0); } }, 100L); @@ -1724,38 +1703,53 @@ public class Barebones 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; + } + } + } + }; } - public void initializeTabs() { + void initializeTabs() { Intent url = getIntent(); - String URL = null; // that opens the browser - // gets the string passed into the browser - URL = url.getDataString(); + String URL = url.getDataString(); boolean oldTabs = false; if (saveTabs) { if (URL != null) { // opens a new tab with the url if its there - newTab(number, URL, true); + newTab(number, URL, true, false); main[number - 1].resumeTimers(); oldTabs = true; } - for (int num = 0; num < memoryURL.length; num++) { - - if (memoryURL[num].length() > 0) { + for (String aMemoryURL : memoryURL) { + if (aMemoryURL.length() > 0) { if (number == 0) { - newTab(number, "", !oldTabs); + newTab(number, "", !oldTabs, false); main[number - 1].resumeTimers(); main[number - 1].getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK); - main[number - 1].loadUrl(memoryURL[num]); + main[number - 1].loadUrl(aMemoryURL); } else { - newTab(number, "", false); + newTab(number, "", false, false); main[number - 1].getSettings().setCacheMode( WebSettings.LOAD_CACHE_ELSE_NETWORK); - main[number - 1].loadUrl(memoryURL[num]); + main[number - 1].loadUrl(aMemoryURL); } oldTabs = true; } @@ -1763,104 +1757,112 @@ public class Barebones extends Activity { } if (!oldTabs) { - newTab(number, homepage, true); + newTab(number, homepage, true, false); main[number - 1].resumeTimers(); } } else { if (URL != null) { // opens a new tab with the url if its there - newTab(number, URL, true); + newTab(number, URL, true, false); main[number - 1].resumeTimers(); } else { // otherwise it opens the homepage - newTab(number, homepage, true); + newTab(number, homepage, true, false); main[number - 1].resumeTimers(); } } } - public void makeTab(final int pageToView, final String Url, + private CustomWebView makeTab(final int pageToView, final String Url, final boolean display) { - main[pageToView] = new AnthonyWebView(CONTEXT); - main[pageToView].setId(pageToView); + CustomWebView view = new CustomWebView(CONTEXT); + view.setId(pageToView); allowLocation = settings.getBoolean("location", false); - main[pageToView].setWebViewClient(new AnthonyWebViewClient()); - main[pageToView].setWebChromeClient(new AnthonyChromeClient()); + view.setWebViewClient(new CustomWebViewClient()); + view.setWebChromeClient(new CustomChromeClient()); if (API > 8) { - main[pageToView].setDownloadListener(new AnthonyDownload()); + view.setDownloadListener(new CustomDownloadListener()); } - main[pageToView].setOnLongClickListener(new WebPageLongClick()); - main[pageToView] = BrowserSettings(main[pageToView]); + view.setOnLongClickListener(new WebPageLongClickListener()); + view = browserSettings(view); agentPicker = settings.getInt("agentchoose", 1); switch (agentPicker) { case 1: - main[pageToView].getSettings().setUserAgentString(mobile); + view.getSettings().setUserAgentString(mobile); break; case 2: - main[pageToView].getSettings().setUserAgentString(desktop); + view.getSettings().setUserAgentString(desktop); break; case 3: userAgent = settings.getString("agent", user); - main[pageToView].getSettings().setUserAgentString(userAgent); + view.getSettings().setUserAgentString(userAgent); break; } if (display) { background.removeView(main[pageId]); - background.addView(main[pageToView]); - main[pageToView].requestFocus(); + background.addView(view); + view.requestFocus(); pageId = pageToView; } uBar.bringToFront(); - if (Url.contains("about:home") && !showFullScreen) { - pageIdIsVisible = false; - goBookmarks(); - } else if (Url.contains("about:home")) { - pageIdIsVisible = true; - main[pageToView].loadUrl("about:blank"); - + if (Url.contains("about:home")) { + goBookmarks(view); } else if (Url.contains("about:blank")) { - pageIdIsVisible = true; - main[pageToView].loadUrl("about:blank"); + + view.loadUrl("about:blank"); } else { - pageIdIsVisible = true; - main[pageToView].loadUrl(Url); + + view.loadUrl(Url); } Log.i("Barebones", "tab complete"); - + return view; } - public void newSettings() { + void newSettings() { Intent set = new Intent(FinalVars.SETTINGS_INTENT); startActivity(set); } // new tab method, takes the id of the tab to be created and the url to load @SuppressWarnings("deprecation") - public void newTab(int theId, final String theUrl, final boolean display) { + int newTab(int theId, final String theUrl, final boolean display, + final boolean incognito_mode) { Log.i("Barebones", "making tab"); - lastVisibleWebView = pageId; - if (isBookmarkShowing) { - background.addView(main[pageId]); - main[pageId].startAnimation(fadeIn); - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - uBar.bringToFront(); - isBookmarkShowing = false; - } - pageIdIsVisible = false; + + int finalID = 0; homepage = settings.getString("home", HOMEPAGE); allowLocation = settings.getBoolean("location", false); boolean isEmptyWebViewAvailable = false; for (int num = 0; num < number; num++) { if (urlTitle[num].getVisibility() == View.GONE) { - urlTitle[num].setVisibility(View.VISIBLE); - urlTitle[num].setText("about:blank"); + + final int n = num; + Animation holo = AnimationUtils.loadAnimation(this, R.anim.up); + holo.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationEnd(Animation animation) { + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationStart(Animation animation) { + urlTitle[n].setVisibility(View.VISIBLE); + } + + }); + urlTitle[n].startAnimation(holo); + urlTitle[num].setText("New Tab"); + incognito[num] = incognito_mode; if (display) { if (API < 16) { urlTitle[num].setBackgroundDrawable(active); @@ -1882,28 +1884,26 @@ public class Barebones extends Activity { urlTitle[pageId].setBackground(inactive); } } + urlTitle[pageId].setCompoundDrawables(webpageOther, null, + exitTab, null); urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); - if (display) { - background.addView(main[num]); - background.removeView(main[pageId]); - pageId = num; - } + main[num] = makeTab(num, theUrl, display); + finalID = num; + pageId = num; uBar.bringToFront(); - main[num] = BrowserSettings(main[num]); + if (API >= 11) { main[num].onResume(); } - main[num].loadUrl(theUrl); - pageIdIsVisible = true; isEmptyWebViewAvailable = true; break; } } - if (isEmptyWebViewAvailable == false) { + if (!isEmptyWebViewAvailable) { if (number < MAX_TABS) { - pageIdIsVisible = false; + incognito[number] = incognito_mode; if (number > 0) { if (display) { if (API < 16) { @@ -1916,7 +1916,7 @@ public class Barebones extends Activity { } } final TextView title = new TextView(CONTEXT); - title.setText("about:blank"); + title.setText("New Tab"); if (display) { if (API < 16) { title.setBackgroundDrawable(active); @@ -1937,33 +1937,62 @@ public class Barebones extends Activity { title.setPadding(leftPad, 0, rightPad, 0); title.setId(number); title.setGravity(Gravity.CENTER_VERTICAL); - title.setCompoundDrawables(null, null, exitTab, null); + if (incognito[number]) { + title.setCompoundDrawables(incognitoPage, null, exitTab, + null); + } else { + title.setCompoundDrawables(webpageOther, null, exitTab, + null); + } Drawable[] drawables = title.getCompoundDrawables(); bounds = drawables[2].getBounds(); - title.setOnLongClickListener(new TabLongClick()); - title.setOnClickListener(new TabClick()); - title.setOnTouchListener(new TabTouch()); + title.setOnTouchListener(new TabTouchListener()); + Animation holo = AnimationUtils.loadAnimation(this, R.anim.up); tabLayout.addView(title); + title.setVisibility(View.INVISIBLE); + holo.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationEnd(Animation animation) { + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationStart(Animation animation) { + title.setVisibility(View.VISIBLE); + } + + }); + title.startAnimation(holo); urlTitle[number] = title; + if (incognito[number]) { + urlTitle[number].setText("Incognito"); + + } if (theUrl != null) { - makeTab(number, theUrl, display); + main[number] = makeTab(number, theUrl, display); } else { - makeTab(number, homepage, display); + main[number] = makeTab(number, homepage, display); } + finalID = number; number = number + 1; } } - if (isEmptyWebViewAvailable == false && number >= MAX_TABS) { + if (!isEmptyWebViewAvailable && number >= MAX_TABS) { Toast.makeText(CONTEXT, "Maximum number of tabs reached...", Toast.LENGTH_SHORT).show(); } + return finalID; } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { - if (requestCode == FILECHOOSER_RESULTCODE) { + if (requestCode == 1) { if (null == mUploadMessage) return; Uri result = intent == null || resultCode != RESULT_OK ? null @@ -1976,24 +2005,8 @@ public class Barebones extends Activity { @Override public void onBackPressed() { - if (isBookmarkShowing) { - - if (showFullScreen && !uBar.isShown()) { - background.addView(uBar); - uBar.startAnimation(fadeIn); - uBar.bringToFront(); - } - background.addView(main[pageId]); - main[pageId].startAnimation(fadeIn); - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - urlTitle[pageId].setText(urlToLoad[pageId][1]); - getUrl.setText(urlToLoad[pageId][0]); - getUrl.setPadding(tenPad, 0, tenPad, 0); - pageIdIsVisible = true; - isBookmarkShowing = false; - uBar.bringToFront(); - } else if (main[pageId].canGoBack()) { + main[pageId].stopLoading(); + if (main[pageId].canGoBack()) { main[pageId].goBack(); } else { deleteTab(pageId); @@ -2006,22 +2019,21 @@ public class Barebones extends Activity { public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); main[pageId].getSettings().setLayoutAlgorithm( - LayoutAlgorithm.NARROW_COLUMNS); + LayoutAlgorithm.NORMAL); // main[pageId].invalidate(); } - + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // displays main xml layout settings = getSharedPreferences(preferences, 0); - edit = settings.edit(); saveTabs = settings.getBoolean("savetabs", true); if (saveTabs) { String mem = settings.getString("memory", ""); memoryURL = null; - memoryURL = GetArray(mem, "\\|\\$\\|SEPARATOR\\|\\$\\|"); + memoryURL = GetArray(mem); } inactive = getResources().getDrawable(R.drawable.bg_inactive); @@ -2031,14 +2043,14 @@ public class Barebones extends Activity { enter();// enter url bar DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); - widthInInches = metrics.widthPixels / metrics.xdpi; - heightInInches = metrics.heightPixels / metrics.ydpi; - sizeInInches = Math.sqrt(Math.pow(widthInInches, 2) + float widthInInches = metrics.widthPixels / metrics.xdpi; + float heightInInches = metrics.heightPixels / metrics.ydpi; + double sizeInInches = Math.sqrt(Math.pow(widthInInches, 2) + Math.pow(heightInInches, 2)); // 0.5" buffer for 7" devices isPhone = sizeInInches < 6.5; forward();// forward button - exit(); + back(); int first = settings.getInt("first", 0); if (first == 0) { // This dialog alerts the user to some navigation @@ -2090,10 +2102,11 @@ public class Barebones extends Activity { @Override protected void onNewIntent(Intent intent) { - String url = null; - url = intent.getDataString(); + String url = intent.getDataString(); if (url != null) { - newTab(number, url, true); + for(int n=0;n= 11) { - main[pageId].onPause(); + if (main[pageId] != null) { + if (API >= 11) { + main[pageId].onPause(); + } + main[pageId].pauseTimers(); } - main[pageId].pauseTimers(); - Thread remember = new Thread(new Runnable() { @Override @@ -2156,23 +2165,11 @@ public class Barebones extends Activity { edit.commit(); } }); + // remember.setPriority(10); remember.start(); super.onPause(); } - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - - MenuItem refresh = menu.findItem(R.id.refresh); - - if (main[pageId].getProgress() < 100) { - refresh.setTitle("Stop"); - } else { - refresh.setTitle("Refresh"); - } - return super.onPrepareOptionsMenu(menu); - } - @Override protected void onResume() { super.onResume(); @@ -2183,69 +2180,36 @@ public class Barebones extends Activity { } - public void openBookmarks() { - scrollBookmarks = new ScrollView(CONTEXT); - RelativeLayout.LayoutParams g = new RelativeLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT); - g.addRule(RelativeLayout.BELOW, R.id.relativeLayout1); - scrollBookmarks.setLayoutParams(g); - LinearLayout bookmarkLayout = new LinearLayout(CONTEXT); - bookmarkLayout.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT)); - bookmarkLayout.setOrientation(LinearLayout.VERTICAL); - TextView description = new TextView(CONTEXT); - description.setHeight(height56); - description.setBackgroundColor(0xff33b5e5); - description.setTextColor(0xffffffff); - description.setText("Bookmarks"); - description.setGravity(Gravity.CENTER_VERTICAL - | Gravity.CENTER_HORIZONTAL); - description.setTextSize(bookHeight / 3); - description.setPadding(rightPad, 0, rightPad, 0); - bookmarkLayout.addView(description); - + void openBookmarks(CustomWebView view) { + String bookmarkHtml = BookmarkPage.Heading; for (int n = 0; n < MAX_BOOKMARKS; n++) { if (bUrl[n] != null) { - TextView b = new TextView(CONTEXT); - b.setId(n); - b.setSingleLine(true); - b.setGravity(Gravity.CENTER_VERTICAL); - b.setTextSize(pixelHeight / 3); - b.setBackgroundResource(R.drawable.bookmark); - b.setHeight(height56); - b.setText(bTitle[n]); - b.setCompoundDrawables(webpage, null, null, null); - b.setOnClickListener(new BookmarkListener()); - b.setOnLongClickListener(new BookmarkLongClick()); - b.setPadding(rightPad, 0, rightPad, 0); - bookmarkLayout.addView(b); - } - } - pageIdIsVisible = false; + bookmarkHtml += (BookmarkPage.Part1 + bUrl[n] + + BookmarkPage.Part2 + bUrl[n] + BookmarkPage.Part3 + + bTitle[n] + BookmarkPage.Part4); + } + } + bookmarkHtml += BookmarkPage.End; + File bookmarkWebPage = new File(getBaseContext().getFilesDir(), + "bookmarks.html"); + try { + FileWriter bookWriter = new FileWriter(bookmarkWebPage, false); + bookWriter.write(bookmarkHtml); + bookWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + view.loadUrl("file:///" + bookmarkWebPage); if (uBar.isShown()) { urlTitle[pageId].setText("Bookmarks"); - getUrl.setText("Bookmarks"); + setUrlText(""); getUrl.setPadding(tenPad, 0, tenPad, 0); } - // main[pageId].startAnimation(fadeOut); - background.removeView(main[pageId]); - - if (showFullScreen) { - // uBar.startAnimation(fadeOut); - background.removeView(uBar); - } - scrollBookmarks.addView(bookmarkLayout); - background.addView(scrollBookmarks); - scrollBookmarks.startAnimation(fadeIn); - isBookmarkShowing = true; - } - public void options() { + void options() { ImageView options = (ImageView) findViewById(R.id.options); options.setBackgroundResource(R.drawable.button); options.setOnClickListener(new OnClickListener() { @@ -2263,15 +2227,11 @@ public class Barebones extends Activity { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { - case R.id.refresh: - if (main[pageId].getProgress() < 100) { - main[pageId].stopLoading(); - } else { - main[pageId].reload(); - } + case R.id.history: + generateHistory(main[pageId]); return true; case R.id.bookmark: - if (!isBookmarkShowing) { + if (!urlToLoad[pageId][1].equals("Bookmarks")) { addBookmark(); } return true; @@ -2279,17 +2239,16 @@ public class Barebones extends Activity { newSettings(); return true; case R.id.allBookmarks: - if (!isBookmarkShowing) { - goBookmarks(); + if (!urlToLoad[pageId][1].equals("Bookmarks")) { + goBookmarks(main[pageId]); } return true; case R.id.share: share(); return true; - case R.id.forward: - if (main[pageId].canGoForward()) { - main[pageId].goForward(); - } + case R.id.incognito: + startActivity(new Intent(FinalVars.INCOGNITO_INTENT)); + //newTab(number, homepage, true, true); return true; default: return false; @@ -2300,25 +2259,6 @@ public class Barebones extends Activity { }); menu.show(); } else if (API < 11) { - /* - * LayoutInflater - * inflater=(LayoutInflater)CONTEXT.getSystemService - * (Context.LAYOUT_INFLATER_SERVICE); Display - * display=getWindowManager().getDefaultDisplay(); - * - * int width=display.getWidth()/2; int - * height=display.getHeight()/2; - * - * View pop = inflater.inflate(R.layout.menu,null,false); - * pop - * .measure(View.MeasureSpec.UNSPECIFIED,View.MeasureSpec. - * UNSPECIFIED); height=pop.getMeasuredHeight(); - * width=pop.getMeasuredWidth(); PopupWindow pu = new - * PopupWindow(pop,width,height,true); - * pu.showAtLocation(findViewById - * (v.getId()),Gravity.NO_GRAVITY - * ,v.getRight(),v.getBottom()+80); - */ openOptionsMenu(); } @@ -2335,7 +2275,7 @@ public class Barebones extends Activity { }); } - public void share() { + void share() { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); // set the type @@ -2355,22 +2295,17 @@ public class Barebones extends Activity { startActivity(Intent.createChooser(shareIntent, "Share this page")); } - public void testForSearch() { + void testForSearch() { String fixedQuery = query.trim(); + main[pageId].stopLoading(); boolean period = fixedQuery.contains("."); - if (isBookmarkShowing) { - scrollBookmarks.startAnimation(fadeOut); - background.removeView(scrollBookmarks); - isBookmarkShowing = false; - background.addView(main[pageId]); - main[pageId].startAnimation(fadeIn); - uBar.bringToFront(); - } - pageIdIsVisible = true; - if (fixedQuery.contains("about:home")) { - goBookmarks(); - } else if (fixedQuery.contains(" ") || period == false) { + if (fixedQuery.contains("about:home") + || fixedQuery.contains("about:bookmarks")) { + goBookmarks(main[pageId]); + } else if (fixedQuery.contains("about:history")) { + generateHistory(main[pageId]); + } else if (fixedQuery.contains(" ") || !period) { fixedQuery.replaceAll(" ", "+"); main[pageId].loadUrl(SEARCH + fixedQuery); } else if (!fixedQuery.contains("http//") @@ -2386,19 +2321,19 @@ public class Barebones extends Activity { } } - public void trimCache(Context context) { + void trimCache(Context context) { try { File dir = context.getCacheDir(); if (dir != null && dir.isDirectory()) { - // deleteDir(dir); + deleteDir(dir); } - } catch (Exception e) { + } catch (Exception ignored) { } } - public void updateHistory(final String url, final String pageTitle) { + void updateHistory(final String url, final String pageTitle) { update = new Runnable() { @Override public void run() { @@ -2406,7 +2341,7 @@ public class Barebones extends Activity { try { Browser.updateVisitedHistory(getContentResolver(), url, false); - } catch (NullPointerException e) { + } catch (NullPointerException ignored) { } } try { @@ -2431,7 +2366,12 @@ public class Barebones extends Activity { } } }; - new Thread(update).start(); + if (!url.contains("file:///" + getBaseContext().getFilesDir() + + "/bookmarks.html") + && !url.contains("file:///" + getBaseContext().getFilesDir() + + "/history.html")) { + new Thread(update).start(); + } } } diff --git a/src/acr/browser/barebones/BookmarkPage.java b/src/acr/browser/barebones/BookmarkPage.java new file mode 100644 index 0000000..85bad3c --- /dev/null +++ b/src/acr/browser/barebones/BookmarkPage.java @@ -0,0 +1,24 @@ +package acr.browser.barebones; + +class BookmarkPage { + 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/CustomWebView.java b/src/acr/browser/barebones/CustomWebView.java new file mode 100644 index 0000000..2bc3139 --- /dev/null +++ b/src/acr/browser/barebones/CustomWebView.java @@ -0,0 +1,55 @@ +package acr.browser.barebones; + +import android.content.Context; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; +import android.view.animation.Animation; +import android.webkit.WebView; + +public final class CustomWebView extends WebView { + + private final int API = FinalVars.API; + private int hitTest; + private final boolean showFullScreen = Barebones.showFullScreen; + private final View uBar = Barebones.uBar; + private final Animation slideUp = Barebones.slideUp; + private final Animation slideDown = Barebones.slideDown; + + public CustomWebView(Context context) { + super(context); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: { + hitTest = 0; + try { + hitTest = getHitTestResult().getType(); + } catch (NullPointerException ignored) { + } + if (API <= 10 && !this.hasFocus()) { + this.requestFocus(); + } + if (showFullScreen) { + if (uBar.isShown()) { + uBar.startAnimation(slideUp); + + } else if (this.getScrollY() <= 5 + && !uBar.isShown() && hitTest != 9) { + uBar.startAnimation(slideDown); + + } + } + break; + } + default: + break; + } + + return super.onTouchEvent(event); + } + +} diff --git a/src/acr/browser/barebones/DatabaseHandler.java b/src/acr/browser/barebones/DatabaseHandler.java index 19ace36..522692d 100644 --- a/src/acr/browser/barebones/DatabaseHandler.java +++ b/src/acr/browser/barebones/DatabaseHandler.java @@ -9,7 +9,7 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; -public class DatabaseHandler extends SQLiteOpenHelper { +class DatabaseHandler extends SQLiteOpenHelper { // All Static variables // Database Version @@ -75,10 +75,10 @@ public class DatabaseHandler extends SQLiteOpenHelper { if (cursor != null) cursor.moveToFirst(); - HistoryItem item = new HistoryItem(Integer.parseInt(cursor.getString(0)), - cursor.getString(1), cursor.getString(2)); + // return item - return item; + return new HistoryItem(Integer.parseInt(cursor.getString(0)), + cursor.getString(1), cursor.getString(2)); } // Getting All HistoryItems diff --git a/src/acr/browser/barebones/FinalVars.java b/src/acr/browser/barebones/FinalVars.java index 718818d..8365f08 100644 --- a/src/acr/browser/barebones/FinalVars.java +++ b/src/acr/browser/barebones/FinalVars.java @@ -1,17 +1,21 @@ package acr.browser.barebones; -public class FinalVars { +class FinalVars { public static final int MAX_TABS = 5; public static final int MAX_BOOKMARKS = 5; public static final boolean PAID_VERSION = false; - public static final int API = Integer.valueOf(android.os.Build.VERSION.SDK_INT); - public static final String YAHOO_SEARCH = "https://search.yahoo.com/search?p="; - public static final String GOOGLE_SEARCH = "https://www.google.com/search?q="; - public static final String BING_SEARCH = "https://www.bing.com/search?q="; + 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 int API = android.os.Build.VERSION.SDK_INT; + public static final String YAHOO_SEARCH = "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 = "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.BAREBONESSETTINGS"; + public static final String INCOGNITO_INTENT = "android.intent.action.BAREBONESINCOGNITO"; diff --git a/src/acr/browser/barebones/HistoryItem.java b/src/acr/browser/barebones/HistoryItem.java index 7265a9b..e7120b5 100644 --- a/src/acr/browser/barebones/HistoryItem.java +++ b/src/acr/browser/barebones/HistoryItem.java @@ -1,12 +1,12 @@ package acr.browser.barebones; -public class HistoryItem { +class HistoryItem { //private variables - int _id; - String _url; - String _title; + private int _id; + private String _url; + private String _title; // Empty constructor public HistoryItem(){ diff --git a/src/acr/browser/barebones/HistoryPage.java b/src/acr/browser/barebones/HistoryPage.java new file mode 100644 index 0000000..7dba450 --- /dev/null +++ b/src/acr/browser/barebones/HistoryPage.java @@ -0,0 +1,18 @@ +package acr.browser.barebones; + +public class HistoryPage { + 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/IncognitoMode.java b/src/acr/browser/barebones/IncognitoMode.java new file mode 100644 index 0000000..6f5fced --- /dev/null +++ b/src/acr/browser/barebones/IncognitoMode.java @@ -0,0 +1,2067 @@ +package acr.browser.barebones; + +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 java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.res.Configuration; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteException; +import android.database.sqlite.SQLiteMisuseException; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Rect; +import android.graphics.drawable.BitmapDrawable; +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.util.DisplayMetrics; +import android.util.Log; +import android.view.Gravity; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnKeyListener; +import android.view.View.OnLongClickListener; +import android.view.View.OnTouchListener; +import android.view.WindowManager; +import android.view.animation.Animation; +import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.webkit.CookieManager; +import android.webkit.CookieSyncManager; +import android.webkit.DownloadListener; +import android.webkit.GeolocationPermissions; +import android.webkit.SslErrorHandler; +import android.webkit.URLUtil; +import android.webkit.ValueCallback; +import android.webkit.WebChromeClient; +import android.webkit.WebChromeClient.CustomViewCallback; +import android.webkit.WebIconDatabase; +import android.webkit.WebSettings; +import android.webkit.WebSettings.LayoutAlgorithm; +import android.webkit.WebSettings.PluginState; +import android.webkit.WebSettings.RenderPriority; +import android.webkit.WebStorage.QuotaUpdater; +import android.webkit.WebView; +import android.webkit.WebView.HitTestResult; +import android.webkit.WebViewClient; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.FrameLayout; +import android.widget.HorizontalScrollView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.MultiAutoCompleteTextView; +import android.widget.PopupMenu; +import android.widget.PopupMenu.OnMenuItemClickListener; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.SimpleAdapter; +import android.widget.TextView; +import android.widget.TextView.OnEditorActionListener; +import android.widget.Toast; + +public class IncognitoMode extends Activity { + + @SuppressLint("SetJavaScriptEnabled") + public class CustomChromeClient extends WebChromeClient { + private Bitmap mDefaultVideoPoster; + private View mVideoProgressView; + + @Override + public void onExceededDatabaseQuota(String url, + String databaseIdentifier, long quota, + long estimatedDatabaseSize, long totalQuota, + QuotaUpdater quotaUpdater) { + // TODO Auto-generated method stub + quotaUpdater.updateQuota(totalQuota + estimatedDatabaseSize); + super.onExceededDatabaseQuota(url, databaseIdentifier, quota, + estimatedDatabaseSize, totalQuota, quotaUpdater); + } + + @Override + public void onReachedMaxAppCacheSize(long requiredStorage, long quota, + QuotaUpdater quotaUpdater) { + // TODO Auto-generated method stub + quotaUpdater.updateQuota(quota+requiredStorage); + super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater); + } + + @Override + public Bitmap getDefaultVideoPoster() { + // Log.i(LOGTAG, "here in on getDefaultVideoPoster"); + if (mDefaultVideoPoster == null) { + mDefaultVideoPoster = BitmapFactory.decodeResource( + getResources(), android.R.color.black); + } + return mDefaultVideoPoster; + } + + @Override + public View getVideoLoadingProgressView() { + // Log.i(LOGTAG, "here in on getVideoLoadingPregressView"); + + if (mVideoProgressView == null) { + LayoutInflater inflater = LayoutInflater.from(getBaseContext()); + mVideoProgressView = inflater.inflate( + android.R.layout.simple_spinner_item, null); + } + return mVideoProgressView; + } + + @Override + public boolean onCreateWindow(WebView view, boolean isDialog, + boolean isUserGesture, final Message resultMsg) { + if (isUserGesture) { + WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj; + transport.setWebView(main[pageId]); + resultMsg.sendToTarget(); + Thread get = new Thread(new Runnable(){ + + @Override + public void run() { + // TODO Auto-generated method stub + try { + Thread.sleep(200); + main[pageId].loadUrl(getUrl.getText().toString()); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + }); + get.start(); + return true; + } + return false; + } + + @Override + public void onGeolocationPermissionsShowPrompt(final String origin, + final GeolocationPermissions.Callback callback) { + + if (!allowLocation) { + callback.invoke(origin, false, false); + } + if (allowLocation) { + + Log.i("IncognitoMode: ", "onGeolocationPermissionsShowPrompt()"); + + final boolean remember = true; + AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); + builder.setTitle("Locations"); + builder.setMessage( + origin + " Would like to use your Current Location ") + .setCancelable(true) + .setPositiveButton("Allow", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int id) { + // origin, allow, remember + callback.invoke(origin, true, remember); + } + }) + .setNegativeButton("Don't Allow", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int id) { + // origin, allow, remember + callback.invoke(origin, false, remember); + } + }); + AlertDialog alert = builder.create(); + alert.show(); + } + } + + @Override + public void onHideCustomView() { + + if (mCustomView == null) + return; + + // Hide the custom view. + mCustomView.setVisibility(View.GONE); + + // Remove the custom view from its container. + background.removeView(mCustomView); + mCustomView = null; + background.setVisibility(View.VISIBLE); + uBar.setVisibility(View.VISIBLE); + mCustomViewCallback.onCustomViewHidden(); + + main[pageId].setVisibility(View.VISIBLE); + + // Log.i(LOGTAG, "set it to webVew"); + } + + + @Override + public void onReceivedTitle(final WebView view, final String title) { + numberPage = view.getId(); + urlTitle[numberPage].setText(title); + urlToLoad[numberPage][1] = title; + super.onReceivedTitle(view, title); + } + + @Override + public void onShowCustomView(View view, int requestedOrientation, + CustomViewCallback callback) { + // Log.i(LOGTAG, "here in on ShowCustomView"); + main[pageId].setVisibility(View.GONE); + uBar.setVisibility(View.GONE); + // if a view already exists then immediately terminate the new one + if (mCustomView != null) { + callback.onCustomViewHidden(); + return; + } + + background.addView(view); + mCustomView = view; + mCustomViewCallback = callback; + background.setVisibility(View.VISIBLE); + } + + @Override + public void onShowCustomView(View view, + WebChromeClient.CustomViewCallback callback) { + // Log.i(LOGTAG, "here in on ShowCustomView"); + main[pageId].setVisibility(View.GONE); + uBar.setVisibility(View.GONE); + // if a view already exists then immediately terminate the new one + if (mCustomView != null) { + callback.onCustomViewHidden(); + return; + } + background.addView(view); + mCustomView = view; + mCustomViewCallback = callback; + background.setVisibility(View.VISIBLE); + } + + public void openFileChooser(ValueCallback uploadMsg) { + + mUploadMessage = uploadMsg; + Intent i = new Intent(Intent.ACTION_GET_CONTENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("image/*"); + IncognitoMode.this.startActivityForResult( + Intent.createChooser(i, "Image Browser"), + 1); + } + + public void openFileChooser(ValueCallback uploadMsg, + String acceptType) { + mUploadMessage = uploadMsg; + Intent i = new Intent(Intent.ACTION_GET_CONTENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("image/*"); + IncognitoMode.this.startActivityForResult( + Intent.createChooser(i, "Image Browser"), + 1); + } + + public void openFileChooser(ValueCallback uploadMsg, + String acceptType, String capture) { + mUploadMessage = uploadMsg; + Intent i = new Intent(Intent.ACTION_GET_CONTENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("image/*"); + IncognitoMode.this.startActivityForResult( + Intent.createChooser(i, "Image Browser"), + 1); + } + } + + private class CustomDownloadListener implements DownloadListener { + + @Override + 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); + } + + 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) { + + } + } + + // } + + } + + private class CustomWebViewClient extends WebViewClient { + + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + + if (url.contains("plus.google.com")) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } else if (url.contains("market://") + || url.contains("play.google.com")) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } else if (url.contains("youtube.com")) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } else if (url.contains("maps.google.com")) { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } + + return false; + } + + @Override + public void onPageFinished(WebView view, final String url) { + if (view.isShown()) { + view.postInvalidate(); + progressBar.setVisibility(View.GONE); + refresh.setVisibility(View.VISIBLE); + if(showFullScreen&&uBar.isShown()){ + uBar.startAnimation(slideUp); + + } + } + view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); + + pageIsLoading = false; + + } + + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + + numberPage = view.getId(); + if (view.isShown()) { + refresh.setVisibility(View.INVISIBLE); + progressBar.setVisibility(View.VISIBLE); + setUrlText(url); + pageIsLoading = true; + } + urlTitle[numberPage].setCompoundDrawables(incognitoPage, null, + exitTab, null); + + getUrl.setPadding(tenPad, 0, tenPad, 0); + urlToLoad[numberPage][0] = url; + + if (!uBar.isShown()&&showFullScreen) { + uBar.startAnimation(slideDown); + } + } + + @Override + public void onReceivedSslError(WebView view, SslErrorHandler handler, + SslError error) { + handler.proceed(); + super.onReceivedSslError(view, handler, error); + } + + @Override + public void onScaleChanged(WebView view, float oldScale, float newScale) { + + view.getSettings().setLayoutAlgorithm( + LayoutAlgorithm.NORMAL); + super.onScaleChanged(view, oldScale, newScale); + } + } + + private void generateHistory(final CustomWebView view) { + + Thread history = new Thread(new Runnable() { + + @Override + public void run() { + String historyHtml = HistoryPage.Heading; + Cursor historyCursor = null; + String[][] h = new String[50][3]; + + try { + SQLiteDatabase s = historyHandler.getReadableDatabase(); + historyCursor = s.query("history", // URI + // of + columns, // Which columns to return + null, // Which rows to return (all rows) + null, // Selection arguments (none) + null, null, null); + + handler.sendEmptyMessage(1); + + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { + } + + list = new ArrayList>(); + try { + if (historyCursor != null) { + if (historyCursor.moveToLast()) { + // Variable for holding the retrieved URL + urlColumn = historyCursor.getColumnIndex("url"); + titleColumn = historyCursor.getColumnIndex("title"); + // Reference to the the column containing the URL + int n = 0; + do { + + h[n][0] = historyCursor.getString(urlColumn); + h[n][2] = h[n][0].substring(0, + Math.min(100, h[n][0].length())) + + "..."; + h[n][1] = historyCursor.getString(titleColumn); + historyHtml += (HistoryPage.Part1 + h[n][0] + + HistoryPage.Part2 + h[n][1] + + HistoryPage.Part3 + h[n][2] + HistoryPage.Part4); + n++; + } while (n < 49 && historyCursor.moveToPrevious()); + } + } + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { + } + + historyHtml += BookmarkPage.End; + File historyWebPage = new File(getBaseContext().getFilesDir(), + "history.html"); + try { + FileWriter hWriter = new FileWriter(historyWebPage, false); + hWriter.write(historyHtml); + hWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + if (uBar.isShown()) { + urlTitle[pageId].setText("History"); + setUrlText(""); + getUrl.setPadding(tenPad, 0, tenPad, 0); + } + + view.loadUrl("file:///" + historyWebPage); + } + + }); + history.run(); + } + + private void setUrlText(String url) { + if (!url.contains("file:///" + getBaseContext().getFilesDir() + + "/bookmarks.html") + && !url.contains("file:///" + getBaseContext().getFilesDir() + + "/history.html")) { + getUrl.setText(url); + } else { + getUrl.setText(""); + } + } + + private class TabTouchListener implements OnTouchListener { + + @SuppressWarnings("deprecation") + @Override + public boolean onTouch(View v, MotionEvent event) { + id = v.getId(); + background.clearDisappearingChildren(); + boolean xPress = false; + int x = (int) event.getX(); + int y = (int) event.getY(); + Rect edge = new Rect(); + v.getLocalVisibleRect(edge); + + urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); + if (event.getAction() == MotionEvent.ACTION_UP) { + if (x >= (edge.right - bounds.width() - v.getPaddingRight() - fuzz * 3 / 2) + && x <= (edge.right - v.getPaddingRight() + fuzz * 3 / 2) + && y >= (v.getPaddingTop() - fuzz / 2) + && y <= (v.getHeight() - v.getPaddingBottom() + fuzz / 2)) { + xPress = true; + } + if (id == pageId) { + if (xPress) { + deleteTab(id); + uBar.bringToFront(); + } + } else if (id != pageId) { + if (xPress) { + deleteTab(id); + } else { + if (API < 16) { + urlTitle[pageId].setBackgroundDrawable(inactive); + } else if (API > 15) { + urlTitle[pageId].setBackground(inactive); + } + urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); + if (!showFullScreen) { + background.addView(main[id]); + main[id].startAnimation(fadeIn); + main[pageId].startAnimation(fadeOut); + background.removeView(main[pageId]); + uBar.bringToFront(); + } else if (API >= 12) { + main[id].setAlpha(0f); + background.addView(main[id]); + try { + main[id].animate().alpha(1f) + .setDuration(mShortAnimationDuration); + } catch (NullPointerException ignored) { + } + background.removeView(main[pageId]); + uBar.bringToFront(); + } else { + background.removeView(main[pageId]); + background.addView(main[id]); + } + uBar.bringToFront(); + + pageId = id; + setUrlText(urlToLoad[pageId][0]); + getUrl.setPadding(tenPad, 0, tenPad, 0); + if (API < 16) { + urlTitle[pageId].setBackgroundDrawable(active); + } else if (API > 15) { + urlTitle[pageId].setBackground(active); + } + if (main[pageId].getProgress() < 100) { + refresh.setVisibility(View.INVISIBLE); + progressBar.setVisibility(View.VISIBLE); + } else { + progressBar.setVisibility(View.GONE); + refresh.setVisibility(View.VISIBLE); + } + tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0); + main[pageId].invalidate(); + } + } + + } + uBar.bringToFront(); + urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); + return true; + } + + } + + private void deleteBookmark(String url) { + File book = new File(getBaseContext().getFilesDir(), "bookmarks"); + File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); + int n = 0; + try { + BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book)); + BufferedWriter urlWriter = new BufferedWriter(new FileWriter( + bookUrl)); + while (bUrl[n] != null && n < (MAX_BOOKMARKS - 1)) { + if (!bUrl[n].equalsIgnoreCase(url)) { + bookWriter.write(bTitle[n]); + urlWriter.write(bUrl[n]); + bookWriter.newLine(); + urlWriter.newLine(); + } + n++; + } + bookWriter.close(); + urlWriter.close(); + } catch (FileNotFoundException e) { + } catch (IOException e) { + } + for (int p = 0; p < MAX_BOOKMARKS; p++) { + bUrl[p] = null; + bTitle[p] = null; + } + try { + BufferedReader readBook = new BufferedReader(new FileReader(book)); + BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl)); + String t, u; + int z = 0; + while ((t = readBook.readLine()) != null + && (u = readUrl.readLine()) != null && z < MAX_BOOKMARKS) { + bUrl[z] = u; + bTitle[z] = t; + z++; + } + readBook.close(); + readUrl.close(); + } catch (IOException ignored) { + } + openBookmarks(main[pageId]); + } + + private class WebPageLongClickListener implements OnLongClickListener { + + @Override + public boolean onLongClick(View v) { + final HitTestResult result = main[pageId].getHitTestResult(); + if (main[pageId].getUrl().contains( + "file:///" + getBaseContext().getFilesDir() + + "/bookmarks.html")) { + if (result.getExtra() != null) { + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case DialogInterface.BUTTON_POSITIVE: { + int num = pageId; + newTab(number, result.getExtra(), false, true); + // urlTitle[num].performClick(); + pageId = num; + break; + } + case DialogInterface.BUTTON_NEGATIVE: { + main[pageId].loadUrl(result.getExtra()); + break; + } + case DialogInterface.BUTTON_NEUTRAL: { + + deleteBookmark(result.getExtra()); + break; + } + } + } + }; + + AlertDialog.Builder builder = new AlertDialog.Builder( + CONTEXT); // dialog + builder.setMessage( + "What would you like to do with this link?") + .setPositiveButton("Open in New Tab", + dialogClickListener) + .setNegativeButton("Open Normally", + dialogClickListener) + .setNeutralButton("Delete", dialogClickListener) + .show(); + } + return true; + } else if (result.getExtra() != null) { + if (result.getType() == 5 && API > 8) { + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case DialogInterface.BUTTON_POSITIVE: { + int num = pageId; + newTab(number, result.getExtra(), false, true); + // urlTitle[num].performClick(); + pageId = num; + break; + } + case DialogInterface.BUTTON_NEGATIVE: { + main[pageId].loadUrl(result.getExtra()); + break; + } + case DialogInterface.BUTTON_NEUTRAL: { + if (API > 8) { + try { + Thread down = new Thread( + new Runnable() { + @SuppressLint("InlinedApi") + @Override + public void run() { + + 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); + + 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; + } + } + } + }; + + AlertDialog.Builder builder = new AlertDialog.Builder( + CONTEXT); // dialog + builder.setMessage( + "What would you like to do with this link?") + .setPositiveButton("Open in New Tab", + dialogClickListener) + .setNegativeButton("Open Normally", + dialogClickListener) + .setNeutralButton("Download Image", + dialogClickListener).show(); + + } else { + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @SuppressWarnings("deprecation") + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case DialogInterface.BUTTON_POSITIVE: { + int num = pageId; + newTab(number, result.getExtra(), false, true); + // urlTitle[num].performClick(); + pageId = num; + break; + } + case DialogInterface.BUTTON_NEGATIVE: { + main[pageId].loadUrl(result.getExtra()); + break; + } + case DialogInterface.BUTTON_NEUTRAL: { + + if (API < 11) { + android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); + clipboard.setText(result.getExtra()); + } else { + ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + ClipData clip = ClipData.newPlainText( + "label", result.getExtra()); + clipboard.setPrimaryClip(clip); + } + break; + } + } + } + }; + + AlertDialog.Builder builder = new AlertDialog.Builder( + CONTEXT); // dialog + builder.setMessage( + "What would you like to do with this link?") + .setPositiveButton("Open in New Tab", + dialogClickListener) + .setNegativeButton("Open Normally", + dialogClickListener) + .setNeutralButton("Copy link", dialogClickListener) + .show(); + } + return true; + } else { + return false; + } + } + + } + + // variables to differentiate free from paid + private static final int MAX_TABS = FinalVars.MAX_TABS; + private static final int MAX_BOOKMARKS = FinalVars.MAX_BOOKMARKS; + private static final boolean PAID_VERSION = FinalVars.PAID_VERSION; + private final Context CONTEXT = IncognitoMode.this; + private static final String HOMEPAGE = FinalVars.HOMEPAGE; + private static final String SEARCH = FinalVars.GOOGLE_SEARCH; + private static SimpleAdapter adapter; + private static MultiAutoCompleteTextView getUrl; + private static final TextView[] urlTitle = new TextView[MAX_TABS]; + private static final CustomWebView[] main = new CustomWebView[MAX_TABS]; + private static Rect bounds; + private static ValueCallback mUploadMessage; + private static ImageView refresh; + private static ProgressBar progressBar; + private static Drawable webpageOther; + private static Drawable incognitoPage; + private static Drawable exitTab; + private static int numberPage; + private static final int fuzz = 10; + private static int number; + private static int pageId = 0; + private static int agentPicker; + private static int enableFlash; + private static int height32; + private static int height; + private static int width; + private static int pixels; + private static int leftPad; + private static int rightPad; + private static final int API = FinalVars.API; + private static int mShortAnimationDuration; + private static int id; + private static int tenPad; + private static int urlColumn; + private static int titleColumn; + private static View mCustomView = null; + private static CustomViewCallback mCustomViewCallback; + private static boolean isPhone = false; + private static boolean pageIsLoading = false; + private static boolean allowLocation; + static boolean showFullScreen; + private static SharedPreferences settings; + private static SharedPreferences.Editor edit; + private static String desktop; + private static String mobile; + private static String user; + private static String urlA; + private static String title; + private static final String[] bUrl = new String[MAX_BOOKMARKS]; + private static final String[] bTitle = new String[MAX_BOOKMARKS]; + private static String[] columns; + private static String homepage; + private static String str; + private static final String preferences = "settings"; + private static String query; + private static String userAgent; + private static final String[][] urlToLoad = new String[MAX_TABS][2]; + private static FrameLayout background; + static RelativeLayout uBar; + private static HorizontalScrollView tabScroll; + static Animation slideUp; + static Animation slideDown; + private static Animation fadeOut; + private static Animation fadeIn; + private static TextView txt; + + private static CookieManager cookieManager; + + private static List> list; + private static Map map; + + private static Handler handler; + + private static DatabaseHandler historyHandler; + + private static Drawable inactive; + + private static Drawable active; + + private static LinearLayout tabLayout; + + @SuppressWarnings("unused") + private static void setFavicon(int id, Bitmap favicon) { + Drawable icon = null; + icon = new BitmapDrawable(null, favicon); + icon.setBounds(0, 0, width / 2, height / 2); + if (icon != null) { + urlTitle[id].setCompoundDrawables(icon, null, exitTab, null); + } else { + urlTitle[id] + .setCompoundDrawables(webpageOther, null, exitTab, null); + } + } + + @SuppressLint("SetJavaScriptEnabled") + CustomWebView browserSettings(CustomWebView view) { + view.setAnimationCacheEnabled(false); + view.setDrawingCacheEnabled(false); + view.setDrawingCacheBackgroundColor(getResources().getColor( + android.R.color.background_light)); + // view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); + + view.setWillNotCacheDrawing(true); + view.setFocusable(true); + view.setFocusableInTouchMode(true); + view.setSaveEnabled(true); + + WebSettings webViewSettings = view.getSettings(); + + boolean java = settings.getBoolean("java", true); + if (java) { + webViewSettings.setJavaScriptEnabled(true); + webViewSettings.setJavaScriptCanOpenWindowsAutomatically(false); + } + webViewSettings.setBlockNetworkImage(false); + webViewSettings.setAllowFileAccess(true); + webViewSettings.setLightTouchEnabled(true); + webViewSettings.setSupportMultipleWindows(false); + webViewSettings.setDomStorageEnabled(true); + webViewSettings.setAppCacheEnabled(true); + webViewSettings.setAppCachePath(getApplicationContext().getFilesDir() + .getAbsolutePath() + "/incognito_cache"); + webViewSettings.setRenderPriority(RenderPriority.HIGH); + webViewSettings.setGeolocationEnabled(true); + webViewSettings.setGeolocationDatabasePath(getApplicationContext() + .getFilesDir().getAbsolutePath()+"/incognito_geolocation"); + webViewSettings.setDatabaseEnabled(true); + webViewSettings.setDatabasePath(getApplicationContext().getFilesDir() + .getAbsolutePath() + "/incognito_databases"); + enableFlash = settings.getInt("enableflash", 0); + switch (enableFlash) { + case 0: + break; + case 1: { + webViewSettings.setPluginState(PluginState.ON_DEMAND); + break; + } + case 2: { + webViewSettings.setPluginState(PluginState.ON); + break; + } + default: + break; + } + + webViewSettings.setUserAgentString(userAgent); + webViewSettings.setSavePassword(false); + webViewSettings.setSaveFormData(false); + + webViewSettings.setBuiltInZoomControls(true); + webViewSettings.setSupportZoom(true); + webViewSettings.setUseWideViewPort(true); + webViewSettings.setLoadWithOverviewMode(true); // Seems to be causing + // the performance + // to drop + if (API >= 11) { + webViewSettings.setDisplayZoomControls(false); + webViewSettings.setAllowContentAccess(true); + } + webViewSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL); + 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) { + main[del].stopLoading(); + main[del].clearHistory(); + main[del].clearView(); + urlToLoad[del][0] = null; + urlToLoad[del][1] = null; + if (API >= 11) { + main[del].onPause(); + } + + // background.clearDisappearingChildren(); + 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() { + + @Override + public void onAnimationEnd(Animation animation) { + urlTitle[del].setVisibility(View.GONE); + findNewView(del); + main[del] = null; + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationStart(Animation animation) { + } + + }); + urlTitle[del].startAnimation(yolo); + + } + + @SuppressWarnings("deprecation") + void findNewView(int id) { + int leftId = id; + boolean right = false, left = false; + if (id == pageId) { + + if (main[id].isShown()) { + background.removeView(main[id]); + } + for (; id <= (number - 1); id++) { + if (urlTitle[id].isShown()) { + background.addView(main[id]); + main[id].setVisibility(View.VISIBLE); + uBar.bringToFront(); + if (API < 16) { + urlTitle[id].setBackgroundDrawable(active); + } else { + urlTitle[id].setBackground(active); + } + urlTitle[id].setPadding(leftPad, 0, rightPad, 0); + pageId = id; + setUrlText(urlToLoad[pageId][0]); + getUrl.setPadding(tenPad, 0, tenPad, 0); + right = true; + break; + } + + } + if (!right) { + for (; leftId >= 0; leftId--) { + + if (urlTitle[leftId].isShown()) { + background.addView(main[leftId]); + main[leftId].setVisibility(View.VISIBLE); + // uBar.bringToFront(); + if (API < 16) { + urlTitle[leftId].setBackgroundDrawable(active); + } else { + urlTitle[leftId].setBackground(active); + } + urlTitle[leftId].setPadding(leftPad, 0, rightPad, 0); + pageId = leftId; + setUrlText(urlToLoad[pageId][0]); + getUrl.setPadding(tenPad, 0, tenPad, 0); + left = true; + break; + } + + } + + } + + } else { + right = left = true; + } + + if (!(right || left)) { + finish(); + } + tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0); + } + + void enter() { + getUrl.setOnKeyListener(new OnKeyListener() { + + @Override + public boolean onKey(View arg0, int arg1, KeyEvent arg2) { + + switch (arg1) { + case KeyEvent.KEYCODE_ENTER: + query = getUrl.getText().toString(); + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); + testForSearch(); + return true; + default: + break; + } + return false; + } + + }); + getUrl.setOnEditorActionListener(new OnEditorActionListener() { + + @Override + public boolean onEditorAction(TextView arg0, int actionId, + KeyEvent arg2) { + if (actionId == EditorInfo.IME_ACTION_GO + || actionId == EditorInfo.IME_ACTION_DONE + || actionId == EditorInfo.IME_ACTION_NEXT + || actionId == EditorInfo.IME_ACTION_SEND + || actionId == EditorInfo.IME_ACTION_SEARCH + || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) { + query = getUrl.getText().toString(); + InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0); + testForSearch(); + return true; + } + return false; + } + + }); + } + + @SuppressLint("HandlerLeak") + void enterUrl() { + getUrl = (MultiAutoCompleteTextView) findViewById(R.id.enterUrl); + getUrl.setPadding(tenPad, 0, tenPad, 0); + getUrl.setTextColor(getResources().getColor(android.R.color.black)); + getUrl.setPadding(tenPad, 0, tenPad, 0); + getUrl.setBackgroundResource(R.drawable.book); + getUrl.setPadding(tenPad, 0, tenPad, 0); + handler = new Handler() { + + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case 1: { + adapter = new SimpleAdapter(CONTEXT, list, + R.layout.two_line_autocomplete, new String[] { + "title", "url" }, new int[] { R.id.title, + R.id.url }); + + getUrl.setAdapter(adapter); + + break; + } + case 2: { + + break; + } + } + } + }; + + Thread updateAutoComplete = new Thread(new Runnable() { + + @Override + public void run() { + + Cursor managedCursor = null; + columns = new String[] { "url", "title" }; + try { + + managedCursor = null; + SQLiteDatabase s = historyHandler.getReadableDatabase(); + managedCursor = s.query("history", // URI + // of + columns, // Which columns to return + null, // Which rows to return (all rows) + null, // Selection arguments (none) + null, null, null); + + handler.sendEmptyMessage(1); + + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { + } + + list = new ArrayList>(); + try { + if (managedCursor != null) { + + if (managedCursor.moveToLast()) { + + // Variable for holding the retrieved URL + + urlColumn = managedCursor.getColumnIndex("url"); + titleColumn = managedCursor.getColumnIndex("title"); + // Reference to the the column containing the URL + do { + urlA = managedCursor.getString(urlColumn); + title = managedCursor.getString(titleColumn); + map = new HashMap(); + map.put("title", title); + map.put("url", urlA); + list.add(map); + } while (managedCursor.moveToPrevious()); + } + } + } catch (SQLiteException ignored) { + } catch (NullPointerException ignored) { + } catch (IllegalStateException ignored) { + } + managedCursor.close(); + } + + }); + updateAutoComplete.setPriority(3); + try { + updateAutoComplete.start(); + } catch (NullPointerException ignored) { + } catch (SQLiteMisuseException ignored) { + } catch (IllegalStateException ignored) { + } + + getUrl.setThreshold(2); + getUrl.setTokenizer(new SpaceTokenizer()); + getUrl.setOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(AdapterView arg0, View arg1, int arg2, + long arg3) { + try { + txt = (TextView) arg1.findViewById(R.id.url); + str = txt.getText().toString(); + main[pageId].loadUrl(str); + setUrlText(str); + 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: ", + "NullPointerException on item click"); + } + } + + }); + + getUrl.setSelectAllOnFocus(true); // allows edittext to select all when + // clicked + } + + void back() { + ImageView exit = (ImageView) findViewById(R.id.exit); + exit.setBackgroundResource(R.drawable.button); + if (isPhone) { + RelativeLayout relativeLayout1 = (RelativeLayout) findViewById(R.id.relativeLayout1); + relativeLayout1.removeView(exit); + } + exit.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + + if (main[pageId].canGoBack()) { + main[pageId].goBack(); + } else { + deleteTab(pageId); + } + + } + + }); + exit.setOnLongClickListener(new OnLongClickListener() { + + @Override + public boolean onLongClick(View v) { + finish(); + return true; + } + + }); + + } + + @Override + public void finish() { + background.clearDisappearingChildren(); + tabScroll.clearDisappearingChildren(); + main[0].clearCache(true); + cookieManager.setAcceptCookie(true); + super.finish(); + } + + void forward() { + ImageView forward = (ImageView) findViewById(R.id.forward); + forward.setBackgroundResource(R.drawable.button); + if (isPhone) { + RelativeLayout relativeLayout1 = (RelativeLayout) findViewById(R.id.relativeLayout1); + relativeLayout1.removeView(forward); + } + forward.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + if (main[pageId].canGoForward()) { + main[pageId].goForward(); + } + } + + }); + } + + void goBookmarks(CustomWebView view) { + File book = new File(getBaseContext().getFilesDir(), "bookmarks"); + File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); + try { + BufferedReader readBook = new BufferedReader(new FileReader(book)); + BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl)); + String t, u; + int n = 0; + while ((t = readBook.readLine()) != null + && (u = readUrl.readLine()) != null && n < MAX_BOOKMARKS) { + bUrl[n] = u; + bTitle[n] = t; + + n++; + } + readBook.close(); + readUrl.close(); + } catch (FileNotFoundException ignored) { + } catch (IOException ignored) { + } + openBookmarks(view); + } + + @SuppressLint("InlinedApi") + void init() { + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + historyHandler = new DatabaseHandler(this); + CookieSyncManager.createInstance(CONTEXT); + cookieManager = CookieManager.getInstance(); + cookieManager.setAcceptCookie(false); + + progressBar = (ProgressBar) findViewById(R.id.progressBar1); + if (API >= 11) { + progressBar.setIndeterminateDrawable(getResources().getDrawable( + R.drawable.ics_animation)); + } else { + progressBar.setIndeterminateDrawable(getResources().getDrawable( + R.drawable.ginger_animation)); + } + + showFullScreen = settings.getBoolean("fullscreen", false); + uBar = (RelativeLayout) findViewById(R.id.urlBar); + RelativeLayout bg = (RelativeLayout) findViewById(R.id.background); + 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); + fadeIn = AnimationUtils.loadAnimation(this, android.R.anim.fade_in); + mShortAnimationDuration = getResources().getInteger( + android.R.integer.config_mediumAnimTime); + slideUp.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationEnd(Animation arg0) { + + uBar.setVisibility(View.GONE); + } + + @Override + public void onAnimationRepeat(Animation arg0) { + + } + + @Override + public void onAnimationStart(Animation arg0) { + + } + + }); + slideDown.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationEnd(Animation animation) { + + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + + @Override + public void onAnimationStart(Animation animation) { + + uBar.setVisibility(View.VISIBLE); + } + + }); + + RelativeLayout refreshLayout = (RelativeLayout) findViewById(R.id.refreshLayout); + refreshLayout.setBackgroundResource(R.drawable.button); + + // user agent + user = new WebView(CONTEXT).getSettings().getUserAgentString(); + + background = (FrameLayout) findViewById(R.id.holder); + mobile = user; // setting mobile user + // agent + desktop = FinalVars.DESKTOP_USER_AGENT; // setting + // desktop user agent + exitTab = getResources().getDrawable(R.drawable.stop); // user + // agent + homepage = settings.getString("home", HOMEPAGE); // initializing + // the + // stored + // homepage + // variable + + userAgent = settings.getString("agent", mobile); // initializing + // useragent string + allowLocation = settings.getBoolean("location", false); // initializing + // location + // variable + + enableFlash = settings.getInt("enableflash", 0); // enable flash + // boolean + agentPicker = settings.getInt("agentchoose", 1); // which user agent to + // use, 1=mobile, + // 2=desktop, + // 3=custom + + + // initializing variables declared + + height = getResources().getDrawable(R.drawable.loading) + .getMinimumHeight(); + width = getResources().getDrawable(R.drawable.loading) + .getMinimumWidth(); + + // hides keyboard so it doesn't default pop up + this.getWindow().setSoftInputMode( + WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); + + // opens icondatabase so that favicons can be stored + WebIconDatabase.getInstance().open( + getDir("icons", MODE_PRIVATE).getPath()); + + // scroll view containing tabs + tabLayout = (LinearLayout) findViewById(R.id.tabLayout); + tabScroll = (HorizontalScrollView) findViewById(R.id.tabScroll); + tabScroll.setBackgroundColor(getResources().getColor(R.color.black)); + tabScroll.setHorizontalScrollBarEnabled(false); + if (API > 8) { + tabScroll.setOverScrollMode(View.OVER_SCROLL_NEVER); // disallow + //overscroll + } + + // image dimensions and initialization + final int dps = 175; + final float scale = getApplicationContext().getResources() + .getDisplayMetrics().density; + pixels = (int) (dps * scale + 0.5f); + leftPad = (int) (17 * scale + 0.5f); + rightPad = (int) (15 * scale + 0.5f); + height32 = (int) (32 * scale + 0.5f); + 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); + + Thread startup = new Thread(new Runnable() { + + @Override + public void run() { + initializeTabs(); // restores old tabs or creates a new one + + } + + }); + startup.run(); + + // new tab button + ImageView newTab = (ImageView) findViewById(R.id.newTab); + newTab.setBackgroundResource(R.drawable.button); + newTab.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + newTab(number, homepage, true, true); + tabScroll.postDelayed(new Runnable() { + public void run() { + tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0); + } + }, 100L); + + } + }); + refresh = (ImageView) findViewById(R.id.refresh); + refreshLayout.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View arg0) { + + if (pageIsLoading) { + main[pageId].stopLoading(); + } else { + main[pageId].reload(); + } + } + + }); + + enterUrl(); + if (showFullScreen) { + bg.removeView(uBar); + background.addView(uBar); + } + + } + + 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, true); + main[number - 1].resumeTimers(); + + } else { + // otherwise it opens the homepage + newTab(number, homepage, true, true); + main[number - 1].resumeTimers(); + + } + + } + + private CustomWebView makeTab(final int pageToView, final String Url, + final boolean display) { + CustomWebView view = new CustomWebView(CONTEXT); + view.setId(pageToView); + allowLocation = settings.getBoolean("location", false); + view.setWebViewClient(new CustomWebViewClient()); + view.setWebChromeClient(new CustomChromeClient()); + if (API > 8) { + view.setDownloadListener(new CustomDownloadListener()); + } + + view.setOnLongClickListener(new WebPageLongClickListener()); + view = browserSettings(view); + agentPicker = settings.getInt("agentchoose", 1); + switch (agentPicker) { + case 1: + view.getSettings().setUserAgentString(mobile); + break; + case 2: + view.getSettings().setUserAgentString(desktop); + break; + case 3: + userAgent = settings.getString("agent", user); + view.getSettings().setUserAgentString(userAgent); + break; + } + if (display) { + background.removeView(main[pageId]); + background.addView(view); + view.requestFocus(); + pageId = pageToView; + } + uBar.bringToFront(); + if (Url.contains("about:home")) { + goBookmarks(view); + } else if (Url.contains("about:blank")) { + + view.loadUrl("about:blank"); + + } else { + + view.loadUrl(Url); + + } + Log.i("IncognitoMode", "tab complete"); + return view; + } + + void newSettings() { + Intent set = new Intent(FinalVars.SETTINGS_INTENT); + startActivity(set); + } + + // 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"); + + int finalID = 0; + homepage = settings.getString("home", HOMEPAGE); + allowLocation = settings.getBoolean("location", false); + boolean isEmptyWebViewAvailable = false; + + for (int num = 0; num < number; num++) { + if (urlTitle[num].getVisibility() == View.GONE) { + + final int n = num; + Animation holo = AnimationUtils.loadAnimation(this, R.anim.up); + holo.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationEnd(Animation animation) { + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationStart(Animation animation) { + urlTitle[n].setVisibility(View.VISIBLE); + } + + }); + urlTitle[n].startAnimation(holo); + urlTitle[num].setText("New Tab"); + if (display) { + if (API < 16) { + urlTitle[num].setBackgroundDrawable(active); + } else { + urlTitle[num].setBackground(active); + } + } else { + if (API < 16) { + urlTitle[num].setBackgroundDrawable(inactive); + } else { + urlTitle[num].setBackground(inactive); + } + } + urlTitle[num].setPadding(leftPad, 0, rightPad, 0); + if (display) { + if (API < 16) { + urlTitle[pageId].setBackgroundDrawable(inactive); + } else { + urlTitle[pageId].setBackground(inactive); + } + } + urlTitle[pageId].setCompoundDrawables(webpageOther, null, + exitTab, null); + urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); + main[num] = makeTab(num, theUrl, display); + finalID = num; + pageId = num; + + uBar.bringToFront(); + + if (API >= 11) { + main[num].onResume(); + } + + isEmptyWebViewAvailable = true; + break; + } + } + if (!isEmptyWebViewAvailable) { + if (number < MAX_TABS) { + if (number > 0) { + if (display) { + if (API < 16) { + urlTitle[pageId].setBackgroundDrawable(inactive); + } else { + urlTitle[pageId].setBackground(inactive); + } + + urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); + } + } + final TextView title = new TextView(CONTEXT); + title.setText("New Tab"); + if (display) { + if (API < 16) { + title.setBackgroundDrawable(active); + } else { + title.setBackground(active); + } + } else { + if (API < 16) { + title.setBackgroundDrawable(inactive); + } else { + title.setBackground(inactive); + } + } + title.setSingleLine(true); + title.setGravity(Gravity.CENTER_VERTICAL); + title.setHeight(height32); + title.setWidth(pixels); + title.setPadding(leftPad, 0, rightPad, 0); + title.setId(number); + title.setGravity(Gravity.CENTER_VERTICAL); + + title.setCompoundDrawables(incognitoPage, null, exitTab, + null); + + Drawable[] drawables = title.getCompoundDrawables(); + bounds = drawables[2].getBounds(); + title.setOnTouchListener(new TabTouchListener()); + Animation holo = AnimationUtils.loadAnimation(this, R.anim.up); + tabLayout.addView(title); + title.setVisibility(View.INVISIBLE); + holo.setAnimationListener(new AnimationListener() { + + @Override + public void onAnimationEnd(Animation animation) { + } + + @Override + public void onAnimationRepeat(Animation animation) { + } + + @Override + public void onAnimationStart(Animation animation) { + title.setVisibility(View.VISIBLE); + } + + }); + title.startAnimation(holo); + urlTitle[number] = title; + + urlTitle[number].setText("Incognito"); + + + if (theUrl != null) { + main[number] = makeTab(number, theUrl, display); + } else { + main[number] = makeTab(number, homepage, display); + } + finalID = number; + number = number + 1; + } + } + if (!isEmptyWebViewAvailable && number >= MAX_TABS) { + Toast.makeText(CONTEXT, "Maximum number of tabs reached...", + Toast.LENGTH_SHORT).show(); + } + return finalID; + + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, + Intent intent) { + if (requestCode == 1) { + if (null == mUploadMessage) + return; + Uri result = intent == null || resultCode != RESULT_OK ? null + : intent.getData(); + mUploadMessage.onReceiveValue(result); + mUploadMessage = null; + + } + } + + @Override + public void onBackPressed() { + if (main[pageId].canGoBack()) { + main[pageId].goBack(); + } else { + deleteTab(pageId); + uBar.bringToFront(); + } + + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + main[pageId].getSettings().setLayoutAlgorithm( + LayoutAlgorithm.NORMAL); + // main[pageId].invalidate(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); // displays main xml layout + settings = getSharedPreferences(preferences, 0); + edit = settings.edit(); + + + inactive = getResources().getDrawable(R.drawable.bg_inactive); + active = getResources().getDrawable(R.drawable.bg_press); + init(); // sets up random stuff + options(); // allows options to be opened + enter();// enter url bar + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + float widthInInches = metrics.widthPixels / metrics.xdpi; + float heightInInches = metrics.heightPixels / metrics.ydpi; + double sizeInInches = Math.sqrt(Math.pow(widthInInches, 2) + + Math.pow(heightInInches, 2)); + // 0.5" buffer for 7" devices + 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 + public boolean onCreateOptionsMenu(Menu menu) { + + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.incognito_menu, menu); + + return true; + } + + @Override + public boolean onKeyLongPress(int keyCode, KeyEvent event) { + + if (keyCode == KeyEvent.KEYCODE_BACK) { + finish(); + return true; + } + return super.onKeyLongPress(keyCode, event); + } + + @Override + protected void onNewIntent(Intent intent) { + + String url = intent.getDataString(); + if (url != null) { + newTab(number, url, true, true); + } + super.onNewIntent(intent); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + switch (item.getItemId()) { + case R.id.history: + generateHistory(main[pageId]); + return true; + case R.id.bookmark: + return true; + case R.id.settings: + return true; + case R.id.allBookmarks: + if (!urlToLoad[pageId][1].equals("Bookmarks")) { + goBookmarks(main[pageId]); + } + return true; + case R.id.share: + return true; + case R.id.incognito: + newTab(number, homepage, true, true); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + protected void onPause() { + if (main[pageId] != null) { + if (API >= 11) { + main[pageId].onPause(); + } + main[pageId].pauseTimers(); + } + super.onPause(); + } + + @Override + protected void onResume() { + super.onResume(); + if (API >= 11) { + main[pageId].onResume(); + } + main[0].resumeTimers(); + + } + + void openBookmarks(CustomWebView view) { + String bookmarkHtml = BookmarkPage.Heading; + for (int n = 0; n < MAX_BOOKMARKS; n++) { + if (bUrl[n] != null) { + bookmarkHtml += (BookmarkPage.Part1 + bUrl[n] + + BookmarkPage.Part2 + bUrl[n] + BookmarkPage.Part3 + + bTitle[n] + BookmarkPage.Part4); + } + } + bookmarkHtml += BookmarkPage.End; + File bookmarkWebPage = new File(getBaseContext().getFilesDir(), + "bookmarks.html"); + try { + FileWriter bookWriter = new FileWriter(bookmarkWebPage, false); + bookWriter.write(bookmarkHtml); + bookWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + view.loadUrl("file:///" + bookmarkWebPage); + + if (uBar.isShown()) { + urlTitle[pageId].setText("Bookmarks"); + setUrlText(""); + getUrl.setPadding(tenPad, 0, tenPad, 0); + } + + } + + void options() { + ImageView options = (ImageView) findViewById(R.id.options); + options.setBackgroundResource(R.drawable.button); + options.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + + if (API >= 11) { + PopupMenu menu = new PopupMenu(CONTEXT, v); + MenuInflater inflate = menu.getMenuInflater(); + inflate.inflate(R.menu.incognito_menu, menu.getMenu()); + menu.setOnMenuItemClickListener(new OnMenuItemClickListener() { + + @Override + public boolean onMenuItemClick(MenuItem item) { + + switch (item.getItemId()) { + case R.id.history: + generateHistory(main[pageId]); + return true; + case R.id.bookmark: + return true; + case R.id.settings: + return true; + case R.id.allBookmarks: + if (!urlToLoad[pageId][1].equals("Bookmarks")) { + goBookmarks(main[pageId]); + } + return true; + case R.id.share: + return true; + case R.id.incognito: + newTab(number, homepage, true, true); + return true; + default: + return false; + } + + } + + }); + menu.show(); + } else if (API < 11) { + + openOptionsMenu(); + } + } + + }); + options.setOnLongClickListener(new OnLongClickListener() { + + @Override + public boolean onLongClick(View arg0) { + return true; + } + + }); + } + + void testForSearch() { + String fixedQuery = query.trim(); + main[pageId].stopLoading(); + boolean period = fixedQuery.contains("."); + + if (fixedQuery.contains("about:home") + || fixedQuery.contains("about:bookmarks")) { + goBookmarks(main[pageId]); + } else if (fixedQuery.contains("about:history")) { + generateHistory(main[pageId]); + } else if (fixedQuery.contains(" ") || !period) { + fixedQuery.replaceAll(" ", "+"); + main[pageId].loadUrl(SEARCH + fixedQuery); + } else if (!fixedQuery.contains("http//") + && !fixedQuery.contains("https//") + && !fixedQuery.contains("http://") + && !fixedQuery.contains("https://")) { + fixedQuery = "http://" + fixedQuery; + main[pageId].loadUrl(fixedQuery); + } else { + fixedQuery = fixedQuery.replaceAll("http//", "http://"); + fixedQuery = fixedQuery.replaceAll("https//", "https://"); + main[pageId].loadUrl(fixedQuery); + } + } + + void trimCache(Context context) { + try { + File dir = context.getCacheDir(); + + if (dir != null && dir.isDirectory()) { + deleteDir(dir); + } + } catch (Exception ignored) { + + } + } +} diff --git a/src/acr/browser/barebones/Settings.java b/src/acr/browser/barebones/Settings.java index 19ba7d6..9ff720a 100644 --- a/src/acr/browser/barebones/Settings.java +++ b/src/acr/browser/barebones/Settings.java @@ -25,14 +25,20 @@ import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; public class Settings extends Activity { - public static final String preferences = "settings"; - static boolean allowLocation, deleteHistory; - static int enableFlash; - static boolean savePasswords, fullScreen, java, saveTabs; - static String userAgent, homepage; - static EditText agent,h; - static SharedPreferences.Editor edit; - static int agentPicker; + private static final String preferences = "settings"; + private static boolean allowLocation; + private static boolean deleteHistory; + private static int enableFlash; + private static boolean savePasswords; + private static boolean fullScreen; + private static boolean java; + private static boolean saveTabs; + private static String userAgent; + private static String homepage; + private static EditText agent; + private static EditText h; + private static SharedPreferences.Editor edit; + private static int agentPicker; @Override public void onCreate(Bundle savedInstanceState) { @@ -132,7 +138,7 @@ public class Settings extends Activity { java(); } - public void saveTabs(){ + void saveTabs(){ final CheckBox tab = (CheckBox)findViewById(R.id.saveTabs); if(saveTabs){ tab.setChecked(true); @@ -157,7 +163,7 @@ public class Settings extends Activity { }); } - public void getHome() { + void getHome() { h = (EditText) findViewById(R.id.homePage); TextView t = (TextView) findViewById(R.id.textView3); @@ -177,7 +183,7 @@ public class Settings extends Activity { String home; home = h.getText().toString(); if(!home.contains("about:blank")&&!home.contains("about:home")){ - if(home.contains("http://")==false&&home.contains("https://")==false){ + if(!home.contains("http://") && !home.contains("https://")){ home = "http://"+home; }} edit.putString("home", home); @@ -201,7 +207,7 @@ public class Settings extends Activity { || actionId == EditorInfo.IME_ACTION_SEND||actionId==EditorInfo.IME_ACTION_SEARCH||event.getAction()==KeyEvent.KEYCODE_ENTER) { String home = h.getText().toString(); if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){ - if(h.getText().toString().contains("http://")==false&&h.getText().toString().contains("https://")==false){ + if(!h.getText().toString().contains("http://") && !h.getText().toString().contains("https://")){ home = "http://"+h.getText().toString(); }} edit.putString("home", home); @@ -245,7 +251,7 @@ public class Settings extends Activity { } - public void back() { + void back() { ImageView back = (ImageView) findViewById(R.id.back); back.setBackgroundResource(R.drawable.button); back.setOnClickListener(new OnClickListener() { @@ -260,7 +266,7 @@ public class Settings extends Activity { } String home = h.getText().toString(); if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){ - if(h.getText().toString().contains("http://")==false&&h.getText().toString().contains("https://")==false){ + if(!h.getText().toString().contains("http://") && !h.getText().toString().contains("https://")){ home = "http://"+h.getText().toString(); }} edit.putString("home", home); @@ -270,7 +276,7 @@ public class Settings extends Activity { }); } - public void java(){ + void java(){ final CheckBox full = (CheckBox)findViewById(R.id.java); if(java){ full.setChecked(true); @@ -294,7 +300,7 @@ public class Settings extends Activity { }); } -public void full(){ +void full(){ final CheckBox full = (CheckBox)findViewById(R.id.fullScreen); if(fullScreen){ full.setChecked(true); @@ -318,7 +324,7 @@ public void full(){ }); } - public void flash() { + void flash() { final CheckBox fla = (CheckBox) findViewById(R.id.flash); if (enableFlash == 1||enableFlash==2) { fla.setChecked(true); @@ -384,9 +390,9 @@ public void full(){ }); } - public void location() { + void location() { CheckBox loc = (CheckBox) findViewById(R.id.location); - if (allowLocation == true) { + if (allowLocation) { loc.setChecked(true); } else { loc.setChecked(false); @@ -409,7 +415,7 @@ public void full(){ } - public void getText() { + void getText() { agent.setOnKeyListener(new OnKeyListener(){ @Override @@ -452,9 +458,9 @@ public void full(){ }); } - public void passwords() { + void passwords() { CheckBox pass = (CheckBox) findViewById(R.id.password); - if (savePasswords == true) { + if (savePasswords) { pass.setChecked(true); } else { pass.setChecked(false); @@ -476,9 +482,9 @@ public void full(){ }); } - public void clearHistory() { + void clearHistory() { CheckBox clearHist = (CheckBox) findViewById(R.id.historyClear); - if (deleteHistory == true) { + if (deleteHistory) { clearHist.setChecked(true); } else { clearHist.setChecked(false); @@ -511,7 +517,7 @@ public void full(){ } String home = h.getText().toString(); if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){ - if(h.getText().toString().contains("http://")==false&&h.getText().toString().contains("https://")==false){ + if(!h.getText().toString().contains("http://") && !h.getText().toString().contains("https://")){ home = "http://"+h.getText().toString(); }} edit.putString("home", home); diff --git a/src/acr/browser/barebones/SpaceTokenizer.java b/src/acr/browser/barebones/SpaceTokenizer.java new file mode 100644 index 0000000..ba03e88 --- /dev/null +++ b/src/acr/browser/barebones/SpaceTokenizer.java @@ -0,0 +1,61 @@ +package acr.browser.barebones; + +import android.text.SpannableString; +import android.text.Spanned; +import android.text.TextUtils; +import android.widget.MultiAutoCompleteTextView.Tokenizer; + +public class SpaceTokenizer implements Tokenizer { + + @Override + public int findTokenEnd(CharSequence text, int cursor) { + int i = cursor; + int len = text.length(); + + while (i < len) { + if (text.charAt(i) == ' ') { + return i; + } else { + i++; + } + } + + return len; + } + + @Override + public int findTokenStart(CharSequence text, int cursor) { + int i = cursor; + + while (i > 0 && text.charAt(i - 1) != ' ') { + i--; + } + while (i < cursor && text.charAt(i) == ' ') { + i++; + } + + return i; + } + + @Override + public CharSequence terminateToken(CharSequence text) { + int i = text.length(); + + while (i > 0 && text.charAt(i - 1) == ' ') { + i--; + } + + if (i > 0 && text.charAt(i - 1) == ' ') { + return text; + } else { + if (text instanceof Spanned) { + SpannableString sp = new SpannableString(text + " "); + TextUtils.copySpansFrom((Spanned) text, 0, text.length(), + Object.class, sp, 0); + return sp; + } else { + return text + " "; + } + } + } +}