Enum values extracted as resources.

This commit is contained in:
GaidamakUA 2015-12-25 12:42:56 +02:00
parent 08f3a64a21
commit 56c3ff9ecd
3 changed files with 37 additions and 7 deletions

View file

@ -2141,4 +2141,9 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="update_time">Update time</string> <string name="update_time">Update time</string>
<string name="updates_size_pattern">"Updates: %s"</string> <string name="updates_size_pattern">"Updates: %s"</string>
<string name="last_map_change">"Last map change: %s"</string> <string name="last_map_change">"Last map change: %s"</string>
<string name="hourly">Hourly</string>
<string name="daily">Daily</string>
<string name="weekly">Weekly</string>
<string name="morning">Morning</string>
<string name="Night">Night</string>
</resources> </resources>

View file

@ -310,9 +310,9 @@ public class LiveUpdatesFragment extends Fragment {
final UpdateFrequency frequency = UpdateFrequency.values()[frequencyId]; final UpdateFrequency frequency = UpdateFrequency.values()[frequencyId];
final TimeOfDay timeOfDay = TimeOfDay.values()[timeOfDateToUpdateId]; final TimeOfDay timeOfDay = TimeOfDay.values()[timeOfDateToUpdateId];
subheaderTextView.setVisibility(View.VISIBLE); subheaderTextView.setVisibility(View.VISIBLE);
String subheaderText = frequency.toString(); String subheaderText = fragment.getString(frequency.getLocalizedId());
if (frequency != UpdateFrequency.HOURLY) { if (frequency != UpdateFrequency.HOURLY) {
subheaderText += "" + timeOfDay.toString(); subheaderText += "" + fragment.getString(timeOfDay.getLocalizedId());
} }
subheaderTextView.setText(subheaderText); subheaderTextView.setText(subheaderText);
subheaderTextView.setTextColor(fragment.getActivity().getResources() subheaderTextView.setTextColor(fragment.getActivity().getResources()

View file

@ -3,6 +3,7 @@ package net.osmand.plus.liveupdates;
import android.content.Context; import android.content.Context;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.OsmandActionBarActivity; import net.osmand.plus.activities.OsmandActionBarActivity;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
@ -65,13 +66,37 @@ public class LiveUpdatesHelper {
} }
public static enum TimeOfDay { public static enum TimeOfDay {
MORNING, MORNING(R.string.morning),
NIGHT 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 { public enum UpdateFrequency {
HOURLY, HOURLY(R.string.hourly),
DAILY, DAILY(R.string.daily),
WEEKLY WEEKLY(R.string.weekly);
private final int localizedId;
UpdateFrequency(int localizedId) {
this.localizedId = localizedId;
}
public int getLocalizedId() {
return localizedId;
}
} }
} }