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

DeleteFdnContactScreen

public class DeleteFdnContactScreen extends android.app.Activity
Activity to let the user delete an FDN contact.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
private static final String
INTENT_EXTRA_NAME
private static final String
INTENT_EXTRA_NUMBER
private static final int
PIN2_REQUEST_CODE
private String
mName
private String
mNumber
private String
mPin2
protected QueryHandler
mQueryHandler
private android.os.Handler
mHandler
Constructors Summary
Methods Summary
private voidauthenticatePin2()

        Intent intent = new Intent();
        intent.setClass(this, GetPin2Screen.class);
        startActivityForResult(intent, PIN2_REQUEST_CODE);
    
private voiddeleteContact()

        StringBuilder buf = new StringBuilder();
        buf.append("tag='");
        buf.append(mName);
        buf.append("' AND number='");
        buf.append(mNumber);
        buf.append("' AND pin2='");
        buf.append(mPin2);
        buf.append("'");

        Uri uri = Uri.parse("content://sim/fdn");

        mQueryHandler = new QueryHandler(getContentResolver());
        mQueryHandler.startDelete(0, null, uri, buf.toString(), null);
        displayProgress(true);
    
private voiddisplayProgress(boolean flag)

        getWindow().setFeatureInt(
                Window.FEATURE_INDETERMINATE_PROGRESS,
                flag ? PROGRESS_VISIBILITY_ON : PROGRESS_VISIBILITY_OFF);
    
private voidhandleResult(boolean success)

        if (success) {
            if (DBG) log("handleResult: success!");
            showStatus(getResources().getText(R.string.fdn_contact_deleted));
        } else {
            if (DBG) log("handleResult: failed!");
            showStatus(getResources().getText(R.string.pin2_invalid));
        }

        mHandler.postDelayed(new Runnable() {
            public void run() {
                finish();
            }
        }, 2000);

    
private voidlog(java.lang.String msg)

        Log.d(LOG_TAG, "[DeleteFdnContact] " + msg);
    
protected voidonActivityResult(int requestCode, int resultCode, android.content.Intent intent)

        if (DBG) log("onActivityResult");

        switch (requestCode) {
            case PIN2_REQUEST_CODE:
                Bundle extras = (intent != null) ? intent.getExtras() : null;
                if (extras != null) {
                    mPin2 = extras.getString("pin2");
                    showStatus(getResources().getText(
                            R.string.deleting_fdn_contact));
                    deleteContact();
                } else {
                    // if they cancelled, then we just cancel too.
                    if (DBG) log("onActivityResult: CANCELLED");
                    displayProgress(false);
                    finish();
                }
                break;
        }
    
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        resolveIntent();

        authenticatePin2();

        getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.delete_fdn_contact_screen);
    
private voidresolveIntent()

        Intent intent = getIntent();

        mName =  intent.getStringExtra(INTENT_EXTRA_NAME);
        mNumber =  intent.getStringExtra(INTENT_EXTRA_NUMBER);

        if (TextUtils.isEmpty(mName)) {
            finish();
        }
    
private voidshowStatus(java.lang.CharSequence statusMsg)

        if (statusMsg != null) {
            Toast.makeText(this, statusMsg, Toast.LENGTH_SHORT)
            .show();
        }