package com.xplora.xpsettings.SKKeyboard;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.util.AttributeSet;

import com.xplora.xpsettings.R;

import java.util.List;

public class SKKeyboardView extends KeyboardView {

    public SKKeyboardView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SKKeyboardView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public SKKeyboardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (getKeyboard() == null)
            return;
        List<Keyboard.Key> keys = getKeyboard().getKeys();
        for (Keyboard.Key key : keys) {
            if (key.codes[0] == -200000) {
                @SuppressLint("UseCompatLoadingForDrawables")
                Drawable dr = (Drawable) getContext().getResources().getDrawable(R.color.black);
                dr.setBounds(key.x, key.y, key.x + key.width, key.y + key.height);
                dr.draw(canvas);
            }
        }
    }
}
