From cf28a8c0ef058c48aedc5f7c8345d7abed55cf23 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Wed, 26 Jan 2022 08:28:02 +0100 Subject: [PATCH] [android] Format OSM data version in local format Signed-off-by: Alexander Borsuk --- android/res/layout/about.xml | 2 +- .../mapswithme/maps/help/HelpFragment.java | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/android/res/layout/about.xml b/android/res/layout/about.xml index 1c978e85e7..5754cd577a 100644 --- a/android/res/layout/about.xml +++ b/android/res/layout/about.xml @@ -48,7 +48,7 @@ android:textAppearance="@style/MwmTextAppearance.Body2" android:textIsSelectable="true" android:selectAllOnFocus="true" - tools:text="Data: 151215" /> + tools:text="OpenStreetMap Data: 3 January 2022" /> diff --git a/android/src/com/mapswithme/maps/help/HelpFragment.java b/android/src/com/mapswithme/maps/help/HelpFragment.java index 3fed5071d5..c1073ccb4d 100644 --- a/android/src/com/mapswithme/maps/help/HelpFragment.java +++ b/android/src/com/mapswithme/maps/help/HelpFragment.java @@ -1,10 +1,8 @@ package com.mapswithme.maps.help; - import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -22,6 +20,8 @@ import com.mapswithme.util.Constants; import com.mapswithme.util.Graphics; import com.mapswithme.util.Utils; +import java.text.SimpleDateFormat; + public class HelpFragment extends BaseMwmFragment implements View.OnClickListener { private void setupItem(@IdRes int id, boolean tint, @NonNull View frame) @@ -32,6 +32,20 @@ public class HelpFragment extends BaseMwmFragment implements View.OnClickListene Graphics.tint(view); } + // Converts 220131 to locale-dependent date (e.g. 31 January 2022), + private String localDate(long v) + { + final SimpleDateFormat format = new SimpleDateFormat("yyMMdd"); + final String strVersion = String.valueOf(v); + try { + final java.util.Date date = format.parse(strVersion); + return java.text.DateFormat.getDateInstance().format(date); + } catch (java.text.ParseException e) { + e.printStackTrace(); + return strVersion; + } + } + @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -41,7 +55,7 @@ public class HelpFragment extends BaseMwmFragment implements View.OnClickListene .setText(BuildConfig.VERSION_NAME); ((TextView) root.findViewById(R.id.data_version)) - .setText(getString(R.string.data_version, Framework.nativeGetDataVersion())); + .setText(getString(R.string.data_version, localDate(Framework.nativeGetDataVersion()))); setupItem(R.id.web, true, root); setupItem(R.id.github, false, root);