Browse Source

2.4

- added ability to remember tabs that were open when the browser is
closed from low memory
- updated german translation (thanks so much)
- fixed some unresponsiveness in froyo, for some reason
webview.resumeTimers() needed to be called even when the browser
restarted
- changed the UI in settings a bit (more HOLOish)
master
Anthony Restaino 12 years ago
parent
commit
deed4b7f3c
  1. 8
      AndroidManifest.xml
  2. BIN
      res/drawable-xhdpi/clearbg.9.png
  3. 5
      res/drawable/blueback.xml
  4. 1
      res/layout/activity_main.xml
  5. 229
      res/layout/settings.xml
  6. 1
      res/values/strings.xml
  7. 260
      src/acr/browser/barebones/Barebones.java
  8. 31
      src/acr/browser/barebones/Settings.java

8
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="36" android:versionCode="37"
android:versionName="2.3.12" > android:versionName="2.4" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"
@ -21,11 +21,9 @@
<activity <activity
android:name="acr.browser.barebones.Barebones" android:name="acr.browser.barebones.Barebones"
android:label="@string/app_name" android:label="@string/app_name"
android:configChanges="orientation|screenSize|keyboardHidden" android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:alwaysRetainTaskState="true" android:alwaysRetainTaskState="true"
android:launchMode="singleTask" android:launchMode="singleTask"
android:allowTaskReparenting="true"
android:multiprocess="false"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
> >
<intent-filter> <intent-filter>

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

5
res/drawable/blueback.xml

@ -0,0 +1,5 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@color/press"/>
<item android:state_pressed="true" android:drawable="@color/blue" />
<item android:drawable="@drawable/clearbg" />
</selector>

1
res/layout/activity_main.xml

@ -114,6 +114,7 @@
android:id="@+id/progressBar1" android:id="@+id/progressBar1"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="30dp" android:layout_height="30dp"
android:visibility="gone"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:indeterminate="true" android:indeterminate="true"

229
res/layout/settings.xml

