Compare commits

..

1 Commits

Author SHA1 Message Date
Jean-Baptiste
1ba0c14ce5 [android] Use error in textfield instead alert dialog
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
2026-01-02 19:17:49 +01:00
19 changed files with 72 additions and 59 deletions

View File

@@ -16,8 +16,8 @@ import app.organicmaps.sdk.bookmarks.data.BookmarkCategory;
import app.organicmaps.sdk.bookmarks.data.BookmarkManager; import app.organicmaps.sdk.bookmarks.data.BookmarkManager;
import app.organicmaps.util.InputUtils; import app.organicmaps.util.InputUtils;
import app.organicmaps.util.Utils; import app.organicmaps.util.Utils;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.imageview.ShapeableImageView;
import com.google.android.material.textfield.TextInputEditText; import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout; import com.google.android.material.textfield.TextInputLayout;
import java.util.Objects; import java.util.Objects;
@@ -38,7 +38,7 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
@NonNull @NonNull
private TextInputEditText mEditCategoryNameView; private TextInputEditText mEditCategoryNameView;
@NonNull @NonNull
private ShapeableImageView mSaveView; private MaterialButton mSaveView;
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) public void onCreate(@Nullable Bundle savedInstanceState)
@@ -75,7 +75,19 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
@Override @Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
{ {
clearNameBtn.setEndIconVisible(charSequence.length() > 0); if (charSequence.length() > 0)
{
clearNameBtn.setEndIconVisible(true);
mSaveView.setEnabled(true);
mSaveView.setAlpha(1f);
}
else
{
clearNameBtn.setEndIconVisible(false);
mSaveView.setEnabled(false);
mSaveView.setAlpha(0.5f);
clearNameBtn.setError(getString(R.string.bookmarks_error_title_empty_list_name));
}
} }
@Override @Override
@@ -111,16 +123,6 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
private boolean validateCategoryName(@Nullable String name) private boolean validateCategoryName(@Nullable String name)
{ {
if (TextUtils.isEmpty(name))
{
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)
.setTitle(R.string.bookmarks_error_title_empty_list_name)
.setMessage(R.string.bookmarks_error_message_empty_list_name)
.setPositiveButton(R.string.ok, null)
.show();
return false;
}
if (BookmarkManager.INSTANCE.isUsedCategoryName(name) && !TextUtils.equals(name, mCategory.getName())) if (BookmarkManager.INSTANCE.isUsedCategoryName(name) && !TextUtils.equals(name, mCategory.getName()))
{ {
new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog) new MaterialAlertDialogBuilder(requireActivity(), R.style.MwmTheme_AlertDialog)

View File

@@ -13,6 +13,7 @@
android:paddingTop="@dimen/margin_half" android:paddingTop="@dimen/margin_half"
android:paddingBottom="@dimen/margin_half" android:paddingBottom="@dimen/margin_half"
android:layout_marginEnd="@dimen/margin_base" android:layout_marginEnd="@dimen/margin_base"
android:background="?cardBackground"
android:textAppearance="@style/MwmTextAppearance.Caption" android:textAppearance="@style/MwmTextAppearance.Caption"
tools:text="Downloaded" tools:text="Downloaded"
tools:background="#80FF0000"/> tools:background="#80FF0000"/>

View File

@@ -6,7 +6,7 @@
android:id="@+id/rl__bookmark_details" android:id="@+id/rl__bookmark_details"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?appBackground" android:background="?cardBackground"
android:padding="@dimen/margin_half"> android:padding="@dimen/margin_half">
<LinearLayout <LinearLayout
android:id="@+id/ll__bookmark_name" android:id="@+id/ll__bookmark_name"

View File

@@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:background="?appBackground" android:background="?cardBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
@@ -12,13 +12,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="@style/MwmWidget.ToolbarTheme"> android:theme="@style/MwmWidget.ToolbarTheme">
<com.google.android.material.imageview.ShapeableImageView <com.google.android.material.button.MaterialButton
android:id="@+id/save" android:id="@+id/save"
android:layout_width="?actionBarSize" style="@style/Widget.Material3.Button.IconButton"
android:layout_width="?actionBarSize"
android:layout_height="?actionBarSize" android:layout_height="?actionBarSize"
android:scaleType="centerInside"
android:layout_gravity="end|center_vertical" android:layout_gravity="end|center_vertical"
app:srcCompat="@drawable/ic_done"/> app:icon="@drawable/ic_done"
app:iconGravity="textStart"
app:iconTint="?iconTint"
android:enabled="false"
app:iconPadding="0dp"
app:iconSize="24dp" />
</com.google.android.material.appbar.MaterialToolbar> </com.google.android.material.appbar.MaterialToolbar>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:scrollbars="none" android:scrollbars="none"
@@ -69,6 +74,7 @@
android:inputType="textMultiLine"/> android:inputType="textMultiLine"/>
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<View <View
android:background="?cardBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>

View File

@@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
style="@style/MwmWidget.Floating" style="@style/MwmWidget.Floating"
android:background="?appBackground" android:background="?cardBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<include layout="@layout/toolbar_with_search"/> <include layout="@layout/toolbar_with_search"/>

View File

@@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?appBackground"> android:background="?cardBackground">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/MwmWidget.ToolbarStyle" style="@style/MwmWidget.ToolbarStyle"

View File

@@ -5,7 +5,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?windowBackgroundForced"
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar

View File

@@ -61,12 +61,12 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:background="?appBackground"> android:background="?cardBackground">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler" android:id="@+id/recycler"
android:clipToPadding="false" android:clipToPadding="false"
android:background="?appBackground" android:background="?cardBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
/> />

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView <ScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -16,9 +16,33 @@
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_half"
style="@style/MwmWidget.M3.Editor.CardView" style="@style/MwmWidget.M3.Editor.CardView"
app:cardBackgroundColor="?cardBackground"> card_view:cardBackgroundColor="?cardBackground"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="4dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et__timetable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@null"
android:gravity="top|start"
android:inputType="textMultiLine"
android:padding="@dimen/margin_base"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:hint="hint"
tools:text="trololo \ntrololo \ntrololo"/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_half"
card_view:cardBackgroundColor="?cardBackground"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="4dp">
<LinearLayout <LinearLayout
android:id="@+id/examples" android:id="@+id/examples"
@@ -26,26 +50,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:animateLayoutChanges="true"> android:animateLayoutChanges="true">
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_half"
app:boxStrokeWidth="0dp"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et__timetable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@null"
android:gravity="top|start"
android:inputType="textMultiLine"
android:padding="@dimen/margin_base"
android:textAppearance="@style/MwmTextAppearance.Body3"
tools:hint="hint"
tools:text="trololo \ntrololo \ntrololo"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/tv__examples_title" android:id="@+id/tv__examples_title"

View File

@@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?appBackground" android:background="?cardBackground"
android:padding="@dimen/margin_base"> android:padding="@dimen/margin_base">
<LinearLayout <LinearLayout

View File

@@ -5,7 +5,7 @@
style="@style/MwmTextAppearance.Headline6" style="@style/MwmTextAppearance.Headline6"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?appBackground" android:background="?windowBackgroundForced"
android:gravity="start|center_vertical" android:gravity="start|center_vertical"
android:paddingStart="@dimen/margin_base" android:paddingStart="@dimen/margin_base"
android:paddingTop="@dimen/margin_base_plus" android:paddingTop="@dimen/margin_base_plus"

View File

@@ -6,7 +6,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:background="?appBackground" android:background="?cardBackground"
android:padding="@dimen/margin_base"> android:padding="@dimen/margin_base">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -4,7 +4,7 @@
android:id="@+id/menu_frame" android:id="@+id/menu_frame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?appBackground" android:background="?cardBackground"
android:clickable="true" android:clickable="true"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">

View File

@@ -2,7 +2,7 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:orientation="horizontal"
android:background="?appBackground" android:background="?cardBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">

View File

@@ -29,7 +29,7 @@
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?appBackground" android:background="?cardBackground"
android:padding="@dimen/margin_base" android:padding="@dimen/margin_base"
android:text="@string/editor_focus_map_on_location" android:text="@string/editor_focus_map_on_location"
app:layout_constraintTop_toBottomOf="@+id/toolbar_point_chooser" /> app:layout_constraintTop_toBottomOf="@+id/toolbar_point_chooser" />

View File

@@ -4,4 +4,5 @@
android:id="@+id/recycler" android:id="@+id/recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?cardBackground"
android:scrollbars="vertical"/> android:scrollbars="vertical"/>

View File

@@ -6,7 +6,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/height_block_base" android:minHeight="@dimen/height_block_base"
android:background="?appBackground" android:background="?cardBackground"
android:baselineAligned="false"> android:baselineAligned="false">
<LinearLayout <LinearLayout
android:id="@+id/btn__search_point" android:id="@+id/btn__search_point"

View File

@@ -11,7 +11,7 @@
<item name="android:textColorPrimary">@color/text_light</item> <item name="android:textColorPrimary">@color/text_light</item>
<item name="android:textColorPrimaryInverse">@color/text_dark</item> <item name="android:textColorPrimaryInverse">@color/text_dark</item>
<item name="android:textColorSecondary">@color/text_light_subtitle</item> <item name="android:textColorSecondary">@color/text_light_subtitle</item>
<item name="android:windowBackground">?appBackground</item> <item name="android:windowBackground">?windowBackgroundForced</item>
<item name="android:colorPrimaryDark">@color/bg_primary_dark</item> <item name="android:colorPrimaryDark">@color/bg_primary_dark</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:fontFamily">@string/robotoRegular</item> <item name="android:fontFamily">@string/robotoRegular</item>

View File

@@ -12,7 +12,7 @@
<item name="android:textColorPrimary">@color/text_dark</item> <item name="android:textColorPrimary">@color/text_dark</item>
<item name="android:textColorPrimaryInverse">@color/text_light</item> <item name="android:textColorPrimaryInverse">@color/text_light</item>
<item name="android:textColorSecondary">@color/text_dark_subtitle</item> <item name="android:textColorSecondary">@color/text_dark_subtitle</item>
<item name="android:windowBackground">?appBackground</item> <item name="android:windowBackground">?windowBackgroundForced</item>
<item name="android:colorPrimaryDark">@color/bg_primary_dark</item> <item name="android:colorPrimaryDark">@color/bg_primary_dark</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item> <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:fontFamily">@string/robotoRegular</item> <item name="android:fontFamily">@string/robotoRegular</item>
@@ -185,11 +185,11 @@
</style> </style>
<style name="MwmTheme.CardBg"> <style name="MwmTheme.CardBg">
<item name="android:windowBackground">?appBackground</item> <item name="android:windowBackground">@color/bg_cards</item>
</style> </style>
<style name="MwmTheme.WindowBg"> <style name="MwmTheme.WindowBg">
<item name="android:windowBackground">?appBackground</item> <item name="android:windowBackground">@color/bg_window</item>
</style> </style>
<style name="MwmTheme.AlertDialog" parent="Theme.Material3.DayNight.Dialog.Alert"> <style name="MwmTheme.AlertDialog" parent="Theme.Material3.DayNight.Dialog.Alert">
@@ -243,7 +243,7 @@
<style name="MwmTheme.FullScreenDialog"> <style name="MwmTheme.FullScreenDialog">
<item name="android:windowIsFloating">false</item> <item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">?appBackground</item> <item name="android:windowBackground">@android:color/white</item>
</style> </style>
<style name="MwmTheme.MaterialTimePicker" parent="ThemeOverlay.MaterialComponents.TimePicker"> <style name="MwmTheme.MaterialTimePicker" parent="ThemeOverlay.MaterialComponents.TimePicker">