|
|
@ -28,7 +28,7 @@ import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
import acr.browser.lightning.utils.ProxyUtils; |
|
|
|
import acr.browser.lightning.utils.ProxyUtils; |
|
|
|
import acr.browser.lightning.utils.Utils; |
|
|
|
import acr.browser.lightning.utils.Utils; |
|
|
|
|
|
|
|
|
|
|
|
public class GeneralSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { |
|
|
|
public class GeneralSettingsFragment extends LightningPreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { |
|
|
|
|
|
|
|
|
|
|
|
private static final String SETTINGS_PROXY = "proxy"; |
|
|
|
private static final String SETTINGS_PROXY = "proxy"; |
|
|
|
private static final String SETTINGS_FLASH = "cb_flash"; |
|
|
|
private static final String SETTINGS_FLASH = "cb_flash"; |
|
|
@ -45,7 +45,6 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
|
|
|
|
|
|
|
|
private Activity mActivity; |
|
|
|
private Activity mActivity; |
|
|
|
private static final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
private static final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
private PreferenceManager mPreferences; |
|
|
|
|
|
|
|
private CharSequence[] mProxyChoices; |
|
|
|
private CharSequence[] mProxyChoices; |
|
|
|
private Preference proxy, useragent, downloadloc, home, searchengine; |
|
|
|
private Preference proxy, useragent, downloadloc, home, searchengine; |
|
|
|
private String mDownloadLocation; |
|
|
|
private String mDownloadLocation; |
|
|
@ -65,9 +64,6 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initPrefs() { |
|
|
|
private void initPrefs() { |
|
|
|
// mPreferences storage
|
|
|
|
|
|
|
|
mPreferences = PreferenceManager.getInstance(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proxy = findPreference(SETTINGS_PROXY); |
|
|
|
proxy = findPreference(SETTINGS_PROXY); |
|
|
|
useragent = findPreference(SETTINGS_USERAGENT); |
|
|
|
useragent = findPreference(SETTINGS_USERAGENT); |
|
|
|
downloadloc = findPreference(SETTINGS_DOWNLOAD); |
|
|
|
downloadloc = findPreference(SETTINGS_DOWNLOAD); |
|
|
@ -95,23 +91,23 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
cbgooglesuggest.setOnPreferenceChangeListener(this); |
|
|
|
cbgooglesuggest.setOnPreferenceChangeListener(this); |
|
|
|
cbDrawerTabs.setOnPreferenceChangeListener(this); |
|
|
|
cbDrawerTabs.setOnPreferenceChangeListener(this); |
|
|
|
|
|
|
|
|
|
|
|
mAgentChoice = mPreferences.getUserAgentChoice(); |
|
|
|
mAgentChoice = preferenceManager.getUserAgentChoice(); |
|
|
|
mHomepage = mPreferences.getHomepage(); |
|
|
|
mHomepage = preferenceManager.getHomepage(); |
|
|
|
mDownloadLocation = mPreferences.getDownloadDirectory(); |
|
|
|
mDownloadLocation = preferenceManager.getDownloadDirectory(); |
|
|
|
mProxyChoices = getResources().getStringArray(R.array.proxy_choices_array); |
|
|
|
mProxyChoices = getResources().getStringArray(R.array.proxy_choices_array); |
|
|
|
|
|
|
|
|
|
|
|
int choice = mPreferences.getProxyChoice(); |
|
|
|
int choice = preferenceManager.getProxyChoice(); |
|
|
|
if (choice == Constants.PROXY_MANUAL) { |
|
|
|
if (choice == Constants.PROXY_MANUAL) { |
|
|
|
proxy.setSummary(mPreferences.getProxyHost() + ':' + mPreferences.getProxyPort()); |
|
|
|
proxy.setSummary(preferenceManager.getProxyHost() + ':' + preferenceManager.getProxyPort()); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
proxy.setSummary(mProxyChoices[choice]); |
|
|
|
proxy.setSummary(mProxyChoices[choice]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (API >= 19) { |
|
|
|
if (API >= 19) { |
|
|
|
mPreferences.setFlashSupport(0); |
|
|
|
preferenceManager.setFlashSupport(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setSearchEngineSummary(mPreferences.getSearchChoice()); |
|
|
|
setSearchEngineSummary(preferenceManager.getSearchChoice()); |
|
|
|
|
|
|
|
|
|
|
|
downloadloc.setSummary(Constants.EXTERNAL_STORAGE + '/' + mDownloadLocation); |
|
|
|
downloadloc.setSummary(Constants.EXTERNAL_STORAGE + '/' + mDownloadLocation); |
|
|
|
|
|
|
|
|
|
|
@ -139,9 +135,9 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
useragent.setSummary(getResources().getString(R.string.agent_custom)); |
|
|
|
useragent.setSummary(getResources().getString(R.string.agent_custom)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int flashNum = mPreferences.getFlashSupport(); |
|
|
|
int flashNum = preferenceManager.getFlashSupport(); |
|
|
|
boolean imagesBool = mPreferences.getBlockImagesEnabled(); |
|
|
|
boolean imagesBool = preferenceManager.getBlockImagesEnabled(); |
|
|
|
boolean enableJSBool = mPreferences.getJavaScriptEnabled(); |
|
|
|
boolean enableJSBool = preferenceManager.getJavaScriptEnabled(); |
|
|
|
|
|
|
|
|
|
|
|
proxy.setEnabled(Constants.FULL_VERSION); |
|
|
|
proxy.setEnabled(Constants.FULL_VERSION); |
|
|
|
cbAds.setEnabled(Constants.FULL_VERSION); |
|
|
|
cbAds.setEnabled(Constants.FULL_VERSION); |
|
|
@ -150,17 +146,17 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
cbImages.setChecked(imagesBool); |
|
|
|
cbImages.setChecked(imagesBool); |
|
|
|
cbJsScript.setChecked(enableJSBool); |
|
|
|
cbJsScript.setChecked(enableJSBool); |
|
|
|
cbFlash.setChecked(flashNum > 0); |
|
|
|
cbFlash.setChecked(flashNum > 0); |
|
|
|
cbAds.setChecked(Constants.FULL_VERSION && mPreferences.getAdBlockEnabled()); |
|
|
|
cbAds.setChecked(Constants.FULL_VERSION && preferenceManager.getAdBlockEnabled()); |
|
|
|
cbColorMode.setChecked(mPreferences.getColorModeEnabled()); |
|
|
|
cbColorMode.setChecked(preferenceManager.getColorModeEnabled()); |
|
|
|
cbgooglesuggest.setChecked(mPreferences.getGoogleSearchSuggestionsEnabled()); |
|
|
|
cbgooglesuggest.setChecked(preferenceManager.getGoogleSearchSuggestionsEnabled()); |
|
|
|
cbDrawerTabs.setChecked(mPreferences.getShowTabsInDrawer(true)); |
|
|
|
cbDrawerTabs.setChecked(preferenceManager.getShowTabsInDrawer(true)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void searchUrlPicker() { |
|
|
|
private void searchUrlPicker() { |
|
|
|
final AlertDialog.Builder urlPicker = new AlertDialog.Builder(mActivity); |
|
|
|
final AlertDialog.Builder urlPicker = new AlertDialog.Builder(mActivity); |
|
|
|
urlPicker.setTitle(getResources().getString(R.string.custom_url)); |
|
|
|
urlPicker.setTitle(getResources().getString(R.string.custom_url)); |
|
|
|
final EditText getSearchUrl = new EditText(mActivity); |
|
|
|
final EditText getSearchUrl = new EditText(mActivity); |
|
|
|
String mSearchUrl = mPreferences.getSearchUrl(); |
|
|
|
String mSearchUrl = preferenceManager.getSearchUrl(); |
|
|
|
getSearchUrl.setText(mSearchUrl); |
|
|
|
getSearchUrl.setText(mSearchUrl); |
|
|
|
urlPicker.setView(getSearchUrl); |
|
|
|
urlPicker.setView(getSearchUrl); |
|
|
|
urlPicker.setPositiveButton(getResources().getString(R.string.action_ok), |
|
|
|
urlPicker.setPositiveButton(getResources().getString(R.string.action_ok), |
|
|
@ -168,7 +164,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
String text = getSearchUrl.getText().toString(); |
|
|
|
String text = getSearchUrl.getText().toString(); |
|
|
|
mPreferences.setSearchUrl(text); |
|
|
|
preferenceManager.setSearchUrl(text); |
|
|
|
searchengine.setSummary(getResources().getString(R.string.custom_url) + ": " |
|
|
|
searchengine.setSummary(getResources().getString(R.string.custom_url) + ": " |
|
|
|
+ text); |
|
|
|
+ text); |
|
|
|
} |
|
|
|
} |
|
|
@ -185,7 +181,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int id) { |
|
|
|
public void onClick(DialogInterface dialog, int id) { |
|
|
|
mPreferences.setFlashSupport(1); |
|
|
|
preferenceManager.setFlashSupport(1); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.setNegativeButton(getResources().getString(R.string.action_auto), |
|
|
|
.setNegativeButton(getResources().getString(R.string.action_auto), |
|
|
@ -193,13 +189,13 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
mPreferences.setFlashSupport(2); |
|
|
|
preferenceManager.setFlashSupport(2); |
|
|
|
} |
|
|
|
} |
|
|
|
}).setOnCancelListener(new DialogInterface.OnCancelListener() { |
|
|
|
}).setOnCancelListener(new DialogInterface.OnCancelListener() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onCancel(DialogInterface dialog) { |
|
|
|
public void onCancel(DialogInterface dialog) { |
|
|
|
mPreferences.setFlashSupport(0); |
|
|
|
preferenceManager.setFlashSupport(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
@ -210,7 +206,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
private void proxyChoicePicker() { |
|
|
|
private void proxyChoicePicker() { |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
picker.setTitle(getResources().getString(R.string.http_proxy)); |
|
|
|
picker.setTitle(getResources().getString(R.string.http_proxy)); |
|
|
|
picker.setSingleChoiceItems(mProxyChoices, mPreferences.getProxyChoice(), |
|
|
|
picker.setSingleChoiceItems(mProxyChoices, preferenceManager.getProxyChoice(), |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -240,7 +236,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mPreferences.setProxyChoice(choice); |
|
|
|
preferenceManager.setProxyChoice(choice); |
|
|
|
if (choice < mProxyChoices.length) |
|
|
|
if (choice < mProxyChoices.length) |
|
|
|
proxy.setSummary(mProxyChoices[choice]); |
|
|
|
proxy.setSummary(mProxyChoices[choice]); |
|
|
|
} |
|
|
|
} |
|
|
@ -258,8 +254,8 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
filterArray[0] = new InputFilter.LengthFilter(maxCharacters - 1); |
|
|
|
filterArray[0] = new InputFilter.LengthFilter(maxCharacters - 1); |
|
|
|
eProxyPort.setFilters(filterArray); |
|
|
|
eProxyPort.setFilters(filterArray); |
|
|
|
|
|
|
|
|
|
|
|
eProxyHost.setText(mPreferences.getProxyHost()); |
|
|
|
eProxyHost.setText(preferenceManager.getProxyHost()); |
|
|
|
eProxyPort.setText(Integer.toString(mPreferences.getProxyPort())); |
|
|
|
eProxyPort.setText(Integer.toString(preferenceManager.getProxyPort())); |
|
|
|
|
|
|
|
|
|
|
|
new AlertDialog.Builder(mActivity) |
|
|
|
new AlertDialog.Builder(mActivity) |
|
|
|
.setTitle(R.string.manual_proxy) |
|
|
|
.setTitle(R.string.manual_proxy) |
|
|
@ -274,10 +270,10 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
// larger than max integer
|
|
|
|
// larger than max integer
|
|
|
|
proxyPort = Integer.parseInt(eProxyPort.getText().toString()); |
|
|
|
proxyPort = Integer.parseInt(eProxyPort.getText().toString()); |
|
|
|
} catch (NumberFormatException ignored) { |
|
|
|
} catch (NumberFormatException ignored) { |
|
|
|
proxyPort = mPreferences.getProxyPort(); |
|
|
|
proxyPort = preferenceManager.getProxyPort(); |
|
|
|
} |
|
|
|
} |
|
|
|
mPreferences.setProxyHost(proxyHost); |
|
|
|
preferenceManager.setProxyHost(proxyHost); |
|
|
|
mPreferences.setProxyPort(proxyPort); |
|
|
|
preferenceManager.setProxyPort(proxyPort); |
|
|
|
proxy.setSummary(proxyHost + ':' + proxyPort); |
|
|
|
proxy.setSummary(proxyHost + ':' + proxyPort); |
|
|
|
} |
|
|
|
} |
|
|
|
}).show(); |
|
|
|
}).show(); |
|
|
@ -291,13 +287,13 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)", |
|
|
|
"DuckDuckGo (Privacy)", "DuckDuckGo Lite (Privacy)", "Baidu (Chinese)", |
|
|
|
"Yandex (Russian)"}; |
|
|
|
"Yandex (Russian)"}; |
|
|
|
|
|
|
|
|
|
|
|
int n = mPreferences.getSearchChoice(); |
|
|
|
int n = preferenceManager.getSearchChoice(); |
|
|
|
|
|
|
|
|
|
|
|
picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() { |
|
|
|
picker.setSingleChoiceItems(chars, n, new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
mPreferences.setSearchChoice(which); |
|
|
|
preferenceManager.setSearchChoice(which); |
|
|
|
setSearchEngineSummary(which); |
|
|
|
setSearchEngineSummary(which); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -313,7 +309,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
private void homepageDialog() { |
|
|
|
private void homepageDialog() { |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
picker.setTitle(getResources().getString(R.string.home)); |
|
|
|
picker.setTitle(getResources().getString(R.string.home)); |
|
|
|
mHomepage = mPreferences.getHomepage(); |
|
|
|
mHomepage = preferenceManager.getHomepage(); |
|
|
|
int n; |
|
|
|
int n; |
|
|
|
if (mHomepage.contains("about:home")) { |
|
|
|
if (mHomepage.contains("about:home")) { |
|
|
|
n = 1; |
|
|
|
n = 1; |
|
|
@ -331,15 +327,15 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
switch (which + 1) { |
|
|
|
switch (which + 1) { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
mPreferences.setHomepage("about:home"); |
|
|
|
preferenceManager.setHomepage("about:home"); |
|
|
|
home.setSummary(getResources().getString(R.string.action_homepage)); |
|
|
|
home.setSummary(getResources().getString(R.string.action_homepage)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
mPreferences.setHomepage("about:blank"); |
|
|
|
preferenceManager.setHomepage("about:blank"); |
|
|
|
home.setSummary(getResources().getString(R.string.action_blank)); |
|
|
|
home.setSummary(getResources().getString(R.string.action_blank)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
mPreferences.setHomepage("about:bookmarks"); |
|
|
|
preferenceManager.setHomepage("about:bookmarks"); |
|
|
|
home.setSummary(getResources().getString(R.string.action_bookmarks)); |
|
|
|
home.setSummary(getResources().getString(R.string.action_bookmarks)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
case 4: |
|
|
@ -361,7 +357,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity); |
|
|
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity); |
|
|
|
homePicker.setTitle(getResources().getString(R.string.title_custom_homepage)); |
|
|
|
homePicker.setTitle(getResources().getString(R.string.title_custom_homepage)); |
|
|
|
final EditText getHome = new EditText(mActivity); |
|
|
|
final EditText getHome = new EditText(mActivity); |
|
|
|
mHomepage = mPreferences.getHomepage(); |
|
|
|
mHomepage = preferenceManager.getHomepage(); |
|
|
|
if (!mHomepage.startsWith("about:")) { |
|
|
|
if (!mHomepage.startsWith("about:")) { |
|
|
|
getHome.setText(mHomepage); |
|
|
|
getHome.setText(mHomepage); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -373,7 +369,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
String text = getHome.getText().toString(); |
|
|
|
String text = getHome.getText().toString(); |
|
|
|
mPreferences.setHomepage(text); |
|
|
|
preferenceManager.setHomepage(text); |
|
|
|
home.setSummary(text); |
|
|
|
home.setSummary(text); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -383,7 +379,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
private void downloadLocDialog() { |
|
|
|
private void downloadLocDialog() { |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
picker.setTitle(getResources().getString(R.string.title_download_location)); |
|
|
|
picker.setTitle(getResources().getString(R.string.title_download_location)); |
|
|
|
mDownloadLocation = mPreferences.getDownloadDirectory(); |
|
|
|
mDownloadLocation = preferenceManager.getDownloadDirectory(); |
|
|
|
int n; |
|
|
|
int n; |
|
|
|
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) { |
|
|
|
if (mDownloadLocation.contains(Environment.DIRECTORY_DOWNLOADS)) { |
|
|
|
n = 1; |
|
|
|
n = 1; |
|
|
@ -397,7 +393,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
switch (which + 1) { |
|
|
|
switch (which + 1) { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
mPreferences.setDownloadDirectory(Environment.DIRECTORY_DOWNLOADS); |
|
|
|
preferenceManager.setDownloadDirectory(Environment.DIRECTORY_DOWNLOADS); |
|
|
|
downloadloc.setSummary(Constants.EXTERNAL_STORAGE + '/' |
|
|
|
downloadloc.setSummary(Constants.EXTERNAL_STORAGE + '/' |
|
|
|
+ Environment.DIRECTORY_DOWNLOADS); |
|
|
|
+ Environment.DIRECTORY_DOWNLOADS); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -419,12 +415,12 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
private void agentDialog() { |
|
|
|
private void agentDialog() { |
|
|
|
AlertDialog.Builder agentPicker = new AlertDialog.Builder(mActivity); |
|
|
|
AlertDialog.Builder agentPicker = new AlertDialog.Builder(mActivity); |
|
|
|
agentPicker.setTitle(getResources().getString(R.string.title_user_agent)); |
|
|
|
agentPicker.setTitle(getResources().getString(R.string.title_user_agent)); |
|
|
|
mAgentChoice = mPreferences.getUserAgentChoice(); |
|
|
|
mAgentChoice = preferenceManager.getUserAgentChoice(); |
|
|
|
agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1, |
|
|
|
agentPicker.setSingleChoiceItems(R.array.user_agent, mAgentChoice - 1, |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
mPreferences.setUserAgentChoice(which + 1); |
|
|
|
preferenceManager.setUserAgentChoice(which + 1); |
|
|
|
switch (which + 1) { |
|
|
|
switch (which + 1) { |
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
useragent.setSummary(getResources().getString(R.string.agent_default)); |
|
|
|
useragent.setSummary(getResources().getString(R.string.agent_default)); |
|
|
@ -467,7 +463,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
String text = getAgent.getText().toString(); |
|
|
|
String text = getAgent.getText().toString(); |
|
|
|
mPreferences.setUserAgentString(text); |
|
|
|
preferenceManager.setUserAgentString(text); |
|
|
|
useragent.setSummary(getResources().getString(R.string.agent_custom)); |
|
|
|
useragent.setSummary(getResources().getString(R.string.agent_custom)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -479,7 +475,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
LinearLayout layout = new LinearLayout(mActivity); |
|
|
|
LinearLayout layout = new LinearLayout(mActivity); |
|
|
|
downLocationPicker.setTitle(getResources().getString(R.string.title_download_location)); |
|
|
|
downLocationPicker.setTitle(getResources().getString(R.string.title_download_location)); |
|
|
|
final EditText getDownload = new EditText(mActivity); |
|
|
|
final EditText getDownload = new EditText(mActivity); |
|
|
|
getDownload.setText(mPreferences.getDownloadDirectory()); |
|
|
|
getDownload.setText(preferenceManager.getDownloadDirectory()); |
|
|
|
|
|
|
|
|
|
|
|
int padding = Utils.dpToPx(10); |
|
|
|
int padding = Utils.dpToPx(10); |
|
|
|
|
|
|
|
|
|
|
@ -507,7 +503,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
String text = getDownload.getText().toString(); |
|
|
|
String text = getDownload.getText().toString(); |
|
|
|
mPreferences.setDownloadDirectory(text); |
|
|
|
preferenceManager.setDownloadDirectory(text); |
|
|
|
downloadloc.setSummary(Constants.EXTERNAL_STORAGE + '/' + text); |
|
|
|
downloadloc.setSummary(Constants.EXTERNAL_STORAGE + '/' + text); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -582,37 +578,37 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe |
|
|
|
if (cbFlash.isChecked()) { |
|
|
|
if (cbFlash.isChecked()) { |
|
|
|
getFlashChoice(); |
|
|
|
getFlashChoice(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
mPreferences.setFlashSupport(0); |
|
|
|
preferenceManager.setFlashSupport(0); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!Utils.isFlashInstalled(mActivity) && cbFlash.isChecked()) { |
|
|
|
if (!Utils.isFlashInstalled(mActivity) && cbFlash.isChecked()) { |
|
|
|
Utils.createInformativeDialog(mActivity, R.string.title_warning, R.string.dialog_adobe_not_installed); |
|
|
|
Utils.createInformativeDialog(mActivity, R.string.title_warning, R.string.dialog_adobe_not_installed); |
|
|
|
cbFlash.setEnabled(false); |
|
|
|
cbFlash.setEnabled(false); |
|
|
|
mPreferences.setFlashSupport(0); |
|
|
|
preferenceManager.setFlashSupport(0); |
|
|
|
} |
|
|
|
} |
|
|
|
cbFlash.setChecked((Boolean) newValue); |
|
|
|
cbFlash.setChecked((Boolean) newValue); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case SETTINGS_ADS: |
|
|
|
case SETTINGS_ADS: |
|
|
|
mPreferences.setAdBlockEnabled((Boolean) newValue); |
|
|
|
preferenceManager.setAdBlockEnabled((Boolean) newValue); |
|
|
|
cbAds.setChecked((Boolean) newValue); |
|
|
|
cbAds.setChecked((Boolean) newValue); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case SETTINGS_IMAGES: |
|
|
|
case SETTINGS_IMAGES: |
|
|
|
mPreferences.setBlockImagesEnabled((Boolean) newValue); |
|
|
|
preferenceManager.setBlockImagesEnabled((Boolean) newValue); |
|
|
|
cbImages.setChecked((Boolean) newValue); |
|
|
|
cbImages.setChecked((Boolean) newValue); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case SETTINGS_JAVASCRIPT: |
|
|
|
case SETTINGS_JAVASCRIPT: |
|
|
|
mPreferences.setJavaScriptEnabled((Boolean) newValue); |
|
|
|
preferenceManager.setJavaScriptEnabled((Boolean) newValue); |
|
|
|
cbJsScript.setChecked((Boolean) newValue); |
|
|
|
cbJsScript.setChecked((Boolean) newValue); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case SETTINGS_COLORMODE: |
|
|
|
case SETTINGS_COLORMODE: |
|
|
|
mPreferences.setColorModeEnabled((Boolean) newValue); |
|
|
|
preferenceManager.setColorModeEnabled((Boolean) newValue); |
|
|
|
cbColorMode.setChecked((Boolean) newValue); |
|
|
|
cbColorMode.setChecked((Boolean) newValue); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case SETTINGS_GOOGLESUGGESTIONS: |
|
|
|
case SETTINGS_GOOGLESUGGESTIONS: |
|
|
|
mPreferences.setGoogleSearchSuggestionsEnabled((Boolean) newValue); |
|
|
|
preferenceManager.setGoogleSearchSuggestionsEnabled((Boolean) newValue); |
|
|
|
cbgooglesuggest.setChecked((Boolean) newValue); |
|
|
|
cbgooglesuggest.setChecked((Boolean) newValue); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case SETTINGS_DRAWERTABS: |
|
|
|
case SETTINGS_DRAWERTABS: |
|
|
|
mPreferences.setShowTabsInDrawer((Boolean) newValue); |
|
|
|
preferenceManager.setShowTabsInDrawer((Boolean) newValue); |
|
|
|
cbDrawerTabs.setChecked((Boolean) newValue); |
|
|
|
cbDrawerTabs.setChecked((Boolean) newValue); |
|
|
|
default: |
|
|
|
default: |
|
|
|
return false; |
|
|
|
return false; |
|
|
|