Browse Source

Assorted Bugfixes

- Fixes tab location ability.
- Improves browser stability
- allow renaming of bookmarks
- better objectification of the code
- oh I can't remember, it's late and I'm tired
master
Anthony Restaino 11 years ago
parent
commit
4042488b56
  1. 11
      res/anim/left.xml
  2. 10
      res/anim/right.xml
  3. BIN
      res/drawable-xhdpi/ic_launcher.png
  4. BIN
      res/drawable-xhdpi/progress_bar.9.png
  5. 4
      res/layout/two_line_autocomplete.xml
  6. 2
      res/values-zh-rCN/strings.xml
  7. 1212
      src/acr/browser/barebones/activities/BrowserActivity.java
  8. 1050
      src/acr/browser/barebones/activities/IncognitoModeActivity.java
  9. 13
      src/acr/browser/barebones/activities/SettingsActivity.java
  10. 228
      src/acr/browser/barebones/customwebview/CustomWebView.java
  11. 232
      src/acr/browser/barebones/customwebview/IncognitoWebView.java
  12. 3
      src/acr/browser/barebones/incognitoclasses/IncognitoChromeClient.java
  13. 2
      src/acr/browser/barebones/incognitoclasses/IncognitoLongClickListener.java
  14. 1
      src/acr/browser/barebones/utilities/FinalVariables.java
  15. 2
      src/acr/browser/barebones/utilities/Utils.java
  16. 3
      src/acr/browser/barebones/webviewclasses/CustomChromeClient.java
  17. 2
      src/acr/browser/barebones/webviewclasses/WebPageLongClickListener.java

11
res/anim/left.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="9%p" android:duration="150"
/>
</set>

10
res/anim/right.xml

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0%p"
android:interpolator="@android:anim/decelerate_interpolator"
android:toXDelta="-9%p" android:duration="150"
/>
</set>

BIN
res/drawable-xhdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 11 KiB

BIN
res/drawable-xhdpi/progress_bar.9.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

After

Width:  |  Height:  |  Size: 176 B

4
res/layout/two_line_autocomplete.xml

@ -16,7 +16,7 @@
android:textColor="#000000" android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingLeft="6dip" android:paddingLeft="6dip"
android:paddingTop="10dip"/> android:paddingTop="2dip"/>
<TextView <TextView
android:id="@+id/url" android:id="@+id/url"
android:clickable="false" android:clickable="false"
@ -27,5 +27,5 @@
android:paddingLeft="6dip" android:paddingLeft="6dip"
android:maxLines="1" android:maxLines="1"
android:paddingTop="2dip" android:paddingTop="2dip"
android:paddingBottom="10dip"/> android:paddingBottom="2dip"/>
</LinearLayout> </LinearLayout>

2
res/values-zh-rCN/strings.xml

@ -53,7 +53,5 @@
<string name="menu_new_tab">新建标签</string> <string name="menu_new_tab">新建标签</string>
<string name="stock_browser_unavailable">(没有检测到系统自带浏览器)</string> <string name="stock_browser_unavailable">(没有检测到系统自带浏览器)</string>
<string name="stock_browser_available">(检测到系统自带浏览器)</string> <string name="stock_browser_available">(检测到系统自带浏览器)</string>
<string name="fullScreenOption">浏览网页时隐藏状态栏</string>
<string name="clear_cookies">清除 cookies</string>
</resources> </resources>

1212
src/acr/browser/barebones/activities/BrowserActivity.java

File diff suppressed because it is too large Load Diff

1050
src/acr/browser/barebones/activities/IncognitoModeActivity.java

File diff suppressed because it is too large Load Diff

13
src/acr/browser/barebones/activities/SettingsActivity.java

