public class

DTMFTwelveKeyDialer

extends Object
implements View.OnKeyListener View.OnTouchListener SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener
java.lang.Object
   ↳ com.android.phone.DTMFTwelveKeyDialer

Class Overview

Dialer class that encapsulates the DTMF twelve key behaviour. This model backs up the UI behaviour in DTMFTwelveKeyDialerView.java.

Summary

Public Constructors
DTMFTwelveKeyDialer(InCallScreen parent, DTMFTwelveKeyDialerView dialerView, SlidingDrawer dialerDrawer)
DTMFTwelveKeyDialer constructor.
Public Methods
void clearDigits()
Clears out the display of "DTMF digits typed so far" that's kept in mDialpadDigits.
void closeDialer(boolean animate)
Forces the dialer into the "closed" state.
boolean isOpened()
boolean onDialerKeyDown(KeyEvent event)
Called externally (from InCallScreen) to play a DTMF Tone.
boolean onDialerKeyUp(KeyEvent event)
Called externally (from InCallScreen) to cancel the last DTMF Tone played.
void onDrawerClosed()
Implemented for the SlidingDrawer close listener, release the dialer.
void onDrawerOpened()
Implemented for the SlidingDrawer open listener, prepare the dialer.
boolean onKey(View v, int keyCode, KeyEvent event)
Implements View.OnKeyListener for the DTMF buttons.
boolean onKeyDown(int keyCode, KeyEvent event)
catch the back and call buttons to return to the in call activity.
boolean onKeyUp(int keyCode, KeyEvent event)
catch the back and call buttons to return to the in call activity.
boolean onTouch(View v, MotionEvent event)
Implemented for the TouchListener, process the touch events.
void openDialer(boolean animate)
Forces the dialer into the "open" state.
void setHandleVisible(boolean visible)
Sets the visibility of the dialpad's onscreen "handle".
void startDialerSession()
Allocates some resources we keep around during a "dialer session".
void stopDialerSession()
Releases resources we keep around during a "dialer session" (see startDialerSession).
boolean usingSlidingDrawer()
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.view.View.OnKeyListener
From interface android.view.View.OnTouchListener
From interface android.widget.SlidingDrawer.OnDrawerCloseListener
From interface android.widget.SlidingDrawer.OnDrawerOpenListener

Public Constructors

public DTMFTwelveKeyDialer (InCallScreen parent, DTMFTwelveKeyDialerView dialerView, SlidingDrawer dialerDrawer)

DTMFTwelveKeyDialer constructor.

Parameters
parent the InCallScreen instance that owns us.
dialerView the DTMFTwelveKeyDialerView we should use to display the dialpad.
dialerDrawer the SlidingDrawer widget that contains dialerView, or null if this device doesn't use a SlidingDrawer as a container for the dialpad.

Public Methods

public void clearDigits ()

Clears out the display of "DTMF digits typed so far" that's kept in mDialpadDigits. The InCallScreen is responsible for calling this method any time a new call becomes active (or, more simply, any time a call ends). This is how we make sure that the "history" of DTMF digits you type doesn't persist from one call to the next. TODO: it might be more elegent if the dialpad itself could remember the call that we're associated with, and clear the digits if the "current call" has changed since last time. (This would require some unique identifier that's different for each call. We can't just use the foreground Call object, since that's a singleton that lasts the whole life of the phone process. Instead, maybe look at the Connection object that comes back from getEarliestConnection()? Or getEarliestConnectTime()?) Or to be even fancier, we could keep a mapping of *multiple* "active calls" to DTMF strings. That way you could have two lines in use and swap calls multiple times, and we'd still remember the digits for each call. (But that's such an obscure use case that it's probably not worth the extra complexity.)

public void closeDialer (boolean animate)

Forces the dialer into the "closed" state. Does nothing if the dialer is already closed.

Parameters
animate if true, close the dialer with an animation.

public boolean isOpened ()

Returns
  • true if the dialer is currently visible onscreen.

public boolean onDialerKeyDown (KeyEvent event)

Called externally (from InCallScreen) to play a DTMF Tone.

public boolean onDialerKeyUp (KeyEvent event)

Called externally (from InCallScreen) to cancel the last DTMF Tone played.

public void onDrawerClosed ()

Implemented for the SlidingDrawer close listener, release the dialer.

public void onDrawerOpened ()

Implemented for the SlidingDrawer open listener, prepare the dialer.

public boolean onKey (View v, int keyCode, KeyEvent event)

Implements View.OnKeyListener for the DTMF buttons. Enables dialing with trackball/dpad.

public boolean onKeyDown (int keyCode, KeyEvent event)

catch the back and call buttons to return to the in call activity.

public boolean onKeyUp (int keyCode, KeyEvent event)

catch the back and call buttons to return to the in call activity.

public boolean onTouch (View v, MotionEvent event)

Implemented for the TouchListener, process the touch events.

public void openDialer (boolean animate)

Forces the dialer into the "open" state. Does nothing if the dialer is already open.

Parameters
animate if true, open the dialer with an animation.

public void setHandleVisible (boolean visible)

Sets the visibility of the dialpad's onscreen "handle". This has no effect on platforms that don't use a SlidingDrawer as a container for the dialpad.

public void startDialerSession ()

Allocates some resources we keep around during a "dialer session". (Currently, a "dialer session" just means any situation where we might need to play local DTMF tones, which means that we need to keep a ToneGenerator instance around. A ToneGenerator instance keeps an AudioTrack resource busy in AudioFlinger, so we don't want to keep it around forever.) Call stopDialerSession to release the dialer session resources.

public void stopDialerSession ()

Releases resources we keep around during a "dialer session" (see startDialerSession). It's safe to call this even without a corresponding startDialerSession call.

public boolean usingSlidingDrawer ()

Returns
  • true if we're using the style of dialpad that's contained within a SlidingDrawer.