|
|
@ -11,7 +11,12 @@ import android.preference.Preference; |
|
|
|
import android.preference.PreferenceFragment; |
|
|
|
import android.preference.PreferenceFragment; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
import android.support.v7.app.AlertDialog; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import acr.browser.lightning.R; |
|
|
|
import acr.browser.lightning.R; |
|
|
|
|
|
|
|
import acr.browser.lightning.constant.Constants; |
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
|
|
|
|
|
|
|
|
public class AdvancedSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { |
|
|
|
public class AdvancedSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener { |
|
|
@ -22,11 +27,12 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref |
|
|
|
private static final String SETTINGS_RESTORETABS = "restore_tabs"; |
|
|
|
private static final String SETTINGS_RESTORETABS = "restore_tabs"; |
|
|
|
private static final String SETTINGS_RENDERINGMODE = "rendering_mode"; |
|
|
|
private static final String SETTINGS_RENDERINGMODE = "rendering_mode"; |
|
|
|
private static final String SETTINGS_URLCONTENT = "url_contents"; |
|
|
|
private static final String SETTINGS_URLCONTENT = "url_contents"; |
|
|
|
|
|
|
|
private static final String SETTINGS_TEXTENCODING = "text_encoding"; |
|
|
|
|
|
|
|
|
|
|
|
private Activity mActivity; |
|
|
|
private Activity mActivity; |
|
|
|
private PreferenceManager mPreferences; |
|
|
|
private PreferenceManager mPreferences; |
|
|
|
private CheckBoxPreference cbAllowPopups, cbenablecookies, cbcookiesInkognito, cbrestoreTabs; |
|
|
|
private CheckBoxPreference cbAllowPopups, cbenablecookies, cbcookiesInkognito, cbrestoreTabs; |
|
|
|
private Preference renderingmode, urlcontent; |
|
|
|
private Preference renderingmode, urlcontent, textEncoding; |
|
|
|
private CharSequence[] mUrlOptions; |
|
|
|
private CharSequence[] mUrlOptions; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -45,6 +51,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref |
|
|
|
mPreferences = PreferenceManager.getInstance(); |
|
|
|
mPreferences = PreferenceManager.getInstance(); |
|
|
|
|
|
|
|
|
|
|
|
renderingmode = findPreference(SETTINGS_RENDERINGMODE); |
|
|
|
renderingmode = findPreference(SETTINGS_RENDERINGMODE); |
|
|
|
|
|
|
|
textEncoding = findPreference(SETTINGS_TEXTENCODING); |
|
|
|
urlcontent = findPreference(SETTINGS_URLCONTENT); |
|
|
|
urlcontent = findPreference(SETTINGS_URLCONTENT); |
|
|
|
cbAllowPopups = (CheckBoxPreference) findPreference(SETTINGS_NEWWINDOW); |
|
|
|
cbAllowPopups = (CheckBoxPreference) findPreference(SETTINGS_NEWWINDOW); |
|
|
|
cbenablecookies = (CheckBoxPreference) findPreference(SETTINGS_ENABLECOOKIES); |
|
|
|
cbenablecookies = (CheckBoxPreference) findPreference(SETTINGS_ENABLECOOKIES); |
|
|
@ -52,6 +59,7 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref |
|
|
|
cbrestoreTabs = (CheckBoxPreference) findPreference(SETTINGS_RESTORETABS); |
|
|
|
cbrestoreTabs = (CheckBoxPreference) findPreference(SETTINGS_RESTORETABS); |
|
|
|
|
|
|
|
|
|
|
|
renderingmode.setOnPreferenceClickListener(this); |
|
|
|
renderingmode.setOnPreferenceClickListener(this); |
|
|
|
|
|
|
|
textEncoding.setOnPreferenceClickListener(this); |
|
|
|
urlcontent.setOnPreferenceClickListener(this); |
|
|
|
urlcontent.setOnPreferenceClickListener(this); |
|
|
|
cbAllowPopups.setOnPreferenceChangeListener(this); |
|
|
|
cbAllowPopups.setOnPreferenceChangeListener(this); |
|
|
|
cbenablecookies.setOnPreferenceChangeListener(this); |
|
|
|
cbenablecookies.setOnPreferenceChangeListener(this); |
|
|
@ -73,6 +81,8 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textEncoding.setSummary(mPreferences.getTextEncoding()); |
|
|
|
|
|
|
|
|
|
|
|
mUrlOptions = getResources().getStringArray(R.array.url_content_array); |
|
|
|
mUrlOptions = getResources().getStringArray(R.array.url_content_array); |
|
|
|
int option = mPreferences.getUrlBoxContentChoice(); |
|
|
|
int option = mPreferences.getUrlBoxContentChoice(); |
|
|
|
urlcontent.setSummary(mUrlOptions[option]); |
|
|
|
urlcontent.setSummary(mUrlOptions[option]); |
|
|
@ -92,6 +102,9 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref |
|
|
|
case SETTINGS_URLCONTENT: |
|
|
|
case SETTINGS_URLCONTENT: |
|
|
|
urlBoxPicker(); |
|
|
|
urlBoxPicker(); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
|
|
|
|
case SETTINGS_TEXTENCODING: |
|
|
|
|
|
|
|
textEncodingPicker(); |
|
|
|
|
|
|
|
return true; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -162,6 +175,29 @@ public class AdvancedSettingsFragment extends PreferenceFragment implements Pref |
|
|
|
picker.show(); |
|
|
|
picker.show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void textEncodingPicker() { |
|
|
|
|
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
|
|
|
|
picker.setTitle(getResources().getString(R.string.text_encoding)); |
|
|
|
|
|
|
|
final List<String> textEncodingList = Arrays.asList(Constants.TEXT_ENCODINGS); |
|
|
|
|
|
|
|
int n = textEncodingList.indexOf(mPreferences.getTextEncoding()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
picker.setSingleChoiceItems(Constants.TEXT_ENCODINGS, n, new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
|
|
|
|
mPreferences.setTextEncoding(Constants.TEXT_ENCODINGS[which]); |
|
|
|
|
|
|
|
textEncoding.setSummary(Constants.TEXT_ENCODINGS[which]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
picker.setNeutralButton(getResources().getString(R.string.action_ok), |
|
|
|
|
|
|
|
new DialogInterface.OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
picker.show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void urlBoxPicker() { |
|
|
|
private void urlBoxPicker() { |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); |
|
|
|
picker.setTitle(getResources().getString(R.string.url_contents)); |
|
|
|
picker.setTitle(getResources().getString(R.string.url_contents)); |
|
|
|