// Path: app/src/main/java/be/ppareit/android/BroadcastReceiverUtils.java
// public static BroadcastReceiver createBroadcastReceiver(Receiver receiver) {
//     return new BroadcastReceiver() {
//         @Override
//         public void onReceive(Context context, Intent intent) {
//             receiver.onReceive(context, intent);
//         }
//     };
// }


import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.IBinder;
import androidx.core.app.NotificationCompat;
import android.widget.Toast;
import net.vrallev.android.cat.Cat;
import static androidx.core.app.NotificationCompat.PRIORITY_MIN;
import static androidx.core.content.ContextCompat.startForegroundService;
import static be.ppareit.android.BroadcastReceiverUtils.createBroadcastReceiver;
                    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
                    .setCategory(NotificationCompat.CATEGORY_SERVICE)
                    .setPriority(PRIORITY_MIN)
                    .setShowWhen(false)
                    .setChannelId(channelId)
                    .build();

            startForeground(AutoConnect.NOTIFICATION_ID, notification);

            IntentFilter wifiStateChangedFilter = new IntentFilter();
            wifiStateChangedFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
            wifiStateChangedFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
            registerReceiver(mWifiStateChangedReceiver, wifiStateChangedFilter);

            return START_STICKY;
        }

        @Override
        public void onDestroy() {
            super.onDestroy();
            stopForeground(true);

            try {
                unregisterReceiver(mWifiStateChangedReceiver);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        }
    }

// Path: app/src/main/java/be/ppareit/android/BroadcastReceiverUtils.java
// public static BroadcastReceiver createBroadcastReceiver(Receiver receiver) {
//     return new BroadcastReceiver() {
//         @Override
//         public void onReceive(Context context, Intent intent) {
//             receiver.onReceive(context, intent);
//         }
//     };
// }


// Path: app/src/main/java/be/ppareit/swiftp/AutoConnect.java
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.IBinder;
import androidx.core.app.NotificationCompat;
import android.widget.Toast;
import net.vrallev.android.cat.Cat;
import static androidx.core.app.NotificationCompat.PRIORITY_MIN;
import static androidx.core.content.ContextCompat.startForegroundService;
import static be.ppareit.android.BroadcastReceiverUtils.createBroadcastReceiver;

                    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
                    .setCategory(NotificationCompat.CATEGORY_SERVICE)
                    .setPriority(PRIORITY_MIN)
                    .setShowWhen(false)
                    .setChannelId(channelId)
                    .build();

            startForeground(AutoConnect.NOTIFICATION_ID, notification);

            IntentFilter wifiStateChangedFilter = new IntentFilter();
            wifiStateChangedFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
            wifiStateChangedFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
            registerReceiver(mWifiStateChangedReceiver, wifiStateChangedFilter);

            return START_STICKY;
        }

        @Override
        public void onDestroy() {
            super.onDestroy();
            stopForeground(true);

            try {
                unregisterReceiver(mWifiStateChangedReceiver);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
        }
    }

    private static BroadcastReceiver mWifiStateChangedReceiver = createBroadcastReceiver(