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