FileDocCategorySizeDatePackage
DialtactsActivity.javaAPI DocAndroid 1.5 API7105Wed May 06 22:42:46 BST 2009com.android.phone

DialtactsActivity

public class DialtactsActivity extends android.app.TabActivity
This is old cruft and should be removed, but there is apparently some test code that depends on it.

Fields Summary
public static final String
EXTRA_IGNORE_STATE
private static final int
FAVORITES_STARRED
private static final int
FAVORITES_FREQUENT
private static final int
FAVORITES_STREQUENT
private static final int
FAVORITES_TAB_MODE
Defines what is displayed in the right tab
protected android.widget.TabHost
mTabHost
Constructors Summary
Methods Summary
private voidfixIntent(android.content.Intent intent)

        // This should be cleaned up: the call key used to send an Intent
        // that just said to go to the recent calls list.  It now sends this
        // abstract action, but this class hasn't been rewritten to deal with it.
        if (Intent.ACTION_CALL_BUTTON.equals(intent.getAction())) {
            intent.setDataAndType(Calls.CONTENT_URI, Calls.CONTENT_TYPE);
            intent.putExtra("call_key", true);
            setIntent(intent);
        }
    
private booleanisSendKeyWhileInCall(android.content.Intent intent, boolean recentCallsRequest)
Returns true if the intent is due to hitting the green send key while in a call.

param
intent the intent that launched this activity
param
recentCallsRequest true if the intent is requesting to view recent calls
return
true if the intent is due to hitting the green send key while in a call

        // If there is a call in progress go to the call screen
        if (recentCallsRequest) {
            final boolean callKey = intent.getBooleanExtra("call_key", false);
            // When running under instrumentation PhoneApp.getInstance() can return null, which
            // causes a crash here.
            PhoneApp app = PhoneApp.getInstance();
            if (callKey && app != null && app.handleInCallOrRinging()) {
                return true;
            }
        }
        
        return false;
    
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        final Intent intent = getIntent();
        fixIntent(intent);
        final boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent.getType());

        if (isSendKeyWhileInCall(intent, recentCallsRequest)) {
            finish();
            return;
        }

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialer_activity);

        mTabHost = getTabHost();

        // Setup the tabs
        setupDialerTab();
        setupCallLogTab();
        setupContactsTab();
        setupFavoritesTab();

        setCurrentTab(intent);
    
public booleanonKeyDown(int keyCode, android.view.KeyEvent event)

        // Handle BACK
        if (keyCode == KeyEvent.KEYCODE_BACK && isTaskRoot()) {
            // Instead of stopping, simply push this to the back of the stack.
            // This is only done when running at the top of the stack;
            // otherwise, we have been launched by someone else so need to
            // allow the user to go back to the caller.
            moveTaskToBack(false);
            return true;
        }
        
        return super.onKeyDown(keyCode, event);
    
public voidonNewIntent(android.content.Intent newIntent)

        setIntent(newIntent);
        fixIntent(newIntent);
        setCurrentTab(newIntent);
    
private voidsetCurrentTab(android.content.Intent intent)
Sets the current tab based on the intent's request type

param
recentCallsRequest true is the recent calls tab is desired, false oltherwise

        final boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent.getType());
        if (isSendKeyWhileInCall(intent, recentCallsRequest)) {
            finish();
            return;
        }
        intent.putExtra(EXTRA_IGNORE_STATE, true);
        if (intent.getComponent().getClassName().equals(getClass().getName())) {
            if (recentCallsRequest) {
                mTabHost.setCurrentTab(1);
            } else {
                mTabHost.setCurrentTab(0);
            }
        } else {
            mTabHost.setCurrentTab(2);
        }
        intent.putExtra(EXTRA_IGNORE_STATE, false);
    
private voidsetupCallLogTab()

        mTabHost.addTab(mTabHost.newTabSpec("call_log")
                .setIndicator(getString(R.string.recentCallsIconLabel),
                        getResources().getDrawable(R.drawable.ic_tab_recent))
                .setContent(new Intent("com.android.phone.action.RECENT_CALLS")));
    
private voidsetupContactsTab()

        mTabHost.addTab(mTabHost.newTabSpec("contacts")
                .setIndicator(getText(R.string.contactsIconLabel),
                        getResources().getDrawable(R.drawable.ic_tab_contacts))
                .setContent(new Intent(UI.LIST_DEFAULT)));
    
private voidsetupDialerTab()

        mTabHost.addTab(mTabHost.newTabSpec("dialer")
                .setIndicator(getString(R.string.dialerIconLabel),
                        getResources().getDrawable(R.drawable.ic_tab_dialer))
                .setContent(new Intent("com.android.phone.action.TOUCH_DIALER")));
    
private voidsetupFavoritesTab()

        Intent tab2Intent;
        switch (FAVORITES_TAB_MODE) {
            case FAVORITES_STARRED:
                tab2Intent = new Intent(UI.LIST_STARRED_ACTION);
                break;

            case FAVORITES_FREQUENT:
                tab2Intent = new Intent(UI.LIST_FREQUENT_ACTION);
                break;

            case FAVORITES_STREQUENT:
                tab2Intent = new Intent(UI.LIST_STREQUENT_ACTION);
                break;

            default:
                throw new UnsupportedOperationException("unknown default mode");
        }
        Drawable tab2Icon = getResources().getDrawable(R.drawable.ic_tab_starred);

        mTabHost.addTab(mTabHost.newTabSpec("favorites")
                .setIndicator(getString(R.string.contactsFavoritesLabel), tab2Icon)
                .setContent(tab2Intent));