2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.os.Bundle;
20 import android.support.v14.preference.PreferenceFragment;
22 import com.android.internal.logging.MetricsLogger;
25 * Instrumented fragment that logs visibility state.
27 public abstract class InstrumentedFragment extends PreferenceFragment {
28 // Declare new temporary categories here, starting after this value.
29 public static final int UNDECLARED = 100000;
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;
48 * Declare the view of this category.
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}.
54 protected abstract int getMetricsCategory();
57 public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
61 public void onResume() {
63 MetricsLogger.visible(getActivity(), getMetricsCategory());
67 public void onPause() {
69 MetricsLogger.hidden(getActivity(), getMetricsCategory());