Home | History | Annotate | Download | only in gestures
      1 /*
      2  * Copyright (C) 2016 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.gestures;
     18 
     19 import android.content.Context;
     20 import android.content.SharedPreferences;
     21 import android.provider.SearchIndexableResource;
     22 
     23 import com.android.internal.hardware.AmbientDisplayConfiguration;
     24 import com.android.internal.logging.nano.MetricsProto;
     25 import com.android.settings.R;
     26 import com.android.settings.dashboard.DashboardFragment;
     27 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
     28 import com.android.settings.overlay.FeatureFactory;
     29 import com.android.settings.search.BaseSearchIndexProvider;
     30 
     31 import java.util.Arrays;
     32 import java.util.List;
     33 
     34 public class PickupGestureSettings extends DashboardFragment {
     35 
     36     private static final String TAG = "PickupGestureSettings";
     37 
     38     public static final String PREF_KEY_SUGGESTION_COMPLETE =
     39             "pref_pickup_gesture_suggestion_complete";
     40 
     41     @Override
     42     public void onAttach(Context context) {
     43         super.onAttach(context);
     44         SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
     45                 .getSuggestionFeatureProvider(context);
     46         SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
     47         prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
     48 
     49         use(PickupGesturePreferenceController.class)
     50             .setConfig(new AmbientDisplayConfiguration(context));
     51     }
     52 
     53     @Override
     54     public int getMetricsCategory() {
     55         return MetricsProto.MetricsEvent.SETTINGS_GESTURE_PICKUP;
     56     }
     57 
     58     @Override
     59     protected String getLogTag() {
     60         return TAG;
     61     }
     62 
     63     @Override
     64     protected int getPreferenceScreenResId() {
     65         return R.xml.pick_up_gesture_settings;
     66     }
     67 
     68     @Override
     69     public int getHelpResource() {
     70         return R.string.help_url_pickup_gesture;
     71     }
     72 
     73     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
     74             new BaseSearchIndexProvider() {
     75                 @Override
     76                 public List<SearchIndexableResource> getXmlResourcesToIndex(
     77                         Context context, boolean enabled) {
     78                     final SearchIndexableResource sir = new SearchIndexableResource(context);
     79                     sir.xmlResId = R.xml.pick_up_gesture_settings;
     80                     return Arrays.asList(sir);
     81                 }
     82             };
     83 
     84 }
     85