package com.example.tyre.maintenance.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.KeyEvent;

public class MyKeyReceiver extends BroadcastReceiver {
    private MyKeyInfoCall myKeyInfoCall;

    public MyKeyReceiver() {
    }

    public MyKeyReceiver(MyKeyInfoCall myKeyInfoCall) {
        this.myKeyInfoCall = myKeyInfoCall;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e("TAG", "onReceive:" + intent.getAction());
        var keydown = intent.getBooleanExtra("keydown", false);
        var keyCode = intent.getIntExtra("keyCode", 0);
        Log.e("TAG", "onReceive:" + keydown + " --" + keyCode);
        if (keydown && (keyCode == 135 || keyCode ==136)) {
            myKeyInfoCall.onkeyDown();
        }

    }
}