Advertisement
Guest User

Untitled

a guest
Mar 9th, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. private void updateUI()
  2. {
  3. //preferences = getSharedPreferences(Select.PREF_FILE_NAME, MODE_PRIVATE);
  4. preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  5.  
  6. toggle = (Button)findViewById(R.id.toggleButton);
  7. incommingEdit = (Button)findViewById(R.id.IncommingEditButton);
  8. outgoingEdit = (Button)findViewById(R.id.outgoingEditButton);
  9. missedEdit = (Button)findViewById(R.id.missedEditButton);
  10. save = (Button)findViewById(R.id.saveButton);
  11. cancel = (Button)findViewById(R.id.cancelButton);
  12. incommingCheck = (CheckBox)findViewById(R.id.incommingCheck);
  13. outgoingCheck = (CheckBox)findViewById(R.id.outgoingCheck);
  14. missedCheck = (CheckBox)findViewById(R.id.missedCheck);
  15. incommingTextView = (TextView) findViewById(R.id.incommingTextView);
  16. outgoingTextView = (TextView) findViewById(R.id.outgoingTextView);
  17. missedTextView = (TextView) findViewById(R.id.missedTextView);
  18.  
  19. //Disable all the edit buttons until their checkboxes are checked.
  20. incommingEdit.setEnabled(false);
  21. outgoingEdit.setEnabled(false);
  22. missedEdit.setEnabled(false);
  23.  
  24. //Display the messages in the text views.
  25. incommingTextView.setText(preferences.getString("incommingMsgPhone", "Currently there are no messages saved."));
  26. outgoingTextView.setText(preferences.getString("outgoingMsgPhone", "Currently there are no messages saved."));
  27. missedTextView.setText(preferences.getString("missedMsgPhone", "Currently there are no messages saved."));
  28.  
  29. //Check the check boxes.
  30. if(preferences.getInt("incommingPhone", 0) == Calls.INCOMING_TYPE)
  31. {
  32. incommingCheck.setChecked(true);
  33. incommingEdit.setEnabled(true);
  34. }
  35.  
  36. if(preferences.getInt("outgoingPhone", 0) == Calls.OUTGOING_TYPE)
  37. {
  38. outgoingCheck.setChecked(true);
  39. outgoingEdit.setEnabled(true);
  40. }
  41.  
  42. if(preferences.getInt("missedPhone", 0) == Calls.MISSED_TYPE)
  43. {
  44. missedCheck.setChecked(true);
  45. missedEdit.setEnabled(true);
  46. }
  47.  
  48. //Check if the application is on or off and set the text of the button.
  49. //preferences = getSharedPreferences(Select.PREF_FILE_NAME, MODE_PRIVATE);
  50. boolean on = preferences.getBoolean("isOn", false);
  51. if(!on)
  52. toggle.setText("Turn On");
  53. else
  54. toggle.setText("Turn off");
  55. }
  56.  
  57. save.setOnClickListener(new OnClickListener()
  58. {
  59.  
  60. @Override
  61. public void onClick(View v)
  62. {
  63. // TODO Auto-generated method stub
  64. //Save all in the preference file and exit.
  65. //preferences = getSharedPreferences(Select.PREF_FILE_NAME, MODE_PRIVATE);
  66. Editor editor = preferences.edit();
  67. editor.putInt("incommingPhone", incomming);
  68. editor.putInt("outgoingPhone", outgoing);
  69. editor.putInt("missedPhone", missed);
  70.  
  71. editor.putString("incommingMsgPhone", incommingMsg);
  72. editor.putString("outgoingMsgPhone", outgoingMsg);
  73. editor.putString("missedMsgPhone", missedMsg);
  74.  
  75. editor.commit();
  76. finish();
  77. }
  78. });
  79.  
  80. Editor editor = preferences.edit();
  81. editor.clear();
  82. editor.putInt("incommingPhone", incomming);
  83. editor.commit();
  84.  
  85. preferences = activity.getSharedPreferences("Share", Context.MODE_PRIVATE);`
  86.  
  87. public void saveFavName(String what)
  88. {
  89.  
  90.  
  91. myPrefs= getSharedPreferences("myPrefs", MODE_PRIVATE);
  92. SharedPreferences.Editor es = myPrefs.edit();
  93. es.putString( "value", what); // add or overwrite someValue
  94. es.commit(); // this saves to disk and notifies observers
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement