Back to project page open311-android.
The source code is released under:
GNU General Public License
If you think the Android project open311-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * @copyright 2012 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/gpl.txt GNU/GPL, see LICENSE.txt * @author Cliff Ingham <inghamn@bloomington.in.gov> *//*from www . ja va2 s . co m*/ package gov.in.bloomington.georeporter.fragments; import gov.in.bloomington.georeporter.adapters.PersonalInfoAdapter; import gov.in.bloomington.georeporter.models.Preferences; import gov.in.bloomington.georeporter.util.json.JSONException; import gov.in.bloomington.georeporter.util.json.JSONObject; import android.app.AlertDialog; import android.app.ListFragment; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; import android.telephony.PhoneNumberFormattingTextWatcher; import android.text.InputType; import android.view.View; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; public class PersonalInfoFragment extends ListFragment { JSONObject mPersonalInfo = null; SharedPreferences mPreferences = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPersonalInfo = Preferences.getPersonalInfo(getActivity()); setListAdapter(new PersonalInfoAdapter(mPersonalInfo, getActivity())); } @Override public void onPause() { Preferences.setPersonalInfo(mPersonalInfo, getActivity()); super.onPause(); } @Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); final String fieldname = PersonalInfoAdapter.FIELDS[position]; final TextView label = (TextView)v.findViewById(android.R.id.text1); final TextView input = (TextView)v.findViewById(android.R.id.text2); final EditText newValue = new EditText(getActivity()); newValue.setText(input.getText()); int type = InputType.TYPE_TEXT_FLAG_CAP_WORDS; if (fieldname == "email") { type = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; } if (fieldname == "phone") { type = InputType.TYPE_CLASS_PHONE; newValue.addTextChangedListener(new PhoneNumberFormattingTextWatcher()); } newValue.setInputType(type); new AlertDialog.Builder(getActivity()) .setTitle(label.getText()) .setView(newValue) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { mPersonalInfo.put(fieldname, newValue.getText()); } catch (JSONException e) { // Just ignore any errors } } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do Nothing } }) .show(); } }