[android] Add support for check_date & check_date:opening_hours

Signed-off-by: Harry Bond <me@hbond.xyz>
This commit is contained in:
Harry Bond
2025-08-23 22:44:42 +01:00
committed by x7z4w
parent ef9f4ceb1e
commit 08abddc7fc
7 changed files with 98 additions and 4 deletions

View File

@@ -106,7 +106,6 @@ public class PlacePageView extends Fragment
Arrays.asList(CoordinatesFormat.LatLonDMS, CoordinatesFormat.LatLonDecimal, CoordinatesFormat.OLCFull,
CoordinatesFormat.UTM, CoordinatesFormat.MGRS, CoordinatesFormat.OSMLink);
private View mFrame;
private Context mContext;
// Preview.
private ViewGroup mPreview;
@@ -144,6 +143,7 @@ public class PlacePageView extends Fragment
private MaterialTextView mTvOutdoorSeating;
private View mEntrance;
private MaterialTextView mTvEntrance;
private MaterialTextView mTvLastChecked;
private View mEditPlace;
private View mAddOrganisation;
private View mAddPlace;
@@ -308,6 +308,7 @@ public class PlacePageView extends Fragment
mTvCuisine = mFrame.findViewById(R.id.tv__place_cuisine);
mEntrance = mFrame.findViewById(R.id.ll__place_entrance);
mTvEntrance = mEntrance.findViewById(R.id.tv__place_entrance);
mTvLastChecked = mFrame.findViewById(R.id.place_page_last_checked);
mEditPlace = mFrame.findViewById(R.id.ll__place_editor);
mEditPlace.setOnClickListener(this);
mAddOrganisation = mFrame.findViewById(R.id.ll__add_organisation);
@@ -662,7 +663,14 @@ public class PlacePageView extends Fragment
refreshMetadataOrHide(outdoorSeating.equals("yes") ? getString(R.string.outdoor_seating) : "", mOutdoorSeating,
mTvOutdoorSeating);
// showTaxiOffer(mapObject);
final String lastChecked = mMapObject.getMetadata(Metadata.MetadataType.FMD_CHECK_DATE);
if (!lastChecked.isEmpty())
{
String periodSinceCheck = DateUtils.getRelativePeriodString(getResources(), lastChecked);
UiUtils.setTextAndShow(mTvLastChecked, requireContext().getString(R.string.existence_confirmed_time_ago, periodSinceCheck));
}
else
UiUtils.hide(mTvLastChecked);
if (RoutingController.get().isNavigating() || RoutingController.get().isPlanning())
{

View File

@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -20,6 +21,8 @@ import app.organicmaps.sdk.bookmarks.data.Metadata;
import app.organicmaps.sdk.editor.OpeningHours;
import app.organicmaps.sdk.editor.data.Timespan;
import app.organicmaps.sdk.editor.data.Timetable;
import app.organicmaps.sdk.util.DateUtils;
import app.organicmaps.sdk.util.UiUtils;
import app.organicmaps.util.ThemeUtils;
import app.organicmaps.util.UiUtils;
import app.organicmaps.util.Utils;
@@ -36,6 +39,7 @@ public class PlacePageOpeningHoursFragment extends Fragment implements Observer<
private MaterialTextView mTodayOpenTime;
private MaterialTextView mTodayNonBusinessTime;
private RecyclerView mFullWeekOpeningHours;
private MaterialTextView mLastCheckedDate;
private PlaceOpeningHoursAdapter mOpeningHoursAdapter;
private PlacePageViewModel mViewModel;
@@ -58,10 +62,23 @@ public class PlacePageOpeningHoursFragment extends Fragment implements Observer<
mTodayOpenTime = view.findViewById(R.id.oh_today_open_time);
mTodayNonBusinessTime = view.findViewById(R.id.oh_nonbusiness_time);
mFullWeekOpeningHours = view.findViewById(R.id.rw__full_opening_hours);
mLastCheckedDate = view.findViewById(R.id.oh_check_date);
mOpeningHoursAdapter = new PlaceOpeningHoursAdapter();
mFullWeekOpeningHours.setAdapter(mOpeningHoursAdapter);
}
private static void setOrHideLastCheckedDate(MapObject mapObject, Resources resources, TextView checkDateView)
{
final String checkDate = mapObject.getMetadata(Metadata.MetadataType.FMD_CHECK_DATE_OPEN_HOURS);
if (!checkDate.isEmpty())
{
String periodSinceCheck = DateUtils.getRelativePeriodString(resources, checkDate);
UiUtils.setTextAndShow(checkDateView, resources.getString(R.string.hours_confirmed_time_ago, periodSinceCheck));
}
else
UiUtils.hide(checkDateView);
}
private void refreshTodayNonBusinessTime(Timespan[] closedTimespans)
{
final String hoursClosedLabel = getResources().getString(R.string.editor_hours_closed);
@@ -102,6 +119,9 @@ public class PlacePageOpeningHoursFragment extends Fragment implements Observer<
final boolean isEmptyTT = (timetables == null || timetables.length == 0);
final int color = ThemeUtils.getColor(requireContext(), android.R.attr.textColorPrimary);
final Resources resources = getResources();
setOrHideLastCheckedDate(mapObject, resources, mLastCheckedDate);
if (isEmptyTT)
{
@@ -119,7 +139,6 @@ public class PlacePageOpeningHoursFragment extends Fragment implements Observer<
else
{
UiUtils.show(mFrame);
final Resources resources = getResources();
if (timetables[0].isFullWeek())
{
final Timetable tt = timetables[0];