blob: 225bebe57128a425975428424e6e76faedfa92ab [file] [log] [blame]
John Spurlock95a6fdf2013-03-20 15:38:18 -04001/*
2 * Copyright (C) 2013 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
John Spurlock52452482013-03-21 08:27:58 -040017package com.android.keyguard;
John Spurlock95a6fdf2013-03-20 15:38:18 -040018
19import android.content.Context;
20import android.util.AttributeSet;
21import android.view.MotionEvent;
22import android.view.View;
John Spurlock95a6fdf2013-03-20 15:38:18 -040023
Sunny Goyal87fccf02019-08-13 17:39:10 -070024import com.android.systemui.R;
25
Jorim Jaggie19b1ac2014-09-11 18:17:56 +020026public class EmergencyCarrierArea extends AlphaOptimizedLinearLayout {
John Spurlock95a6fdf2013-03-20 15:38:18 -040027
28 private CarrierText mCarrierText;
29 private EmergencyButton mEmergencyButton;
30
31 public EmergencyCarrierArea(Context context) {
32 super(context);
33 }
34
35 public EmergencyCarrierArea(Context context, AttributeSet attrs) {
36 super(context, attrs);
37 }
38
39 @Override
40 protected void onFinishInflate() {
41 super.onFinishInflate();
Alan Viverette51efddb2017-04-05 10:00:01 -040042 mCarrierText = findViewById(R.id.carrier_text);
43 mEmergencyButton = findViewById(R.id.emergency_call_button);
John Spurlock95a6fdf2013-03-20 15:38:18 -040044
45 // The emergency button overlaps the carrier text, only noticeable when highlighted.
46 // So temporarily hide the carrier text while the emergency button is pressed.
47 mEmergencyButton.setOnTouchListener(new OnTouchListener(){
48 @Override
49 public boolean onTouch(View v, MotionEvent event) {
Jorim Jaggi40a0b382014-05-27 21:12:27 +020050 if (mCarrierText.getVisibility() != View.VISIBLE) return false;
John Spurlock95a6fdf2013-03-20 15:38:18 -040051 switch(event.getAction()) {
52 case MotionEvent.ACTION_DOWN:
53 mCarrierText.animate().alpha(0);
54 break;
55 case MotionEvent.ACTION_UP:
56 mCarrierText.animate().alpha(1);
57 break;
58 }
59 return false;
60 }});
61 }
Jorim Jaggi40a0b382014-05-27 21:12:27 +020062
63 public void setCarrierTextVisible(boolean visible) {
64 mCarrierText.setVisibility(visible ? View.VISIBLE : View.GONE);
65 }
John Spurlock95a6fdf2013-03-20 15:38:18 -040066}