AndroidAPS/app/src/main/java/info/nightscout/androidaps/AgreementActivity.java
2016-07-07 18:04:36 +02:00

45 lines
1.5 KiB
Java

package info.nightscout.androidaps;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
public class AgreementActivity extends Activity {
boolean IUnderstand;
CheckBox agreeCheckBox;
Button saveButton;
SharedPreferences prefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_agreement);
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
IUnderstand = prefs.getBoolean("I_understand", false);
setContentView(R.layout.activity_agreement);
agreeCheckBox = (CheckBox)findViewById(R.id.agreementCheckBox);
agreeCheckBox.setChecked(IUnderstand);
saveButton = (Button)findViewById(R.id.agreementSaveButton);
addListenerOnButton();
}
public void addListenerOnButton() {
saveButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
prefs.edit().putBoolean("I_understand", agreeCheckBox.isChecked()).apply();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
});
}
}