@ -47,23 +47,26 @@
<TextView <TextView
android:id="@+id/textView4" android:id="@+id/textView4"
android:layout_width="match_parent" android:layout_width="match_parent"
android:textColor="#ffffffff"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_below="@+id/relativeLayout1" android:layout_below="@+id/relativeLayout1"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:background="#ff0099cc" android:background="#ff0099cc"
android:gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal"
android:text="@string/settingshelp" android:text="@string/settingshelp"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffffff" />
<CheckBox <CheckBox
android:id="@+id/password" android:id="@+id/password"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignLeft="@+id/location" android:layout_alignLeft="@+id/flash"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_below="@+id/location" android:layout_below="@+id/saveTabs"
android:paddingRight="20dp" /> android:layout_marginRight="20dp"
android:background="@drawable/blueback"
android:paddingRight="20dp"
android:text="@string/password" />
<EditText <EditText
android:id="@+id/agent" android:id="@+id/agent"
@ -74,53 +77,64 @@
android:layout_toRightOf="@+id/textView2" android:layout_toRightOf="@+id/textView2"
android:ems="10" android:ems="10"
android:inputType="textUri" android:inputType="textUri"
android:paddingRight="10dp"
android:singleLine="true" >
android:background="@drawable/bookmark"
android:layout_marginRight="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true" >
</EditText> </EditText>
<CheckBox <CheckBox
android:id="@+id/flash" android:id="@+id/flash"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/blueback"
android:layout_below="@+id/password" android:layout_below="@+id/password"
android:paddingRight="20dp" /> android:paddingRight="20dp"
android:text="@string/flash" />
<CheckBox <CheckBox
android:id="@+id/historyClear" android:id="@+id/historyClear"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_below="@+id/flash" android:layout_below="@+id/flash"
android:paddingRight="20dp" /> android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
<RadioButton android:layout_toLeftOf="@+id/flash"
android:id="@+id/radioMobile" android:paddingRight="20dp"
android:layout_width="match_parent" android:background="@drawable/blueback"
android:layout_height="56dp" android:text="@string/history" />
android:layout_alignLeft="@+id/java"
android:layout_below="@+id/java"
android:marqueeRepeatLimit="20"
android:onClick="radioAgent" />
<RadioButton <RadioButton
android:id="@+id/radioDesktop" android:id="@+id/radioDesktop"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignLeft="@+id/radioMobile" android:layout_alignLeft="@+id/radioMobile"
android:layout_below="@+id/radioMobile" android:layout_below="@+id/radioMobile"
android:onClick="radioAgent" android:layout_marginRight="20dp"
android:paddingRight="20dp" /> android:onClick="radioAgent"
android:paddingRight="20dp"
android:background="@drawable/blueback"
android:text="@string/desk" />
<RadioButton <RadioButton
android:id="@+id/radioCustom" android:id="@+id/radioCustom"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignLeft="@+id/radioDesktop" android:layout_alignLeft="@+id/radioDesktop"
android:layout_below="@+id/radioDesktop" android:layout_below="@+id/radioDesktop"
android:onClick="radioAgent" android:background="@drawable/blueback"
android:paddingRight="20dp" /> android:layout_marginRight="20dp"
android:onClick="radioAgent"
android:paddingRight="20dp"
android:text="@string/custom" />
<TextView <TextView
android:id="@+id/textView2" android:id="@+id/textView2"
@ -131,6 +145,8 @@
android:gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="5dp" android:paddingRight="5dp"
android:layout_marginLeft="20dp"
android:text="@string/agent" /> android:text="@string/agent" />
<TextView <TextView
@ -141,6 +157,7 @@
android:layout_below="@+id/textView2" android:layout_below="@+id/textView2"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:layout_marginLeft="20dp"
android:paddingRight="5dp" android:paddingRight="5dp"
android:text="@string/home" /> android:text="@string/home" />
@ -150,10 +167,13 @@
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignLeft="@+id/agent" android:layout_alignLeft="@+id/agent"
android:layout_alignRight="@+id/agent" android:layout_alignRight="@+id/agent"
android:background="@drawable/bookmark"
android:layout_below="@+id/agent" android:layout_below="@+id/agent"
android:ems="10" android:ems="10"
android:inputType="textUri" android:inputType="textUri"
android:paddingRight="10dp" /> android:paddingLeft="10dp"
android:paddingRight="10dp"/>
<CheckBox <CheckBox
android:id="@+id/fullScreen" android:id="@+id/fullScreen"
@ -162,133 +182,64 @@
android:layout_alignLeft="@+id/historyClear" android:layout_alignLeft="@+id/historyClear"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_below="@+id/historyClear" android:layout_below="@+id/historyClear"
android:paddingRight="20dp" /> android:layout_marginRight="20dp"
android:paddingRight="20dp"
android:background="@drawable/blueback"
android:text="@string/fullscreen" />
<CheckBox <CheckBox
android:id="@+id/java" android:id="@+id/java"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_below="@+id/fullScreen" android:layout_below="@+id/fullScreen"
android:paddingRight="20dp" /> android:layout_toLeftOf="@+id/flash"
android:paddingRight="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/blueback"
android:text="@string/java" />
<CheckBox <CheckBox
android:id="@+id/location" android:id="@+id/location"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_below="@+id/textView4" android:layout_below="@+id/textView4"
android:paddingRight="20dp" /> android:paddingRight="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/blueback"
android:text="@string/location" />
<TextView <RadioButton
android:id="@+id/textView5" android:id="@+id/radioMobile"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/location" android:layout_alignParentRight="true"
android:layout_toLeftOf="@+id/location" android:layout_below="@+id/java"
android:gravity="center_vertical" android:marqueeRepeatLimit="20"
android:paddingLeft="20dp" android:onClick="radioAgent"
android:text="@string/location" android:layout_marginLeft="20dp"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:layout_marginRight="20dp"
android:background="@drawable/blueback"
<TextView android:text="@string/mobile" />
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView5"
android:layout_toLeftOf="@+id/password"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="@string/password"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignTop="@+id/flash"
android:layout_toLeftOf="@+id/flash"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="@string/flash"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/textView7"
android:layout_alignTop="@+id/historyClear"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="@string/history"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/textView8"
android:layout_alignTop="@+id/fullScreen"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="@string/fullscreen"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/textView9"
android:layout_alignTop="@+id/java"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="@string/java"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/textView10"
android:layout_alignTop="@+id/radioMobile"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="@string/mobile"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/textView11"
android:layout_below="@+id/textView11"
android:gravity="center_vertical"
android:paddingLeft="20dp"
android:text="@string/desk"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <CheckBox
android:id="@+id/textView13" android:id="@+id/saveTabs"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_above="@+id/agent" android:layout_alignLeft="@+id/password"
android:layout_alignParentLeft="true" android:layout_alignRight="@+id/password"
android:layout_alignRight="@+id/textView12" android:layout_below="@+id/location"
android:gravity="center_vertical" android:background="@drawable/blueback"
android:paddingLeft="20dp" android:text="@string/saveTab" />
android:text="@string/custom"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout> </RelativeLayout>
</ScrollView> </ScrollView>

