Browse Source

Play Store sync

Fixed some crashes, stabilized the code
master
Anthony Restaino 11 years ago
parent
commit
a383f8e778
  1. 4
      AndroidManifest.xml
  2. BIN
      BrowserActivity.apk
  3. 2
      README.md
  4. 10
      res/layout/two_line_autocomplete.xml
  5. 29
      res/values-zh-rTW/strings.xml
  6. 1
      src/acr/browser/barebones/activities/AdvancedSettingsActivity.java
  7. 158
      src/acr/browser/barebones/activities/BrowserActivity.java
  8. 136
      src/acr/browser/barebones/activities/IncognitoModeActivity.java
  9. 7
      src/acr/browser/barebones/customwebview/CustomWebView.java
  10. 7
      src/acr/browser/barebones/customwebview/IncognitoWebView.java
  11. 4
      src/acr/browser/barebones/incognitoclasses/IncognitoWebViewClient.java
  12. 2
      src/acr/browser/barebones/utilities/FinalVariables.java
  13. 4
      src/acr/browser/barebones/webviewclasses/CustomWebViewClient.java

4
AndroidManifest.xml

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

BIN
Barebones.apk → BrowserActivity.apk

Binary file not shown.

2
README.md

@ -1,7 +1,7 @@
#Lightning Browser #Lightning Browser
#![](ic_launcher_small.png) #![](ic_launcher_small.png)
####Download ####Download
* [Download APK from here](https://github.com/anthonycr/Lightning-Browser/blob/master/Barebones.apk?raw=true) * [Download APK from here](https://github.com/anthonycr/Lightning-Browser/blob/master/BrowserActivity.apk?raw=true)
* [Download from Google Play](https://play.google.com/store/apps/details?id=acr.browser.barebones) * [Download from Google Play](https://play.google.com/store/apps/details?id=acr.browser.barebones)

10
res/layout/two_line_autocomplete.xml

@ -17,15 +17,17 @@
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:paddingLeft="6dip" android:paddingLeft="6dip"
android:paddingTop="2dip"/> android:paddingTop="2dip"/>
<TextView <TextView
android:id="@+id/url" android:id="@+id/url"
android:clickable="false"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:textColor="@color/dark" android:clickable="false"
android:paddingLeft="6dip"
android:maxLines="1" android:maxLines="1"
android:paddingBottom="2dip"
android:paddingLeft="6dip"
android:paddingTop="2dip" android:paddingTop="2dip"
android:paddingBottom="2dip"/> android:textColor="@color/light" />
</LinearLayout> </LinearLayout>

29
res/values-zh-rTW/strings.xml

@ -3,7 +3,7 @@
<string name="app_name">Lightning</string> <string name="app_name">Lightning</string>
<string name="google">Google</string> <string name="google">Google</string>
<string name="settings">瀏覽器設</string> <string name="settings">瀏覽器設</string>
<string name="location">允許站點訪問地理位置</string> <string name="location">允許站點訪問地理位置</string>
<string name="password">保存密碼</string> <string name="password">保存密碼</string>
<string name="agent">User Agent</string> <string name="agent">User Agent</string>
@ -13,21 +13,21 @@
<string name="mobile">作為移動設備訪問</string> <string name="mobile">作為移動設備訪問</string>
<string name="desk">作為桌面設備訪問</string> <string name="desk">作為桌面設備訪問</string>
<string name="custom">自定義 User Agent</string> <string name="custom">自定義 User Agent</string>
<string name="home">設定首頁</string> <string name="home">首頁</string>
<string name="settingshelp">定僅將程式於新標簽頁</string> <string name="settingshelp">置僅將應用於新標簽頁</string>
<string name="fullscreen">啟用全屏模式</string> <string name="fullscreen">啟用全屏模式</string>
<string name="java">啟用 JavaScript</string> <string name="java">啟用 JavaScript</string>
<string name="saveTab">恢復丟失標簽</string> <string name="saveTab">恢復丟失標簽</string>
<string name="settings_title">程式設定</string> <string name="settings_title">設置</string>
<string name="download">下載目錄</string> <string name="download">下載位置</string>
<string name="advanced">高級設</string> <string name="advanced">高級設</string>
<string name="source">源碼</string> <string name="source">源碼</string>
<string name="license">許可</string> <string name="license">許可</string>
<string name="github">github.com/anthonycr/Lightning-Browser</string> <string name="github">github.com/anthonycr/Lightning-Browser</string>
<string name="apache">Apache License 2.0</string> <string name="apache">Apache License 2.0</string>
<string name="title_activity_new_settings">NewSettings</string> <string name="title_activity_new_settings">NewSettings</string>
<string name="action_settings">程式設定</string> <string name="action_settings">設置</string>
<string name="version">當前版本</string> <string name="version">應用版本</string>
<string name="cache">退出時清理緩存</string> <string name="cache">退出時清理緩存</string>
<string name="reflow">啟用文本重排</string> <string name="reflow">啟用文本重排</string>
<string name="block">屏蔽網頁圖像</string> <string name="block">屏蔽網頁圖像</string>
@ -38,7 +38,7 @@
<string name="title_activity_advanced_settings">AdvancedSettings</string> <string name="title_activity_advanced_settings">AdvancedSettings</string>
<string name="hello_world">Hello world!</string> <string name="hello_world">Hello world!</string>
<string name="recommended">(推薦)</string> <string name="recommended">(推薦)</string>
<string name="weird_look">可能導致部分網頁排版混亂</string> <string name="weird_look">部分網頁可能看起來很奇怪</string>
<string name="search">搜索引擎</string> <string name="search">搜索引擎</string>
<string name="search_hint">搜索</string> <string name="search_hint">搜索</string>
<string name="wideViewPort">使用寬視圖</string> <string name="wideViewPort">使用寬視圖</string>
@ -48,13 +48,10 @@
<string name="menu_add">添加書簽</string> <string name="menu_add">添加書簽</string>
<string name="menu_bookmarks">書簽列表</string> <string name="menu_bookmarks">書簽列表</string>
<string name="menu_share">分享頁面</string> <string name="menu_share">分享頁面</string>
<string name="menu_settings">程式設定</string> <string name="menu_settings">應用設置</string>
<string name="menu_incognito">隱身標簽</string> <string name="menu_incognito">隱身標簽</string>
<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>
<string name="gestures">啟用前進後退手勢控制</string>
</resources> </resources>

1
src/acr/browser/barebones/activities/AdvancedSettingsActivity.java

@ -681,7 +681,6 @@ public class AdvancedSettingsActivity extends Activity {
Cursor mCur; Cursor mCur;
mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj, mCur = getContentResolver().query(Browser.BOOKMARKS_URI, proj,
sel, null, null); sel, null, null);
mCur.moveToFirst();
String title = ""; String title = "";
String url = ""; String url = "";

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

@ -7,8 +7,11 @@ 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 java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
@ -33,6 +36,8 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
@ -51,6 +56,7 @@ import android.provider.Browser;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
@ -58,6 +64,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
@ -158,6 +165,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
public static final String HOMEPAGE = FinalVariables.HOMEPAGE; public static final String HOMEPAGE = FinalVariables.HOMEPAGE;
public static final int API = FinalVariables.API; public static final int API = FinalVariables.API;
public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|"; public static final String SEPARATOR = "\\|\\$\\|SEPARATOR\\|\\$\\|";
public static boolean DEVICE_HAS_GPS = false; public static boolean DEVICE_HAS_GPS = false;
// semi constants // semi constants
public static Context CONTEXT; public static Context CONTEXT;
@ -438,7 +446,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
if (API > 8) { if (API > 8) {
view.setDownloadListener(new CustomDownloadListener(ACTIVITY)); view.setDownloadListener(new CustomDownloadListener(ACTIVITY));
} }
main[pageToView] = view;
if (display) { if (display) {
if (currentId != -1) { if (currentId != -1) {
background.removeView(currentTab); background.removeView(currentTab);
@ -455,8 +463,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} else if (Url.contains("about:blank")) { } else if (Url.contains("about:blank")) {
view.loadUrl(""); view.loadUrl("");
} else { } else {
searchTheWeb(Url, CONTEXT); view.loadUrl(Url);
} }
Log.i("Browser", "tab complete"); Log.i("Browser", "tab complete");
return view; return view;
@ -475,6 +482,29 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
static List<Map<String, String>> getBookmarks() {
List<Map<String, String>> bookmarks = new ArrayList<Map<String, String>>();
File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl");
File book = new File(CONTEXT.getFilesDir(), "bookmarks");
try {
BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl));
BufferedReader readBook = new BufferedReader(new FileReader(book));
String u, t;
while ((u = readUrl.readLine()) != null
&& (t = readBook.readLine()) != null) {
Map<String, String> map = new HashMap<String, String>();
map.put("title", '\u2605' + " " + t);
map.put("url", u);
bookmarks.add(map);
}
readBook.close();
readUrl.close();
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {
}
return bookmarks;
}
static void goBookmarks(Context context, CustomWebView view) { static void goBookmarks(Context context, CustomWebView view) {
File book = new File(context.getFilesDir(), "bookmarks"); File book = new File(context.getFilesDir(), "bookmarks");
File bookUrl = new File(context.getFilesDir(), "bookurl"); File bookUrl = new File(context.getFilesDir(), "bookurl");
@ -583,6 +613,10 @@ public class BrowserActivity extends Activity implements OnTouchListener {
public static void onHideCustomView(FrameLayout fullScreenContainer, public static void onHideCustomView(FrameLayout fullScreenContainer,
CustomViewCallback mCustomViewCallback, int orientation) { CustomViewCallback mCustomViewCallback, int orientation) {
if (!settings.getBoolean("hidestatus", false)) {
ACTIVITY.getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView(); FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView();
screen.removeView(fullScreenContainer); screen.removeView(fullScreenContainer);
fullScreenContainer = null; fullScreenContainer = null;
@ -593,8 +627,8 @@ public class BrowserActivity extends Activity implements OnTouchListener {
uBar.bringToFront(); uBar.bringToFront();
} }
private static Message click; private static Message click;
public static boolean onLongClick() { public static boolean onLongClick() {
int n = currentId; int n = currentId;
if (currentId == -1 || currentTab == null) { if (currentId == -1 || currentTab == null) {
@ -724,8 +758,8 @@ public class BrowserActivity extends Activity implements OnTouchListener {
Log.i("Lightning", "Load Time: " + loadTime); Log.i("Lightning", "Load Time: " + loadTime);
} }
private static int numberPage; private static int numberPage;
public static void onPageStarted(WebView view, String url, Bitmap favicon) { public static void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.i("Lightning", "Page Started"); Log.i("Lightning", "Page Started");
loadTime = System.currentTimeMillis(); loadTime = System.currentTimeMillis();
@ -779,6 +813,9 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
public static void onShowCustomView() { public static void onShowCustomView() {
ACTIVITY.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
background.removeView(currentTab); background.removeView(currentTab);
uBar.setVisibility(View.GONE); uBar.setVisibility(View.GONE);
} }
@ -831,7 +868,6 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
} }
public static void renameBookmark(String url) { public static void renameBookmark(String url) {
index = 0; index = 0;
for (int n = 0; n < MAX_BOOKMARKS; n++) { for (int n = 0; n < MAX_BOOKMARKS; n++) {
@ -929,7 +965,12 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} else if (query.contains("about:history")) { } else if (query.contains("about:history")) {
generateHistory(currentTab, context); generateHistory(currentTab, context);
} else if (isSearch) { } else if (isSearch) {
query.replaceAll(" ", "+"); try {
URLEncoder.encode(query, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
currentTab.loadUrl(SEARCH + query); currentTab.loadUrl(SEARCH + query);
} else if (!validURL) { } else if (!validURL) {
currentTab.loadUrl("http://" + query); currentTab.loadUrl("http://" + query);
@ -1022,6 +1063,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
clearCache();
finish(); finish();
return true; return true;
} }
@ -1063,8 +1105,17 @@ public class BrowserActivity extends Activity implements OnTouchListener {
}); });
findNewView(del); findNewView(del);
if (main[del] != null) {
if (API > 11) {
main[del].onPause();
}
if (main[del].isShown()) {
background.removeView(main[del]);
}
main[del].removeAllViews();
main[del] = null; main[del] = null;
} }
}
@Override @Override
public void onAnimationRepeat(Animation animation) { public void onAnimationRepeat(Animation animation) {
@ -1129,6 +1180,11 @@ public class BrowserActivity extends Activity implements OnTouchListener {
getUrl.setBackgroundResource(R.drawable.book); getUrl.setBackgroundResource(R.drawable.book);
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
final List<Map<String, String>> list = new ArrayList<Map<String, String>>(); final List<Map<String, String>> list = new ArrayList<Map<String, String>>();
List<Map<String, String>> books = getBookmarks();
Iterator<Map<String, String>> it = books.iterator();
while (it.hasNext()) {
list.add(it.next());
}
handler = new Handler() { handler = new Handler() {
@Override @Override
@ -1350,24 +1406,54 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
tabList.remove(delete); tabList.remove(delete);
if (!(right || left)) { if (!(right || left)) {
if (API > 11) {
currentTab.onPause();
}
currentTab.pauseTimers();
clearCache();
currentTab = null;
finish(); finish();
} }
uBar.bringToFront(); uBar.bringToFront();
tabScroll.smoothScrollTo(currentTabTitle.getLeft(), 0); tabScroll.smoothScrollTo(currentTabTitle.getLeft(), 0);
} }
public void clearCache() {
if (settings.getBoolean("cache", false) && currentTab != null) {
currentTab.clearCache(true);
Log.i("Lightning", "Cache Cleared");
}
for (int n = 0; n < MAX_TABS; n++) {
if (main[n] != null) {
main[n].removeAllViews();
main[n] = null;
}
}
}
@Override @Override
public void finish() { public void finish() {
background.clearDisappearingChildren(); background.clearDisappearingChildren();
background.removeView(currentTab); background.removeView(currentTab);
tabScroll.clearDisappearingChildren(); tabScroll.clearDisappearingChildren();
if (settings.getBoolean("cache", false)) {
currentTab.clearCache(true);
Log.i("Lightning", "Cache Cleared");
}
super.finish(); super.finish();
} }
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
}
void forward() { void forward() {
ImageView forward = (ImageView) findViewById(R.id.forward); ImageView forward = (ImageView) findViewById(R.id.forward);
forward.setBackgroundResource(R.drawable.button); forward.setBackgroundResource(R.drawable.button);
@ -1558,12 +1644,12 @@ public class BrowserActivity extends Activity implements OnTouchListener {
@Override @Override
public void run() { public void run() {
reopenOldTabs(); // restores old tabs or creates a new one // restores old tabs or creates a new one
} }
}); });
startup.run(); startup.run();
reopenOldTabs();
// new tab button // new tab button
ImageView newTab = (ImageView) findViewById(R.id.newTab); ImageView newTab = (ImageView) findViewById(R.id.newTab);
newTab.setBackgroundResource(R.drawable.button); newTab.setBackgroundResource(R.drawable.button);
@ -1717,6 +1803,16 @@ public class BrowserActivity extends Activity implements OnTouchListener {
isPhone = sizeInInches < 6.5; isPhone = sizeInInches < 6.5;
forward();// forward button forward();// forward button
back(); back();
PackageInfo p;
int code = 0;
try {
p = getPackageManager().getPackageInfo(getPackageName(), 0);
code = p.versionCode;
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (settings.getInt("first", 0) == 0) { if (settings.getInt("first", 0) == 0) {
// navigation tips // navigation tips
String message = "1. Long-press back button to exit browser\n\n" String message = "1. Long-press back button to exit browser\n\n"
@ -1727,6 +1823,10 @@ public class BrowserActivity extends Activity implements OnTouchListener {
Utils.createInformativeDialog(CONTEXT, "Browser Tips", message); Utils.createInformativeDialog(CONTEXT, "Browser Tips", message);
edit.putInt("first", 1); edit.putInt("first", 1);
edit.putInt("version", code);
edit.commit();
} else if (settings.getInt("version", code - 1) != code) {
edit.putInt("version", code);
edit.commit(); edit.commit();
} }
} }
@ -1769,6 +1869,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
case KeyEvent.KEYCODE_F12: { case KeyEvent.KEYCODE_F12: {
clearCache();
finish(); finish();
} }
case KeyEvent.KEYCODE_F6: { case KeyEvent.KEYCODE_F6: {
@ -1799,6 +1900,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
urlToLoad[n][0] = null; urlToLoad[n][0] = null;
} }
} }
clearCache();
finish(); finish();
return true; return true;
} else } else
@ -1883,13 +1985,17 @@ public class BrowserActivity extends Activity implements OnTouchListener {
@Override @Override
protected void onPause() { protected void onPause() {
if (currentTab != null) { if (currentTab != null) {
if (API >= 11) { if (API >= 11) {
currentTab.onPause(); currentTab.onPause();
for (int n = 0; n < MAX_TABS; n++) {
if (main[n] != null)
main[n].onPause();
}
} }
currentTab.pauseTimers(); currentTab.pauseTimers();
} }
Thread remember = new Thread(new Runnable() { Thread remember = new Thread(new Runnable() {
@Override @Override
@ -1920,11 +2026,15 @@ public class BrowserActivity extends Activity implements OnTouchListener {
} }
if (API >= 11) { if (API >= 11) {
currentTab.onResume(); currentTab.onResume();
for (int n = 0; n < MAX_TABS; n++) {
if (main[n] != null)
main[n].onResume();
}
} }
} }
gestures = settings.getBoolean("gestures", true); gestures = settings.getBoolean("gestures", true);
reinitializeSettings();
currentTab.resumeTimers(); currentTab.resumeTimers();
reinitializeSettings();
if (settings.getBoolean("fullscreen", false) != fullScreen) { if (settings.getBoolean("fullscreen", false) != fullScreen) {
toggleFullScreen(); toggleFullScreen();
} }
@ -1935,11 +2045,21 @@ public class BrowserActivity extends Activity implements OnTouchListener {
private int y; private int y;
private boolean xPress; private boolean xPress;
private Rect edge; private Rect edge;
private final GestureDetector mGestureDetector = new GestureDetector(
CONTEXT, new CustomGestureListener());
private class CustomGestureListener extends SimpleOnGestureListener {
@Override
public void onLongPress(MotionEvent e) {
deleteTab(id);
super.onLongPress(e);
}
}
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
try {
id = v.getId(); id = v.getId();
try {
background.clearDisappearingChildren(); background.clearDisappearingChildren();
xPress = false; xPress = false;
x = (int) event.getX(); x = (int) event.getX();
@ -1948,13 +2068,8 @@ public class BrowserActivity extends Activity implements OnTouchListener {
v.getDrawingRect(edge); v.getDrawingRect(edge);
currentTabTitle.setPadding(leftPad, 0, rightPad, 0); currentTabTitle.setPadding(leftPad, 0, rightPad, 0);
if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getAction() == MotionEvent.ACTION_DOWN) {
timeTabPressed = System.currentTimeMillis();
} else if (event.getAction() == MotionEvent.ACTION_UP) { } else if (event.getAction() == MotionEvent.ACTION_UP) {
if ((System.currentTimeMillis() - timeTabPressed) > 1000) {
xPress = true;
}
if (x >= (edge.right - bounds.width() - v.getPaddingRight() - 10 * 3 / 2) if (x >= (edge.right - bounds.width() - v.getPaddingRight() - 10 * 3 / 2)
&& x <= (edge.right - v.getPaddingRight() + 10 * 3 / 2) && x <= (edge.right - v.getPaddingRight() + 10 * 3 / 2)
&& y >= (v.getPaddingTop() - 10 / 2) && y >= (v.getPaddingTop() - 10 / 2)
@ -2029,6 +2144,7 @@ public class BrowserActivity extends Activity implements OnTouchListener {
e.printStackTrace(); e.printStackTrace();
Log.e("Lightning Error", "Well we dun messed up"); Log.e("Lightning Error", "Well we dun messed up");
} }
mGestureDetector.onTouchEvent(event);
return true; return true;
} }

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

@ -7,8 +7,11 @@ 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 java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
@ -50,6 +53,7 @@ import android.provider.Browser;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
@ -57,6 +61,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnKeyListener; import android.view.View.OnKeyListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
@ -216,6 +221,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
public static Drawable inactive; public static Drawable inactive;
public static Drawable active; public static Drawable active;
public static LinearLayout tabLayout; public static LinearLayout tabLayout;
// creates the tab and returns the ID of the view // creates the tab and returns the ID of the view
public static int createTab(String theUrl, boolean display) { public static int createTab(String theUrl, boolean display) {
int id = -1; int id = -1;
@ -299,6 +305,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
return id; return id;
} }
public static void deleteBookmark(String url) { public static void deleteBookmark(String url) {
File book = new File(CONTEXT.getFilesDir(), "bookmarks"); File book = new File(CONTEXT.getFilesDir(), "bookmarks");
File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl"); File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl");
@ -422,8 +429,8 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
history.run(); history.run();
} }
public static IncognitoWebView generateTab(final int pageToView, String Url, public static IncognitoWebView generateTab(final int pageToView,
final boolean display) { String Url, final boolean display) {
IncognitoWebView view = new IncognitoWebView(CONTEXT); IncognitoWebView view = new IncognitoWebView(CONTEXT);
view.setId(pageToView); view.setId(pageToView);
view.setWebViewClient(new IncognitoWebViewClient(ACTIVITY)); view.setWebViewClient(new IncognitoWebViewClient(ACTIVITY));
@ -431,7 +438,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
if (API > 8) { if (API > 8) {
view.setDownloadListener(new IncognitoDownloadListener(ACTIVITY)); view.setDownloadListener(new IncognitoDownloadListener(ACTIVITY));
} }
main[pageToView] = view;
if (display) { if (display) {
if (currentId != -1) { if (currentId != -1) {
background.removeView(currentTab); background.removeView(currentTab);
@ -448,7 +455,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} else if (Url.contains("about:blank")) { } else if (Url.contains("about:blank")) {
view.loadUrl(""); view.loadUrl("");
} else { } else {
searchTheWeb(Url, CONTEXT); view.loadUrl(Url);
} }
Log.i("Browser", "tab complete"); Log.i("Browser", "tab complete");
return view; return view;
@ -571,6 +578,10 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
public static void onHideCustomView(FrameLayout fullScreenContainer, public static void onHideCustomView(FrameLayout fullScreenContainer,
CustomViewCallback mCustomViewCallback, int orientation) { CustomViewCallback mCustomViewCallback, int orientation) {
if (!settings.getBoolean("hidestatus", false)) {
ACTIVITY.getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView(); FrameLayout screen = (FrameLayout) ACTIVITY.getWindow().getDecorView();
screen.removeView(fullScreenContainer); screen.removeView(fullScreenContainer);
fullScreenContainer = null; fullScreenContainer = null;
@ -582,6 +593,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
private static Message click; private static Message click;
public static boolean onLongClick() { public static boolean onLongClick() {
int n = currentId; int n = currentId;
if (currentId == -1 || currentTab == null) { if (currentId == -1 || currentTab == null) {
@ -713,6 +725,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
private static int numberPage; private static int numberPage;
public static void onPageStarted(WebView view, String url, Bitmap favicon) { public static void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.i("Lightning", "Page Started"); Log.i("Lightning", "Page Started");
loadTime = System.currentTimeMillis(); loadTime = System.currentTimeMillis();
@ -764,6 +777,9 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
public static void onShowCustomView() { public static void onShowCustomView() {
ACTIVITY.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
background.removeView(currentTab); background.removeView(currentTab);
uBar.setVisibility(View.GONE); uBar.setVisibility(View.GONE);
} }
@ -813,7 +829,6 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
} }
public static void renameBookmark(String url) { public static void renameBookmark(String url) {
index = 0; index = 0;
for (int n = 0; n < MAX_BOOKMARKS; n++) { for (int n = 0; n < MAX_BOOKMARKS; n++) {
@ -911,7 +926,12 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} else if (query.contains("about:history")) { } else if (query.contains("about:history")) {
generateHistory(currentTab, context); generateHistory(currentTab, context);
} else if (isSearch) { } else if (isSearch) {
query.replaceAll(" ", "+"); try {
URLEncoder.encode(query, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
currentTab.loadUrl(SEARCH + query); currentTab.loadUrl(SEARCH + query);
} else if (!validURL) { } else if (!validURL) {
currentTab.loadUrl("http://" + query); currentTab.loadUrl("http://" + query);
@ -924,9 +944,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
Drawable icon; Drawable icon;
icon = new BitmapDrawable(null, favicon); icon = new BitmapDrawable(null, favicon);
icon.setBounds(0, 0, width / 2, height / 2); icon.setBounds(0, 0, width / 2, height / 2);
urlTitle[id] urlTitle[id].setCompoundDrawables(incognitoPage, null, exitTab, null);
.setCompoundDrawables(incognitoPage, null, exitTab, null);
} }
@ -1000,6 +1018,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
clearCache();
finish(); finish();
return true; return true;
} }
@ -1041,8 +1060,17 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
}); });
findNewView(del); findNewView(del);
if (main[del] != null) {
if (API > 11) {
main[del].onPause();
}
if (main[del].isShown()) {
background.removeView(main[del]);
}
main[del].removeAllViews();
main[del] = null; main[del] = null;
} }
}
@Override @Override
public void onAnimationRepeat(Animation animation) { public void onAnimationRepeat(Animation animation) {
@ -1098,6 +1126,29 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
}); });
} }
static List<Map<String, String>> getBookmarks() {
List<Map<String, String>> bookmarks = new ArrayList<Map<String, String>>();
File bookUrl = new File(CONTEXT.getFilesDir(), "bookurl");
File book = new File(CONTEXT.getFilesDir(), "bookmarks");
try {
BufferedReader readUrl = new BufferedReader(new FileReader(bookUrl));
BufferedReader readBook = new BufferedReader(new FileReader(book));
String u, t;
while ((u = readUrl.readLine()) != null
&& (t = readBook.readLine()) != null) {
Map<String, String> map = new HashMap<String, String>();
map.put("title", '\u2605' + " " + t);
map.put("url", u);
bookmarks.add(map);
}
readBook.close();
readUrl.close();
} catch (FileNotFoundException ignored) {
} catch (IOException ignored) {
}
return bookmarks;
}
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
void enterUrl() { void enterUrl() {
getUrl = (MultiAutoCompleteTextView) findViewById(R.id.enterUrl); getUrl = (MultiAutoCompleteTextView) findViewById(R.id.enterUrl);
@ -1107,6 +1158,11 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
getUrl.setBackgroundResource(R.drawable.book); getUrl.setBackgroundResource(R.drawable.book);
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
final List<Map<String, String>> list = new ArrayList<Map<String, String>>(); final List<Map<String, String>> list = new ArrayList<Map<String, String>>();
List<Map<String, String>> books = getBookmarks();
Iterator<Map<String, String>> it = books.iterator();
while (it.hasNext()) {
list.add(it.next());
}
handler = new Handler() { handler = new Handler() {
@Override @Override
@ -1328,24 +1384,47 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
tabList.remove(delete); tabList.remove(delete);
if (!(right || left)) { if (!(right || left)) {
if (API > 11) {
currentTab.onPause();
}
currentTab.pauseTimers();
clearCache();
currentTab = null;
finish(); finish();
} }
uBar.bringToFront(); uBar.bringToFront();
tabScroll.smoothScrollTo(currentTabTitle.getLeft(), 0); tabScroll.smoothScrollTo(currentTabTitle.getLeft(), 0);
} }
public void clearCache() {
if (settings.getBoolean("cache", false) && currentTab != null) {
currentTab.clearCache(true);
Log.i("Lightning", "Cache Cleared");
}
for (int n = 0; n < MAX_TABS; n++) {
if (main[n] != null) {
main[n].removeAllViews();
main[n] = null;
}
}
}
@Override @Override
public void finish() { public void finish() {
background.clearDisappearingChildren(); background.clearDisappearingChildren();
background.removeView(currentTab); background.removeView(currentTab);
tabScroll.clearDisappearingChildren(); tabScroll.clearDisappearingChildren();
if (settings.getBoolean("cache", false)) {
currentTab.clearCache(true);
Log.i("Lightning", "Cache Cleared");
}
super.finish(); super.finish();
} }
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
}
void forward() { void forward() {
ImageView forward = (ImageView) findViewById(R.id.forward); ImageView forward = (ImageView) findViewById(R.id.forward);
forward.setBackgroundResource(R.drawable.button); forward.setBackgroundResource(R.drawable.button);
@ -1676,10 +1755,10 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
back(); back();
if (settings.getInt("firstIncognito", 0) == 0) { if (settings.getInt("firstIncognito", 0) == 0) {
// navigation tips // navigation tips
String message = "Incognito Mode keeps you safe while browsing the internet." + String message = "Incognito Mode keeps you safe while browsing the internet."
" History is not saved, Cookies are disabled, and Location access is " + + " History is not saved, Cookies are disabled, and Location access is "
"disabled to ensure as best we can that you are not being tracked. " + + "disabled to ensure as best we can that you are not being tracked. "
"Happy Browsing!"; + "Happy Browsing!";
Utils.createInformativeDialog(CONTEXT, "About Incognito", message); Utils.createInformativeDialog(CONTEXT, "About Incognito", message);
edit.putInt("first", 1); edit.putInt("first", 1);
@ -1725,6 +1804,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
} }
case KeyEvent.KEYCODE_F12: { case KeyEvent.KEYCODE_F12: {
clearCache();
finish(); finish();
} }
case KeyEvent.KEYCODE_F6: { case KeyEvent.KEYCODE_F6: {
@ -1755,6 +1835,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
urlToLoad[n][0] = null; urlToLoad[n][0] = null;
} }
} }
clearCache();
finish(); finish();
return true; return true;
} else } else
@ -1842,6 +1923,10 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
if (currentTab != null) { if (currentTab != null) {
if (API >= 11) { if (API >= 11) {
currentTab.onPause(); currentTab.onPause();
for (int n = 0; n < MAX_TABS; n++) {
if (main[n] != null)
main[n].onPause();
}
} }
currentTab.pauseTimers(); currentTab.pauseTimers();
} }
@ -1872,6 +1957,16 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
private int y; private int y;
private Rect edge; private Rect edge;
private boolean xPress; private boolean xPress;
private final GestureDetector mGestureDetector = new GestureDetector(
CONTEXT, new CustomGestureListener());
private class CustomGestureListener extends SimpleOnGestureListener {
@Override
public void onLongPress(MotionEvent e) {
deleteTab(id);
super.onLongPress(e);
}
}
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
@ -1885,12 +1980,8 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
v.getDrawingRect(edge); v.getDrawingRect(edge);
currentTabTitle.setPadding(leftPad, 0, rightPad, 0); currentTabTitle.setPadding(leftPad, 0, rightPad, 0);
if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getAction() == MotionEvent.ACTION_DOWN) {
timeTabPressed = System.currentTimeMillis();
} else if (event.getAction() == MotionEvent.ACTION_UP) {
if ((System.currentTimeMillis() - timeTabPressed) > 1000) { } else if (event.getAction() == MotionEvent.ACTION_UP) {
xPress = true;
}
if (x >= (edge.right - bounds.width() - v.getPaddingRight() - 10 * 3 / 2) if (x >= (edge.right - bounds.width() - v.getPaddingRight() - 10 * 3 / 2)
&& x <= (edge.right - v.getPaddingRight() + 10 * 3 / 2) && x <= (edge.right - v.getPaddingRight() + 10 * 3 / 2)
@ -1966,6 +2057,7 @@ public class IncognitoModeActivity extends Activity implements OnTouchListener {
e.printStackTrace(); e.printStackTrace();
Log.e("Lightning Error", "Well we dun messed up"); Log.e("Lightning Error", "Well we dun messed up");
} }
mGestureDetector.onTouchEvent(event);
return true; return true;
} }

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

@ -69,6 +69,9 @@ public final class CustomWebView extends WebView {
public void settingsInitialization(Context context) { public void settingsInitialization(Context context) {
SharedPreferences preferences = context.getSharedPreferences( SharedPreferences preferences = context.getSharedPreferences(
"settings", 0); "settings", 0);
if(API < 11){
settings.setLightTouchEnabled(true);
}
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true); settings.setAppCacheEnabled(true);
settings.setAppCachePath(context.getFilesDir().getAbsolutePath() settings.setAppCachePath(context.getFilesDir().getAbsolutePath()
@ -199,6 +202,10 @@ public final class CustomWebView extends WebView {
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if(API < 11){
if(!hasFocus())
requestFocus();
}
mGestureDetector.onTouchEvent(event); mGestureDetector.onTouchEvent(event);
return super.onTouchEvent(event); return super.onTouchEvent(event);
} }

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

@ -68,6 +68,9 @@ public final class IncognitoWebView extends WebView {
public void settingsInitialization(Context context) { public void settingsInitialization(Context context) {
SharedPreferences preferences = context.getSharedPreferences( SharedPreferences preferences = context.getSharedPreferences(
"settings", 0); "settings", 0);
if(API < 11){
settings.setLightTouchEnabled(true);
}
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true); settings.setAppCacheEnabled(true);
settings.setAppCachePath(context.getFilesDir().getAbsolutePath() settings.setAppCachePath(context.getFilesDir().getAbsolutePath()
@ -191,6 +194,10 @@ public final class IncognitoWebView extends WebView {
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if(API < 11){
if(!hasFocus())
requestFocus();
}
mGestureDetector.onTouchEvent(event); mGestureDetector.onTouchEvent(event);
return super.onTouchEvent(event); return super.onTouchEvent(event);
} }

4
src/acr/browser/barebones/incognitoclasses/IncognitoWebViewClient.java

@ -31,8 +31,8 @@ public class IncognitoWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("market://") if (url.startsWith("market://")
|| url.startsWith("http://play.google.com") || url.startsWith("http://play.google.com/store/apps")
|| url.startsWith("https://play.google.com")) { || url.startsWith("https://play.google.com/store/apps")) {
Intent urlIntent = new Intent(Intent.ACTION_VIEW, Intent urlIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url)); Uri.parse(url));
urlIntent.putExtra("acr.browser.barebones.Origin", urlIntent.putExtra("acr.browser.barebones.Origin",

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

@ -17,7 +17,7 @@ public class FinalVariables {
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/?t=lightning&q="; public static final String DUCK_LITE_SEARCH = "https://duckduckgo.com/lite/?t=lightning&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://duckduckgo.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=";
public static final String YANDEX_SEARCH = "http://yandex.ru/yandsearch?lr=21411&text="; public static final String YANDEX_SEARCH = "http://yandex.ru/yandsearch?lr=21411&text=";
public static final String ADVANCED_SETTINGS_INTENT = "android.intent.action.ADVANCED_SETTINGS"; public static final String ADVANCED_SETTINGS_INTENT = "android.intent.action.ADVANCED_SETTINGS";

4
src/acr/browser/barebones/webviewclasses/CustomWebViewClient.java

@ -31,8 +31,8 @@ public class CustomWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("market://") if (url.startsWith("market://")
|| url.startsWith("http://play.google.com") || url.startsWith("http://play.google.com/store/apps")
|| url.startsWith("https://play.google.com")) { || url.startsWith("https://play.google.com/store/apps")) {
Intent urlIntent = new Intent(Intent.ACTION_VIEW, Intent urlIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url)); Uri.parse(url));
urlIntent.putExtra("acr.browser.barebones.Origin", urlIntent.putExtra("acr.browser.barebones.Origin",

Loading…
Cancel
Save