Fix: ask to unlock device if it requires keyboard interaction while in FLAG_SHOW_WHEN_LOCKED mode.

This commit is contained in:
Everton Hermann 2020-08-13 22:33:04 +02:00
parent eb2d577c2e
commit 90ec2ddd79
13 changed files with 23 additions and 19 deletions

View file

@ -96,20 +96,24 @@ public class AndroidUtils {
return context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS; return context.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
} }
public static void softKeyboardDelayed(final View view) { public static void softKeyboardDelayed(final Activity activity, final View view) {
view.post(new Runnable() { view.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (!isHardwareKeyboardAvailable(view.getContext())) { if (!isHardwareKeyboardAvailable(view.getContext())) {
showSoftKeyboard(view); showSoftKeyboard(activity,view);
} }
} }
}); });
} }
public static void showSoftKeyboard(final View view) { public static void showSoftKeyboard(final Activity activity, final View view) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) { if (imm != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
KeyguardManager keyguardManager = (KeyguardManager) view.getContext().getSystemService(Context.KEYGUARD_SERVICE);
keyguardManager.requestDismissKeyguard(activity,null);
}
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
} }
} }

View file

@ -249,7 +249,7 @@ public class FavoritesSearchFragment extends DialogFragment {
private void openKeyboard() { private void openKeyboard() {
searchEditText.requestFocus(); searchEditText.requestFocus();
AndroidUtils.softKeyboardDelayed(searchEditText); AndroidUtils.softKeyboardDelayed(getActivity(), searchEditText);
} }
public void hideKeyboard() { public void hideKeyboard() {

View file

@ -113,7 +113,7 @@ public class FavoriteDialogs {
editText.requestFocus(); editText.requestFocus();
final AutoCompleteTextView cat = (AutoCompleteTextView) dialog.findViewById(R.id.Category); final AutoCompleteTextView cat = (AutoCompleteTextView) dialog.findViewById(R.id.Category);
cat.setText(point.getCategory()); cat.setText(point.getCategory());
AndroidUtils.softKeyboardDelayed(editText); AndroidUtils.softKeyboardDelayed(activity, editText);
} }
public static Dialog createAddFavouriteDialog(final Activity activity, final Bundle args) { public static Dialog createAddFavouriteDialog(final Activity activity, final Bundle args) {

View file

@ -78,7 +78,7 @@ public class EditCategoryDialogFragment extends DialogFragment {
nameEdit = (EditText)v.findViewById(R.id.edit_name); nameEdit = (EditText)v.findViewById(R.id.edit_name);
nameEdit.setText(name); nameEdit.setText(name);
nameEdit.requestFocus(); nameEdit.requestFocus();
AndroidUtils.softKeyboardDelayed(nameEdit); AndroidUtils.softKeyboardDelayed(getActivity(), nameEdit);
colorSpinner = (Spinner)v.findViewById(R.id.edit_color); colorSpinner = (Spinner)v.findViewById(R.id.edit_color);
final TIntArrayList colors = new TIntArrayList(); final TIntArrayList colors = new TIntArrayList();
final int intColor = color; final int intColor = color;

View file

@ -207,7 +207,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
if (editor != null && editor.isNew()) { if (editor != null && editor.isNew()) {
nameEdit.selectAll(); nameEdit.selectAll();
nameEdit.requestFocus(); nameEdit.requestFocus();
AndroidUtils.softKeyboardDelayed(nameEdit); AndroidUtils.softKeyboardDelayed(getActivity(), nameEdit);
} }
} }

View file

@ -235,7 +235,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
addDelDescription.setText(view.getResources().getString(R.string.delete_description)); addDelDescription.setText(view.getResources().getString(R.string.delete_description));
View descriptionEdit = view.findViewById(R.id.description_edit); View descriptionEdit = view.findViewById(R.id.description_edit);
descriptionEdit.requestFocus(); descriptionEdit.requestFocus();
AndroidUtils.softKeyboardDelayed(descriptionEdit); AndroidUtils.softKeyboardDelayed(getActivity(), descriptionEdit);
} else { } else {
descriptionCaption.setVisibility(View.GONE); descriptionCaption.setVisibility(View.GONE);
addDelDescription.setText(view.getResources().getString(R.string.add_description)); addDelDescription.setText(view.getResources().getString(R.string.add_description));
@ -267,7 +267,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment {
deleteIcon.setVisibility(View.GONE); deleteIcon.setVisibility(View.GONE);
nameEdit.selectAll(); nameEdit.selectAll();
nameEdit.requestFocus(); nameEdit.requestFocus();
AndroidUtils.softKeyboardDelayed(nameEdit); AndroidUtils.softKeyboardDelayed(getActivity(), nameEdit);
} else { } else {
toolbarAction.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeColorResId)); toolbarAction.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_delete_dark, activeColorResId));
deleteButton.setVisibility(View.VISIBLE); deleteButton.setVisibility(View.VISIBLE);

