Evolver: Alert Slider: Add toggle to disable notifications [2/2]

This commit is contained in:
Pranav Vashi
2025-01-23 02:28:42 +09:00
committed by Joey Huab
parent 82ef37b8b6
commit 16a8a7bf4c
3 changed files with 45 additions and 11 deletions

View File

@@ -429,6 +429,10 @@
<string name="notifications_alert_display_on_title">Alert while display on</string>
<string name="notifications_alert_display_on_summary">Play sound and vibration for notifications while the display is on</string>
<!-- Notifications/Alert Slider Notifications (OnePlus devices) -->
<string name="alert_slider_notifications_title">Alert slider notifications</string>
<string name="alert_slider_notifications_summary">Display notification when changing alert slider position</string>
<!-- Notifications/Edge light -->
<string name="notifications_edge_light_always_trigger_on_pulse_title">Always trigger on pulse</string>
<string name="notifications_edge_light_always_trigger_on_pulse_summary">Whether to show edge light whenever ambient display is shown and not just for notifications</string>

View File

@@ -32,6 +32,13 @@
android:key="notifications_interface_category"
android:title="@string/notifications_interface_category">
<!-- Alert Slider Notifications (OnePlus devices) -->
<org.evolution.settings.preferences.SystemSettingSwitchPreference
android:key="alert_slider_notifications"
android:title="@string/alert_slider_notifications_title"
android:summary="@string/alert_slider_notifications_summary"
android:defaultValue="true" />
<!-- Edge light -->
<Preference
android:key="edge_light_settings"

View File

@@ -5,6 +5,7 @@
package org.evolution.settings.fragments.notifications;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
@@ -23,21 +24,37 @@ import com.android.settingslib.search.SearchIndexable;
import java.util.List;
import org.evolution.settings.preferences.SystemSettingSwitchPreference;
@SearchIndexable
public class Notifications extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener {
private static final String TAG = "Notifications";
private static final String KEY_ALERT_SLIDER_PREF = "alert_slider_notifications";
private static final String KEY_INTERFACE_CATEGORY = "notifications_interface_category";
private PreferenceCategory mInterfaceCategory;
private Preference mAlertSlider;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.evolution_settings_notifications);
final Context context = getContext();
final ContentResolver resolver = context.getContentResolver();
final Context mContext = getActivity().getApplicationContext();
final ContentResolver resolver = mContext.getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources resources = context.getResources();
final Resources res = mContext.getResources();
mAlertSlider = (SystemSettingSwitchPreference) findPreference(KEY_ALERT_SLIDER_PREF);
mInterfaceCategory = (PreferenceCategory) findPreference(KEY_INTERFACE_CATEGORY);
boolean mAlertSliderAvailable = res.getBoolean(
com.android.internal.R.bool.config_hasAlertSlider);
if (!mAlertSliderAvailable) {
mInterfaceCategory.removePreference(mAlertSlider);
}
}
@Override
@@ -53,13 +70,19 @@ public class Notifications extends SettingsPreferenceFragment implements
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.evolution_settings_notifications) {
new BaseSearchIndexProvider(R.xml.evolution_settings_notifications) {
@Override
public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context);
final Resources resources = context.getResources();
return keys;
}
};
@Override
public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context);
final Resources res = context.getResources();
boolean mAlertSliderAvailable = res.getBoolean(
com.android.internal.R.bool.config_hasAlertSlider);
if (!mAlertSliderAvailable)
keys.add(KEY_ALERT_SLIDER_PREF);
return keys;
}
};
}