@ -95,6 +95,9 @@ public class SettingsActivity extends Activity {
case 7: case 7:
searchText.setText("Yandex"); searchText.setText("Yandex");
break; break;
case 8:
searchText.setText("DuckDuckGo Lite");
break;
} }
back.setBackgroundResource(R.drawable.button); back.setBackgroundResource(R.drawable.button);
@ -224,8 +227,8 @@ public class SettingsActivity extends Activity {
AlertDialog.Builder picker = new AlertDialog.Builder( AlertDialog.Builder picker = new AlertDialog.Builder(
SettingsActivity.this); SettingsActivity.this);
picker.setTitle("Search Engine"); picker.setTitle("Search Engine");
CharSequence[] chars = { "Google (Suggested)", "Bing", "Yahoo", CharSequence[] chars = { "Google", "Bing", "Yahoo",
"StartPage", "DuckDuckGo (Privacy)" , "Baidu (Chinese)", "Yandex (Russian)"}; "StartPage", "DuckDuckGo (Privacy)" , "Baidu (Chinese)", "Yandex (Russian)", "DuckDuckGo Lite (Privacy)"};
int n = settings.getInt("search", 1); int n = settings.getInt("search", 1);
@ -259,6 +262,9 @@ public class SettingsActivity extends Activity {
case 7: case 7:
searchText.setText("Yandex"); searchText.setText("Yandex");
break; break;
case 8:
searchText.setText("DuckDuckGo Lite");
break;
} }
} }
}); });
@ -463,10 +469,9 @@ public class SettingsActivity extends Activity {
Utils.createInformativeDialog( Utils.createInformativeDialog(
SettingsActivity.this, SettingsActivity.this,
"Warning", "Warning",
"Adobe Flash does not support Android 4.3 and will" "Adobe Flash does not support Android 4.3 and will "
+ "crash the browser, please do not report crashes that occur if you enable flash."); + "crash the browser, please do not report crashes that occur if you enable flash.");
} }
} }
}); });

228
src/acr/browser/barebones/customwebview/CustomWebView.java

@ -2,7 +2,9 @@ package acr.browser.barebones.customwebview;
import acr.browser.barebones.activities.BrowserActivity; import acr.browser.barebones.activities.BrowserActivity;
import acr.browser.barebones.utilities.FinalVariables; import acr.browser.barebones.utilities.FinalVariables;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Point; import android.graphics.Point;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Display; import android.view.Display;
@ -14,50 +16,63 @@ import android.view.WindowManager;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebSettings.RenderPriority;
public final class CustomWebView extends WebView { public final class CustomWebView extends WebView {
private float location;
private boolean first = false; private boolean first = false;
final int API = FinalVariables.API; static final int API = FinalVariables.API;
final boolean showFullScreen = BrowserActivity.showFullScreen; public static boolean showFullScreen;;
final View uBar = BrowserActivity.uBar; final View uBar = BrowserActivity.uBar;
final Animation slideUp = BrowserActivity.slideUp; final Animation slideUp = BrowserActivity.slideUp;
final Animation slideDown = BrowserActivity.slideDown; final Animation slideDown = BrowserActivity.slideDown;
static Context CONTEXT; static Context CONTEXT;
static String defaultUser;
public WebSettings settings;
public CustomWebView(Context context) { public CustomWebView(Context context) {
super(context); super(context);
defaultUser = BrowserActivity.defaultUser;
showFullScreen = BrowserActivity.showFullScreen;
mGestureDetector = new GestureDetector(context, mGestureDetector = new GestureDetector(context,
new CustomGestureListener()); new CustomGestureListener());
CONTEXT = context; CONTEXT = context;
WebSettings settings = this.getSettings(); settings = getSettings();
browserInitialization(context); browserInitialization(context);
settingsInitialization(context, settings); settingsInitialization(context);
} }
@SuppressWarnings("deprecation")
public void browserInitialization(Context context) { public void browserInitialization(Context context) {
this.setDrawingCacheBackgroundColor(0x00000000); setDrawingCacheBackgroundColor(0x00000000);
this.setFocusableInTouchMode(true); setFocusableInTouchMode(true);
this.setFocusable(true); setFocusable(true);
this.setAnimationCacheEnabled(false); setAnimationCacheEnabled(false);
this.setDrawingCacheEnabled(true); setDrawingCacheEnabled(true);
this.setBackgroundColor(context.getResources().getColor( setBackgroundColor(context.getResources().getColor(
android.R.color.white)); android.R.color.white));
this.setWillNotCacheDrawing(false); if (API >= 16) {
this.setAlwaysDrawnWithCacheEnabled(true); getRootView().setBackground(null);
this.setScrollbarFadingEnabled(true); } else {
this.setSaveEnabled(true); getRootView().setBackgroundDrawable(null);
}
setWillNotCacheDrawing(false);
setAlwaysDrawnWithCacheEnabled(true);
setScrollbarFadingEnabled(true);
setSaveEnabled(true);
} }
@SuppressLint("SetJavaScriptEnabled")
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void settingsInitialization(Context context, WebSettings settings) { public void settingsInitialization(Context context) {
SharedPreferences preferences = context.getSharedPreferences(
"settings", 0);
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true); settings.setAppCacheEnabled(true);
settings.setAppCachePath(context.getFilesDir().getAbsolutePath() settings.setAppCachePath(context.getFilesDir().getAbsolutePath()
+ "/cache"); + "/cache");
if (API < 18) {
settings.setLightTouchEnabled(true);
}
settings.setAllowFileAccess(true); settings.setAllowFileAccess(true);
settings.setDatabaseEnabled(true); settings.setDatabaseEnabled(true);
settings.setDatabasePath(context.getFilesDir().getAbsolutePath() settings.setDatabasePath(context.getFilesDir().getAbsolutePath()
@ -68,54 +83,168 @@ public final class CustomWebView extends WebView {
settings.setDisplayZoomControls(false); settings.setDisplayZoomControls(false);
settings.setAllowContentAccess(true); settings.setAllowContentAccess(true);
} }
}
@Override if (preferences.getBoolean("java", true)) {
public boolean onTouchEvent(MotionEvent event) { settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
}
switch (event.getAction()) { if (API < 14) {
case MotionEvent.ACTION_DOWN: { switch (preferences.getInt("textsize", 3)) {
first = true; case 1:
if (API <= 10 && !hasFocus()) { settings.setTextSize(WebSettings.TextSize.LARGEST);
requestFocus(); break;
case 2:
settings.setTextSize(WebSettings.TextSize.LARGER);
break;
case 3:
settings.setTextSize(WebSettings.TextSize.NORMAL);
break;
case 4:
settings.setTextSize(WebSettings.TextSize.SMALLER);
break;
case 5:
settings.setTextSize(WebSettings.TextSize.SMALLEST);
break;
}
} else {
switch (preferences.getInt("textsize", 3)) {
case 1:
settings.setTextZoom(200);
break;
case 2:
settings.setTextZoom(150);
break;
case 3:
settings.setTextZoom(100);
break;
case 4:
settings.setTextZoom(75);
break;
case 5:
settings.setTextZoom(50);
break;
} }
location = event.getY(); }
settings.setSupportMultipleWindows(preferences.getBoolean("newwindow",
true));
switch (preferences.getInt("enableflash", 0)) {
case 0:
break;
case 1: {
settings.setPluginState(PluginState.ON_DEMAND);
break;
}
case 2: {
settings.setPluginState(PluginState.ON);
break;
}
default:
break; break;
} }
case MotionEvent.ACTION_UP: { if (preferences.getBoolean("passwords", false)) {
if (API < 18) {
settings.setSavePassword(true);
}
settings.setSaveFormData(true);
}
if (API < 18) {
try {
settings.setRenderPriority(RenderPriority.HIGH);
} catch (SecurityException ignored) {
if (showFullScreen && first) {
if (uBar.isShown() && getScrollY() < 5) {
uBar.startAnimation(slideUp);
} else if ((event.getY() - location) > 20.0 && !uBar.isShown()) {
uBar.startAnimation(slideDown);
} else if ((event.getY() - location) < -20.0 && uBar.isShown()) {
uBar.startAnimation(slideUp);
}
first = false;
} }
break;
} }
settings.setGeolocationEnabled(preferences
.getBoolean("location", false));
settings.setGeolocationDatabasePath(context.getFilesDir()
.getAbsolutePath());
settings.setUseWideViewPort(preferences
.getBoolean("wideviewport", true));
settings.setLoadWithOverviewMode(preferences.getBoolean("overviewmode",
true));
if (preferences.getBoolean("textreflow", false)) {
settings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
} else {
settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
} }
settings.setBlockNetworkImage(preferences.getBoolean("blockimages",
false));
settings.setLoadsImagesAutomatically(true);
switch (preferences.getInt("agentchoose", 1)) {
case 1:
getSettings().setUserAgentString(defaultUser);
break;
case 2:
getSettings().setUserAgentString(
FinalVariables.DESKTOP_USER_AGENT);
break;
case 3:
getSettings().setUserAgentString(
FinalVariables.MOBILE_USER_AGENT);
break;
case 4:
getSettings().setUserAgentString(
preferences.getString("userAgentString", defaultUser));
break;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
mGestureDetector.onTouchEvent(event); mGestureDetector.onTouchEvent(event);
return super.onTouchEvent(event); return super.onTouchEvent(event);
} }
@Override @Override
protected void onWindowVisibilityChanged(int visibility) { protected void onWindowVisibilityChanged(int visibility) {
if (API >= 11) { if (API >= 11) {
this.setActivated(visibility == View.VISIBLE); setActivated(visibility == View.VISIBLE);
} }
this.setEnabled(visibility == View.VISIBLE); setEnabled(visibility == View.VISIBLE);
super.onWindowVisibilityChanged(visibility); super.onWindowVisibilityChanged(visibility);
} }
private final GestureDetector mGestureDetector; private final GestureDetector mGestureDetector;
private class CustomGestureListener extends SimpleOnGestureListener { private class CustomGestureListener extends SimpleOnGestureListener {
private final int SWIPE_THRESHOLD = 100; final int SWIPE_THRESHOLD = 100;
private final int SWIPE_VELOCITY_THRESHOLD = 100; final int SWIPE_VELOCITY_THRESHOLD = 100;
@Override
public boolean onDown(MotionEvent e) {
first = true;
return super.onDown(e);
}
@Override
public void onLongPress(MotionEvent e) {
if (BrowserActivity.currentId != -1) {
BrowserActivity.onLongClick();
}
super.onLongPress(e);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
if (showFullScreen && first) {
if (uBar.isShown() && getScrollY() < 5) {
uBar.startAnimation(slideUp);
} else if (distanceY < -5 && !uBar.isShown()) {
uBar.startAnimation(slideDown);
} else if (distanceY > 5 && uBar.isShown()) {
uBar.startAnimation(slideUp);
}
first = false;
}
return super.onScroll(e1, e2, distanceX, distanceY);
}
@Override @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
@ -136,18 +265,17 @@ public final class CustomWebView extends WebView {
width = size.x; width = size.x;
} }
if ((width - e1.getX() < width/12) || (e1.getX() < width/12)) { if ((width - e1.getX() < width / 12)
|| (e1.getX() < width / 12)) {
float diffY = e2.getY() - e1.getY(); float diffY = e2.getY() - e1.getY();
float diffX = e2.getX() - e1.getX(); float diffX = e2.getX() - e1.getX();
if (Math.abs(diffX) > Math.abs(diffY)) { if (Math.abs(diffX) > Math.abs(diffY)) {
if (Math.abs(diffX) > SWIPE_THRESHOLD if (Math.abs(diffX) > SWIPE_THRESHOLD
&& Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
if (diffX > 0) { if (diffX > 0) {
BrowserActivity.goBack(); BrowserActivity.goBack(CustomWebView.this);
return false;
} else { } else {
BrowserActivity.goForward(); BrowserActivity.goForward(CustomWebView.this);
return false;
} }
} }
} }
@ -156,7 +284,7 @@ public final class CustomWebView extends WebView {
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
return false; return super.onFling(e1, e2, velocityX, velocityY);
} }
} }

232
src/acr/browser/barebones/customwebview/IncognitoWebView.java

@ -2,7 +2,9 @@ package acr.browser.barebones.customwebview;
import acr.browser.barebones.activities.IncognitoModeActivity; import acr.browser.barebones.activities.IncognitoModeActivity;
import acr.browser.barebones.utilities.FinalVariables; import acr.browser.barebones.utilities.FinalVariables;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Point; import android.graphics.Point;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.Display; import android.view.Display;
@ -14,50 +16,63 @@ import android.view.WindowManager;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebSettings.RenderPriority;
public final class IncognitoWebView extends WebView { public final class IncognitoWebView extends WebView {
private float location;
private boolean first = false; private boolean first = false;
final int API = FinalVariables.API; static final int API = FinalVariables.API;
final boolean showFullScreen = IncognitoModeActivity.showFullScreen; public static boolean showFullScreen;;
final View uBar = IncognitoModeActivity.urlBar; final View uBar = IncognitoModeActivity.uBar;
final Animation slideUp = IncognitoModeActivity.slideUp; final Animation slideUp = IncognitoModeActivity.slideUp;
final Animation slideDown = IncognitoModeActivity.slideDown; final Animation slideDown = IncognitoModeActivity.slideDown;
static Context CONTEXT; static Context CONTEXT;
static String defaultUser;
public WebSettings settings;
public IncognitoWebView(Context context) { public IncognitoWebView(Context context) {
super(context); super(context);
defaultUser = IncognitoModeActivity.defaultUser;
showFullScreen = IncognitoModeActivity.showFullScreen;
mGestureDetector = new GestureDetector(context, mGestureDetector = new GestureDetector(context,
new CustomGestureListener()); new CustomGestureListener());
CONTEXT = context; CONTEXT = context;
WebSettings settings = this.getSettings(); settings = getSettings();
browserInitialization(context); browserInitialization(context);
settingsInitialization(context, settings); settingsInitialization(context);
} }
@SuppressWarnings("deprecation")
public void browserInitialization(Context context) { public void browserInitialization(Context context) {
this.setDrawingCacheBackgroundColor(0x00000000); setDrawingCacheBackgroundColor(0x00000000);
this.setFocusableInTouchMode(true); setFocusableInTouchMode(true);
this.setFocusable(true); setFocusable(true);
this.setAnimationCacheEnabled(false); setAnimationCacheEnabled(false);
this.setDrawingCacheEnabled(true); setDrawingCacheEnabled(true);
this.setBackgroundColor(context.getResources().getColor( setBackgroundColor(context.getResources().getColor(
android.R.color.white)); android.R.color.white));
this.setWillNotCacheDrawing(false); if (API >= 16) {
this.setAlwaysDrawnWithCacheEnabled(true); getRootView().setBackground(null);
this.setScrollbarFadingEnabled(true); } else {
this.setSaveEnabled(true); getRootView().setBackgroundDrawable(null);
}
setWillNotCacheDrawing(false);
setAlwaysDrawnWithCacheEnabled(true);
setScrollbarFadingEnabled(true);
setSaveEnabled(true);
} }
@SuppressLint("SetJavaScriptEnabled")
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void settingsInitialization(Context context, WebSettings settings) { public void settingsInitialization(Context context) {
SharedPreferences preferences = context.getSharedPreferences(
"settings", 0);
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true); settings.setAppCacheEnabled(true);
settings.setAppCachePath(context.getFilesDir().getAbsolutePath() settings.setAppCachePath(context.getFilesDir().getAbsolutePath()
+ "/cache"); + "/cache");
if (API < 18) {
settings.setLightTouchEnabled(true);
}
settings.setAllowFileAccess(true); settings.setAllowFileAccess(true);
settings.setDatabaseEnabled(true); settings.setDatabaseEnabled(true);
settings.setDatabasePath(context.getFilesDir().getAbsolutePath() settings.setDatabasePath(context.getFilesDir().getAbsolutePath()
@ -68,54 +83,168 @@ public final class IncognitoWebView extends WebView {
settings.setDisplayZoomControls(false); settings.setDisplayZoomControls(false);
settings.setAllowContentAccess(true); settings.setAllowContentAccess(true);
} }
}
@Override if (preferences.getBoolean("java", true)) {
public boolean onTouchEvent(MotionEvent event) { settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
}
switch (event.getAction()) { if (API < 14) {
case MotionEvent.ACTION_DOWN: { switch (preferences.getInt("textsize", 3)) {
first = true; case 1:
if (API <= 10 && !hasFocus()) { settings.setTextSize(WebSettings.TextSize.LARGEST);
requestFocus(); break;
case 2:
settings.setTextSize(WebSettings.TextSize.LARGER);
break;
case 3:
settings.setTextSize(WebSettings.TextSize.NORMAL);
break;
case 4:
settings.setTextSize(WebSettings.TextSize.SMALLER);
break;
case 5:
settings.setTextSize(WebSettings.TextSize.SMALLEST);
break;
}
} else {
switch (preferences.getInt("textsize", 3)) {
case 1:
settings.setTextZoom(200);
break;
case 2:
settings.setTextZoom(150);
break;
case 3:
settings.setTextZoom(100);
break;
case 4:
settings.setTextZoom(75);
break;
case 5:
settings.setTextZoom(50);
break;
} }
location = event.getY(); }
settings.setSupportMultipleWindows(preferences.getBoolean("newwindow",
true));
switch (preferences.getInt("enableflash", 0)) {
case 0:
break;
case 1: {
settings.setPluginState(PluginState.ON_DEMAND);
break; break;
} }
case MotionEvent.ACTION_UP: { case 2: {
settings.setPluginState(PluginState.ON);
break;
}
default:
break;
}
if (preferences.getBoolean("passwords", false)) {
if (API < 18) {
settings.setSavePassword(true);
}
settings.setSaveFormData(true);
}
if (API < 18) {
try {
settings.setRenderPriority(RenderPriority.HIGH);
} catch (SecurityException ignored) {
if (showFullScreen && first) {
if (uBar.isShown() && getScrollY() < 5) {
uBar.startAnimation(slideUp);
} else if ((event.getY() - location) > 20.0 && !uBar.isShown()) {
uBar.startAnimation(slideDown);
} else if ((event.getY() - location) < -20.0 && uBar.isShown()) {
uBar.startAnimation(slideUp);
}
first = false;
} }
break;
} }
settings.setGeolocationEnabled(preferences
.getBoolean("location", false));
settings.setGeolocationDatabasePath(context.getFilesDir()
.getAbsolutePath());
settings.setUseWideViewPort(preferences
.getBoolean("wideviewport", true));
settings.setLoadWithOverviewMode(preferences.getBoolean("overviewmode",
true));
if (preferences.getBoolean("textreflow", false)) {
settings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
} else {
settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
} }
return mGestureDetector.onTouchEvent(event)
|| super.onTouchEvent(event);
settings.setBlockNetworkImage(preferences.getBoolean("blockimages",
false));
settings.setLoadsImagesAutomatically(true);
switch (preferences.getInt("agentchoose", 1)) {
case 1:
getSettings().setUserAgentString(defaultUser);
break;
case 2:
getSettings().setUserAgentString(
FinalVariables.DESKTOP_USER_AGENT);
break;
case 3:
getSettings().setUserAgentString(
FinalVariables.MOBILE_USER_AGENT);
break;
case 4:
getSettings().setUserAgentString(
preferences.getString("userAgentString", defaultUser));
break;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
mGestureDetector.onTouchEvent(event);
return super.onTouchEvent(event);
} }
@Override @Override
protected void onWindowVisibilityChanged(int visibility) { protected void onWindowVisibilityChanged(int visibility) {
if (API >= 11) { if (API >= 11) {
this.setActivated(visibility == View.VISIBLE); setActivated(visibility == View.VISIBLE);
} }
this.setEnabled(visibility == View.VISIBLE); setEnabled(visibility == View.VISIBLE);
super.onWindowVisibilityChanged(visibility); super.onWindowVisibilityChanged(visibility);
} }
private final GestureDetector mGestureDetector; private final GestureDetector mGestureDetector;
private class CustomGestureListener extends SimpleOnGestureListener { private class CustomGestureListener extends SimpleOnGestureListener {
private final int SWIPE_THRESHOLD = 100; final int SWIPE_THRESHOLD = 100;
private final int SWIPE_VELOCITY_THRESHOLD = 100; final int SWIPE_VELOCITY_THRESHOLD = 100;
@Override
public boolean onDown(MotionEvent e) {
first = true;
return super.onDown(e);
}
@Override
public void onLongPress(MotionEvent e) {
if (IncognitoModeActivity.currentId != -1) {
IncognitoModeActivity.onLongClick();
}
super.onLongPress(e);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
if (showFullScreen && first) {
if (uBar.isShown() && getScrollY() < 5) {
uBar.startAnimation(slideUp);
} else if (distanceY < -5 && !uBar.isShown()) {
uBar.startAnimation(slideDown);
} else if (distanceY > 5 && uBar.isShown()) {
uBar.startAnimation(slideUp);
}
first = false;
}
return super.onScroll(e1, e2, distanceX, distanceY);
}
@Override @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
@ -136,18 +265,17 @@ public final class IncognitoWebView extends WebView {
width = size.x; width = size.x;
} }
if ((width - e1.getX() < width/12) || (e1.getX() < width/12)) { if ((width - e1.getX() < width / 12)
|| (e1.getX() < width / 12)) {
float diffY = e2.getY() - e1.getY(); float diffY = e2.getY() - e1.getY();
float diffX = e2.getX() - e1.getX(); float diffX = e2.getX() - e1.getX();
if (Math.abs(diffX) > Math.abs(diffY)) { if (Math.abs(diffX) > Math.abs(diffY)) {
if (Math.abs(diffX) > SWIPE_THRESHOLD if (Math.abs(diffX) > SWIPE_THRESHOLD
&& Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
if (diffX > 0) { if (diffX > 0) {
IncognitoModeActivity.goBack(); IncognitoModeActivity.goBack(IncognitoWebView.this);
return false;
} else { } else {
IncognitoModeActivity.goForward(); IncognitoModeActivity.goForward(IncognitoWebView.this);
return false;
} }
} }
} }
@ -156,7 +284,7 @@ public final class IncognitoWebView extends WebView {
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
return false; return super.onFling(e1, e2, velocityX, velocityY);
} }
} }

3
src/acr/browser/barebones/incognitoclasses/IncognitoChromeClient.java

@ -136,8 +136,9 @@ public class IncognitoChromeClient extends WebChromeClient {
if (mCustomView == null && mCustomViewCallback == null) { if (mCustomView == null && mCustomViewCallback == null) {
return; return;
} }
mCustomView = null;
mCustomView.setKeepScreenOn(false); mCustomView.setKeepScreenOn(false);
mCustomView = null;
IncognitoModeActivity.onHideCustomView(fullScreenContainer, mCustomViewCallback, orientation); IncognitoModeActivity.onHideCustomView(fullScreenContainer, mCustomViewCallback, orientation);
} }

2
src/acr/browser/barebones/incognitoclasses/IncognitoLongClickListener.java

@ -8,7 +8,7 @@ public class IncognitoLongClickListener implements OnLongClickListener{
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
return IncognitoModeActivity.onLongClick(v.getId()); return IncognitoModeActivity.onLongClick();
} }
} }

1
src/acr/browser/barebones/utilities/FinalVariables.java

@ -15,6 +15,7 @@ public class FinalVariables {
public static final String GOOGLE_SEARCH = "https://www.google.com/search?client=lightning&q="; public static final String GOOGLE_SEARCH = "https://www.google.com/search?client=lightning&q=";
public static final String BING_SEARCH = "http://www.bing.com/search?q="; public static final String BING_SEARCH = "http://www.bing.com/search?q=";
public static final String DUCK_SEARCH = "https://duckduckgo.com/?t=lightning&q="; public static final String DUCK_SEARCH = "https://duckduckgo.com/?t=lightning&q=";
public static final String DUCK_LITE_SEARCH = "https://duckduckgo.com/lite/?q=";
public static final String STARTPAGE_SEARCH = "https://startpage.com/do/metasearch.pl?language=english&cat=web&query="; 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 HOMEPAGE = "https://www.google.com/";
public static final String BAIDU_SEARCH = "http://www.baidu.com/s?wd="; public static final String BAIDU_SEARCH = "http://www.baidu.com/s?wd=";

2
src/acr/browser/barebones/utilities/Utils.java

@ -7,6 +7,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import acr.browser.barebones.databases.DatabaseHandler; import acr.browser.barebones.databases.DatabaseHandler;
import acr.browser.barebones.databases.HistoryItem; import acr.browser.barebones.databases.HistoryItem;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
@ -27,6 +28,7 @@ import android.os.Environment;
import android.provider.Browser; import android.provider.Browser;
import android.util.Log; import android.util.Log;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
public class Utils { public class Utils {

3
src/acr/browser/barebones/webviewclasses/CustomChromeClient.java

@ -136,8 +136,9 @@ public class CustomChromeClient extends WebChromeClient {
if (mCustomView == null && mCustomViewCallback == null) { if (mCustomView == null && mCustomViewCallback == null) {
return; return;
} }
mCustomView = null;
mCustomView.setKeepScreenOn(false); mCustomView.setKeepScreenOn(false);
mCustomView = null;
BrowserActivity.onHideCustomView(fullScreenContainer, mCustomViewCallback, orientation); BrowserActivity.onHideCustomView(fullScreenContainer, mCustomViewCallback, orientation);
} }

2
src/acr/browser/barebones/webviewclasses/WebPageLongClickListener.java

@ -8,7 +8,7 @@ public class WebPageLongClickListener implements OnLongClickListener{
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
return BrowserActivity.onLongClick(v.getId()); return BrowserActivity.onLongClick();
} }
} }

Loading…
Cancel
Save