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