• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.dashboard;
18 
19 import android.content.Context;
20 import android.support.v7.preference.Preference;
21 import android.support.v7.preference.PreferenceScreen;
22 
23 import com.android.settings.core.PreferenceController;
24 
25 /**
26  * PreferenceController for a dashboard_tile_placeholder, a special preference marking where
27  * dynamic dashboard tiles should be injected in a screen. It is optional when building
28  * preference screen in xml. If not present, all dynamic dashboard tiles will be added to the
29  * bottom of page.
30  */
31 class DashboardTilePlaceholderPreferenceController extends PreferenceController {
32 
33     private static final String KEY_PLACEHOLDER = "dashboard_tile_placeholder";
34 
35     private int mOrder = Preference.DEFAULT_ORDER;
36 
DashboardTilePlaceholderPreferenceController(Context context)37     public DashboardTilePlaceholderPreferenceController(Context context) {
38         super(context);
39     }
40 
41     @Override
displayPreference(PreferenceScreen screen)42     public void displayPreference(PreferenceScreen screen) {
43         final Preference pref = screen.findPreference(getPreferenceKey());
44         if (pref != null) {
45             mOrder = pref.getOrder();
46             screen.removePreference(pref);
47         }
48     }
49 
50     @Override
isAvailable()51     public boolean isAvailable() {
52         return false;
53     }
54 
55     @Override
getPreferenceKey()56     public String getPreferenceKey() {
57         return KEY_PLACEHOLDER;
58     }
59 
getOrder()60     public int getOrder() {
61         return mOrder;
62     }
63 }
64