mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[Android] Add info about outdated maps and update button to place page
Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
@@ -154,6 +154,7 @@ public class PlacePageView extends Fragment
|
||||
private MaterialTextView mTvLastChecked;
|
||||
private View mEditPlace;
|
||||
private View mAddPlace;
|
||||
private View mMapTooOld;
|
||||
private View mEditTopSpace;
|
||||
private ShapeableImageView mColorIcon;
|
||||
private MaterialTextView mTvCategory;
|
||||
@@ -318,6 +319,7 @@ public class PlacePageView extends Fragment
|
||||
mTvLastChecked = mFrame.findViewById(R.id.place_page_last_checked);
|
||||
mEditPlace = mFrame.findViewById(R.id.ll__place_editor);
|
||||
mAddPlace = mFrame.findViewById(R.id.ll__place_add);
|
||||
mMapTooOld = mFrame.findViewById(R.id.cv__map_too_old);
|
||||
mEditTopSpace = mFrame.findViewById(R.id.edit_top_space);
|
||||
latlon.setOnLongClickListener(this);
|
||||
address.setOnLongClickListener(this);
|
||||
@@ -684,7 +686,7 @@ public class PlacePageView extends Fragment
|
||||
|
||||
if (RoutingController.get().isNavigating() || RoutingController.get().isPlanning())
|
||||
{
|
||||
UiUtils.hide(mEditPlace, mAddPlace, mEditTopSpace);
|
||||
UiUtils.hide(mEditPlace, mAddPlace, mEditTopSpace, mMapTooOld);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -692,31 +694,59 @@ public class PlacePageView extends Fragment
|
||||
UiUtils.showIf(Editor.nativeShouldShowAddPlace(), mAddPlace);
|
||||
MaterialButton mTvEditPlace = mEditPlace.findViewById(R.id.mb__place_editor);
|
||||
MaterialButton mTvAddPlace = mAddPlace.findViewById(R.id.mb__place_add);
|
||||
mTvEditPlace.setOnClickListener(this);
|
||||
mTvAddPlace.setOnClickListener(this);
|
||||
mTvEditPlace.setEnabled(Editor.nativeShouldEnableEditPlace());
|
||||
mTvAddPlace.setEnabled(Editor.nativeShouldEnableAddPlace());
|
||||
final int editTextButtonColor =
|
||||
Editor.nativeShouldEnableEditPlace()
|
||||
|
||||
boolean shouldEnableEditPlace = Editor.nativeShouldEnableEditPlace();
|
||||
|
||||
if (shouldEnableEditPlace)
|
||||
{
|
||||
mTvEditPlace.setOnClickListener(this);
|
||||
mTvAddPlace.setOnClickListener(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
mTvEditPlace.setOnClickListener((v) -> {
|
||||
Utils.showSnackbar(v.getContext(), v.getRootView(), R.string.place_page_too_old_to_edit);
|
||||
});
|
||||
mTvAddPlace.setOnClickListener((v) -> {
|
||||
Utils.showSnackbar(v.getContext(), v.getRootView(), R.string.place_page_too_old_to_edit);
|
||||
});
|
||||
|
||||
CountryItem map = CountryItem.fill(MapManager.nativeGetSelectedCountry());
|
||||
|
||||
if (map.status == CountryItem.STATUS_UPDATABLE || map.status == CountryItem.STATUS_DONE
|
||||
|| map.status == CountryItem.STATUS_FAILED)
|
||||
{
|
||||
mMapTooOld.setVisibility(VISIBLE);
|
||||
MaterialButton mTvUpdateTooOldMap = mMapTooOld.findViewById(R.id.mb__update_too_old_map);
|
||||
boolean canUpdateMap = map.status != CountryItem.STATUS_DONE;
|
||||
|
||||
if (canUpdateMap)
|
||||
{
|
||||
mTvUpdateTooOldMap.setOnClickListener((v) -> {
|
||||
MapManagerHelper.warn3gAndDownload(requireActivity(), map.id, null);
|
||||
mMapTooOld.setVisibility(GONE);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
mTvUpdateTooOldMap.setVisibility(GONE);
|
||||
MaterialTextView mapTooOldDescription = mMapTooOld.findViewById(R.id.tv__map_too_old_description);
|
||||
mapTooOldDescription.setText(R.string.place_page_app_too_old_description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int editButtonColor =
|
||||
shouldEnableEditPlace
|
||||
? ContextCompat.getColor(
|
||||
getContext(),
|
||||
UiUtils.getStyledResourceId(getContext(), com.google.android.material.R.attr.colorSecondary))
|
||||
: ContextCompat.getColor(getContext(), R.color.button_accent_text_disabled);
|
||||
final ColorStateList editStrokeButtonColor = new ColorStateList(
|
||||
new int[][]{
|
||||
new int[]{android.R.attr.state_enabled}, // enabled
|
||||
new int[]{-android.R.attr.state_enabled} // disabled
|
||||
},
|
||||
new int[]{
|
||||
ContextCompat.getColor(
|
||||
getContext(),
|
||||
UiUtils.getStyledResourceId(getContext(), com.google.android.material.R.attr.colorSecondary)),
|
||||
ContextCompat.getColor(getContext(), R.color.button_accent_text_disabled)
|
||||
});
|
||||
mTvEditPlace.setTextColor(editTextButtonColor);
|
||||
mTvAddPlace.setTextColor(editTextButtonColor);
|
||||
mTvEditPlace.setStrokeColor(editStrokeButtonColor);
|
||||
mTvAddPlace.setStrokeColor(editStrokeButtonColor);
|
||||
|
||||
mTvEditPlace.setTextColor(editButtonColor);
|
||||
mTvAddPlace.setTextColor(editButtonColor);
|
||||
mTvEditPlace.setStrokeColor(ColorStateList.valueOf(editButtonColor));
|
||||
mTvAddPlace.setStrokeColor(ColorStateList.valueOf(editButtonColor));
|
||||
UiUtils.showIf(
|
||||
UiUtils.isVisible(mEditPlace) || UiUtils.isVisible(mAddPlace),
|
||||
mEditTopSpace);
|
||||
|
||||
10
android/app/src/main/res/drawable/info_icon.xml
Normal file
10
android/app/src/main/res/drawable/info_icon.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M453,680L513,680L513,440L453,440L453,680ZM479.98,366Q494,366 503.5,356.8Q513,347.6 513,334Q513,319.55 503.52,309.78Q494.04,300 480.02,300Q466,300 456.5,309.78Q447,319.55 447,334Q447,347.6 456.48,356.8Q465.96,366 479.98,366ZM480.27,880Q397.53,880 324.77,848.5Q252,817 197.5,762.5Q143,708 111.5,635.16Q80,562.32 80,479.5Q80,396.68 111.5,323.84Q143,251 197.5,197Q252,143 324.84,111.5Q397.68,80 480.5,80Q563.32,80 636.16,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,479.73Q880,562.47 848.5,635.23Q817,708 763,762.32Q709,816.63 636,848.32Q563,880 480.27,880ZM480.5,820Q622,820 721,720.5Q820,621 820,479.5Q820,338 721.19,239Q622.38,140 480,140Q339,140 239.5,238.81Q140,337.62 140,480Q140,621 239.5,720.5Q339,820 480.5,820ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
|
||||
</vector>
|
||||
@@ -89,6 +89,8 @@
|
||||
android:paddingHorizontal="@dimen/margin_base"
|
||||
tools:text="Existence confirmed 1 month ago"/>
|
||||
|
||||
<include android:visibility="gone" layout="@layout/place_page_map_too_old"/>
|
||||
|
||||
<include android:visibility="gone" layout="@layout/place_page_editor"/>
|
||||
|
||||
<include android:visibility="gone" layout="@layout/place_page_add"/>
|
||||
|
||||
65
android/app/src/main/res/layout/place_page_map_too_old.xml
Normal file
65
android/app/src/main/res/layout/place_page_map_too_old.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/cv__map_too_old"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/margin_base"
|
||||
android:layout_marginTop="@dimen/margin_half"
|
||||
app:strokeWidth="1dp"
|
||||
app:strokeColor="@color/base_accent"
|
||||
app:cardBackgroundColor="@color/bg_cards">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="@dimen/margin_base"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginEnd="@dimen/margin_base"
|
||||
app:srcCompat="@drawable/info_icon"
|
||||
app:tint="@color/base_accent" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_quarter"
|
||||
android:text="@string/place_page_map_too_old_title"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body2"
|
||||
android:textStyle="bold"
|
||||
android:textColor="?android:textColorPrimary" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/tv__map_too_old_description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/margin_quarter"
|
||||
android:text="@string/place_page_map_too_old_description"
|
||||
android:fontFamily="@string/robotoRegular"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:textColor="?android:textColorPrimary" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/mb__update_too_old_map"
|
||||
style="@style/MwmWidget.M3.Button.Primary"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="@string/place_page_update_too_old_map"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
@@ -573,6 +573,16 @@
|
||||
<string name="error_enter_correct_fediverse_page">Enter a valid Mastodon username or web address</string>
|
||||
<string name="error_enter_correct_bluesky_page">Enter a valid Bluesky username or web address</string>
|
||||
<string name="placepage_add_place_button">Add Place to OpenStreetMap</string>
|
||||
<!-- Title of info shown when the map is older than 3 to 6 months -->
|
||||
<string name="place_page_map_too_old_title">Map data outdated</string>
|
||||
<!-- Description of info shown when the map is older than 3 months -->
|
||||
<string name="place_page_map_too_old_description"> Your current map data is very old, please update the map.</string>
|
||||
<!-- Description of info shown when the app and the map are older than 6 months -->
|
||||
<string name="place_page_app_too_old_description"> Your current map data is very old, please update the CoMaps app.</string>
|
||||
<!-- Button to update map region, part of the map too old info -->
|
||||
<string name="place_page_update_too_old_map">Update map region</string>
|
||||
<!-- Toast shown after pressing add place / edit OpenStreetMap when editing is disabled -->
|
||||
<string name="place_page_too_old_to_edit">OpenStreetMap editing is disabled because the map data is too old.</string>
|
||||
<string name="osm_note_hint">Or, alternatively, leave a note to OpenStreetMap community so that someone else can add or fix a place here.</string>
|
||||
<string name="osm_note_toast">Note will be sent to OpenStreetMap</string>
|
||||
<!-- Displayed when saving some edits to the map to warn against publishing personal data -->
|
||||
|
||||
Reference in New Issue
Block a user