Add ResultPayload for Allow notification dots
Bug: 62022517 Test: robotests Change-Id: I86caa1c8604ae8eff27574ca45b5e9f3f6830f8f
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.notification;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
@@ -28,6 +29,10 @@ import android.support.v7.preference.TwoStatePreference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.InlineSwitchPayload;
|
||||
import com.android.settings.search.ResultPayload;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
@@ -40,7 +45,8 @@ public class BadgingNotificationPreferenceController extends AbstractPreferenceC
|
||||
|
||||
private static final String TAG = "BadgeNotifPrefContr";
|
||||
private static final String KEY_NOTIFICATION_BADGING = "notification_badging";
|
||||
private static final int DEFAULT_VALUE = 1;
|
||||
private static final int ON = 1;
|
||||
private static final int OFF = 0;
|
||||
|
||||
private SettingObserver mSettingObserver;
|
||||
|
||||
@@ -85,7 +91,7 @@ public class BadgingNotificationPreferenceController extends AbstractPreferenceC
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
final boolean checked = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BADGING, DEFAULT_VALUE) == 1;
|
||||
NOTIFICATION_BADGING, ON) == ON;
|
||||
((TwoStatePreference) preference).setChecked(checked);
|
||||
}
|
||||
|
||||
@@ -93,7 +99,7 @@ public class BadgingNotificationPreferenceController extends AbstractPreferenceC
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final boolean val = (Boolean) newValue;
|
||||
return Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BADGING, val ? 1 : 0);
|
||||
NOTIFICATION_BADGING, val ? ON : OFF);
|
||||
}
|
||||
|
||||
class SettingObserver extends ContentObserver {
|
||||
@@ -124,4 +130,15 @@ public class BadgingNotificationPreferenceController extends AbstractPreferenceC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultPayload getResultPayload() {
|
||||
final Intent intent = DatabaseIndexingUtils.buildSubsettingIntent(mContext,
|
||||
ConfigureNotificationSettings.class.getName(), KEY_NOTIFICATION_BADGING,
|
||||
mContext.getString(R.string.configure_notification_settings));
|
||||
|
||||
return new InlineSwitchPayload(Settings.Secure.NOTIFICATION_BADGING,
|
||||
ResultPayload.SettingsSource.SECURE, ON /* onValue */, intent, isAvailable(),
|
||||
ON /* defaultValue */);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user