Browse Source

Use a PreferenceManager to handle SharedPreferences among classes

master
Anthony Restaino 10 years ago
parent
commit
2d347074a6
  1. 7
      src/acr/browser/lightning/AdBlock.java
  2. 38
      src/acr/browser/lightning/AdvancedSettingsActivity.java
  3. 7
      src/acr/browser/lightning/BookmarkActivity.java
  4. 3
      src/acr/browser/lightning/BookmarkManager.java
  5. 89
      src/acr/browser/lightning/BrowserActivity.java
  6. 39
      src/acr/browser/lightning/DisplaySettingsActivity.java
  7. 5
      src/acr/browser/lightning/DownloadHandler.java
  8. 78
      src/acr/browser/lightning/GeneralSettingsActivity.java
  9. 11
      src/acr/browser/lightning/IncognitoActivity.java
  10. 49
      src/acr/browser/lightning/LightningView.java
  11. 8
      src/acr/browser/lightning/MainActivity.java
  12. 56
      src/acr/browser/lightning/PreferenceConstants.java
  13. 399
      src/acr/browser/lightning/PreferenceManager.java
  14. 49
      src/acr/browser/lightning/PrivacySettingsActivity.java
  15. 16
      src/acr/browser/lightning/ReadingActivity.java
  16. 7
      src/acr/browser/lightning/SearchAdapter.java
  17. 117
      src/acr/browser/lightning/SettingsActivity.java
  18. 9
      src/acr/browser/lightning/ThemableActivity.java
  19. 9
      src/acr/browser/lightning/ThemableSettingsActivity.java

7
src/acr/browser/lightning/AdBlock.java

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
package acr.browser.lightning;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.util.Log;
@ -19,7 +18,6 @@ public class AdBlock { @@ -19,7 +18,6 @@ public class AdBlock {
private static final String TAG = "AdBlock";
private static final String BLOCKED_DOMAINS_LIST_FILE_NAME = "hosts.txt";
private static final Set<String> mBlockedDomainsList = new HashSet<String>();
private SharedPreferences mPreferences;
private boolean mBlockAds;
private static final Locale mLocale = Locale.getDefault();
private static AdBlock mInstance;
@ -35,12 +33,11 @@ public class AdBlock { @@ -35,12 +33,11 @@ public class AdBlock {
if (mBlockedDomainsList.isEmpty()) {
loadBlockedDomainsList(context);
}
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mBlockAds = mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false);
mBlockAds = PreferenceManager.getInstance().getAdBlockEnabled();
}
public void updatePreference() {
mBlockAds = mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false);
mBlockAds = PreferenceManager.getInstance().getAdBlockEnabled();
}
private void loadBlockedDomainsList(final Context context) {

38
src/acr/browser/lightning/AdvancedSettingsActivity.java

@ -7,7 +7,6 @@ import android.app.Activity; @@ -7,7 +7,6 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
@ -22,13 +21,13 @@ import android.widget.TextView; @@ -22,13 +21,13 @@ import android.widget.TextView;
public class AdvancedSettingsActivity extends ThemableSettingsActivity {
private SharedPreferences mPreferences;
private CheckBox cbAllowPopups, cbAllowCookies, cbAllowIncognitoCookies, cbRestoreTabs;
private Context mContext;
private TextView mRenderText;
private TextView mUrlText;
private Activity mActivity;
private CharSequence[] mUrlOptions;
private PreferenceManager mPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -53,7 +52,8 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity { @@ -53,7 +52,8 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity {
}
private void initialize() {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mPreferences = PreferenceManager.getInstance();
RelativeLayout rAllowPopups, rAllowCookies, rAllowIncognitoCookies, rRestoreTabs;
LinearLayout lRenderPicker, lUrlContent;
@ -70,17 +70,15 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity { @@ -70,17 +70,15 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity {
cbAllowIncognitoCookies = (CheckBox) findViewById(R.id.cbAllowIncognitoCookies);
cbRestoreTabs = (CheckBox) findViewById(R.id.cbRestoreTabs);
cbAllowPopups.setChecked(mPreferences.getBoolean(PreferenceConstants.POPUPS, true));
cbAllowCookies.setChecked(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
cbAllowIncognitoCookies.setChecked(mPreferences.getBoolean(
PreferenceConstants.INCOGNITO_COOKIES, false));
cbRestoreTabs.setChecked(mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS,
true));
cbAllowPopups.setChecked(mPreferences.getPopupsEnabled());
cbAllowCookies.setChecked(mPreferences.getCookiesEnabled());
cbAllowIncognitoCookies.setChecked(mPreferences.getIncognitoCookiesEnabled());
cbRestoreTabs.setChecked(mPreferences.getRestoreLostTabsEnabled());
mRenderText = (TextView) findViewById(R.id.renderText);
mUrlText = (TextView) findViewById(R.id.urlText);
switch (mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0)) {
switch (mPreferences.getRenderingMode()) {
case 0:
mRenderText.setText(mContext.getString(R.string.name_normal));
break;
@ -96,7 +94,7 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity { @@ -96,7 +94,7 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity {
}
mUrlOptions = this.getResources().getStringArray(R.array.url_content_array);
int option = mPreferences.getInt(PreferenceConstants.URL_BOX_CONTENTS, 0);
int option = mPreferences.getUrlBoxContentChoice();
mUrlText.setText(mUrlOptions[option]);
LayoutClickListener listener = new LayoutClickListener();
@ -150,18 +148,16 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity { @@ -150,18 +148,16 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()) {
case R.id.cbAllowPopups:
mPreferences.edit().putBoolean(PreferenceConstants.POPUPS, isChecked).apply();
mPreferences.setPopupsEnabled(isChecked);
break;
case R.id.cbAllowCookies:
mPreferences.edit().putBoolean(PreferenceConstants.COOKIES, isChecked).apply();
mPreferences.setCookiesEnabled(isChecked);
break;
case R.id.cbAllowIncognitoCookies:
mPreferences.edit()
.putBoolean(PreferenceConstants.INCOGNITO_COOKIES, isChecked).apply();
mPreferences.setIncognitoCookiesEnabled(isChecked);
break;
case R.id.cbRestoreTabs:
mPreferences.edit()
.putBoolean(PreferenceConstants.RESTORE_LOST_TABS, isChecked).apply();
mPreferences.setRestoreLostTabsEnabled(isChecked);
break;
}
}
@ -177,13 +173,13 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity { @@ -177,13 +173,13 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity {
mContext.getString(R.string.name_grayscale),
mContext.getString(R.string.name_inverted_grayscale) };
int n = mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0);
int n = mPreferences.getRenderingMode();
picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferences.edit().putInt(PreferenceConstants.RENDERING_MODE, which).apply();
mPreferences.setRenderingMode(which);
switch (which) {
case 0:
mRenderText.setText(mContext.getString(R.string.name_normal));
@ -216,13 +212,13 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity { @@ -216,13 +212,13 @@ public class AdvancedSettingsActivity extends ThemableSettingsActivity {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.url_contents));
int n = mPreferences.getInt(PreferenceConstants.URL_BOX_CONTENTS, 0);
int n = mPreferences.getUrlBoxContentChoice();
picker.setSingleChoiceItems(mUrlOptions, n, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferences.edit().putInt(PreferenceConstants.URL_BOX_CONTENTS, which).apply();
mPreferences.setUrlBoxContentChoice(which);
if (which < mUrlOptions.length) {
mUrlText.setText(mUrlOptions[which]);
}

7
src/acr/browser/lightning/BookmarkActivity.java

@ -8,7 +8,6 @@ import android.app.AlertDialog; @@ -8,7 +8,6 @@ import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.widget.Toolbar;
@ -21,8 +20,8 @@ import android.widget.TextView; @@ -21,8 +20,8 @@ import android.widget.TextView;
public class BookmarkActivity extends ThemableSettingsActivity implements OnClickListener {
private BookmarkManager mBookmarkManager;
private PreferenceManager mPreferences;
private boolean mSystemBrowser;
private SharedPreferences mPreferences;
private File[] mFileList;
private String[] mFileNameList;
private File mPath = new File(Environment.getExternalStorageDirectory().toString());
@ -47,9 +46,7 @@ public class BookmarkActivity extends ThemableSettingsActivity implements OnClic @@ -47,9 +46,7 @@ public class BookmarkActivity extends ThemableSettingsActivity implements OnClic
mBookmarkManager = BookmarkManager.getInstance(getApplicationContext());
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
mSystemBrowser = mPreferences.getSystemBrowserPresent();
exportBackup.setOnClickListener(this);
importBackup.setOnClickListener(this);

3
src/acr/browser/lightning/BookmarkManager.java

@ -321,8 +321,7 @@ public class BookmarkManager { @@ -321,8 +321,7 @@ public class BookmarkManager {
* permanent bookmark storage
*/
public synchronized void importBookmarksFromBrowser() {
if (mContext.getSharedPreferences(PreferenceConstants.PREFERENCES, 0).getBoolean(
PreferenceConstants.SYSTEM_BROWSER_PRESENT, false)) {
if (PreferenceManager.getInstance().getSystemBrowserPresent()) {
List<HistoryItem> bookmarkList = new ArrayList<HistoryItem>();
String[] columns = new String[] { Browser.BookmarkColumns.TITLE,

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

@ -117,7 +117,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -117,7 +117,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
// Storage
private HistoryDatabase mHistoryDatabase;
private BookmarkManager mBookmarkManager;
private SharedPreferences mPreferences;
private PreferenceManager mPreferences;
// Image
private Bitmap mDefaultVideoPoster, mWebpageBitmap;
@ -145,9 +145,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -145,9 +145,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mDarkTheme = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false)
|| isIncognito();
mPreferences = PreferenceManager.getInstance();
mDarkTheme = mPreferences.getUseDarkTheme() || isIncognito();
mActivity = this;
mWebViews.clear();
@ -182,7 +181,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -182,7 +181,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
mActionBar = getSupportActionBar();
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
mHomepage = mPreferences.getHomepage();
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViews);
mDrawerListLeft.setAdapter(mTitleAdapter);
@ -272,12 +271,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -272,12 +271,12 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@Override
public boolean onLongClick(View v) {
String url = mPreferences.getString(PreferenceConstants.SAVE_URL, null);
String url = mPreferences.getSavedUrl();
if (url != null) {
newTab(url, true);
Toast.makeText(mActivity, R.string.deleted_tab, Toast.LENGTH_SHORT).show();
}
mPreferences.edit().putString(PreferenceConstants.SAVE_URL, null).apply();
mPreferences.setSavedUrl(null);
return true;
}
@ -487,25 +486,21 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -487,25 +486,21 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
* proxying for this session
*/
public boolean checkForTor() {
boolean useProxy = mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false);
boolean useProxy = mPreferences.getUseProxy();
OrbotHelper oh = new OrbotHelper(this);
if (oh.isOrbotInstalled()
&& !mPreferences.getBoolean(PreferenceConstants.INITIAL_CHECK_FOR_TOR, false)) {
mPreferences.edit().putBoolean(PreferenceConstants.INITIAL_CHECK_FOR_TOR, true).apply();
if (oh.isOrbotInstalled() && !mPreferences.getCheckedForTor()) {
mPreferences.setCheckedForTor(true);
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true)
.apply();
mPreferences.setUseProxy(true);
initializeTor();
break;
case DialogInterface.BUTTON_NEGATIVE:
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false)
.apply();
mPreferences.setUseProxy(false);
break;
}
}
@ -520,7 +515,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -520,7 +515,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
} else if (oh.isOrbotInstalled() & useProxy) {
return true;
} else {
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false).apply();
mPreferences.setUseProxy(false);
return false;
}
}
@ -535,8 +530,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -535,8 +530,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
oh.requestOrbotStart(this);
}
try {
String host = mPreferences.getString(PreferenceConstants.USE_PROXY_HOST, "localhost");
int port = mPreferences.getInt(PreferenceConstants.USE_PROXY_PORT, 8118);
String host = mPreferences.getProxyHost();
int port = mPreferences.getProxyPort();
WebkitProxy.setProxy(this.getPackageName() + ".BrowserApp", getApplicationContext(),
host, port);
} catch (Exception e) {
@ -602,9 +597,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -602,9 +597,9 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
}
}
if (mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) {
String mem = mPreferences.getString(PreferenceConstants.URL_MEMORY, "");
mPreferences.edit().putString(PreferenceConstants.URL_MEMORY, "").apply();
if (mPreferences.getRestoreLostTabsEnabled()) {
String mem = mPreferences.getMemoryUrl();
mPreferences.setMemoryUrl("");
String[] array = Utils.getArray(mem);
int count = 0;
for (int n = 0; n < array.length; n++) {
@ -627,11 +622,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -627,11 +622,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
public void initializePreferences() {
if (mPreferences == null) {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
}
mFullScreen = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false);
mColorMode = mPreferences.getBoolean(PreferenceConstants.ENABLE_COLOR_MODE, true);
mFullScreen = mPreferences.getFullScreenEnabled();
mColorMode = mPreferences.getColorModeEnabled();
mColorMode &= !mDarkTheme;
if (!isIncognito() && !mColorMode && !mDarkTheme && mWebpageBitmap != null) {
@ -649,17 +641,16 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -649,17 +641,16 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
mBrowserFrame.removeView(mToolbarLayout);
mUiLayout.addView(mToolbarLayout, 0);
}
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
if (mPreferences.getHideStatusBarEnabled()) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
switch (mPreferences.getSearchChoice()) {
case 0:
mSearchText = mPreferences.getString(PreferenceConstants.SEARCH_URL,
Constants.GOOGLE_SEARCH);
mSearchText = mPreferences.getSearchUrl();
if (!mSearchText.startsWith(Constants.HTTP)
&& !mSearchText.startsWith(Constants.HTTPS)) {
mSearchText = Constants.GOOGLE_SEARCH;
@ -698,7 +689,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -698,7 +689,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
updateCookiePreference();
if (mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false)) {
if (mPreferences.getUseProxy()) {
initializeTor();
} else {
try {
@ -1155,7 +1146,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1155,7 +1146,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
return;
}
if (reference.getUrl() != null && !reference.getUrl().startsWith(Constants.FILE)) {
mPreferences.edit().putString(PreferenceConstants.SAVE_URL, reference.getUrl()).apply();
mPreferences.setSavedUrl(reference.getUrl());
}
boolean isShown = reference.isShown();
if (isShown) {
@ -1191,20 +1182,17 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1191,20 +1182,17 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
closeActivity();
} else {
mWebViews.remove(position);
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, false)
&& mCurrentView != null && !isIncognito()) {
if (mPreferences.getClearCacheExit() && mCurrentView != null && !isIncognito()) {
mCurrentView.clearCache(true);
Log.d(Constants.TAG, "Cache Cleared");
}
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, false)
&& !isIncognito()) {
if (mPreferences.getClearHistoryExitEnabled() && !isIncognito()) {
clearHistory();
Log.d(Constants.TAG, "History Cleared");
}
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, false)
&& !isIncognito()) {
if (mPreferences.getClearCookiesExitEnabled() && !isIncognito()) {
clearCookies();
Log.d(Constants.TAG, "Cookies Cleared");
@ -1237,20 +1225,17 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1237,20 +1225,17 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
private void closeBrowser() {
mBrowserFrame.setBackgroundColor(mBackgroundColor);
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, false)
&& mCurrentView != null && !isIncognito()) {
if (mPreferences.getClearCacheExit() && mCurrentView != null && !isIncognito()) {
mCurrentView.clearCache(true);
Log.d(Constants.TAG, "Cache Cleared");
}
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, false)
&& !isIncognito()) {
if (mPreferences.getClearHistoryExitEnabled() && !isIncognito()) {
clearHistory();
Log.d(Constants.TAG, "History Cleared");
}
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, false)
&& !isIncognito()) {
if (mPreferences.getClearCookiesExitEnabled() && !isIncognito()) {
clearCookies();
Log.d(Constants.TAG, "Cookies Cleared");
@ -1335,14 +1320,14 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1335,14 +1320,14 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
}
public void saveOpenTabs() {
if (mPreferences.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) {
if (mPreferences.getRestoreLostTabsEnabled()) {
String s = "";
for (int n = 0; n < mWebViews.size(); n++) {
if (mWebViews.get(n).getUrl() != null) {
s = s + mWebViews.get(n).getUrl() + "|$|SEPARATOR|$|";
}
}
mPreferences.edit().putString(PreferenceConstants.URL_MEMORY, s).apply();
mPreferences.setMemoryUrl(s);
}
}
@ -1749,7 +1734,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1749,7 +1734,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
return;
}
if (shortUrl && !url.startsWith(Constants.FILE)) {
switch (mPreferences.getInt(PreferenceConstants.URL_BOX_CONTENTS, 0)) {
switch (mPreferences.getUrlBoxContentChoice()) {
case 0: // Default, show only the domain
url = url.replaceFirst(Constants.HTTP, "");
url = Utils.getDomainName(url);
@ -1794,8 +1779,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1794,8 +1779,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
Runnable update = new Runnable() {
@Override
public void run() {
if (isSystemBrowserAvailable()
&& mPreferences.getBoolean(PreferenceConstants.SYNC_HISTORY, true)) {
if (isSystemBrowserAvailable() && mPreferences.getSyncHistoryEnabled()) {
try {
Browser.updateVisitedHistory(getContentResolver(), url, true);
} catch (NullPointerException ignored) {
@ -1848,8 +1832,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -1848,8 +1832,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
c.close();
c = null;
}
mPreferences.edit().putBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, browserFlag)
.apply();
mPreferences.setSystemBrowserPresent(browserFlag);
return browserFlag;
}
@ -2051,7 +2034,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @@ -2051,7 +2034,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
} catch (SecurityException e) {
Log.e(Constants.TAG, "WebView is not allowed to keep the screen on");
}
setFullscreen(mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false));
setFullscreen(mPreferences.getHideStatusBarEnabled());
FrameLayout decor = (FrameLayout) getWindow().getDecorView();
if (decor != null) {
decor.removeView(mFullscreenContainer);

39
src/acr/browser/lightning/DisplaySettingsActivity.java

@ -5,7 +5,6 @@ package acr.browser.lightning; @@ -5,7 +5,6 @@ package acr.browser.lightning;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
@ -19,7 +18,7 @@ import android.widget.RelativeLayout; @@ -19,7 +18,7 @@ import android.widget.RelativeLayout;
public class DisplaySettingsActivity extends ThemableSettingsActivity {
// mPreferences variables
private SharedPreferences mPreferences;
private PreferenceManager mPreferences;
private CheckBox cbHideStatusBar, cbFullScreen, cbWideViewPort, cbOverView, cbTextReflow,
cbDarkTheme;
@ -28,7 +27,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -28,7 +27,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.display_settings);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mPreferences = PreferenceManager.getInstance();
// set up ActionBar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
@ -64,14 +63,12 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -64,14 +63,12 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
cbTextReflow = (CheckBox) findViewById(R.id.cbTextReflow);
cbDarkTheme = (CheckBox) findViewById(R.id.cbDarkTheme);
cbHideStatusBar.setChecked(mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR,
false));
cbFullScreen.setChecked(mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false));
cbWideViewPort.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT,
true));
cbOverView.setChecked(mPreferences.getBoolean(PreferenceConstants.OVERVIEW_MODE, true));
cbTextReflow.setChecked(mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, false));
cbDarkTheme.setChecked(mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false));
cbHideStatusBar.setChecked(mPreferences.getHideStatusBarEnabled());
cbFullScreen.setChecked(mPreferences.getFullScreenEnabled());
cbWideViewPort.setChecked(mPreferences.getUseWideViewportEnabled());
cbOverView.setChecked(mPreferences.getOverviewModeEnabled());
cbTextReflow.setChecked(mPreferences.getTextReflowEnabled());
cbDarkTheme.setChecked(mPreferences.getUseDarkTheme());
rHideStatusBar(rHideStatusBar);
rFullScreen(rFullScreen);
@ -93,8 +90,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -93,8 +90,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPreferences.edit().putBoolean(PreferenceConstants.HIDE_STATUS_BAR, isChecked)
.apply();
mPreferences.setHideStatusBarEnabled(isChecked);
}
});
@ -105,7 +101,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -105,7 +101,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPreferences.edit().putBoolean(PreferenceConstants.FULL_SCREEN, isChecked).apply();
mPreferences.setFullScreenEnabled(isChecked);
}
});
@ -116,7 +112,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -116,7 +112,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPreferences.edit().putBoolean(PreferenceConstants.DARK_THEME, isChecked).apply();
mPreferences.setUseDarkTheme(isChecked);
restart();
}
@ -128,8 +124,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -128,8 +124,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPreferences.edit().putBoolean(PreferenceConstants.USE_WIDE_VIEWPORT, isChecked)
.apply();
mPreferences.setUseWideViewportEnabled(isChecked);
}
});
@ -140,8 +135,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -140,8 +135,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPreferences.edit().putBoolean(PreferenceConstants.OVERVIEW_MODE, isChecked)
.apply();
mPreferences.setOverviewModeEnabled(isChecked);
}
});
@ -152,7 +146,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -152,7 +146,7 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPreferences.edit().putBoolean(PreferenceConstants.TEXT_REFLOW, isChecked).apply();
mPreferences.setTextReflowEnabled(isChecked);
}
});
}
@ -234,15 +228,14 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity { @@ -234,15 +228,14 @@ public class DisplaySettingsActivity extends ThemableSettingsActivity {
AlertDialog.Builder picker = new AlertDialog.Builder(DisplaySettingsActivity.this);
picker.setTitle(getResources().getString(R.string.title_text_size));
int n = mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3);
int n = mPreferences.getTextSize();
picker.setSingleChoiceItems(R.array.text_size, n - 1,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mPreferences.edit()
.putInt(PreferenceConstants.TEXT_SIZE, which + 1).apply();
mPreferences.setTextSize(which + 1);
}
});

