• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import android.widget.LinearLayout;
24 
25 import com.android.keyguard.R;
26 
27 public class EmergencyCarrierArea extends LinearLayout {
28 
29     private CarrierText mCarrierText;
30     private EmergencyButton mEmergencyButton;
31 
EmergencyCarrierArea(Context context)32     public EmergencyCarrierArea(Context context) {
33         super(context);
34     }
35 
EmergencyCarrierArea(Context context, AttributeSet attrs)36     public EmergencyCarrierArea(Context context, AttributeSet attrs) {
37         super(context, attrs);
38     }
39 
40     @Override
onFinishInflate()41     protected void onFinishInflate() {
42         super.onFinishInflate();
43         mCarrierText = (CarrierText) findViewById(R.id.carrier_text);
44         mEmergencyButton = (EmergencyButton) findViewById(R.id.emergency_call_button);
45 
46         // The emergency button overlaps the carrier text, only noticeable when highlighted.
47         // So temporarily hide the carrier text while the emergency button is pressed.
48         mEmergencyButton.setOnTouchListener(new OnTouchListener(){
49             @Override
50             public boolean onTouch(View v, MotionEvent event) {
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 }
63