// Path: app/src/main/java/eu/se_bastiaan/popcorntimeremote/utils/PixelUtils.java
// public final class PixelUtils {
// 
//     private PixelUtils() throws InstantiationException {
//         throw new InstantiationException("This class is not created for instantiation");
//     }
// 
//     public static int getPixelsFromDp(Context context, Integer dp) {
//         Resources r = context.getResources();
//         return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
//     }
// 
//     public static int getPixelsFromSp(Context context, Integer sp) {
//         Resources r = context.getResources();
//         return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, r.getDisplayMetrics());
//     }
// 
//     public static Drawable changeDrawableColor(Context context, Integer resId, Integer color) {
//         Drawable drawable = context.getResources().getDrawable(resId).mutate();
//         drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
//         return drawable;
//     }
// 
//     public static Integer getStatusBarHeight(Context context) {
//         int statusBarHeight = 0;
//         int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
//         if (resourceId > 0) {
//             statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
//         }
//         return statusBarHeight;
//     }
// 
// }


import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import eu.se_bastiaan.popcorntimeremote.utils.PixelUtils;
    private final Runnable mCallbackRunnable = new Runnable() {
        @Override
        public void run() {
            mCalledOnce = true;
            mOnJoystickMoveListener.onValueChanged(getAngle(), getPower(), getDirection());
            mHandler.postDelayed(this, 500);
        }
    };

    public JoystickView(Context context) {
        super(context);
        initJoystickView(context);
    }

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

    public JoystickView(Context context, AttributeSet attrs, int defaultStyle) {
        super(context, attrs, defaultStyle);
        initJoystickView(context);
    }

    protected void initJoystickView(Context context) {
        mContext = context;

        mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mCirclePaint.setColor(Color.parseColor("#444C53"));
        mCirclePaint.setStyle(Paint.Style.STROKE);
// Path: app/src/main/java/eu/se_bastiaan/popcorntimeremote/utils/PixelUtils.java
// public final class PixelUtils {
// 
//     private PixelUtils() throws InstantiationException {
//         throw new InstantiationException("This class is not created for instantiation");
//     }
// 
//     public static int getPixelsFromDp(Context context, Integer dp) {
//         Resources r = context.getResources();
//         return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
//     }
// 
//     public static int getPixelsFromSp(Context context, Integer sp) {
//         Resources r = context.getResources();
//         return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, r.getDisplayMetrics());
//     }
// 
//     public static Drawable changeDrawableColor(Context context, Integer resId, Integer color) {
//         Drawable drawable = context.getResources().getDrawable(resId).mutate();
//         drawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
//         return drawable;
//     }
// 
//     public static Integer getStatusBarHeight(Context context) {
//         int statusBarHeight = 0;
//         int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
//         if (resourceId > 0) {
//             statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
//         }
//         return statusBarHeight;
//     }
// 
// }


// Path: app/src/main/java/eu/se_bastiaan/popcorntimeremote/widget/JoystickView.java
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import eu.se_bastiaan.popcorntimeremote.utils.PixelUtils;

    private final Runnable mCallbackRunnable = new Runnable() {
        @Override
        public void run() {
            mCalledOnce = true;
            mOnJoystickMoveListener.onValueChanged(getAngle(), getPower(), getDirection());
            mHandler.postDelayed(this, 500);
        }
    };

    public JoystickView(Context context) {
        super(context);
        initJoystickView(context);
    }

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

    public JoystickView(Context context, AttributeSet attrs, int defaultStyle) {
        super(context, attrs, defaultStyle);
        initJoystickView(context);
    }

    protected void initJoystickView(Context context) {
        mContext = context;

        mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mCirclePaint.setColor(Color.parseColor("#444C53"));
        mCirclePaint.setStyle(Paint.Style.STROKE);
        mCirclePaint.setStrokeWidth(PixelUtils.getPixelsFromDp(mContext, 2));