OSDN Git Service

884e07b35c21f570b710b7f127514b6e534c44b4
[android-x86/packages-apps-Settings.git] / src / com / android / settings / InstrumentedFragment.java
1 /*
2  * Copyright (C) 2015 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;
18
19 import android.os.Bundle;
20 import android.support.v14.preference.PreferenceFragment;
21
22 import com.android.internal.logging.MetricsLogger;
23
24 /**
25  * Instrumented fragment that logs visibility state.
26  */
27 public abstract class InstrumentedFragment extends PreferenceFragment {
28     // Declare new temporary categories here, starting after this value.
29     public static final int UNDECLARED = 100000;
30
31     public static final int ACCESSIBILITY_TOGGLE_AUTOCLICK = UNDECLARED + 1;
32     public static final int SOUND = UNDECLARED + 2;
33     public static final int CONFIGURE_NOTIFICATION = UNDECLARED + 3;
34     public static final int CONFIGURE_WIFI = UNDECLARED + 4;
35     public static final int DISPLAY_SCREEN_ZOOM = UNDECLARED + 5;
36     public static final int ACCESSIBILITY_FONT_SIZE = UNDECLARED + 6;
37     public static final int DATA_USAGE_LIST = UNDECLARED + 7;
38     public static final int BILLING_CYCLE = UNDECLARED + 8;
39     public static final int APP_DATA_USAGE = UNDECLARED + 9;
40     public static final int USER_LOCALE_LIST = UNDECLARED + 10;
41     public static final int VIRTUAL_KEYBOARDS = UNDECLARED + 11;
42     public static final int PHYSICAL_KEYBOARDS = UNDECLARED + 12;
43     public static final int ENABLE_VIRTUAL_KEYBOARDS = UNDECLARED + 13;
44     public static final int DATA_SAVER_SUMMARY = UNDECLARED + 14;
45     public static final int DATA_USAGE_UNRESTRICTED_ACCESS = UNDECLARED + 15;
46
47     /**
48      * Declare the view of this category.
49      *
50      * Categories are defined in {@link com.android.internal.logging.MetricsLogger}
51      * or if there is no relevant existing category you may define one in
52      * {@link com.android.settings.InstrumentedFragment}.
53      */
54     protected abstract int getMetricsCategory();
55
56     @Override
57     public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
58     }
59
60     @Override
61     public void onResume() {
62         super.onResume();
63         MetricsLogger.visible(getActivity(), getMetricsCategory());
64     }
65
66     @Override
67     public void onPause() {
68         super.onPause();
69         MetricsLogger.hidden(getActivity(), getMetricsCategory());
70     }
71 }