summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/java/app/organicmaps/MwmActivity.java32
-rw-r--r--android/app/src/main/java/app/organicmaps/widget/SearchEditText.java20
2 files changed, 45 insertions, 7 deletions
diff --git a/android/app/src/main/java/app/organicmaps/MwmActivity.java b/android/app/src/main/java/app/organicmaps/MwmActivity.java
index 0d09317150..a0b69972d9 100644
--- a/android/app/src/main/java/app/organicmaps/MwmActivity.java
+++ b/android/app/src/main/java/app/organicmaps/MwmActivity.java
@@ -403,6 +403,21 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (mSearchPageViewModel == null)
return;
mSearchPageViewModel.setSearchEnabled(false, null);
+ // 701KC: and put the sheet itself away. The ViewModel only disables the page; the sheet is a
+ // BottomSheet of THIS layout and stayed where it was, so a closed search page could still be
+ // seen underneath the map / the next sheet ("検索欄が後ろに回る", measured).
+ final View page = findViewById(R.id.search_page_container);
+ if (page != null)
+ {
+ try
+ {
+ BottomSheetBehavior.from(page).setState(BottomSheetBehavior.STATE_HIDDEN);
+ }
+ catch (IllegalArgumentException notASheet)
+ {
+ UiUtils.hide(page);
+ }
+ }
}
private void showBookmarks()
@@ -2850,6 +2865,23 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP
&& event.getRepeatCount() == 0 && isSearchPageShowing())
{
+ // 701KC: while the IME is up, クリア / BACK belongs to the TEXT, not to the page. The handset's
+ // clear key sends BACK, and the IME forwards it, so the page closed (and jumped back to the
+ // map or to the routing sheet behind it) in the middle of a query - measured complaint
+ // ("IMEの文字をクリアで消そうとするとmapのほうにとんでもどる"). First press: clear the query and
+ // put the keyboard away. A second press, with no keyboard up, does what it always did.
+ if (isImeVisible())
+ {
+ for (EditText field : searchFields())
+ {
+ if (!field.isShown() || !field.hasFocus())
+ continue;
+ if (field.getText() != null && field.getText().length() > 0)
+ field.setText("");
+ app.organicmaps.util.InputUtils.hideKeyboard(field);
+ return true;
+ }
+ }
// 701KC: クリア / BACK while a query is typed must clear the text, not throw the page away.
// Closing on the first press lost what the user was in the middle of typing (measured
// complaint: "文字を打っている状態でもクリアを押すと閉じてしまう"). The page closes only once
diff --git a/android/app/src/main/java/app/organicmaps/widget/SearchEditText.java b/android/app/src/main/java/app/organicmaps/widget/SearchEditText.java
index 23440529ad..be84e3d205 100644
--- a/android/app/src/main/java/app/organicmaps/widget/SearchEditText.java
+++ b/android/app/src/main/java/app/organicmaps/widget/SearchEditText.java
@@ -82,15 +82,21 @@ public class SearchEditText extends TextInputEditText
@Override
public boolean onKeyPreIme(int keyCode, @NonNull KeyEvent event)
{
- // 701KC: while typing, BACK / クリア clears the text first and keeps the page. Closing on the
- // first press threw away the query the user was in the middle of
- // ("文字を打っている状態でもクリアを押すと閉じてしまう"); the page only closes once the box is empty.
- if (event.getAction() == KeyEvent.ACTION_UP && event.getRepeatCount() == 0
+ // 701KC: while this box is a live editor, BACK / クリア belongs to the TEXT, not to the page.
+ // The handset's clear key sends BACK and the IME forwards it, so the page closed underneath the
+ // user in the middle of a query ("IMEの文字をクリアで消そうとするとmapのほうにとんでもどる").
+ // Note the composing text is NOT in getText() yet - that is why the "clear if non-empty" check
+ // misfired while the conversion was still unconfirmed, and why pressing 確定 first made the
+ // problem disappear.
+ if (event.getAction() == KeyEvent.ACTION_UP && event.getRepeatCount() == 0 && mImeAllowed
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_CLEAR
- || keyCode == KeyEvent.KEYCODE_ESCAPE)
- && getText() != null && getText().length() > 0)
+ || keyCode == KeyEvent.KEYCODE_ESCAPE))
{
- setText("");
+ if (getText() != null && getText().length() > 0)
+ setText("");
+ app.organicmaps.util.InputUtils.hideKeyboard(this);
+ // Stop being an editor: the next BACK is a page-level BACK again.
+ setImeAllowed(false);
return true;
}
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP