Browse Source

Moved bookmark and homepage file locations so they don't get destroyed when the cache gets cleared

master
Anthony Restaino 11 years ago
parent
commit
ec6c1bcd2a
  1. 52
      src/acr/browser/lightning/BrowserActivity.java
  2. 12
      src/acr/browser/lightning/LightningView.java

52
src/acr/browser/lightning/BrowserActivity.java

@ -68,104 +68,55 @@ import java.util.*;
public class BrowserActivity extends Activity implements BrowserController { public class BrowserActivity extends Activity implements BrowserController {
private DrawerLayout mDrawerLayout; private DrawerLayout mDrawerLayout;
private ListView mDrawerList; private ListView mDrawerList;
private RelativeLayout mDrawer; private RelativeLayout mDrawer;
private LinearLayout mDrawerRight; private LinearLayout mDrawerRight;
private ListView mDrawerListRight; private ListView mDrawerListRight;
private RelativeLayout mNewTab; private RelativeLayout mNewTab;
private ActionBarDrawerToggle mDrawerToggle; private ActionBarDrawerToggle mDrawerToggle;
private List<LightningView> mWebViews = new ArrayList<LightningView>(); private List<LightningView> mWebViews = new ArrayList<LightningView>();
private List<Integer> mIdList = new ArrayList<Integer>(); private List<Integer> mIdList = new ArrayList<Integer>();
private LightningView mCurrentView; private LightningView mCurrentView;
private int mIdGenerator; private int mIdGenerator;
private LightningViewAdapter mTitleAdapter; private LightningViewAdapter mTitleAdapter;
private List<HistoryItem> mBookmarkList; private List<HistoryItem> mBookmarkList;
private BookmarkViewAdapter mBookmarkAdapter; private BookmarkViewAdapter mBookmarkAdapter;
private AutoCompleteTextView mSearch; private AutoCompleteTextView mSearch;
private ClickHandler mClickHandler; private ClickHandler mClickHandler;
private ProgressBar mProgressBar; private ProgressBar mProgressBar;
private boolean mSystemBrowser = false; private boolean mSystemBrowser = false;
private ValueCallback<Uri> mUploadMessage; private ValueCallback<Uri> mUploadMessage;
private View mCustomView; private View mCustomView;
private int mOriginalOrientation; private int mOriginalOrientation;
private int mActionBarSize; private int mActionBarSize;
private ActionBar mActionBar; private ActionBar mActionBar;
private boolean mFullScreen; private boolean mFullScreen;
private FrameLayout mBrowserFrame; private FrameLayout mBrowserFrame;
private FullscreenHolder mFullscreenContainer; private FullscreenHolder mFullscreenContainer;
private CustomViewCallback mCustomViewCallback; private CustomViewCallback mCustomViewCallback;
private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams( private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
private Bitmap mDefaultVideoPoster; private Bitmap mDefaultVideoPoster;
private View mVideoProgressView; private View mVideoProgressView;
private DatabaseHandler mHistoryHandler; private DatabaseHandler mHistoryHandler;
private SQLiteDatabase mHistoryDatabase; private SQLiteDatabase mHistoryDatabase;
private SharedPreferences mPreferences; private SharedPreferences mPreferences;
private SharedPreferences.Editor mEditPrefs; private SharedPreferences.Editor mEditPrefs;
private Context mContext; private Context mContext;
private Bitmap mWebpageBitmap; private Bitmap mWebpageBitmap;
private String mSearchText; private String mSearchText;
private Activity mActivity; private Activity mActivity;
private final int API = android.os.Build.VERSION.SDK_INT; private final int API = android.os.Build.VERSION.SDK_INT;
private Drawable mDeleteIcon; private Drawable mDeleteIcon;
private Drawable mRefreshIcon; private Drawable mRefreshIcon;
private Drawable mCopyIcon; private Drawable mCopyIcon;
private Drawable mIcon; private Drawable mIcon;
private int mActionBarSizeDp; private int mActionBarSizeDp;
private int mNumberIconColor; private int mNumberIconColor;
private String mHomepage; private String mHomepage;
private boolean mIsNewIntent = false; private boolean mIsNewIntent = false;
private VideoView mVideoView; private VideoView mVideoView;
private static SearchAdapter mSearchAdapter; private static SearchAdapter mSearchAdapter;
private static LayoutParams mMatchParent = new LayoutParams(LayoutParams.MATCH_PARENT, private static LayoutParams mMatchParent = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT); LayoutParams.MATCH_PARENT);
@ -648,7 +599,6 @@ public class BrowserActivity extends Activity implements BrowserController {
try { try {
WebkitProxy.resetProxy("acr.browser.lightning.BrowserApp", getApplicationContext()); WebkitProxy.resetProxy("acr.browser.lightning.BrowserApp", getApplicationContext());
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -1997,7 +1947,7 @@ public class BrowserActivity extends Activity implements BrowserController {
+ helper.getTitle() + BookmarkPageVariables.Part4); + helper.getTitle() + BookmarkPageVariables.Part4);
} }
bookmarkHtml += BookmarkPageVariables.End; bookmarkHtml += BookmarkPageVariables.End;
File bookmarkWebPage = new File(mContext.getCacheDir(), "bookmarks.html"); File bookmarkWebPage = new File(mContext.getFilesDir(), "bookmarks.html");
try { try {
FileWriter bookWriter = new FileWriter(bookmarkWebPage, false); FileWriter bookWriter = new FileWriter(bookmarkWebPage, false);
bookWriter.write(bookmarkHtml); bookWriter.write(bookmarkHtml);

12
src/acr/browser/lightning/LightningView.java

@ -243,7 +243,7 @@ public class LightningView {
home = home + HomepageVariables.END; home = home + HomepageVariables.END;
File homepage = new File(mActivity.getCacheDir(), "homepage.html"); File homepage = new File(mActivity.getFilesDir(), "homepage.html");
try { try {
FileWriter hWriter = new FileWriter(homepage, false); FileWriter hWriter = new FileWriter(homepage, false);
hWriter.write(home); hWriter.write(home);
@ -366,13 +366,13 @@ public class LightningView {
settings.setMediaPlaybackRequiresUserGesture(true); settings.setMediaPlaybackRequiresUserGesture(true);
} }
if (API < 19) { if (API < 19) {
settings.setDatabasePath(context.getFilesDir().getAbsolutePath() + "/databases"); settings.setDatabasePath(context.getCacheDir() + "/databases");
} }
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAppCachePath(context.getCacheDir().toString());
settings.setAppCacheEnabled(true); settings.setAppCacheEnabled(true);
settings.setAppCachePath(context.getCacheDir().toString());
settings.setCacheMode(WebSettings.LOAD_DEFAULT); settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setGeolocationDatabasePath(context.getCacheDir().getAbsolutePath()); settings.setGeolocationDatabasePath(context.getFilesDir().toString());
settings.setAllowFileAccess(true); settings.setAllowFileAccess(true);
settings.setDatabaseEnabled(true); settings.setDatabaseEnabled(true);
settings.setSupportZoom(true); settings.setSupportZoom(true);
@ -432,6 +432,10 @@ public class LightningView {
public void setNormalRendering() { public void setNormalRendering() {
mWebView.setLayerType(View.LAYER_TYPE_NONE, mPaint); mWebView.setLayerType(View.LAYER_TYPE_NONE, mPaint);
} }
public void setSoftwareRendering() {
mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, mPaint);
}
public void setColorMode(int mode) { public void setColorMode(int mode) {
switch (mode) { switch (mode) {

Loading…
Cancel
Save