You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.4 KiB

package ru.defend.defdevteam.tstu;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
private EditText login, password;
private SharedPreferences sPref;
final String LOGIN = "login";
final String PASSWORD = "password";
final String CHECK = "check";
public CheckBox check;
public void authButtonOnClick(View v){
if(check.isChecked()){
saveForms();
}
Intent WebA = new Intent(this, CabinetActivity.class);
WebA.putExtra("login", login.getText().toString());
WebA.putExtra("pass", password.getText().toString());
startActivity(WebA);
//onFeedReaderComplete();
}
void saveForms() {
sPref = getPreferences(MODE_PRIVATE);
SharedPreferences.Editor ed = sPref.edit();
ed.putString(LOGIN, login.getText().toString());
ed.putString(PASSWORD, password.getText().toString());
ed.putBoolean(CHECK, check.isChecked());
ed.apply();
}
void loadForms() {
sPref = getPreferences(MODE_PRIVATE);
login.setText(sPref.getString(LOGIN, ""));
password.setText(sPref.getString(PASSWORD, ""));
check.setChecked(sPref.getBoolean(CHECK, false));
}
public void updateForms(View v){
if(!check.isChecked()) {
password.setText("");
saveForms();
}
else {
saveForms();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
login = (EditText) findViewById(R.id.editLogin);
password = (EditText) findViewById(R.id.passEdit);
check = (CheckBox) findViewById(R.id.save);
loadForms();
}
@Override
protected void onResume() {
super.onResume();
Intent intent = getIntent();
if (!(intent.getStringExtra("error") == null)) {
Log.i("TESTINGG", intent.getStringExtra("error"));
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if(check.isChecked()) saveForms();
}
}