diff --git a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java index 0bfb423d8..a16fb8423 100644 --- a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java +++ b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java @@ -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( diff --git a/src/org/geometerplus/fbreader/fbreader/FBView.java b/src/org/geometerplus/fbreader/fbreader/FBView.java index 98b748403..bb88d2258 100644 --- a/src/org/geometerplus/fbreader/fbreader/FBView.java +++ b/src/org/geometerplus/fbreader/fbreader/FBView.java @@ -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 myFontEntry; private Map myHeightMap = new HashMap(); private Map myCharHeightMap = new HashMap(); diff --git a/src/org/geometerplus/fbreader/fbreader/options/FooterOptions.java b/src/org/geometerplus/fbreader/fbreader/options/FooterOptions.java index d11c06398..4c9d6da95 100644 --- a/src/org/geometerplus/fbreader/fbreader/options/FooterOptions.java +++ b/src/org/geometerplus/fbreader/fbreader/options/FooterOptions.java @@ -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 +} \ No newline at end of file