5
src/acr/browser/lightning/DownloadHandler.java

@ -27,7 +27,6 @@ public class DownloadHandler { @@ -27,7 +27,6 @@ public class DownloadHandler {
private static final String LOGTAG = "DLHandler";
private static Activity mActivity;
/**
* Notify the host application a download should be done, or that the data
@ -48,7 +47,6 @@ public class DownloadHandler { @@ -48,7 +47,6 @@ public class DownloadHandler {
*/
public static void onDownloadStart(Activity activity, String url, String userAgent,
String contentDisposition, String mimetype, boolean privateBrowsing) {
mActivity = activity;
// if we're dealing wih A/V content that's not explicitly marked
// for download, check if it's streamable.
if (contentDisposition == null
@ -183,8 +181,7 @@ public class DownloadHandler { @@ -183,8 +181,7 @@ public class DownloadHandler {
// or, should it be set to one of several Environment.DIRECTORY* dirs
// depending on mimetype?
String location = mActivity.getSharedPreferences(PreferenceConstants.PREFERENCES, 0)
.getString(PreferenceConstants.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS);
String location = PreferenceManager.getInstance().getDownloadDirectory();
request.setDestinationInExternalPublicDir(location, filename);
// let this downloaded file be scanned by MediaScanner - so that it can
// show up in Gallery app, for example.

78
src/acr/browser/lightning/GeneralSettingsActivity.java

@ -6,7 +6,6 @@ package acr.browser.lightning; @@ -6,7 +6,6 @@ package acr.browser.lightning;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Environment;
@ -28,8 +27,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -28,8 +27,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
// mPreferences variables
private static final int API = android.os.Build.VERSION.SDK_INT;
private SharedPreferences mPreferences;
private SharedPreferences.Editor mEditPrefs;
private PreferenceManager mPreferences;
private int mAgentChoice;
private String mHomepage;
private TextView mAgentTextView;
@ -51,10 +49,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -51,10 +49,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// TODO WARNING: SharedPreferences.edit() without a corresponding
// commit() or apply() call
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mEditPrefs = mPreferences.edit();
mPreferences = PreferenceManager.getInstance();
mActivity = this;
initialize();
@ -70,7 +65,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -70,7 +65,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
mSearchText = (TextView) findViewById(R.id.searchText);
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
switch (mPreferences.getSearchChoice()) {
case 0:
mSearchText.setText(getResources().getString(R.string.custom_url));
break;
@ -108,10 +103,9 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -108,10 +103,9 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
mAgentTextView = (TextView) findViewById(R.id.agentText);
mHomepageText = (TextView) findViewById(R.id.homepageText);
mDownloadTextView = (TextView) findViewById(R.id.downloadText);
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS);
mAgentChoice = mPreferences.getUserAgentChoice();
mHomepage = mPreferences.getHomepage();
mDownloadLocation = mPreferences.getDownloadDirectory();
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + mDownloadLocation);
@ -144,8 +138,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -144,8 +138,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
cbSearchSuggestions = (CheckBox) findViewById(R.id.cbGoogleSuggestions);
cbSearchSuggestions.setChecked(mPreferences.getBoolean(
PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true));
cbSearchSuggestions.setChecked(mPreferences.getGoogleSearchSuggestionsEnabled());
RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent);
RelativeLayout download = (RelativeLayout) findViewById(R.id.layoutDownload);
@ -173,14 +166,13 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -173,14 +166,13 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)",
"Yandex (Russian)" };
int n = mPreferences.getInt(PreferenceConstants.SEARCH, 1);
int n = mPreferences.getSearchChoice();
picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mEditPrefs.putInt(PreferenceConstants.SEARCH, which);
mEditPrefs.apply();
mPreferences.setSearchChoice(which);
switch (which) {
case 0:
searchUrlPicker();
@ -237,8 +229,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -237,8 +229,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
urlPicker.setTitle(getResources().getString(R.string.custom_url));
final EditText getSearchUrl = new EditText(this);
String mSearchUrl = mPreferences.getString(PreferenceConstants.SEARCH_URL,
Constants.GOOGLE_SEARCH);
String mSearchUrl = mPreferences.getSearchUrl();
getSearchUrl.setText(mSearchUrl);
urlPicker.setView(getSearchUrl);
urlPicker.setPositiveButton(getResources().getString(R.string.action_ok),
@ -247,8 +238,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -247,8 +238,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = getSearchUrl.getText().toString();
mEditPrefs.putString(PreferenceConstants.SEARCH_URL, text);
mEditPrefs.apply();
mPreferences.setSearchUrl(text);
mSearchText.setText(getResources().getString(R.string.custom_url) + ": "
+ text);
}
@ -263,14 +253,13 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -263,14 +253,13 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
public void onClick(View v) {
AlertDialog.Builder agentPicker = new AlertDialog.Builder(mActivity);
agentPicker.setTitle(getResources().getString(R.string.title_user_agent));
mAgentChoice = mPreferences.getInt(PreferenceConstants.USER_AGENT, 1);
mAgentChoice = mPreferences.getUserAgentChoice();
agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mEditPrefs.putInt(PreferenceConstants.USER_AGENT, which + 1);
mEditPrefs.apply();
mPreferences.setUserAgentChoice(which + 1);
switch (which + 1) {
case 1:
mAgentTextView.setText(getResources().getString(
@ -329,8 +318,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -329,8 +318,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = getAgent.getText().toString();
mEditPrefs.putString(PreferenceConstants.USER_AGENT_STRING, text);
mEditPrefs.apply();
mPreferences.setUserAgentString(text);
mAgentTextView.setText(getResources().getString(R.string.agent_custom));
}
});
@ -345,8 +333,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -345,8 +333,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.title_download_location));
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS);
mDownloadLocation = mPreferences.getDownloadDirectory();
int n;
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) {
n = 1;
@ -362,10 +349,8 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -362,10 +349,8 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
switch (which + 1) {
case 1:
mEditPrefs.putString(
PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS);
mEditPrefs.apply();
mPreferences
.setDownloadDirectory(Environment.DIRECTORY_DOWNLOADS);
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/'
+ Environment.DIRECTORY_DOWNLOADS);
break;
@ -394,7 +379,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -394,7 +379,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity);
homePicker.setTitle(getResources().getString(R.string.title_custom_homepage));
final EditText getHome = new EditText(this);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
mHomepage = mPreferences.getHomepage();
if (!mHomepage.startsWith("about:")) {
getHome.setText(mHomepage);
} else {
@ -407,8 +392,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -407,8 +392,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = getHome.getText().toString();
mEditPrefs.putString(PreferenceConstants.HOMEPAGE, text);
mEditPrefs.apply();
mPreferences.setHomepage(text);
mHomepageText.setText(text);
}
});
@ -422,8 +406,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -422,8 +406,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
downLocationPicker.setTitle(getResources().getString(R.string.title_download_location));
final EditText getDownload = new EditText(this);
getDownload.setBackgroundResource(0);
mDownloadLocation = mPreferences.getString(PreferenceConstants.DOWNLOAD_DIRECTORY,
Environment.DIRECTORY_DOWNLOADS);
mDownloadLocation = mPreferences.getDownloadDirectory();
int padding = Utils.convertDpToPixels(10);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
@ -453,8 +436,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -453,8 +436,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = getDownload.getText().toString();
mEditPrefs.putString(PreferenceConstants.DOWNLOAD_DIRECTORY, text);
mEditPrefs.apply();
mPreferences.setDownloadDirectory(text);
mDownloadTextView.setText(Constants.EXTERNAL_STORAGE + '/' + text);
}
});
@ -468,8 +450,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -468,8 +450,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.home));
mHomepage = mPreferences
.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
mHomepage = mPreferences.getHomepage();
int n;
if (mHomepage.contains("about:home")) {
n = 1;
@ -489,23 +470,17 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -489,23 +470,17 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
switch (which + 1) {
case 1:
mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
"about:home");
mEditPrefs.apply();
mPreferences.setHomepage("about:home");
mHomepageText.setText(getResources().getString(
R.string.action_homepage));
break;
case 2:
mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
"about:blank");
mEditPrefs.apply();
mPreferences.setHomepage("about:blank");
mHomepageText.setText(getResources().getString(
R.string.action_blank));
break;
case 3:
mEditPrefs.putString(PreferenceConstants.HOMEPAGE,
"about:bookmarks");
mEditPrefs.apply();
mPreferences.setHomepage("about:bookmarks");
mHomepageText.setText(getResources().getString(
R.string.action_bookmarks));
@ -536,8 +511,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity { @@ -536,8 +511,7 @@ public class GeneralSettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, isChecked);
mEditPrefs.apply();
mPreferences.setGoogleSearchSuggestionsEnabled(isChecked);
}
});

