From 2dbdc396b64dc4dec1bf84afb6cf166fcbe2c522 Mon Sep 17 00:00:00 2001 From: NurKeinNeid Date: Sun, 7 Jul 2024 15:00:52 +0200 Subject: [PATCH] fixup! Implement notificationlight settings --- .../BatteryLightPreferenceController.java | 46 +++++++++++++++++++ ...NotificationLightPreferenceController.java | 46 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/com/android/settings/derp/notificationlight/BatteryLightPreferenceController.java create mode 100644 src/com/android/settings/derp/notificationlight/NotificationLightPreferenceController.java diff --git a/src/com/android/settings/derp/notificationlight/BatteryLightPreferenceController.java b/src/com/android/settings/derp/notificationlight/BatteryLightPreferenceController.java new file mode 100644 index 00000000000..95855d40f37 --- /dev/null +++ b/src/com/android/settings/derp/notificationlight/BatteryLightPreferenceController.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 The PixelExperience Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.derp.notificationlight; + +import android.content.Context; +import com.android.settings.core.BasePreferenceController; + +public class BatteryLightPreferenceController extends BasePreferenceController { + + public static final String KEY = "battery_lights"; + + private Context mContext; + + public BatteryLightPreferenceController(Context context, String key) { + super(context, key); + + mContext = context; + } + + public BatteryLightPreferenceController(Context context) { + this(context, KEY); + + mContext = context; + } + + @Override + public int getAvailabilityStatus() { + int caps = mContext.getResources().getInteger(com.android.internal.R.integer.config_deviceLightCapabilities); + return (((caps & 64) == 64) ? AVAILABLE : UNSUPPORTED_ON_DEVICE); + } + +} diff --git a/src/com/android/settings/derp/notificationlight/NotificationLightPreferenceController.java b/src/com/android/settings/derp/notificationlight/NotificationLightPreferenceController.java new file mode 100644 index 00000000000..eac27700293 --- /dev/null +++ b/src/com/android/settings/derp/notificationlight/NotificationLightPreferenceController.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 The PixelExperience Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.derp.notificationlight; + +import android.content.Context; +import com.android.settings.core.BasePreferenceController; + +public class NotificationLightPreferenceController extends BasePreferenceController { + + public static final String KEY = "notification_lights"; + + private Context mContext; + + public NotificationLightPreferenceController(Context context, String key) { + super(context, key); + + mContext = context; + } + + public NotificationLightPreferenceController(Context context) { + this(context, KEY); + + mContext = context; + } + + @Override + public int getAvailabilityStatus() { + boolean exists = mContext.getResources().getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed); + return (exists ? AVAILABLE : UNSUPPORTED_ON_DEVICE); + } + +}