package info.knacki.pass.ui.alertPrompt.views;

import android.content.Context;
import android.support.v7.widget.AppCompatEditText;
import android.text.Editable;
import android.view.LayoutInflater;
import android.widget.ScrollView;

import info.knacki.pass.R;

public class UsernameAndEmail extends ScrollView {
    private final AppCompatEditText usernameEdit;
    private final AppCompatEditText emailEdit;

    public UsernameAndEmail(Context context) {
        super(context);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.username_and_email, this);
        usernameEdit = findViewById(R.id.username);
        emailEdit = findViewById(R.id.email);
    }

    public String GetUser() {
        Editable text = usernameEdit.getText();
        return null == text ? "" : text.toString();
    }

    public String GetEmail() {
        Editable text = emailEdit.getText();
        return null == text ? "" : text.toString();
    }

    public String GetUserAndEmail() {
        return GetUser() +" <" +GetEmail() +">";
    }
}
