Add ranking to SuggestionFeatureProvider interface.
Test: RunSettingsRoboTests Fixes: b/35363662 Change-Id: Ib786e6b2733e2b151f73fb68e174a21aedb2b20a
This commit is contained in:
@@ -225,7 +225,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
return;
|
||||
}
|
||||
boolean isSmartSuggestionEnabled = FeatureFactory.getFactory(mContext)
|
||||
.getSuggestionFeatureProvider().isSmartSuggestionEnabled(mContext);
|
||||
.getSuggestionFeatureProvider(mContext).isSmartSuggestionEnabled(mContext);
|
||||
if (mSuggestionParser.dismissSuggestion(suggestion, isSmartSuggestionEnabled)) {
|
||||
mContext.getPackageManager().setComponentEnabledSetting(
|
||||
suggestion.intent.getComponent(),
|
||||
|
||||
@@ -37,9 +37,7 @@ import com.android.settings.dashboard.conditional.ConditionAdapterUtils;
|
||||
import com.android.settings.dashboard.conditional.ConditionManager;
|
||||
import com.android.settings.dashboard.conditional.FocusRecyclerView;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.suggestions.EventStore;
|
||||
import com.android.settings.suggestions.SuggestionFeaturizer;
|
||||
import com.android.settings.suggestions.SuggestionRanker;
|
||||
import com.android.settings.suggestions.SuggestionFeatureProvider;
|
||||
import com.android.settingslib.SuggestionParser;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
@@ -68,7 +66,6 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
private SummaryLoader mSummaryLoader;
|
||||
private ConditionManager mConditionManager;
|
||||
private SuggestionParser mSuggestionParser;
|
||||
private SuggestionRanker mSuggestionRanker;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private SuggestionsChecks mSuggestionsChecks;
|
||||
private DashboardFeatureProvider mDashboardFeatureProvider;
|
||||
@@ -87,7 +84,7 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
mDashboardFeatureProvider = FeatureFactory.getFactory(activity)
|
||||
.getDashboardFeatureProvider(activity);
|
||||
mSuggestionFeatureProvider = FeatureFactory.getFactory(activity)
|
||||
.getSuggestionFeatureProvider();
|
||||
.getSuggestionFeatureProvider(activity);
|
||||
|
||||
if (mDashboardFeatureProvider.isEnabled()) {
|
||||
mSummaryLoader = new SummaryLoader(activity, CategoryKey.CATEGORY_HOMEPAGE);
|
||||
@@ -99,8 +96,6 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
mConditionManager = ConditionManager.get(activity, false);
|
||||
mSuggestionParser = new SuggestionParser(activity,
|
||||
activity.getSharedPreferences(SUGGESTIONS, 0), R.xml.suggestion_ordering);
|
||||
mSuggestionRanker = new SuggestionRanker(
|
||||
new SuggestionFeaturizer(new EventStore(activity)));
|
||||
mSuggestionsChecks = new SuggestionsChecks(getContext());
|
||||
if (DEBUG_TIMING) {
|
||||
Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime)
|
||||
@@ -254,7 +249,7 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
DashboardAdapter.getSuggestionIdentifier(context, suggestion));
|
||||
}
|
||||
// TODO: create a Suggestion class to maintain the id and other info
|
||||
mSuggestionRanker.rank(suggestions, suggestionIds);
|
||||
mSuggestionFeatureProvider.rankSuggestions(suggestions, suggestionIds);
|
||||
}
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
Tile suggestion = suggestions.get(i);
|
||||
|
||||
@@ -1,35 +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.dashboard;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/** Interface should be implemented if you have added new suggestions */
|
||||
public interface SuggestionFeatureProvider {
|
||||
|
||||
/**
|
||||
* Returns true if smart suggestion should be used instead of xml based SuggestionParser.
|
||||
*/
|
||||
boolean isSmartSuggestionEnabled(Context context);
|
||||
|
||||
/** Return true if className is the name of a class of one of your newly added suggestion. */
|
||||
boolean isPresent(String className);
|
||||
|
||||
/** Return true if the suggestion has already been completed and does not need to be shown */
|
||||
boolean isSuggestionCompleted(Context context);
|
||||
|
||||
}
|
||||
@@ -1,38 +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.dashboard;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider {
|
||||
|
||||
@Override
|
||||
public boolean isSmartSuggestionEnabled(Context context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent(String className) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuggestionCompleted(Context context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import com.android.settings.Settings.ZenModeAutomationSuggestionActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.WallpaperSuggestionActivity;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.suggestions.SuggestionFeatureProvider;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -70,7 +71,7 @@ public class SuggestionsChecks {
|
||||
}
|
||||
|
||||
SuggestionFeatureProvider provider =
|
||||
FeatureFactory.getFactory(mContext).getSuggestionFeatureProvider();
|
||||
FeatureFactory.getFactory(mContext).getSuggestionFeatureProvider(mContext);
|
||||
if (provider != null && provider.isPresent(className)) {
|
||||
return provider.isSuggestionCompleted(mContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user