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>
|
||||
<!-- Title for prevent ringing setting -->
|
||||
<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 -->
|
||||
<string name="prevent_ringing_option_vibrate">Vibrate</string>
|
||||
<!-- Option for prevent ringing setting -->
|
||||
@@ -9874,11 +9876,11 @@
|
||||
<!-- Option for prevent ringing setting -->
|
||||
<string name="prevent_ringing_option_none">Do nothing</string>
|
||||
<!-- 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 -->
|
||||
<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 -->
|
||||
<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] -->
|
||||
<string name="pref_title_network_details">Network details</string>
|
||||
|
@@ -60,6 +60,7 @@
|
||||
<Preference
|
||||
android:key="gesture_prevent_ringing_summary"
|
||||
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>
|
||||
|
@@ -21,15 +21,17 @@
|
||||
android:key="gesture_prevent_ringing_screen"
|
||||
android:title="@string/gesture_prevent_ringing_screen_title">
|
||||
|
||||
<!-- TODO: Add video preference when it exists -->
|
||||
<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
|
||||
android:key="gesture_prevent_ringing"
|
||||
android:title="@string/gesture_prevent_ringing_title"
|
||||
android:entries="@array/gesture_prevent_ringing_entries"
|
||||
android:entryValues="@array/gesture_prevent_ringing_values"
|
||||
app:controller="com.android.settings.gestures.PreventRingingPreferenceController"
|
||||
app:keywords="@string/keywords_gesture" />
|
||||
|
||||
</PreferenceScreen>
|
@@ -20,7 +20,7 @@
|
||||
android:title="@string/sound_settings"
|
||||
android:key="sound_settings"
|
||||
settings:keywords="@string/keywords_sounds"
|
||||
settings:initialExpandedChildrenCount="7">
|
||||
settings:initialExpandedChildrenCount="8">
|
||||
|
||||
<!-- Media volume -->
|
||||
<com.android.settings.notification.VolumeSeekBarPreference
|
||||
@@ -70,6 +70,14 @@
|
||||
settings:allowDividerAbove="true"
|
||||
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 -->
|
||||
<com.android.settings.DefaultRingtonePreference
|
||||
android:key="ringtone"
|
||||
|
@@ -65,19 +65,6 @@ public class GestureSettings extends DashboardFragment {
|
||||
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
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
@@ -103,12 +90,6 @@ public class GestureSettings extends DashboardFragment {
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context 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_TAP_SCREEN);
|
||||
keys.add(KEY_PICK_UP);
|
||||
keys.add(KEY_PREVENT_RINGING);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GesturesSettingPreferenceController extends BasePreferenceController {
|
||||
@@ -63,8 +64,7 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle
|
||||
@NonNull Context context) {
|
||||
final AmbientDisplayConfiguration ambientDisplayConfiguration =
|
||||
new AmbientDisplayConfiguration(context);
|
||||
final List<AbstractPreferenceController> controllers =
|
||||
GestureSettings.buildPreferenceControllers(context, null);
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
|
||||
controllers.add(new AssistGestureSettingsPreferenceController(context, FAKE_PREF_KEY)
|
||||
.setAssistOnly(false));
|
||||
@@ -75,6 +75,7 @@ public class GesturesSettingPreferenceController extends BasePreferenceControlle
|
||||
.setConfig(ambientDisplayConfiguration));
|
||||
controllers.add(new DoubleTapScreenPreferenceController(context, FAKE_PREF_KEY)
|
||||
.setConfig(ambientDisplayConfiguration));
|
||||
controllers.add(new PreventRingingPreferenceController(context, FAKE_PREF_KEY));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
|
@@ -63,19 +63,6 @@ public class PreventRingingGestureSettings extends DashboardFragment {
|
||||
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 =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
@@ -85,12 +72,6 @@ public class PreventRingingGestureSettings extends DashboardFragment {
|
||||
sir.xmlResId = R.xml.prevent_ringing_gesture_settings;
|
||||
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_VIBRATE;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
@@ -31,22 +30,20 @@ import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
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.events.OnCreate;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
|
||||
|
||||
public class PreventRingingPreferenceController extends AbstractPreferenceController
|
||||
public class PreventRingingPreferenceController extends BasePreferenceController
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
|
||||
LifecycleObserver, OnResume, OnPause, OnCreate, OnSaveInstanceState {
|
||||
|
||||
private static final String PREF_KEY_VIDEO = "gesture_prevent_ringing_video";
|
||||
private final String mPrefKey;
|
||||
@VisibleForTesting
|
||||
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;
|
||||
|
||||
@UserIdInt
|
||||
private final int mUserId;
|
||||
public PreventRingingPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
public PreventRingingPreferenceController(Context context, Lifecycle lifecycle,
|
||||
@UserIdInt int userId, String key) {
|
||||
super(context);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
mUserId = userId;
|
||||
mPrefKey = key;
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_volumeHushGestureEnabled)
|
||||
? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@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() {
|
||||
return PREF_KEY_VIDEO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return mPrefKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
int value = Integer.parseInt((String) newValue);
|
||||
|
@@ -68,8 +68,7 @@ public class PreventRingingPreferenceControllerTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mController = new PreventRingingPreferenceController(
|
||||
mContext, null, 0, KEY_PICK_UP);
|
||||
mController = new PreventRingingPreferenceController(mContext, KEY_PICK_UP);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user