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

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Pranav Vashi
2021-07-04 00:31:25 +07:00
committed by Hưng Phan
parent 7c3bcc8509
commit a9d7b858b2
3 changed files with 29 additions and 3 deletions

View File

@@ -440,4 +440,8 @@
<string name="swap_volume_buttons_summary">Swap volume buttons when the screen is rotated</string> <string name="swap_volume_buttons_summary">Swap volume buttons when the screen is rotated</string>
<string name="volume_panel_on_left_title">Show volume panel on left</string> <string name="volume_panel_on_left_title">Show volume panel on left</string>
<string name="volume_panel_on_left_summary">Display volume panel on the left side of the screen</string> <string name="volume_panel_on_left_summary">Display volume panel on the left side of the screen</string>
<!-- 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>
</resources> </resources>

View File

@@ -53,6 +53,15 @@
android:summary="@string/notification_sound_vib_screen_on_summary" android:summary="@string/notification_sound_vib_screen_on_summary"
android:defaultValue="true" /> android:defaultValue="true" />
<!-- Alert Slider Notifications -->
<com.cherish.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" />
</PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:key="incall_vib_options" android:key="incall_vib_options"
android:title="@string/incall_vibration_category" > android:title="@string/incall_vibration_category" >

View File

@@ -38,7 +38,10 @@ import java.util.List;
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{ public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
private static final String INCALL_VIB_OPTIONS = "incall_vib_options"; private static final String INCALL_VIB_OPTIONS = "incall_vib_options";
private static final String ALERT_SLIDER_PREF = "alert_slider_notifications";
private Preference mChargingLeds; private Preference mChargingLeds;
private Preference mAlertSlider;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@@ -48,6 +51,12 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
final PreferenceScreen prefScreen = getPreferenceScreen(); final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources res = getResources(); final Resources res = getResources();
mAlertSlider = (Preference) prefScreen.findPreference(ALERT_SLIDER_PREF);
boolean mAlertSliderAvailable = res.getBoolean(
com.android.internal.R.bool.config_hasAlertSlider);
if (!mAlertSliderAvailable)
prefScreen.removePreference(mAlertSlider);
mChargingLeds = (Preference) findPreference("charging_light"); mChargingLeds = (Preference) findPreference("charging_light");
if (mChargingLeds != null if (mChargingLeds != null
&& !getResources().getBoolean( && !getResources().getBoolean(
@@ -94,6 +103,10 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
public List<String> getNonIndexableKeys(Context context) { public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context); List<String> keys = super.getNonIndexableKeys(context);
final Resources res = context.getResources(); final Resources res = context.getResources();
boolean mAlertSliderAvailable = res.getBoolean(
com.android.internal.R.bool.config_hasAlertSlider);
if (!mAlertSliderAvailable)
keys.add(ALERT_SLIDER_PREF);
return keys; return keys;
} }
}; };