Merge Ambient display into Lockscreen settings.

And remove the entry point from security page. Now we only have 1 entry
point from Display page.

Change-Id: I06bc15a6fd8802a4918d8772af2722d5aafa332e
Fixes: 71892510
Test: robotests
This commit is contained in:
Fan Zhang
2018-05-11 17:49:39 -07:00
parent b976044f57
commit 30d4d015b5
18 changed files with 184 additions and 507 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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;
}
}

View File

@@ -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;
}
}