Settings: Add vibration patterns from OOS [3/3]
a rewrite of: c4560cafae
Change-Id: If5e776b622d603ed9c4022e23e6904b5c996e195
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
@@ -135,4 +135,23 @@
|
||||
<item>4</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Vibration patterns -->
|
||||
<string-array name="vibration_pattern_entries">
|
||||
<item>@string/pattern_dzzz_dzzz</item>
|
||||
<item>@string/pattern_dzzz_da</item>
|
||||
<item>@string/pattern_mm_mm_mm</item>
|
||||
<item>@string/pattern_da_da_dzzz</item>
|
||||
<item>@string/pattern_da_dzzz_da</item>
|
||||
<item>@string/pattern_custom</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="vibration_pattern_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -283,4 +283,13 @@
|
||||
<string name="always_on_display_schedule_sunrise">Sunrise</string>
|
||||
<string name="always_on_display_schedule_mixed_sunset">Turns on from sunset till a time</string>
|
||||
<string name="always_on_display_schedule_mixed_sunrise">Turns on from a time till sunrise</string>
|
||||
|
||||
<!-- Vibration patterns -->
|
||||
<string name="vibration_pattern_title">Ringtone vibration pattern</string>
|
||||
<string name="pattern_dzzz_dzzz" translatable="false">dzzz-dzzz</string>
|
||||
<string name="pattern_dzzz_da" translatable="false">dzzz-da</string>
|
||||
<string name="pattern_mm_mm_mm" translatable="false">mm-mm-mm</string>
|
||||
<string name="pattern_da_da_dzzz" translatable="false">da-da-dzzz</string>
|
||||
<string name="pattern_da_dzzz_da" translatable="false">da-dzzz-da</string>
|
||||
<string name="pattern_custom">Custom</string>
|
||||
</resources>
|
||||
|
||||
@@ -178,6 +178,14 @@
|
||||
settings:controller="com.android.settings.accessibility.VibrationPreferenceController"
|
||||
settings:keywords="@string/keywords_vibration"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="vibration_pattern"
|
||||
android:title="@string/vibration_pattern_title"
|
||||
android:order="-125"
|
||||
android:entries="@array/vibration_pattern_entries"
|
||||
android:entryValues="@array/vibration_pattern_values"
|
||||
android:dependency="vibrate_for_calls"/>
|
||||
|
||||
<com.android.settingslib.PrimarySwitchPreference
|
||||
android:key="gesture_prevent_ringing_sound"
|
||||
android:title="@string/gesture_prevent_ringing_sound_title"
|
||||
|
||||
@@ -308,6 +308,7 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
|
||||
controllers.add(new NotificationRingtonePreferenceController(context));
|
||||
controllers.add(new IncreasingRingPreferenceController(context));
|
||||
controllers.add(new IncreasingRingVolumePreferenceController(context));
|
||||
controllers.add(new VibrationPatternPreferenceController(context));
|
||||
|
||||
// === Other Sound Settings ===
|
||||
final DialPadTonePreferenceController dialPadTonePreferenceController =
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Yet Another AOSP 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.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
/**
|
||||
* This class allows choosing a vibration pattern while ringing
|
||||
*/
|
||||
public class VibrationPatternPreferenceController extends AbstractPreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String KEY_VIB_PATTERN = "vibration_pattern";
|
||||
|
||||
private ListPreference mVibPattern;
|
||||
|
||||
public VibrationPatternPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_VIB_PATTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mVibPattern = (ListPreference) screen.findPreference(KEY_VIB_PATTERN);
|
||||
int vibPattern = Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.RINGTONE_VIBRATION_PATTERN, 0);
|
||||
mVibPattern.setValueIndex(vibPattern);
|
||||
mVibPattern.setSummary(mVibPattern.getEntries()[vibPattern]);
|
||||
mVibPattern.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
int vibPattern = Integer.valueOf((String) newValue);
|
||||
Settings.System.putInt(mContext.getContentResolver(),
|
||||
Settings.System.RINGTONE_VIBRATION_PATTERN, vibPattern);
|
||||
mVibPattern.setSummary(mVibPattern.getEntries()[vibPattern]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user