diff options
| author | Joanne Chung <joannechung@google.com> | 2021-12-16 05:56:41 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-12-16 05:56:41 +0000 |
| commit | fcf3a92a1d6cb91b330aa1451d1bae83cd1a0458 (patch) | |
| tree | f5bc545581b18200d0783b3272842040b1a1997d /core/java | |
| parent | 036895df5b002f280b4d0f357fe88b1abcc9144d (diff) | |
| parent | 41c4a0ac71ab8e7975880ef7b7aceed5f03959a4 (diff) | |
Merge "Initial layout of selection toolbar."
Diffstat (limited to 'core/java')
14 files changed, 1067 insertions, 0 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 5002a59440e9..bd5fb1163800 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -227,6 +227,8 @@ import android.view.contentcapture.ContentCaptureManager; import android.view.contentcapture.IContentCaptureManager; import android.view.displayhash.DisplayHashManager; import android.view.inputmethod.InputMethodManager; +import android.view.selectiontoolbar.ISelectionToolbarManager; +import android.view.selectiontoolbar.SelectionToolbarManager; import android.view.textclassifier.TextClassificationManager; import android.view.textservice.TextServicesManager; import android.view.translation.ITranslationManager; @@ -366,6 +368,15 @@ public final class SystemServiceRegistry { return new TextClassificationManager(ctx); }}); + registerService(Context.SELECTION_TOOLBAR_SERVICE, SelectionToolbarManager.class, + new CachedServiceFetcher<SelectionToolbarManager>() { + @Override + public SelectionToolbarManager createService(ContextImpl ctx) { + IBinder b = ServiceManager.getService(Context.SELECTION_TOOLBAR_SERVICE); + return new SelectionToolbarManager(ctx.getOuterContext(), + ISelectionToolbarManager.Stub.asInterface(b)); + }}); + registerService(Context.FONT_SERVICE, FontManager.class, new CachedServiceFetcher<FontManager>() { @Override diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 543239bef101..6d13712b68ae 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -4790,6 +4790,15 @@ public abstract class Context { /** * Use with {@link #getSystemService(String)} to retrieve a + * {@link android.view.selectiontoolbar.SelectionToolbarManager} for selection toolbar service. + * + * @see #getSystemService(String) + * @hide + */ + public static final String SELECTION_TOOLBAR_SERVICE = "selection_toolbar"; + + /** + * Use with {@link #getSystemService(String)} to retrieve a * {@link android.graphics.fonts.FontManager} for font services. * * @see #getSystemService(String) diff --git a/core/java/android/view/selectiontoolbar/ISelectionToolbarCallback.aidl b/core/java/android/view/selectiontoolbar/ISelectionToolbarCallback.aidl new file mode 100644 index 000000000000..0e8e57bd475d --- /dev/null +++ b/core/java/android/view/selectiontoolbar/ISelectionToolbarCallback.aidl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +import android.view.selectiontoolbar.ToolbarMenuItem; +import android.view.selectiontoolbar.WidgetInfo; + +/** + * Binder interface to notify the selection toolbar events from one process to the other. + * @hide + */ +oneway interface ISelectionToolbarCallback { + void onShown(in WidgetInfo info); + void onHidden(); + void onDismissed(); + void onWidgetUpdated(in WidgetInfo info); + void onMenuItemClicked(in ToolbarMenuItem item); + void onError(int errorCode); +} diff --git a/core/java/android/view/selectiontoolbar/ISelectionToolbarManager.aidl b/core/java/android/view/selectiontoolbar/ISelectionToolbarManager.aidl new file mode 100644 index 000000000000..4a647ada1d6c --- /dev/null +++ b/core/java/android/view/selectiontoolbar/ISelectionToolbarManager.aidl @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +import android.view.selectiontoolbar.ISelectionToolbarCallback; +import android.view.selectiontoolbar.ShowInfo; + +/** + * Mediator between apps and selection toolbar service implementation. + * + * @hide + */ +oneway interface ISelectionToolbarManager { + void showToolbar(in ShowInfo showInfo, in ISelectionToolbarCallback callback, int userId); + void hideToolbar(long widgetToken, int userId); + void dismissToolbar(long widgetToken, int userId); +}
\ No newline at end of file diff --git a/core/java/android/view/selectiontoolbar/OWNERS b/core/java/android/view/selectiontoolbar/OWNERS new file mode 100644 index 000000000000..5500b92868dd --- /dev/null +++ b/core/java/android/view/selectiontoolbar/OWNERS @@ -0,0 +1,10 @@ +# Bug component: 709498 + +augale@google.com +joannechung@google.com +licha@google.com +lpeter@google.com +svetoslavganov@google.com +toki@google.com +tonymak@google.com +tymtsai@google.com
\ No newline at end of file diff --git a/core/java/android/view/selectiontoolbar/SelectionContext.aidl b/core/java/android/view/selectiontoolbar/SelectionContext.aidl new file mode 100644 index 000000000000..52068312d4a1 --- /dev/null +++ b/core/java/android/view/selectiontoolbar/SelectionContext.aidl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +/** + * @hide + */ +parcelable SelectionContext; diff --git a/core/java/android/view/selectiontoolbar/SelectionContext.java b/core/java/android/view/selectiontoolbar/SelectionContext.java new file mode 100644 index 000000000000..21b8d8f11d25 --- /dev/null +++ b/core/java/android/view/selectiontoolbar/SelectionContext.java @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +import android.annotation.NonNull; +import android.os.Parcelable; + +import com.android.internal.util.DataClass; + +/** + * The class holds information for a selection. + * + * @hide + */ +@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true) +public final class SelectionContext implements Parcelable { + + /** + * The start index of a selection. + */ + private final int mStartIndex; + + /** + * The end index of a selection. + */ + private final int mEndIndex; + + + + // Code below generated by codegen v1.0.23. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/selectiontoolbar/SelectionContext.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + @DataClass.Generated.Member + /* package-private */ SelectionContext( + int startIndex, + int endIndex) { + this.mStartIndex = startIndex; + this.mEndIndex = endIndex; + + // onConstructed(); // You can define this method to get a callback + } + + /** + * The start index of a selection. + */ + @DataClass.Generated.Member + public int getStartIndex() { + return mStartIndex; + } + + /** + * The end index of a selection. + */ + @DataClass.Generated.Member + public int getEndIndex() { + return mEndIndex; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "SelectionContext { " + + "startIndex = " + mStartIndex + ", " + + "endIndex = " + mEndIndex + + " }"; + } + + @Override + @DataClass.Generated.Member + public boolean equals(@android.annotation.Nullable Object o) { + // You can override field equality logic by defining either of the methods like: + // boolean fieldNameEquals(SelectionContext other) { ... } + // boolean fieldNameEquals(FieldType otherValue) { ... } + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + @SuppressWarnings("unchecked") + SelectionContext that = (SelectionContext) o; + //noinspection PointlessBooleanExpression + return true + && mStartIndex == that.mStartIndex + && mEndIndex == that.mEndIndex; + } + + @Override + @DataClass.Generated.Member + public int hashCode() { + // You can override field hashCode logic by defining methods like: + // int fieldNameHashCode() { ... } + + int _hash = 1; + _hash = 31 * _hash + mStartIndex; + _hash = 31 * _hash + mEndIndex; + return _hash; + } + + @Override + @DataClass.Generated.Member + public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { + // You can override field parcelling by defining methods like: + // void parcelFieldName(Parcel dest, int flags) { ... } + + dest.writeInt(mStartIndex); + dest.writeInt(mEndIndex); + } + + @Override + @DataClass.Generated.Member + public int describeContents() { return 0; } + + /** @hide */ + @SuppressWarnings({"unchecked", "RedundantCast"}) + @DataClass.Generated.Member + /* package-private */ SelectionContext(@NonNull android.os.Parcel in) { + // You can override field unparcelling by defining methods like: + // static FieldType unparcelFieldName(Parcel in) { ... } + + int startIndex = in.readInt(); + int endIndex = in.readInt(); + + this.mStartIndex = startIndex; + this.mEndIndex = endIndex; + + // onConstructed(); // You can define this method to get a callback + } + + @DataClass.Generated.Member + public static final @NonNull Parcelable.Creator<SelectionContext> CREATOR + = new Parcelable.Creator<SelectionContext>() { + @Override + public SelectionContext[] newArray(int size) { + return new SelectionContext[size]; + } + + @Override + public SelectionContext createFromParcel(@NonNull android.os.Parcel in) { + return new SelectionContext(in); + } + }; + + /** + * A builder for {@link SelectionContext} + */ + @SuppressWarnings("WeakerAccess") + @DataClass.Generated.Member + public static final class Builder { + + private int mStartIndex; + private int mEndIndex; + + private long mBuilderFieldsSet = 0L; + + /** + * Creates a new Builder. + * + * @param startIndex + * The start index of a selection. + * @param endIndex + * The end index of a selection. + */ + public Builder( + int startIndex, + int endIndex) { + mStartIndex = startIndex; + mEndIndex = endIndex; + } + + /** + * The start index of a selection. + */ + @DataClass.Generated.Member + public @NonNull Builder setStartIndex(int value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x1; + mStartIndex = value; + return this; + } + + /** + * The end index of a selection. + */ + @DataClass.Generated.Member + public @NonNull Builder setEndIndex(int value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x2; + mEndIndex = value; + return this; + } + + /** Builds the instance. This builder should not be touched after calling this! */ + public @NonNull SelectionContext build() { + checkNotUsed(); + mBuilderFieldsSet |= 0x4; // Mark builder used + + SelectionContext o = new SelectionContext( + mStartIndex, + mEndIndex); + return o; + } + + private void checkNotUsed() { + if ((mBuilderFieldsSet & 0x4) != 0) { + throw new IllegalStateException( + "This Builder should not be reused. Use a new Builder instance instead"); + } + } + } + + @DataClass.Generated( + time = 1639488292248L, + codegenVersion = "1.0.23", + sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/SelectionContext.java", + inputSignatures = "private final int mStartIndex\nprivate final int mEndIndex\nclass SelectionContext extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true)") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + +} diff --git a/core/java/android/view/selectiontoolbar/SelectionToolbarManager.java b/core/java/android/view/selectiontoolbar/SelectionToolbarManager.java new file mode 100644 index 000000000000..60688eaa3600 --- /dev/null +++ b/core/java/android/view/selectiontoolbar/SelectionToolbarManager.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +import android.annotation.NonNull; +import android.annotation.SystemService; +import android.content.Context; +import android.os.RemoteException; + +import java.util.Objects; + +/** + * The {@link SelectionToolbarManager} class provides ways for apps to control the + * selection toolbar. + * + * @hide + */ +@SystemService(Context.SELECTION_TOOLBAR_SERVICE) +public final class SelectionToolbarManager { + + private static final String TAG = "SelectionToolbar"; + + /** + * The tag which uses for enabling debug log dump. To enable it, we can use command "adb shell + * setprop log.tag.UiTranslation DEBUG". + */ + public static final String LOG_TAG = "SelectionToolbar"; + + + @NonNull + private final Context mContext; + private final ISelectionToolbarManager mService; + + public SelectionToolbarManager(@NonNull Context context, + @NonNull ISelectionToolbarManager service) { + mContext = Objects.requireNonNull(context); + mService = service; + } + + /** + * Request to show selection toolbar for a given View. + */ + public void showToolbar(@NonNull ShowInfo showInfo, + @NonNull ISelectionToolbarCallback callback) { + try { + Objects.requireNonNull(showInfo); + Objects.requireNonNull(callback); + mService.showToolbar(showInfo, callback, mContext.getUserId()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Request to hide selection toolbar. + */ + public void hideToolbar(long widgetToken) { + try { + mService.hideToolbar(widgetToken, mContext.getUserId()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Dismiss to dismiss selection toolbar. + */ + public void dismissToolbar(long widgetToken) { + try { + mService.dismissToolbar(widgetToken, mContext.getUserId()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } +} diff --git a/core/java/android/view/selectiontoolbar/ShowInfo.aidl b/core/java/android/view/selectiontoolbar/ShowInfo.aidl new file mode 100644 index 000000000000..dce9c15dce3e --- /dev/null +++ b/core/java/android/view/selectiontoolbar/ShowInfo.aidl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +/** + * @hide + */ +parcelable ShowInfo; diff --git a/core/java/android/view/selectiontoolbar/ShowInfo.java b/core/java/android/view/selectiontoolbar/ShowInfo.java new file mode 100644 index 000000000000..bbbd5c0df0b4 --- /dev/null +++ b/core/java/android/view/selectiontoolbar/ShowInfo.java @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +import android.annotation.NonNull; +import android.os.Parcelable; + +import com.android.internal.util.DataClass; + + +/** + * The class holds menu information for render service to render the selection toolbar. + * + * @hide + */ +@DataClass(genToString = true, genEqualsHashCode = true) +public final class ShowInfo implements Parcelable { + /** + * The token that is used to identify the selection toolbar. This is initially set to 0 + * until a selection toolbar has been created for the showToolbar request. + */ + private final long mWidgetToken; + + // TODO: add members when the code really uses it + + + + + // Code below generated by codegen v1.0.23. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/selectiontoolbar/ShowInfo.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + /** + * Creates a new ShowInfo. + * + * @param widgetToken + * The token that is used to identify the selection toolbar. + */ + @DataClass.Generated.Member + public ShowInfo( + long widgetToken) { + this.mWidgetToken = widgetToken; + + // onConstructed(); // You can define this method to get a callback + } + + /** + * The token that is used to identify the selection toolbar. + */ + @DataClass.Generated.Member + public long getWidgetToken() { + return mWidgetToken; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "ShowInfo { " + + "widgetToken = " + mWidgetToken + + " }"; + } + + @Override + @DataClass.Generated.Member + public boolean equals(@android.annotation.Nullable Object o) { + // You can override field equality logic by defining either of the methods like: + // boolean fieldNameEquals(ShowInfo other) { ... } + // boolean fieldNameEquals(FieldType otherValue) { ... } + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + @SuppressWarnings("unchecked") + ShowInfo that = (ShowInfo) o; + //noinspection PointlessBooleanExpression + return true + && mWidgetToken == that.mWidgetToken; + } + + @Override + @DataClass.Generated.Member + public int hashCode() { + // You can override field hashCode logic by defining methods like: + // int fieldNameHashCode() { ... } + + int _hash = 1; + _hash = 31 * _hash + Long.hashCode(mWidgetToken); + return _hash; + } + + @Override + @DataClass.Generated.Member + public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { + // You can override field parcelling by defining methods like: + // void parcelFieldName(Parcel dest, int flags) { ... } + + dest.writeLong(mWidgetToken); + } + + @Override + @DataClass.Generated.Member + public int describeContents() { return 0; } + + /** @hide */ + @SuppressWarnings({"unchecked", "RedundantCast"}) + @DataClass.Generated.Member + /* package-private */ ShowInfo(@NonNull android.os.Parcel in) { + // You can override field unparcelling by defining methods like: + // static FieldType unparcelFieldName(Parcel in) { ... } + + long widgetToken = in.readLong(); + + this.mWidgetToken = widgetToken; + + // onConstructed(); // You can define this method to get a callback + } + + @DataClass.Generated.Member + public static final @NonNull Parcelable.Creator<ShowInfo> CREATOR + = new Parcelable.Creator<ShowInfo>() { + @Override + public ShowInfo[] newArray(int size) { + return new ShowInfo[size]; + } + + @Override + public ShowInfo createFromParcel(@NonNull android.os.Parcel in) { + return new ShowInfo(in); + } + }; + + @DataClass.Generated( + time = 1639488262761L, + codegenVersion = "1.0.23", + sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/ShowInfo.java", + inputSignatures = "private final long mWidgetToken\nclass ShowInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + +} diff --git a/core/java/android/view/selectiontoolbar/ToolbarMenuItem.aidl b/core/java/android/view/selectiontoolbar/ToolbarMenuItem.aidl new file mode 100644 index 000000000000..711a85a7771e --- /dev/null +++ b/core/java/android/view/selectiontoolbar/ToolbarMenuItem.aidl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +/** + * @hide + */ +parcelable ToolbarMenuItem; diff --git a/core/java/android/view/selectiontoolbar/ToolbarMenuItem.java b/core/java/android/view/selectiontoolbar/ToolbarMenuItem.java new file mode 100644 index 000000000000..5af232c7a34d --- /dev/null +++ b/core/java/android/view/selectiontoolbar/ToolbarMenuItem.java @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.os.Parcelable; + +import com.android.internal.util.DataClass; + +/** + * The menu item that is used to show the selection toolbar. + * + * @hide + */ +@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true) +public final class ToolbarMenuItem implements Parcelable { + + /** + * The id of the menu item. + */ + private final int mItemId; + + + + // Code below generated by codegen v1.0.23. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/selectiontoolbar/ToolbarMenuItem.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + @DataClass.Generated.Member + /* package-private */ ToolbarMenuItem( + int itemId) { + this.mItemId = itemId; + + // onConstructed(); // You can define this method to get a callback + } + + /** + * The id of the menu item. + */ + @DataClass.Generated.Member + public int getItemId() { + return mItemId; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "ToolbarMenuItem { " + + "itemId = " + mItemId + + " }"; + } + + @Override + @DataClass.Generated.Member + public boolean equals(@Nullable Object o) { + // You can override field equality logic by defining either of the methods like: + // boolean fieldNameEquals(ToolbarMenuItem other) { ... } + // boolean fieldNameEquals(FieldType otherValue) { ... } + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + @SuppressWarnings("unchecked") + ToolbarMenuItem that = (ToolbarMenuItem) o; + //noinspection PointlessBooleanExpression + return true + && mItemId == that.mItemId; + } + + @Override + @DataClass.Generated.Member + public int hashCode() { + // You can override field hashCode logic by defining methods like: + // int fieldNameHashCode() { ... } + + int _hash = 1; + _hash = 31 * _hash + mItemId; + return _hash; + } + + @Override + @DataClass.Generated.Member + public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { + // You can override field parcelling by defining methods like: + // void parcelFieldName(Parcel dest, int flags) { ... } + + dest.writeInt(mItemId); + } + + @Override + @DataClass.Generated.Member + public int describeContents() { return 0; } + + /** @hide */ + @SuppressWarnings({"unchecked", "RedundantCast"}) + @DataClass.Generated.Member + /* package-private */ ToolbarMenuItem(@NonNull android.os.Parcel in) { + // You can override field unparcelling by defining methods like: + // static FieldType unparcelFieldName(Parcel in) { ... } + + int itemId = in.readInt(); + + this.mItemId = itemId; + + // onConstructed(); // You can define this method to get a callback + } + + @DataClass.Generated.Member + public static final @NonNull Parcelable.Creator<ToolbarMenuItem> CREATOR + = new Parcelable.Creator<ToolbarMenuItem>() { + @Override + public ToolbarMenuItem[] newArray(int size) { + return new ToolbarMenuItem[size]; + } + + @Override + public ToolbarMenuItem createFromParcel(@NonNull android.os.Parcel in) { + return new ToolbarMenuItem(in); + } + }; + + /** + * A builder for {@link ToolbarMenuItem} + */ + @SuppressWarnings("WeakerAccess") + @DataClass.Generated.Member + public static final class Builder { + + private int mItemId; + + private long mBuilderFieldsSet = 0L; + + /** + * Creates a new Builder. + * + * @param itemId + * The id of the menu item. + */ + public Builder( + int itemId) { + mItemId = itemId; + } + + /** + * The id of the menu item. + */ + @DataClass.Generated.Member + public @NonNull Builder setItemId(int value) { + checkNotUsed(); + mBuilderFieldsSet |= 0x1; + mItemId = value; + return this; + } + + /** Builds the instance. This builder should not be touched after calling this! */ + public @NonNull ToolbarMenuItem build() { + checkNotUsed(); + mBuilderFieldsSet |= 0x2; // Mark builder used + + ToolbarMenuItem o = new ToolbarMenuItem( + mItemId); + return o; + } + + private void checkNotUsed() { + if ((mBuilderFieldsSet & 0x2) != 0) { + throw new IllegalStateException( + "This Builder should not be reused. Use a new Builder instance instead"); + } + } + } + + @DataClass.Generated( + time = 1639488328542L, + codegenVersion = "1.0.23", + sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/ToolbarMenuItem.java", + inputSignatures = "private final int mItemId\nclass ToolbarMenuItem extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true)") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + +} diff --git a/core/java/android/view/selectiontoolbar/WidgetInfo.aidl b/core/java/android/view/selectiontoolbar/WidgetInfo.aidl new file mode 100644 index 000000000000..1057c516e233 --- /dev/null +++ b/core/java/android/view/selectiontoolbar/WidgetInfo.aidl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +/** + * @hide + */ +parcelable WidgetInfo; diff --git a/core/java/android/view/selectiontoolbar/WidgetInfo.java b/core/java/android/view/selectiontoolbar/WidgetInfo.java new file mode 100644 index 000000000000..961d8ac8e5e0 --- /dev/null +++ b/core/java/android/view/selectiontoolbar/WidgetInfo.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.view.selectiontoolbar; + +import android.annotation.NonNull; +import android.os.Parcelable; + +import com.android.internal.util.DataClass; + +/** + * The class holds the rendered content and the related information from the render service to + * be used to show on the selection toolbar. + * + * @hide + */ +@DataClass(genToString = true, genEqualsHashCode = true) +public final class WidgetInfo implements Parcelable { + + /** + * The token that is used to identify the selection toolbar. + */ + private final long mWidgetToken; + + // TODO: add members when the code really uses it + + + + // Code below generated by codegen v1.0.23. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/selectiontoolbar/WidgetInfo.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + /** + * Creates a new WidgetInfo. + * + * @param widgetToken + * The token that is used to identify the selection toolbar. + */ + @DataClass.Generated.Member + public WidgetInfo( + long widgetToken) { + this.mWidgetToken = widgetToken; + + // onConstructed(); // You can define this method to get a callback + } + + /** + * The token that is used to identify the selection toolbar. + */ + @DataClass.Generated.Member + public long getWidgetToken() { + return mWidgetToken; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "WidgetInfo { " + + "widgetToken = " + mWidgetToken + + " }"; + } + + @Override + @DataClass.Generated.Member + public boolean equals(@android.annotation.Nullable Object o) { + // You can override field equality logic by defining either of the methods like: + // boolean fieldNameEquals(WidgetInfo other) { ... } + // boolean fieldNameEquals(FieldType otherValue) { ... } + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + @SuppressWarnings("unchecked") + WidgetInfo that = (WidgetInfo) o; + //noinspection PointlessBooleanExpression + return true + && mWidgetToken == that.mWidgetToken; + } + + @Override + @DataClass.Generated.Member + public int hashCode() { + // You can override field hashCode logic by defining methods like: + // int fieldNameHashCode() { ... } + + int _hash = 1; + _hash = 31 * _hash + Long.hashCode(mWidgetToken); + return _hash; + } + + @Override + @DataClass.Generated.Member + public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { + // You can override field parcelling by defining methods like: + // void parcelFieldName(Parcel dest, int flags) { ... } + + dest.writeLong(mWidgetToken); + } + + @Override + @DataClass.Generated.Member + public int describeContents() { return 0; } + + /** @hide */ + @SuppressWarnings({"unchecked", "RedundantCast"}) + @DataClass.Generated.Member + /* package-private */ WidgetInfo(@NonNull android.os.Parcel in) { + // You can override field unparcelling by defining methods like: + // static FieldType unparcelFieldName(Parcel in) { ... } + + long widgetToken = in.readLong(); + + this.mWidgetToken = widgetToken; + + // onConstructed(); // You can define this method to get a callback + } + + @DataClass.Generated.Member + public static final @NonNull Parcelable.Creator<WidgetInfo> CREATOR + = new Parcelable.Creator<WidgetInfo>() { + @Override + public WidgetInfo[] newArray(int size) { + return new WidgetInfo[size]; + } + + @Override + public WidgetInfo createFromParcel(@NonNull android.os.Parcel in) { + return new WidgetInfo(in); + } + }; + + @DataClass.Generated( + time = 1639488254020L, + codegenVersion = "1.0.23", + sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/WidgetInfo.java", + inputSignatures = "private final long mWidgetToken\nclass WidgetInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genEqualsHashCode=true)") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + +} |
