• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.settings.dashboard.suggestions;
18 
19 import android.content.ComponentName;
20 import android.content.Context;
21 import android.content.SharedPreferences;
22 import android.support.annotation.NonNull;
23 
24 import com.android.settingslib.drawer.Tile;
25 import com.android.settingslib.suggestions.SuggestionParser;
26 
27 import java.util.List;
28 
29 /** Interface should be implemented if you have added new suggestions */
30 public interface SuggestionFeatureProvider {
31 
32     /**
33      * Whether or not the whole suggestion feature is enabled.
34      */
isSuggestionEnabled(Context context)35     boolean isSuggestionEnabled(Context context);
36 
37     /**
38      * Returns true if smart suggestion should be used instead of xml based SuggestionParser.
39      */
isSmartSuggestionEnabled(Context context)40     boolean isSmartSuggestionEnabled(Context context);
41 
42     /** Return true if the suggestion has already been completed and does not need to be shown */
isSuggestionCompleted(Context context, @NonNull ComponentName suggestion)43     boolean isSuggestionCompleted(Context context, @NonNull ComponentName suggestion);
44 
45     /**
46      * Returns the {@link SharedPreferences} that holds metadata for suggestions.
47      */
getSharedPrefs(Context context)48     SharedPreferences getSharedPrefs(Context context);
49 
50     /**
51      * Ranks the list of suggestions in place.
52      *
53      * @param suggestions   List of suggestion Tiles
54      * @param suggestionIds List of suggestion ids corresponding to the suggestion tiles.
55      */
rankSuggestions(final List<Tile> suggestions, List<String> suggestionIds)56     void rankSuggestions(final List<Tile> suggestions, List<String> suggestionIds);
57 
58     /**
59      * Only keep top few suggestions from exclusive suggestions.
60      */
filterExclusiveSuggestions(List<Tile> suggestions)61     void filterExclusiveSuggestions(List<Tile> suggestions);
62 
63     /**
64      * Dismisses a suggestion.
65      */
dismissSuggestion(Context context, SuggestionParser parser, Tile suggestion)66     void dismissSuggestion(Context context, SuggestionParser parser, Tile suggestion);
67 
68     /**
69      * Returns an identifier for the suggestion
70      */
getSuggestionIdentifier(Context context, Tile suggestion)71     String getSuggestionIdentifier(Context context, Tile suggestion);
72 }
73