Reintroduce complication types.
This change was removed during the ComplicationProvider to Complication refactor. Test: atest ComplicationUtilsTest Bug: 214038720 Change-Id: Iabaecd2d4748b84e3c5d24e4b3662aa972d54e1f
This commit is contained in:
@@ -153,6 +153,27 @@ public interface Complication {
|
||||
*/
|
||||
int CATEGORY_SYSTEM = 1 << 1;
|
||||
|
||||
/**
|
||||
* The type of dream complications which can be provided by a {@link Complication}.
|
||||
*/
|
||||
@IntDef(prefix = {"COMPLICATION_TYPE_"}, flag = true, value = {
|
||||
COMPLICATION_TYPE_NONE,
|
||||
COMPLICATION_TYPE_TIME,
|
||||
COMPLICATION_TYPE_DATE,
|
||||
COMPLICATION_TYPE_WEATHER,
|
||||
COMPLICATION_TYPE_AIR_QUALITY,
|
||||
COMPLICATION_TYPE_CAST_INFO
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface ComplicationType {}
|
||||
|
||||
int COMPLICATION_TYPE_NONE = 0;
|
||||
int COMPLICATION_TYPE_TIME = 1;
|
||||
int COMPLICATION_TYPE_DATE = 1 << 1;
|
||||
int COMPLICATION_TYPE_WEATHER = 1 << 2;
|
||||
int COMPLICATION_TYPE_AIR_QUALITY = 1 << 3;
|
||||
int COMPLICATION_TYPE_CAST_INFO = 1 << 4;
|
||||
|
||||
/**
|
||||
* The {@link Host} interface specifies a way a {@link Complication} to communicate with its
|
||||
* parent entity for information and actions.
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.systemui.dreams.complication;
|
||||
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_AIR_QUALITY;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_CAST_INFO;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_DATE;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_NONE;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_TIME;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_WEATHER;
|
||||
|
||||
import com.android.settingslib.dream.DreamBackend;
|
||||
|
||||
/**
|
||||
* A collection of utility methods for working with {@link Complication}.
|
||||
*/
|
||||
public class ComplicationUtils {
|
||||
/**
|
||||
* Converts a {@link com.android.settingslib.dream.DreamBackend.ComplicationType} to
|
||||
* {@link ComplicationType}.
|
||||
*/
|
||||
@Complication.ComplicationType
|
||||
public static int convertComplicationType(@DreamBackend.ComplicationType int type) {
|
||||
switch (type) {
|
||||
case DreamBackend.COMPLICATION_TYPE_TIME:
|
||||
return COMPLICATION_TYPE_TIME;
|
||||
case DreamBackend.COMPLICATION_TYPE_DATE:
|
||||
return COMPLICATION_TYPE_DATE;
|
||||
case DreamBackend.COMPLICATION_TYPE_WEATHER:
|
||||
return COMPLICATION_TYPE_WEATHER;
|
||||
case DreamBackend.COMPLICATION_TYPE_AIR_QUALITY:
|
||||
return COMPLICATION_TYPE_AIR_QUALITY;
|
||||
case DreamBackend.COMPLICATION_TYPE_CAST_INFO:
|
||||
return COMPLICATION_TYPE_CAST_INFO;
|
||||
default:
|
||||
return COMPLICATION_TYPE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.systemui.dreams.complication;
|
||||
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_AIR_QUALITY;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_CAST_INFO;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_DATE;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_TIME;
|
||||
import static com.android.systemui.dreams.complication.Complication.COMPLICATION_TYPE_WEATHER;
|
||||
import static com.android.systemui.dreams.complication.ComplicationUtils.convertComplicationType;
|
||||
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.testing.AndroidTestingRunner;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.settingslib.dream.DreamBackend;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
public class ComplicationUtilsTest extends SysuiTestCase {
|
||||
@Test
|
||||
public void testConvertComplicationType() {
|
||||
assertThat(convertComplicationType(DreamBackend.COMPLICATION_TYPE_TIME))
|
||||
.isEqualTo(COMPLICATION_TYPE_TIME);
|
||||
assertThat(convertComplicationType(DreamBackend.COMPLICATION_TYPE_DATE))
|
||||
.isEqualTo(COMPLICATION_TYPE_DATE);
|
||||
assertThat(convertComplicationType(DreamBackend.COMPLICATION_TYPE_WEATHER))
|
||||
.isEqualTo(COMPLICATION_TYPE_WEATHER);
|
||||
assertThat(convertComplicationType(DreamBackend.COMPLICATION_TYPE_AIR_QUALITY))
|
||||
.isEqualTo(COMPLICATION_TYPE_AIR_QUALITY);
|
||||
assertThat(convertComplicationType(DreamBackend.COMPLICATION_TYPE_CAST_INFO))
|
||||
.isEqualTo(COMPLICATION_TYPE_CAST_INFO);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user