Alert Slider: Add toggle to disable notifications [2/2]
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -1206,4 +1206,8 @@
|
|||||||
<!-- Custom statusbar paddings -->
|
<!-- Custom statusbar paddings -->
|
||||||
<string name="custom_statusbar_padding_start">Padding (Start)</string>
|
<string name="custom_statusbar_padding_start">Padding (Start)</string>
|
||||||
<string name="custom_statusbar_padding_end">Padding (End)</string>
|
<string name="custom_statusbar_padding_end">Padding (End)</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>
|
||||||
|
|||||||
@@ -82,6 +82,13 @@
|
|||||||
android:title="@string/notification_headers_title"
|
android:title="@string/notification_headers_title"
|
||||||
android:summary="@string/notification_headers_summary"
|
android:summary="@string/notification_headers_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" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="notification_light"
|
android:key="notification_light"
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ import android.provider.Settings;
|
|||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
import android.provider.SearchIndexableResource;
|
||||||
import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
|
import com.cherish.settings.preferences.SystemSettingMasterSwitchPreference;
|
||||||
import com.cherish.settings.preferences.SystemSettingSeekBarPreference;
|
import com.cherish.settings.preferences.SystemSettingSeekBarPreference;
|
||||||
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||||
@@ -29,6 +32,10 @@ import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
|||||||
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
import net.margaritov.preference.colorpicker.ColorPickerPreference;
|
||||||
import com.android.internal.util.cherish.CherishUtils;
|
import com.android.internal.util.cherish.CherishUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||||
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
public class NotificationSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener{
|
||||||
|
|
||||||
private static final String NOTIFICATION_PULSE_COLOR = "ambient_notification_light_color";
|
private static final String NOTIFICATION_PULSE_COLOR = "ambient_notification_light_color";
|
||||||
@@ -37,6 +44,7 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
private static final String PULSE_COLOR_MODE_PREF = "ambient_notification_light_color_mode";
|
private static final String PULSE_COLOR_MODE_PREF = "ambient_notification_light_color_mode";
|
||||||
private static final String INCALL_VIB_OPTIONS = "incall_vib_options";
|
private static final String INCALL_VIB_OPTIONS = "incall_vib_options";
|
||||||
private static final String KEY_AMBIENT = "ambient_notification_light_enabled";
|
private static final String KEY_AMBIENT = "ambient_notification_light_enabled";
|
||||||
|
private static final String ALERT_SLIDER_PREF = "alert_slider_notifications";
|
||||||
|
|
||||||
private Preference mChargingLeds;
|
private Preference mChargingLeds;
|
||||||
private ColorPickerPreference mEdgeLightColorPreference;
|
private ColorPickerPreference mEdgeLightColorPreference;
|
||||||
@@ -44,13 +52,21 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
private CustomSeekBarPreference mEdgeLightRepeatCountPreference;
|
private CustomSeekBarPreference mEdgeLightRepeatCountPreference;
|
||||||
private ListPreference mColorMode;
|
private ListPreference mColorMode;
|
||||||
private SystemSettingSwitchPreference mAmbientPref;
|
private SystemSettingSwitchPreference mAmbientPref;
|
||||||
|
private Preference mAlertSlider;
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.cherish_settings_notifications);
|
addPreferencesFromResource(R.xml.cherish_settings_notifications);
|
||||||
PreferenceScreen prefScreen = getPreferenceScreen();
|
ContentResolver resolver = getActivity().getContentResolver();
|
||||||
ContentResolver resolver = getActivity().getContentResolver();
|
final PreferenceScreen prefScreen = getPreferenceScreen();
|
||||||
|
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
|
||||||
@@ -171,4 +187,34 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
|
|||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For Search.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
|
new BaseSearchIndexProvider() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||||
|
boolean enabled) {
|
||||||
|
ArrayList<SearchIndexableResource> result =
|
||||||
|
new ArrayList<SearchIndexableResource>();
|
||||||
|
SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
|
sir.xmlResId = R.xml.cherish_settings_notifications;
|
||||||
|
result.add(sir);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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(ALERT_SLIDER_PREF);
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user