Android Open Source - gaosp_packages_apps_Phone Select Speed Dial Slot Dialog






From Project

Back to project page gaosp_packages_apps_Phone.

License

The source code is released under:

Apache License

If you think the Android project gaosp_packages_apps_Phone listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.dnaq.dialer2;
//from   w  ww  . j  a  v  a  2  s .c  o m
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.RadioButton;

public class SelectSpeedDialSlotDialog extends Activity implements OnClickListener {

    public static final String PHONE_NUMBER = "phoneNumber";
    
    public static final String SPEED_DIAL_SLOT = "speedDialSlot";
    private String mPhoneNumber;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        Bundle bundle = savedInstanceState == null ? getIntent().getExtras() : savedInstanceState;
        
        mPhoneNumber = bundle.getString(PHONE_NUMBER);
        
        setContentView(R.layout.empty_dialog);

        LinearLayout speedDialSlotContainer = (LinearLayout)findViewById(R.id.EmptyDialogContainer);
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

        for (int i=1; i<=9; i++) {
            RadioButton rb = (RadioButton)getLayoutInflater().inflate(R.layout.contactview_dialog_item_phone, null);
            String phoneNumber = preferences.getString(DialerActivity.PREFERENCE_SPEED_DIAL_SLOT+i, null);
            
            String buttonText = phoneNumber == null ? getString(R.string.not_set) : phoneNumber;
            
            rb.setText(i+": "+buttonText);
            rb.setButtonDrawable(R.drawable.button_speed_dial);
            rb.setTag(i);
            speedDialSlotContainer.addView(rb);
        }
    }
    
    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putString(PHONE_NUMBER, mPhoneNumber);
    }
    
    @Override
    public void onClick(View v) {

        int slot = (Integer)v.getTag();
        Intent data = new Intent();
        data.putExtra(PHONE_NUMBER, mPhoneNumber);
        data.putExtra(SPEED_DIAL_SLOT, slot);
        setResult(RESULT_OK, data);
        finish();
    }
}




Java Source Code List

org.dnaq.dialer2.AsyncContactImageLoader.java
org.dnaq.dialer2.CallLogAdapter.java
org.dnaq.dialer2.CallLogEntry.java
org.dnaq.dialer2.ContactViewDialog.java
org.dnaq.dialer2.Contact.java
org.dnaq.dialer2.ContactsAdapter.java
org.dnaq.dialer2.DialerActivity.java
org.dnaq.dialer2.DialerPreferenceActivity.java
org.dnaq.dialer2.SelectNumberDialog.java
org.dnaq.dialer2.SelectSpeedDialSlotDialog.java
org.dnaq.libs.GroupingCursorAdapter.java