From 56c3ff9ecd7d7988212372a80579a1bed5e6a4be Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 25 Dec 2015 12:42:56 +0200 Subject: [PATCH] Enum values extracted as resources. --- OsmAnd/res/values/strings.xml | 5 +++ .../plus/liveupdates/LiveUpdatesFragment.java | 4 +-- .../plus/liveupdates/LiveUpdatesHelper.java | 35 ++++++++++++++++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index a53f337c6d..b93ad0eaf4 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2141,4 +2141,9 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A Update time "Updates: %s" "Last map change: %s" + Hourly + Daily + Weekly + Morning + Night \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index 2d412e1d9d..3104caf091 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -310,9 +310,9 @@ public class LiveUpdatesFragment extends Fragment { final UpdateFrequency frequency = UpdateFrequency.values()[frequencyId]; final TimeOfDay timeOfDay = TimeOfDay.values()[timeOfDateToUpdateId]; subheaderTextView.setVisibility(View.VISIBLE); - String subheaderText = frequency.toString(); + String subheaderText = fragment.getString(frequency.getLocalizedId()); if (frequency != UpdateFrequency.HOURLY) { - subheaderText += " • " + timeOfDay.toString(); + subheaderText += " • " + fragment.getString(timeOfDay.getLocalizedId()); } subheaderTextView.setText(subheaderText); subheaderTextView.setTextColor(fragment.getActivity().getResources() diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java index 4b57f7a47b..a8034fdcd8 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java @@ -3,6 +3,7 @@ package net.osmand.plus.liveupdates; import android.content.Context; import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.helpers.FileNameTranslationHelper; @@ -65,13 +66,37 @@ public class LiveUpdatesHelper { } public static enum TimeOfDay { - MORNING, - NIGHT + MORNING(R.string.morning), + NIGHT(R.string.Night); + private final int localizedId; + + TimeOfDay(int localizedId) { + this.localizedId = localizedId; + } + + public int getLocalizedId() { + return localizedId; + } + + + @Override + public String toString() { + return super.toString(); + } } public enum UpdateFrequency { - HOURLY, - DAILY, - WEEKLY + HOURLY(R.string.hourly), + DAILY(R.string.daily), + WEEKLY(R.string.weekly); + private final int localizedId; + + UpdateFrequency(int localizedId) { + this.localizedId = localizedId; + } + + public int getLocalizedId() { + return localizedId; + } } }