Fixed AccessPreference listener.

When an app is blacklisted, its switch toggle is disabled, but previous
the onClick() method was still being called, which would launch the data
usage screen but also call setIsWhitelist().

BUG: 27481520
Change-Id: Id8df3d65eee286d1aecb4ae2a0417d6932d91441
This commit is contained in:
Felipe Leme
2016-04-19 10:05:08 -07:00
parent c2ef27faf4
commit 11b06ca8bf

View File

@@ -227,19 +227,20 @@ public class UnrestrictedDataAccess extends SettingsPreferenceFragment
if (mEntry.icon != null) {
setIcon(mEntry.icon);
}
setOnPreferenceClickListener( new OnPreferenceClickListener() {
}
@Override
public boolean onPreferenceClick(Preference pref) {
if (mState.isDataSaverBlacklisted) {
InstalledAppDetails.startAppInfoFragment(AppDataUsage.class,
context.getString(R.string.app_data_usage),
UnrestrictedDataAccess.this,
mEntry);
return false;
}
return true;
}});
@Override
protected void onClick() {
if (mState.isDataSaverBlacklisted) {
// app is blacklisted, launch App Data Usage screen
InstalledAppDetails.startAppInfoFragment(AppDataUsage.class,
getContext().getString(R.string.app_data_usage),
UnrestrictedDataAccess.this,
mEntry);
} else {
// app is not blacklisted, let superclass handle toggle switch
super.onClick();
}
}
// Sets UI state based on whitelist/blacklist status.