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