John Spurlock | 95a6fdf | 2013-03-20 15:38:18 -0400 | [diff] [blame] | 1 | /* |
| 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 Spurlock | 5245248 | 2013-03-21 08:27:58 -0400 | [diff] [blame] | 17 | package com.android.keyguard; |
John Spurlock | 95a6fdf | 2013-03-20 15:38:18 -0400 | [diff] [blame] | 18 | |
| 19 | import android.content.Context; |
| 20 | import android.util.AttributeSet; |
| 21 | import android.view.MotionEvent; |
| 22 | import android.view.View; |
John Spurlock | 95a6fdf | 2013-03-20 15:38:18 -0400 | [diff] [blame] | 23 | |
Sunny Goyal | 87fccf0 | 2019-08-13 17:39:10 -0700 | [diff] [blame] | 24 | import com.android.systemui.R; |
| 25 | |
Jorim Jaggi | e19b1ac | 2014-09-11 18:17:56 +0200 | [diff] [blame] | 26 | public class EmergencyCarrierArea extends AlphaOptimizedLinearLayout { |
John Spurlock | 95a6fdf | 2013-03-20 15:38:18 -0400 | [diff] [blame] | 27 | |
| 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 Viverette | 51efddb | 2017-04-05 10:00:01 -0400 | [diff] [blame] | 42 | mCarrierText = findViewById(R.id.carrier_text); |
| 43 | mEmergencyButton = findViewById(R.id.emergency_call_button); |
John Spurlock | 95a6fdf | 2013-03-20 15:38:18 -0400 | [diff] [blame] | 44 | |
| 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 Jaggi | 40a0b38 | 2014-05-27 21:12:27 +0200 | [diff] [blame] | 50 | if (mCarrierText.getVisibility() != View.VISIBLE) return false; |
John Spurlock | 95a6fdf | 2013-03-20 15:38:18 -0400 | [diff] [blame] | 51 | 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 Jaggi | 40a0b38 | 2014-05-27 21:12:27 +0200 | [diff] [blame] | 62 | |
| 63 | public void setCarrierTextVisible(boolean visible) { |
| 64 | mCarrierText.setVisibility(visible ? View.VISIBLE : View.GONE); |
| 65 | } |
John Spurlock | 95a6fdf | 2013-03-20 15:38:18 -0400 | [diff] [blame] | 66 | } |