同期の設定をPreferenceに保存するようにした。
@@ -1,14 +1,43 @@ | ||
1 | 1 | package jp.sf.amateras.nikocale.android; |
2 | 2 | |
3 | 3 | import android.app.Activity; |
4 | +import android.content.SharedPreferences; | |
5 | +import android.content.SharedPreferences.Editor; | |
4 | 6 | import android.os.Bundle; |
7 | +import android.view.View; | |
8 | +import android.view.View.OnClickListener; | |
9 | +import android.widget.Button; | |
10 | +import android.widget.EditText; | |
5 | 11 | |
6 | 12 | public class ConfigActivity extends Activity { |
7 | 13 | |
14 | + public static final String CONFIG_MAILADDRESS = "MAIL_ADDRESS"; | |
15 | + public static final String CONFIG_PASSWORD = "PASSWORD"; | |
16 | + | |
8 | 17 | @Override |
9 | 18 | public void onCreate(Bundle savedInstanceState) { |
10 | 19 | super.onCreate(savedInstanceState); |
11 | 20 | setContentView(R.layout.config); |
21 | + | |
22 | + SharedPreferences pref = getPreferences(MODE_PRIVATE); | |
23 | + final EditText mailAddress = (EditText) findViewById(R.id.MailAddress); | |
24 | + mailAddress.setText(pref.getString(CONFIG_MAILADDRESS, "")); | |
25 | + | |
26 | + final EditText password = (EditText) findViewById(R.id.Password); | |
27 | + password.setText(pref.getString(CONFIG_PASSWORD, "")); | |
28 | + | |
29 | + Button button = (Button) findViewById(R.id.ConfigSaveButton); | |
30 | + button.setOnClickListener(new OnClickListener() { | |
31 | + @Override | |
32 | + public void onClick(View v) { | |
33 | + Editor editor = getPreferences(MODE_PRIVATE).edit(); | |
34 | + editor.putString(CONFIG_MAILADDRESS, mailAddress.getText().toString()); | |
35 | + editor.putString(CONFIG_PASSWORD, password.getText().toString()); | |
36 | + editor.commit(); | |
37 | + | |
38 | + ConfigActivity.this.finish(); | |
39 | + } | |
40 | + }); | |
12 | 41 | } |
13 | 42 | |
14 | 43 | } |