package kz.com.aman.kassa.bank.gui;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import kz.com.aman.kassa.R;
import ru.m4bank.mpos.service.transactions.data.MessageButtonData;


public class CustomKeyBoardDilalog {

    Button btnb1, btnb2, btnb3, btnb4, btnb5, btnb6, btnb7, btnb8, btnb9, btnb0,
            btncancel, btnconfirm, btnclean;
    View view;
    Dialog dialog;

    public void createDialog(Context context) {

        dialog = new Dialog(context);
        view = LayoutInflater.from(context).inflate(R.layout.layout_pin, null);
        btnb1 = (Button) view.findViewById(R.id.button1);
        btnb2 = (Button) view.findViewById(R.id.button2);
        btnb3 = (Button) view.findViewById(R.id.button3);
        btnb4 = (Button) view.findViewById(R.id.button4);
        btnb5 = (Button) view.findViewById(R.id.button5);
        btnb6 = (Button) view.findViewById(R.id.button6);
        btnb7 = (Button) view.findViewById(R.id.button7);
        btnb8 = (Button) view.findViewById(R.id.button8);
        btnb9 = (Button) view.findViewById(R.id.button9);
        btnb0 = (Button) view.findViewById(R.id.button0);
        btncancel = (Button) view.findViewById(R.id.buttoncan);
        btnconfirm = (Button) view.findViewById(R.id.buttonconfirm);
        btnclean = (Button) view.findViewById(R.id.buttonclean);
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setGravity( Gravity.BOTTOM);

        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.x = 0;
        lp.y = 0;
        view.measure(0, 0);
        lp.height = view.getMeasuredHeight();
        lp.alpha = 9f;
        dialogWindow.setAttributes(lp);
        dialog.setContentView(view);
    }

    public void show(Activity activity) {
        if (!activity.isFinishing())
            dialog.show();
    }

    public void close(Activity activity) {
        if (!activity.isFinishing() && dialog != null && dialog.isShowing())
            dialog.dismiss();
    }

    public void setText(MessageButtonData messageButtonData) {
        btnb1.setText("" + messageButtonData.getBtnb1());
        btnb2.setText("" + messageButtonData.getBtnb2());
        btnb3.setText("" + messageButtonData.getBtnb3());
        btnb4.setText("" + messageButtonData.getBtnb4());
        btnb5.setText("" + messageButtonData.getBtnb5());
        btnb6.setText("" + messageButtonData.getBtnb6());
        btnb7.setText("" + messageButtonData.getBtnb7());
        btnb8.setText("" + messageButtonData.getBtnb8());
        btnb9.setText("" + messageButtonData.getBtnb9());
        btnb0.setText("" + messageButtonData.getBtnb0());
    }

    public Button getBtnb1() {
        return btnb1;
    }

    public Button getBtnb2() {
        return btnb2;
    }

    public Button getBtnb3() {
        return btnb3;
    }

    public Button getBtnb4() {
        return btnb4;
    }

    public Button getBtnb5() {
        return btnb5;
    }

    public Button getBtnb6() {
        return btnb6;
    }

    public Button getBtnb7() {
        return btnb7;
    }

    public Button getBtnb8() {
        return btnb8;
    }

    public Button getBtnb9() {
        return btnb9;
    }

    public Button getBtnb0() {
        return btnb0;
    }

    public Button getBtncancel() {
        return btncancel;
    }

    public Button getBtnconfirm() {
        return btnconfirm;
    }

    public Button getBtnclean() {
        return btnclean;
    }
}
