Add ambient notifications as inline setting.
Bug: 62022517 Test: robotest and manual Change-Id: I7e3faf56a1c8282017a2e84d88e7b0b788a7bfb6 Merged-In: If245f541ec3c8a1627d082b97bba9b325438cfeb
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
@@ -21,8 +22,12 @@ import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.InlineSwitchPayload;
|
||||
import com.android.settings.search.ResultPayload;
|
||||
|
||||
import static android.provider.Settings.Secure.DOZE_ENABLED;
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_AMBIENT_DISPLAY;
|
||||
@@ -30,6 +35,9 @@ import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION
|
||||
public class AmbientDisplayNotificationsPreferenceController extends PreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private final int ON = 1;
|
||||
private final int OFF = 0;
|
||||
|
||||
@VisibleForTesting
|
||||
static final String KEY_AMBIENT_DISPLAY_NOTIFICATIONS = "ambient_display_notification";
|
||||
private static final int MY_USER = UserHandle.myUserId();
|
||||
@@ -65,7 +73,7 @@ public class AmbientDisplayNotificationsPreferenceController extends PreferenceC
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean value = (Boolean) newValue;
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), DOZE_ENABLED, value ? 1 : 0);
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), DOZE_ENABLED, value ? ON : OFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -73,4 +81,15 @@ public class AmbientDisplayNotificationsPreferenceController extends PreferenceC
|
||||
public boolean isAvailable() {
|
||||
return mConfig.pulseOnNotificationAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultPayload getResultPayload() {
|
||||
final Intent intent = DatabaseIndexingUtils.buildSubsettingIntent(mContext,
|
||||
AmbientDisplaySettings.class.getName(), KEY_AMBIENT_DISPLAY_NOTIFICATIONS,
|
||||
mContext.getString(R.string.ambient_display_screen_title));
|
||||
|
||||
return new InlineSwitchPayload(Settings.Secure.DOZE_ENABLED,
|
||||
ResultPayload.SettingsSource.SECURE, ON /* onValue */, intent, isAvailable(),
|
||||
ON /* defaultValue */);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user