Add a suggestion: showing new device features
- New suggestion activity - Removed useless api SuggestionFeatureProvider.isPresent(). - Also updated support activity search indexing icon and summary Change-Id: Ib52cf26a985f57bf0aac918606b10f75bd024639 Fix: 62034077 Fix: 62196070 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -60,7 +60,6 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
private static final int MAX_WAIT_MILLIS = 700;
|
||||
private static final String TAG = "DashboardSummary";
|
||||
|
||||
private static final String SUGGESTIONS = "suggestions";
|
||||
|
||||
private static final String EXTRA_SCROLL_POSITION = "scroll_position";
|
||||
|
||||
@@ -98,7 +97,7 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
mConditionManager = ConditionManager.get(activity, false);
|
||||
getLifecycle().addObserver(mConditionManager);
|
||||
mSuggestionParser = new SuggestionParser(activity,
|
||||
activity.getSharedPreferences(SUGGESTIONS, 0), R.xml.suggestion_ordering);
|
||||
mSuggestionFeatureProvider.getSharedPrefs(activity), R.xml.suggestion_ordering);
|
||||
mSuggestionsChecks = new SuggestionsChecks(getContext());
|
||||
if (DEBUG_TIMING) {
|
||||
Log.d(TAG, "onCreate took " + (System.currentTimeMillis() - startTime)
|
||||
@@ -276,8 +275,6 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
Tile suggestion = suggestions.get(i);
|
||||
if (mSuggestionsChecks.isSuggestionComplete(suggestion)) {
|
||||
mSuggestionFeatureProvider.dismissSuggestion(
|
||||
context, mSuggestionParser, suggestion);
|
||||
suggestions.remove(i--);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.dashboard.suggestions;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
@@ -33,12 +34,14 @@ public interface SuggestionFeatureProvider {
|
||||
*/
|
||||
boolean isSmartSuggestionEnabled(Context context);
|
||||
|
||||
/** Return true if {@code suggestion} is managed by this provider. */
|
||||
boolean isPresent(@NonNull ComponentName suggestion);
|
||||
|
||||
/** Return true if the suggestion has already been completed and does not need to be shown */
|
||||
boolean isSuggestionCompleted(Context context, @NonNull ComponentName suggestion);
|
||||
|
||||
/**
|
||||
* Returns the {@link SharedPreferences} that holds metadata for suggestions.
|
||||
*/
|
||||
SharedPreferences getSharedPrefs(Context context);
|
||||
|
||||
/**
|
||||
* Ranks the list of suggestions in place.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.dashboard.suggestions;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
@@ -25,6 +26,7 @@ import android.util.Log;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.support.NewDeviceIntroSuggestionActivity;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.suggestions.SuggestionParser;
|
||||
|
||||
@@ -35,6 +37,8 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
private static final String TAG = "SuggestionFeature";
|
||||
private static final int EXCLUSIVE_SUGGESTION_MAX_COUNT = 3;
|
||||
|
||||
private static final String SHARED_PREF_FILENAME = "suggestions";
|
||||
|
||||
private final SuggestionRanker mSuggestionRanker;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
@@ -44,16 +48,19 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent(@NonNull ComponentName component) {
|
||||
public boolean isSuggestionCompleted(Context context, @NonNull ComponentName component) {
|
||||
final String className = component.getClassName();
|
||||
if (className.equals(NewDeviceIntroSuggestionActivity.class.getName())) {
|
||||
return NewDeviceIntroSuggestionActivity.isSuggestionComplete(context);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuggestionCompleted(Context context, @NonNull ComponentName component) {
|
||||
return false;
|
||||
public SharedPreferences getSharedPrefs(Context context) {
|
||||
return context.getSharedPreferences(SHARED_PREF_FILENAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
|
||||
public SuggestionFeatureProviderImpl(Context context) {
|
||||
final Context appContext = context.getApplicationContext();
|
||||
mSuggestionRanker = new SuggestionRanker(
|
||||
|
||||
@@ -79,13 +79,10 @@ public class SuggestionsChecks {
|
||||
return isCameraLiftTriggerEnabled();
|
||||
}
|
||||
|
||||
SuggestionFeatureProvider provider =
|
||||
final SuggestionFeatureProvider provider =
|
||||
FeatureFactory.getFactory(mContext).getSuggestionFeatureProvider(mContext);
|
||||
if (provider != null && provider.isPresent(component)) {
|
||||
return provider.isSuggestionCompleted(mContext, component);
|
||||
}
|
||||
|
||||
return false;
|
||||
return provider.isSuggestionCompleted(mContext, component);
|
||||
}
|
||||
|
||||
private boolean isDeviceSecured() {
|
||||
|
||||
Reference in New Issue
Block a user