View file

@ -391,7 +391,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
} }
final View focusedView = getDialog().getCurrentFocus(); final View focusedView = getDialog().getCurrentFocus();
if (focusedView != null) { if (focusedView != null) {
AndroidUtils.softKeyboardDelayed(focusedView); AndroidUtils.softKeyboardDelayed(getActivity(), focusedView);
} }
} }
}); });
@ -707,7 +707,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
final View focusedView = getDialog().getCurrentFocus(); final View focusedView = getDialog().getCurrentFocus();
if (focusedView != null) { if (focusedView != null) {
if (!isOsmandKeyboardOn()) { if (!isOsmandKeyboardOn()) {
AndroidUtils.softKeyboardDelayed(focusedView); AndroidUtils.softKeyboardDelayed(getActivity(), focusedView);
} }
} }
} }
@ -1039,7 +1039,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
AndroidUtils.showSoftKeyboard(focusedView); AndroidUtils.showSoftKeyboard(getActivity(), focusedView);
} }
}, 200); }, 200);
} }
@ -1271,7 +1271,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
changeOsmandKeyboardVisibility(true); changeOsmandKeyboardVisibility(true);
} }
} else if (!softKeyboardShown && focusedView != null) { } else if (!softKeyboardShown && focusedView != null) {
AndroidUtils.softKeyboardDelayed(focusedView); AndroidUtils.softKeyboardDelayed(getActivity(), focusedView);
} }
} }

View file

@ -281,7 +281,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
}); });
poiNameEditText.setText(editPoiData.getTag(OSMSettings.OSMTagKey.NAME.getValue())); poiNameEditText.setText(editPoiData.getTag(OSMSettings.OSMTagKey.NAME.getValue()));
poiNameEditText.requestFocus(); poiNameEditText.requestFocus();
AndroidUtils.showSoftKeyboard(poiNameEditText); AndroidUtils.showSoftKeyboard(getActivity(), poiNameEditText);
poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout); poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout);
poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText); poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText);
AndroidUtils.setTextHorizontalGravity(poiTypeEditText, Gravity.START); AndroidUtils.setTextHorizontalGravity(poiTypeEditText, Gravity.START);

View file

@ -450,7 +450,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
((EditText) view.findViewById(R.id.message_field)).setText(text); ((EditText) view.findViewById(R.id.message_field)).setText(text);
} }
view.findViewById(R.id.message_field).requestFocus(); view.findViewById(R.id.message_field).requestFocus();
AndroidUtils.softKeyboardDelayed(view.findViewById(R.id.message_field)); AndroidUtils.softKeyboardDelayed(activity, view.findViewById(R.id.message_field));
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.shared_string_commit); builder.setTitle(R.string.shared_string_commit);

View file

@ -223,7 +223,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment implements OnFi
@Override @Override
public void onClick(View view) { public void onClick(View view) {
searchEditText.requestFocus(); searchEditText.requestFocus();
AndroidUtils.showSoftKeyboard(searchEditText); AndroidUtils.showSoftKeyboard(getActivity(), searchEditText);
} }
}); });
searchCloseIcon = view.findViewById(R.id.search_close); searchCloseIcon = view.findViewById(R.id.search_close);

View file

@ -1928,7 +1928,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
private void openKeyboard() { private void openKeyboard() {
searchEditText.requestFocus(); searchEditText.requestFocus();
AndroidUtils.softKeyboardDelayed(searchEditText); AndroidUtils.softKeyboardDelayed(getActivity(), searchEditText);
} }
public void replaceQueryWithText(String txt) { public void replaceQueryWithText(String txt) {

View file

@ -210,7 +210,7 @@ public class QuickSearchSubCategoriesFragment extends BaseOsmAndDialogFragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
searchEditText.requestFocus(); searchEditText.requestFocus();
AndroidUtils.showSoftKeyboard(searchEditText); AndroidUtils.showSoftKeyboard(getActivity(), searchEditText);
} }
}); });
ImageView searchCloseIcon = root.findViewById(R.id.search_close); ImageView searchCloseIcon = root.findViewById(R.id.search_close);

View file

@ -368,7 +368,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment {
public void onFocusChange(View v, boolean hasFocus) { public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){ if(hasFocus){
profileName.setSelection(profileName.getText().length()); profileName.setSelection(profileName.getText().length());
AndroidUtils.showSoftKeyboard(profileName); AndroidUtils.showSoftKeyboard(getMyActivity(), profileName);
} }
} }
}); });