Browse Source

2.5.0.1

FIxed full-screen video, changed some animations, changed icon, fixed
some problems with incognito mode
master
Anthony Restaino 12 years ago
parent
commit
6827bb9946
  1. 4
      AndroidManifest.xml
  2. 5
      README
  3. 11
      res/anim/slide_down.xml
  4. 12
      res/anim/slide_up.xml
  5. BIN
      res/drawable-hdpi/ic_launcher.png
  6. BIN
      res/drawable-mdpi/ic_launcher.png
  7. BIN
      res/drawable-xhdpi/ic_launcher.png
  8. 200
      src/acr/browser/barebones/Barebones.java
  9. 4
      src/acr/browser/barebones/BookmarkPage.java
  10. 51
      src/acr/browser/barebones/CustomWebView.java
  11. 4
      src/acr/browser/barebones/HistoryPage.java
  12. 409
      src/acr/browser/barebones/IncognitoMode.java
  13. 68
      src/acr/browser/barebones/IncognitoWebView.java
  14. 10
      src/acr/browser/barebones/SpaceTokenizer.java

4
AndroidManifest.xml

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

5
README

@ -2,8 +2,3 @@ This is an open source webkit based browser. @@ -2,8 +2,3 @@ This is an open source webkit based browser.
I make money off a similar paid version which currently has unlimited tabs and unlimited bookmarks. Modifiying two values at the top of the main activity "barebones" will turn this into the paid version.
Change static public int MAX_TABS and MAX_BOOKMARKS from 5 to 50 and you have the paid version.
Current issues:
- it doesn't open apps that belong to links like market:// youtube:// etc...
- can't set bookmarks as default view in fullscreen

11
res/anim/slide_down.xml

@ -1,8 +1,11 @@ @@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="-50%p"
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromYDelta="-50%" android:toYDelta="0"
android:interpolator="@android:anim/decelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime"/>
<alpha android:fromAlpha="0.25" android:toAlpha="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toYDelta="0%p" android:duration="500" />
android:duration="@android:integer/config_shortAnimTime" />
</set>

12
res/anim/slide_up.xml

@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate android:fromYDelta="0%p"
android:toYDelta="-50%p"
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromYDelta="0" android:toYDelta="-50%"
android:interpolator="@android:anim/decelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.25"
android:interpolator="@android:anim/linear_interpolator"
android:duration="500" />
android:duration="@android:integer/config_shortAnimTime" />
</set>

BIN
res/drawable-hdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
res/drawable-mdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
res/drawable-xhdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

200
src/acr/browser/barebones/Barebones.java

@ -11,6 +11,7 @@ import java.util.ArrayList; @@ -11,6 +11,7 @@ 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;
@ -53,6 +54,7 @@ import android.view.View.OnClickListener; @@ -53,6 +54,7 @@ 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;
@ -99,6 +101,8 @@ public class Barebones extends Activity { @@ -99,6 +101,8 @@ public class Barebones extends Activity {
public class CustomChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster;
private View mVideoProgressView;
private FrameLayout fullScreenContainer;
private int orientation;
@Override
public void onExceededDatabaseQuota(String url,
@ -113,12 +117,13 @@ public class Barebones extends Activity { @@ -113,12 +117,13 @@ public class Barebones extends Activity {
@Override
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(quota+requiredStorage);
quotaUpdater.updateQuota(quota + requiredStorage);
super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
}
@Override
public void onCloseWindow(WebView window) {
closeWindow = window.getId();
browserHandler.sendEmptyMessage(2);
super.onCloseWindow(window);
}
@ -146,11 +151,12 @@ public class Barebones extends Activity { @@ -146,11 +151,12 @@ public class Barebones extends Activity {
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, final Message resultMsg) {
newTab(number,"",true,false);
newTab(number, "", true, false);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(main[pageId]);
resultMsg.sendToTarget();
browserHandler.postDelayed(new Runnable() {
@Override
public void run() {
main[pageId].loadUrl(getUrl.getText().toString());
}
@ -166,14 +172,12 @@ public class Barebones extends Activity { @@ -166,14 +172,12 @@ public class Barebones extends Activity {
callback.invoke(origin, false, false);
}
if (allowLocation) {
Log.i("Barebones: ", "onGeolocationPermissionsShowPrompt()");
final boolean remember = true;
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT);
builder.setTitle("Locations");
String org = (String) origin.subSequence(0, 50);
builder.setMessage(
origin + " Would like to use your Current Location ")
org + " Would like to use your Current Location ")
.setCancelable(true)
.setPositiveButton("Allow",
new DialogInterface.OnClickListener() {
@ -198,23 +202,19 @@ public class Barebones extends Activity { @@ -198,23 +202,19 @@ public class Barebones extends Activity {
@Override
public void onHideCustomView() {
if (mCustomView == null)
if (mCustomView == null && mCustomViewCallback == null) {
return;
// Hide the custom view.
mCustomView.setVisibility(View.GONE);
// Remove the custom view from its container.
background.removeView(mCustomView);
}
mCustomView.setKeepScreenOn(false);
FrameLayout screen = (FrameLayout) getWindow().getDecorView();
screen.removeView(fullScreenContainer);
fullScreenContainer = null;
mCustomView = null;
background.setVisibility(View.VISIBLE);
uBar.setVisibility(View.VISIBLE);
mCustomViewCallback.onCustomViewHidden();
main[pageId].setVisibility(View.VISIBLE);
// Log.i(LOGTAG, "set it to webVew");
setRequestedOrientation(orientation);
background.addView(main[pageId]);
uBar.setVisibility(View.VISIBLE);
uBar.bringToFront();
}
@Override
@ -239,36 +239,50 @@ public class Barebones extends Activity { @@ -239,36 +239,50 @@ public class Barebones extends Activity {
@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);
view.setKeepScreenOn(true);
orientation = getRequestedOrientation();
FrameLayout screen = (FrameLayout) getWindow().getDecorView();
fullScreenContainer = new FrameLayout(getBaseContext());
fullScreenContainer.setBackgroundColor(getResources().getColor(
R.color.black));
background.removeView(main[pageId]);
uBar.setVisibility(View.GONE);
fullScreenContainer.addView(view,
ViewGroup.LayoutParams.MATCH_PARENT);
screen.addView(fullScreenContainer,
ViewGroup.LayoutParams.MATCH_PARENT);
mCustomView = view;
mCustomViewCallback = callback;
background.setVisibility(View.VISIBLE);
setRequestedOrientation(requestedOrientation);
}
@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);
view.setKeepScreenOn(true);
orientation = getRequestedOrientation();
FrameLayout screen = (FrameLayout) getWindow().getDecorView();
fullScreenContainer = new FrameLayout(getBaseContext());
fullScreenContainer.setBackgroundColor(getResources().getColor(
R.color.black));
background.removeView(main[pageId]);
uBar.setVisibility(View.GONE);
fullScreenContainer.addView(view,
ViewGroup.LayoutParams.MATCH_PARENT);
screen.addView(fullScreenContainer,
ViewGroup.LayoutParams.MATCH_PARENT);
mCustomView = view;
mCustomViewCallback = callback;
background.setVisibility(View.VISIBLE);
setRequestedOrientation(getRequestedOrientation());
}
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
@ -278,8 +292,7 @@ public class Barebones extends Activity { @@ -278,8 +292,7 @@ public class Barebones extends Activity {
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
Barebones.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
1);
Intent.createChooser(i, "File Browser"), 1);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg,
@ -289,8 +302,7 @@ public class Barebones extends Activity { @@ -289,8 +302,7 @@ public class Barebones extends Activity {
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
Barebones.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
1);
Intent.createChooser(i, "File Browser"), 1);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg,
@ -300,8 +312,7 @@ public class Barebones extends Activity { @@ -300,8 +312,7 @@ public class Barebones extends Activity {
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
Barebones.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
1);
Intent.createChooser(i, "File Browser"), 1);
}
}
@ -356,8 +367,7 @@ public class Barebones extends Activity { @@ -356,8 +367,7 @@ public class Barebones extends Activity {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("market://")
|| url.contains("play.google.com")) {
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")) {
@ -370,15 +380,24 @@ public class Barebones extends Activity { @@ -370,15 +380,24 @@ public class Barebones extends Activity {
return false;
}
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
if (view != null) {
view.invalidate();
}
super.onScaleChanged(view, oldScale, newScale);
}
@Override
public void onPageFinished(WebView view, final String url) {
if (view.isShown()) {
if (view != null) {
view.invalidate();
}
if (view.isShown()) {
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
if(showFullScreen&&uBar.isShown()){
if (showFullScreen && uBar.isShown()) {
uBar.startAnimation(slideUp);
}
}
view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
@ -410,14 +429,14 @@ public class Barebones extends Activity { @@ -410,14 +429,14 @@ public class Barebones extends Activity {
getUrl.setPadding(tenPad, 0, tenPad, 0);
urlToLoad[numberPage][0] = url;
if (!uBar.isShown()&&showFullScreen) {
if (!uBar.isShown() && showFullScreen) {
uBar.startAnimation(slideDown);
}
}
@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler,
SslError error) {
public void onReceivedSslError(WebView view,
final SslErrorHandler handler, SslError error) {
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT);
builder.setTitle("Warning");
builder.setMessage(
@ -444,21 +463,12 @@ public class Barebones extends Activity { @@ -444,21 +463,12 @@ public class Barebones extends Activity {
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);
}
@Override
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?")
builder.setTitle("Form Resubmission");
builder.setMessage("Would you like to resend the data?")
.setCancelable(true)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
@ -658,6 +668,14 @@ public class Barebones extends Activity { @@ -658,6 +668,14 @@ public class Barebones extends Activity {
}
private void removeView(WebView view) {
if (!showFullScreen) {
view.startAnimation(fadeOut);
}
background.removeView(view);
uBar.bringToFront();
}
private void deleteBookmark(String url) {
File book = new File(getBaseContext().getFilesDir(), "bookmarks");
File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl");
@ -1000,11 +1018,12 @@ public class Barebones extends Activity { @@ -1000,11 +1018,12 @@ public class Barebones extends Activity {
File book = new File(getBaseContext().getFilesDir(), "bookmarks");
File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl");
try {
BufferedReader readUrlRead = new BufferedReader(new FileReader(bookUrl));
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])){
if (u.contentEquals(urlToLoad[pageId][0])) {
readUrlRead.close();
return;
@ -1089,7 +1108,6 @@ public class Barebones extends Activity { @@ -1089,7 +1108,6 @@ public class Barebones extends Activity {
webViewSettings.setSavePassword(true);
webViewSettings.setSaveFormData(true);
}
webViewSettings.setBuiltInZoomControls(true);
webViewSettings.setSupportZoom(true);
webViewSettings.setUseWideViewPort(true);
@ -1124,7 +1142,7 @@ public class Barebones extends Activity { @@ -1124,7 +1142,7 @@ public class Barebones extends Activity {
void deleteTab(final int del) {
main[del].stopLoading();
main[del].clearHistory();
main[del].clearView();
// main[del].clearView();
urlToLoad[del][0] = null;
urlToLoad[del][1] = null;
if (API >= 11) {
@ -1139,7 +1157,6 @@ public class Barebones extends Activity { @@ -1139,7 +1157,6 @@ public class Barebones extends Activity {
}
urlTitle[del].setPadding(leftPad, 0, rightPad, 0);
Animation yolo = AnimationUtils.loadAnimation(this, R.anim.down);
yolo.setAnimationListener(new AnimationListener() {
@Override
@ -1159,7 +1176,7 @@ public class Barebones extends Activity { @@ -1159,7 +1176,7 @@ public class Barebones extends Activity {
});
urlTitle[del].startAnimation(yolo);
uBar.bringToFront();
}
@SuppressWarnings("deprecation")
@ -1169,7 +1186,8 @@ public class Barebones extends Activity { @@ -1169,7 +1186,8 @@ public class Barebones extends Activity {
if (id == pageId) {
if (main[id].isShown()) {
background.removeView(main[id]);
// background.removeView(main[id]);
removeView(main[id]);
}
for (; id <= (number - 1); id++) {
if (urlTitle[id].isShown()) {
@ -1186,6 +1204,13 @@ public class Barebones extends Activity { @@ -1186,6 +1204,13 @@ public class Barebones extends Activity {
setUrlText(urlToLoad[pageId][0]);
getUrl.setPadding(tenPad, 0, tenPad, 0);
right = true;
if (main[id].getProgress() < 100) {
refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
}
break;
}
@ -1207,6 +1232,13 @@ public class Barebones extends Activity { @@ -1207,6 +1232,13 @@ public class Barebones extends Activity {
setUrlText(urlToLoad[pageId][0]);
getUrl.setPadding(tenPad, 0, tenPad, 0);
left = true;
if (main[leftId].getProgress() < 100) {
refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
}
break;
}
@ -1221,6 +1253,7 @@ public class Barebones extends Activity { @@ -1221,6 +1253,7 @@ public class Barebones extends Activity {
if (!(right || left)) {
finish();
}
uBar.bringToFront();
tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0);
}
@ -1379,7 +1412,7 @@ public class Barebones extends Activity { @@ -1379,7 +1412,7 @@ public class Barebones extends Activity {
} catch (IllegalStateException ignored) {
}
getUrl.setThreshold(2);
getUrl.setThreshold(1);
getUrl.setTokenizer(new SpaceTokenizer());
getUrl.setOnItemClickListener(new OnItemClickListener() {
@ -1395,7 +1428,6 @@ public class Barebones extends Activity { @@ -1395,7 +1428,6 @@ public class Barebones extends Activity {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
} catch (NullPointerException e) {
Log.e("Barebones Error: ",
"NullPointerException on item click");
}
@ -1636,7 +1668,7 @@ public class Barebones extends Activity { @@ -1636,7 +1668,7 @@ public class Barebones extends Activity {
tabScroll.setHorizontalScrollBarEnabled(false);
if (API > 8) {
tabScroll.setOverScrollMode(View.OVER_SCROLL_NEVER); // disallow
//overscroll
// overscroll
}
// image dimensions and initialization
@ -1650,7 +1682,6 @@ public class Barebones extends Activity { @@ -1650,7 +1682,6 @@ public class Barebones extends Activity {
tenPad = (int) (10 * scale + 0.5f);
number = 0;
webpageOther = getResources().getDrawable(R.drawable.webpage);
incognitoPage = getResources().getDrawable(R.drawable.incognito);
webpageOther.setBounds(0, 0, width / 2, height / 2);
@ -1676,6 +1707,7 @@ public class Barebones extends Activity { @@ -1676,6 +1707,7 @@ public class Barebones extends Activity {
public void onClick(View v) {
newTab(number, homepage, true, false);
tabScroll.postDelayed(new Runnable() {
@Override
public void run() {
tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0);
}
@ -1703,19 +1735,19 @@ public class Barebones extends Activity { @@ -1703,19 +1735,19 @@ public class Barebones extends Activity {
bg.removeView(uBar);
background.addView(uBar);
}
browserHandler = new Handler(){
browserHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch(msg.what){
case 1:{
switch (msg.what) {
case 1: {
main[pageId].loadUrl(getUrl.getText().toString());
break;
}
case 2:{
case 2: {
deleteTab(closeWindow);
break;
}
case 3:{
case 3: {
main[pageId].invalidate();
break;
}
@ -2005,22 +2037,27 @@ public class Barebones extends Activity { @@ -2005,22 +2037,27 @@ public class Barebones extends Activity {
@Override
public void onBackPressed() {
if (main[pageId] != null) {
main[pageId].stopLoading();
if (showFullScreen && !uBar.isShown()) {
uBar.startAnimation(slideDown);
}
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();
main[pageId].getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
}
@Override
@ -2104,10 +2141,8 @@ public class Barebones extends Activity { @@ -2104,10 +2141,8 @@ public class Barebones extends Activity {
String url = intent.getDataString();
if (url != null) {
for(int n=0;n<MAX_TABS;n++){
newTab(number, url, true, false);
}
}
super.onNewIntent(intent);
}
@ -2136,7 +2171,7 @@ public class Barebones extends Activity { @@ -2136,7 +2171,7 @@ public class Barebones extends Activity {
return true;
case R.id.incognito:
startActivity(new Intent(FinalVars.INCOGNITO_INTENT));
//newTab(number, homepage, true, true);
// newTab(number, homepage, true, true);
return true;
default:
return super.onOptionsItemSelected(item);
@ -2247,8 +2282,9 @@ public class Barebones extends Activity { @@ -2247,8 +2282,9 @@ public class Barebones extends Activity {
share();
return true;
case R.id.incognito:
startActivity(new Intent(FinalVars.INCOGNITO_INTENT));
//newTab(number, homepage, true, true);
startActivity(new Intent(
FinalVars.INCOGNITO_INTENT));
// newTab(number, homepage, true, true);
return true;
default:
return false;

4
src/acr/browser/barebones/BookmarkPage.java

@ -8,7 +8,7 @@ class BookmarkPage { @@ -8,7 +8,7 @@ class BookmarkPage {
+ "body{color: gray;}"
+ "div {vertical-align: middle;background-color: #ffffff;}"
+ "div.clickable {position:relative;}"
+ "p.font{font-size: 60px;font-family: \"Lucida Console\"}"
+ "p.font{font-size: xx-large;font-family: \"Lucida Console\"}"
+ "div.clickable a {position:absolute;width:100%;height:100%;top:0;left:0;text-decoration:none; z-index:10; background-color:white;opacity: 0; filter: alpha(opacity=1);}"
+ "div.space {height: 10px;}"
+ "p{padding-top: 3mm;padding-bottom: 3mm;padding-right: 2mm;padding-left: 2mm;}"
@ -17,7 +17,7 @@ class BookmarkPage { @@ -17,7 +17,7 @@ class BookmarkPage {
public static final String Part1 = "<div class=\"clickable\">"
+ "<div class=\"shadow\">" + "<p class=\"font\">" + "<a href=\"";
public static final String Part2 = "\"></a>"+
"<img height=\"32\" width=\"32\" src='http://getfavicon.appspot.com/";
"<img height=\"25\" width=\"25\" src='http://getfavicon.appspot.com/";
public static final String Part3 = "'/>";
public static final String Part4 = "</p></div></div>";
public static final String End = "</body></html>";

51
src/acr/browser/barebones/CustomWebView.java

@ -1,55 +1,68 @@ @@ -1,55 +1,68 @@
package acr.browser.barebones;
import java.lang.reflect.Method;
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;
import android.widget.ZoomButtonsController;
public final class CustomWebView extends WebView {
private float location;
private boolean first = false;
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;
private ZoomButtonsController zoomControl;
public CustomWebView(Context context) {
super(context);
getControls();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if(API<11&&zoomControl!=null){
zoomControl.getZoomControls().setVisibility(View.INVISIBLE);
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
hitTest = 0;
try {
hitTest = getHitTestResult().getType();
} catch (NullPointerException ignored) {
}
first = true;
if (API <= 10 && !this.hasFocus()) {
this.requestFocus();
}
if (showFullScreen) {
if (uBar.isShown()) {
location = event.getY();
break;
}
case MotionEvent.ACTION_UP:{
if (showFullScreen&&first) {
if (uBar.isShown()&&this.getScrollY()<5) {
uBar.startAnimation(slideUp);
} else if (this.getScrollY() <= 5
&& !uBar.isShown() && hitTest != 9) {
} else if (event.getY()>location && !uBar.isShown()) {
uBar.startAnimation(slideDown);
} else if (event.getY()<location && uBar.isShown()){
uBar.startAnimation(slideUp);
}
first = false;
}
break;
}
default:
break;
}
return super.onTouchEvent(event);
}
private void getControls() {
if(API<11){
try {
Class<?> webview = Class.forName("android.webkit.WebView");
Method method = webview.getMethod("getZoomButtonsController");
zoomControl = (ZoomButtonsController) method.invoke(this, null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

4
src/acr/browser/barebones/HistoryPage.java

@ -5,8 +5,8 @@ public class HistoryPage { @@ -5,8 +5,8 @@ public class HistoryPage {
+ "<head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><title>History</title></head><style>"
+ "div.shadow {-moz-box-shadow: 0px 0px 6px #111;-webkit-box-shadow: 0px 0px 6px #111;box-shadow: 0px 0px 6px #111;}"
+ "body{color: gray;}div.space {height: 10px;} div.extra{text-align: center;}div {vertical-align: middle;}"
+ "div {background-color: #ffffff;}div.clickable {position:relative;}p.black{color: black;font-size: 40px;font-family: \"Lucida Console\"}"
+ "p.font{font-size: 25px;font-family: \"Lucida Console\"}p{padding-left: 1mm;padding-right: 1mm;padding-top: 1mm;padding-bottom: 1mm;}"
+ "div {background-color: #ffffff;}div.clickable {position:relative;}p.black{color: black;font-size: x-large;font-family: \"Lucida Console\"}"
+ "p.font{font-size: large;font-family: \"Lucida Console\"}p{padding-left: 1mm;padding-right: 1mm;padding-top: 1mm;padding-bottom: 1mm;}"
+ "div.clickable a {position:absolute; width:100%;height:100%;top:0;left:0;text-decoration:none; z-index:10; background-color:white;opacity: 0;filter: alpha(opacity=1);}"
+ "</style><body bgcolor = #f2f2f2>";

409
src/acr/browser/barebones/IncognitoMode.java

@ -11,6 +11,7 @@ import java.util.ArrayList; @@ -11,6 +11,7 @@ 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;
@ -51,6 +52,7 @@ import android.view.View.OnClickListener; @@ -51,6 +52,7 @@ 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;
@ -97,13 +99,14 @@ public class IncognitoMode extends Activity { @@ -97,13 +99,14 @@ public class IncognitoMode extends Activity {
public class CustomChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster;
private View mVideoProgressView;
private FrameLayout fullScreenContainer;
private int orientation;
@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);
@ -112,14 +115,19 @@ public class IncognitoMode extends Activity { @@ -112,14 +115,19 @@ public class IncognitoMode extends Activity {
@Override
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
QuotaUpdater quotaUpdater) {
// TODO Auto-generated method stub
quotaUpdater.updateQuota(quota+requiredStorage);
quotaUpdater.updateQuota(quota + requiredStorage);
super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
}
@Override
public void onCloseWindow(WebView window) {
closeWindow = window.getId();
browserHandler.sendEmptyMessage(2);
super.onCloseWindow(window);
}
@Override
public Bitmap getDefaultVideoPoster() {
// Log.i(LOGTAG, "here in on getDefaultVideoPoster");
if (mDefaultVideoPoster == null) {
mDefaultVideoPoster = BitmapFactory.decodeResource(
getResources(), android.R.color.black);
@ -129,8 +137,6 @@ public class IncognitoMode extends Activity { @@ -129,8 +137,6 @@ public class IncognitoMode extends Activity {
@Override
public View getVideoLoadingProgressView() {
// Log.i(LOGTAG, "here in on getVideoLoadingPregressView");
if (mVideoProgressView == null) {
LayoutInflater inflater = LayoutInflater.from(getBaseContext());
mVideoProgressView = inflater.inflate(
@ -142,30 +148,19 @@ public class IncognitoMode extends Activity { @@ -142,30 +148,19 @@ public class IncognitoMode extends Activity {
@Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, final Message resultMsg) {
if (isUserGesture) {
newTab(number, "", true);
WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(main[pageId]);
resultMsg.sendToTarget();
Thread get = new Thread(new Runnable(){
browserHandler.postDelayed(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();
}, 500);
return true;
}
return false;
}
@Override
public void onGeolocationPermissionsShowPrompt(final String origin,
@ -175,21 +170,18 @@ public class IncognitoMode extends Activity { @@ -175,21 +170,18 @@ public class IncognitoMode extends Activity {
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");
String org = (String) origin.subSequence(0, 50);
builder.setMessage(
origin + " Would like to use your Current Location ")
org + " 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);
}
})
@ -198,7 +190,6 @@ public class IncognitoMode extends Activity { @@ -198,7 +190,6 @@ public class IncognitoMode extends Activity {
@Override
public void onClick(DialogInterface dialog,
int id) {
// origin, allow, remember
callback.invoke(origin, false, remember);
}
});
@ -209,26 +200,21 @@ public class IncognitoMode extends Activity { @@ -209,26 +200,21 @@ public class IncognitoMode extends Activity {
@Override
public void onHideCustomView() {
if (mCustomView == null)
if (mCustomView == null && mCustomViewCallback == null) {
return;
// Hide the custom view.
mCustomView.setVisibility(View.GONE);
// Remove the custom view from its container.
background.removeView(mCustomView);
}
mCustomView.setKeepScreenOn(false);
FrameLayout screen = (FrameLayout) getWindow().getDecorView();
screen.removeView(fullScreenContainer);
fullScreenContainer = null;
mCustomView = null;
background.setVisibility(View.VISIBLE);
uBar.setVisibility(View.VISIBLE);
mCustomViewCallback.onCustomViewHidden();
main[pageId].setVisibility(View.VISIBLE);
// Log.i(LOGTAG, "set it to webVew");
setRequestedOrientation(orientation);
background.addView(main[pageId]);
uBar.setVisibility(View.VISIBLE);
uBar.bringToFront();
}
@Override
public void onReceivedTitle(final WebView view, final String title) {
numberPage = view.getId();
@ -240,36 +226,50 @@ public class IncognitoMode extends Activity { @@ -240,36 +226,50 @@ public class IncognitoMode extends Activity {
@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);
view.setKeepScreenOn(true);
orientation = getRequestedOrientation();
FrameLayout screen = (FrameLayout) getWindow().getDecorView();
fullScreenContainer = new FrameLayout(getBaseContext());
fullScreenContainer.setBackgroundColor(getResources().getColor(
R.color.black));
background.removeView(main[pageId]);
uBar.setVisibility(View.GONE);
fullScreenContainer.addView(view,
ViewGroup.LayoutParams.MATCH_PARENT);
screen.addView(fullScreenContainer,
ViewGroup.LayoutParams.MATCH_PARENT);
mCustomView = view;
mCustomViewCallback = callback;
background.setVisibility(View.VISIBLE);
setRequestedOrientation(requestedOrientation);
}
@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);
view.setKeepScreenOn(true);
orientation = getRequestedOrientation();
FrameLayout screen = (FrameLayout) getWindow().getDecorView();
fullScreenContainer = new FrameLayout(getBaseContext());
fullScreenContainer.setBackgroundColor(getResources().getColor(
R.color.black));
background.removeView(main[pageId]);
uBar.setVisibility(View.GONE);
fullScreenContainer.addView(view,
ViewGroup.LayoutParams.MATCH_PARENT);
screen.addView(fullScreenContainer,
ViewGroup.LayoutParams.MATCH_PARENT);
mCustomView = view;
mCustomViewCallback = callback;
background.setVisibility(View.VISIBLE);
setRequestedOrientation(getRequestedOrientation());
}
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
@ -279,8 +279,7 @@ public class IncognitoMode extends Activity { @@ -279,8 +279,7 @@ public class IncognitoMode extends Activity {
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
IncognitoMode.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
1);
Intent.createChooser(i, "File Browser"), 1);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg,
@ -290,8 +289,7 @@ public class IncognitoMode extends Activity { @@ -290,8 +289,7 @@ public class IncognitoMode extends Activity {
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
IncognitoMode.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
1);
Intent.createChooser(i, "File Browser"), 1);
}
public void openFileChooser(ValueCallback<Uri> uploadMsg,
@ -301,8 +299,7 @@ public class IncognitoMode extends Activity { @@ -301,8 +299,7 @@ public class IncognitoMode extends Activity {
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
IncognitoMode.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
1);
Intent.createChooser(i, "File Browser"), 1);
}
}
@ -352,16 +349,12 @@ public class IncognitoMode extends Activity { @@ -352,16 +349,12 @@ public class IncognitoMode extends Activity {
}
private class CustomWebViewClient extends WebViewClient {
private class IncognitoWebViewClient 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")) {
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")) {
@ -371,19 +364,27 @@ public class IncognitoMode extends Activity { @@ -371,19 +364,27 @@ public class IncognitoMode extends Activity {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
return false;
}
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
if (view != null) {
view.invalidate();
}
super.onScaleChanged(view, oldScale, newScale);
}
@Override
public void onPageFinished(WebView view, final String url) {
if (view != null) {
view.invalidate();
}
if (view.isShown()) {
view.postInvalidate();
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
if(showFullScreen&&uBar.isShown()){
if (showFullScreen && uBar.isShown()) {
uBar.startAnimation(slideUp);
}
}
view.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
@ -402,34 +403,79 @@ public class IncognitoMode extends Activity { @@ -402,34 +403,79 @@ public class IncognitoMode extends Activity {
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) {
if (!uBar.isShown() && showFullScreen) {
uBar.startAnimation(slideDown);
}
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
public void onReceivedSslError(WebView view,
final SslErrorHandler handler, SslError error) {
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT);
builder.setTitle("Warning");
builder.setMessage(
"The certificate of the site is not trusted. Proceed anyway?")
.setCancelable(true)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
handler.proceed();
}
})
.setNegativeButton("No",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
handler.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
super.onReceivedSslError(view, handler, error);
}
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
public void onFormResubmission(WebView view, final Message dontResend,
final Message resend) {
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT);
builder.setTitle("Form Resubmission");
builder.setMessage("Would you like to resend the data?")
.setCancelable(true)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
view.getSettings().setLayoutAlgorithm(
LayoutAlgorithm.NORMAL);
super.onScaleChanged(view, oldScale, newScale);
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);
}
}
private void generateHistory(final CustomWebView view) {
private void generateHistory(final IncognitoWebView view) {
Thread history = new Thread(new Runnable() {
@ -603,6 +649,14 @@ public class IncognitoMode extends Activity { @@ -603,6 +649,14 @@ public class IncognitoMode extends Activity {
}
private void removeView(WebView view) {
if (!showFullScreen) {
view.startAnimation(fadeOut);
}
background.removeView(view);
uBar.bringToFront();
}
private void deleteBookmark(String url) {
File book = new File(getBaseContext().getFilesDir(), "bookmarks");
File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl");
@ -662,7 +716,7 @@ public class IncognitoMode extends Activity { @@ -662,7 +716,7 @@ public class IncognitoMode extends Activity {
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
int num = pageId;
newTab(number, result.getExtra(), false, true);
newTab(number, result.getExtra(), false);
// urlTitle[num].performClick();
pageId = num;
break;
@ -700,7 +754,7 @@ public class IncognitoMode extends Activity { @@ -700,7 +754,7 @@ public class IncognitoMode extends Activity {
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
int num = pageId;
newTab(number, result.getExtra(), false, true);
newTab(number, result.getExtra(), false);
// urlTitle[num].performClick();
pageId = num;
break;
@ -783,7 +837,7 @@ public class IncognitoMode extends Activity { @@ -783,7 +837,7 @@ public class IncognitoMode extends Activity {
switch (which) {
case DialogInterface.BUTTON_POSITIVE: {
int num = pageId;
newTab(number, result.getExtra(), false, true);
newTab(number, result.getExtra(), false);
// urlTitle[num].performClick();
pageId = num;
break;
@ -838,7 +892,7 @@ public class IncognitoMode extends Activity { @@ -838,7 +892,7 @@ public class IncognitoMode extends Activity {
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 final IncognitoWebView[] main = new IncognitoWebView[MAX_TABS];
private static Rect bounds;
private static ValueCallback<Uri> mUploadMessage;
private static ImageView refresh;
@ -864,6 +918,7 @@ public class IncognitoMode extends Activity { @@ -864,6 +918,7 @@ public class IncognitoMode extends Activity {
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 boolean isPhone = false;
@ -900,7 +955,7 @@ public class IncognitoMode extends Activity { @@ -900,7 +955,7 @@ public class IncognitoMode extends Activity {
private static List<Map<String, String>> list;
private static Map<String, String> map;
private static Handler handler;
private static Handler handler, browserHandler;
private static DatabaseHandler historyHandler;
@ -923,8 +978,45 @@ public class IncognitoMode extends Activity { @@ -923,8 +978,45 @@ public class IncognitoMode extends Activity {
}
}
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));
BufferedWriter urlWriter = new BufferedWriter(new FileWriter(
bookUrl, true));
bookWriter.write(urlToLoad[pageId][1]);
urlWriter.write(urlToLoad[pageId][0]);
bookWriter.newLine();
urlWriter.newLine();
bookWriter.close();
urlWriter.close();
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {
} catch (NullPointerException ignored) {
}
}
@SuppressLint("SetJavaScriptEnabled")
CustomWebView browserSettings(CustomWebView view) {
IncognitoWebView browserSettings(IncognitoWebView view) {
view.setAnimationCacheEnabled(false);
view.setDrawingCacheEnabled(false);
view.setDrawingCacheBackgroundColor(getResources().getColor(
@ -946,18 +1038,18 @@ public class IncognitoMode extends Activity { @@ -946,18 +1038,18 @@ public class IncognitoMode extends Activity {
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()
.getAbsolutePath() + "/incognito_cache");
.getAbsolutePath() + "/cache");
webViewSettings.setRenderPriority(RenderPriority.HIGH);
webViewSettings.setGeolocationEnabled(true);
webViewSettings.setGeolocationDatabasePath(getApplicationContext()
.getFilesDir().getAbsolutePath()+"/incognito_geolocation");
.getFilesDir().getAbsolutePath());
webViewSettings.setDatabaseEnabled(true);
webViewSettings.setDatabasePath(getApplicationContext().getFilesDir()
.getAbsolutePath() + "/incognito_databases");
.getAbsolutePath() + "/databases");
enableFlash = settings.getInt("enableflash", 0);
switch (enableFlash) {
case 0:
@ -977,7 +1069,6 @@ public class IncognitoMode extends Activity { @@ -977,7 +1069,6 @@ public class IncognitoMode extends Activity {
webViewSettings.setUserAgentString(userAgent);
webViewSettings.setSavePassword(false);
webViewSettings.setSaveFormData(false);
webViewSettings.setBuiltInZoomControls(true);
webViewSettings.setSupportZoom(true);
webViewSettings.setUseWideViewPort(true);
@ -1012,7 +1103,7 @@ public class IncognitoMode extends Activity { @@ -1012,7 +1103,7 @@ public class IncognitoMode extends Activity {
void deleteTab(final int del) {
main[del].stopLoading();
main[del].clearHistory();
main[del].clearView();
// main[del].clearView();
urlToLoad[del][0] = null;
urlToLoad[del][1] = null;
if (API >= 11) {
@ -1027,7 +1118,6 @@ public class IncognitoMode extends Activity { @@ -1027,7 +1118,6 @@ public class IncognitoMode extends Activity {
}
urlTitle[del].setPadding(leftPad, 0, rightPad, 0);
Animation yolo = AnimationUtils.loadAnimation(this, R.anim.down);
yolo.setAnimationListener(new AnimationListener() {
@Override
@ -1047,7 +1137,7 @@ public class IncognitoMode extends Activity { @@ -1047,7 +1137,7 @@ public class IncognitoMode extends Activity {
});
urlTitle[del].startAnimation(yolo);
uBar.bringToFront();
}
@SuppressWarnings("deprecation")
@ -1057,7 +1147,8 @@ public class IncognitoMode extends Activity { @@ -1057,7 +1147,8 @@ public class IncognitoMode extends Activity {
if (id == pageId) {
if (main[id].isShown()) {
background.removeView(main[id]);
// background.removeView(main[id]);
removeView(main[id]);
}
for (; id <= (number - 1); id++) {
if (urlTitle[id].isShown()) {
@ -1074,6 +1165,13 @@ public class IncognitoMode extends Activity { @@ -1074,6 +1165,13 @@ public class IncognitoMode extends Activity {
setUrlText(urlToLoad[pageId][0]);
getUrl.setPadding(tenPad, 0, tenPad, 0);
right = true;
if (main[id].getProgress() < 100) {
refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
}
break;
}
@ -1095,6 +1193,13 @@ public class IncognitoMode extends Activity { @@ -1095,6 +1193,13 @@ public class IncognitoMode extends Activity {
setUrlText(urlToLoad[pageId][0]);
getUrl.setPadding(tenPad, 0, tenPad, 0);
left = true;
if (main[leftId].getProgress() < 100) {
refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE);
}
break;
}
@ -1109,6 +1214,7 @@ public class IncognitoMode extends Activity { @@ -1109,6 +1214,7 @@ public class IncognitoMode extends Activity {
if (!(right || left)) {
finish();
}
uBar.bringToFront();
tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0);
}
@ -1248,7 +1354,7 @@ public class IncognitoMode extends Activity { @@ -1248,7 +1354,7 @@ public class IncognitoMode extends Activity {
} catch (IllegalStateException ignored) {
}
getUrl.setThreshold(2);
getUrl.setThreshold(1);
getUrl.setTokenizer(new SpaceTokenizer());
getUrl.setOnItemClickListener(new OnItemClickListener() {
@ -1264,7 +1370,6 @@ public class IncognitoMode extends Activity { @@ -1264,7 +1370,6 @@ public class IncognitoMode extends Activity {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getUrl.getWindowToken(), 0);
} catch (NullPointerException e) {
Log.e("IncognitoMode Error: ",
"NullPointerException on item click");
}
@ -1313,8 +1418,6 @@ public class IncognitoMode extends Activity { @@ -1313,8 +1418,6 @@ public class IncognitoMode extends Activity {
public void finish() {
background.clearDisappearingChildren();
tabScroll.clearDisappearingChildren();
main[0].clearCache(true);
cookieManager.setAcceptCookie(true);
super.finish();
}
@ -1337,7 +1440,7 @@ public class IncognitoMode extends Activity { @@ -1337,7 +1440,7 @@ public class IncognitoMode extends Activity {
});
}
void goBookmarks(CustomWebView view) {
void goBookmarks(IncognitoWebView view) {
File book = new File(getBaseContext().getFilesDir(), "bookmarks");
File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl");
try {
@ -1365,9 +1468,6 @@ public class IncognitoMode extends Activity { @@ -1365,9 +1468,6 @@ public class IncognitoMode extends Activity {
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) {
@ -1450,7 +1550,6 @@ public class IncognitoMode extends Activity { @@ -1450,7 +1550,6 @@ public class IncognitoMode extends Activity {
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
@ -1458,7 +1557,6 @@ public class IncognitoMode extends Activity { @@ -1458,7 +1557,6 @@ public class IncognitoMode extends Activity {
// 2=desktop,
// 3=custom
// initializing variables declared
height = getResources().getDrawable(R.drawable.loading)
@ -1481,7 +1579,7 @@ public class IncognitoMode extends Activity { @@ -1481,7 +1579,7 @@ public class IncognitoMode extends Activity {
tabScroll.setHorizontalScrollBarEnabled(false);
if (API > 8) {
tabScroll.setOverScrollMode(View.OVER_SCROLL_NEVER); // disallow
//overscroll
// overscroll
}
// image dimensions and initialization
@ -1495,7 +1593,6 @@ public class IncognitoMode extends Activity { @@ -1495,7 +1593,6 @@ public class IncognitoMode extends Activity {
tenPad = (int) (10 * scale + 0.5f);
number = 0;
webpageOther = getResources().getDrawable(R.drawable.webpage);
incognitoPage = getResources().getDrawable(R.drawable.incognito);
webpageOther.setBounds(0, 0, width / 2, height / 2);
@ -1519,8 +1616,9 @@ public class IncognitoMode extends Activity { @@ -1519,8 +1616,9 @@ public class IncognitoMode extends Activity {
newTab.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
newTab(number, homepage, true, true);
newTab(number, homepage, true);
tabScroll.postDelayed(new Runnable() {
@Override
public void run() {
tabScroll.smoothScrollTo(urlTitle[pageId].getLeft(), 0);
}
@ -1548,7 +1646,25 @@ public class IncognitoMode extends Activity { @@ -1548,7 +1646,25 @@ public class IncognitoMode 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;
}
}
}
};
}
void initializeTabs() {
@ -1556,24 +1672,24 @@ public class IncognitoMode extends Activity { @@ -1556,24 +1672,24 @@ public class IncognitoMode extends Activity {
String URL = url.getDataString();
if (URL != null) {
// opens a new tab with the url if its there
newTab(number, URL, true, true);
newTab(number, URL, true);
main[number - 1].resumeTimers();
} else {
// otherwise it opens the homepage
newTab(number, homepage, true, true);
newTab(number, homepage, true);
main[number - 1].resumeTimers();
}
}
private CustomWebView makeTab(final int pageToView, final String Url,
private IncognitoWebView makeTab(final int pageToView, final String Url,
final boolean display) {
CustomWebView view = new CustomWebView(CONTEXT);
IncognitoWebView view = new IncognitoWebView(CONTEXT);
view.setId(pageToView);
allowLocation = settings.getBoolean("location", false);
view.setWebViewClient(new CustomWebViewClient());
view.setWebViewClient(new IncognitoWebViewClient());
view.setWebChromeClient(new CustomChromeClient());
if (API > 8) {
view.setDownloadListener(new CustomDownloadListener());
@ -1623,8 +1739,7 @@ public class IncognitoMode extends Activity { @@ -1623,8 +1739,7 @@ public class IncognitoMode extends Activity {
// new tab method, takes the id of the tab to be created and the url to load
@SuppressWarnings("deprecation")
int newTab(int theId, final String theUrl, final boolean display,
final boolean incognito_mode) {
int newTab(int theId, final String theUrl, final boolean display) {
Log.i("IncognitoMode", "making tab");
int finalID = 0;
@ -1655,6 +1770,7 @@ public class IncognitoMode extends Activity { @@ -1655,6 +1770,7 @@ public class IncognitoMode extends Activity {
});
urlTitle[n].startAnimation(holo);
urlTitle[num].setText("New Tab");
if (display) {
if (API < 16) {
urlTitle[num].setBackgroundDrawable(active);
@ -1729,8 +1845,7 @@ public class IncognitoMode extends Activity { @@ -1729,8 +1845,7 @@ public class IncognitoMode extends Activity {
title.setId(number);
title.setGravity(Gravity.CENTER_VERTICAL);
title.setCompoundDrawables(incognitoPage, null, exitTab,
null);
title.setCompoundDrawables(incognitoPage, null, exitTab, null);
Drawable[] drawables = title.getCompoundDrawables();
bounds = drawables[2].getBounds();
@ -1759,7 +1874,6 @@ public class IncognitoMode extends Activity { @@ -1759,7 +1874,6 @@ public class IncognitoMode extends Activity {
urlTitle[number].setText("Incognito");
if (theUrl != null) {
main[number] = makeTab(number, theUrl, display);
} else {
@ -1793,21 +1907,27 @@ public class IncognitoMode extends Activity { @@ -1793,21 +1907,27 @@ public class IncognitoMode extends Activity {
@Override
public void onBackPressed() {
if (main[pageId] != null) {
main[pageId].stopLoading();
if (showFullScreen && !uBar.isShown()) {
uBar.startAnimation(slideDown);
}
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();
main[pageId].getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
}
@Override
@ -1816,8 +1936,9 @@ public class IncognitoMode extends Activity { @@ -1816,8 +1936,9 @@ public class IncognitoMode extends Activity {
setContentView(R.layout.activity_main); // displays main xml layout
settings = getSharedPreferences(preferences, 0);
edit = settings.edit();
CookieSyncManager.createInstance(CONTEXT);
cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(false);
inactive = getResources().getDrawable(R.drawable.bg_inactive);
active = getResources().getDrawable(R.drawable.bg_press);
init(); // sets up random stuff
@ -1886,7 +2007,7 @@ public class IncognitoMode extends Activity { @@ -1886,7 +2007,7 @@ public class IncognitoMode extends Activity {
String url = intent.getDataString();
if (url != null) {
newTab(number, url, true, true);
newTab(number, url, true);
}
super.onNewIntent(intent);
}
@ -1898,22 +2019,16 @@ public class IncognitoMode extends Activity { @@ -1898,22 +2019,16 @@ public class IncognitoMode extends Activity {
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);
newTab(number, homepage, true);
return true;
default:
return super.onOptionsItemSelected(item);
return false;
}
}
@ -1938,7 +2053,7 @@ public class IncognitoMode extends Activity { @@ -1938,7 +2053,7 @@ public class IncognitoMode extends Activity {
}
void openBookmarks(CustomWebView view) {
void openBookmarks(IncognitoWebView view) {
String bookmarkHtml = BookmarkPage.Heading;
for (int n = 0; n < MAX_BOOKMARKS; n++) {
if (bUrl[n] != null) {
@ -1988,19 +2103,13 @@ public class IncognitoMode extends Activity { @@ -1988,19 +2103,13 @@ public class IncognitoMode extends Activity {
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);
newTab(number, homepage, true);
return true;
default:
return false;
@ -2027,6 +2136,26 @@ public class IncognitoMode extends Activity { @@ -2027,6 +2136,26 @@ public class IncognitoMode extends Activity {
});
}
void share() {
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
// set the type
shareIntent.setType("text/plain");
// add a subject
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
urlToLoad[pageId][1]);
// build the body of the message to be shared
String shareMessage = urlToLoad[pageId][0];
// add the message
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
// start the chooser for sharing
startActivity(Intent.createChooser(shareIntent, "Share this page"));
}
void testForSearch() {
String fixedQuery = query.trim();
main[pageId].stopLoading();

68
src/acr/browser/barebones/IncognitoWebView.java

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
package acr.browser.barebones;
import java.lang.reflect.Method;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.Animation;
import android.webkit.WebView;
import android.widget.ZoomButtonsController;
public final class IncognitoWebView extends WebView {
private float location;
private boolean first = false;
private final int API = FinalVars.API;
private final boolean showFullScreen = IncognitoMode.showFullScreen;
private final View uBar = IncognitoMode.uBar;
private final Animation slideUp = IncognitoMode.slideUp;
private final Animation slideDown = IncognitoMode.slideDown;
private ZoomButtonsController zoomControl;
public IncognitoWebView(Context context) {
super(context);
getControls();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if(API<11&&zoomControl!=null){
zoomControl.getZoomControls().setVisibility(View.INVISIBLE);
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
first = true;
if (API <= 10 && !this.hasFocus()) {
this.requestFocus();
}
location = event.getY();
break;
}
case MotionEvent.ACTION_UP:{
if (showFullScreen&&first) {
if (uBar.isShown()&&this.getScrollY()<5) {
uBar.startAnimation(slideUp);
} else if (event.getY()>location && !uBar.isShown()) {
uBar.startAnimation(slideDown);
} else if (event.getY()<location && uBar.isShown()){
uBar.startAnimation(slideUp);
}
first = false;
}
break;
}
}
return super.onTouchEvent(event);
}
private void getControls() {
if(API<11){
try {
Class<?> webview = Class.forName("android.webkit.WebView");
Method method = webview.getMethod("getZoomButtonsController");
zoomControl = (ZoomButtonsController) method.invoke(this, null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

10
src/acr/browser/barebones/SpaceTokenizer.java

@ -12,14 +12,14 @@ public class SpaceTokenizer implements Tokenizer { @@ -12,14 +12,14 @@ public class SpaceTokenizer implements Tokenizer {
int i = cursor;
int len = text.length();
while (i < len) {
/*while (i < len) {
if (text.charAt(i) == ' ') {
return i;
} else {
i++;
}
}
*/
return len;
}
@ -40,8 +40,8 @@ public class SpaceTokenizer implements Tokenizer { @@ -40,8 +40,8 @@ public class SpaceTokenizer implements Tokenizer {
@Override
public CharSequence terminateToken(CharSequence text) {
int i = text.length();
while (i > 0 && text.charAt(i - 1) == ' ') {
return text;
/*while (i > 0 && text.charAt(i - 1) == ' ') {
i--;
}
@ -56,6 +56,6 @@ public class SpaceTokenizer implements Tokenizer { @@ -56,6 +56,6 @@ public class SpaceTokenizer implements Tokenizer {
} else {
return text + " ";
}
}
}*/
}
}

Loading…
Cancel
Save