Browse Source

2.3.10 bugfix

crash fix for devices without AOSP browser
master
Anthony Restaino 12 years ago
parent
commit
3eaec7c2ee
  1. 4
      AndroidManifest.xml
  2. 81
      src/acr/browser/barebones/Barebones.java

4
AndroidManifest.xml

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

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

@ -125,7 +125,7 @@ public class Barebones extends Activity implements OnLongClickListener,
static Drawable loading, webpage, webpageOther; static Drawable loading, webpage, webpageOther;
static Drawable exitTab; static Drawable exitTab;
final static int FILECHOOSER_RESULTCODE = 1; final static int FILECHOOSER_RESULTCODE = 1;
static int num, x, y; static int numberPage, x, y;
static final int fuzz = 10; static final int fuzz = 10;
static int statusBar; static int statusBar;
static int number, pageId = 0, agentPicker; static int number, pageId = 0, agentPicker;
@ -177,6 +177,9 @@ public class Barebones extends Activity implements OnLongClickListener,
static Map<String, String> map; static Map<String, String> map;
static Handler handler; static Handler handler;
static DatabaseHandler historyHandler; static DatabaseHandler historyHandler;
static StringBuilder sb;
static SQLiteDatabase s;
static Cursor cursor;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -388,7 +391,7 @@ public class Barebones extends Activity implements OnLongClickListener,
// otherwise it opens the homepage // otherwise it opens the homepage
newTab(number, homepage); newTab(number, homepage);
} }
// new tab button // new tab button
ImageView newTab = (ImageView) findViewById(R.id.newTab); ImageView newTab = (ImageView) findViewById(R.id.newTab);
newTab.setBackgroundResource(R.drawable.button); newTab.setBackgroundResource(R.drawable.button);
@ -506,10 +509,23 @@ public class Barebones extends Activity implements OnLongClickListener,
@Override @Override
public void run() { public void run() {
Cursor c = null;
// bookmarks = Browser.BOOKMARKS_URI;
columns = new String[] { "url", "title" }; columns = new String[] { "url", "title" };
try{
bookmarks = Browser.BOOKMARKS_URI;
c = getContentResolver().query(bookmarks, columns, null, null, null);
}
catch(SQLiteException e){}
noStockBrowser = true;
if(c!=null){
noStockBrowser = false;
Log.i("Barebones","detected AOSP browser");
}
else{
Log.e("Barebones","did not detect AOSP browser");
}
try { try {
@ -521,6 +537,7 @@ public class Barebones extends Activity implements OnLongClickListener,
null, // Which rows to return (all rows) null, // Which rows to return (all rows)
null, // Selection arguments (none) null, // Selection arguments (none)
null, null, null); null, null, null);
handler.sendEmptyMessage(1); handler.sendEmptyMessage(1);
} catch (SQLiteException e) { } catch (SQLiteException e) {
@ -529,9 +546,9 @@ public class Barebones extends Activity implements OnLongClickListener,
} }
list = new ArrayList<Map<String, String>>(); list = new ArrayList<Map<String, String>>();
noStockBrowser = true;
if (managedCursor != null) { if (managedCursor != null) {
noStockBrowser = false;
if (managedCursor.moveToFirst()) { if (managedCursor.moveToFirst()) {
@ -958,9 +975,19 @@ public class Barebones extends Activity implements OnLongClickListener,
private class AnthonyWebViewClient extends WebViewClient { private class AnthonyWebViewClient extends WebViewClient {
@Override @Override
public void doUpdateVisitedHistory(WebView view, String url, public void doUpdateVisitedHistory(WebView view, final String url,
boolean isReload) { final boolean isReload) {
if (!noStockBrowser) {
Thread history = new Thread(new Runnable() {
@Override
public void run() {
Browser.updateVisitedHistory(getContentResolver(), url,
isReload);
}
});
history.start();
}
return; return;
} }
@ -1005,15 +1032,14 @@ public class Barebones extends Activity implements OnLongClickListener,
@Override @Override
public void onPageStarted(WebView view, String url, Bitmap favicon) { public void onPageStarted(WebView view, String url, Bitmap favicon) {
int num = view.getId(); numberPage = view.getId();
pageIsLoading = true; pageIsLoading = true;
getUrl.setText(url); getUrl.setText(url);
refresh.setVisibility(View.INVISIBLE); refresh.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
getUrl.setPadding(tenPad, 0, tenPad, 0); getUrl.setPadding(tenPad, 0, tenPad, 0);
urlToLoad[num][0] = url; urlToLoad[numberPage][0] = url;
urlTitle[num].setCompoundDrawables(webpageOther, null, exitTab, urlTitle[numberPage].setCompoundDrawables(webpageOther, null, exitTab,
null); null);
if (uBarShows == false) { if (uBarShows == false) {
@ -1026,17 +1052,7 @@ public class Barebones extends Activity implements OnLongClickListener,
public void onPageFinished(WebView view, final String url) { public void onPageFinished(WebView view, final String url) {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
refresh.setVisibility(View.VISIBLE); refresh.setVisibility(View.VISIBLE);
if (!noStockBrowser) {
Thread history = new Thread(new Runnable() {
@Override
public void run() {
Browser.updateVisitedHistory(getContentResolver(), url,
true);
}
});
history.start();
}
pageIsLoading = false; pageIsLoading = false;
} }
@ -1215,24 +1231,23 @@ public class Barebones extends Activity implements OnLongClickListener,
@Override @Override
public void onReceivedTitle(final WebView view, final String title) { public void onReceivedTitle(final WebView view, final String title) {
int num = view.getId(); numberPage = view.getId();
urlTitle[num].setText(title); urlTitle[numberPage].setText(title);
urlToLoad[num][1] = title; urlToLoad[numberPage][1] = title;
Thread up = new Thread(new Runnable() { Thread up = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
StringBuilder sb = new StringBuilder("url" + " = "); sb = new StringBuilder("url" + " = ");
DatabaseUtils.appendEscapedSQLString(sb, view.getUrl()); DatabaseUtils.appendEscapedSQLString(sb, view.getUrl());
SQLiteDatabase s = historyHandler.getReadableDatabase(); s = historyHandler.getReadableDatabase();
Cursor c = s.query("history", new String[] { "id", cursor = s.query("history", new String[] { "id",
"url", "title" }, sb.toString(), null, null, "url", "title" }, sb.toString(), null, null,
null, null); null, null);
if (c.moveToFirst()) { if (cursor.moveToFirst()) {
} else { } else {
historyHandler.addHistoryItem(new HistoryItem(view historyHandler.addHistoryItem(new HistoryItem(urlToLoad[numberPage][0], title));
.getUrl(), title));
} }
} catch (IllegalStateException e) { } catch (IllegalStateException e) {

Loading…
Cancel
Save