[android] Use FAB instead save button at the top

Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
Jean-Baptiste
2025-09-13 09:25:29 +02:00
committed by jeanbaptisteC
parent cc8f45bac9
commit d1643d695e
4 changed files with 35 additions and 59 deletions

View File

@@ -6,9 +6,6 @@ import android.text.InputFilter;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@@ -20,6 +17,7 @@ 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.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;
@@ -39,6 +37,8 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
@SuppressWarnings("NullableProblems") @SuppressWarnings("NullableProblems")
@NonNull @NonNull
private TextInputEditText mEditCategoryNameView; private TextInputEditText mEditCategoryNameView;
@NonNull
private ShapeableImageView mSaveView;
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) public void onCreate(@Nullable Bundle savedInstanceState)
@@ -85,23 +85,8 @@ public class BookmarkCategorySettingsFragment extends BaseMwmToolbarFragment
}); });
mEditDescView = root.findViewById(R.id.edit_description); mEditDescView = root.findViewById(R.id.edit_description);
mEditDescView.setText(mCategory.getDescription()); mEditDescView.setText(mCategory.getDescription());
} mSaveView = root.findViewById(R.id.done);
mSaveView.setOnClickListener(v -> onEditDoneClicked());
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater)
{
inflater.inflate(R.menu.menu_done, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if (item.getItemId() == R.id.done)
{
onEditDoneClicked();
return true;
}
return super.onOptionsItemSelected(item);
} }
private void onEditDoneClicked() private void onEditDoneClicked()

View File

@@ -11,7 +11,14 @@
style="@style/MwmWidget.ToolbarStyle" style="@style/MwmWidget.ToolbarStyle"
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
android:layout_width="?actionBarSize"
android:layout_height="?actionBarSize"
android:scaleType="centerInside"
android:layout_gravity="end|center_vertical"
app:srcCompat="@drawable/ic_done"/>
</com.google.android.material.appbar.MaterialToolbar>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:scrollbars="none" android:scrollbars="none"
android:fillViewport="true" android:fillViewport="true"

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <androidx.constraintlayout.widget.ConstraintLayout
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:layout_width="match_parent" android:layout_width="match_parent"
@@ -12,35 +12,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="end|center_vertical" android:gravity="end|center_vertical"
android:theme="@style/MwmWidget.ToolbarTheme"> android:theme="@style/MwmWidget.ToolbarTheme"
app:layout_constraintEnd_toEndOf="parent"
<LinearLayout app:layout_constraintStart_toStartOf="parent"
android:layout_width="match_parent" app:layout_constraintTop_toTopOf="parent">
android:layout_height="match_parent"
android:orientation="horizontal"
android:padding="@dimen/margin_half">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/editor_add_select_location"
android:textAppearance="@style/MwmTextAppearance.Toolbar.Title"/>
<com.google.android.material.imageview.ShapeableImageView
app:tint="@color/image_view"
android:id="@+id/done"
app:srcCompat="@drawable/ic_done"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless" android:padding="@dimen/margin_half"
android:layout_gravity="end" android:text="@string/editor_add_select_location"
android:scaleType="centerInside" android:textAppearance="@style/MwmTextAppearance.Toolbar.Title"/>
android:contentDescription="@string/done" />
</LinearLayout>
</com.google.android.material.appbar.MaterialToolbar> </com.google.android.material.appbar.MaterialToolbar>
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
@@ -48,6 +31,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?panel" android:background="?panel"
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" />
</LinearLayout> <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:contentDescription="@string/save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_done" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
app:showAsAction="always"
android:id="@+id/done"
android:title="@string/done"
android:icon="@drawable/ic_done"/>
</menu>