mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
preferences code cleanup
This commit is contained in:
parent
76bc6da867
commit
15febb11af
17 changed files with 89 additions and 90 deletions
|
@ -325,23 +325,15 @@
|
||||||
<node name="summaryOn" value="Synchronise my library with FBReader book network server"/>
|
<node name="summaryOn" value="Synchronise my library with FBReader book network server"/>
|
||||||
<node name="summaryOff" value="Do not synchronise my library with FBReader book network server"/>
|
<node name="summaryOff" value="Do not synchronise my library with FBReader book network server"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="uploadAllBooks" value="Upload all books to server">
|
<node name="values">
|
||||||
<node name="always" value="Always"/>
|
<node name="always" value="Always"/>
|
||||||
<node name="viaWifi" value="If device is connected via Wi-Fi"/>
|
<node name="viaWifi" value="If device is connected via Wi-Fi"/>
|
||||||
<node name="never" value="Never"/>
|
<node name="never" value="Never"/>
|
||||||
</node>
|
</node>
|
||||||
<node name="positions" value="Reading positions">
|
<node name="uploadAllBooks" value="Upload all books to server"/>
|
||||||
<node name="summaryOn" value="Automatically synchronise reading positions"/>
|
<node name="positions" value="Reading positions"/>
|
||||||
<node name="summaryOff" value="Do not synchronise reading positions"/>
|
<node name="bookmarks" value="Bookmarks"/>
|
||||||
</node>
|
<node name="metainfo" value="Metainfo (title, tags, etc.)"/>
|
||||||
<node name="bookmarks" value="Bookamrks">
|
|
||||||
<node name="summaryOn" value="Automatically synchronise bookmarks"/>
|
|
||||||
<node name="summaryOff" value="Do not synchronise bookmarks"/>
|
|
||||||
</node>
|
|
||||||
<node name="metainfo" value="Metainfo (title, tags, etc.)">
|
|
||||||
<node name="summaryOn" value="Automatically synchronise book metainfo"/>
|
|
||||||
<node name="summaryOff" value="Do not synchronise book metainfo"/>
|
|
||||||
</node>
|
|
||||||
</node>
|
</node>
|
||||||
<node name="directories" value="Directories">
|
<node name="directories" value="Directories">
|
||||||
<node name="summary" value="Directories to seek for files"/>
|
<node name="summary" value="Directories to seek for files"/>
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
||||||
class BatteryLevelToTurnScreenOffPreference extends ZLStringListPreference {
|
class BatteryLevelToTurnScreenOffPreference extends ZLStringListPreference {
|
||||||
private final ZLIntegerRangeOption myOption;
|
private final ZLIntegerRangeOption myOption;
|
||||||
|
|
||||||
BatteryLevelToTurnScreenOffPreference(Context context, ZLIntegerRangeOption option, ZLResource rootResource, String resourceKey) {
|
BatteryLevelToTurnScreenOffPreference(Context context, ZLIntegerRangeOption option, ZLResource resource) {
|
||||||
super(context, rootResource, resourceKey);
|
super(context, resource);
|
||||||
myOption = option;
|
myOption = option;
|
||||||
String[] entries = { "0", "25", "50", "100" };
|
String[] entries = { "0", "25", "50", "100" };
|
||||||
setList(entries);
|
setList(entries);
|
||||||
|
|
|
@ -31,8 +31,8 @@ import org.geometerplus.android.fbreader.DictionaryUtil;
|
||||||
class DictionaryPreference extends ZLStringListPreference {
|
class DictionaryPreference extends ZLStringListPreference {
|
||||||
private final ZLStringOption myOption;
|
private final ZLStringOption myOption;
|
||||||
|
|
||||||
DictionaryPreference(Context context, ZLResource resource, String resourceKey, ZLStringOption dictionaryOption, List<DictionaryUtil.PackageInfo> infos) {
|
DictionaryPreference(Context context, ZLResource resource, ZLStringOption dictionaryOption, List<DictionaryUtil.PackageInfo> infos) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource);
|
||||||
|
|
||||||
myOption = dictionaryOption;
|
myOption = dictionaryOption;
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ class BookLanguagePreference extends LanguagePreference {
|
||||||
return new ArrayList<Language>(set);
|
return new ArrayList<Language>(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
BookLanguagePreference(Context context, ZLResource rootResource, String resourceKey, Book book) {
|
BookLanguagePreference(Context context, ZLResource resource, Book book) {
|
||||||
super(context, rootResource, resourceKey, languages());
|
super(context, resource, languages());
|
||||||
myBook = book;
|
myBook = book;
|
||||||
final String language = myBook.getLanguage();
|
final String language = myBook.getLanguage();
|
||||||
if (language == null || !setInitialValue(language)) {
|
if (language == null || !setInitialValue(language)) {
|
||||||
|
@ -91,8 +91,8 @@ class BookLanguagePreference extends LanguagePreference {
|
||||||
class EncodingPreference extends ZLStringListPreference {
|
class EncodingPreference extends ZLStringListPreference {
|
||||||
private final Book myBook;
|
private final Book myBook;
|
||||||
|
|
||||||
EncodingPreference(Context context, ZLResource rootResource, String resourceKey, Book book) {
|
EncodingPreference(Context context, ZLResource resource, Book book) {
|
||||||
super(context, rootResource, resourceKey);
|
super(context, resource);
|
||||||
myBook = book;
|
myBook = book;
|
||||||
|
|
||||||
final FormatPlugin plugin;
|
final FormatPlugin plugin;
|
||||||
|
@ -278,8 +278,8 @@ public class EditBookInfoActivity extends ZLPreferenceActivity {
|
||||||
addPreference(new BookTitlePreference(EditBookInfoActivity.this, Resource, "title", myBook));
|
addPreference(new BookTitlePreference(EditBookInfoActivity.this, Resource, "title", myBook));
|
||||||
myEditAuthorsPreference = (EditAuthorsPreference)addPreference(new EditAuthorsPreference(EditBookInfoActivity.this, Resource, "authors", myBook));
|
myEditAuthorsPreference = (EditAuthorsPreference)addPreference(new EditAuthorsPreference(EditBookInfoActivity.this, Resource, "authors", myBook));
|
||||||
myEditTagsPreference = (EditTagsPreference)addPreference(new EditTagsPreference(EditBookInfoActivity.this, Resource, "tags", myBook));
|
myEditTagsPreference = (EditTagsPreference)addPreference(new EditTagsPreference(EditBookInfoActivity.this, Resource, "tags", myBook));
|
||||||
addPreference(new BookLanguagePreference(EditBookInfoActivity.this, Resource, "language", myBook));
|
addPreference(new BookLanguagePreference(EditBookInfoActivity.this, Resource.getResource("language"), myBook));
|
||||||
addPreference(new EncodingPreference(EditBookInfoActivity.this, Resource, "encoding", myBook));
|
addPreference(new EncodingPreference(EditBookInfoActivity.this, Resource.getResource("encoding"), myBook));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ class FontPreference extends ZLStringListPreference implements ReloadablePrefere
|
||||||
|
|
||||||
private static String UNCHANGED = "inherit";
|
private static String UNCHANGED = "inherit";
|
||||||
|
|
||||||
FontPreference(Context context, ZLResource resource, String resourceKey, ZLStringOption option, boolean includeDummyValue) {
|
FontPreference(Context context, ZLResource resource, ZLStringOption option, boolean includeDummyValue) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource);
|
||||||
|
|
||||||
myOption = option;
|
myOption = option;
|
||||||
myIncludeDummyValue = includeDummyValue;
|
myIncludeDummyValue = includeDummyValue;
|
||||||
|
|
|
@ -29,8 +29,8 @@ class FontStylePreference extends ZLStringListPreference {
|
||||||
private final ZLBooleanOption myItalicOption;
|
private final ZLBooleanOption myItalicOption;
|
||||||
private final String[] myValues = { "regular", "bold", "italic", "boldItalic" };
|
private final String[] myValues = { "regular", "bold", "italic", "boldItalic" };
|
||||||
|
|
||||||
FontStylePreference(Context context, ZLResource resource, String resourceKey, ZLBooleanOption boldOption, ZLBooleanOption italicOption) {
|
FontStylePreference(Context context, ZLResource resource, ZLBooleanOption boldOption, ZLBooleanOption italicOption) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource);
|
||||||
|
|
||||||
myBoldOption = boldOption;
|
myBoldOption = boldOption;
|
||||||
myItalicOption = italicOption;
|
myItalicOption = italicOption;
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
abstract class LanguagePreference extends ZLStringListPreference {
|
abstract class LanguagePreference extends ZLStringListPreference {
|
||||||
LanguagePreference(
|
LanguagePreference(
|
||||||
Context context, ZLResource rootResource, String resourceKey, List<Language> languages
|
Context context, ZLResource resource, List<Language> languages
|
||||||
) {
|
) {
|
||||||
super(context, rootResource, resourceKey);
|
super(context, resource);
|
||||||
|
|
||||||
final int size = languages.size();
|
final int size = languages.size();
|
||||||
String[] codes = new String[size];
|
String[] codes = new String[size];
|
||||||
|
|
|
@ -138,15 +138,15 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
syncPreferences.run();
|
syncPreferences.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
syncPreferences.add(syncScreen.addOption(syncOptions.UploadAllBooks, "uploadAllBooks"));
|
syncPreferences.add(syncScreen.addOption(syncOptions.UploadAllBooks, "uploadAllBooks", "values"));
|
||||||
syncPreferences.add(syncScreen.addOption(syncOptions.Positions, "positions"));
|
syncPreferences.add(syncScreen.addOption(syncOptions.Positions, "positions", "values"));
|
||||||
//syncPreferences.add(syncScreen.addOption(syncOptions.Metainfo, "metainfo"));
|
//syncPreferences.add(syncScreen.addOption(syncOptions.Metainfo, "metainfo", "values"));
|
||||||
//syncPreferences.add(syncScreen.addOption(syncOptions.Bookmarks, "bookmarks"));
|
//syncPreferences.add(syncScreen.addOption(syncOptions.Bookmarks, "bookmarks", "values"));
|
||||||
syncPreferences.run();
|
syncPreferences.run();
|
||||||
|
|
||||||
final Screen appearanceScreen = createPreferenceScreen("appearance");
|
final Screen appearanceScreen = createPreferenceScreen("appearance");
|
||||||
appearanceScreen.addPreference(new LanguagePreference(
|
appearanceScreen.addPreference(new LanguagePreference(
|
||||||
this, appearanceScreen.Resource, "language", ZLResource.interfaceLanguages()
|
this, appearanceScreen.Resource.getResource("language"), ZLResource.interfaceLanguages()
|
||||||
) {
|
) {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -166,7 +166,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
appearanceScreen.addPreference(new ZLStringChoicePreference(
|
appearanceScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, appearanceScreen.Resource, "screenOrientation",
|
this, appearanceScreen.Resource.getResource("screenOrientation"),
|
||||||
androidLibrary.getOrientationOption(), androidLibrary.allOrientations()
|
androidLibrary.getOrientationOption(), androidLibrary.allOrientations()
|
||||||
));
|
));
|
||||||
appearanceScreen.addPreference(new ZLBooleanPreference(
|
appearanceScreen.addPreference(new ZLBooleanPreference(
|
||||||
|
@ -192,8 +192,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
appearanceScreen.addPreference(new BatteryLevelToTurnScreenOffPreference(
|
appearanceScreen.addPreference(new BatteryLevelToTurnScreenOffPreference(
|
||||||
this,
|
this,
|
||||||
androidLibrary.BatteryLevelToTurnScreenOffOption,
|
androidLibrary.BatteryLevelToTurnScreenOffOption,
|
||||||
appearanceScreen.Resource,
|
appearanceScreen.Resource.getResource("dontTurnScreenOff")
|
||||||
"dontTurnScreenOff"
|
|
||||||
));
|
));
|
||||||
/*
|
/*
|
||||||
appearanceScreen.addPreference(new ZLBooleanPreference(
|
appearanceScreen.addPreference(new ZLBooleanPreference(
|
||||||
|
@ -245,19 +244,16 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
|
|
||||||
final ZLTextBaseStyle baseStyle = collection.getBaseStyle();
|
final ZLTextBaseStyle baseStyle = collection.getBaseStyle();
|
||||||
|
|
||||||
final FontPreference fontPreference = new FontPreference(
|
fontReloader.add(textScreen.addPreference(new FontPreference(
|
||||||
this, textScreen.Resource, "font",
|
this, textScreen.Resource.getResource("font"),
|
||||||
baseStyle.FontFamilyOption, false
|
baseStyle.FontFamilyOption, false
|
||||||
);
|
)));
|
||||||
textScreen.addPreference(fontPreference);
|
|
||||||
fontReloader.add(fontPreference);
|
|
||||||
|
|
||||||
textScreen.addPreference(new ZLIntegerRangePreference(
|
textScreen.addPreference(new ZLIntegerRangePreference(
|
||||||
this, textScreen.Resource.getResource("fontSize"),
|
this, textScreen.Resource.getResource("fontSize"),
|
||||||
baseStyle.FontSizeOption
|
baseStyle.FontSizeOption
|
||||||
));
|
));
|
||||||
textScreen.addPreference(new FontStylePreference(
|
textScreen.addPreference(new FontStylePreference(
|
||||||
this, textScreen.Resource, "fontStyle",
|
this, textScreen.Resource.getResource("fontStyle"),
|
||||||
baseStyle.BoldOption, baseStyle.ItalicOption
|
baseStyle.BoldOption, baseStyle.ItalicOption
|
||||||
));
|
));
|
||||||
final ZLIntegerRangeOption spaceOption = baseStyle.LineSpaceOption;
|
final ZLIntegerRangeOption spaceOption = baseStyle.LineSpaceOption;
|
||||||
|
@ -267,12 +263,12 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
spacings[i] = (char)(val / 10 + '0') + decimalSeparator + (char)(val % 10 + '0');
|
spacings[i] = (char)(val / 10 + '0') + decimalSeparator + (char)(val % 10 + '0');
|
||||||
}
|
}
|
||||||
textScreen.addPreference(new ZLChoicePreference(
|
textScreen.addPreference(new ZLChoicePreference(
|
||||||
this, textScreen.Resource, "lineSpacing",
|
this, textScreen.Resource.getResource("lineSpacing"),
|
||||||
spaceOption, spacings
|
spaceOption, spacings
|
||||||
));
|
));
|
||||||
final String[] alignments = { "left", "right", "center", "justify" };
|
final String[] alignments = { "left", "right", "center", "justify" };
|
||||||
textScreen.addPreference(new ZLChoicePreference(
|
textScreen.addPreference(new ZLChoicePreference(
|
||||||
this, textScreen.Resource, "alignment",
|
this, textScreen.Resource.getResource("alignment"),
|
||||||
baseStyle.AlignmentOption, alignments
|
baseStyle.AlignmentOption, alignments
|
||||||
));
|
));
|
||||||
textScreen.addOption(baseStyle.AutoHyphenationOption, "autoHyphenations");
|
textScreen.addOption(baseStyle.AutoHyphenationOption, "autoHyphenations");
|
||||||
|
@ -281,7 +277,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
for (ZLTextNGStyleDescription description : collection.getDescriptionList()) {
|
for (ZLTextNGStyleDescription description : collection.getDescriptionList()) {
|
||||||
final Screen ngScreen = moreStylesScreen.createPreferenceScreen(description.Name);
|
final Screen ngScreen = moreStylesScreen.createPreferenceScreen(description.Name);
|
||||||
ngScreen.addPreference(new FontPreference(
|
ngScreen.addPreference(new FontPreference(
|
||||||
this, textScreen.Resource, "font",
|
this, textScreen.Resource.getResource("font"),
|
||||||
description.FontFamilyOption, true
|
description.FontFamilyOption, true
|
||||||
));
|
));
|
||||||
ngScreen.addPreference(new StringPreference(
|
ngScreen.addPreference(new StringPreference(
|
||||||
|
@ -290,27 +286,27 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
textScreen.Resource, "fontSize"
|
textScreen.Resource, "fontSize"
|
||||||
));
|
));
|
||||||
ngScreen.addPreference(new ZLStringChoicePreference(
|
ngScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, textScreen.Resource, "bold",
|
this, textScreen.Resource.getResource("bold"),
|
||||||
description.FontWeightOption,
|
description.FontWeightOption,
|
||||||
new String[] { "inherit", "normal", "bold" }
|
new String[] { "inherit", "normal", "bold" }
|
||||||
));
|
));
|
||||||
ngScreen.addPreference(new ZLStringChoicePreference(
|
ngScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, textScreen.Resource, "italic",
|
this, textScreen.Resource.getResource("italic"),
|
||||||
description.FontStyleOption,
|
description.FontStyleOption,
|
||||||
new String[] { "inherit", "normal", "italic" }
|
new String[] { "inherit", "normal", "italic" }
|
||||||
));
|
));
|
||||||
ngScreen.addPreference(new ZLStringChoicePreference(
|
ngScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, textScreen.Resource, "textDecoration",
|
this, textScreen.Resource.getResource("textDecoration"),
|
||||||
description.TextDecorationOption,
|
description.TextDecorationOption,
|
||||||
new String[] { "inherit", "none", "underline", "line-through" }
|
new String[] { "inherit", "none", "underline", "line-through" }
|
||||||
));
|
));
|
||||||
ngScreen.addPreference(new ZLStringChoicePreference(
|
ngScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, textScreen.Resource, "allowHyphenations",
|
this, textScreen.Resource.getResource("allowHyphenations"),
|
||||||
description.HyphenationOption,
|
description.HyphenationOption,
|
||||||
new String[] { "inherit", "none", "auto" }
|
new String[] { "inherit", "none", "auto" }
|
||||||
));
|
));
|
||||||
ngScreen.addPreference(new ZLStringChoicePreference(
|
ngScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, textScreen.Resource, "alignment",
|
this, textScreen.Resource.getResource("alignment"),
|
||||||
description.AlignmentOption,
|
description.AlignmentOption,
|
||||||
new String[] { "inherit", "left", "right", "center", "justify" }
|
new String[] { "inherit", "left", "right", "center", "justify" }
|
||||||
));
|
));
|
||||||
|
@ -373,7 +369,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
final Screen colorsScreen = createPreferenceScreen("colors");
|
final Screen colorsScreen = createPreferenceScreen("colors");
|
||||||
|
|
||||||
final WallpaperPreference wallpaperPreference = new WallpaperPreference(
|
final WallpaperPreference wallpaperPreference = new WallpaperPreference(
|
||||||
this, profile, colorsScreen.Resource, "background"
|
this, profile, colorsScreen.Resource.getResource("background")
|
||||||
) {
|
) {
|
||||||
@Override
|
@Override
|
||||||
protected void onDialogClosed(boolean result) {
|
protected void onDialogClosed(boolean result) {
|
||||||
|
@ -422,7 +418,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
|
|
||||||
final String[] scrollBarTypes = {"hide", "show", "showAsProgress", "showAsFooter"};
|
final String[] scrollBarTypes = {"hide", "show", "showAsProgress", "showAsFooter"};
|
||||||
statusLineScreen.addPreference(new ZLChoicePreference(
|
statusLineScreen.addPreference(new ZLChoicePreference(
|
||||||
this, statusLineScreen.Resource, "scrollbarType",
|
this, statusLineScreen.Resource.getResource("scrollbarType"),
|
||||||
viewOptions.ScrollbarType, scrollBarTypes
|
viewOptions.ScrollbarType, scrollBarTypes
|
||||||
) {
|
) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -443,7 +439,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowClock, "showClock"));
|
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowClock, "showClock"));
|
||||||
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowBattery, "showBattery"));
|
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowBattery, "showBattery"));
|
||||||
footerPreferences.add(statusLineScreen.addPreference(new FontPreference(
|
footerPreferences.add(statusLineScreen.addPreference(new FontPreference(
|
||||||
this, statusLineScreen.Resource, "font",
|
this, statusLineScreen.Resource.getResource("font"),
|
||||||
footerOptions.Font, false
|
footerOptions.Font, false
|
||||||
)));
|
)));
|
||||||
footerPreferences.run();
|
footerPreferences.run();
|
||||||
|
@ -533,7 +529,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
Language.ANY_CODE, dictionaryScreen.Resource.getResource("targetLanguage")
|
Language.ANY_CODE, dictionaryScreen.Resource.getResource("targetLanguage")
|
||||||
));
|
));
|
||||||
final LanguagePreference targetLanguagePreference = new LanguagePreference(
|
final LanguagePreference targetLanguagePreference = new LanguagePreference(
|
||||||
this, dictionaryScreen.Resource, "targetLanguage", languages
|
this, dictionaryScreen.Resource.getResource("targetLanguage"), languages
|
||||||
) {
|
) {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -550,8 +546,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
public void run() {
|
public void run() {
|
||||||
dictionaryScreen.addPreference(new DictionaryPreference(
|
dictionaryScreen.addPreference(new DictionaryPreference(
|
||||||
PreferenceActivity.this,
|
PreferenceActivity.this,
|
||||||
dictionaryScreen.Resource,
|
dictionaryScreen.Resource.getResource("dictionary"),
|
||||||
"dictionary",
|
|
||||||
DictionaryUtil.singleWordTranslatorOption(),
|
DictionaryUtil.singleWordTranslatorOption(),
|
||||||
DictionaryUtil.dictionaryInfos(PreferenceActivity.this, true)
|
DictionaryUtil.dictionaryInfos(PreferenceActivity.this, true)
|
||||||
) {
|
) {
|
||||||
|
@ -565,8 +560,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
});
|
});
|
||||||
dictionaryScreen.addPreference(new DictionaryPreference(
|
dictionaryScreen.addPreference(new DictionaryPreference(
|
||||||
PreferenceActivity.this,
|
PreferenceActivity.this,
|
||||||
dictionaryScreen.Resource,
|
dictionaryScreen.Resource.getResource("translator"),
|
||||||
"translator",
|
|
||||||
DictionaryUtil.multiWordTranslatorOption(),
|
DictionaryUtil.multiWordTranslatorOption(),
|
||||||
DictionaryUtil.dictionaryInfos(PreferenceActivity.this, false)
|
DictionaryUtil.dictionaryInfos(PreferenceActivity.this, false)
|
||||||
));
|
));
|
||||||
|
@ -599,13 +593,13 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
final String[] backKeyActions =
|
final String[] backKeyActions =
|
||||||
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU };
|
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU };
|
||||||
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, cancelMenuScreen.Resource, "backKeyAction",
|
this, cancelMenuScreen.Resource.getResource("backKeyAction"),
|
||||||
keyBindings.getOption(KeyEvent.KEYCODE_BACK, false), backKeyActions
|
keyBindings.getOption(KeyEvent.KEYCODE_BACK, false), backKeyActions
|
||||||
));
|
));
|
||||||
final String[] backKeyLongPressActions =
|
final String[] backKeyLongPressActions =
|
||||||
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU, FBReaderApp.NoAction };
|
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU, FBReaderApp.NoAction };
|
||||||
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, cancelMenuScreen.Resource, "backKeyLongPressAction",
|
this, cancelMenuScreen.Resource.getResource("backKeyLongPressAction"),
|
||||||
keyBindings.getOption(KeyEvent.KEYCODE_BACK, true), backKeyLongPressActions
|
keyBindings.getOption(KeyEvent.KEYCODE_BACK, true), backKeyLongPressActions
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ import org.geometerplus.fbreader.fbreader.options.ColorProfile;
|
||||||
class WallpaperPreference extends ZLStringListPreference implements ReloadablePreference {
|
class WallpaperPreference extends ZLStringListPreference implements ReloadablePreference {
|
||||||
private final ZLStringOption myOption;
|
private final ZLStringOption myOption;
|
||||||
|
|
||||||
WallpaperPreference(Context context, ColorProfile profile, ZLResource resource, String resourceKey) {
|
WallpaperPreference(Context context, ColorProfile profile, ZLResource resource) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource);
|
||||||
myOption = profile.WallpaperOption;
|
myOption = profile.WallpaperOption;
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
|
@ -49,12 +49,12 @@ class WallpaperPreference extends ZLStringListPreference implements ReloadablePr
|
||||||
final String[] texts = new String[size];
|
final String[] texts = new String[size];
|
||||||
|
|
||||||
values[0] = "";
|
values[0] = "";
|
||||||
texts[0] = myResource.getResource("solidColor").getValue();
|
texts[0] = myValuesResource.getResource("solidColor").getValue();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
for (ZLFile f : predefined) {
|
for (ZLFile f : predefined) {
|
||||||
values[index] = f.getPath();
|
values[index] = f.getPath();
|
||||||
final String name = f.getShortName();
|
final String name = f.getShortName();
|
||||||
texts[index] = myResource.getResource(
|
texts[index] = myValuesResource.getResource(
|
||||||
name.substring(0, name.indexOf("."))
|
name.substring(0, name.indexOf("."))
|
||||||
).getValue();
|
).getValue();
|
||||||
++index;
|
++index;
|
||||||
|
|
|
@ -32,8 +32,8 @@ class ZLBoolean3Preference extends ZLStringListPreference {
|
||||||
|
|
||||||
private final ZLBoolean3Option myOption;
|
private final ZLBoolean3Option myOption;
|
||||||
|
|
||||||
ZLBoolean3Preference(Context context, ZLResource resource, String resourceKey, ZLBoolean3Option option) {
|
ZLBoolean3Preference(Context context, ZLResource resource, ZLBoolean3Option option) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource);
|
||||||
|
|
||||||
myOption = option;
|
myOption = option;
|
||||||
setList(new String[] { ON, OFF, UNCHANGED });
|
setList(new String[] { ON, OFF, UNCHANGED });
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
class ZLChoicePreference extends ZLStringListPreference {
|
class ZLChoicePreference extends ZLStringListPreference {
|
||||||
private final ZLIntegerRangeOption myOption;
|
private final ZLIntegerRangeOption myOption;
|
||||||
|
|
||||||
ZLChoicePreference(Context context, ZLResource resource, String resourceKey, ZLIntegerRangeOption option, String[] valueResourceKeys) {
|
ZLChoicePreference(Context context, ZLResource resource, ZLIntegerRangeOption option, String[] valueResourceKeys) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource);
|
||||||
|
|
||||||
assert(option.MaxValue - option.MinValue + 1 == valueResourceKeys.length);
|
assert(option.MaxValue - option.MinValue + 1 == valueResourceKeys.length);
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,12 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
class ZLEnumPreference<T extends Enum<T>> extends ZLStringListPreference {
|
class ZLEnumPreference<T extends Enum<T>> extends ZLStringListPreference {
|
||||||
private final ZLEnumOption<T> myOption;
|
private final ZLEnumOption<T> myOption;
|
||||||
|
|
||||||
ZLEnumPreference(Context context, ZLEnumOption<T> option, ZLResource resource, String resourceKey) {
|
ZLEnumPreference(Context context, ZLEnumOption<T> option, ZLResource resource) {
|
||||||
super(context, resource, resourceKey);
|
this(context, option, resource, resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZLEnumPreference(Context context, ZLEnumOption<T> option, ZLResource resource, ZLResource valuesResource) {
|
||||||
|
super(context, resource, valuesResource);
|
||||||
myOption = option;
|
myOption = option;
|
||||||
|
|
||||||
final T initialValue = option.getValue();
|
final T initialValue = option.getValue();
|
||||||
|
|
|
@ -28,8 +28,8 @@ class ZLIntegerChoicePreference extends ZLStringListPreference {
|
||||||
private final ZLIntegerOption myOption;
|
private final ZLIntegerOption myOption;
|
||||||
private final int[] myValues;
|
private final int[] myValues;
|
||||||
|
|
||||||
ZLIntegerChoicePreference(Context context, ZLResource resource, String resourceKey, ZLIntegerOption option, int[] values, String[] valueResourceKeys) {
|
ZLIntegerChoicePreference(Context context, ZLResource resource, ZLIntegerOption option, int[] values, String[] valueResourceKeys) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource);
|
||||||
assert(values.length == valueResourceKeys.length);
|
assert(values.length == valueResourceKeys.length);
|
||||||
|
|
||||||
myOption = option;
|
myOption = option;
|
||||||
|
|
|
@ -73,9 +73,15 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Enum<T>> Preference addOption(ZLEnumOption<T> option, String resourceKey) {
|
public <T extends Enum<T>> Preference addOption(ZLEnumOption<T> option, String key) {
|
||||||
return addPreference(
|
return addPreference(
|
||||||
new ZLEnumPreference<T>(ZLPreferenceActivity.this, option, Resource, resourceKey)
|
new ZLEnumPreference<T>(ZLPreferenceActivity.this, option, Resource.getResource(key))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Enum<T>> Preference addOption(ZLEnumOption<T> option, String key, String valuesKey) {
|
||||||
|
return addPreference(
|
||||||
|
new ZLEnumPreference<T>(ZLPreferenceActivity.this, option, Resource.getResource(key), Resource.getResource(valuesKey))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
class ZLStringChoicePreference extends ZLStringListPreference {
|
class ZLStringChoicePreference extends ZLStringListPreference {
|
||||||
private final ZLStringOption myOption;
|
private final ZLStringOption myOption;
|
||||||
|
|
||||||
ZLStringChoicePreference(Context context, ZLResource rootResource, String resourceKey, ZLStringOption option, String[] values) {
|
ZLStringChoicePreference(Context context, ZLResource resource, ZLStringOption option, String[] values) {
|
||||||
super(context, rootResource, resourceKey);
|
super(context, resource);
|
||||||
setList(values);
|
setList(values);
|
||||||
setInitialValue(option.getValue());
|
setInitialValue(option.getValue());
|
||||||
myOption = option;
|
myOption = option;
|
||||||
|
|
|
@ -25,19 +25,22 @@ import android.preference.ListPreference;
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
|
||||||
abstract class ZLStringListPreference extends ListPreference {
|
abstract class ZLStringListPreference extends ListPreference {
|
||||||
protected final ZLResource myResource;
|
protected final ZLResource myValuesResource;
|
||||||
|
|
||||||
ZLStringListPreference(Context context, ZLResource rootResource, String resourceKey) {
|
ZLStringListPreference(Context context, ZLResource resource) {
|
||||||
|
this(context, resource, resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZLStringListPreference(Context context, ZLResource resource, ZLResource valuesResource) {
|
||||||
super(context);
|
super(context);
|
||||||
|
setTitle(resource.getValue());
|
||||||
myResource = rootResource.getResource(resourceKey);
|
myValuesResource = valuesResource;
|
||||||
setTitle(myResource.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void setList(String[] values) {
|
protected final void setList(String[] values) {
|
||||||
String[] texts = new String[values.length];
|
String[] texts = new String[values.length];
|
||||||
for (int i = 0; i < values.length; ++i) {
|
for (int i = 0; i < values.length; ++i) {
|
||||||
final ZLResource resource = myResource.getResource(values[i]);
|
final ZLResource resource = myValuesResource.getResource(values[i]);
|
||||||
texts[i] = resource.hasValue() ? resource.getValue() : values[i];
|
texts[i] = resource.hasValue() ? resource.getValue() : values[i];
|
||||||
}
|
}
|
||||||
setLists(values, texts);
|
setLists(values, texts);
|
||||||
|
|
|
@ -30,10 +30,10 @@ public class SyncOptions {
|
||||||
}
|
}
|
||||||
public final ZLEnumOption<SyncCondition> UploadAllBooks =
|
public final ZLEnumOption<SyncCondition> UploadAllBooks =
|
||||||
new ZLEnumOption<SyncCondition>("Sync", "UploadAllBooks", SyncCondition.viaWifi);
|
new ZLEnumOption<SyncCondition>("Sync", "UploadAllBooks", SyncCondition.viaWifi);
|
||||||
public final ZLBooleanOption Positions =
|
public final ZLEnumOption<SyncCondition> Positions =
|
||||||
new ZLBooleanOption("Sync", "Positions", true);
|
new ZLEnumOption<SyncCondition>("Sync", "Positions", SyncCondition.always);
|
||||||
public final ZLBooleanOption Bookmarks =
|
public final ZLEnumOption<SyncCondition> Bookmarks =
|
||||||
new ZLBooleanOption("Sync", "Bookmarks", true);
|
new ZLEnumOption<SyncCondition>("Sync", "Bookmarks", SyncCondition.always);
|
||||||
public final ZLBooleanOption Metainfo =
|
public final ZLEnumOption<SyncCondition> Metainfo =
|
||||||
new ZLBooleanOption("Sync", "Metainfo", true);
|
new ZLEnumOption<SyncCondition>("Sync", "Metainfo", SyncCondition.always);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue