Merge changes I30b40c48,I7d02c54c,Id68ebd35

* changes:
  Use lambda when appropriate
  Remove redundant type casts
  Fix JavaDoc errors
This commit is contained in:
TreeHugger Robot
2018-01-15 02:19:15 +00:00
committed by Android (Google) Code Review
2 changed files with 45 additions and 54 deletions

View File

@@ -340,42 +340,35 @@ public class InputMethodService extends AbstractInputMethodService {
final Insets mTmpInsets = new Insets();
final int[] mTmpLocation = new int[2];
final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer =
new ViewTreeObserver.OnComputeInternalInsetsListener() {
public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
if (isExtractViewShown()) {
// In true fullscreen mode, we just say the window isn't covering
// any content so we don't impact whatever is behind.
View decor = getWindow().getWindow().getDecorView();
info.contentInsets.top = info.visibleInsets.top
= decor.getHeight();
info.touchableRegion.setEmpty();
info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME);
} else {
onComputeInsets(mTmpInsets);
info.contentInsets.top = mTmpInsets.contentTopInsets;
info.visibleInsets.top = mTmpInsets.visibleTopInsets;
info.touchableRegion.set(mTmpInsets.touchableRegion);
info.setTouchableInsets(mTmpInsets.touchableInsets);
final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer = info -> {
if (isExtractViewShown()) {
// In true fullscreen mode, we just say the window isn't covering
// any content so we don't impact whatever is behind.
View decor = getWindow().getWindow().getDecorView();
info.contentInsets.top = info.visibleInsets.top = decor.getHeight();
info.touchableRegion.setEmpty();
info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME);
} else {
onComputeInsets(mTmpInsets);
info.contentInsets.top = mTmpInsets.contentTopInsets;
info.visibleInsets.top = mTmpInsets.visibleTopInsets;
info.touchableRegion.set(mTmpInsets.touchableRegion);
info.setTouchableInsets(mTmpInsets.touchableInsets);
}
};
final View.OnClickListener mActionClickListener = v -> {
final EditorInfo ei = getCurrentInputEditorInfo();
final InputConnection ic = getCurrentInputConnection();
if (ei != null && ic != null) {
if (ei.actionId != 0) {
ic.performEditorAction(ei.actionId);
} else if ((ei.imeOptions & EditorInfo.IME_MASK_ACTION) != EditorInfo.IME_ACTION_NONE) {
ic.performEditorAction(ei.imeOptions & EditorInfo.IME_MASK_ACTION);
}
}
};
final View.OnClickListener mActionClickListener = new View.OnClickListener() {
public void onClick(View v) {
final EditorInfo ei = getCurrentInputEditorInfo();
final InputConnection ic = getCurrentInputConnection();
if (ei != null && ic != null) {
if (ei.actionId != 0) {
ic.performEditorAction(ei.actionId);
} else if ((ei.imeOptions&EditorInfo.IME_MASK_ACTION)
!= EditorInfo.IME_ACTION_NONE) {
ic.performEditorAction(ei.imeOptions&EditorInfo.IME_MASK_ACTION);
}
}
}
};
/**
* Concrete implementation of
* {@link AbstractInputMethodService.AbstractInputMethodImpl} that provides
@@ -896,20 +889,20 @@ public class InputMethodService extends AbstractInputMethodService {
mWindow.getWindow().setWindowAnimations(
com.android.internal.R.style.Animation_InputMethodFancy);
}
mFullscreenArea = (ViewGroup)mRootView.findViewById(com.android.internal.R.id.fullscreenArea);
mFullscreenArea = mRootView.findViewById(com.android.internal.R.id.fullscreenArea);
mExtractViewHidden = false;
mExtractFrame = (FrameLayout)mRootView.findViewById(android.R.id.extractArea);
mExtractFrame = mRootView.findViewById(android.R.id.extractArea);
mExtractView = null;
mExtractEditText = null;
mExtractAccessories = null;
mExtractAction = null;
mFullscreenApplied = false;
mCandidatesFrame = (FrameLayout)mRootView.findViewById(android.R.id.candidatesArea);
mInputFrame = (FrameLayout)mRootView.findViewById(android.R.id.inputArea);
mCandidatesFrame = mRootView.findViewById(android.R.id.candidatesArea);
mInputFrame = mRootView.findViewById(android.R.id.inputArea);
mInputView = null;
mIsInputViewShown = false;
mExtractFrame.setVisibility(View.GONE);
mCandidatesVisibility = getCandidatesHiddenVisibility();
mCandidatesFrame.setVisibility(mCandidatesVisibility);
@@ -1490,13 +1483,13 @@ public class InputMethodService extends AbstractInputMethodService {
ViewGroup.LayoutParams.MATCH_PARENT));
mExtractView = view;
if (view != null) {
mExtractEditText = (ExtractEditText)view.findViewById(
mExtractEditText = view.findViewById(
com.android.internal.R.id.inputExtractEditText);
mExtractEditText.setIME(this);
mExtractAction = view.findViewById(
com.android.internal.R.id.inputExtractAction);
if (mExtractAction != null) {
mExtractAccessories = (ViewGroup)view.findViewById(
mExtractAccessories = view.findViewById(
com.android.internal.R.id.inputExtractAccessories);
}
startExtractingText(false);
@@ -2754,7 +2747,7 @@ public class InputMethodService extends AbstractInputMethodService {
* application.
* This cannot be {@code null}.
* @param inputConnection {@link InputConnection} with which
* {@link InputConnection#commitContent(InputContentInfo, Bundle)} will be called.
* {@link InputConnection#commitContent(InputContentInfo, int, Bundle)} will be called.
* @hide
*/
@Override

View File

@@ -337,20 +337,23 @@ public final class InputMethodManager {
int mCursorCandEnd;
/**
* Represents an invalid action notification sequence number. {@link InputMethodManagerService}
* always issues a positive integer for action notification sequence numbers. Thus -1 is
* guaranteed to be different from any valid sequence number.
* Represents an invalid action notification sequence number.
* {@link com.android.server.InputMethodManagerService} always issues a positive integer for
* action notification sequence numbers. Thus {@code -1} is guaranteed to be different from any
* valid sequence number.
*/
private static final int NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER = -1;
/**
* The next sequence number that is to be sent to {@link InputMethodManagerService} via
* The next sequence number that is to be sent to
* {@link com.android.server.InputMethodManagerService} via
* {@link IInputMethodManager#notifyUserAction(int)} at once when a user action is observed.
*/
private int mNextUserActionNotificationSequenceNumber =
NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER;
/**
* The last sequence number that is already sent to {@link InputMethodManagerService}.
* The last sequence number that is already sent to
* {@link com.android.server.InputMethodManagerService}.
*/
private int mLastSentUserActionNotificationSequenceNumber =
NOT_AN_ACTION_NOTIFICATION_SEQUENCE_NUMBER;
@@ -1255,12 +1258,7 @@ public final class InputMethodManager {
// The view is running on a different thread than our own, so
// we need to reschedule our work for over there.
if (DEBUG) Log.v(TAG, "Starting input: reschedule to view thread");
vh.post(new Runnable() {
@Override
public void run() {
startInputInner(startInputReason, null, 0, 0, 0);
}
});
vh.post(() -> startInputInner(startInputReason, null, 0, 0, 0));
return false;
}
@@ -2429,8 +2427,8 @@ public final class InputMethodManager {
* Allow the receiver of {@link InputContentInfo} to obtain a temporary read-only access
* permission to the content.
*
* <p>See {@link android.inputmethodservice.InputMethodService#exposeContent(InputContentInfo, EditorInfo)}
* for details.</p>
* <p>See {@link android.inputmethodservice.InputMethodService#exposeContent(InputContentInfo,
* InputConnection)} for details.</p>
*
* @param token Supplies the identifying token given to an input method when it was started,
* which allows it to perform this operation on itself.