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 17 package com.android.keyguard; 18 19 import android.content.Context; 20 import android.util.AttributeSet; 21 import android.view.MotionEvent; 22 import android.view.View; 23 24 import com.android.systemui.R; 25 26 public class EmergencyCarrierArea extends AlphaOptimizedLinearLayout { 27 28 private CarrierText mCarrierText; 29 private EmergencyButton mEmergencyButton; 30 EmergencyCarrierArea(Context context)31 public EmergencyCarrierArea(Context context) { 32 super(context); 33 } 34 EmergencyCarrierArea(Context context, AttributeSet attrs)35 public EmergencyCarrierArea(Context context, AttributeSet attrs) { 36 super(context, attrs); 37 } 38 39 @Override onFinishInflate()40 protected void onFinishInflate() { 41 super.onFinishInflate(); 42 mCarrierText = findViewById(R.id.carrier_text); 43 mEmergencyButton = findViewById(R.id.emergency_call_button); 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) { 50 if (mCarrierText.getVisibility() != View.VISIBLE) return false; 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 } 62 setCarrierTextVisible(boolean visible)63 public void setCarrierTextVisible(boolean visible) { 64 mCarrierText.setVisibility(visible ? View.VISIBLE : View.GONE); 65 } 66 } 67