Disable app usage item if this item is not clickable
some items are not clickable to launch the restriction page in the battery usage list, we will apply the disabled visual in the preferrence item to improve the UX (avoid users click the item without any action) Bug: 188751551 Bug: 188663505 Test: make SettingsgRoboTests Change-Id: Ib8925b8e191117543bb1c74d6d01191e3043fc73
This commit is contained in:
@@ -189,6 +189,8 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
mPrefContext = screen.getContext();
|
||||
mAppListPrefGroup = screen.findPreference(mPreferenceKey);
|
||||
mAppListPrefGroup.setOrderingAsAdded(false);
|
||||
mAppListPrefGroup.setTitle(
|
||||
mPrefContext.getString(R.string.battery_app_usage_for_past_24));
|
||||
mFooterPreference = screen.findPreference(KEY_FOOTER_PREF);
|
||||
// Removes footer first until usage data is loaded to avoid flashing.
|
||||
if (mFooterPreference != null) {
|
||||
@@ -216,15 +218,6 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
final BatteryHistEntry histEntry = diffEntry.mBatteryHistEntry;
|
||||
final String packageName = histEntry.mPackageName;
|
||||
final boolean isAppEntry = histEntry.isAppEntry();
|
||||
// Checks whether the package is installed or not.
|
||||
boolean isValidPackage = true;
|
||||
if (isAppEntry) {
|
||||
if (mBatteryUtils == null) {
|
||||
mBatteryUtils = BatteryUtils.getInstance(mPrefContext);
|
||||
}
|
||||
isValidPackage = mBatteryUtils.getPackageUid(packageName)
|
||||
!= BatteryUtils.UID_NULL;
|
||||
}
|
||||
mMetricsFeatureProvider.action(
|
||||
mPrefContext,
|
||||
isAppEntry
|
||||
@@ -233,15 +226,12 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
new Pair(ConvertUtils.METRIC_KEY_PACKAGE, packageName),
|
||||
new Pair(ConvertUtils.METRIC_KEY_BATTERY_LEVEL, histEntry.mBatteryLevel),
|
||||
new Pair(ConvertUtils.METRIC_KEY_BATTERY_USAGE, powerPref.getPercent()));
|
||||
Log.d(TAG, String.format("handleClick() label=%s key=%s isValid:%b\n%s",
|
||||
diffEntry.getAppLabel(), histEntry.getKey(), isValidPackage, histEntry));
|
||||
if (isValidPackage) {
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
||||
Log.d(TAG, String.format("handleClick() label=%s key=%s enntry=\n%s",
|
||||
diffEntry.getAppLabel(), histEntry.getKey(), histEntry));
|
||||
AdvancedPowerUsageDetail.startBatteryDetailPage(
|
||||
mActivity, mFragment, diffEntry, powerPref.getPercent(),
|
||||
isValidToShowSummary(packageName), getSlotInformation());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -434,6 +424,7 @@ public class BatteryChartPreferenceController extends AbstractPreferenceControll
|
||||
pref.setSingleLineTitle(true);
|
||||
// Sets the BatteryDiffEntry to preference for launching detailed page.
|
||||
pref.setBatteryDiffEntry(entry);
|
||||
pref.setEnabled(entry.validForRestriction());
|
||||
setPreferenceSummary(pref, entry);
|
||||
if (!isAdded) {
|
||||
mAppListPrefGroup.addPreference(pref);
|
||||
|
Reference in New Issue
Block a user