11
src/acr/browser/lightning/IncognitoActivity.java

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
package acr.browser.lightning;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
@ -11,27 +10,21 @@ import android.webkit.CookieSyncManager; @@ -11,27 +10,21 @@ import android.webkit.CookieSyncManager;
@SuppressWarnings("deprecation")
public class IncognitoActivity extends BrowserActivity {
SharedPreferences mPreferences;
CookieManager mCookieManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
}
@Override
public void updateCookiePreference() {
if (mPreferences == null) {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
}
mCookieManager = CookieManager.getInstance();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
CookieSyncManager.createInstance(this);
}
mCookieManager.setAcceptCookie(mPreferences.getBoolean(
PreferenceConstants.INCOGNITO_COOKIES, false));
mCookieManager
.setAcceptCookie(PreferenceManager.getInstance().getIncognitoCookiesEnabled());
super.updateCookiePreference();
}

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

@ -19,7 +19,6 @@ import android.content.ActivityNotFoundException; @@ -19,7 +19,6 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.ColorMatrix;
@ -66,7 +65,7 @@ public class LightningView { @@ -66,7 +65,7 @@ public class LightningView {
private static String mHomepage;
private static String mDefaultUserAgent;
private static Bitmap mWebpageBitmap;
private static SharedPreferences mPreferences;
private static PreferenceManager mPreferences;
private AdBlock mAdBlock;
private boolean isForegroundTab;
private IntentUtils mIntentUtils;
@ -149,14 +148,12 @@ public class LightningView { @@ -149,14 +148,12 @@ public class LightningView {
public String getHomepage() {
String home;
home = HomepageVariables.HEAD;
switch (mPreferences.getInt(PreferenceConstants.SEARCH, 1)) {
switch (mPreferences.getSearchChoice()) {
case 0:
// CUSTOM SEARCH
home = home + "file:///android_asset/lightning.png";
home = home + HomepageVariables.MIDDLE;
home = home
+ mPreferences.getString(PreferenceConstants.SEARCH_URL,
Constants.GOOGLE_SEARCH);
home = home + mPreferences.getSearchUrl();
break;
case 1:
// GOOGLE_SEARCH;
@ -251,8 +248,8 @@ public class LightningView { @@ -251,8 +248,8 @@ public class LightningView {
@SuppressWarnings("deprecation")
@SuppressLint({ "NewApi", "SetJavaScriptEnabled" })
public synchronized void initializePreferences(Context context) {
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mHomepage = mPreferences.getString(PreferenceConstants.HOMEPAGE, Constants.HOMEPAGE);
mPreferences = PreferenceManager.getInstance();
mHomepage = mPreferences.getHomepage();
mAdBlock.updatePreference();
if (mSettings == null && mWebView != null) {
mSettings = mWebView.getSettings();
@ -260,16 +257,15 @@ public class LightningView { @@ -260,16 +257,15 @@ public class LightningView {
return;
}
setColorMode(mPreferences.getInt(PreferenceConstants.RENDERING_MODE, 0));
setColorMode(mPreferences.getRenderingMode());
if (!mBrowserController.isIncognito()) {
mSettings.setGeolocationEnabled(mPreferences.getBoolean(PreferenceConstants.LOCATION,
false));
mSettings.setGeolocationEnabled(mPreferences.getLocationEnabled());
} else {
mSettings.setGeolocationEnabled(false);
}
if (API < 19) {
switch (mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0)) {
switch (mPreferences.getFlashSupport()) {
case 0:
mSettings.setPluginState(PluginState.OFF);
break;
@ -284,7 +280,7 @@ public class LightningView { @@ -284,7 +280,7 @@ public class LightningView {
}
}
switch (mPreferences.getInt(PreferenceConstants.USER_AGENT, 1)) {
switch (mPreferences.getUserAgentChoice()) {
case 1:
if (API > 16) {
mSettings.setUserAgentString(WebSettings.getDefaultUserAgent(context));
@ -299,13 +295,11 @@ public class LightningView { @@ -299,13 +295,11 @@ public class LightningView {
mSettings.setUserAgentString(Constants.MOBILE_USER_AGENT);
break;
case 4:
mSettings.setUserAgentString(mPreferences.getString(
PreferenceConstants.USER_AGENT_STRING, mDefaultUserAgent));
mSettings.setUserAgentString(mPreferences.getUserAgentString(mDefaultUserAgent));
break;
}
if (mPreferences.getBoolean(PreferenceConstants.SAVE_PASSWORDS, false)
&& !mBrowserController.isIncognito()) {
if (mPreferences.getSavePasswordsEnabled() && !mBrowserController.isIncognito()) {
if (API < 18) {
mSettings.setSavePassword(true);
}
@ -317,12 +311,12 @@ public class LightningView { @@ -317,12 +311,12 @@ public class LightningView {
mSettings.setSaveFormData(false);
}
if (mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, true)) {
if (mPreferences.getJavaScriptEnabled()) {
mSettings.setJavaScriptEnabled(true);
mSettings.setJavaScriptCanOpenWindowsAutomatically(true);
}
if (mPreferences.getBoolean(PreferenceConstants.TEXT_REFLOW, false)) {
if (mPreferences.getTextReflowEnabled()) {
mTextReflow = true;
mSettings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
if (API >= android.os.Build.VERSION_CODES.KITKAT) {
@ -339,15 +333,11 @@ public class LightningView { @@ -339,15 +333,11 @@ public class LightningView {
mSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
}
mSettings.setBlockNetworkImage(mPreferences.getBoolean(PreferenceConstants.BLOCK_IMAGES,
false));
mSettings.setSupportMultipleWindows(mPreferences.getBoolean(PreferenceConstants.POPUPS,
true));
mSettings.setUseWideViewPort(mPreferences.getBoolean(PreferenceConstants.USE_WIDE_VIEWPORT,
true));
mSettings.setLoadWithOverviewMode(mPreferences.getBoolean(
PreferenceConstants.OVERVIEW_MODE, true));
switch (mPreferences.getInt(PreferenceConstants.TEXT_SIZE, 3)) {
mSettings.setBlockNetworkImage(mPreferences.getBlockImagesEnabled());
mSettings.setSupportMultipleWindows(mPreferences.getPopupsEnabled());
mSettings.setUseWideViewPort(mPreferences.getUseWideViewportEnabled());
mSettings.setLoadWithOverviewMode(mPreferences.getOverviewModeEnabled());
switch (mPreferences.getTextSize()) {
case 1:
mSettings.setTextZoom(200);
break;
@ -366,7 +356,7 @@ public class LightningView { @@ -366,7 +356,7 @@ public class LightningView {
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().setAcceptThirdPartyCookies(mWebView,
!mPreferences.getBoolean(PreferenceConstants.BLOCK_THIRD_PARTY, false));
!mPreferences.getBlockThirdPartyCookiesEnabled());
}
}
@ -759,7 +749,6 @@ public class LightningView { @@ -759,7 +749,6 @@ public class LightningView {
public void run() {
mZoomScale = newScale;
view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, null);
Log.d("YOLO", "SCALE CHANGING " + newScale);
mIsRunning = false;
}

8
src/acr/browser/lightning/MainActivity.java

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
package acr.browser.lightning;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
@ -11,25 +10,20 @@ import android.webkit.CookieSyncManager; @@ -11,25 +10,20 @@ import android.webkit.CookieSyncManager;
@SuppressWarnings("deprecation")
public class MainActivity extends BrowserActivity {
SharedPreferences mPreferences;
CookieManager mCookieManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
}
@Override
public void updateCookiePreference() {
if (mPreferences == null) {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
}
mCookieManager = CookieManager.getInstance();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
CookieSyncManager.createInstance(this);
}
mCookieManager.setAcceptCookie(mPreferences.getBoolean(PreferenceConstants.COOKIES, true));
mCookieManager.setAcceptCookie(PreferenceManager.getInstance().getCookiesEnabled());
super.updateCookiePreference();
}

56
src/acr/browser/lightning/PreferenceConstants.java

@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
/*
* Copyright 2014 A.C.R. Development
*/
package acr.browser.lightning;
public final class PreferenceConstants {
private PreferenceConstants() {
}
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
public static final String BLOCK_ADS = "AdBlock";
public static final String BLOCK_IMAGES = "blockimages";
public static final String CLEAR_CACHE_EXIT = "cache";
public static final String COOKIES = "cookies";
public static final String DOWNLOAD_DIRECTORY = "download";
public static final String FULL_SCREEN = "fullscreen";
public static final String HIDE_STATUS_BAR = "hidestatus";
public static final String HOMEPAGE = "home";
public static final String INCOGNITO_COOKIES = "incognitocookies";
public static final String JAVASCRIPT = "java";
public static final String LOCATION = "location";
public static final String OVERVIEW_MODE = "overviewmode";
public static final String POPUPS = "newwindows";
public static final String PREFERENCES = "settings";
public static final String RESTORE_LOST_TABS = "restoreclosed";
public static final String SAVE_PASSWORDS = "passwords";
public static final String SEARCH = "search";
public static final String SEARCH_URL = "searchurl";
public static final String SYSTEM_BROWSER_PRESENT = "SystemBrowser";
public static final String TEXT_REFLOW = "textreflow";
public static final String TEXT_SIZE = "textsize";
public static final String URL_MEMORY = "memory";
public static final String USE_WIDE_VIEWPORT = "wideviewport";
public static final String USER_AGENT = "agentchoose";
public static final String USER_AGENT_STRING = "userAgentString";
public static final String GOOGLE_SEARCH_SUGGESTIONS = "GoogleSearchSuggestions";
public static final String CLEAR_HISTORY_EXIT = "clearHistoryExit";
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
public static final String SAVE_URL = "saveUrl";
public static final String RENDERING_MODE = "renderMode";
public static final String SYNC_HISTORY = "syncHistory";
public static final String BLOCK_THIRD_PARTY = "thirdParty";
public static final String ENABLE_COLOR_MODE = "colorMode";
public static final String URL_BOX_CONTENTS = "urlContent";
public static final String INVERT_COLORS = "invertColors";
public static final String READING_TEXT_SIZE = "readingTextSize";
public static final String DARK_THEME = "darkTheme";
public static final String USE_PROXY = "useProxy";
public static final String USE_PROXY_HOST = "useProxyHost";
public static final String USE_PROXY_PORT = "useProxyPort";
public static final String INITIAL_CHECK_FOR_TOR = "checkForTor";
public static final String OLD_BOOKMARKS_IMPORTED = "oldBookmarksImported";
}

399
src/acr/browser/lightning/PreferenceManager.java

@ -0,0 +1,399 @@ @@ -0,0 +1,399 @@
package acr.browser.lightning;
import android.content.SharedPreferences;
import android.os.Environment;
public class PreferenceManager {
private static PreferenceManager mInstance;
private static SharedPreferences mPrefs;
private static final String PREFERENCES = "settings";
private PreferenceManager() {
mPrefs = BrowserApp.getAppContext().getSharedPreferences(PREFERENCES, 0);
}
public static PreferenceManager getInstance() {
if (mInstance == null) {
mInstance = new PreferenceManager();
}
return mInstance;
}
public int getFlashSupport() {
return mPrefs.getInt(Name.ADOBE_FLASH_SUPPORT, 0);
}
public void setFlashSupport(int n) {
putInt(Name.ADOBE_FLASH_SUPPORT, n);
}
public boolean getAdBlockEnabled() {
return mPrefs.getBoolean(Name.BLOCK_ADS, false);
}
public void setAdBlockEnabled(boolean enable) {
putBoolean(Name.BLOCK_ADS, enable);
}
public int getReadingTextSize() {
return mPrefs.getInt(Name.READING_TEXT_SIZE, 2);
}
public void setReadingTextSize(int size) {
putInt(Name.READING_TEXT_SIZE, 2);
}
public boolean getBlockImagesEnabled() {
return mPrefs.getBoolean(Name.BLOCK_IMAGES, false);
}
public void setBlockImagesEnabled(boolean enable) {
putBoolean(Name.BLOCK_IMAGES, enable);
}
public boolean getInvertColors() {
return mPrefs.getBoolean(Name.INVERT_COLORS, false);
}
public void setInvertColors(boolean enable) {
putBoolean(Name.INVERT_COLORS, enable);
}
public boolean getClearCacheExit() {
return mPrefs.getBoolean(Name.CLEAR_CACHE_EXIT, false);
}
public void setClearCacheExit(boolean enable) {
putBoolean(Name.CLEAR_CACHE_EXIT, enable);
}
public boolean getCookiesEnabled() {
return mPrefs.getBoolean(Name.COOKIES, true);
}
public void setCookiesEnabled(boolean enable) {
putBoolean(Name.COOKIES, enable);
}
public String getDownloadDirectory() {
return mPrefs.getString(Name.DOWNLOAD_DIRECTORY, Environment.DIRECTORY_DOWNLOADS);
}
public void setDownloadDirectory(String directory) {
putString(Name.DOWNLOAD_DIRECTORY, directory);
}
public boolean getFullScreenEnabled() {
return mPrefs.getBoolean(Name.FULL_SCREEN, false);
}
public void setFullScreenEnabled(boolean enable) {
putBoolean(Name.FULL_SCREEN, enable);
}
public boolean getHideStatusBarEnabled() {
return mPrefs.getBoolean(Name.HIDE_STATUS_BAR, false);
}
public void setHideStatusBarEnabled(boolean enable) {
putBoolean(Name.HIDE_STATUS_BAR, enable);
}
public String getHomepage() {
return mPrefs.getString(Name.HOMEPAGE, Constants.HOMEPAGE);
}
public void setHomepage(String homepage) {
putString(Name.HOMEPAGE, homepage);
}
public boolean getUseDarkTheme() {
return mPrefs.getBoolean(Name.DARK_THEME, false);
}
public void setUseDarkTheme(boolean use) {
putBoolean(Name.DARK_THEME, use);
}
public boolean getIncognitoCookiesEnabled() {
return mPrefs.getBoolean(Name.INCOGNITO_COOKIES, false);
}
public void setIncognitoCookiesEnabled(boolean enable) {
putBoolean(Name.INCOGNITO_COOKIES, enable);
}
public boolean getJavaScriptEnabled() {
return mPrefs.getBoolean(Name.JAVASCRIPT, true);
}
public void setJavaScriptEnabled(boolean enable) {
putBoolean(Name.JAVASCRIPT, enable);
}
public boolean getLocationEnabled() {
return mPrefs.getBoolean(Name.LOCATION, false);
}
public void setLocationEnabled(boolean enable) {
putBoolean(Name.LOCATION, enable);
}
public boolean getOverviewModeEnabled() {
return mPrefs.getBoolean(Name.OVERVIEW_MODE, true);
}
public void setOverviewModeEnabled(boolean enable) {
putBoolean(Name.OVERVIEW_MODE, enable);
}
public boolean getPopupsEnabled() {
return mPrefs.getBoolean(Name.POPUPS, true);
}
public void setPopupsEnabled(boolean enable) {
putBoolean(Name.POPUPS, enable);
}
public boolean getRestoreLostTabsEnabled() {
return mPrefs.getBoolean(Name.RESTORE_LOST_TABS, true);
}
public void setRestoreLostTabsEnabled(boolean enable) {
putBoolean(Name.RESTORE_LOST_TABS, enable);
}
public boolean getSavePasswordsEnabled() {
return mPrefs.getBoolean(Name.SAVE_PASSWORDS, true);
}
public void setSavePasswordsEnabled(boolean enable) {
putBoolean(Name.SAVE_PASSWORDS, enable);
}
public int getSearchChoice() {
return mPrefs.getInt(Name.SEARCH, 1);
}
public void setSearchChoice(int choice) {
putInt(Name.SEARCH, choice);
}
public String getSearchUrl() {
return mPrefs.getString(Name.SEARCH_URL, Constants.GOOGLE_SEARCH);
}
public void setSearchUrl(String url) {
putString(Name.SEARCH_URL, url);
}
public boolean getSystemBrowserPresent() {
return mPrefs.getBoolean(Name.SYSTEM_BROWSER_PRESENT, false);
}
public void setSystemBrowserPresent(boolean available) {
putBoolean(Name.SYSTEM_BROWSER_PRESENT, available);
}
public boolean getTextReflowEnabled() {
return mPrefs.getBoolean(Name.TEXT_REFLOW, false);
}
public void setTextReflowEnabled(boolean enable) {
putBoolean(Name.TEXT_REFLOW, enable);
}
public int getTextSize() {
return mPrefs.getInt(Name.TEXT_SIZE, 3);
}
public void setTextSize(int size) {
putInt(Name.TEXT_SIZE, size);
}
public String getMemoryUrl() {
return mPrefs.getString(Name.URL_MEMORY, "");
}
public void setMemoryUrl(String url) {
putString(Name.URL_MEMORY, url);
}
public boolean getUseWideViewportEnabled() {
return mPrefs.getBoolean(Name.USE_WIDE_VIEWPORT, true);
}
public void setUseWideViewportEnabled(boolean enable) {
putBoolean(Name.USE_WIDE_VIEWPORT, enable);
}
public int getUserAgentChoice() {
return mPrefs.getInt(Name.USER_AGENT, 1);
}
public void setUserAgentChoice(int choice) {
putInt(Name.USER_AGENT, choice);
}
public String getUserAgentString(String def) {
return mPrefs.getString(Name.USER_AGENT_STRING, def);
}
public void setUserAgentString(String agent) {
putString(Name.USER_AGENT_STRING, agent);
}
public boolean getGoogleSearchSuggestionsEnabled() {
return mPrefs.getBoolean(Name.GOOGLE_SEARCH_SUGGESTIONS, true);
}
public void setGoogleSearchSuggestionsEnabled(boolean enabled) {
putBoolean(Name.GOOGLE_SEARCH_SUGGESTIONS, enabled);
}
public boolean getClearHistoryExitEnabled() {
return mPrefs.getBoolean(Name.CLEAR_HISTORY_EXIT, false);
}
public void setClearHistoryExitEnabled(boolean enable) {
putBoolean(Name.CLEAR_HISTORY_EXIT, enable);
}
public boolean getClearCookiesExitEnabled() {
return mPrefs.getBoolean(Name.CLEAR_COOKIES_EXIT, false);
}
public void setClearCookiesExitEnabled(boolean enable) {
putBoolean(Name.CLEAR_COOKIES_EXIT, enable);
}
public String getSavedUrl() {
return mPrefs.getString(Name.SAVE_URL, null);
}
public void setSavedUrl(String url) {
putString(Name.SAVE_URL, url);
}
public int getRenderingMode() {
return mPrefs.getInt(Name.RENDERING_MODE, 0);
}
public void setRenderingMode(int mode) {
putInt(Name.RENDERING_MODE, mode);
}
public boolean getSyncHistoryEnabled() {
return mPrefs.getBoolean(Name.SYNC_HISTORY, true);
}
public void setSyncHistoryEnabled(boolean enable) {
putBoolean(Name.SYNC_HISTORY, enable);
}
public boolean getBlockThirdPartyCookiesEnabled() {
return mPrefs.getBoolean(Name.BLOCK_THIRD_PARTY, false);
}
public void setBlockThirdPartyCookiesEnabled(boolean enable) {
putBoolean(Name.BLOCK_THIRD_PARTY, enable);
}
public boolean getColorModeEnabled() {
return mPrefs.getBoolean(Name.ENABLE_COLOR_MODE, true);
}
public void setColorModeEnabled(boolean enable) {
mPrefs.edit().putBoolean(Name.ENABLE_COLOR_MODE, enable).apply();
}
public int getUrlBoxContentChoice() {
return mPrefs.getInt(Name.URL_BOX_CONTENTS, 0);
}
public void setUrlBoxContentChoice(int choice) {
mPrefs.edit().putInt(Name.URL_BOX_CONTENTS, choice).apply();
}
public boolean getUseProxy() {
return mPrefs.getBoolean(Name.USE_PROXY, false);
}
public void setUseProxy(boolean enable) {
mPrefs.edit().putBoolean(Name.USE_PROXY, enable).apply();
}
public String getProxyHost() {
return mPrefs.getString(Name.USE_PROXY_HOST, "localhost");
}
public int getProxyPort() {
return mPrefs.getInt(Name.USE_PROXY_PORT, 8118);
}
public boolean getCheckedForTor() {
return mPrefs.getBoolean(Name.INITIAL_CHECK_FOR_TOR, false);
}
public void setCheckedForTor(boolean check) {
putBoolean(Name.INITIAL_CHECK_FOR_TOR, check);
}
private void putInt(String name, int value) {
mPrefs.edit().putInt(name, value).apply();
}
private void putBoolean(String name, boolean value) {
mPrefs.edit().putBoolean(name, value).apply();
}
private void putString(String name, String value) {
mPrefs.edit().putString(name, value).apply();
}
private class Name {
public static final String ADOBE_FLASH_SUPPORT = "enableflash";
public static final String BLOCK_ADS = "AdBlock";
public static final String BLOCK_IMAGES = "blockimages";
public static final String CLEAR_CACHE_EXIT = "cache";
public static final String COOKIES = "cookies";
public static final String DOWNLOAD_DIRECTORY = "download";
public static final String FULL_SCREEN = "fullscreen";
public static final String HIDE_STATUS_BAR = "hidestatus";
public static final String HOMEPAGE = "home";
public static final String INCOGNITO_COOKIES = "incognitocookies";
public static final String JAVASCRIPT = "java";
public static final String LOCATION = "location";
public static final String OVERVIEW_MODE = "overviewmode";
public static final String POPUPS = "newwindows";
public static final String RESTORE_LOST_TABS = "restoreclosed";
public static final String SAVE_PASSWORDS = "passwords";
public static final String SEARCH = "search";
public static final String SEARCH_URL = "searchurl";
public static final String SYSTEM_BROWSER_PRESENT = "SystemBrowser";
public static final String TEXT_REFLOW = "textreflow";
public static final String TEXT_SIZE = "textsize";
public static final String URL_MEMORY = "memory";
public static final String USE_WIDE_VIEWPORT = "wideviewport";
public static final String USER_AGENT = "agentchoose";
public static final String USER_AGENT_STRING = "userAgentString";
public static final String GOOGLE_SEARCH_SUGGESTIONS = "GoogleSearchSuggestions";
public static final String CLEAR_HISTORY_EXIT = "clearHistoryExit";
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
public static final String SAVE_URL = "saveUrl";
public static final String RENDERING_MODE = "renderMode";
public static final String SYNC_HISTORY = "syncHistory";
public static final String BLOCK_THIRD_PARTY = "thirdParty";
public static final String ENABLE_COLOR_MODE = "colorMode";
public static final String URL_BOX_CONTENTS = "urlContent";
public static final String INVERT_COLORS = "invertColors";
public static final String READING_TEXT_SIZE = "readingTextSize";
public static final String DARK_THEME = "darkTheme";
public static final String USE_PROXY = "useProxy";
public static final String USE_PROXY_HOST = "useProxyHost";
public static final String USE_PROXY_PORT = "useProxyPort";
public static final String INITIAL_CHECK_FOR_TOR = "checkForTor";
}
}

49
src/acr/browser/lightning/PrivacySettingsActivity.java

@ -6,7 +6,6 @@ package acr.browser.lightning; @@ -6,7 +6,6 @@ package acr.browser.lightning;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@ -27,8 +26,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -27,8 +26,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
// mPreferences variables
private static final int API = android.os.Build.VERSION.SDK_INT;
private SharedPreferences mPreferences;
private SharedPreferences.Editor mEditPrefs;
private PreferenceManager mPreferences;
private CheckBox cbLocation, cbSavePasswords, cbClearCacheExit, cbClearHistoryExit,
cbClearCookiesExit, cbThirdParty;
private Context mContext;
@ -48,10 +46,9 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -48,10 +46,9 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
// TODO WARNING: SharedPreferences.edit() without a corresponding
// commit() or apply() call
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mEditPrefs = mPreferences.edit();
mPreferences = PreferenceManager.getInstance();
mSystemBrowser = mPreferences.getBoolean(PreferenceConstants.SYSTEM_BROWSER_PRESENT, false);
mSystemBrowser = mPreferences.getSystemBrowserPresent();
mContext = this;
initialize();
}
@ -83,17 +80,12 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -83,17 +80,12 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
cbClearCookiesExit = (CheckBox) findViewById(R.id.cbClearCookiesExit);
cbThirdParty = (CheckBox) findViewById(R.id.cbThirdParty);
cbLocation.setChecked(mPreferences.getBoolean(PreferenceConstants.LOCATION, false));
cbSavePasswords.setChecked(mPreferences
.getBoolean(PreferenceConstants.SAVE_PASSWORDS, true));
cbClearCacheExit.setChecked(mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT,
false));
cbClearHistoryExit.setChecked(mPreferences.getBoolean(
PreferenceConstants.CLEAR_HISTORY_EXIT, false));
cbClearCookiesExit.setChecked(mPreferences.getBoolean(
PreferenceConstants.CLEAR_COOKIES_EXIT, false));
cbThirdParty.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_THIRD_PARTY,
false));
cbLocation.setChecked(mPreferences.getLocationEnabled());
cbSavePasswords.setChecked(mPreferences.getSavePasswordsEnabled());
cbClearCacheExit.setChecked(mPreferences.getClearCacheExit());
cbClearHistoryExit.setChecked(mPreferences.getClearHistoryExitEnabled());
cbClearCookiesExit.setChecked(mPreferences.getClearCookiesExitEnabled());
cbThirdParty.setChecked(mPreferences.getBlockThirdPartyCookiesEnabled());
cbThirdParty.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
@ -129,7 +121,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -129,7 +121,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.SYNC_HISTORY, isChecked).apply();
mPreferences.setSyncHistoryEnabled(isChecked);
}
});
@ -140,8 +132,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -140,8 +132,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
syncHistory.setText(getResources().getString(R.string.stock_browser_unavailable));
} else {
cbSyncHistory.setEnabled(true);
cbSyncHistory.setChecked(mPreferences
.getBoolean(PreferenceConstants.SYNC_HISTORY, true));
cbSyncHistory.setChecked(mPreferences.getSyncHistoryEnabled());
syncHistory.setText(getResources().getString(R.string.stock_browser_available));
}
@ -180,8 +171,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -180,8 +171,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.LOCATION, isChecked);
mEditPrefs.apply();
mPreferences.setLocationEnabled(isChecked);
}
});
@ -192,8 +182,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -192,8 +182,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.SAVE_PASSWORDS, isChecked);
mEditPrefs.apply();
mPreferences.setSavePasswordsEnabled(isChecked);
}
});
@ -204,8 +193,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -204,8 +193,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, isChecked);
mEditPrefs.apply();
mPreferences.setClearCacheExit(isChecked);
}
});
@ -216,8 +204,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -216,8 +204,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_HISTORY_EXIT, isChecked);
mEditPrefs.apply();
mPreferences.setClearHistoryExitEnabled(isChecked);
}
});
@ -228,8 +215,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -228,8 +215,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_THIRD_PARTY, isChecked);
mEditPrefs.apply();
mPreferences.setBlockThirdPartyCookiesEnabled(isChecked);
}
});
@ -240,8 +226,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { @@ -240,8 +226,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.CLEAR_COOKIES_EXIT, isChecked);
mEditPrefs.apply();
mPreferences.setClearCookiesExitEnabled(isChecked);
}
});

