Merge "Add a title to BubbleInfo." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
75bb6efbd1
@@ -300,7 +300,8 @@ public class Bubble implements BubbleViewProvider {
|
||||
getShortcutId(),
|
||||
getIcon(),
|
||||
getUser().getIdentifier(),
|
||||
getPackageName());
|
||||
getPackageName(),
|
||||
getTitle());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.Objects;
|
||||
*/
|
||||
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
|
||||
|
||||
private String mKey; // Same key as the Notification
|
||||
@@ -46,24 +45,28 @@ public class BubbleInfo implements Parcelable {
|
||||
*/
|
||||
@Nullable
|
||||
private Icon mIcon;
|
||||
@Nullable
|
||||
private String mTitle;
|
||||
|
||||
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;
|
||||
mFlags = flags;
|
||||
mShortcutId = shortcutId;
|
||||
mIcon = icon;
|
||||
mUserId = userId;
|
||||
mPackageName = packageName;
|
||||
mTitle = title;
|
||||
}
|
||||
|
||||
public BubbleInfo(Parcel source) {
|
||||
private BubbleInfo(Parcel source) {
|
||||
mKey = source.readString();
|
||||
mFlags = source.readInt();
|
||||
mShortcutId = source.readString();
|
||||
mIcon = source.readTypedObject(Icon.CREATOR);
|
||||
mUserId = source.readInt();
|
||||
mPackageName = source.readString();
|
||||
mTitle = source.readString();
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
@@ -92,6 +95,11 @@ public class BubbleInfo implements Parcelable {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this bubble is currently being hidden from the stack.
|
||||
*/
|
||||
@@ -141,11 +149,12 @@ public class BubbleInfo implements Parcelable {
|
||||
parcel.writeTypedObject(mIcon, flags);
|
||||
parcel.writeInt(mUserId);
|
||||
parcel.writeString(mPackageName);
|
||||
parcel.writeString(mTitle);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static final Creator<BubbleInfo> CREATOR =
|
||||
new Creator<BubbleInfo>() {
|
||||
new Creator<>() {
|
||||
public BubbleInfo createFromParcel(Parcel source) {
|
||||
return new BubbleInfo(source);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user