Home | History | Annotate | Download | only in volume
      1 /*
      2  * Copyright (C) 2014 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.systemui.volume;
     18 
     19 import android.content.res.Configuration;
     20 import android.os.Handler;
     21 import android.util.Log;
     22 
     23 import com.android.systemui.R;
     24 import com.android.systemui.SystemUI;
     25 import com.android.systemui.qs.tiles.DndTile;
     26 import com.android.systemui.statusbar.policy.ZenModeController;
     27 import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
     28 
     29 import java.io.FileDescriptor;
     30 import java.io.PrintWriter;
     31 
     32 public class VolumeUI extends SystemUI {
     33     private static final String TAG = "VolumeUI";
     34     private static boolean LOGD = Log.isLoggable(TAG, Log.DEBUG);
     35 
     36     private final Handler mHandler = new Handler();
     37 
     38     private boolean mEnabled;
     39     private VolumeDialogComponent mVolumeComponent;
     40 
     41     @Override
     42     public void start() {
     43         mEnabled = mContext.getResources().getBoolean(R.bool.enable_volume_ui);
     44         if (!mEnabled) return;
     45         mVolumeComponent = new VolumeDialogComponent(this, mContext, null);
     46         putComponent(VolumeComponent.class, getVolumeComponent());
     47         setDefaultVolumeController();
     48     }
     49 
     50     private VolumeComponent getVolumeComponent() {
     51         return mVolumeComponent;
     52     }
     53 
     54     @Override
     55     protected void onConfigurationChanged(Configuration newConfig) {
     56         super.onConfigurationChanged(newConfig);
     57         if (!mEnabled) return;
     58         getVolumeComponent().onConfigurationChanged(newConfig);
     59     }
     60 
     61     @Override
     62     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
     63         pw.print("mEnabled="); pw.println(mEnabled);
     64         if (!mEnabled) return;
     65         getVolumeComponent().dump(fd, pw, args);
     66     }
     67 
     68     private void setDefaultVolumeController() {
     69         DndTile.setVisible(mContext, true);
     70         if (LOGD) Log.d(TAG, "Registering default volume controller");
     71         getVolumeComponent().register();
     72     }
     73 }
     74