List of usage examples for android.preference PreferenceCategory PreferenceCategory
public PreferenceCategory(Context context)
From source file:com.quarterfull.newsAndroid.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./* w w w. j a v a 2s. co m*/ */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); PreferenceCategory header = new PreferenceCategory(this); header.setTitle(R.string.pref_header_display); getPreferenceScreen().addPreference(header); addPreferencesFromResource(R.xml.pref_display); header = new PreferenceCategory(this); header.setTitle(R.string.pref_header_data_sync); getPreferenceScreen().addPreference(header); addPreferencesFromResource(R.xml.pref_data_sync); header = new PreferenceCategory(this); header.setTitle(R.string.pref_header_notifications); getPreferenceScreen().addPreference(header); addPreferencesFromResource(R.xml.pref_notification); /* header = new PreferenceCategory(this); header.setTitle(R.string.pref_header_podcast); getPreferenceScreen().addPreference(header); addPreferencesFromResource(R.xml.pref_podcast); */ bindGeneralPreferences(null, this); bindDisplayPreferences(null, this); bindDataSyncPreferences(null, this); bindNotificationPreferences(null, this); //bindPodcastPreferences(null, this); }
From source file:com.nttec.everychan.chans.makaba.MakabaModule.java
/** ? ( .. https) */ private void addDomainPreferences(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() { @Override//from w ww .j av a2s . c o m public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) { updateDomain((String) newValue, preferences.getBoolean(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA), true)); return true; } else if (preference.getKey().equals(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA))) { updateDomain(preferences.getString(getSharedKey(PREF_KEY_DOMAIN), DEFAULT_DOMAIN), (boolean) newValue); return true; } return false; } }; PreferenceCategory domainCat = new PreferenceCategory(context); domainCat.setTitle(R.string.makaba_prefs_domain_category); group.addPreference(domainCat); EditTextPreference domainPref = new EditTextPreference(context); // domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); domainPref.setOnPreferenceChangeListener(updateDomainListener); domainCat.addPreference(domainPref); CheckBoxPreference httpsPref = new LazyPreferences.CheckBoxPreference(context); //? "? https" httpsPref.setTitle(R.string.pref_use_https); httpsPref.setSummary(R.string.pref_use_https_summary); httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA)); httpsPref.setDefaultValue(true); httpsPref.setOnPreferenceChangeListener(updateDomainListener); domainCat.addPreference(httpsPref); }
From source file:de.azapps.mirakel.settings.custom_views.Settings.java
public static PreferenceScreen inflateHeaders(final @NonNull PreferenceScreen screen, final @NonNull OnItemClickedListener<Settings> onClick) { for (final Map.Entry<Integer, List<Settings>> id : all.entrySet()) { final PreferenceCategory cat = new PreferenceCategory(ctx); screen.addPreference(cat);/*from ww w . j a v a2s . c om*/ cat.setTitle(id.getKey()); for (final Settings setting : id.getValue()) { if (setting == DEV && !MirakelCommonPreferences.isEnabledDebugMenu()) { continue; } cat.addItemFromInflater(setting.getPreference(onClick)); } } return screen; }
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) ? ?-?/* w w w . j ava 2 s . c o m*/ * @param group , ??? */ protected void addProxyPreferences(PreferenceGroup group) { final Context context = group.getContext(); PreferenceCategory proxyCat = new PreferenceCategory(context); //? ? ? proxyCat.setTitle(R.string.pref_cat_proxy); group.addPreference(proxyCat); CheckBoxPreference useProxyPref = new CheckBoxPreference(context); //? "? ? " useProxyPref.setTitle(R.string.pref_use_proxy); useProxyPref.setSummary(R.string.pref_use_proxy_summary); useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY)); useProxyPref.setDefaultValue(false); useProxyPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(useProxyPref); EditTextPreference proxyHostPref = new EditTextPreference(context); // ? ?-? proxyHostPref.setTitle(R.string.pref_proxy_host); proxyHostPref.setDialogTitle(R.string.pref_proxy_host); proxyHostPref.setSummary(R.string.pref_proxy_host_summary); proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST)); proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST); proxyHostPref.getEditText().setSingleLine(); proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); proxyHostPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPref); proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); EditTextPreference proxyHostPort = new EditTextPreference(context); // ?-? proxyHostPort.setTitle(R.string.pref_proxy_port); proxyHostPort.setDialogTitle(R.string.pref_proxy_port); proxyHostPort.setSummary(R.string.pref_proxy_port_summary); proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT)); proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT); proxyHostPort.getEditText().setSingleLine(); proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); proxyHostPort.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPort); proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); }
From source file:com.rareventure.gps2.reviewer.SettingsActivity.java
private void createPreferenceHierarchy() { PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); this.setPreferenceScreen(root); isCollectData = new CheckBoxPreference(this); isCollectData.setTitle(R.string.collect_gps_data); isCollectData.setSummary(R.string.collect_gps_data_desc); root.addPreference(isCollectData);/*from ww w .ja v a 2 s . c o m*/ isCollectData.setOnPreferenceClickListener(this); percTimeGpsOn = new SeekBarDialogPreference(this, getText(R.string.title_perc_time_gps_on), getText(R.string.desc_perc_time_gps_on), getResources().getInteger(R.dimen.perc_time_gps_on_min_value), getResources().getInteger(R.dimen.perc_time_gps_on_max_value), getResources().getInteger(R.dimen.perc_time_gps_on_steps), getResources().getInteger(R.dimen.perc_time_gps_on_log_scale), getText(R.string.seekbar_perc_printf_format).toString(), null); percTimeGpsOn.setOnPreferenceChangeListener(this); root.addPreference(percTimeGpsOn); minBatteryLife = new SeekBarDialogPreference(this, getText(R.string.title_min_battery_life_perc), getText(R.string.desc_min_battery_life_perc), getResources().getInteger(R.dimen.min_battery_level_min_value), getResources().getInteger(R.dimen.min_battery_level_max_value), getResources().getInteger(R.dimen.min_battery_level_steps), getResources().getInteger(R.dimen.min_battery_level_log_scale), getText(R.string.seekbar_perc_printf_format).toString(), null); minBatteryLife.setOnPreferenceChangeListener(this); root.addPreference(minBatteryLife); enableToolTips = new CheckBoxPreference(this); enableToolTips.setTitle(R.string.enable_tooltips); enableToolTips.setKey("enable_tooltips"); root.addPreference(enableToolTips); enableToolTips.setOnPreferenceClickListener(this); useMetricUnits = new CheckBoxPreference(this); useMetricUnits.setTitle(R.string.use_metric_units); useMetricUnits.setChecked(GTG.prefs.useMetric); root.addPreference(useMetricUnits); //note that we can't use setIntent() for these preferences, since that would // be interpreted as an outside action causing us to lose the password is set flag colorblindSettings = getPreferenceManager().createPreferenceScreen(this); // screenPref.setKey("screen_preference"); // colorblindSettings.setIntent(new Intent(this, ChooseColorsScreen.class)); colorblindSettings.setTitle(R.string.colorblind_title); colorblindSettings.setSummary(R.string.colorblind_summary); colorblindSettings.setOnPreferenceClickListener(this); root.addPreference(colorblindSettings); mapFontSize = new SeekBarDialogPreference(this, getText(R.string.title_map_font_size), getText(R.string.desc_map_font_size), getResources().getInteger(R.dimen.map_font_size_min_value), getResources().getInteger(R.dimen.map_font_size_max_value), getResources().getInteger(R.dimen.map_font_size_steps), getResources().getInteger(R.dimen.map_font_size_log_scale), "%1.0f", null); mapFontSize.setOnPreferenceChangeListener(this); root.addPreference(mapFontSize); enablePassword = new CheckBoxPreference(this); enablePassword.setTitle(R.string.enable_password); enablePassword.setKey("enable_password"); root.addPreference(enablePassword); enablePassword.setOnPreferenceClickListener(this); changePassword = new Preference(this); changePassword.setTitle(R.string.change_password); root.addPreference(changePassword); changePassword.setDependency("enable_password"); changePassword.setOnPreferenceClickListener(this); passwordTimeout = new SeekBarDialogPreference(this, getText(R.string.title_password_timeout), getText(R.string.desc_password_timeout), 0, passwordTimeoutStrs.length - 1, passwordTimeoutStrs.length, 0, null, new SeekBarWithText.CustomUpdateTextView() { @Override public String updateText(float value) { return passwordTimeoutStrs[(int) value]; } }); passwordTimeout.setOnPreferenceChangeListener(this); root.addPreference(passwordTimeout); createBackupFilePref = getPreferenceManager().createPreferenceScreen(this); createBackupFilePref.setTitle(R.string.create_backup_pref); root.addPreference(createBackupFilePref); createBackupFilePref.setOnPreferenceClickListener(this); restoreBackupFilePref = getPreferenceManager().createPreferenceScreen(this); restoreBackupFilePref.setTitle(R.string.restore_backup_pref); root.addPreference(restoreBackupFilePref); restoreBackupFilePref.setOnPreferenceClickListener(this); allowErrorReporting = new CheckBoxPreference(this); allowErrorReporting.setTitle(R.string.allow_error_reporting); allowErrorReporting.setSummary(R.string.allow_error_reporting_summary); allowErrorReporting.setChecked(GTG.isAcraEnabled(this)); root.addPreference(allowErrorReporting); aboutPref = getPreferenceManager().createPreferenceScreen(this); aboutPref.setOnPreferenceClickListener(this); aboutPref.setTitle(R.string.about); root.addPreference(aboutPref); PreferenceCategory advancedCategory = new PreferenceCategory(this); advancedCategory.setTitle("Advanced"); root.addPreference(advancedCategory); writeGpsWakeLockDebugFile = new CheckBoxPreference(this); writeGpsWakeLockDebugFile.setTitle(R.string.write_to_gps_wake_lock_log); writeGpsWakeLockDebugFile.setSummary(String.format(getString(R.string.write_to_gps_wake_lock_log_summary), getString(R.string.gps_wake_lock_filename))); writeGpsWakeLockDebugFile.setChecked(GTG.prefs.writeGpsWakeLockDebug); writeGpsWakeLockDebugFile.setOnPreferenceClickListener(this); advancedCategory.addPreference(writeGpsWakeLockDebugFile); }
From source file:org.geometerplus.android.fbreader.preferences.PreferenceActivity.java
@Override protected void init(Intent intent) { try {//from w w w . j av a2s . c o m this.runFromBook = getIntent().getExtras().getBoolean("fromBook", false); } catch (NullPointerException e) { this.runFromBook = false; } if (getIntent() != null) { Intent myIntent = getIntent(); if (myIntent.hasExtra(PreferenceActivity.OPEN_COLOR_PREFERENCES)) { showColorsScreen = true; } } setResult(FullReaderActivity.RESULT_REPAINT); ReaderApp myReaderApp = (ReaderApp) ReaderApp.Instance(); if (myReaderApp == null) { myReaderApp = new ReaderApp(new BookCollectionShadow()); } final ZLAndroidLibrary androidLibrary = (ZLAndroidLibrary) ZLAndroidLibrary.Instance(); final ColorProfile profile = myReaderApp.getColorProfile(); final String profileName = myReaderApp.getColorProfileName(); //androidLibrary.setActivity(Reader.getInstance()); //androidLibrary.setActivity(intent.getC); // final ZLAndroidApplication androidApplication = (ZLAndroidApplication)getApplication(); // if (androidApplication.myMainWindow == null) { // androidApplication.myMainWindow = new ZLAndroidApplicationWindow(myReaderApp); // myReaderApp.initWindow(); // } //GENERAL Screen appearanceScreen = null; Screen GeneralScreen = createPreferenceScreen("general"); if (!isOpenFromPdfDjvu) { appearanceScreen = createPreferenceScreen("appearance"); } Log.d("runFromBookPREFS: ", String.valueOf(runFromBook)); if (runFromBook) { if (android.os.Build.VERSION.SDK_INT >= 11) { GeneralScreen.addPreference(new LanguagePreference(this, appearanceScreen.Resource, "language", ZLResource.languages()) { @Override protected void init() { setInitialValue(ZLResource.LanguageOption.getValue()); } @Override protected void setLanguage(String code) { if (!code.equals(ZLResource.LanguageOption.getValue())) { ZLResource.LanguageOption.setValue(code); // startActivity(new Intent( // Intent.ACTION_VIEW, Uri.parse("reader-action:preferences#appearance") // )); Editor editor = PreferenceManager.getDefaultSharedPreferences(PreferenceActivity.this) .edit(); editor.putString(IConstants.PREF_LOCALE, code); editor.commit(); recreatethis(); } } }); appearanceScreen.addPreference(new ThemeListPreference(this) { @Override public void updatePref() { // startActivity(new Intent( // Intent.ACTION_VIEW, Uri.parse("reader-action:preferences#general") // )); // finish(); mFromTheme = true; recreatethis(); } }); } } else { if (isOpenFromPdfDjvu) { } if (!isOpenFromPdfDjvu) { GeneralScreen.addPreference(new LanguagePreference(this, appearanceScreen.Resource, "language", ZLResource.languages()) { @Override protected void init() { setInitialValue(ZLResource.LanguageOption.getValue()); } @Override protected void setLanguage(String code) { if (!code.equals(ZLResource.LanguageOption.getValue())) { ZLResource.LanguageOption.setValue(code); // startActivity(new Intent( // Intent.ACTION_VIEW, Uri.parse("reader-action:preferences#appearance") // )); Editor editor = PreferenceManager.getDefaultSharedPreferences(PreferenceActivity.this) .edit(); editor.putString(IConstants.PREF_LOCALE, code); editor.commit(); recreatethis(); } } }); appearanceScreen.addPreference(new ThemeListPreference(this) { @Override public void updatePref() { // startActivity(new Intent( // Intent.ACTION_VIEW, Uri.parse("reader-action:preferences#general") // )); // finish(); mFromTheme = true; recreatethis(); } }); } } //REMINDER GeneralScreen.addPreference( new ZLBooleanPreference(this, myReaderApp.ReaderOption, GeneralScreen.Resource, "reminder") { @Override protected void onClick() { super.onClick(); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("needToRemind", isChecked()); editor.commit(); } }); remindPref = new ReminderChoosePreference(this); remindPref.setEnabled( PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getBoolean("needToRemind", false)); GeneralScreen.addPreference(remindPref); if (!isOpenFromPdfDjvu) { GeneralScreen.addPreference(new OrientationChangePreference(this, GeneralScreen.Resource, "screenOrientation", androidLibrary.OrientationOption, androidLibrary.allOrientations())); /* final Screen directoriesScreen = createPreferenceScreen("directories"); directoriesScreen.addPreference(new ZLStringOptionPreference( this, Paths.BooksDirectoryOption(), directoriesScreen.Resource, "books" ) { protected void setValue(String value) { super.setValue(value); myCollection.reset(false); } }); directoriesScreen.addOption(Paths.FontsDirectoryOption(), "fonts"); directoriesScreen.addOption(Paths.WallpapersDirectoryOption(), "wallpapers"); */ // appearanceScreen.addPreference(new ZLStringChoicePreference( // this, appearanceScreen.Resource, "screenOrientation", // androidLibrary.OrientationOption, androidLibrary.allOrientations() // )); appearanceScreen .addPreference(new ZLBooleanPreference(this, myReaderApp.AllowScreenBrightnessAdjustmentOption, appearanceScreen.Resource, "allowScreenBrightnessAdjustment") { private final int myLevel = androidLibrary.ScreenBrightnessLevelOption.getValue(); @Override protected void onClick() { super.onClick(); androidLibrary.ScreenBrightnessLevelOption.setValue(isChecked() ? myLevel : 0); } }); /*appearanceScreen.addPreference(new BatteryLevelToTurnScreenOffPreference( this, androidLibrary.BatteryLevelToTurnScreenOffOption, appearanceScreen.Resource, "dontTurnScreenOff" )); appearanceScreen.addPreference(new ZLBooleanPreference( this, androidLibrary.DontTurnScreenOffDuringChargingOption, appearanceScreen.Resource, "dontTurnScreenOffDuringCharging" )); appearanceScreen.addOption(androidLibrary.ShowStatusBarOption, "showStatusBar"); appearanceScreen.addOption(androidLibrary.DisableButtonLightsOption, "disableButtonLights"); */ final Screen textScreen = createPreferenceScreen("text"); final Screen fontPropertiesScreen = textScreen.createPreferenceScreen("fontProperties"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.AntiAliasOption, "antiAlias"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.DeviceKerningOption, "deviceKerning"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.DitheringOption, "dithering"); fontPropertiesScreen.addOption(ZLAndroidPaintContext.SubpixelOption, "subpixel"); final ZLTextStyleCollection collection = ZLTextStyleCollection.Instance(); final ZLTextBaseStyle baseStyle = collection.getBaseStyle(); textScreen.addPreference( new FontOption(this, textScreen.Resource, "font", baseStyle.FontFamilyOption, false)); textScreen.addPreference(new ZLIntegerRangePreference(this, textScreen.Resource.getResource("fontSize"), baseStyle.FontSizeOption)); textScreen.addPreference(new FontStylePreference(this, textScreen.Resource, "fontStyle", baseStyle.BoldOption, baseStyle.ItalicOption)); final ZLIntegerRangeOption spaceOption = baseStyle.LineSpaceOption; final String[] spacings = new String[spaceOption.MaxValue - spaceOption.MinValue + 1]; for (int i = 0; i < spacings.length; ++i) { final int val = spaceOption.MinValue + i; spacings[i] = (char) (val / 10 + '0') + "." + (char) (val % 10 + '0'); } textScreen.addPreference( new ZLChoicePreference(this, textScreen.Resource, "lineSpacing", spaceOption, spacings)); final String[] alignments = { "left", "right", "center", "justify" }; textScreen.addPreference(new ZLChoicePreference(this, textScreen.Resource, "alignment", baseStyle.AlignmentOption, alignments)); textScreen.addOption(baseStyle.AutoHyphenationOption, "autoHyphenations"); final Screen moreStylesScreen = textScreen.createPreferenceScreen("more"); byte styles[] = { FBTextKind.REGULAR, FBTextKind.TITLE, FBTextKind.SECTION_TITLE, FBTextKind.SUBTITLE, FBTextKind.H1, FBTextKind.H2, FBTextKind.H3, FBTextKind.H4, FBTextKind.H5, FBTextKind.H6, FBTextKind.ANNOTATION, FBTextKind.EPIGRAPH, FBTextKind.AUTHOR, FBTextKind.POEM_TITLE, FBTextKind.STANZA, FBTextKind.VERSE, FBTextKind.CITE, FBTextKind.INTERNAL_HYPERLINK, FBTextKind.EXTERNAL_HYPERLINK, FBTextKind.FOOTNOTE, FBTextKind.ITALIC, FBTextKind.EMPHASIS, FBTextKind.BOLD, FBTextKind.STRONG, FBTextKind.DEFINITION, FBTextKind.DEFINITION_DESCRIPTION, FBTextKind.PREFORMATTED, FBTextKind.CODE }; for (int i = 0; i < styles.length; ++i) { final ZLTextStyleDecoration decoration = collection.getDecoration(styles[i]); if (decoration == null) { continue; } ZLTextFullStyleDecoration fullDecoration = decoration instanceof ZLTextFullStyleDecoration ? (ZLTextFullStyleDecoration) decoration : null; final Screen formatScreen = moreStylesScreen.createPreferenceScreen(decoration.getName()); formatScreen.addPreference( new FontOption(this, textScreen.Resource, "font", decoration.FontFamilyOption, true)); formatScreen.addPreference(new ZLIntegerRangePreference(this, textScreen.Resource.getResource("fontSizeDifference"), decoration.FontSizeDeltaOption)); formatScreen.addPreference( new ZLBoolean3Preference(this, textScreen.Resource, "bold", decoration.BoldOption)); formatScreen.addPreference( new ZLBoolean3Preference(this, textScreen.Resource, "italic", decoration.ItalicOption)); formatScreen.addPreference(new ZLBoolean3Preference(this, textScreen.Resource, "underlined", decoration.UnderlineOption)); formatScreen.addPreference(new ZLBoolean3Preference(this, textScreen.Resource, "strikedThrough", decoration.StrikeThroughOption)); if (fullDecoration != null) { final String[] allAlignments = { "unchanged", "left", "right", "center", "justify" }; formatScreen.addPreference(new ZLChoicePreference(this, textScreen.Resource, "alignment", fullDecoration.AlignmentOption, allAlignments)); } formatScreen.addPreference(new ZLBoolean3Preference(this, textScreen.Resource, "allowHyphenations", decoration.AllowHyphenationsOption)); if (fullDecoration != null) { formatScreen.addPreference(new ZLIntegerRangePreference(this, textScreen.Resource.getResource("spaceBefore"), fullDecoration.SpaceBeforeOption)); formatScreen.addPreference(new ZLIntegerRangePreference(this, textScreen.Resource.getResource("spaceAfter"), fullDecoration.SpaceAfterOption)); formatScreen.addPreference(new ZLIntegerRangePreference(this, textScreen.Resource.getResource("leftIndent"), fullDecoration.LeftIndentOption)); formatScreen.addPreference(new ZLIntegerRangePreference(this, textScreen.Resource.getResource("rightIndent"), fullDecoration.RightIndentOption)); formatScreen.addPreference( new ZLIntegerRangePreference(this, textScreen.Resource.getResource("firstLineIndent"), fullDecoration.FirstLineIndentDeltaOption)); final ZLIntegerOption spacePercentOption = fullDecoration.LineSpacePercentOption; final int[] spacingValues = new int[17]; final String[] spacingKeys = new String[17]; spacingValues[0] = -1; spacingKeys[0] = "unchanged"; for (int j = 1; j < spacingValues.length; ++j) { final int val = 4 + j; spacingValues[j] = 10 * val; spacingKeys[j] = (char) (val / 10 + '0') + "." + (char) (val % 10 + '0'); } formatScreen.addPreference(new ZLIntegerChoicePreference(this, textScreen.Resource, "lineSpacing", spacePercentOption, spacingValues, spacingKeys)); } } /*final ZLPreferenceSet bgPreferences = new ZLPreferenceSet(); if(profileName.equals(ColorProfile.DAY)){ final Screen colorsScreen = createPreferenceScreen("colors"); colorsScreen.addPreference(new WallpaperPreference( this, profile, colorsScreen.Resource, "background" ) { @Override protected void onDialogClosed(boolean result) { super.onDialogClosed(result); bgPreferences.setEnabled("".equals(getValue())); } }); bgPreferences.add( colorsScreen.addOption(profile.BackgroundOption, "#FFFFFF") ); bgPreferences.setEnabled("".equals(profile.WallpaperOption.getValue())); }*/ final Screen colorsScreen = createPreferenceScreen("colors"); if (profileName.equals(ColorProfile.DAY)) { final ZLPreferenceSet bgPreferences = new ZLPreferenceSet(); final WallpaperPreference wallpaperPreference = new WallpaperPreference(this, profile, colorsScreen.Resource, "background") { @Override protected void onDialogClosed(boolean result) { super.onDialogClosed(result); bgPreferences.setEnabled("".equals(getValue())); } }; colorsScreen.addPreference(wallpaperPreference); /* * ?? ? ? ? */ WallpaperAlignmentPreference wallpaperAlignment = new WallpaperAlignmentPreference(this); wallpaperAlignment.setKey(WallpaperAlignmentPreference.WALLPAPER_ALIGN_KEY); String currentLanguage = loadCurrentLanguage(); if (currentLanguage.equals("ru")) { wallpaperAlignment.setTitle(russianTitle); wallpaperAlignment.setEntries(russianValues); } else if (currentLanguage.equals("uk")) { wallpaperAlignment.setTitle(ukrainianTitle); wallpaperAlignment.setEntries(ukrainianValues); } else if (currentLanguage.equals("en")) { wallpaperAlignment.setTitle(englishTitle); wallpaperAlignment.setEntries(englishValues); } else if (currentLanguage.equals("de")) { wallpaperAlignment.setTitle(germanTitle); wallpaperAlignment.setEntries(germanValues); } else if (currentLanguage.equals("fr")) { wallpaperAlignment.setTitle(frenchTitle); wallpaperAlignment.setEntries(frenchValues); } else { if (Locale.getDefault().getDisplayLanguage().equals("??")) { wallpaperAlignment.setTitle(russianTitle); wallpaperAlignment.setEntries(russianValues); } else if (Locale.getDefault().getDisplayLanguage().equals("?")) { wallpaperAlignment.setTitle(ukrainianTitle); wallpaperAlignment.setEntries(ukrainianValues); } else { wallpaperAlignment.setTitle(englishTitle); wallpaperAlignment.setEntries(englishValues); } } wallpaperAlignment.setEntryValues(R.array.wallpaper_alignment_entry_values); // , ? ? ? ? SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(PreferenceActivity.this); boolean isEnabled = prefs.getBoolean(WallpaperAlignmentPreference.WALLPAPER_ALIGN_ENABLED, false); wallpaperAlignment.setEnabled(isEnabled); wallpaperPreference.setWallpaperAlignmentPreference(wallpaperAlignment); colorsScreen.addPreference(wallpaperAlignment); /* * */ /*bgPreferences.add( colorsScreen.addOption(profile.BackgroundOption, "backgroundColor") );*/ bgPreferences.setEnabled("".equals(profile.WallpaperOption.getValue())); Preference bcgColorPref = colorsScreen.addOption(profile.BackgroundOption, "backgroundColor"); wallpaperPreference.setBcgColorPreference(bcgColorPref); if (wallpaperPreference.getValue().length() != 0) bcgColorPref.setEnabled(false); colorsScreen.addOption(profile.HighlightingOption, "highlighting"); colorsScreen.addOption(profile.RegularTextOption, "text"); colorsScreen.addOption(profile.HyperlinkTextOption, "hyperlink"); colorsScreen.addOption(profile.VisitedHyperlinkTextOption, "hyperlinkVisited"); //colorsScreen.addOption(profile.FooterFillOption, "footer"); colorsScreen.addOption(profile.SelectionBackgroundOption, "selectionBackground"); colorsScreen.addOption(profile.SelectionForegroundOption, "selectionForeground"); // Colors SCREEN /*colorsScreen.addOption(profile.HighlightingOption, "highlighting"); colorsScreen.addOption(profile.RegularTextOption, "text"); colorsScreen.addOption(profile.HyperlinkTextOption, "hyperlink"); colorsScreen.addOption(profile.VisitedHyperlinkTextOption, "hyperlinkVisited"); colorsScreen.addOption(profile.FooterFillOption, "footer"); colorsScreen.addOption(profile.SelectionBackgroundOption, "selectionBackground"); colorsScreen.addOption(profile.SelectionForegroundOption, "selectionForeground");*/ //profile /* colorsScreen.addOption(profile.SelectionBackgroundOption, "selectionBackground"); colorsScreen.addOption(profile.HighlightingOption, "highlighting"); colorsScreen.addOption(profile.HyperlinkTextOption, "hyperlink"); colorsScreen.addOption(profile.VisitedHyperlinkTextOption, "hyperlinkVisited"); colorsScreen.addOption(profile.FooterFillOption, "footer"); colorsScreen.addOption(profile.SelectionBackgroundOption, "selectionBackground"); colorsScreen.addOption(profile.SelectionForegroundOption, "selectionForeground"); final Screen marginsScreen = createPreferenceScreen("margins"); marginsScreen.addPreference(new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("left"), fbReader.LeftMarginOption )); marginsScreen.addPreference(new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("right"), fbReader.RightMarginOption )); marginsScreen.addPreference(new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("top"), fbReader.TopMarginOption )); marginsScreen.addPreference(new ZLIntegerRangePreference( this, marginsScreen.Resource.getResource("bottom"), fbReader.BottomMarginOption )); final Screen statusLineScreen = createPreferenceScreen("scrollBar"); final String[] scrollBarTypes = {"hide", "show", "showAsProgress", "showAsFooter"}; statusLineScreen.addPreference(new ZLChoicePreference( this, statusLineScreen.Resource, "scrollbarType", fbReader.ScrollbarTypeOption, scrollBarTypes ) { @Override protected void onDialogClosed(boolean result) { super.onDialogClosed(result); footerPreferences.setEnabled( findIndexOfValue(getValue()) == FBView.SCROLLBAR_SHOW_AS_FOOTER ); } }); footerPreferences.add(statusLineScreen.addPreference(new ZLIntegerRangePreference( this, statusLineScreen.Resource.getResource("footerHeight"), fbReader.FooterHeightOption ))); footerPreferences.add(statusLineScreen.addOption(profile.FooterFillOption, "footerColor")); footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowTOCMarksOption, "tocMarks")); footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowClockOption, "showClock")); footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowBatteryOption, "showBattery")); footerPreferences.add(statusLineScreen.addOption(fbReader.FooterShowProgressOption, "showProgress")); footerPreferences.add(statusLineScreen.addPreference(new FontOption( this, statusLineScreen.Resource, "font", fbReader.FooterFontOption, false ))); footerPreferences.setEnabled( fbReader.ScrollbarTypeOption.getValue() == FBView.SCROLLBAR_SHOW_AS_FOOTER ); final Screen colorProfileScreen = createPreferenceScreen("colorProfile"); final ZLResource resource = colorProfileScreen.Resource; colorProfileScreen.setSummary(ColorProfilePreference.createTitle(resource, fbreader.getColorProfileName())); for (String key : ColorProfile.names()) { colorProfileScreen.addPreference(new ColorProfilePreference( this, fbreader, colorProfileScreen, key, ColorProfilePreference.createTitle(resource, key) )); } */ /* final Screen imagesScreen = createPreferenceScreen("images"); imagesScreen.addOption(fbReader.ImageTappingActionOption, "tappingAction"); imagesScreen.addOption(fbReader.FitImagesToScreenOption, "fitImagesToScreen"); imagesScreen.addOption(fbReader.ImageViewBackgroundOption, "backgroundColor"); final Screen cancelMenuScreen = createPreferenceScreen("cancelMenu"); cancelMenuScreen.addOption(fbReader.ShowLibraryInCancelMenuOption, "library"); cancelMenuScreen.addOption(fbReader.ShowNetworkLibraryInCancelMenuOption, "networkLibrary"); cancelMenuScreen.addOption(fbReader.ShowPreviousBookInCancelMenuOption, "previousBook"); cancelMenuScreen.addOption(fbReader.ShowPositionsInCancelMenuOption, "positions"); final String[] backKeyActions = { ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU }; cancelMenuScreen.addPreference(new ZLStringChoicePreference( this, cancelMenuScreen.Resource, "backKeyAction", keyBindings.getOption(KeyEvent.KEYCODE_BACK, false), backKeyActions )); final String[] backKeyLongPressActions = { ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU, ReaderApp.NoAction }; cancelMenuScreen.addPreference(new ZLStringChoicePreference( this, cancelMenuScreen.Resource, "backKeyLongPressAction", keyBindings.getOption(KeyEvent.KEYCODE_BACK, true), backKeyLongPressActions )); final Screen tipsScreen = createPreferenceScreen("tips"); tipsScreen.addOption(TipsManager.Instance().ShowTipsOption, "showTips"); final Screen aboutScreen = createPreferenceScreen("about"); aboutScreen.addPreference(new InfoPreference( this, aboutScreen.Resource.getResource("version").getValue(), androidLibrary.getFullVersionName() )); aboutScreen.addPreference(new UrlPreference(this, aboutScreen.Resource, "site")); aboutScreen.addPreference(new UrlPreference(this, aboutScreen.Resource, "email")); aboutScreen.addPreference(new UrlPreference(this, aboutScreen.Resource, "twitter")); */ } else { myScreen.removePreference(colorsScreen.myScreen); } //GENERAL Screen otherScreen = createPreferenceScreen("other"); otherScreen.addPreference( new ZLBooleanPreference(this, myReaderApp.DayNight, otherScreen.Resource, "daynightenable") { @Override protected void onClick() { super.onClick(); SharedPreferences settings = PreferenceManager .getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("daynightenable", isChecked()); editor.commit(); } }); dayNight = new TimePreference(this); dayNight.setEnabled(PreferenceManager.getDefaultSharedPreferences(getBaseContext()) .getBoolean("daynightenable", false)); otherScreen.addPreference(dayNight); //otherScreen.addOption(myReaderApp.EnableDoubleTapOption, "enableDoubleTapDetection"); final ScrollingPreferences scrollingPreferences = ScrollingPreferences.Instance(); final Screen scrollingScreen = createPreferenceScreenForScreen("scrolling", otherScreen); //AUTOPAGGINg scrollingScreen.addPreference(new ZLBooleanPreference(this, myReaderApp.AllowAutopaggingOption, GeneralScreen.Resource, "autoscrolling") { @Override protected void onClick() { super.onClick(); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences.Editor editor = settings.edit(); if (isChecked()) { FullReaderActivity.autopagingTimer = true; } else { FullReaderActivity.autopagingTimer = false; } editor.putBoolean("needToAutopaging", isChecked()); editor.commit(); } }); timePref = new TimeSwitchPreference(this); timePref.setEnabled(PreferenceManager.getDefaultSharedPreferences(getBaseContext()) .getBoolean("needToAutopaging", false)); scrollingScreen.addPreference(timePref); scrollingScreen.addOption(scrollingPreferences.FingerScrollingOption, "fingerScrolling"); /* final ZLPreferenceSet volumeKeysPreferences = new ZLPreferenceSet(); scrollingScreen.addPreference(new ZLCheckBoxPreference( this, scrollingScreen.Resource, "volumeKeys" ) { { setChecked(fbReader.hasActionForKey(KeyEvent.KEYCODE_VOLUME_UP, false)); } @Override protected void onClick() { super.onClick(); if (isChecked()) { keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_DOWN, false, ActionCode.VOLUME_KEY_SCROLL_FORWARD); keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_UP, false, ActionCode.VOLUME_KEY_SCROLL_BACK); } else { keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_DOWN, false, ReaderApp.NoAction); keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_UP, false, ReaderApp.NoAction); } volumeKeysPreferences.setEnabled(isChecked()); } }); volumeKeysPreferences.add(scrollingScreen.addPreference(new ZLCheckBoxPreference( this, scrollingScreen.Resource, "invertVolumeKeys" ) { { setChecked(ActionCode.VOLUME_KEY_SCROLL_FORWARD.equals( keyBindings.getBinding(KeyEvent.KEYCODE_VOLUME_UP, false) )); } @Override protected void onClick() { super.onClick(); if (isChecked()) { keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_DOWN, false, ActionCode.VOLUME_KEY_SCROLL_BACK); keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_UP, false, ActionCode.VOLUME_KEY_SCROLL_FORWARD); } else { keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_DOWN, false, ActionCode.VOLUME_KEY_SCROLL_FORWARD); keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_UP, false, ActionCode.VOLUME_KEY_SCROLL_BACK); } } })); volumeKeysPreferences.setEnabled(fbReader.hasActionForKey(KeyEvent.KEYCODE_VOLUME_UP, false)); */ scrollingScreen.addOption(scrollingPreferences.AnimationOption, "animation"); /*scrollingScreen.addPreference(new AnimationSpeedPreference( this, scrollingScreen.Resource, "animationSpeed", scrollingPreferences.AnimationSpeedOption ));*/ scrollingScreen.addOption(scrollingPreferences.HorizontalOption, "horizontal"); final Screen dictionaryScreen = createPreferenceScreenForScreen("dictionary", otherScreen); try { dictionaryScreen.addPreference(new DictionaryPreference(this, dictionaryScreen.Resource, "dictionary", DictionaryUtil.singleWordTranslatorOption(), DictionaryUtil.dictionaryInfos(this, true))); dictionaryScreen.addPreference(new DictionaryPreference(this, dictionaryScreen.Resource, "translator", DictionaryUtil.multiWordTranslatorOption(), DictionaryUtil.dictionaryInfos(this, false))); } catch (Exception e) { // ignore: dictionary lists are not initialized yet } dictionaryScreen.addPreference(new ZLBooleanPreference(this, myReaderApp.NavigateAllWordsOption, dictionaryScreen.Resource, "navigateOverAllWords")); //dictionaryScreen.addOption(myReaderApp.WordTappingActionOption, "tappingAction"); //initAdMob(); // ?? ? final Screen syncScreen = createPreferenceScreen("synchronization"); ZLBooleanOption DropboxSync = new ZLBooleanOption("Syncronization", "DropboxSync", false); mDbxBoolPref = new ZLBooleanPreference(this, DropboxSync, otherScreen.Resource, "synchronizationDropbox"); mDbxBoolPref.setupForDropbox(this); syncScreen.addPreference(mDbxBoolPref); /* * * ? ? - * */ tapScreen = createPreferenceScreen("tapzones"); ZLResource tapRes = ZLResource.resource("tapzones"); tapzonesListPrefs = new TapzonesListPreference(this); tapzonesListPrefs.setKey(TapzonesListPreference.TAPZONES_LIST_KEY); String[] entries = new String[] { tapRes.getResource("tapzone_horizontal").getValue(), tapRes.getResource("tapzone_vertical").getValue(), }; String[] entryValues = new String[] { TapzonesListPreference.TAPZONE_HORIZONTAL, TapzonesListPreference.TAPZONE_VERTICAL }; tapzonesListPrefs.setTitle(tapRes.getResource("tapzone_choose").getValue()); tapzonesListPrefs.setEntries(entries); tapzonesListPrefs.setEntryValues(entryValues); tapzonesListPrefs.setOnPreferenceChangeListener(tapListPrefChangeListener); tapScreen.addPreference(tapzonesListPrefs); // ? c ? ? horTapzoneCat = new PreferenceCategory(this); horTapzoneCat.setKey(HOR_TAPZONE_CAT); horTapzoneCat.setTitle(tapRes.getResource("tapzone_horisontal_category").getValue()); tapScreen.addPreference(horTapzoneCat); String[] tapzoneOptEntries = new String[] { tapRes.getResource("tapzone_next_page").getValue(), tapRes.getResource("tapzone_prev_page").getValue(), tapRes.getResource("tapzone_day_mode").getValue(), tapRes.getResource("tapzone_night_mode").getValue(), tapRes.getResource("tapzone_book_info").getValue(), tapRes.getResource("tapzone_bookmarks").getValue(), tapRes.getResource("tapzone_quotes").getValue(), tapRes.getResource("tapzone_preferences").getValue(), tapRes.getResource("tapzone_increase_font").getValue(), tapRes.getResource("tapzone_decrease_font").getValue(), tapRes.getResource("tapzone_contents").getValue(), tapRes.getResource("tapzone_search").getValue(), tapRes.getResource("tapzone_navigate").getValue(), tapRes.getResource("tapzone_close").getValue(), tapRes.getResource("tapzone_library").getValue(), tapRes.getResource("tapzone_menu").getValue(), tapRes.getResource("tapzone_colors").getValue(), tapRes.getResource("tapzone_next_book").getValue(), tapRes.getResource("tapzone_previous_book").getValue(), tapRes.getResource("tapzone_fullscreen").getValue() }; horTopPref = new TapzoneOptionsPreference(this); horTopPref.setKey(TapzoneOptionsPreference.TAPZONE_HOR_TOP_KEY); horTopPref.setTitle(tapRes.getResource("tapzone_top_touch").getValue()); horTopPref.setEntries(tapzoneOptEntries); horTopPref.setEntryValues(TAP_ACTIONS); horTopPref.setOnPreferenceChangeListener(tapOptionPrefChangeListener); horTapzoneCat.addPreference(horTopPref); horCenterPref = new TapzoneOptionsPreference(this); horCenterPref.setKey(TapzoneOptionsPreference.TAPZONE_HOR_CENTER_KEY); horCenterPref.setTitle(tapRes.getResource("tapzone_center_touch").getValue()); horCenterPref.setEntries(tapzoneOptEntries); horCenterPref.setEntryValues(TAP_ACTIONS); horCenterPref.setOnPreferenceChangeListener(tapOptionPrefChangeListener); horTapzoneCat.addPreference(horCenterPref); horBottomPref = new TapzoneOptionsPreference(this); horBottomPref.setKey(TapzoneOptionsPreference.TAPZONE_HOR_BOTTOM_KEY); horBottomPref.setTitle(tapRes.getResource("tapzone_bottom_touch").getValue()); horBottomPref.setEntries(tapzoneOptEntries); horBottomPref.setEntryValues(TAP_ACTIONS); horBottomPref.setOnPreferenceChangeListener(tapOptionPrefChangeListener); horTapzoneCat.addPreference(horBottomPref); // ? c ? ? verTapzoneCat = new PreferenceCategory(this); verTapzoneCat.setKey(VER_TAPZONE_CAT); verTapzoneCat.setTitle(tapRes.getResource("tapzone_vertical_category").getValue()); tapScreen.addPreference(verTapzoneCat); verLeftPref = new TapzoneOptionsPreference(this); verLeftPref.setKey(TapzoneOptionsPreference.TAPZONE_VER_LEFT_KEY); verLeftPref.setTitle(tapRes.getResource("tapzone_left_touch").getValue()); verLeftPref.setEntries(tapzoneOptEntries); verLeftPref.setEntryValues(TAP_ACTIONS); verLeftPref.setOnPreferenceChangeListener(tapOptionPrefChangeListener); verTapzoneCat.addPreference(verLeftPref); verCenterPref = new TapzoneOptionsPreference(this); verCenterPref.setKey(TapzoneOptionsPreference.TAPZONE_VER_CENTER_KEY); verCenterPref.setTitle(tapRes.getResource("tapzone_center_touch").getValue()); verCenterPref.setEntries(tapzoneOptEntries); verCenterPref.setEntryValues(TAP_ACTIONS); verCenterPref.setOnPreferenceChangeListener(tapOptionPrefChangeListener); verTapzoneCat.addPreference(verCenterPref); verRightPref = new TapzoneOptionsPreference(this); verRightPref.setKey(TapzoneOptionsPreference.TAPZONE_VER_RIGHT_KEY); verRightPref.setTitle(tapRes.getResource("tapzone_right_touch").getValue()); verRightPref.setEntries(tapzoneOptEntries); verRightPref.setEntryValues(TAP_ACTIONS); verRightPref.setOnPreferenceChangeListener(tapOptionPrefChangeListener); verTapzoneCat.addPreference(verRightPref); tapzoneDoubleTapPref = tapScreen.addOption(myReaderApp.EnableDoubleTapOption, "tapzoneDoubleTapDetection"); tapDefault = new CheckBoxPreference(this); tapDefault.setKey(tapDefaultKey); tapDefault.setSummary(tapRes.getResource("tapzone_default").getValue()); tapDefault.setOnPreferenceChangeListener(mTapDefaultChangeListener); tapDefault.setChecked(false); tapScreen.addPreference(tapDefault); // , ? ? ?? ? - // ?? , ? ?, ? SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); String selectedValue = settings.getString(TapzonesListPreference.TAPZONES_LIST_KEY, ""); if (selectedValue.equals(TapzonesListPreference.TAPZONE_HORIZONTAL)) { tapScreen.myScreen.removePreference(verTapzoneCat); initTapPrefs(selectedValue); } else if (selectedValue.equals(TapzonesListPreference.TAPZONE_VERTICAL)) { tapScreen.myScreen.removePreference(horTapzoneCat); initTapPrefs(selectedValue); } else { tapScreen.myScreen.removePreference(horTapzoneCat); tapScreen.myScreen.removePreference(verTapzoneCat); tapScreen.myScreen.removePreference(tapzoneDoubleTapPref); tapScreen.myScreen.removePreference(tapDefault); } // ? - ? ? ? if (showColorsScreen && profileName.equals(ColorProfile.DAY)) { runOnUiThread(new Runnable() { public void run() { PreferenceActivity.this.setPreferenceScreen((PreferenceScreen) colorsScreen.myScreen); } }); } } mPreferences = PreferenceManager.getDefaultSharedPreferences(this); }