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. 199
      res/layout/settings.xml
  6. 1
      res/values/strings.xml
  7. 250
      src/acr/browser/barebones/Barebones.java
  8. 31
      src/acr/browser/barebones/Settings.java

8
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="36"
android:versionName="2.3.12" >
android:versionCode="37"
android:versionName="2.4" >
<uses-sdk
android:minSdkVersion="8"
@ -21,11 +21,9 @@ @@ -21,11 +21,9 @@
<activity
android:name="acr.browser.barebones.Barebones"
android:label="@string/app_name"
android:configChanges="orientation|screenSize|keyboardHidden"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:alwaysRetainTaskState="true"
android:launchMode="singleTask"
android:allowTaskReparenting="true"
android:multiprocess="false"
android:hardwareAccelerated="true"
>
<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 @@ @@ -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 @@ @@ -114,6 +114,7 @@
android:id="@+id/progressBar1"
android:layout_width="30dp"
android:layout_height="30dp"
android:visibility="gone"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true"

199
res/layout/settings.xml

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

1
res/values/strings.xml

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

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

@ -12,19 +12,16 @@ import java.util.HashMap; @@ -12,19 +12,16 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.database.Cursor;
import android.database.DatabaseUtils;
@ -67,19 +64,15 @@ import android.view.animation.Animation.AnimationListener; @@ -67,19 +64,15 @@ import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.webkit.ConsoleMessage;
import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebChromeClient.CustomViewCallback;
import android.webkit.WebIconDatabase;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState;
@ -114,7 +107,6 @@ public class Barebones extends Activity { @@ -114,7 +107,6 @@ public class Barebones extends Activity {
static final boolean PAID_VERSION = false;
// variable declaration
static Rect edge;
static SimpleAdapter adapter;
static MultiAutoCompleteTextView getUrl;
@ -145,7 +137,7 @@ public class Barebones extends Activity { @@ -145,7 +137,7 @@ public class Barebones extends Activity {
static boolean xPress;
static boolean tabsAreDisplayed = true, isPhone = false;
static boolean pageIsLoading = false, java;
static boolean allowLocation, savePasswords, deleteHistory;
static boolean allowLocation, savePasswords, deleteHistory, saveTabs;
static boolean showFullScreen, pageIdIsVisible = true;
static boolean urlBarShows = true, move = false;
static boolean isBookmarkShowing = false;
@ -155,6 +147,7 @@ public class Barebones extends Activity { @@ -155,6 +147,7 @@ public class Barebones extends Activity {
static SharedPreferences.Editor edit;
static String desktop, mobile, user;
static String urlA, title;
static String[] memoryURL = new String[MAX_TABS];
static final String[] bUrl = new String[MAX_BOOKMARKS];
static final String[] bTitle = new String[MAX_BOOKMARKS];
static String[] columns;
@ -195,7 +188,15 @@ public class Barebones extends Activity { @@ -195,7 +188,15 @@ public class Barebones extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // displays main xml layout
settings = getSharedPreferences(preferences, 0);
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);
active = this.getResources().getDrawable(R.drawable.bg_press);
init(); // sets up random stuff
@ -241,10 +242,12 @@ public class Barebones extends Activity { @@ -241,10 +242,12 @@ public class Barebones extends Activity {
}
}
@SuppressLint("InlinedApi")
public void init() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
historyHandler = new DatabaseHandler(this);
API = Integer.valueOf(android.os.Build.VERSION.SDK_INT); // gets the sdk
// level
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
@ -255,6 +258,7 @@ public class Barebones extends Activity { @@ -255,6 +258,7 @@ public class Barebones extends Activity {
progressBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.ginger_animation));
}
showFullScreen = settings.getBoolean("fullscreen", false);
uBar = (RelativeLayout) findViewById(R.id.urlBar);
bg = (RelativeLayout) findViewById(R.id.background);
@ -311,6 +315,7 @@ public class Barebones extends Activity { @@ -311,6 +315,7 @@ public class Barebones extends Activity {
// user agent
user = test.getSettings().getUserAgentString();
background = (FrameLayout) findViewById(R.id.holder);
mobile = user; // setting mobile user
// agent
@ -398,13 +403,46 @@ public class Barebones extends Activity { @@ -398,13 +403,46 @@ public class Barebones extends Activity {
String URL = null; // that opens the browser
// gets the string passed into the browser
URL = url.getDataString();
boolean oldTabs = false;
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 {
if (URL != null) {
// 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
ImageView newTab = (ImageView) findViewById(R.id.newTab);
@ -493,6 +531,7 @@ public class Barebones extends Activity { @@ -493,6 +531,7 @@ public class Barebones extends Activity {
}
}
@SuppressLint("HandlerLeak")
public void enterUrl() {
getUrl = (MultiAutoCompleteTextView) findViewById(R.id.enterUrl);
getUrl.setPadding(tenPad, 0, tenPad, 0);
@ -534,6 +573,7 @@ public class Barebones extends Activity { @@ -534,6 +573,7 @@ public class Barebones extends Activity {
c = getContentResolver().query(bookmarks, columns, null,
null, null);
} catch (SQLiteException e) {
} catch (IllegalStateException e) {
}
noStockBrowser = true;
if (c != null) {
@ -627,6 +667,7 @@ public class Barebones extends Activity { @@ -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
@SuppressWarnings("deprecation")
public void newTab(int theId, final String theUrl, final boolean display) {
lastVisibleWebView = pageId;
if (isBookmarkShowing) {
@ -773,6 +814,7 @@ public class Barebones extends Activity { @@ -773,6 +814,7 @@ public class Barebones extends Activity {
public class TabTouch implements OnTouchListener {
@SuppressWarnings("deprecation")
@Override
public boolean onTouch(View v, MotionEvent event) {
pageIdIsVisible = false;
@ -877,6 +919,7 @@ public class Barebones extends Activity { @@ -877,6 +919,7 @@ public class Barebones extends Activity {
public class TabClick implements OnClickListener {
@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {
id = v.getId();
@ -1026,6 +1069,7 @@ public class Barebones extends Activity { @@ -1026,6 +1069,7 @@ public class Barebones extends Activity {
try {
Thread down = new Thread(
new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
@ -1065,6 +1109,8 @@ public class Barebones extends Activity { @@ -1065,6 +1109,8 @@ public class Barebones extends Activity {
Toast.makeText(Barebones.this,
"Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (SecurityException e) {
}
}
break;
@ -1086,6 +1132,7 @@ public class Barebones extends Activity { @@ -1086,6 +1132,7 @@ public class Barebones extends Activity {
} else {
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@SuppressWarnings("deprecation")
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
@ -1138,19 +1185,6 @@ public class Barebones extends Activity { @@ -1138,19 +1185,6 @@ public class Barebones extends Activity {
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
public void onScaleChanged(WebView view, float oldScale, float newScale) {
// TODO Auto-generated method stub
@ -1160,25 +1194,6 @@ public class Barebones extends Activity { @@ -1160,25 +1194,6 @@ public class Barebones extends Activity {
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
public void doUpdateVisitedHistory(WebView view, final String url,
final boolean isReload) {
@ -1196,12 +1211,6 @@ public class Barebones extends Activity { @@ -1196,12 +1211,6 @@ public class Barebones extends Activity {
return;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onReceivedHttpAuthRequest(WebView view,
HttpAuthHandler handler, String host, String realm) {
@ -1209,13 +1218,6 @@ public class Barebones extends Activity { @@ -1209,13 +1218,6 @@ public class Barebones extends Activity {
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
public void onReceivedSslError(WebView view, SslErrorHandler handler,
SslError error) {
@ -1235,9 +1237,11 @@ public class Barebones extends Activity { @@ -1235,9 +1237,11 @@ public class Barebones extends Activity {
public void onPageStarted(WebView view, String url, Bitmap favicon) {
numberPage = view.getId();
pageIsLoading = true;
getUrl.setText(url);
refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
if (main[numberPage].isShown()) {
getUrl.setText(url);
}
getUrl.setPadding(tenPad, 0, tenPad, 0);
urlToLoad[numberPage][0] = url;
urlTitle[numberPage].setCompoundDrawables(webpageOther, null,
@ -1264,32 +1268,11 @@ public class Barebones extends Activity { @@ -1264,32 +1268,11 @@ public class Barebones extends Activity {
public void onDownloadStart(final String url, String userAgent,
final String contentDisposition, final String mimetype,
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 {
Thread downloader = new Thread(new Runnable() {
@SuppressLint("InlinedApi")
@Override
public void run() {
DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Uri nice = Uri.parse(url);
DownloadManager.Request it = new DownloadManager.Request(
@ -1317,6 +1300,8 @@ public class Barebones extends Activity { @@ -1317,6 +1300,8 @@ public class Barebones extends Activity {
Log.e("Barebones", "Problem downloading");
Toast.makeText(Barebones.this, "Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (SecurityException e) {
}
}
@ -1338,28 +1323,17 @@ public class Barebones extends Activity { @@ -1338,28 +1323,17 @@ public class Barebones extends Activity {
}
}
@SuppressLint("SetJavaScriptEnabled")
public class AnthonyChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster;
private View mVideoProgressView;
@Override
public void getVisitedHistory(ValueCallback<String[]> callback) {
// TODO Auto-generated method stub
super.getVisitedHistory(callback);
}
@Override
public void onCloseWindow(WebView window) {
// TODO Auto-generated method stub
super.onCloseWindow(window);
}
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
// Log.i("Barebones",consoleMessage.toString());
return super.onConsoleMessage(consoleMessage);
}
@Override
public boolean onCreateWindow(WebView view, boolean isDialog,
boolean isUserGesture, Message resultMsg) {
@ -1368,57 +1342,6 @@ public class Barebones extends Activity { @@ -1368,57 +1342,6 @@ public class Barebones extends Activity {
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
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
QuotaUpdater quotaUpdater) {
@ -1427,19 +1350,6 @@ public class Barebones extends Activity { @@ -1427,19 +1350,6 @@ public class Barebones extends Activity {
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
public void onShowCustomView(View view, int requestedOrientation,
CustomViewCallback callback) {
@ -1513,7 +1423,10 @@ public class Barebones extends Activity { @@ -1513,7 +1423,10 @@ public class Barebones extends Activity {
if (allowLocation == true) {
callback.invoke(origin, true, false);
} else if (allowLocation == false) {
callback.invoke(origin, false, false);
} else {
Log.i("Barebones: ", "onGeolocationPermissionsShowPrompt()");
final boolean remember = true;
@ -1574,6 +1487,8 @@ public class Barebones extends Activity { @@ -1574,6 +1487,8 @@ public class Barebones extends Activity {
Log.e("Barebones", "ERRRRROOORRRR 1");
} catch (NullPointerException e) {
Log.e("Barebones", "ERRRRROOORRRR 2");
} catch (SQLiteException e) {
Log.e("Barebones", "SQLiteException");
}
}
});
@ -1641,6 +1556,7 @@ public class Barebones extends Activity { @@ -1641,6 +1556,7 @@ public class Barebones extends Activity {
}
}
@SuppressLint("SetJavaScriptEnabled")
public AnthonyWebView BrowserSettings(AnthonyWebView view) {
WebSettings webViewSettings = view.getSettings();
java = settings.getBoolean("java", true);
@ -1925,11 +1841,14 @@ public class Barebones extends Activity { @@ -1925,11 +1841,14 @@ public class Barebones extends Activity {
openBookmarks();
}
@SuppressWarnings("deprecation")
public void deleteTab(int id) {
int leftId = id;
pageIdIsVisible = false;
main[id].stopLoading();
main[id].clearHistory();
urlToLoad[id][0] = null;
urlToLoad[id][1] = null;
if (API >= 11) {
main[id].onPause();
}
@ -2390,12 +2309,6 @@ public class Barebones extends Activity { @@ -2390,12 +2309,6 @@ public class Barebones extends Activity {
super.finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
public void trimCache(Context context) {
try {
File dir = context.getCacheDir();
@ -2429,22 +2342,30 @@ public class Barebones extends Activity { @@ -2429,22 +2342,30 @@ public class Barebones extends Activity {
main[pageId].onPause();
}
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();
}
@Override
protected void onResume() {
super.onResume();
if (API >= 11) {
main[pageId].onResume();
}
main[pageId].resumeTimers();
super.onResume();
main[0].resumeTimers();
}
public Barebones() {
super();
// TODO Auto-generated constructor stub
}
@Override
@ -2458,4 +2379,7 @@ public class Barebones extends Activity { @@ -2458,4 +2379,7 @@ public class Barebones extends Activity {
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 { @@ -28,7 +28,7 @@ public class Settings extends Activity {
public static final String preferences = "settings";
static boolean allowLocation, deleteHistory;
static int enableFlash;
static boolean savePasswords, fullScreen,java;
static boolean savePasswords, fullScreen, java, saveTabs;
static String userAgent, homepage;
static EditText agent,h;
static SharedPreferences.Editor edit;
@ -51,7 +51,8 @@ public class Settings extends Activity { @@ -51,7 +51,8 @@ public class Settings extends Activity {
test.destroy();
it.requestFocus();
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);
fullScreen = settings.getBoolean("fullscreen", false);
enableFlash = settings.getInt("enableflash", 0);
@ -123,6 +124,7 @@ public class Settings extends Activity { @@ -123,6 +124,7 @@ public class Settings extends Activity {
location();
passwords();
clearHistory();
saveTabs();
getText();
flash();
getHome();
@ -130,6 +132,31 @@ public class Settings extends Activity { @@ -130,6 +132,31 @@ public class Settings extends Activity {
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() {
h = (EditText) findViewById(R.id.homePage);

Loading…
Cancel
Save