Refactor bookmark category fragment

Signed-off-by: Jean-BaptisteC <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
Jean-Baptiste 2023-11-12 10:32:03 +01:00 committed by Alexander Borsuk
parent aadb525b7f
commit 4c218d66cb
16 changed files with 48 additions and 25 deletions

View file

@ -848,7 +848,8 @@
<activity
android:name="app.organicmaps.bookmarks.BookmarkCategorySettingsActivity"
android:label="@string/edit"/>
android:label="@string/edit"
android:windowSoftInputMode="stateVisible"/>
<activity
android:name="app.organicmaps.widget.placepage.PlaceDescriptionActivity"
android:label="@string/place_description_title"/>

View file

@ -9,6 +9,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -19,8 +20,10 @@ import app.organicmaps.bookmarks.data.BookmarkCategory;
import app.organicmaps.bookmarks.data.BookmarkManager;
import app.organicmaps.util.Utils;
import app.organicmaps.util.InputUtils;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;
import java.util.Objects;
@ -63,14 +66,14 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
private void initViews(@NonNull View root)
{
mEditCategoryNameView = root.findViewById(R.id.edit_list_name_view);
TextInputLayout clearNameBtn = root.findViewById(R.id.edit_list_name_input);
clearNameBtn.setEndIconOnClickListener(v -> clearAndFocus(mEditCategoryNameView));
mEditCategoryNameView.setText(mCategory.getName());
InputFilter[] f = { new InputFilter.LengthFilter(TEXT_LENGTH_LIMIT) };
mEditCategoryNameView.setFilters(f);
mEditCategoryNameView.requestFocus();
mEditDescView = root.findViewById(R.id.edit_description);
mEditDescView.setText(mCategory.getDescription());
View clearNameBtn = root.findViewById(R.id.edit_text_clear_btn);
clearNameBtn.setOnClickListener(v -> mEditCategoryNameView.getEditableText().clear());
}
@Override
@ -152,4 +155,11 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
String categoryDesc = getEditableCategoryDesc();
return !TextUtils.equals(mCategory.getDescription(), categoryDesc);
}
private void clearAndFocus(TextView textView)
{
textView.getEditableText().clear();
textView.requestFocus();
InputUtils.showKeyboard(textView);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 658 B

View file

@ -0,0 +1,11 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#FFFFFF"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.47,2 2,6.47 2,12s4.47,10 10,10 10,-4.47 10,-10S17.53,2 12,2zM17,15.59L15.59,17 12,13.41 8.41,17 7,15.59 10.59,12 7,8.41 8.41,7 12,10.59 15.59,7 17,8.41 13.41,12 17,15.59z" />
</vector>

View file

@ -86,7 +86,9 @@
android:textColorHint="?android:textColorSecondary"
app:layout_constraintLeft_toRightOf="@id/osm_username_container"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
app:endIconMode="password_toggle"
app:endIconTint="?android:textColorSecondary">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/osm_password"
style="@style/MwmWidget.Editor.FieldLayout.EditText"

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="?cardBackground"
android:layout_width="match_parent"
@ -22,9 +23,9 @@
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:paddingStart="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:paddingBottom="@dimen/bookmark_hide_btn_padding_top"
android:paddingStart="@dimen/margin_half"
android:paddingEnd="@dimen/margin_half"
android:paddingBottom="@dimen/margin_half"
android:paddingTop="@dimen/margin_half_plus"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -33,36 +34,36 @@
android:id="@+id/edit_name_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<app.organicmaps.widget.CustomTextInputLayout
android:id="@+id/edit_list_name_input"
style="@style/MwmWidget.Editor.CustomTextInput"
android:textColorHint="?android:textColorSecondary"
app:endIconMode="custom"
app:endIconDrawable="@drawable/ic_clear_rounded"
app:endIconTint="?android:textColorSecondary">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_list_name_view"
style="@style/MwmWidget.PlacePage.EditText"
android:hint="@string/list"
android:layout_weight="1"
android:layout_width="0dp"
android:background="@null"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/margin_base"/>
<ImageView
android:id="@+id/edit_text_clear_btn"
android:src="?attr/icClearRounded"
android:background="?selectableItemBackgroundBorderless"
android:layout_gravity="center"
android:layout_weight="0"
android:layout_width="@dimen/margin_base_plus"
android:layout_height="@dimen/margin_base_plus"/>
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</app.organicmaps.widget.CustomTextInputLayout>
</LinearLayout>
</LinearLayout>
<app.organicmaps.widget.CustomTextInputLayout
style="@style/MwmWidget.Editor.CustomTextInput"
android:textColorHint="?android:textColorSecondary">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_description"
style="@style/MwmWidget.PlacePage.EditText"
android:background="@null"
android:hint="@string/bookmark_list_description_hint"
android:minHeight="@dimen/height_item_multiline"
android:paddingStart="@dimen/margin_base"
android:paddingEnd="@dimen/margin_base"
android:textAppearance="?android:attr/textAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:inputType="textMultiLine"/>
</app.organicmaps.widget.CustomTextInputLayout>
<View
android:background="?android:attr/windowBackground"
android:layout_width="match_parent"

View file

@ -96,7 +96,6 @@
<item name="subwayMenuDisabled">@drawable/ic_layers_subway_inactive</item>
<item name="isoLinesMenuDisabled">@drawable/ic_layers_isoline_inactive</item>
<item name="accentColorSelector">@color/accent_color_selector</item>
<item name="icClearRounded">@drawable/ic_clear_rounded</item>
<item name="android:textAppearance">@style/TextAppearance</item>
<item name="android:textAppearanceSmall">@style/TextAppearance.Small</item>
<item name="android:textAppearanceMedium">@style/TextAppearance.Medium</item>
@ -228,7 +227,6 @@
<item name="subwayMenuEnabled">@drawable/ic_layers_subway_active_night</item>
<item name="isoLinesMenuEnabled">@drawable/ic_layers_isoline_active_night</item>
<item name="accentColorSelector">@color/accent_color_selector_night</item>
<item name="icClearRounded">@drawable/ic_clear_rounded_night</item>
<item name="android:textAppearance">@style/TextAppearance</item>
<item name="android:textAppearanceSmall">@style/TextAppearance.Small</item>
<item name="android:textAppearanceMedium">@style/TextAppearance.Medium</item>