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.incallui; 18 19 import android.telephony.PhoneNumberUtils; 20 21 /** 22 * Logic for call buttons. 23 */ 24 public class DialpadPresenter extends Presenter<DialpadPresenter.DialpadUi> 25 implements InCallPresenter.InCallStateListener { 26 27 @Override 28 public void onUiReady(DialpadUi ui) { 29 super.onUiReady(ui); 30 } 31 32 @Override 33 public void onStateChange(InCallPresenter.InCallState state, CallList callList) { 34 35 } 36 37 /** 38 * Processes the specified digit as a DTMF key, by playing the 39 * appropriate DTMF tone, and appending the digit to the EditText 40 * field that displays the DTMF digits sent so far. 41 * 42 * @see #processDtmf(char, boolean) 43 */ 44 public final void processDtmf(char c) { 45 processDtmf(c, false); 46 } 47 48 /** 49 * Processes the specified digit as a DTMF key, by playing the appropriate 50 * DTMF tone (or short tone if requested), and appending the digit to the 51 * EditText field that displays the DTMF digits sent so far. 52 */ 53 public final void processDtmf(char c, boolean timedShortTone) { 54 Log.d(this, "Processing dtmf key " + c); 55 // if it is a valid key, then update the display and send the dtmf tone. 56 if (PhoneNumberUtils.is12Key(c)) { 57 Log.d(this, "updating display and sending dtmf tone for '" + c + "'"); 58 59 // Append this key to the "digits" widget. 60 getUi().appendDigitsToField(c); 61 // Plays the tone through CallCommandService 62 CallCommandClient.getInstance().playDtmfTone(c, timedShortTone); 63 } else { 64 Log.d(this, "ignoring dtmf request for '" + c + "'"); 65 } 66 } 67 68 /** 69 * Stops the local tone based on the phone type. 70 */ 71 public void stopTone() { 72 Log.d(this, "stopping remote tone"); 73 CallCommandClient.getInstance().stopDtmfTone(); 74 } 75 76 public interface DialpadUi extends Ui { 77 void setVisible(boolean on); 78 void appendDigitsToField(char digit); 79 } 80 } 81