Home | History | Annotate | Download | only in settings
      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.preference.PreferenceFragment;
     20 import com.android.internal.logging.MetricsLogger;
     21 
     22 /**
     23  * Instrumented fragment that logs visibility state.
     24  */
     25 public abstract class InstrumentedFragment extends PreferenceFragment {
     26     // Declare new temporary categories here, starting after this value.
     27     public static final int UNDECLARED = 100000;
     28 
     29     /**
     30      * Declare the view of this category.
     31      *
     32      * Categories are defined in {@link com.android.internal.logging.MetricsLogger}
     33      * or if there is no relevant existing category you may define one in
     34      * {@link com.android.settings.InstrumentedFragment}.
     35      */
     36     protected abstract int getMetricsCategory();
     37 
     38     @Override
     39     public void onResume() {
     40         super.onResume();
     41         MetricsLogger.visible(getActivity(), getMetricsCategory());
     42     }
     43 
     44     @Override
     45     public void onPause() {
     46         super.onPause();
     47         MetricsLogger.hidden(getActivity(), getMetricsCategory());
     48     }
     49 }
     50