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

@@ -34,6 +34,8 @@ import androidx.loader.content.Loader;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.fuelgauge.BatteryBroadcastReceiver;
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
@@ -143,6 +145,16 @@ public class PowerUsageAdvanced extends PowerUsageBase {
controllers.add(screenOnTimeController);
controllers.add(batteryUsageBreakdownController);
setBatteryChartPreferenceController();
final PowerUsageFeatureProvider powerUsageFeatureProvider =
FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
if (powerUsageFeatureProvider.isBatteryTipsEnabled()) {
BatteryTipsController batteryTipsController = new BatteryTipsController(context);
mBatteryChartPreferenceController.setOnBatteryTipsUpdatedListener(
batteryTipsController::handleBatteryTipsCardUpdated);
controllers.add(batteryTipsController);
}
return controllers;
}