Merge "Add a title to BubbleInfo." into udc-dev

This commit is contained in:
Treehugger Robot
2023-05-04 22:28:26 +00:00
committed by Android (Google) Code Review
3 changed files with 64 additions and 5 deletions

View File

@@ -300,7 +300,8 @@ public class Bubble implements BubbleViewProvider {
getShortcutId(), getShortcutId(),
getIcon(), getIcon(),
getUser().getIdentifier(), getUser().getIdentifier(),
getPackageName()); getPackageName(),
getTitle());
} }
@Override @Override

View File

@@ -30,7 +30,6 @@ import java.util.Objects;
*/ */
public class BubbleInfo implements Parcelable { public class BubbleInfo implements Parcelable {
// TODO(b/269672147): needs a title string for a11y & that comes from notification
// TODO(b/269671451): needs whether the bubble is an 'important person' or not // TODO(b/269671451): needs whether the bubble is an 'important person' or not
private String mKey; // Same key as the Notification private String mKey; // Same key as the Notification
@@ -46,24 +45,28 @@ public class BubbleInfo implements Parcelable {
*/ */
@Nullable @Nullable
private Icon mIcon; private Icon mIcon;
@Nullable
private String mTitle;
public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon, public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon,
int userId, String packageName) { int userId, String packageName, @Nullable String title) {
mKey = key; mKey = key;
mFlags = flags; mFlags = flags;
mShortcutId = shortcutId; mShortcutId = shortcutId;
mIcon = icon; mIcon = icon;
mUserId = userId; mUserId = userId;
mPackageName = packageName; mPackageName = packageName;
mTitle = title;
} }
public BubbleInfo(Parcel source) { private BubbleInfo(Parcel source) {
mKey = source.readString(); mKey = source.readString();
mFlags = source.readInt(); mFlags = source.readInt();
mShortcutId = source.readString(); mShortcutId = source.readString();
mIcon = source.readTypedObject(Icon.CREATOR); mIcon = source.readTypedObject(Icon.CREATOR);
mUserId = source.readInt(); mUserId = source.readInt();
mPackageName = source.readString(); mPackageName = source.readString();
mTitle = source.readString();
} }
public String getKey() { public String getKey() {
@@ -92,6 +95,11 @@ public class BubbleInfo implements Parcelable {
return mPackageName; return mPackageName;
} }
@Nullable
public String getTitle() {
return mTitle;
}
/** /**
* Whether this bubble is currently being hidden from the stack. * Whether this bubble is currently being hidden from the stack.
*/ */
@@ -141,11 +149,12 @@ public class BubbleInfo implements Parcelable {
parcel.writeTypedObject(mIcon, flags); parcel.writeTypedObject(mIcon, flags);
parcel.writeInt(mUserId); parcel.writeInt(mUserId);
parcel.writeString(mPackageName); parcel.writeString(mPackageName);
parcel.writeString(mTitle);
} }
@NonNull @NonNull
public static final Creator<BubbleInfo> CREATOR = public static final Creator<BubbleInfo> CREATOR =
new Creator<BubbleInfo>() { new Creator<>() {
public BubbleInfo createFromParcel(Parcel source) { public BubbleInfo createFromParcel(Parcel source) {
return new BubbleInfo(source); return new BubbleInfo(source);
} }

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2023 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 com.android.wm.shell.common.bubbles
import android.os.Parcel
import android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE
import android.testing.AndroidTestingRunner
import androidx.test.filters.SmallTest
import com.android.wm.shell.ShellTestCase
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@SmallTest
@RunWith(AndroidTestingRunner::class)
class BubbleInfoTest : ShellTestCase() {
@Test
fun bubbleInfo() {
val bubbleInfo = BubbleInfo("key", 0, "shortcut id", null, 6, "com.some.package", "title")
val parcel = Parcel.obtain()
bubbleInfo.writeToParcel(parcel, PARCELABLE_WRITE_RETURN_VALUE)
parcel.setDataPosition(0)
val bubbleInfoFromParcel = BubbleInfo.CREATOR.createFromParcel(parcel)
assertThat(bubbleInfo.key).isEqualTo(bubbleInfoFromParcel.key)
assertThat(bubbleInfo.flags).isEqualTo(bubbleInfoFromParcel.flags)
assertThat(bubbleInfo.shortcutId).isEqualTo(bubbleInfoFromParcel.shortcutId)
assertThat(bubbleInfo.icon).isEqualTo(bubbleInfoFromParcel.icon)
assertThat(bubbleInfo.userId).isEqualTo(bubbleInfoFromParcel.userId)
assertThat(bubbleInfo.packageName).isEqualTo(bubbleInfoFromParcel.packageName)
assertThat(bubbleInfo.title).isEqualTo(bubbleInfoFromParcel.title)
}
}