[android] Focus name when editing "Unknown Place" bookmarks

Fixes #7090

Signed-off-by: Simon Klüber <48260138+sklueber@users.noreply.github.com>
This commit is contained in:
Simon Klüber 2024-01-12 14:02:13 -06:00 committed by Roman Tsisyk
parent 167bde3a94
commit ce37d12ce3

View file

@ -16,6 +16,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentFactory;
import androidx.fragment.app.FragmentManager;
@ -125,6 +127,22 @@ public class EditBookmarkFragment extends BaseMwmDialogFragment implements View.
initToolbar(view);
}
@Override
public void onStart()
{
super.onStart();
// Focus name and show keyboard for "Unknown Place" bookmarks
if (mBookmark != null && mBookmark.getName().equals(getString(R.string.core_placepage_unknown_place)))
{
mEtName.requestFocus();
mEtName.selectAll();
// Recommended way of showing the keyboard on activity start
// https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/visibility#ShowReliably
WindowCompat.getInsetsController(requireActivity().getWindow(), mEtName).show(WindowInsetsCompat.Type.ime());
}
}
private void initToolbar(View view)
{
Toolbar toolbar = view.findViewById(R.id.toolbar);