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.statusbar.phone; 18 19 import android.content.Context; 20 import android.graphics.Canvas; 21 import android.graphics.Color; 22 import android.graphics.ColorFilter; 23 import android.graphics.Rect; 24 import android.graphics.drawable.Drawable; 25 import android.util.AttributeSet; 26 import android.view.WindowInsets; 27 import android.widget.FrameLayout; 28 29 /** 30 * A view group which contains the preview of phone/camera and draws a black bar at the bottom as 31 * the fake navigation bar. 32 */ 33 public class KeyguardPreviewContainer extends FrameLayout { 34 35 private Drawable mBlackBarDrawable = new Drawable() { 36 @Override 37 public void draw(Canvas canvas) { 38 canvas.save(); 39 canvas.clipRect(0, getHeight() - getPaddingBottom(), getWidth(), getHeight()); 40 canvas.drawColor(Color.BLACK); 41 canvas.restore(); 42 } 43 44 @Override 45 public void setAlpha(int alpha) { 46 // noop 47 } 48 49 @Override 50 public void setColorFilter(ColorFilter cf) { 51 // noop 52 } 53 54 @Override 55 public int getOpacity() { 56 return android.graphics.PixelFormat.OPAQUE; 57 } 58 }; 59 60 public KeyguardPreviewContainer(Context context, AttributeSet attrs) { 61 super(context, attrs); 62 setBackground(mBlackBarDrawable); 63 } 64 65 @Override 66 public WindowInsets onApplyWindowInsets(WindowInsets insets) { 67 setPadding(0, 0, 0, insets.getStableInsetBottom()); 68 return super.onApplyWindowInsets(insets); 69 } 70 } 71