Use FooterPreference in xml explicitly

Removed the FooterPreferenceMixin from the FeatureFlagsDashboard page.

Fixes: 139046148
Test: manual test
Change-Id: I6363f265a9c8b996141b7d7547c450cb70e2a7cd
This commit is contained in:
Sunny Shao
2019-08-07 17:48:32 +08:00
parent c9d8437287
commit b97eda4ff5
3 changed files with 6 additions and 76 deletions

View File

@@ -25,4 +25,10 @@
android:layout="@layout/preference_category_no_label"
android:title="@string/summary_placeholder"
settings:controller="com.android.settings.development.featureflags.FeatureFlagsPreferenceController" />
<com.android.settingslib.widget.FooterPreference
android:key="feature_flag_footer"
android:title="@string/experimental_category_title"
android:selectable="false"
settings:searchable="false"/>
</PreferenceScreen>

View File

@@ -1,50 +0,0 @@
/*
* Copyright (C) 2018 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.development.featureflags;
import android.content.Context;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.widget.FooterPreferenceMixinCompat;
public class FeatureFlagFooterPreferenceController extends BasePreferenceController
implements LifecycleObserver, OnStart {
private FooterPreferenceMixinCompat mFooterMixin;
public FeatureFlagFooterPreferenceController(Context context) {
super(context, "feature_flag_footer_pref");
}
public void setFooterMixin(FooterPreferenceMixinCompat mixin) {
mFooterMixin = mixin;
}
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
@Override
public void onStart() {
mFooterMixin.createFooterPreference()
.setTitle(R.string.experimental_category_title);
}
}

View File

@@ -24,8 +24,6 @@ import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.development.DevelopmentSettingsEnabler;
import com.android.settingslib.search.SearchIndexable;
@@ -55,7 +53,6 @@ public class FeatureFlagsDashboard extends DashboardFragment {
@Override
public void onAttach(Context context) {
super.onAttach(context);
use(FeatureFlagFooterPreferenceController.class).setFooterMixin(mFooterPreferenceMixin);
}
@Override
@@ -63,23 +60,6 @@ public class FeatureFlagsDashboard extends DashboardFragment {
return 0;
}
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
return buildPrefControllers(context, getSettingsLifecycle());
}
private static List<AbstractPreferenceController> buildPrefControllers(Context context,
Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
final FeatureFlagFooterPreferenceController footerController =
new FeatureFlagFooterPreferenceController(context);
if (lifecycle != null) {
lifecycle.addObserver(footerController);
}
controllers.add(footerController);
return controllers;
}
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
@@ -97,11 +77,5 @@ public class FeatureFlagsDashboard extends DashboardFragment {
protected boolean isPageSearchEnabled(Context context) {
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
}
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
return buildPrefControllers(context, null /* lifecycle */);
}
};
}