Android Open Source - Points Settings Activity






From Project

Back to project page Points.

License

The source code is released under:

GNU General Public License

If you think the Android project Points 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 se.frusunnanbo.points;
// w  w  w  . j a  va 2  s .  c  o m
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class SettingsActivity extends Activity {

  private static TextView messageView;
  private static EditText uriInput;
  private static EditText parentNameInput;
  private static EditText task1Input;
  private static EditText task2Input;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_activity);
    String message = getIntent().getStringExtra("se.frusunnanbo.points.whySettings");
    
    messageView = (TextView) findViewById(R.id.settings_message);
    uriInput = (EditText) findViewById(R.id.uri_input);
    parentNameInput = (EditText) findViewById(R.id.parent_name_input);
    task1Input = (EditText) findViewById(R.id.task1_input);
    task2Input = (EditText) findViewById(R.id.task2_input);
    
    SharedPreferences settings = getSharedPreferences(Constants.PREFS_NAME, 0);
    
    messageView.setText(message);
    uriInput.setText(settings.getString(Constants.URI_KEY, this.getString(R.string.server_uri_default)));
    parentNameInput.setText(settings.getString(Constants.PARENT_NAME_KEY, ""));
    task1Input.setText(settings.getString(Constants.TASK1_KEY, ""));
    task2Input.setText(settings.getString(Constants.TASK2_KEY, ""));
  }

  private void save() {
    // We need an Editor object to make preference changes.
      // All objects are from android.context.Context
      SharedPreferences settings = getSharedPreferences(Constants.PREFS_NAME, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putString(Constants.URI_KEY, uriInput.getText().toString());
      editor.putString(Constants.PARENT_NAME_KEY, parentNameInput.getText().toString());
      editor.putString(Constants.TASK1_KEY, task1Input.getText().toString());
      editor.putString(Constants.TASK2_KEY, task2Input.getText().toString());

      // Commit the edits!
      editor.commit();
  }
  
  
  @Override
  protected void onPause() {
    super.onStop();  
    save();
  }
  
  public void onSave(View view) {
    finish();
  }  

}




Java Source Code List

se.frusunnanbo.points.Constants.java
se.frusunnanbo.points.DailyAlarmStarter.java
se.frusunnanbo.points.DailyPointsActivity.java
se.frusunnanbo.points.Prefs.java
se.frusunnanbo.points.SettingsActivity.java
se.frusunnanbo.points.Storage.java