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. 33
      src/acr/browser/barebones/AnthonyWebView.java
  4. 352
      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" />

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

@ -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) {
uBar.startAnimation(slideDown);
uBarShows = true;
} else if (uBarShows) {
uBar.startAnimation(slideUp);
uBarShows = false;
} }
break; timeBetweenDownPress = System.currentTimeMillis();
if (showFullScreen) {
} else if (Barebones.main[Barebones.pageId].getScrollY() > 5 && uBarShows) { if (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;

352
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,6 +304,7 @@ 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);
@ -508,25 +517,24 @@ 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 {
managedCursor = null; managedCursor = null;
@ -542,14 +550,13 @@ public class Barebones extends Activity implements OnLongClickListener,
} 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()) {
// Variable for holding the retrieved URL // Variable for holding the retrieved URL
@ -565,6 +572,7 @@ 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,25 +847,53 @@ public class Barebones extends Activity implements OnLongClickListener,
} }
case DialogInterface.BUTTON_NEUTRAL: { case DialogInterface.BUTTON_NEUTRAL: {
if (API > 8) { if (API > 8) {
try {
Thread down = new Thread(
new Runnable() {
@Override
public void run() {
DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); DownloadManager download = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
Uri nice = Uri.parse(result.getExtra()); Uri nice = Uri
.parse(result
.getExtra());
DownloadManager.Request it = new DownloadManager.Request( DownloadManager.Request it = new DownloadManager.Request(
nice); nice);
String fileName = result String fileName = URLUtil
.getExtra() .guessFileName(
.substring( result.getExtra(),
result.getExtra() null,
.lastIndexOf( null);
'/') + 1,
result.getExtra() if (API >= 11) {
.length()); it.allowScanningByMediaScanner();
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
it.setDestinationInExternalPublicDir( it.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, Environment.DIRECTORY_DOWNLOADS,
fileName); fileName);
Log.i("Barebones", "Downloading" Log.i("Barebones",
"Downloading"
+ fileName); + fileName);
download.enqueue(it); 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,15 +1130,18 @@ 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
// handler
// that matches. // that matches.
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), mimetype); intent.setDataAndType(Uri.parse(url), mimetype);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ResolveInfo info = getPackageManager().resolveActivity(intent, ResolveInfo info = getPackageManager().resolveActivity(intent,
PackageManager.MATCH_DEFAULT_ONLY); PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) { if (info != null) {
@ -1087,36 +1159,47 @@ public class Barebones extends Activity implements OnLongClickListener,
return; return;
} catch (ActivityNotFoundException ex) { } catch (ActivityNotFoundException ex) {
Log.d("Barebones", "activity not found for " + mimetype // Best behavior is to fall back to a download in
+ " over " + Uri.parse(url).getScheme(), // this
ex);
// Best behavior is to fall back to a download in this
// case // case
}
}
}
} else {
try { try {
Thread downloader = new Thread(new Runnable() {
@Override
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(nice); DownloadManager.Request it = new DownloadManager.Request(
nice);
String fileName = URLUtil.guessFileName(url, String fileName = URLUtil.guessFileName(url,
contentDisposition, mimetype); contentDisposition, mimetype);
if (API >= 11) {
it.allowScanningByMediaScanner();
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
}
it.setDestinationInExternalPublicDir( it.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, fileName); Environment.DIRECTORY_DOWNLOADS, fileName);
Log.i("Barebones", "Downloading" + fileName); Log.i("Barebones", "Downloading" + fileName);
download.enqueue(it); download.enqueue(it);
}
});
downloader.run();
} catch (NullPointerException e) { } catch (NullPointerException e) {
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 (IllegalArgumentException e) {
catch (IllegalArgumentException e){
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();
} }
} }
}
}
}
} }
@ -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,13 +1440,15 @@ 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) {
@ -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();
@ -2124,18 +2303,19 @@ public class Barebones extends Activity implements OnLongClickListener,
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