Merge branch 'heads/android-14.0.0_r18' into 14-dev

This commit is contained in:
MrSluffy committed 2023-12-16 17:18:13 +08:00
1 parent 32700b0100
commit cc8f9828ab
756 files changed
+23785 -12235

No files matched your search

+26 -14
View File
@@ -21,6 +21,7 @@ import android.content.Context;
import android.graphics.Rect;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.inputmethod.InputMethodManager;
@@ -38,6 +39,8 @@ import java.util.Set;
* #onCommitCompletion
*/
public class ExtendedEditText extends EditText {
private static final String TAG = "ExtendedEditText";
private final Set<OnFocusChangeListener> mOnFocusChangeListeners = new HashSet<>();
private boolean mForceDisableSuggestions = false;
@@ -74,14 +77,9 @@ public class ExtendedEditText extends EditText {
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
// If this is a back key, propagate the key back to the listener
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
if (TextUtils.isEmpty(getText())) {
hideKeyboard();
}
if (mBackKeyListener != null) {
return mBackKeyListener.onBackKey();
}
return false;
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP
&& mBackKeyListener != null) {
return mBackKeyListener.onBackKey();
}
return super.onKeyPreIme(keyCode, event);
}
@@ -92,9 +90,18 @@ public class ExtendedEditText extends EditText {
return false;
}
public void showKeyboard() {
/**
* Synchronously shows the soft input method.
*
* @param shouldFocus whether this EditText should also request focus.
* @return true if the keyboard is shown correctly and focus is given to this
* view (if
* applicable).
*/
public boolean showKeyboard(boolean shouldFocus) {
onKeyboardShown();
showSoftInput();
boolean focusResult = !shouldFocus || requestFocus();
return focusResult && showSoftInputInternal();
}
public void hideKeyboard() {
@@ -107,10 +114,15 @@ public class ExtendedEditText extends EditText {
.keyboardStateManager().setKeyboardState(SHOW);
}
private boolean showSoftInput() {
return requestFocus() &&
getContext().getSystemService(InputMethodManager.class)
.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
private boolean showSoftInputInternal() {
boolean result = false;
InputMethodManager imm = getContext().getSystemService(InputMethodManager.class);
if (imm != null) {
result = imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
} else {
Log.w(TAG, "Failed to retrieve InputMethodManager from the system.");
}
return result;
}
public void dispatchBackKey() {