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. 22
      res/layout/two_line_autocomplete.xml
  5. 2
      res/values-zh-rCN/strings.xml
  6. 31
      res/values-zh-rTW/strings.xml
  7. 1
      src/acr/browser/barebones/activities/AdvancedSettingsActivity.java
  8. 166
      src/acr/browser/barebones/activities/BrowserActivity.java
  9. 146
      src/acr/browser/barebones/activities/IncognitoModeActivity.java
  10. 7
      src/acr/browser/barebones/customwebview/CustomWebView.java
  11. 7
      src/acr/browser/barebones/customwebview/IncognitoWebView.java
  12. 4
      src/acr/browser/barebones/incognitoclasses/IncognitoWebViewClient.java
  13. 2
      src/acr/browser/barebones/utilities/FinalVariables.java
  14. 4
      src/acr/browser/barebones/webviewclasses/CustomWebViewClient.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="56"
android:versionName="2.5.1.2" >
android:versionCode="60"
android:versionName="2.5.1.4" >
<uses-sdk
android:minSdkVersion="8"

BIN
Barebones.apk → BrowserActivity.apk

Binary file not shown.

2
README.md

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#Lightning Browser
#![](ic_launcher_small.png)
####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)

22
res/layout/two_line_autocomplete.xml

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

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

@ -57,4 +57,4 @@ @@ -57,4 +57,4 @@
<string name="clear_cookies">清除浏览器 Cookies</string>
<string name="gestures">启用前进后退手势控制</string>
</resources>
</resources>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -17,7 +17,7 @@ public class FinalVariables { @@ -17,7 +17,7 @@ public class FinalVariables {
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 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 YANDEX_SEARCH = "http://yandex.ru/yandsearch?lr=21411&text=";
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 { @@ -31,8 +31,8 @@ public class CustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("market://")
|| url.startsWith("http://play.google.com")
|| url.startsWith("https://play.google.com")) {
|| url.startsWith("http://play.google.com/store/apps")
|| url.startsWith("https://play.google.com/store/apps")) {
Intent urlIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
urlIntent.putExtra("acr.browser.barebones.Origin",

Loading…
Cancel
Save