|
|
|
|
@@ -16,6 +16,7 @@
|
|
|
|
|
|
|
|
|
|
package android.view.inputmethod;
|
|
|
|
|
|
|
|
|
|
import android.annotation.BinderThread;
|
|
|
|
|
import android.annotation.CallbackExecutor;
|
|
|
|
|
import android.annotation.NonNull;
|
|
|
|
|
import android.annotation.Nullable;
|
|
|
|
|
@@ -94,19 +95,21 @@ public final class InlineSuggestion implements Parcelable {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Inflates a view with the content of this suggestion at a specific size.
|
|
|
|
|
* The size must be between the {@link InlinePresentationSpec#getMinSize() min size}
|
|
|
|
|
* and the {@link InlinePresentationSpec#getMaxSize() max size} of the presentation
|
|
|
|
|
* spec returned by {@link InlineSuggestionInfo#getPresentationSpec()}.
|
|
|
|
|
*
|
|
|
|
|
* @param context Context in which to inflate the view.
|
|
|
|
|
* @param size The size at which to inflate the suggestion.
|
|
|
|
|
* @param callback Callback for receiving the inflated view.
|
|
|
|
|
* <p> The caller can attach an {@link View.OnClickListener} and/or an
|
|
|
|
|
* {@link View.OnLongClickListener} to the view in the {@code callback} to receive click and
|
|
|
|
|
* long click events on the view.
|
|
|
|
|
*
|
|
|
|
|
* @param context Context in which to inflate the view.
|
|
|
|
|
* @param size The size at which to inflate the suggestion.
|
|
|
|
|
* @param callback Callback for receiving the inflated view.
|
|
|
|
|
* @throws IllegalArgumentException If an invalid argument is passed.
|
|
|
|
|
* @throws IllegalStateException if this method is already called.
|
|
|
|
|
* @throws IllegalStateException If this method is already called.
|
|
|
|
|
*/
|
|
|
|
|
public void inflate(@NonNull Context context, @NonNull Size size,
|
|
|
|
|
@NonNull @CallbackExecutor Executor callbackExecutor,
|
|
|
|
|
@@ -151,12 +154,31 @@ public final class InlineSuggestion implements Parcelable {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@BinderThread
|
|
|
|
|
public void onContent(SurfaceControlViewHost.SurfacePackage content) {
|
|
|
|
|
final InlineContentCallbackImpl callbackImpl = mCallbackImpl.get();
|
|
|
|
|
if (callbackImpl != null) {
|
|
|
|
|
callbackImpl.onContent(content);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@BinderThread
|
|
|
|
|
public void onClick() {
|
|
|
|
|
final InlineContentCallbackImpl callbackImpl = mCallbackImpl.get();
|
|
|
|
|
if (callbackImpl != null) {
|
|
|
|
|
callbackImpl.onClick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@BinderThread
|
|
|
|
|
public void onLongClick() {
|
|
|
|
|
final InlineContentCallbackImpl callbackImpl = mCallbackImpl.get();
|
|
|
|
|
if (callbackImpl != null) {
|
|
|
|
|
callbackImpl.onLongClick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static final class InlineContentCallbackImpl {
|
|
|
|
|
@@ -164,6 +186,7 @@ public final class InlineSuggestion implements Parcelable {
|
|
|
|
|
private final @NonNull Context mContext;
|
|
|
|
|
private final @NonNull Executor mCallbackExecutor;
|
|
|
|
|
private final @NonNull Consumer<View> mCallback;
|
|
|
|
|
private @Nullable View mView;
|
|
|
|
|
|
|
|
|
|
InlineContentCallbackImpl(@NonNull Context context,
|
|
|
|
|
@NonNull @CallbackExecutor Executor callbackExecutor,
|
|
|
|
|
@@ -173,12 +196,27 @@ public final class InlineSuggestion implements Parcelable {
|
|
|
|
|
mCallback = callback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@BinderThread
|
|
|
|
|
public void onContent(SurfaceControlViewHost.SurfacePackage content) {
|
|
|
|
|
if (content == null) {
|
|
|
|
|
mCallbackExecutor.execute(() -> mCallback.accept(/* view */null));
|
|
|
|
|
} else {
|
|
|
|
|
mCallbackExecutor.execute(
|
|
|
|
|
() -> mCallback.accept(new InlineContentView(mContext, content)));
|
|
|
|
|
mView = new InlineContentView(mContext, content);
|
|
|
|
|
mCallbackExecutor.execute(() -> mCallback.accept(mView));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@BinderThread
|
|
|
|
|
public void onClick() {
|
|
|
|
|
if (mView != null && mView.hasOnClickListeners()) {
|
|
|
|
|
mView.callOnClick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@BinderThread
|
|
|
|
|
public void onLongClick() {
|
|
|
|
|
if (mView != null && mView.hasOnLongClickListeners()) {
|
|
|
|
|
mView.performLongClick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -201,7 +239,7 @@ public final class InlineSuggestion implements Parcelable {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Code below generated by codegen v1.0.14.
|
|
|
|
|
// Code below generated by codegen v1.0.15.
|
|
|
|
|
//
|
|
|
|
|
// DO NOT MODIFY!
|
|
|
|
|
// CHECKSTYLE:OFF Generated code
|
|
|
|
|
@@ -360,8 +398,8 @@ public final class InlineSuggestion implements Parcelable {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@DataClass.Generated(
|
|
|
|
|
time = 1581929285156L,
|
|
|
|
|
codegenVersion = "1.0.14",
|
|
|
|
|
time = 1583889058241L,
|
|
|
|
|
codegenVersion = "1.0.15",
|
|
|
|
|
sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestion.java",
|
|
|
|
|
inputSignatures = "private static final java.lang.String TAG\nprivate final @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo mInfo\nprivate final @android.annotation.Nullable com.android.internal.view.inline.IInlineContentProvider mContentProvider\nprivate @com.android.internal.util.DataClass.ParcelWith(android.view.inputmethod.InlineSuggestion.InlineContentCallbackImplParceling.class) @android.annotation.Nullable android.view.inputmethod.InlineSuggestion.InlineContentCallbackImpl mInlineContentCallback\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestion newInlineSuggestion(android.view.inputmethod.InlineSuggestionInfo)\npublic void inflate(android.content.Context,android.util.Size,java.util.concurrent.Executor,java.util.function.Consumer<android.view.View>)\nprivate synchronized android.view.inputmethod.InlineSuggestion.InlineContentCallbackImpl getInlineContentCallback(android.content.Context,java.util.concurrent.Executor,java.util.function.Consumer<android.view.View>)\nclass InlineSuggestion extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
|
|
|
|
|
@Deprecated
|
|
|
|
|
|