Merge "Prevent ringing updates" into pi-dev am: dbffb1812d
am: 8176af9610
Change-Id: I880b80215cfec3897b18200b18bedbb6c899e241
This commit is contained in:
0
res/drawable-nodpi/gesture_prevent_ringing
Normal file
0
res/drawable-nodpi/gesture_prevent_ringing
Normal file
0
res/raw/gesture_prevent_ringing.mp4
Normal file
0
res/raw/gesture_prevent_ringing.mp4
Normal file
@@ -9867,6 +9867,8 @@
|
|||||||
<string name="gesture_prevent_ringing_screen_title">Prevent ringing</string>
|
<string name="gesture_prevent_ringing_screen_title">Prevent ringing</string>
|
||||||
<!-- Title for prevent ringing setting -->
|
<!-- Title for prevent ringing setting -->
|
||||||
<string name="gesture_prevent_ringing_title">Press Power & Volume Up together</string>
|
<string name="gesture_prevent_ringing_title">Press Power & Volume Up together</string>
|
||||||
|
<!-- Title for prevent ringing setting -->
|
||||||
|
<string name="gesture_prevent_ringing_sound_title">Shortcut to prevent ringing</string>
|
||||||
<!-- Option for prevent ringing setting -->
|
<!-- Option for prevent ringing setting -->
|
||||||
<string name="prevent_ringing_option_vibrate">Vibrate</string>
|
<string name="prevent_ringing_option_vibrate">Vibrate</string>
|
||||||
<!-- Option for prevent ringing setting -->
|
<!-- Option for prevent ringing setting -->
|
||||||
@@ -9874,11 +9876,11 @@
|
|||||||
<!-- Option for prevent ringing setting -->
|
<!-- Option for prevent ringing setting -->
|
||||||
<string name="prevent_ringing_option_none">Do nothing</string>
|
<string name="prevent_ringing_option_none">Do nothing</string>
|
||||||
<!-- Summary for prevent ringing setting -->
|
<!-- Summary for prevent ringing setting -->
|
||||||
<string name="prevent_ringing_option_vibrate_summary">Vibrate all calls and notifications</string>
|
<string name="prevent_ringing_option_vibrate_summary">On (vibrate)</string>
|
||||||
<!-- Summary for prevent ringing setting -->
|
<!-- Summary for prevent ringing setting -->
|
||||||
<string name="prevent_ringing_option_mute_summary">Mute all calls and notifications</string>
|
<string name="prevent_ringing_option_mute_summary">On (mute)</string>
|
||||||
<!-- Summary for prevent ringing setting -->
|
<!-- Summary for prevent ringing setting -->
|
||||||
<string name="prevent_ringing_option_none_summary">Do nothing</string>
|
<string name="prevent_ringing_option_none_summary">Off</string>
|
||||||
|
|
||||||
<!-- Title for detail page of wifi network [CHAR LIMIT=30] -->
|
<!-- Title for detail page of wifi network [CHAR LIMIT=30] -->
|
||||||
<string name="pref_title_network_details">Network details</string>
|
<string name="pref_title_network_details">Network details</string>
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_prevent_ringing_summary"
|
android:key="gesture_prevent_ringing_summary"
|
||||||
android:title="@string/gesture_prevent_ringing_screen_title"
|
android:title="@string/gesture_prevent_ringing_screen_title"
|
||||||
android:fragment="com.android.settings.gestures.PreventRingingGestureSettings" />
|
android:fragment="com.android.settings.gestures.PreventRingingGestureSettings"
|
||||||
|
settings:controller="com.android.settings.gestures.PreventRingingPreferenceController" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -21,15 +21,17 @@
|
|||||||
android:key="gesture_prevent_ringing_screen"
|
android:key="gesture_prevent_ringing_screen"
|
||||||
android:title="@string/gesture_prevent_ringing_screen_title">
|
android:title="@string/gesture_prevent_ringing_screen_title">
|
||||||
|
|
||||||
<!-- TODO: Add video preference when it exists -->
|
|
||||||
<com.android.settings.widget.VideoPreference
|
<com.android.settings.widget.VideoPreference
|
||||||
android:key="gesture_prevent_ringing_video" />
|
android:key="gesture_prevent_ringing_video"
|
||||||
|
app:animation="@raw/gesture_prevent_ringing"
|
||||||
|
app:preview="@drawable/gesture_prevent_ringing" />
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="gesture_prevent_ringing"
|
android:key="gesture_prevent_ringing"
|
||||||
android:title="@string/gesture_prevent_ringing_title"
|
android:title="@string/gesture_prevent_ringing_title"
|
||||||
android:entries="@array/gesture_prevent_ringing_entries"
|
android:entries="@array/gesture_prevent_ringing_entries"
|
||||||
android:entryValues="@array/gesture_prevent_ringing_values"
|
android:entryValues="@array/gesture_prevent_ringing_values"
|
||||||
|
app:controller="com.android.settings.gestures.PreventRingingPreferenceController"
|
||||||
app:keywords="@string/keywords_gesture" />
|
app:keywords="@string/keywords_gesture" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -20,7 +20,7 @@
|
|||||||
android:title="@string/sound_settings"
|
android:title="@string/sound_settings"
|
||||||
android:key="sound_settings"
|
android:key="sound_settings"
|
||||||
settings:keywords="@string/keywords_sounds"
|
settings:keywords="@string/keywords_sounds"
|
||||||
settings:initialExpandedChildrenCount="7">
|
settings:initialExpandedChildrenCount="8">
|
||||||
|
|
||||||
<!-- Media volume -->
|
<!-- Media volume -->
|
||||||
<com.android.settings.notification.VolumeSeekBarPreference
|
<com.android.settings.notification.VolumeSeekBarPreference
|
||||||
@@ -70,6 +70,14 @@
|
|||||||
settings:allowDividerAbove="true"
|
settings:allowDividerAbove="true"
|
||||||
android:order="-120"/>
|
android:order="-120"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="gesture_prevent_ringing_sound"
|
||||||
|
android:title="@string/gesture_prevent_ringing_sound_title"
|
||||||
|
settings:allowDividerAbove="true"
|
||||||
|
android:order="-110"
|
||||||
|
android:fragment="com.android.settings.gestures.PreventRingingGestureSettings"
|
||||||
|
settings:controller="com.android.settings.gestures.PreventRingingPreferenceController" />
|
||||||
|
|
||||||
<!-- Phone ringtone -->
|
<!-- Phone ringtone -->
|
||||||
<com.android.settings.DefaultRingtonePreference
|
<com.android.settings.DefaultRingtonePreference
|
||||||
android:key="ringtone"
|
android:key="ringtone"
|
||||||
|
@@ -65,19 +65,6 @@ public class GestureSettings extends DashboardFragment {
|
|||||||
return R.xml.gestures;
|
return R.xml.gestures;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
|
||||||
return buildPreferenceControllers(context, getLifecycle());
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<AbstractPreferenceController> buildPreferenceControllers(
|
|
||||||
@NonNull Context context, @Nullable Lifecycle lifecycle) {
|
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
|
||||||
controllers.add(new PreventRingingPreferenceController(
|
|
||||||
context, lifecycle, UserHandle.myUserId(), KEY_PREVENT_RINGING));
|
|
||||||
return controllers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
@@ -103,12 +90,6 @@ public class GestureSettings extends DashboardFragment {
|
|||||||
return Arrays.asList(sir);
|
return Arrays.asList(sir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
|
||||||
Context context) {
|
|
||||||
return buildPreferenceControllers(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getNonIndexableKeys(Context context) {
|
public List<String> getNonIndexableKeys(Context context) {
|
||||||
List<String> keys = super.getNonIndexableKeys(context);
|
List<String> keys = super.getNonIndexableKeys(context);
|
||||||
@@ -119,6 +100,7 @@ public class GestureSettings extends DashboardFragment {
|
|||||||
keys.add(KEY_DOUBLE_TWIST);
|
keys.add(KEY_DOUBLE_TWIST);
|
||||||
keys.add(KEY_DOUBLE_TAP_SCREEN);
|
keys.add(KEY_DOUBLE_TAP_SCREEN);
|
||||||
keys.add(KEY_PICK_UP);
|
keys.add(KEY_PICK_UP);
|
||||||
|
keys.add(KEY_PREVENT_RINGING);
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@ import com.android.settings.core.BasePreferenceController;
|
|||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GesturesSettingPreferenceController extends BasePreferenceController {
|
public class GesturesSettingPreferenceController extends BasePreferenceController {
|
||||||
@@ -63,8 +64,7 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle
|
|||||||
@NonNull Context context) {
|
@NonNull Context context) {
|
||||||
final AmbientDisplayConfiguration ambientDisplayConfiguration =
|
final AmbientDisplayConfiguration ambientDisplayConfiguration =
|
||||||
new AmbientDisplayConfiguration(context);
|
new AmbientDisplayConfiguration(context);
|
||||||
final List<AbstractPreferenceController> controllers =
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
GestureSettings.buildPreferenceControllers(context, null);
|
|
||||||
|
|
||||||
controllers.add(new AssistGestureSettingsPreferenceController(context, FAKE_PREF_KEY)
|
controllers.add(new AssistGestureSettingsPreferenceController(context, FAKE_PREF_KEY)
|
||||||
.setAssistOnly(false));
|
.setAssistOnly(false));
|
||||||
@@ -75,6 +75,7 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle
|
|||||||
.setConfig(ambientDisplayConfiguration));
|
.setConfig(ambientDisplayConfiguration));
|
||||||
controllers.add(new DoubleTapScreenPreferenceController(context, FAKE_PREF_KEY)
|
controllers.add(new DoubleTapScreenPreferenceController(context, FAKE_PREF_KEY)
|
||||||
.setConfig(ambientDisplayConfiguration));
|
.setConfig(ambientDisplayConfiguration));
|
||||||
|
controllers.add(new PreventRingingPreferenceController(context, FAKE_PREF_KEY));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,19 +63,6 @@ public class PreventRingingGestureSettings extends DashboardFragment {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
|
||||||
return buildPreferenceControllers(context, getLifecycle());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
|
||||||
Lifecycle lifecycle) {
|
|
||||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
|
||||||
controllers.add(new PreventRingingPreferenceController(context, lifecycle,
|
|
||||||
UserHandle.myUserId(), KEY_PREVENT_RINGING));
|
|
||||||
return controllers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider() {
|
new BaseSearchIndexProvider() {
|
||||||
@Override
|
@Override
|
||||||
@@ -85,12 +72,6 @@ public class PreventRingingGestureSettings extends DashboardFragment {
|
|||||||
sir.xmlResId = R.xml.prevent_ringing_gesture_settings;
|
sir.xmlResId = R.xml.prevent_ringing_gesture_settings;
|
||||||
return Arrays.asList(sir);
|
return Arrays.asList(sir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
|
||||||
Context context) {
|
|
||||||
return buildPreferenceControllers(context, null /* lifecycle */);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@ import static android.provider.Settings.Secure.VOLUME_HUSH_MUTE;
|
|||||||
import static android.provider.Settings.Secure.VOLUME_HUSH_OFF;
|
import static android.provider.Settings.Secure.VOLUME_HUSH_OFF;
|
||||||
import static android.provider.Settings.Secure.VOLUME_HUSH_VIBRATE;
|
import static android.provider.Settings.Secure.VOLUME_HUSH_VIBRATE;
|
||||||
|
|
||||||
import android.annotation.UserIdInt;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -31,22 +30,20 @@ import android.support.v7.preference.Preference;
|
|||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settings.widget.VideoPreference;
|
import com.android.settings.widget.VideoPreference;
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnCreate;
|
import com.android.settingslib.core.lifecycle.events.OnCreate;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
||||||
|
|
||||||
public class PreventRingingPreferenceController extends AbstractPreferenceController
|
public class PreventRingingPreferenceController extends BasePreferenceController
|
||||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
|
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
|
||||||
LifecycleObserver, OnResume, OnPause, OnCreate, OnSaveInstanceState {
|
LifecycleObserver, OnResume, OnPause, OnCreate, OnSaveInstanceState {
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_prevent_ringing_video";
|
private static final String PREF_KEY_VIDEO = "gesture_prevent_ringing_video";
|
||||||
private final String mPrefKey;
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_VIDEO_PAUSED = "key_video_paused";
|
static final String KEY_VIDEO_PAUSED = "key_video_paused";
|
||||||
|
|
||||||
@@ -56,17 +53,15 @@ public class PreventRingingPreferenceController extends AbstractPreferenceContro
|
|||||||
|
|
||||||
private final String SECURE_KEY = VOLUME_HUSH_GESTURE;
|
private final String SECURE_KEY = VOLUME_HUSH_GESTURE;
|
||||||
|
|
||||||
@UserIdInt
|
public PreventRingingPreferenceController(Context context, String key) {
|
||||||
private final int mUserId;
|
super(context, key);
|
||||||
|
}
|
||||||
|
|
||||||
public PreventRingingPreferenceController(Context context, Lifecycle lifecycle,
|
@Override
|
||||||
@UserIdInt int userId, String key) {
|
public int getAvailabilityStatus() {
|
||||||
super(context);
|
return mContext.getResources().getBoolean(
|
||||||
if (lifecycle != null) {
|
com.android.internal.R.bool.config_volumeHushGestureEnabled)
|
||||||
lifecycle.addObserver(this);
|
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||||
}
|
|
||||||
mUserId = userId;
|
|
||||||
mPrefKey = key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,21 +139,10 @@ public class PreventRingingPreferenceController extends AbstractPreferenceContro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAvailable() {
|
|
||||||
return mContext.getResources()
|
|
||||||
.getBoolean(com.android.internal.R.bool.config_volumeHushGestureEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getVideoPrefKey() {
|
protected String getVideoPrefKey() {
|
||||||
return PREF_KEY_VIDEO;
|
return PREF_KEY_VIDEO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPreferenceKey() {
|
|
||||||
return mPrefKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
int value = Integer.parseInt((String) newValue);
|
int value = Integer.parseInt((String) newValue);
|
||||||
|
@@ -68,8 +68,7 @@ public class PreventRingingPreferenceControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mController = new PreventRingingPreferenceController(
|
mController = new PreventRingingPreferenceController(mContext, KEY_PICK_UP);
|
||||||
mContext, null, 0, KEY_PICK_UP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user