Add swipe to see notification to "Notification preferences"
Bug: 31799948 Test: RunSettingsRoboTests Change-Id: Ib892ca4d5596c1c89e1efaf636a3eefd7cee371a
This commit is contained in:
@@ -34,9 +34,9 @@ import android.view.ViewGroup;
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -53,11 +53,11 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
private static final String PREF_KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
|
||||
private static final String PREF_KEY_DOUBLE_TWIST = "gesture_double_twist";
|
||||
private static final String PREF_KEY_PICK_UP = "gesture_pick_up";
|
||||
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
|
||||
private static final String PREF_KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen";
|
||||
private static final String DEBUG_DOZE_COMPONENT = "debug.doze.component";
|
||||
|
||||
private List<GesturePreference> mPreferences;
|
||||
private SwipeToNotificationPreferenceController mSwipeToNotificationPreferenceController;
|
||||
|
||||
private AmbientDisplayConfiguration mAmbientConfig;
|
||||
|
||||
@@ -66,6 +66,8 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.gesture_settings);
|
||||
Context context = getActivity();
|
||||
mSwipeToNotificationPreferenceController =
|
||||
new SwipeToNotificationPreferenceController(context);
|
||||
mPreferences = new ArrayList();
|
||||
|
||||
// Double tap power for camera
|
||||
@@ -93,11 +95,7 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
|
||||
// Fingerprint slide for notifications
|
||||
if (isSystemUINavigationAvailable(context)) {
|
||||
addPreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT, isSystemUINavigationEnabled(context));
|
||||
} else {
|
||||
removePreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
|
||||
}
|
||||
mSwipeToNotificationPreferenceController.displayPreference(getPreferenceScreen());
|
||||
|
||||
// Double twist for camera mode
|
||||
if (isDoubleTwistAvailable(context)) {
|
||||
@@ -112,7 +110,7 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
RecyclerView listview = getListView();
|
||||
listview.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@@ -136,6 +134,13 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mSwipeToNotificationPreferenceController.updateState(
|
||||
findPreference(mSwipeToNotificationPreferenceController.getPreferenceKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
@@ -163,9 +168,6 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
Secure.putInt(getContentResolver(), Secure.DOZE_PULSE_ON_PICK_UP, enabled ? 1 : 0);
|
||||
} else if (PREF_KEY_DOUBLE_TAP_SCREEN.equals(key)) {
|
||||
Secure.putInt(getContentResolver(), Secure.DOZE_PULSE_ON_DOUBLE_TAP, enabled ? 1 : 0);
|
||||
} else if (PREF_KEY_SWIPE_DOWN_FINGERPRINT.equals(key)) {
|
||||
Secure.putInt(getContentResolver(),
|
||||
Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, enabled ? 1 : 0);
|
||||
} else if (PREF_KEY_DOUBLE_TWIST.equals(key)) {
|
||||
Secure.putInt(getContentResolver(),
|
||||
Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, enabled ? 1 : 0);
|
||||
@@ -188,16 +190,6 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
|
||||
}
|
||||
|
||||
private static boolean isSystemUINavigationAvailable(Context context) {
|
||||
return context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_supportSystemNavigationKeys);
|
||||
}
|
||||
|
||||
private static boolean isSystemUINavigationEnabled(Context context) {
|
||||
return Secure.getInt(context.getContentResolver(), Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0)
|
||||
== 1;
|
||||
}
|
||||
|
||||
private static boolean isDoubleTwistAvailable(Context context) {
|
||||
return hasSensor(context, R.string.gesture_double_twist_sensor_name,
|
||||
R.string.gesture_double_twist_sensor_vendor);
|
||||
@@ -227,42 +219,41 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
ArrayList<SearchIndexableResource> result =
|
||||
new ArrayList<SearchIndexableResource>();
|
||||
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.gesture_settings;
|
||||
result.add(sir);
|
||||
SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.gesture_settings;
|
||||
result.add(sir);
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
AmbientDisplayConfiguration ambientConfig
|
||||
= new AmbientDisplayConfiguration(context);
|
||||
if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) {
|
||||
result.add(PREF_KEY_DOUBLE_TAP_POWER);
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
AmbientDisplayConfiguration ambientConfig
|
||||
= new AmbientDisplayConfiguration(context);
|
||||
if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) {
|
||||
result.add(PREF_KEY_DOUBLE_TAP_POWER);
|
||||
}
|
||||
if (!ambientConfig.pulseOnPickupAvailable()) {
|
||||
result.add(PREF_KEY_PICK_UP);
|
||||
}
|
||||
if (!ambientConfig.pulseOnDoubleTapAvailable()) {
|
||||
result.add(PREF_KEY_DOUBLE_TAP_SCREEN);
|
||||
}
|
||||
new SwipeToNotificationPreferenceController(context)
|
||||
.updateNonIndexableKeys(result);
|
||||
if (!isDoubleTwistAvailable(context)) {
|
||||
result.add(PREF_KEY_DOUBLE_TWIST);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (!ambientConfig.pulseOnPickupAvailable()) {
|
||||
result.add(PREF_KEY_PICK_UP);
|
||||
}
|
||||
if (!ambientConfig.pulseOnDoubleTapAvailable()) {
|
||||
result.add(PREF_KEY_DOUBLE_TAP_SCREEN);
|
||||
}
|
||||
if (!isSystemUINavigationAvailable(context)) {
|
||||
result.add(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
|
||||
}
|
||||
if (!isDoubleTwistAvailable(context)) {
|
||||
result.add(PREF_KEY_DOUBLE_TWIST);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source 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.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.TwoStatePreference;
|
||||
|
||||
import com.android.settings.core.PreferenceController;
|
||||
|
||||
public class SwipeToNotificationPreferenceController extends PreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
|
||||
|
||||
public SwipeToNotificationPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return PREF_KEY_SWIPE_DOWN_FINGERPRINT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
if (preference != null && preference instanceof TwoStatePreference) {
|
||||
((TwoStatePreference) preference).setChecked(isSystemUINavigationEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailable() {
|
||||
return mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_supportSystemNavigationKeys);
|
||||
}
|
||||
|
||||
private boolean isSystemUINavigationEnabled() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0)
|
||||
== 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, (boolean) newValue ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -17,11 +17,14 @@
|
||||
package com.android.settings.notification;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.gestures.SwipeToNotificationPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -59,8 +62,21 @@ public class ConfigureNotificationSettings extends DashboardFragment {
|
||||
mLockScreenNotificationController = new LockScreenNotificationPreferenceController(context);
|
||||
getLifecycle().addObserver(pulseController);
|
||||
getLifecycle().addObserver(mLockScreenNotificationController);
|
||||
controllers.add(new SwipeToNotificationPreferenceController(context));
|
||||
controllers.add(pulseController);
|
||||
controllers.add(mLockScreenNotificationController);
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
final Context context = getContext();
|
||||
if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context).isEnabled()) {
|
||||
final String prefKey = getPreferenceController(
|
||||
SwipeToNotificationPreferenceController.class)
|
||||
.getPreferenceKey();
|
||||
removePreference(prefKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user