Compare commits

..

2 Commits

Author SHA1 Message Date
matheusgomesms
9916850758 [iOS] Improve confirmed existence format
Signed-off-by: matheusgomesms <matheusgomesms@noreply.codeberg.org>
2026-01-06 11:58:56 -03:00
Jean-Baptiste
5e8d2e1a59 [android] Use Material Cardview foreach item phone
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
2026-01-03 22:53:00 +01:00
6 changed files with 60 additions and 38 deletions

View File

@@ -197,8 +197,10 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment<Bookmark
() -> onShareActionSelected(mSelectedCategory, KmlFileType.Text)));
items.add(new MenuBottomSheetItem(R.string.export_file_gpx, R.drawable.ic_file_gpx,
() -> onShareActionSelected(mSelectedCategory, KmlFileType.Gpx)));
items.add(new MenuBottomSheetItem(R.string.delete, R.drawable.ic_delete,
() -> onDeleteActionSelected(mSelectedCategory)));
// Disallow deleting the last category
if (getAdapter().getBookmarkCategories().size() > 1)
items.add(new MenuBottomSheetItem(R.string.delete, R.drawable.ic_delete,
() -> onDeleteActionSelected(mSelectedCategory)));
}
return items;
}
@@ -295,24 +297,8 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment<Bookmark
private void onDeleteActionSelected(@NonNull BookmarkCategory category)
{
// Disallow deleting the last category
if ((getAdapter().getBookmarkCategories().size() > 1))
{
BookmarkManager.INSTANCE.deleteCategory(category.getId());
getAdapter().notifyDataSetChanged();
}
else
{
new MaterialAlertDialogBuilder(requireActivity())
.setMessage(R.string.unable_to_delete_list)
.setPositiveButton(android.R.string.yes, ((dialog, which) -> {
onAddButtonClick();
BookmarkManager.INSTANCE.deleteCategory(category.getId());
getAdapter().notifyDataSetChanged();
}))
.setNegativeButton(android.R.string.no,(dialog, which) -> dialog.dismiss())
.show();
}
BookmarkManager.INSTANCE.deleteCategory(category.getId());
getAdapter().notifyDataSetChanged();
}
private void onSettingsActionSelected(@NonNull BookmarkCategory category)

View File

@@ -1,11 +1,15 @@
<androidx.constraintlayout.widget.ConstraintLayout
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/MwmWidget.M3.Editor.CardView"
android:layout_width="match_parent"
android:layout_height="@dimen/height_item_oneline"
android:background="?clickableBackground"
android:layout_marginTop="@dimen/margin_half"
android:layout_margin="@dimen/margin_eighth"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/margin_half"
android:background="?cardBackground"
android:paddingStart="@dimen/margin_half_plus"
android:paddingEnd="@dimen/margin_half_plus">
@@ -25,7 +29,6 @@
android:layout_marginStart="@dimen/margin_half"
android:layout_marginEnd="@dimen/margin_half"
android:layout_toStartOf="@id/delete_icon"
android:textColorHint="?android:textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/delete_icon"
app:layout_constraintStart_toEndOf="@+id/phone_icon"
@@ -41,7 +44,6 @@
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/delete_icon"
style="@style/MwmWidget.Editor.MetadataIcon"
android:layout_marginStart="@dimen/margin_half"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
@@ -49,3 +51,4 @@
app:srcCompat="@drawable/ic_delete" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

View File

@@ -973,5 +973,4 @@
<string name="download_resources_custom_url_message">Override the default map download server used for map downloads. Leave empty to use CoMaps default server.</string>
<string name="download_resources_custom_url_summary_none">Not set</string>
<string name="download_resources_custom_url_error_scheme">Please enter a URL starting with http:// or https://</string>
<string name="unable_to_delete_list">The app cannot work without at least one list. Do you want to remove it and create a new one?</string>
</resources>

View File

@@ -32,7 +32,7 @@ NSDate * _Nullable ParseDateString(NSString * _Nullable dateString) {
dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy-MM-dd";
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
dateFormatter.timeZone = [NSTimeZone localTimeZone];
});
return [dateFormatter dateFromString:dateString];

View File

@@ -85,10 +85,27 @@ class OpeningHoursViewController: UIViewController {
}
if let checkDate = self.openingHoursCheckDate, self.expanded {
let checkDateFormatter = RelativeDateTimeFormatter()
checkDateFormatter.unitsStyle = .spellOut
checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now)
self.checkDateLabel.text = String(format: L("hours_confirmed_time_ago"), checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now))
let dateString: String
// Check if the date is strictly "Today" or "Yesterday"
if Calendar.current.isDateInToday(checkDate) || Calendar.current.isDateInYesterday(checkDate) {
// Case 1: Today/Yesterday -> Use "today" / "yesterday"
let df = DateFormatter()
df.dateStyle = .medium
df.timeStyle = .none
df.doesRelativeDateFormatting = true
let rawString = df.string(from: checkDate)
// Lowercase first letter: "Today" -> "today"
dateString = rawString.prefix(1).lowercased() + rawString.dropFirst()
} else {
// Case 2: Older -> Use "2 years ago"
let rdf = RelativeDateTimeFormatter()
rdf.unitsStyle = .spellOut
dateString = rdf.localizedString(for: checkDate, relativeTo: Date())
}
self.checkDateLabel.text = String(format: L("hours_confirmed_time_ago"), dateString)
NSLayoutConstraint.activate([self.checkDateLabelTopLayoutConstraint])
NSLayoutConstraint.activate([self.checkDateLabelBottomLayoutConstraint])

View File

@@ -458,11 +458,28 @@ class PlacePageInfoViewController: UIViewController {
setupOpenWithAppView()
if let checkDate = placePageInfoData.checkDate {
let checkDateFormatter = RelativeDateTimeFormatter()
checkDateFormatter.unitsStyle = .spellOut
checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now)
self.checkDateLabel.text = String(format: L("existence_confirmed_time_ago"), checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now))
checkDateLabel.isHidden = false
let dateString: String
// Check if the date is strictly "Today" or "Yesterday"
if Calendar.current.isDateInToday(checkDate) || Calendar.current.isDateInYesterday(checkDate) {
// Case 1: Today/Yesterday -> Use "today" / "yesterday"
let df = DateFormatter()
df.dateStyle = .medium
df.timeStyle = .none
df.doesRelativeDateFormatting = true // Generates "Today"
let rawString = df.string(from: checkDate)
// Lowercase first letter: "Today" -> "today"
dateString = rawString.prefix(1).lowercased() + rawString.dropFirst()
} else {
// Case 2: Older -> Use "2 years ago"
let rdf = RelativeDateTimeFormatter()
rdf.unitsStyle = .spellOut
dateString = rdf.localizedString(for: checkDate, relativeTo: Date())
}
self.checkDateLabel.text = String(format: L("existence_confirmed_time_ago"), dateString)
checkDateLabel.isHidden = false
NSLayoutConstraint.activate([checkDateLabelLayoutConstraint])
} else {
checkDateLabel.text = String()