Skip to content

Commit 137b2e7

Browse files
committed
fixup! add toggle to modify suppress notification flag in AswAppInfoFragment
1 parent a60a0c7 commit 137b2e7

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/com/android/settings/applications/appinfo/AswAppInfoFragment.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.android.settings.R;
1616

1717
import java.util.Objects;
18+
import java.util.function.Consumer;
1819

1920
public abstract class AswAppInfoFragment<T extends AppSwitch>
2021
extends RadioButtonAppInfoFragment implements Preference.OnPreferenceChangeListener {
@@ -147,14 +148,10 @@ protected CharSequence getSummaryForImmutabilityReason(int ir) {
147148
return null;
148149
}
149150

150-
private interface GosPackageStateUpdater {
151-
void run(GosPackageState.Editor ed);
152-
}
153-
154-
private void updateGosPackageState(GosPackageStateUpdater updater) {
151+
private void updateGosPackageState(Consumer<GosPackageState.Editor> updater) {
155152
GosPackageState.Editor ed = GosPackageState.edit(mPackageName, mUserId);
156153

157-
updater.run(ed);
154+
updater.accept(ed);
158155

159156
ed.setKillUidAfterApply(shouldKillUidAfterChange());
160157

@@ -194,19 +191,16 @@ public final void onEntrySelected(int id) {
194191
}
195192

196193
@Override
197-
public boolean onPreferenceChange(@NonNull Preference preference, Object o) {
194+
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
198195
if (!preference.equals(notificationPreference)) {
199196
return false;
200197
}
201198

202-
SwitchPreferenceCompat np = notificationPreference;
203199
AppSwitch asw = adapter.getAppSwitch();
204-
205-
boolean oldValue = np.isChecked();
206-
boolean newValue = !oldValue;
200+
boolean newChecked = (boolean) newValue;
207201

208202
updateGosPackageState(ed -> {
209-
if (newValue) {
203+
if (newChecked) {
210204
asw.removeSuppressNotificationFlag(ed);
211205
} else {
212206
asw.addSuppressNotificationFlag(ed);

0 commit comments

Comments
 (0)