blob: 076e5f1c1ce75a33cce7c4941506a08385abcaa8 [file] [log] [blame]
Jorim Jaggib6cdcbc2014-07-25 21:58:29 +02001/*
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;
Jorim Jaggib6cdcbc2014-07-25 21:58:29 +020023import 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
Chris Craikbd3bfc52015-03-02 10:43:29 -080049 public void setColorFilter(ColorFilter colorFilter) {
Jorim Jaggib6cdcbc2014-07-25 21:58:29 +020050 // 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}