From ec6c1bcd2ae33e23c488bb72c69fbd3cc5055401 Mon Sep 17 00:00:00 2001 From: Anthony Restaino Date: Thu, 14 Aug 2014 21:11:18 -0400 Subject: [PATCH] Moved bookmark and homepage file locations so they don't get destroyed when the cache gets cleared --- .../browser/lightning/BrowserActivity.java | 52 +------------------ src/acr/browser/lightning/LightningView.java | 12 +++-- 2 files changed, 9 insertions(+), 55 deletions(-) diff --git a/src/acr/browser/lightning/BrowserActivity.java b/src/acr/browser/lightning/BrowserActivity.java index d10971b..ef9f20f 100644 --- a/src/acr/browser/lightning/BrowserActivity.java +++ b/src/acr/browser/lightning/BrowserActivity.java @@ -68,104 +68,55 @@ import java.util.*; public class BrowserActivity extends Activity implements BrowserController { private DrawerLayout mDrawerLayout; - private ListView mDrawerList; - private RelativeLayout mDrawer; - private LinearLayout mDrawerRight; - private ListView mDrawerListRight; - private RelativeLayout mNewTab; - private ActionBarDrawerToggle mDrawerToggle; - private List mWebViews = new ArrayList(); - private List mIdList = new ArrayList(); - private LightningView mCurrentView; - private int mIdGenerator; - private LightningViewAdapter mTitleAdapter; - private List mBookmarkList; - private BookmarkViewAdapter mBookmarkAdapter; - private AutoCompleteTextView mSearch; - private ClickHandler mClickHandler; - private ProgressBar mProgressBar; - private boolean mSystemBrowser = false; - private ValueCallback mUploadMessage; - private View mCustomView; - private int mOriginalOrientation; - private int mActionBarSize; - private ActionBar mActionBar; - private boolean mFullScreen; - private FrameLayout mBrowserFrame; - private FullscreenHolder mFullscreenContainer; - private CustomViewCallback mCustomViewCallback; - private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - private Bitmap mDefaultVideoPoster; - private View mVideoProgressView; - private DatabaseHandler mHistoryHandler; - private SQLiteDatabase mHistoryDatabase; - private SharedPreferences mPreferences; - private SharedPreferences.Editor mEditPrefs; - private Context mContext; - private Bitmap mWebpageBitmap; - private String mSearchText; - private Activity mActivity; - private final int API = android.os.Build.VERSION.SDK_INT; - private Drawable mDeleteIcon; - private Drawable mRefreshIcon; - private Drawable mCopyIcon; - private Drawable mIcon; - private int mActionBarSizeDp; - private int mNumberIconColor; - private String mHomepage; - private boolean mIsNewIntent = false; - private VideoView mVideoView; - private static SearchAdapter mSearchAdapter; - private static LayoutParams mMatchParent = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); @@ -648,7 +599,6 @@ public class BrowserActivity extends Activity implements BrowserController { try { WebkitProxy.resetProxy("acr.browser.lightning.BrowserApp", getApplicationContext()); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -1997,7 +1947,7 @@ public class BrowserActivity extends Activity implements BrowserController { + helper.getTitle() + BookmarkPageVariables.Part4); } bookmarkHtml += BookmarkPageVariables.End; - File bookmarkWebPage = new File(mContext.getCacheDir(), "bookmarks.html"); + File bookmarkWebPage = new File(mContext.getFilesDir(), "bookmarks.html"); try { FileWriter bookWriter = new FileWriter(bookmarkWebPage, false); bookWriter.write(bookmarkHtml); diff --git a/src/acr/browser/lightning/LightningView.java b/src/acr/browser/lightning/LightningView.java index 2dbed1f..27f03cf 100644 --- a/src/acr/browser/lightning/LightningView.java +++ b/src/acr/browser/lightning/LightningView.java @@ -243,7 +243,7 @@ public class LightningView { home = home + HomepageVariables.END; - File homepage = new File(mActivity.getCacheDir(), "homepage.html"); + File homepage = new File(mActivity.getFilesDir(), "homepage.html"); try { FileWriter hWriter = new FileWriter(homepage, false); hWriter.write(home); @@ -366,13 +366,13 @@ public class LightningView { settings.setMediaPlaybackRequiresUserGesture(true); } if (API < 19) { - settings.setDatabasePath(context.getFilesDir().getAbsolutePath() + "/databases"); + settings.setDatabasePath(context.getCacheDir() + "/databases"); } settings.setDomStorageEnabled(true); - settings.setAppCachePath(context.getCacheDir().toString()); settings.setAppCacheEnabled(true); + settings.setAppCachePath(context.getCacheDir().toString()); settings.setCacheMode(WebSettings.LOAD_DEFAULT); - settings.setGeolocationDatabasePath(context.getCacheDir().getAbsolutePath()); + settings.setGeolocationDatabasePath(context.getFilesDir().toString()); settings.setAllowFileAccess(true); settings.setDatabaseEnabled(true); settings.setSupportZoom(true); @@ -432,6 +432,10 @@ public class LightningView { public void setNormalRendering() { mWebView.setLayerType(View.LAYER_TYPE_NONE, mPaint); } + + public void setSoftwareRendering() { + mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, mPaint); + } public void setColorMode(int mode) { switch (mode) {