1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 09:49:19 +02:00

Collapse "show pages" and "show percentage" into a list of options

This simplifies the UI some what.
This commit is contained in:
Danie Roux 2015-08-23 21:42:30 +02:00
parent ef56e2e140
commit e15f54582b
3 changed files with 59 additions and 20 deletions

View file

@ -557,8 +557,12 @@ public class PreferenceActivity extends ZLPreferenceActivity {
newStyleFooterPreferences.add(statusLineScreen.addOption(profile.FooterNGForegroundUnreadOption, "footerForegroundUnreadColor"));
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowTOCMarks, "tocMarks"));
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowProgress, "showProgress"));
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowProgressAsPercentage, "showProgressAsPercentage"));
statusLineScreen.addPreference(new ZLChoicePreference(
this, statusLineScreen.Resource.getResource("showProgressTypes"),
footerOptions.ShowProgressType, footerOptions.getProgressValueResourceKeys()
));
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowClock, "showClock"));
footerPreferences.add(statusLineScreen.addOption(footerOptions.ShowBattery, "showBattery"));
footerPreferences.add(statusLineScreen.addPreference(new FontPreference(

View file

@ -531,25 +531,24 @@ public final class FBView extends ZLTextView {
protected String buildInfoString(PagePosition pagePosition, String separator) {
final StringBuilder info = new StringBuilder();
final FooterOptions footerOptions = myViewOptions.getFooterOptions();
if (footerOptions.ShowProgress.getValue()) {
if (footerOptions.ShowProgressAsPercentage.getValue()) {
info.append(pagePosition.getPercentageString());
} else {
info.append(pagePosition.Current);
info.append("/");
info.append(pagePosition.Total);
}
if (footerOptions.showProgressAsPages()) {
maybeAddSeparator(separator, info);
info.append(pagePosition.Current);
info.append("/");
info.append(pagePosition.Total);
}
if (footerOptions.showProgressAsPercentage()) {
maybeAddSeparator(separator, info);
info.append(pagePosition.getPercentageString());
}
if (footerOptions.ShowClock.getValue()) {
if (info.length() > 0) {
info.append(separator);
}
maybeAddSeparator(separator, info);
info.append(ZLibrary.Instance().getCurrentTimeString());
}
if (footerOptions.ShowBattery.getValue()) {
if (info.length() > 0) {
info.append(separator);
}
maybeAddSeparator(separator, info);
info.append("");
info.append(myReader.getBatteryLevel());
info.append("%");
@ -557,6 +556,12 @@ public final class FBView extends ZLTextView {
return info.toString();
}
private void maybeAddSeparator(String separator, StringBuilder info) {
if (info.length() > 0) {
info.append(separator);
}
}
private List<FontEntry> myFontEntry;
private Map<String,Integer> myHeightMap = new HashMap<String,Integer>();
private Map<String,Integer> myCharHeightMap = new HashMap<String,Integer>();

View file

@ -25,16 +25,46 @@ public class FooterOptions {
public final ZLBooleanOption ShowTOCMarks;
public final ZLBooleanOption ShowClock;
public final ZLBooleanOption ShowBattery;
public final ZLBooleanOption ShowProgress;
public final ZLBooleanOption ShowProgressAsPercentage;
public final ZLIntegerRangeOption ShowProgressType;
public final ZLStringOption Font;
public FooterOptions() {
ShowTOCMarks = new ZLBooleanOption("Options", "FooterShowTOCMarks", true);
ShowClock = new ZLBooleanOption("Options", "ShowClockInFooter", true);
ShowBattery = new ZLBooleanOption("Options", "ShowBatteryInFooter", true);
ShowProgress = new ZLBooleanOption("Options", "ShowProgressInFooter", true);
ShowProgressAsPercentage = new ZLBooleanOption("Options", "ShowProgressInFooterAsPercentage", false);
Font = new ZLStringOption("Options", "FooterFont", "Droid Sans");
ShowProgressType = new ZLIntegerRangeOption("Options", "ShowProgressType", 0, 4, ProgressTypes.showProgressAsPages.ordinal());
}
public boolean showProgressAsPercentage() {
return ShowProgressType.getValue() == ProgressTypes.showProgressAsPercentage.ordinal() ||
ShowProgressType.getValue() == ProgressTypes.showProgressAsBoth.ordinal();
}
public boolean showProgressAsPages() {
return ShowProgressType.getValue() == ProgressTypes.showProgressAsPages.ordinal() ||
ShowProgressType.getValue() == ProgressTypes.showProgressAsBoth.ordinal();
}
public String[] getProgressValueResourceKeys() {
ProgressTypes[] progressTypes = ProgressTypes.values();
String[] resourceKeys = new String[progressTypes.length];
for (int i = 0; i < progressTypes.length; i++) {
resourceKeys[i] = progressTypes[i].name();
}
return resourceKeys;
}
}
enum ProgressTypes {
hide,
showProgressAsPages,
showProgressAsPercentage,
showProgressAsBoth
}