Browse Source

Bug fixes 2.3.11.1

- downloading fixed
- performance slightly improved
-  better tab performance
- other stuff I can't remember
- blah blah blah I'm really tired...........
master
Anthony Restaino 12 years ago
parent
commit
b88eabc102
  1. 4
      AndroidManifest.xml
  2. 2
      res/drawable/ics_animation.xml
  3. 37
      src/acr/browser/barebones/AnthonyWebView.java
  4. 474
      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="33" android:versionCode="35"
android:versionName="2.3.10" > android:versionName="2.3.11.1" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"

2
res/drawable/ics_animation.xml

@ -18,7 +18,7 @@
<item> <item>
<rotate <rotate
android:drawable="@drawable/spinner" android:drawable="@drawable/spinner"
android:fromDegrees="720" android:fromDegrees="1080"
android:pivotX="50%" android:pivotX="50%"
android:pivotY="50%" android:pivotY="50%"
android:toDegrees="0" /> android:toDegrees="0" />

37
src/acr/browser/barebones/AnthonyWebView.java

@ -17,7 +17,7 @@ public final class AnthonyWebView extends WebView {
boolean uBarShows = Barebones.uBarShows; boolean uBarShows = Barebones.uBarShows;
Animation slideUp = Barebones.slideUp; Animation slideUp = Barebones.slideUp;
Animation slideDown = Barebones.slideDown; Animation slideDown = Barebones.slideDown;
public AnthonyWebView(Context context) { public AnthonyWebView(Context context) {
super(context); super(context);
} }
@ -27,45 +27,28 @@ public final class AnthonyWebView extends WebView {
switch (event.getAction()) { switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: { case MotionEvent.ACTION_DOWN: {
move = false;
if (API <= 10 && !Barebones.main[Barebones.pageId].hasFocus()) {
Barebones.main[Barebones.pageId].requestFocus();
}
timeBetweenDownPress = System.currentTimeMillis();
break;
}
case MotionEvent.ACTION_MOVE: {
move = true;
}
case MotionEvent.ACTION_UP: {
try { try {
hitTest = getHitTestResult().getType(); hitTest = getHitTestResult().getType();
} catch (NullPointerException e) { } catch (NullPointerException e) {
} }
if (showFullScreen && hitTest != 9) { if (API <= 10 && !Barebones.main[Barebones.pageId].hasFocus()) {
if (System.currentTimeMillis() - timeBetweenDownPress < 500 Barebones.main[Barebones.pageId].requestFocus();
&& !move) { }
if (!uBarShows) { timeBetweenDownPress = System.currentTimeMillis();
uBar.startAnimation(slideDown); if (showFullScreen) {
uBarShows = true; if (uBarShows) {
} else if (uBarShows) {
uBar.startAnimation(slideUp);
uBarShows = false;
}
break;
} else if (Barebones.main[Barebones.pageId].getScrollY() > 5 && uBarShows) {
uBar.startAnimation(slideUp); uBar.startAnimation(slideUp);
uBarShows = false; uBarShows = false;
break; break;
} else if (Barebones.main[Barebones.pageId].getScrollY() < 5 && !uBarShows) { } else if (Barebones.main[Barebones.pageId].getScrollY() <= 5
&& !uBarShows && hitTest != 9) {
uBar.startAnimation(slideDown); uBar.startAnimation(slideDown);
uBarShows = true; uBarShows = true;
break; break;
} }
} }
break;
} }
default: default:
break; break;

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

@ -31,6 +31,7 @@ import android.database.Cursor;
import android.database.DatabaseUtils; import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteMisuseException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
@ -68,19 +69,26 @@ 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.MimeTypeMap;
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.WebResourceResponse;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebChromeClient.CustomViewCallback; import android.webkit.WebChromeClient.CustomViewCallback;
import android.webkit.WebIconDatabase; import android.webkit.WebIconDatabase;
import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState; import android.webkit.WebSettings.PluginState;
import android.webkit.WebSettings.RenderPriority; import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebStorage;
import android.webkit.WebStorage.QuotaUpdater;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebView.HitTestResult; import android.webkit.WebView.HitTestResult;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
@ -296,7 +304,8 @@ public class Barebones extends Activity implements OnLongClickListener,
refreshLayout.setBackgroundResource(R.drawable.button); refreshLayout.setBackgroundResource(R.drawable.button);
// get settings // get settings
WebView test = new WebView(Barebones.this); // getting default webview WebView test = new WebView(Barebones.this); // getting default webview
// 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
@ -391,7 +400,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);
@ -508,24 +517,23 @@ public class Barebones extends Activity implements OnLongClickListener,
Thread updateAutoComplete = new Thread(new Runnable() { Thread updateAutoComplete = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() throws SQLiteMisuseException {
Cursor c = null; Cursor c = null;
columns = new String[] { "url", "title" }; columns = new String[] { "url", "title" };
try{ try {
bookmarks = Browser.BOOKMARKS_URI; bookmarks = Browser.BOOKMARKS_URI;
c = getContentResolver().query(bookmarks, columns, null, null, null); c = getContentResolver().query(bookmarks, columns, null,
null, null);
} catch (SQLiteException e) {
} }
catch(SQLiteException e){}
noStockBrowser = true; noStockBrowser = true;
if(c!=null){ if (c != null) {
noStockBrowser = false; noStockBrowser = false;
Log.i("Barebones","detected AOSP browser"); Log.i("Barebones", "detected AOSP browser");
} } else {
else{ Log.e("Barebones", "did not detect AOSP browser");
Log.e("Barebones","did not detect AOSP browser");
} }
try { try {
@ -537,18 +545,17 @@ 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) {
handler.sendEmptyMessage(2); handler.sendEmptyMessage(2);
Log.e("Barebones: ", "SQLite Error!!! " + e); Log.e("Barebones: ", "SQLite Error!!!");
} }
list = new ArrayList<Map<String, String>>(); list = new ArrayList<Map<String, String>>();
if (managedCursor != null) { if (managedCursor != null) {
if (managedCursor.moveToFirst()) { if (managedCursor.moveToFirst()) {
@ -565,9 +572,10 @@ public class Barebones extends Activity implements OnLongClickListener,
map.put("url", urlA); map.put("url", urlA);
list.add(map); list.add(map);
} while (managedCursor.moveToNext()); } while (managedCursor.moveToNext());
} }
} }
} }
}); });
@ -649,9 +657,11 @@ public class Barebones extends Activity implements OnLongClickListener,
urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0); urlTitle[pageId].setPadding(leftPad, 0, rightPad, 0);
background.addView(main[num]); background.addView(main[num]);
background.removeView(main[pageId]); background.removeView(main[pageId]);
uBar.bringToFront(); uBar.bringToFront();
main[num] = settings(main[num]); main[num] = settings(main[num]);
if (API >= 11) {
main[num].onResume();
}
main[num].loadUrl(theUrl); main[num].loadUrl(theUrl);
pageId = num; pageId = num;
pageIdIsVisible = true; pageIdIsVisible = true;
@ -788,7 +798,7 @@ public class Barebones extends Activity implements OnLongClickListener,
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
main[pageId].getSettings().setLayoutAlgorithm( main[pageId].getSettings().setLayoutAlgorithm(
LayoutAlgorithm.NARROW_COLUMNS); LayoutAlgorithm.NARROW_COLUMNS);
main[pageId].invalidate(); // main[pageId].invalidate();
} }
public void makeTab(final int pageToView, String Url) { public void makeTab(final int pageToView, String Url) {
@ -837,24 +847,52 @@ public class Barebones extends Activity implements OnLongClickListener,
} }
case DialogInterface.BUTTON_NEUTRAL: { case DialogInterface.BUTTON_NEUTRAL: {
if (API > 8) { if (API > 8) {
DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); try {
Uri nice = Uri.parse(result.getExtra()); Thread down = new Thread(
DownloadManager.Request it = new DownloadManager.Request( new Runnable() {
nice); @Override
String fileName = result public void run() {
.getExtra()
.substring( DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
result.getExtra() Uri nice = Uri
.lastIndexOf( .parse(result
'/') + 1, .getExtra());
result.getExtra() DownloadManager.Request it = new DownloadManager.Request(
.length()); nice);
it.setDestinationInExternalPublicDir( String fileName = URLUtil
Environment.DIRECTORY_DOWNLOADS, .guessFileName(
fileName); result.getExtra(),
Log.i("Barebones", "Downloading" null,
+ fileName); null);
download.enqueue(it);
if (API >= 11) {
it.allowScanningByMediaScanner();
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
it.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS,
fileName);
Log.i("Barebones",
"Downloading"
+ fileName);
download.enqueue(it);
}
});
down.run();
} catch (NullPointerException e) {
Log.e("Barebones",
"Problem downloading");
Toast.makeText(Barebones.this,
"Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (IllegalArgumentException e) {
Log.e("Barebones",
"Problem downloading");
Toast.makeText(Barebones.this,
"Error Downloading File",
Toast.LENGTH_SHORT).show();
}
} }
break; break;
} }
@ -933,16 +971,13 @@ public class Barebones extends Activity implements OnLongClickListener,
switch (agentPicker) { switch (agentPicker) {
case 1: case 1:
main[pageToView].getSettings().setUserAgentString(mobile); main[pageToView].getSettings().setUserAgentString(mobile);
Log.i("barebones", mobile);
break; break;
case 2: case 2:
main[pageToView].getSettings().setUserAgentString(desktop); main[pageToView].getSettings().setUserAgentString(desktop);
Log.i("barebones", desktop);
break; break;
case 3: case 3:
userAgent = settings.getString("agent", user); userAgent = settings.getString("agent", user);
main[pageToView].getSettings().setUserAgentString(userAgent); main[pageToView].getSettings().setUserAgentString(userAgent);
Log.i("barebones", userAgent);
break; break;
} }
background.addView(main[pageToView]); background.addView(main[pageToView]);
@ -972,7 +1007,46 @@ public class Barebones extends Activity implements OnLongClickListener,
} }
private class AnthonyWebViewClient extends WebViewClient { protected 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
// view.invalidate();
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,
@ -993,8 +1067,6 @@ public class Barebones extends Activity implements OnLongClickListener,
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
pageIdIsVisible = true;
return super.shouldOverrideUrlLoading(view, url); return super.shouldOverrideUrlLoading(view, url);
} }
@ -1010,8 +1082,6 @@ public class Barebones extends Activity implements OnLongClickListener,
public void onReceivedError(WebView view, int errorCode, public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) { String description, String failingUrl) {
Log.e("Barebones: ", "Error: " + description);
super.onReceivedError(view, errorCode, description, failingUrl); super.onReceivedError(view, errorCode, description, failingUrl);
} }
@ -1039,8 +1109,8 @@ public class Barebones extends Activity implements OnLongClickListener,
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
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, exitTab, urlTitle[numberPage].setCompoundDrawables(webpageOther, null,
null); exitTab, null);
if (uBarShows == false) { if (uBarShows == false) {
uBar.startAnimation(slideDown); uBar.startAnimation(slideDown);
@ -1052,7 +1122,6 @@ 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);
pageIsLoading = false; pageIsLoading = false;
} }
@ -1061,63 +1130,77 @@ public class Barebones extends Activity implements OnLongClickListener,
private class AnthonyDownload implements DownloadListener { private class AnthonyDownload implements DownloadListener {
@Override @Override
public void onDownloadStart(String url, String userAgent, public void onDownloadStart(final String url, String userAgent,
String contentDisposition, String mimetype, long contentLength) { final String contentDisposition, final String mimetype,
long contentLength) {
if (contentDisposition == null if (contentDisposition == null
|| !contentDisposition.regionMatches( || !contentDisposition.regionMatches(true, 0, "attachment",
true, 0, "attachment", 0, 10)) { 0, 10)) {
// query the package manager to see if there's a registered handler // query the package manager to see if there's a registered
// that matches. // handler
Intent intent = new Intent(Intent.ACTION_VIEW); // that matches.
intent.setDataAndType(Uri.parse(url), mimetype); Intent intent = new Intent(Intent.ACTION_VIEW);
ResolveInfo info = getPackageManager().resolveActivity(intent, intent.setDataAndType(Uri.parse(url), mimetype);
PackageManager.MATCH_DEFAULT_ONLY); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (info != null) { ResolveInfo info = getPackageManager().resolveActivity(intent,
ComponentName myName = getComponentName(); PackageManager.MATCH_DEFAULT_ONLY);
// If we resolved to ourselves, we don't want to attempt to if (info != null) {
// load the url only to try and download it again. ComponentName myName = getComponentName();
if (!myName.getPackageName().equals( // If we resolved to ourselves, we don't want to attempt to
info.activityInfo.packageName) // load the url only to try and download it again.
|| !myName.getClassName().equals( if (!myName.getPackageName().equals(
info.activityInfo.name)) { info.activityInfo.packageName)
// someone (other than us) knows how to handle this mime || !myName.getClassName().equals(
// type with this scheme, don't download. info.activityInfo.name)) {
try { // someone (other than us) knows how to handle this mime
startActivity(intent); // type with this scheme, don't download.
return; try {
} catch (ActivityNotFoundException ex) { startActivity(intent);
return;
Log.d("Barebones", "activity not found for " + mimetype } catch (ActivityNotFoundException ex) {
+ " over " + Uri.parse(url).getScheme(),
ex); // Best behavior is to fall back to a download in
// this
// Best behavior is to fall back to a download in this // case
// case }
try { }
DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); }
Uri nice = Uri.parse(url); } else {
DownloadManager.Request it = new DownloadManager.Request(nice); try {
String fileName = URLUtil.guessFileName(url, Thread downloader = new Thread(new Runnable() {
contentDisposition, mimetype); @Override
it.setDestinationInExternalPublicDir( public void run() {
Environment.DIRECTORY_DOWNLOADS, fileName);
Log.i("Barebones", "Downloading" + fileName); DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
download.enqueue(it); Uri nice = Uri.parse(url);
} catch (NullPointerException e) { DownloadManager.Request it = new DownloadManager.Request(
Log.e("Barebones", "Problem downloading"); nice);
Toast.makeText(Barebones.this, "Error Downloading File", String fileName = URLUtil.guessFileName(url,
Toast.LENGTH_SHORT).show(); contentDisposition, mimetype);
}
catch (IllegalArgumentException e){ if (API >= 11) {
Log.e("Barebones", "Problem downloading"); it.allowScanningByMediaScanner();
Toast.makeText(Barebones.this, "Error Downloading File", it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
Toast.LENGTH_SHORT).show(); }
}
} it.setDestinationInExternalPublicDir(
} Environment.DIRECTORY_DOWNLOADS, fileName);
} Log.i("Barebones", "Downloading" + fileName);
} download.enqueue(it);
}
});
downloader.run();
} catch (NullPointerException e) {
Log.e("Barebones", "Problem downloading");
Toast.makeText(Barebones.this, "Error Downloading File",
Toast.LENGTH_SHORT).show();
} catch (IllegalArgumentException e) {
Log.e("Barebones", "Problem downloading");
Toast.makeText(Barebones.this, "Error Downloading File",
Toast.LENGTH_SHORT).show();
}
}
} }
} }
@ -1140,11 +1223,127 @@ public class Barebones extends Activity implements OnLongClickListener,
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
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) {
// TODO Auto-generated method stub
return super.onCreateWindow(view, isDialog, isUserGesture,
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) {
// TODO Auto-generated method stub
main[pageId].freeMemory();
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) {
// Log.i(LOGTAG, "here in on ShowCustomView");
main[pageId].setVisibility(View.GONE);
// if a view already exists then immediately terminate the new one
if (mCustomView != null) {
callback.onCustomViewHidden();
return;
}
background.addView(view);
mCustomView = view;
mCustomViewCallback = callback;
background.setVisibility(View.VISIBLE);
}
@Override @Override
public void onReceivedIcon(WebView view, Bitmap favicon) { public void onReceivedIcon(WebView view, Bitmap favicon) {
icon = null; icon = null;
icon = new BitmapDrawable(getResources(), favicon); icon = new BitmapDrawable(null, favicon);
int num = view.getId(); int num = view.getId();
icon.setBounds(0, 0, width * 1 / 2, height * 1 / 2); icon.setBounds(0, 0, width * 1 / 2, height * 1 / 2);
if (icon != null) { if (icon != null) {
@ -1241,15 +1440,17 @@ public class Barebones extends Activity implements OnLongClickListener,
sb = new StringBuilder("url" + " = "); sb = new StringBuilder("url" + " = ");
DatabaseUtils.appendEscapedSQLString(sb, view.getUrl()); DatabaseUtils.appendEscapedSQLString(sb, view.getUrl());
s = historyHandler.getReadableDatabase(); s = historyHandler.getReadableDatabase();
cursor = s.query("history", new String[] { "id", cursor = s.query("history", new String[] { "id", "url",
"url", "title" }, sb.toString(), null, null, "title" }, sb.toString(), null, null, null,
null, null); null);
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
} else { } else {
historyHandler.addHistoryItem(new HistoryItem(urlToLoad[numberPage][0], title)); historyHandler.addHistoryItem(new HistoryItem(
urlToLoad[numberPage][0], title));
} }
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
Log.e("Barebones", "ERRRRROOORRRR 1"); Log.e("Barebones", "ERRRRROOORRRR 1");
} catch (NullPointerException e) { } catch (NullPointerException e) {
@ -1329,20 +1530,18 @@ public class Barebones extends Activity implements OnLongClickListener,
webViewSettings.setJavaScriptEnabled(true); webViewSettings.setJavaScriptEnabled(true);
webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true); webViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
} }
webViewSettings.setAllowFileAccess(true); webViewSettings.setAllowFileAccess(true);
webViewSettings.setLightTouchEnabled(true); webViewSettings.setLightTouchEnabled(true);
view.setAnimationCacheEnabled(false); // view.setAnimationCacheEnabled(true);
// view.setDrawingCacheEnabled(true); // view.setDrawingCacheEnabled(false);
view.setDrawingCacheBackgroundColor(getResources().getColor( // view.setDrawingCacheBackgroundColor(getResources().getColor(
android.R.color.background_light)); // android.R.color.background_light));
// view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); // view.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
// view.setAlwaysDrawnWithCacheEnabled(true); // view.setAlwaysDrawnWithCacheEnabled(true);
view.setWillNotCacheDrawing(true); view.setWillNotCacheDrawing(true);
// view.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES);
view.setFocusable(true); view.setFocusable(true);
view.setFocusableInTouchMode(true); view.setFocusableInTouchMode(true);
view.setSaveEnabled(true); // view.setSaveEnabled(true);
webViewSettings.setDomStorageEnabled(true); webViewSettings.setDomStorageEnabled(true);
webViewSettings.setAppCacheEnabled(true); webViewSettings.setAppCacheEnabled(true);
webViewSettings.setAppCachePath(getApplicationContext().getFilesDir() webViewSettings.setAppCachePath(getApplicationContext().getFilesDir()
@ -1390,7 +1589,6 @@ public class Barebones extends Activity implements OnLongClickListener,
webViewSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS); webViewSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
webViewSettings.setLoadsImagesAutomatically(true); webViewSettings.setLoadsImagesAutomatically(true);
// webViewSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); // webViewSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
return view; return view;
} }
@ -1488,11 +1686,7 @@ public class Barebones extends Activity implements OnLongClickListener,
bookWriter.close(); bookWriter.close();
urlWriter.close(); urlWriter.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} }
for (int p = 0; p < MAX_BOOKMARKS; p++) { for (int p = 0; p < MAX_BOOKMARKS; p++) {
bUrl[p] = null; bUrl[p] = null;
@ -1515,12 +1709,7 @@ public class Barebones extends Activity implements OnLongClickListener,
readBook.close(); readBook.close();
readUrl.close(); readUrl.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} }
// scrollBookmarks.startAnimation(fadeOut); // scrollBookmarks.startAnimation(fadeOut);
background.removeView(scrollBookmarks); background.removeView(scrollBookmarks);
@ -1573,6 +1762,7 @@ public class Barebones extends Activity implements OnLongClickListener,
} }
} }
public void addBookmark() { public void addBookmark() {
File book = new File(getBaseContext().getFilesDir(), "bookmarks"); File book = new File(getBaseContext().getFilesDir(), "bookmarks");
File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl");
@ -1588,13 +1778,8 @@ public class Barebones extends Activity implements OnLongClickListener,
bookWriter.close(); bookWriter.close();
urlWriter.close(); urlWriter.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace();
} }
} }
@ -1615,12 +1800,7 @@ public class Barebones extends Activity implements OnLongClickListener,
readBook.close(); readBook.close();
readUrl.close(); readUrl.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} }
openBookmarks(); openBookmarks();
} }
@ -1652,6 +1832,7 @@ public class Barebones extends Activity implements OnLongClickListener,
int leftId = id; int leftId = id;
pageIdIsVisible = false; pageIdIsVisible = false;
main[id].stopLoading(); main[id].stopLoading();
main[id].clearHistory();
if (API >= 11) { if (API >= 11) {
main[id].onPause(); main[id].onPause();
} }
@ -1739,7 +1920,7 @@ public class Barebones extends Activity implements OnLongClickListener,
finish(); finish();
} else { } else {
pageIdIsVisible = true; pageIdIsVisible = true;
main[pageId].invalidate(); // main[pageId].invalidate();
} }
} }
@ -2109,10 +2290,8 @@ public class Barebones extends Activity implements OnLongClickListener,
Browser.clearHistory(getContentResolver()); Browser.clearHistory(getContentResolver());
} }
} }
// trimCache(this); trimCache(this);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
this.onPause(); this.onPause();
super.finish(); super.finish();
@ -2120,22 +2299,23 @@ public class Barebones extends Activity implements OnLongClickListener,
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
} }
public static void trimCache(Context context) { public void trimCache(Context context) {
try { try {
File dir = context.getCacheDir(); File dir = context.getCacheDir();
if (dir != null && dir.isDirectory()) { if (dir != null && dir.isDirectory()) {
deleteDir(dir); // deleteDir(dir);
} }
} catch (Exception e) { } catch (Exception e) {
} }
} }
public static boolean deleteDir(File dir) { public boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) { if (dir != null && dir.isDirectory()) {
String[] children = dir.list(); String[] children = dir.list();
for (int i = 0; i < children.length; i++) { for (int i = 0; i < children.length; i++) {

Loading…
Cancel
Save