forked from organicmaps/organicmaps
[android] Fix search floating toolbar focus on Android 8 and lower
Signed-off-by: Arnaud Vergnet <arnaud.vergnet@mailo.com>
This commit is contained in:
parent
8c4b8c4166
commit
c0a73aea48
2 changed files with 16 additions and 10 deletions
|
@ -27,6 +27,8 @@ public class FloatingSearchToolbarController extends SearchToolbarController
|
|||
{
|
||||
super(activity.getWindow().getDecorView(), activity);
|
||||
mListener = listener;
|
||||
// We only want to detect a click on the input and not allow editing.
|
||||
disableQueryEditing();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.mapswithme.maps.widget;
|
|||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -19,8 +20,7 @@ import com.mapswithme.util.InputUtils;
|
|||
import com.mapswithme.util.StringUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
public class SearchToolbarController extends ToolbarController
|
||||
implements View.OnClickListener, View.OnFocusChangeListener
|
||||
public class SearchToolbarController extends ToolbarController implements View.OnClickListener
|
||||
{
|
||||
private static final int REQUEST_VOICE_RECOGNITION = 0xCA11;
|
||||
@Nullable
|
||||
|
@ -62,7 +62,7 @@ public class SearchToolbarController extends ToolbarController
|
|||
mSearchContainer = getToolbar().findViewById(R.id.search_container);
|
||||
mBack = mSearchContainer.findViewById(R.id.back);
|
||||
mQuery = mSearchContainer.findViewById(R.id.query);
|
||||
mQuery.setOnFocusChangeListener(this);
|
||||
mQuery.setOnClickListener(this);
|
||||
mQuery.addTextChangedListener(mTextWatcher);
|
||||
mQuery.setOnEditorActionListener(
|
||||
(v, actionId, event) ->
|
||||
|
@ -146,6 +146,13 @@ public class SearchToolbarController extends ToolbarController
|
|||
return R.string.search;
|
||||
}
|
||||
|
||||
protected void disableQueryEditing()
|
||||
{
|
||||
mQuery.setFocusable(false);
|
||||
mQuery.setLongClickable(false);
|
||||
mQuery.setInputType(InputType.TYPE_NULL);
|
||||
}
|
||||
|
||||
public String getQuery()
|
||||
{
|
||||
return (UiUtils.isVisible(mSearchContainer) ? mQuery.getText().toString() : "");
|
||||
|
@ -185,13 +192,6 @@ public class SearchToolbarController extends ToolbarController
|
|||
UiUtils.showIf(show, mProgress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b)
|
||||
{
|
||||
if (view.getId()== R.id.query && b)
|
||||
onQueryClick(getQuery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
|
@ -201,6 +201,10 @@ public class SearchToolbarController extends ToolbarController
|
|||
onClearClick();
|
||||
break;
|
||||
|
||||
case R.id.query:
|
||||
onQueryClick(getQuery());
|
||||
break;
|
||||
|
||||
case R.id.voice_input:
|
||||
onVoiceInputClick();
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue