package com.android.launcher3.settings;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.android.launcher3.R;
import com.secspace.lib.common.utils.InputUtil;
import com.secspace.lib.common.utils.Prefs;
import com.secspace.lib.common.utils.ToastUtil;

public class ProtectionPwdActivity extends AppCompatActivity implements View.OnClickListener {
    EditText mEditQuestion1;
    EditText mEditQuestion2;
    EditText mEditAnswer1;
    EditText mEditAnswer2;
    Button mBtnSure;
    TextView mTvTitle;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_protection_pwd);
        initView();
    }

    private void initView() {
        mEditAnswer1=findViewById(R.id.edit_answer_1);
        mEditAnswer2=findViewById(R.id.edit_answer_2);
        mEditQuestion1=findViewById(R.id.edit_question_1);
        mEditQuestion2=findViewById(R.id.edit_question_2);
        mTvTitle=findViewById(R.id.tv_title);
        mBtnSure=findViewById(R.id.btn_sure);
        findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        mTvTitle.setText("设置密保问题");
        mBtnSure.setOnClickListener(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onClick(View v) {
        String question1 = mEditQuestion1.getText().toString();
        String question2 = mEditQuestion2.getText().toString();
        String answer1 = mEditAnswer1.getText().toString();
        String answer2 = mEditAnswer2.getText().toString();
        if (TextUtils.isEmpty(question1)||TextUtils.isEmpty(question2)||TextUtils.isEmpty(answer1)||TextUtils.isEmpty(answer2)){
            ToastUtil.showShort(this,"不能存在问题或者答案为空的情况，请重新检查输入");
            return;
        }
        Prefs.setPwdProtectionAnswer1(this,answer1);
        Prefs.setPwdProtectionQuestion1(this,question1);
        Prefs.setPwdProtectionAnswer2(this,answer2);
        Prefs.setPwdProtectionQuestion2(this,question2);
        finish();
    }
}
