package com.stm.asset.keyboard;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.stm.asset.R;

public class SafeKeyboardManager {

    private static String preKeyBoardName = "";

    public static void initKeyBoard(String preKeyBoardName){
        SafeKeyboardManager.preKeyBoardName = preKeyBoardName;
    }

    public static void registKeyboard(Activity activity, EditText safeEdit){
        LinearLayout linearLayout = new LinearLayout(activity);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.gravity = Gravity.BOTTOM;
        activity.addContentView(linearLayout,layoutParams);



        @SuppressLint("InflateParams") View view = LayoutInflater.from(activity).inflate(R.layout.layout_keyboard_containor, null);
        SafeKeyboard safeKeyboard = new SafeKeyboard(activity, linearLayout, safeEdit,
                R.layout.layout_keyboard_containor, view.findViewById(R.id.safeKeyboardLetter).getId(),
                SafeKeyboardManager.preKeyBoardName);
        safeKeyboard.setDelDrawable(activity.getResources().getDrawable(R.drawable.icon_del2));
        safeKeyboard.setLowDrawable(activity.getResources().getDrawable(R.drawable.icon_capital_default3));
        safeKeyboard.setUpDrawable(activity.getResources().getDrawable(R.drawable.icon_capital_default2));
    }
}
