Merge "Merge Ambient display into Lockscreen settings."
This commit is contained in:
committed by
Android (Google) Code Review
commit
77d9076158
@@ -19,10 +19,8 @@ package com.android.settings;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.display.AmbientDisplayPreferenceController;
|
||||
import com.android.settings.display.BrightnessLevelPreferenceController;
|
||||
import com.android.settings.display.CameraGesturePreferenceController;
|
||||
import com.android.settings.display.ColorModePreferenceController;
|
||||
@@ -89,10 +87,6 @@ public class DisplaySettings extends DashboardFragment {
|
||||
controllers.add(new NightDisplayPreferenceController(context));
|
||||
controllers.add(new NightModePreferenceController(context));
|
||||
controllers.add(new ScreenSaverPreferenceController(context));
|
||||
controllers.add(new AmbientDisplayPreferenceController(
|
||||
context,
|
||||
new AmbientDisplayConfiguration(context),
|
||||
KEY_AMBIENT_DISPLAY));
|
||||
controllers.add(new TapToWakePreferenceController(context));
|
||||
controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
|
||||
controllers.add(new VrDisplayPreferenceController(context));
|
||||
|
||||
@@ -32,9 +32,9 @@ import java.util.concurrent.FutureTask;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
|
||||
public class DeviceModelPreferenceController extends BasePreferenceController {
|
||||
|
||||
|
||||
private static final String TAG = "DeviceModelPrefCtrl";
|
||||
|
||||
private Fragment mHost;
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.InlineSwitchPayload;
|
||||
import com.android.settings.search.ResultPayload;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
|
||||
public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreferenceController {
|
||||
|
||||
@@ -96,7 +97,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
||||
@Override
|
||||
public ResultPayload getResultPayload() {
|
||||
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
|
||||
AmbientDisplaySettings.class.getName(), getPreferenceKey(),
|
||||
LockscreenDashboardFragment.class.getName(), getPreferenceKey(),
|
||||
mContext.getString(R.string.ambient_display_screen_title));
|
||||
|
||||
return new InlineSwitchPayload(Settings.Secure.DOZE_ALWAYS_ON,
|
||||
|
||||
@@ -14,15 +14,12 @@
|
||||
package com.android.settings.display;
|
||||
|
||||
import static android.provider.Settings.Secure.DOZE_ENABLED;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_AMBIENT_DISPLAY;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.R;
|
||||
@@ -31,8 +28,12 @@ import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.InlineSwitchPayload;
|
||||
import com.android.settings.search.ResultPayload;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
public class AmbientDisplayNotificationsPreferenceController extends
|
||||
TogglePreferenceController implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -93,7 +94,7 @@ public class AmbientDisplayNotificationsPreferenceController extends
|
||||
//TODO (b/69808376): Remove result payload
|
||||
public ResultPayload getResultPayload() {
|
||||
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
|
||||
AmbientDisplaySettings.class.getName(), KEY_AMBIENT_DISPLAY_NOTIFICATIONS,
|
||||
LockscreenDashboardFragment.class.getName(), KEY_AMBIENT_DISPLAY_NOTIFICATIONS,
|
||||
mContext.getString(R.string.ambient_display_screen_title));
|
||||
|
||||
return new InlineSwitchPayload(Settings.Secure.DOZE_ENABLED,
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
public class AmbientDisplayPreferenceController extends AbstractPreferenceController implements
|
||||
PreferenceControllerMixin {
|
||||
|
||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
||||
|
||||
private final AmbientDisplayConfiguration mConfig;
|
||||
private final String mKey;
|
||||
|
||||
public AmbientDisplayPreferenceController(Context context, AmbientDisplayConfiguration config,
|
||||
String key) {
|
||||
super(context);
|
||||
mConfig = config;
|
||||
mKey = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mConfig.available();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
if (mConfig.alwaysOnEnabled(MY_USER_ID)) {
|
||||
preference.setSummary(R.string.ambient_display_screen_summary_always_on);
|
||||
} else if (mConfig.pulseOnNotificationEnabled(MY_USER_ID)) {
|
||||
preference.setSummary(R.string.ambient_display_screen_summary_notifications);
|
||||
} else if (mConfig.enabled(MY_USER_ID)) {
|
||||
preference.setSummary(R.string.switch_on_text);
|
||||
} else {
|
||||
preference.setSummary(R.string.switch_off_text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return mKey;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.display;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
||||
import com.android.settings.gestures.PickupGesturePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Settings screen for Ambient display.
|
||||
*/
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class AmbientDisplaySettings extends DashboardFragment {
|
||||
|
||||
public static final String KEY_AMBIENT_DISPLAY_ALWAYS_ON = "ambient_display_always_on";
|
||||
|
||||
private static final String TAG = "AmbientDisplaySettings";
|
||||
|
||||
private AmbientDisplayConfiguration mConfig;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
use(AmbientDisplayAlwaysOnPreferenceController.class)
|
||||
.setConfig(getConfig(context))
|
||||
.setCallback(this::updatePreferenceStates);
|
||||
use(AmbientDisplayNotificationsPreferenceController.class).setConfig(getConfig(context));
|
||||
use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
|
||||
use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.ambient_display_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.AMBIENT_DISPLAY_SETTINGS;
|
||||
}
|
||||
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
|
||||
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.ambient_display_settings;
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
private AmbientDisplayConfiguration getConfig(Context context) {
|
||||
if (mConfig == null) {
|
||||
mConfig = new AmbientDisplayConfiguration(context);
|
||||
}
|
||||
return mConfig;
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,14 @@ package com.android.settings.security;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController;
|
||||
import com.android.settings.display.AmbientDisplayNotificationsPreferenceController;
|
||||
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
||||
import com.android.settings.gestures.PickupGesturePreferenceController;
|
||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.users.AddUserWhenLockedPreferenceController;
|
||||
@@ -42,6 +47,8 @@ import androidx.annotation.VisibleForTesting;
|
||||
public class LockscreenDashboardFragment extends DashboardFragment
|
||||
implements OwnerInfoPreferenceController.OwnerInfoCallback {
|
||||
|
||||
public static final String KEY_AMBIENT_DISPLAY_ALWAYS_ON = "ambient_display_always_on";
|
||||
|
||||
private static final String TAG = "LockscreenDashboardFragment";
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -56,6 +63,8 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
||||
static final String KEY_ADD_USER_FROM_LOCK_SCREEN =
|
||||
"security_lockscreen_add_users_when_locked";
|
||||
|
||||
|
||||
private AmbientDisplayConfiguration mConfig;
|
||||
private OwnerInfoPreferenceController mOwnerInfoPreferenceController;
|
||||
|
||||
@Override
|
||||
@@ -78,6 +87,17 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
||||
return R.string.help_url_lockscreen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
use(AmbientDisplayAlwaysOnPreferenceController.class)
|
||||
.setConfig(getConfig(context))
|
||||
.setCallback(this::updatePreferenceStates);
|
||||
use(AmbientDisplayNotificationsPreferenceController.class).setConfig(getConfig(context));
|
||||
use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
|
||||
use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
@@ -105,6 +125,13 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
||||
}
|
||||
}
|
||||
|
||||
private AmbientDisplayConfiguration getConfig(Context context) {
|
||||
if (mConfig == null) {
|
||||
mConfig = new AmbientDisplayConfiguration(context);
|
||||
}
|
||||
return mConfig;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package com.android.settings.security;
|
||||
|
||||
import static com.android.settings.security.EncryptionStatusPreferenceController
|
||||
.PREF_KEY_ENCRYPTION_SECURITY_PAGE;
|
||||
import static com.android.settings.security.EncryptionStatusPreferenceController.PREF_KEY_ENCRYPTION_SECURITY_PAGE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@@ -35,7 +34,6 @@ import com.android.settings.fingerprint.FingerprintProfileStatusPreferenceContro
|
||||
import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
|
||||
import com.android.settings.location.LocationPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.security.screenlock.LockScreenPreferenceController;
|
||||
import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
|
||||
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
@@ -128,7 +126,6 @@ public class SecuritySettings extends DashboardFragment {
|
||||
|
||||
final List<AbstractPreferenceController> securityPreferenceControllers = new ArrayList<>();
|
||||
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(context));
|
||||
securityPreferenceControllers.add(new LockScreenPreferenceController(context, lifecycle));
|
||||
securityPreferenceControllers.add(new ChangeScreenLockPreferenceController(context, host));
|
||||
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY)
|
||||
.setChildren(securityPreferenceControllers));
|
||||
|
||||
@@ -20,33 +20,28 @@ import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
public class LockScreenPreferenceController extends BasePreferenceController implements
|
||||
LifecycleObserver, OnResume {
|
||||
|
||||
static final String KEY_LOCKSCREEN_PREFERENCES = "lockscreen_preferences";
|
||||
|
||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private Preference mPreference;
|
||||
|
||||
public LockScreenPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
super(context, KEY_LOCKSCREEN_PREFERENCES);
|
||||
public LockScreenPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mLockPatternUtils = FeatureFactory.getFactory(context)
|
||||
.getSecurityFeatureProvider().getLockPatternUtils(context);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user