Home | History | Annotate | Download | only in datausage
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
      5  * except in compliance with the License. You may obtain a copy of the License at
      6  *
      7  *      http://www.apache.org/licenses/LICENSE-2.0
      8  *
      9  * Unless required by applicable law or agreed to in writing, software distributed under the
     10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     11  * KIND, either express or implied. See the License for the specific language governing
     12  * permissions and limitations under the License.
     13  */
     14 
     15 package com.android.settings.datausage;
     16 
     17 import android.content.Context;
     18 import android.support.v7.preference.Preference;
     19 import android.util.AttributeSet;
     20 import com.android.settings.R;
     21 
     22 public class DataSaverPreference extends Preference implements DataSaverBackend.Listener {
     23 
     24     private final DataSaverBackend mDataSaverBackend;
     25 
     26     public DataSaverPreference(Context context, AttributeSet attrs) {
     27         super(context, attrs);
     28         mDataSaverBackend = new DataSaverBackend(context);
     29     }
     30 
     31     @Override
     32     public void onAttached() {
     33         super.onAttached();
     34         mDataSaverBackend.addListener(this);
     35     }
     36 
     37     @Override
     38     public void onDetached() {
     39         super.onDetached();
     40         mDataSaverBackend.addListener(this);
     41     }
     42 
     43     @Override
     44     public void onDataSaverChanged(boolean isDataSaving) {
     45         setSummary(isDataSaving ? R.string.data_saver_on : R.string.data_saver_off);
     46     }
     47 
     48     @Override
     49     public void onWhitelistStatusChanged(int uid, boolean isWhitelisted) {
     50     }
     51 
     52     @Override
     53     public void onBlacklistStatusChanged(int uid, boolean isBlacklisted) {
     54     }
     55 }
     56