android-app/app/src/main/java/fr/gaulupeau/apps/Poche/Settings.java

56 lines
2.1 KiB
Java
Raw Normal View History

2013-11-13 18:14:27 -05:00
package fr.gaulupeau.apps.Poche;
import static fr.gaulupeau.apps.Poche.Helpers.PREFS_NAME;
import fr.gaulupeau.apps.InThePoche.R;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
2014-08-19 15:24:22 -04:00
import android.widget.TextView;
2013-11-13 18:14:27 -05:00
public class Settings extends Activity {
Button btnDone;
EditText editPocheUrl;
2013-11-15 08:32:25 -05:00
EditText editAPIUsername;
EditText editAPIToken;
EditText editGlobalToken;
2014-08-19 15:24:22 -04:00
TextView textViewVersion;
2013-11-13 18:14:27 -05:00
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String pocheUrl = settings.getString("pocheUrl", "http://");
2013-11-15 08:32:25 -05:00
String apiUsername = settings.getString("APIUsername", "");
String apiToken = settings.getString("APIToken", "");
2013-11-13 18:14:27 -05:00
editPocheUrl = (EditText)findViewById(R.id.pocheUrl);
editPocheUrl.setText(pocheUrl);
2013-11-15 08:32:25 -05:00
editAPIUsername = (EditText)findViewById(R.id.APIUsername);
editAPIUsername.setText(apiUsername);
editAPIToken = (EditText)findViewById(R.id.APIToken);
editAPIToken.setText(apiToken);
2013-11-13 18:14:27 -05:00
btnDone = (Button)findViewById(R.id.btnDone);
btnDone.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("pocheUrl", editPocheUrl.getText().toString());
2013-11-15 08:32:25 -05:00
editor.putString("APIUsername", editAPIUsername.getText().toString());
editor.putString("APIToken", editAPIToken.getText().toString());
2013-11-13 18:14:27 -05:00
editor.commit();
finish();
}
});
2014-08-19 15:24:22 -04:00
try {
textViewVersion = (TextView) findViewById(R.id.version);
textViewVersion.setText(getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName);
} catch (Exception e) {
//
}
2013-11-13 18:14:27 -05:00
}
}