1 /* 2 * Copyright (C) 2008 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.phone; 18 19 import android.content.Context; 20 import android.graphics.Rect; 21 import android.graphics.drawable.Drawable; 22 import android.util.AttributeSet; 23 import android.util.Log; 24 import android.view.FocusFinder; 25 import android.view.KeyEvent; 26 import android.view.MotionEvent; 27 import android.view.View; 28 import android.view.ViewConfiguration; 29 import android.view.ViewGroup; 30 import android.widget.LinearLayout; 31 32 import java.util.ArrayList; 33 34 /** 35 * DTMFTwelveKeyDialerView is the view logic that the DTMFDialer uses. 36 * This is really a thin wrapper around Linear Layout that intercepts 37 * some user interactions to provide the correct UI behaviour for the 38 * dialer. 39 * 40 * See dtmf_twelve_key_dialer_view.xml. 41 */ 42 class DTMFTwelveKeyDialerView extends LinearLayout { 43 44 private static final String LOG_TAG = "PHONE/DTMFTwelveKeyDialerView"; 45 private static final boolean DBG = false; 46 47 private DTMFTwelveKeyDialer mDialer; 48 49 DTMFTwelveKeyDialerView(Context context)50 public DTMFTwelveKeyDialerView (Context context) { 51 super(context); 52 } 53 DTMFTwelveKeyDialerView(Context context, AttributeSet attrs)54 public DTMFTwelveKeyDialerView(Context context, AttributeSet attrs) { 55 super(context, attrs); 56 } 57 setDialer(DTMFTwelveKeyDialer dialer)58 void setDialer (DTMFTwelveKeyDialer dialer) { 59 mDialer = dialer; 60 } 61 62 /** 63 * Normally we ignore everything except for the BACK and CALL keys. 64 * For those, we pass them to the model (and then the InCallScreen). 65 */ 66 @Override dispatchKeyEvent(KeyEvent event)67 public boolean dispatchKeyEvent(KeyEvent event) { 68 if (DBG) log("dispatchKeyEvent(" + event + ")..."); 69 70 int keyCode = event.getKeyCode(); 71 if (mDialer != null) { 72 switch (keyCode) { 73 case KeyEvent.KEYCODE_BACK: 74 case KeyEvent.KEYCODE_CALL: 75 return event.isDown() ? mDialer.onKeyDown(keyCode, event) : 76 mDialer.onKeyUp(keyCode, event); 77 } 78 } 79 80 if (DBG) log("==> dispatchKeyEvent: forwarding event to the DTMFDialer"); 81 return super.dispatchKeyEvent(event); 82 } 83 log(String msg)84 private void log(String msg) { 85 Log.d(LOG_TAG, msg); 86 } 87 } 88