1
res/values/strings.xml

@ -17,5 +17,6 @@
<string name="settingshelp">Settings only apply to new tabs</string> <string name="settingshelp">Settings only apply to new tabs</string>
<string name="fullscreen">Enable fullscreen mode</string> <string name="fullscreen">Enable fullscreen mode</string>
<string name="java">Enable JavaScript</string> <string name="java">Enable JavaScript</string>
<string name="saveTab">Restore your tabs if they\'re lost</string>
</resources> </resources>

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

@ -12,19 +12,16 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context; 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.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.database.Cursor; import android.database.Cursor;
import android.database.DatabaseUtils; import android.database.DatabaseUtils;
@ -67,19 +64,15 @@ import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.webkit.ConsoleMessage;
import android.webkit.DownloadListener; import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions; import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler; import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler; import android.webkit.SslErrorHandler;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebChromeClient.CustomViewCallback; import android.webkit.WebChromeClient.CustomViewCallback;
import android.webkit.WebIconDatabase; import android.webkit.WebIconDatabase;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState; import android.webkit.WebSettings.PluginState;
@ -114,7 +107,6 @@ public class Barebones extends Activity {
static final boolean PAID_VERSION = false; static final boolean PAID_VERSION = false;
// variable declaration // variable declaration
static Rect edge; static Rect edge;
static SimpleAdapter adapter; static SimpleAdapter adapter;
static MultiAutoCompleteTextView getUrl; static MultiAutoCompleteTextView getUrl;
@ -145,7 +137,7 @@ public class Barebones extends Activity {
static boolean xPress; static boolean xPress;
static boolean tabsAreDisplayed = true, isPhone = false; static boolean tabsAreDisplayed = true, isPhone = false;
static boolean pageIsLoading = false, java; static boolean pageIsLoading = false, java;
static boolean allowLocation, savePasswords, deleteHistory; static boolean allowLocation, savePasswords, deleteHistory, saveTabs;
static boolean showFullScreen, pageIdIsVisible = true; static boolean showFullScreen, pageIdIsVisible = true;
static boolean urlBarShows = true, move = false; static boolean urlBarShows = true, move = false;
static boolean isBookmarkShowing = false; static boolean isBookmarkShowing = false;
@ -155,6 +147,7 @@ public class Barebones extends Activity {
static SharedPreferences.Editor edit; static SharedPreferences.Editor edit;
static String desktop, mobile, user; static String desktop, mobile, user;
static String urlA, title; static String urlA, title;
static String[] memoryURL = new String[MAX_TABS];
static final String[] bUrl = new String[MAX_BOOKMARKS]; static final String[] bUrl = new String[MAX_BOOKMARKS];
static final String[] bTitle = new String[MAX_BOOKMARKS]; static final String[] bTitle = new String[MAX_BOOKMARKS];
static String[] columns; static String[] columns;
@ -195,7 +188,15 @@ public class Barebones extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // displays main xml layout setContentView(R.layout.activity_main); // displays main xml layout
settings = getSharedPreferences(preferences, 0); settings = getSharedPreferences(preferences, 0);
edit = settings.edit(); edit = settings.edit();
saveTabs = settings.getBoolean("savetabs", true);
if (saveTabs) {
String mem = settings.getString("memory", "");
memoryURL = null;
memoryURL = GetArray(mem, "\\|\\$\\|SEPARATOR\\|\\$\\|");
}
inactive = this.getResources().getDrawable(R.drawable.bg_inactive); inactive = this.getResources().getDrawable(R.drawable.bg_inactive);
active = this.getResources().getDrawable(R.drawable.bg_press); active = this.getResources().getDrawable(R.drawable.bg_press);
init(); // sets up random stuff init(); // sets up random stuff
@ -241,10 +242,12 @@ public class Barebones extends Activity {
} }
} }
@SuppressLint("InlinedApi")
public void init() { public void init() {
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics); getWindowManager().getDefaultDisplay().getMetrics(metrics);
historyHandler = new DatabaseHandler(this); historyHandler = new DatabaseHandler(this);
API = Integer.valueOf(android.os.Build.VERSION.SDK_INT); // gets the sdk API = Integer.valueOf(android.os.Build.VERSION.SDK_INT); // gets the sdk
// level // level
progressBar = (ProgressBar) findViewById(R.id.progressBar1); progressBar = (ProgressBar) findViewById(R.id.progressBar1);
@ -255,6 +258,7 @@ public class Barebones extends Activity {
progressBar.setIndeterminateDrawable(getResources().getDrawable( progressBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.ginger_animation)); R.drawable.ginger_animation));
} }
showFullScreen = settings.getBoolean("fullscreen", false); showFullScreen = settings.getBoolean("fullscreen", false);
uBar = (RelativeLayout) findViewById(R.id.urlBar); uBar = (RelativeLayout) findViewById(R.id.urlBar);
bg = (RelativeLayout) findViewById(R.id.background); bg = (RelativeLayout) findViewById(R.id.background);
@ -311,6 +315,7 @@ public class Barebones extends Activity {
// user agent // user agent
user = test.getSettings().getUserAgentString(); user = test.getSettings().getUserAgentString();
background = (FrameLayout) findViewById(R.id.holder); background = (FrameLayout) findViewById(R.id.holder);
mobile = user; // setting mobile user mobile = user; // setting mobile user
// agent // agent
@ -398,13 +403,46 @@ public class Barebones extends Activity {
String URL = null; // that opens the browser String URL = null; // that opens the browser
// gets the string passed into the browser // gets the string passed into the browser
URL = url.getDataString(); URL = url.getDataString();
if (URL != null) { boolean oldTabs = false;
// opens a new tab with the url if its there
newTab(number, URL, true); if (saveTabs) {
if (URL != null) {
// opens a new tab with the url if its there
newTab(number, URL, true);
main[0].resumeTimers();
oldTabs = true;
}
for (int num = 0; num < memoryURL.length; num++) {
if (memoryURL[num].length() > 0) {
if (number == 0) {
newTab(number, memoryURL[num], !oldTabs);
main[0].resumeTimers();
} else {
newTab(number, memoryURL[num], false);
}
oldTabs = true;
}
}
if (!oldTabs) {
newTab(number, homepage, true);
}
} else { } else {
// otherwise it opens the homepage if (URL != null) {
newTab(number, homepage, true); // opens a new tab with the url if its there
newTab(number, URL, true);
main[0].resumeTimers();
} else {
// otherwise it opens the homepage
newTab(number, homepage, true);
main[0].resumeTimers();
}
} }
main[0].resumeTimers();
// new tab button // new tab button
ImageView newTab = (ImageView) findViewById(R.id.newTab); ImageView newTab = (ImageView) findViewById(R.id.newTab);
@ -493,6 +531,7 @@ public class Barebones extends Activity {
} }
} }
@SuppressLint("HandlerLeak")
public void enterUrl() { public void enterUrl() {
getUrl = (MultiAutoCompleteTextView) findViewById(R.id.enterUrl); getUrl = (MultiAutoCompleteTextView) findViewById(R.id.enterUrl);
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
@ -534,6 +573,7 @@ public class Barebones extends Activity {
c = getContentResolver().query(bookmarks, columns, null, c = getContentResolver().query(bookmarks, columns, null,
null, null); null, null);
} catch (SQLiteException e) { } catch (SQLiteException e) {
} catch (IllegalStateException e) {
} }
noStockBrowser = true; noStockBrowser = true;
if (c != null) { if (c != null) {
@ -627,6 +667,7 @@ public class Barebones extends Activity {
} }
// new tab method, takes the id of the tab to be created and the url to load // new tab method, takes the id of the tab to be created and the url to load
@SuppressWarnings("deprecation")
public void newTab(int theId, final String theUrl, final boolean display) { public void newTab(int theId, final String theUrl, final boolean display) {
lastVisibleWebView = pageId; lastVisibleWebView = pageId;
if (isBookmarkShowing) { if (isBookmarkShowing) {
@ -773,6 +814,7 @@ public class Barebones extends Activity {
public class TabTouch implements OnTouchListener { public class TabTouch implements OnTouchListener {
@SuppressWarnings("deprecation")
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
pageIdIsVisible = false; pageIdIsVisible = false;
@ -877,6 +919,7 @@ public class Barebones extends Activity {
public class TabClick implements OnClickListener { public class TabClick implements OnClickListener {
@SuppressWarnings("deprecation")
@Override @Override
public void onClick(View v) { public void onClick(View v) {
id = v.getId(); id = v.getId();
@ -1026,6 +1069,7 @@ public class Barebones extends Activity {
try { try {
Thread down = new Thread( Thread down = new Thread(
new Runnable() { new Runnable() {
@SuppressLint("InlinedApi")
@Override @Override
public void run() { public void run() {
@ -1065,6 +1109,8 @@ public class Barebones extends Activity {
Toast.makeText(Barebones.this, Toast.makeText(Barebones.this,
"Error Downloading File", "Error Downloading File",
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} catch (SecurityException e) {
} }
} }
break; break;
@ -1086,6 +1132,7 @@ public class Barebones extends Activity {
} else { } else {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@SuppressWarnings("deprecation")
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
switch (which) { switch (which) {
@ -1138,19 +1185,6 @@ public class Barebones extends Activity {
public class AnthonyWebViewClient extends WebViewClient { public class AnthonyWebViewClient extends WebViewClient {
@Override
public void onFormResubmission(WebView view, Message dontResend,
Message resend) {
// TODO Auto-generated method stub
super.onFormResubmission(view, dontResend, resend);
}
@Override
public void onLoadResource(WebView view, String url) {
// TODO Auto-generated method stub
super.onLoadResource(view, url);
}
@Override @Override
public void onScaleChanged(WebView view, float oldScale, float newScale) { public void onScaleChanged(WebView view, float oldScale, float newScale) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -1160,25 +1194,6 @@ public class Barebones extends Activity {
super.onScaleChanged(view, oldScale, newScale); super.onScaleChanged(view, oldScale, newScale);
} }
@Override
public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
// TODO Auto-generated method stub
super.onUnhandledKeyEvent(view, event);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView view,
String url) {
// TODO Auto-generated method stub
return super.shouldInterceptRequest(view, url);
}
@Override
public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
// TODO Auto-generated method stub
return super.shouldOverrideKeyEvent(view, event);
}
@Override @Override
public void doUpdateVisitedHistory(WebView view, final String url, public void doUpdateVisitedHistory(WebView view, final String url,
final boolean isReload) { final boolean isReload) {
@ -1196,12 +1211,6 @@ public class Barebones extends Activity {
return; return;
} }
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override @Override
public void onReceivedHttpAuthRequest(WebView view, public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) { HttpAuthHandler handler, String host, String realm) {
@ -1209,13 +1218,6 @@ public class Barebones extends Activity {
super.onReceivedHttpAuthRequest(view, handler, host, realm); super.onReceivedHttpAuthRequest(view, handler, host, realm);
} }
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
}
@Override @Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) { SslError error) {
@ -1235,9 +1237,11 @@ public class Barebones extends Activity {
public void onPageStarted(WebView view, String url, Bitmap favicon) { public void onPageStarted(WebView view, String url, Bitmap favicon) {
numberPage = view.getId(); numberPage = view.getId();
pageIsLoading = true; pageIsLoading = true;
getUrl.setText(url);
refresh.setVisibility(View.INVISIBLE); refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
if (main[numberPage].isShown()) {
getUrl.setText(url);
}
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
urlToLoad[numberPage][0] = url; urlToLoad[numberPage][0] = url;
urlTitle[numberPage].setCompoundDrawables(webpageOther, null, urlTitle[numberPage].setCompoundDrawables(webpageOther, null,
@ -1264,32 +1268,11 @@ public class Barebones extends Activity {
public void onDownloadStart(final String url, String userAgent, public void onDownloadStart(final String url, String userAgent,
final String contentDisposition, final String mimetype, final String contentDisposition, final String mimetype,
long contentLength) { long contentLength) {
/*
* if (contentDisposition == null ||
* !contentDisposition.regionMatches(true, 0, "attachment", 0, 10))
* { // query the package manager to see if there's a registered //
* handler // that matches. Intent intent = new
* Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url),
* mimetype); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
* ResolveInfo info = getPackageManager().resolveActivity(intent,
* PackageManager.MATCH_DEFAULT_ONLY); if (info != null) {
* ComponentName myName = getComponentName(); // If we resolved to
* ourselves, we don't want to attempt to // load the url only to
* try and download it again. if (!myName.getPackageName().equals(
* info.activityInfo.packageName) || !myName.getClassName().equals(
* info.activityInfo.name)) { // someone (other than us) knows how
* to handle this mime // type with this scheme, don't download. try
* { startActivity(intent); return; } catch
* (ActivityNotFoundException ex) {
*
* // Best behavior is to fall back to a download in // this // case
* } } } } else {
*/
try { try {
Thread downloader = new Thread(new Runnable() { Thread downloader = new Thread(new Runnable() {
@SuppressLint("InlinedApi")
@Override @Override
public void run() { public void run() {
DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Uri nice = Uri.parse(url); Uri nice = Uri.parse(url);
DownloadManager.Request it = new DownloadManager.Request( DownloadManager.Request it = new DownloadManager.Request(
@ -1317,6 +1300,8 @@ public class Barebones extends Activity {
Log.e("Barebones", "Problem downloading"); Log.e("Barebones", "Problem downloading");
Toast.makeText(Barebones.this, "Error Downloading File", Toast.makeText(Barebones.this, "Error Downloading File",
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} catch (SecurityException e) {
} }
} }
@ -1338,28 +1323,17 @@ public class Barebones extends Activity {
} }
} }
@SuppressLint("SetJavaScriptEnabled")
public class AnthonyChromeClient extends WebChromeClient { public class AnthonyChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster; private Bitmap mDefaultVideoPoster;
private View mVideoProgressView; private View mVideoProgressView;
@Override
public void getVisitedHistory(ValueCallback<String[]> callback) {
// TODO Auto-generated method stub
super.getVisitedHistory(callback);
}
@Override @Override
public void onCloseWindow(WebView window) { public void onCloseWindow(WebView window) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onCloseWindow(window); super.onCloseWindow(window);
} }
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
// Log.i("Barebones",consoleMessage.toString());
return super.onConsoleMessage(consoleMessage);
}
@Override @Override
public boolean onCreateWindow(WebView view, boolean isDialog, public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) { boolean isUserGesture, Message resultMsg) {
@ -1368,57 +1342,6 @@ public class Barebones extends Activity {
resultMsg); resultMsg);
} }
@Override
public void onExceededDatabaseQuota(String url,
String databaseIdentifier, long quota,
long estimatedDatabaseSize, long totalQuota,
QuotaUpdater quotaUpdater) {
// TODO Auto-generated method stub
super.onExceededDatabaseQuota(url, databaseIdentifier, quota,
estimatedDatabaseSize, totalQuota, quotaUpdater);
}
@Override
public void onGeolocationPermissionsHidePrompt() {
// TODO Auto-generated method stub
super.onGeolocationPermissionsHidePrompt();
}
@Override
public boolean onJsAlert(WebView view, String url, String message,
JsResult result) {
// TODO Auto-generated method stub
return super.onJsAlert(view, url, message, result);
}
@Override
public boolean onJsBeforeUnload(WebView view, String url,
String message, JsResult result) {
return super.onJsBeforeUnload(view, url, message, result);
}
@Override
public boolean onJsConfirm(WebView view, String url, String message,
JsResult result) {
// TODO Auto-generated method stub
return super.onJsConfirm(view, url, message, result);
}
@Override
public boolean onJsPrompt(WebView view, String url, String message,
String defaultValue, JsPromptResult result) {
// TODO Auto-generated method stub
return super.onJsPrompt(view, url, message, defaultValue, result);
}
@Override
public void onProgressChanged(WebView view, int newProgress) {
// TODO Auto-generated method stub
super.onProgressChanged(view, newProgress);
}
@Override @Override
public void onReachedMaxAppCacheSize(long requiredStorage, long quota, public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
QuotaUpdater quotaUpdater) { QuotaUpdater quotaUpdater) {
@ -1427,19 +1350,6 @@ public class Barebones extends Activity {
super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater); super.onReachedMaxAppCacheSize(requiredStorage, quota, quotaUpdater);
} }
@Override
public void onReceivedTouchIconUrl(WebView view, String url,
boolean precomposed) {
// TODO Auto-generated method stub
super.onReceivedTouchIconUrl(view, url, precomposed);
}
@Override
public void onRequestFocus(WebView view) {
// TODO Auto-generated method stub
super.onRequestFocus(view);
}
@Override @Override
public void onShowCustomView(View view, int requestedOrientation, public void onShowCustomView(View view, int requestedOrientation,
CustomViewCallback callback) { CustomViewCallback callback) {
@ -1513,7 +1423,10 @@ public class Barebones extends Activity {
if (allowLocation == true) { if (allowLocation == true) {
callback.invoke(origin, true, false); callback.invoke(origin, true, false);
} else if (allowLocation == false) {
callback.invoke(origin, false, false);
} else { } else {
Log.i("Barebones: ", "onGeolocationPermissionsShowPrompt()"); Log.i("Barebones: ", "onGeolocationPermissionsShowPrompt()");
final boolean remember = true; final boolean remember = true;
@ -1574,6 +1487,8 @@ public class Barebones extends Activity {
Log.e("Barebones", "ERRRRROOORRRR 1"); Log.e("Barebones", "ERRRRROOORRRR 1");
} catch (NullPointerException e) { } catch (NullPointerException e) {
Log.e("Barebones", "ERRRRROOORRRR 2"); Log.e("Barebones", "ERRRRROOORRRR 2");
} catch (SQLiteException e) {
Log.e("Barebones", "SQLiteException");
} }
} }
}); });
@ -1641,6 +1556,7 @@ public class Barebones extends Activity {
} }
} }
@SuppressLint("SetJavaScriptEnabled")
public AnthonyWebView BrowserSettings(AnthonyWebView view) { public AnthonyWebView BrowserSettings(AnthonyWebView view) {
WebSettings webViewSettings = view.getSettings(); WebSettings webViewSettings = view.getSettings();
java = settings.getBoolean("java", true); java = settings.getBoolean("java", true);
@ -1925,11 +1841,14 @@ public class Barebones extends Activity {
openBookmarks(); openBookmarks();
} }
@SuppressWarnings("deprecation")
public void deleteTab(int id) { public void deleteTab(int id) {
int leftId = id; int leftId = id;
pageIdIsVisible = false; pageIdIsVisible = false;
main[id].stopLoading(); main[id].stopLoading();
main[id].clearHistory(); main[id].clearHistory();
urlToLoad[id][0] = null;
urlToLoad[id][1] = null;
if (API >= 11) { if (API >= 11) {
main[id].onPause(); main[id].onPause();
} }
@ -2390,12 +2309,6 @@ public class Barebones extends Activity {
super.finish(); super.finish();
} }
@Override
protected void onDestroy() {
super.onDestroy();
}
public void trimCache(Context context) { public void trimCache(Context context) {
try { try {
File dir = context.getCacheDir(); File dir = context.getCacheDir();
@ -2429,22 +2342,30 @@ public class Barebones extends Activity {
main[pageId].onPause(); main[pageId].onPause();
} }
main[pageId].pauseTimers(); main[pageId].pauseTimers();
String s = "";
for (int n = 0; n < MAX_TABS; n++) {
if (urlToLoad[n][0] != null) {
s = s + urlToLoad[n][0] + "|$|SEPARATOR|$|";
}
}
edit.putString("memory", s);
edit.commit();
super.onPause(); super.onPause();
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume();
if (API >= 11) { if (API >= 11) {
main[pageId].onResume(); main[pageId].onResume();
} }
main[pageId].resumeTimers(); main[0].resumeTimers();
super.onResume();
} }
public Barebones() { public Barebones() {
super(); super();
// TODO Auto-generated constructor stub
} }
@Override @Override
@ -2458,4 +2379,7 @@ public class Barebones extends Activity {
super.onNewIntent(intent); super.onNewIntent(intent);
} }
public static String[] GetArray(String input, String delimiter) {
return input.split(delimiter);
}
} }

31
src/acr/browser/barebones/Settings.java

@ -28,7 +28,7 @@ public class Settings extends Activity {
public static final String preferences = "settings"; public static final String preferences = "settings";
static boolean allowLocation, deleteHistory; static boolean allowLocation, deleteHistory;
static int enableFlash; static int enableFlash;
static boolean savePasswords, fullScreen,java; static boolean savePasswords, fullScreen, java, saveTabs;
static String userAgent, homepage; static String userAgent, homepage;
static EditText agent,h; static EditText agent,h;
static SharedPreferences.Editor edit; static SharedPreferences.Editor edit;
@ -51,7 +51,8 @@ public class Settings extends Activity {
test.destroy(); test.destroy();
it.requestFocus(); it.requestFocus();
allowLocation = settings.getBoolean("location", false); allowLocation = settings.getBoolean("location", false);
savePasswords = settings.getBoolean("passwords", false); saveTabs = settings.getBoolean("savetabs", true);
savePasswords = settings.getBoolean("passwords", true);
deleteHistory = settings.getBoolean("history", false); deleteHistory = settings.getBoolean("history", false);
fullScreen = settings.getBoolean("fullscreen", false); fullScreen = settings.getBoolean("fullscreen", false);
enableFlash = settings.getInt("enableflash", 0); enableFlash = settings.getInt("enableflash", 0);
@ -123,6 +124,7 @@ public class Settings extends Activity {
location(); location();
passwords(); passwords();
clearHistory(); clearHistory();
saveTabs();
getText(); getText();
flash(); flash();
getHome(); getHome();
@ -130,6 +132,31 @@ public class Settings extends Activity {
java(); java();
} }
public void saveTabs(){
final CheckBox tab = (CheckBox)findViewById(R.id.saveTabs);
if(saveTabs){
tab.setChecked(true);
}else{
tab.setChecked(false);
}
tab.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// TODO Auto-generated method stub
if(arg1){
edit.putBoolean("savetabs", true);
edit.commit();
}else{
edit.putBoolean("savetabs", false);
edit.commit();
}
}
});
}
public void getHome() { public void getHome() {
h = (EditText) findViewById(R.id.homePage); h = (EditText) findViewById(R.id.homePage);

Loading…
Cancel
Save