Implement the battery tips cards.(1/2)

- Implement a tips card UI in Battery Usage.

[Screenshot]:
- Tips Card with thumbs-up/down feedback in dark mode
https://screenshot.googleplex.com/3nRCFYvLTWfiYYT
- Tips Card without feedback
https://screenshot.googleplex.com/B7QGRJZAHzgWpCP
- Tips Card in Force RTL layout
https://screenshot.googleplex.com/8crQdj8ao26pKpH
- Tips Card in light mode
https://screenshot.googleplex.com/885aVvZm8xmhK2S

[TODO]:
- Add accessibility
- Localization

Bug: 291689623
Test: Manual
Change-Id: I4443cdb21b3ba30900fc2f6fcc21c4c56dc1293f
Merged-In: I4443cdb21b3ba30900fc2f6fcc21c4c56dc1293f
This commit is contained in:
mxyyiyi
2023-07-19 13:28:52 +08:00
committed by Xinyi Mao
parent 99d99c1e0c
commit be8407c566
20 changed files with 657 additions and 0 deletions

View File

@@ -67,6 +67,15 @@ public class PowerUsageFeatureProviderImplTest {
assertThat(mPowerFeatureProvider.isBatteryUsageEnabled()).isTrue();
}
@Test
public void testIsBatteryTipsEnabled_returnFalse() {
assertThat(mPowerFeatureProvider.isBatteryTipsEnabled()).isFalse();
}
@Test
public void testIsBatteryTipsFeedbackEnabled_returnTrue() {
assertThat(mPowerFeatureProvider.isBatteryTipsFeedbackEnabled()).isTrue();
}
@Test
public void testGetBatteryUsageListConsumePowerThreshold_return0() {
assertThat(mPowerFeatureProvider.getBatteryUsageListConsumePowerThreshold()).isEqualTo(0.0);

View File

@@ -0,0 +1,50 @@
/*
* 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.settings.fuelgauge.batteryusage;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
import android.content.Context;
import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public final class BatteryTipsCardPreferenceTest {
private Context mContext;
private BatteryTipsCardPreference mBatteryTipsCardPreference;
@Before
public void setUp() {
mContext = spy(RuntimeEnvironment.application);
mBatteryTipsCardPreference = new BatteryTipsCardPreference(mContext, /*attrs=*/ null);
}
@Test
public void constructor_returnExpectedResult() {
assertThat(mBatteryTipsCardPreference.getLayoutResource()).isEqualTo(
R.layout.battery_tips_card);
}
}