diff --git a/android/app/src/main/java/app/organicmaps/editor/EditorHostFragment.java b/android/app/src/main/java/app/organicmaps/editor/EditorHostFragment.java index 69e3634347..1a95c42d26 100644 --- a/android/app/src/main/java/app/organicmaps/editor/EditorHostFragment.java +++ b/android/app/src/main/java/app/organicmaps/editor/EditorHostFragment.java @@ -25,6 +25,7 @@ import app.organicmaps.editor.data.LocalizedName; import app.organicmaps.editor.data.LocalizedStreet; import app.organicmaps.editor.data.NamesDataSource; import app.organicmaps.editor.data.PhoneFragment; +import app.organicmaps.util.InputUtils; import app.organicmaps.widget.SearchToolbarController; import app.organicmaps.widget.ToolbarController; import app.organicmaps.util.ConnectionState; @@ -132,6 +133,7 @@ public class EditorHostFragment extends BaseMwmToolbarFragment implements View.O mSave.setOnClickListener(this); UiUtils.setupHomeUpButtonAsNavigationIcon(getToolbarController().getToolbar(), v -> onBackPressed()); + InputUtils.hideKeyboard(requireView()); if (getArguments() != null) mIsNewObject = getArguments().getBoolean(EditorActivity.EXTRA_NEW_OBJECT, false); diff --git a/android/app/src/main/java/app/organicmaps/editor/data/PhoneFragment.java b/android/app/src/main/java/app/organicmaps/editor/data/PhoneFragment.java index 2707736e73..07e90d1119 100644 --- a/android/app/src/main/java/app/organicmaps/editor/data/PhoneFragment.java +++ b/android/app/src/main/java/app/organicmaps/editor/data/PhoneFragment.java @@ -13,12 +13,15 @@ import androidx.recyclerview.widget.RecyclerView; import app.organicmaps.R; import app.organicmaps.base.BaseMwmFragment; import app.organicmaps.editor.PhoneListAdapter; +import app.organicmaps.util.InputUtils; +import com.google.android.material.floatingactionbutton.FloatingActionButton; public class PhoneFragment extends BaseMwmFragment implements View.OnClickListener { public static final String EXTRA_PHONE_LIST = "Phone"; private PhoneListAdapter mAdapter; private RecyclerView mPhonesRecycler; + final Integer maxAdapter = 5; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) @@ -26,6 +29,14 @@ public class PhoneFragment extends BaseMwmFragment implements View.OnClickListen return inflater.inflate(R.layout.fragment_phone, container, false); } + @Override + public boolean onBackPressed() + { + super.onBackPressed(); + InputUtils.hideKeyboard(requireView()); + return true; + } + @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { @@ -38,12 +49,17 @@ public class PhoneFragment extends BaseMwmFragment implements View.OnClickListen mAdapter = new PhoneListAdapter(phoneList); mAdapter.setHasStableIds(true); - view.findViewById(R.id.tv__append_phone).setOnClickListener(this); + FloatingActionButton phoneFab = view.findViewById(R.id.tv__append_phone); + phoneFab.setOnClickListener(this); mPhonesRecycler = view.findViewById(R.id.phones_recycler); LinearLayoutManager manager = new LinearLayoutManager(view.getContext()); manager.setSmoothScrollbarEnabled(true); mPhonesRecycler.setLayoutManager(manager); mPhonesRecycler.setAdapter(mAdapter); + //int last_position = mAdapter.getItemCount() - 1; + //mPhonesRecycler.requestFocus(last_position); + mPhonesRecycler.smoothScrollToPosition(mPhonesRecycler.getBottom()); + InputUtils.showKeyboard(requireView()); } public String getPhone() @@ -56,7 +72,7 @@ public class PhoneFragment extends BaseMwmFragment implements View.OnClickListen { if (view.getId() == R.id.tv__append_phone) { - if (mAdapter != null) mAdapter.appendPhone(); + if (mAdapter != null && mAdapter.getItemCount() <= maxAdapter) mAdapter.appendPhone(); } } } diff --git a/android/app/src/main/res/layout/add_phone_fab.xml b/android/app/src/main/res/layout/add_phone_fab.xml new file mode 100644 index 0000000000..641f412cf0 --- /dev/null +++ b/android/app/src/main/res/layout/add_phone_fab.xml @@ -0,0 +1,12 @@ +<com.google.android.material.floatingactionbutton.FloatingActionButton + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/phone_fab" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:contentDescription="@string/editor_add_phone" + android:clickable="true" + android:focusable="true" + app:srcCompat="@drawable/ic_plus" + app:tint="?android:textColorPrimaryInverse" + app:fabSize="normal" /> diff --git a/android/app/src/main/res/layout/fragment_phone.xml b/android/app/src/main/res/layout/fragment_phone.xml index fecbdc8c56..d6964430c8 100644 --- a/android/app/src/main/res/layout/fragment_phone.xml +++ b/android/app/src/main/res/layout/fragment_phone.xml @@ -1,10 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:fitsSystemWindows="true"> + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true"> <FrameLayout style="@style/MwmWidget.FrameLayout.Elevation" @@ -20,25 +19,13 @@ android:background="?cardBackground" android:scrollbars="vertical" /> + <include + android:id="@+id/tv__append_phone" + layout="@layout/add_phone_fab" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom|end" + android:layout_margin="@dimen/margin_base" /> </FrameLayout> - <TextView - android:id="@+id/tv__append_phone" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="?clickableBackground" - android:gravity="center_vertical" - android:padding="@dimen/margin_base" - android:text="@string/editor_add_phone" - android:textAllCaps="true" - android:textAppearance="@style/MwmTextAppearance.Body3" - android:textColor="?colorAccent" - app:layout_constraintBottom_toBottomOf="@+id/frameLayout" /> - - <include - layout="@layout/shadow_bottom" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_above="@id/tv__mode_switch"/> - </androidx.constraintlayout.widget.ConstraintLayout>