16
src/acr/browser/lightning/ReadingActivity.java

@ -12,7 +12,6 @@ import android.content.Context; @@ -12,7 +12,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
@ -31,7 +30,7 @@ public class ReadingActivity extends ActionBarActivity { @@ -31,7 +30,7 @@ public class ReadingActivity extends ActionBarActivity {
private TextView mBody;
private boolean mInvert;
private String mUrl = null;
private SharedPreferences mPreferences;
private PreferenceManager mPreferences;
private int mTextSize;
private static final float XXLARGE = 30.0f;
private static final float XLARGE = 26.0f;
@ -42,9 +41,8 @@ public class ReadingActivity extends ActionBarActivity { @@ -42,9 +41,8 @@ public class ReadingActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
boolean initInvert = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
mInvert = mPreferences.getBoolean(PreferenceConstants.INVERT_COLORS, initInvert);
mPreferences = PreferenceManager.getInstance();
mInvert = mPreferences.getInvertColors();
if (mInvert) {
this.setTheme(R.style.Theme_SettingsTheme_Dark);
}
@ -58,7 +56,7 @@ public class ReadingActivity extends ActionBarActivity { @@ -58,7 +56,7 @@ public class ReadingActivity extends ActionBarActivity {
mTitle = (TextView) findViewById(R.id.textViewTitle);
mBody = (TextView) findViewById(R.id.textViewBody);
mTextSize = mPreferences.getInt(PreferenceConstants.READING_TEXT_SIZE, 2);
mTextSize = mPreferences.getReadingTextSize();
mBody.setTextSize(getTextSize(mTextSize));
mTitle.setText(getString(R.string.untitled));
mBody.setText(getString(R.string.loading));
@ -198,7 +196,7 @@ public class ReadingActivity extends ActionBarActivity { @@ -198,7 +196,7 @@ public class ReadingActivity extends ActionBarActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.invert_item:
mPreferences.edit().putBoolean(PreferenceConstants.INVERT_COLORS, !mInvert).apply();
mPreferences.setInvertColors(!mInvert);
Intent read = new Intent(this, ReadingActivity.class);
read.putExtra(Constants.LOAD_READING_URL, mUrl);
startActivity(read);
@ -235,9 +233,7 @@ public class ReadingActivity extends ActionBarActivity { @@ -235,9 +233,7 @@ public class ReadingActivity extends ActionBarActivity {
public void onClick(DialogInterface arg0, int arg1) {
mTextSize = bar.getProgress();
mBody.setTextSize(getTextSize(mTextSize));
mPreferences.edit()
.putInt(PreferenceConstants.READING_TEXT_SIZE, bar.getProgress())
.apply();
mPreferences.setReadingTextSize(bar.getProgress());
}
});

7
src/acr/browser/lightning/SearchAdapter.java

@ -21,7 +21,6 @@ import org.xmlpull.v1.XmlPullParserFactory; @@ -21,7 +21,6 @@ import org.xmlpull.v1.XmlPullParserFactory;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources.Theme;
import android.graphics.Color;
import android.net.ConnectivityManager;
@ -45,7 +44,6 @@ public class SearchAdapter extends BaseAdapter implements Filterable { @@ -45,7 +44,6 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
private List<HistoryItem> mFilteredList;
private List<HistoryItem> mAllBookmarks;
private HistoryDatabase mDatabaseHandler;
private SharedPreferences mPreferences;
private Context mContext;
private boolean mUseGoogle = true;
private boolean mIsExecuting = false;
@ -68,8 +66,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { @@ -68,8 +66,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
mSuggestions = new ArrayList<HistoryItem>();
mBookmarkManager = BookmarkManager.getInstance(context.getApplicationContext());
mAllBookmarks = mBookmarkManager.getBookmarks(true);
mPreferences = context.getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
mUseGoogle = PreferenceManager.getInstance().getGoogleSearchSuggestionsEnabled();
mContext = context;
mSearchSubtitle = mContext.getString(R.string.suggestion);
mDarkTheme = dark || incognito;
@ -109,7 +106,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { @@ -109,7 +106,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
}
public void refreshPreferences() {
mUseGoogle = mPreferences.getBoolean(PreferenceConstants.GOOGLE_SEARCH_SUGGESTIONS, true);
mUseGoogle = PreferenceManager.getInstance().getGoogleSearchSuggestionsEnabled();
if (!mUseGoogle && mSuggestions != null) {
mSuggestions.clear();
}

117
src/acr/browser/lightning/SettingsActivity.java

@ -10,7 +10,6 @@ import android.content.Context; @@ -10,7 +10,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
@ -29,8 +28,7 @@ import info.guardianproject.onionkit.ui.OrbotHelper; @@ -29,8 +28,7 @@ import info.guardianproject.onionkit.ui.OrbotHelper;
public class SettingsActivity extends ThemableSettingsActivity {
private static int API = android.os.Build.VERSION.SDK_INT;
private SharedPreferences.Editor mEditPrefs;
private SharedPreferences mPreferences;
private PreferenceManager mPreferences;
private Context mContext;
private Activity mActivity;
@ -58,8 +56,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -58,8 +56,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// mPreferences storage
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mEditPrefs = mPreferences.edit();
mPreferences = PreferenceManager.getInstance();
// initialize UI
RelativeLayout layoutFlash = (RelativeLayout) findViewById(R.id.layoutFlash);
@ -80,12 +77,11 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -80,12 +77,11 @@ public class SettingsActivity extends ThemableSettingsActivity {
});
if (API >= 19) {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
mEditPrefs.apply();
mPreferences.setFlashSupport(0);
}
int flashNum = mPreferences.getInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
boolean imagesBool = mPreferences.getBoolean(PreferenceConstants.BLOCK_IMAGES, false);
boolean enableJSBool = mPreferences.getBoolean(PreferenceConstants.JAVASCRIPT, true);
int flashNum = mPreferences.getFlashSupport();
boolean imagesBool = mPreferences.getBlockImagesEnabled();
boolean enableJSBool = mPreferences.getJavaScriptEnabled();
CheckBox flash = (CheckBox) findViewById(R.id.cbFlash);
CheckBox adblock = (CheckBox) findViewById(R.id.cbAdblock);
@ -101,9 +97,9 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -101,9 +97,9 @@ public class SettingsActivity extends ThemableSettingsActivity {
} else {
flash.setChecked(false);
}
adblock.setChecked(mPreferences.getBoolean(PreferenceConstants.BLOCK_ADS, false));
orbot.setChecked(mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false));
color.setChecked(mPreferences.getBoolean(PreferenceConstants.ENABLE_COLOR_MODE, true));
adblock.setChecked(mPreferences.getAdBlockEnabled());
orbot.setChecked(mPreferences.getUseProxy());
color.setChecked(mPreferences.getColorModeEnabled());
initCheckBox(flash, adblock, images, enablejs, orbot, color);
clickListenerForCheckBoxes(layoutFlash, layoutBlockAds, layoutImages, layoutEnableJS,
@ -197,8 +193,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -197,8 +193,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
if (isChecked) {
getFlashChoice();
} else {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
mEditPrefs.apply();
mPreferences.setFlashSupport(0);
}
boolean flashInstalled = false;
@ -216,8 +211,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -216,8 +211,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
getResources().getString(R.string.title_warning), getResources()
.getString(R.string.dialog_adobe_not_installed));
buttonView.setChecked(false);
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
mEditPrefs.apply();
mPreferences.setFlashSupport(0);
} else if ((API >= 17) && isChecked) {
Utils.createInformativeDialog(SettingsActivity.this,
@ -231,8 +225,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -231,8 +225,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_ADS, isChecked);
mEditPrefs.apply();
mPreferences.setAdBlockEnabled(isChecked);
}
});
@ -240,8 +233,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -240,8 +233,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES, isChecked);
mEditPrefs.apply();
mPreferences.setBlockImagesEnabled(isChecked);
}
@ -250,9 +242,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -250,9 +242,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.JAVASCRIPT, isChecked);
mEditPrefs.apply();
mPreferences.setJavaScriptEnabled(isChecked);
}
});
@ -265,8 +255,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -265,8 +255,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.USE_PROXY, isChecked);
mEditPrefs.apply();
mPreferences.setUseProxy(isChecked);
}
@ -275,8 +264,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -275,8 +264,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.ENABLE_COLOR_MODE, isChecked);
mEditPrefs.apply();
mPreferences.setColorModeEnabled(isChecked);
}
@ -292,8 +280,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -292,8 +280,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 1);
mEditPrefs.apply();
mPreferences.setFlashSupport(1);
}
})
.setNegativeButton(getResources().getString(R.string.action_auto),
@ -301,15 +288,13 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -301,15 +288,13 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 2);
mEditPrefs.apply();
mPreferences.setFlashSupport(2);
}
}).setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
mEditPrefs.apply();
mPreferences.setFlashSupport(0);
}
});
@ -317,71 +302,12 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -317,71 +302,12 @@ public class SettingsActivity extends ThemableSettingsActivity {
alert.show();
}
public void initCheckBox(CheckBox flash, CheckBox images, CheckBox enablejs) {
flash.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int n = 0;
if (isChecked) {
n = 1;
}
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, n);
mEditPrefs.apply();
boolean flashInstalled = false;
try {
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
if (ai != null) {
flashInstalled = true;
}
} catch (NameNotFoundException e) {
flashInstalled = false;
}
if (!flashInstalled && isChecked) {
Utils.createInformativeDialog(SettingsActivity.this,
getResources().getString(R.string.title_warning), getResources()
.getString(R.string.dialog_adobe_not_installed));
buttonView.setChecked(false);
mEditPrefs.putInt(PreferenceConstants.ADOBE_FLASH_SUPPORT, 0);
mEditPrefs.apply();
} else if ((API > 17) && isChecked) {
Utils.createInformativeDialog(SettingsActivity.this,
getResources().getString(R.string.title_warning), getResources()
.getString(R.string.dialog_adobe_unsupported));
}
}
});
images.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.BLOCK_IMAGES, isChecked);
mEditPrefs.apply();
}
});
enablejs.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mEditPrefs.putBoolean(PreferenceConstants.JAVASCRIPT, isChecked);
mEditPrefs.apply();
}
});
}
public void agentPicker() {
final AlertDialog.Builder agentStringPicker = new AlertDialog.Builder(mActivity);
agentStringPicker.setTitle(getResources().getString(R.string.title_user_agent));
final EditText getAgent = new EditText(this);
getAgent.append(mPreferences.getString(PreferenceConstants.USER_AGENT_STRING, ""));
getAgent.append(mPreferences.getUserAgentString(""));
agentStringPicker.setView(getAgent);
agentStringPicker.setPositiveButton(getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() {
@ -389,8 +315,7 @@ public class SettingsActivity extends ThemableSettingsActivity { @@ -389,8 +315,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
String text = getAgent.getText().toString();
mEditPrefs.putString(PreferenceConstants.USER_AGENT_STRING, text);
mEditPrefs.apply();
mPreferences.setUserAgentString(text);
getAgent.setText(getResources().getString(R.string.agent_custom));
}
});

9
src/acr/browser/lightning/ThemableActivity.java

@ -1,19 +1,16 @@ @@ -1,19 +1,16 @@
package acr.browser.lightning;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
public abstract class ThemableActivity extends ActionBarActivity {
private SharedPreferences mPreferences;
private boolean mDark;
@Override
protected void onCreate(Bundle savedInstanceState) {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
mDark = PreferenceManager.getInstance().getUseDarkTheme();
// set the theme
if (mDark) {
@ -25,9 +22,7 @@ public abstract class ThemableActivity extends ActionBarActivity { @@ -25,9 +22,7 @@ public abstract class ThemableActivity extends ActionBarActivity {
@Override
protected void onResume() {
super.onResume();
if (mPreferences != null
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME,
false) != mDark) {
if (PreferenceManager.getInstance().getUseDarkTheme() != mDark) {
restart();
}
}

9
src/acr/browser/lightning/ThemableSettingsActivity.java

@ -1,19 +1,16 @@ @@ -1,19 +1,16 @@
package acr.browser.lightning;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
public abstract class ThemableSettingsActivity extends ActionBarActivity {
private SharedPreferences mPreferences;
private boolean mDark;
@Override
protected void onCreate(Bundle savedInstanceState) {
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
mDark = mPreferences.getBoolean(PreferenceConstants.DARK_THEME, false);
mDark = PreferenceManager.getInstance().getUseDarkTheme();
// set the theme
if (mDark) {
@ -25,9 +22,7 @@ public abstract class ThemableSettingsActivity extends ActionBarActivity { @@ -25,9 +22,7 @@ public abstract class ThemableSettingsActivity extends ActionBarActivity {
@Override
protected void onResume() {
super.onResume();
if (mPreferences != null
&& mPreferences.getBoolean(PreferenceConstants.DARK_THEME,
false) != mDark) {
if (PreferenceManager.getInstance().getUseDarkTheme() != mDark) {
restart();
}
}

Loading…
Cancel
Save