// Path: src/org/kde/kdeconnect/Helpers/NotificationHelper.java
// public class NotificationHelper {
// 
//     public static class Channels {
//         public final static String PERSISTENT = "persistent";
//         public final static String DEFAULT = "default";
//         public final static String MEDIA_CONTROL = "media_control";
//         public final static String FILETRANSFER = "filetransfer";
//         public final static String SMS_MMS = "sms_mms";
//         public final static String RECEIVENOTIFICATION = "receive";
//         public final static String HIGHPRIORITY = "highpriority";
//     }
// 
//     public static void notifyCompat(NotificationManager notificationManager, int notificationId, Notification notification) {
//         try {
//             notificationManager.notify(notificationId, notification);
//         } catch (Exception e) {
//             //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
//             //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
//         }
//     }
// 
//     public static void notifyCompat(NotificationManager notificationManager, String tag, int notificationId, Notification notification) {
//         try {
//             notificationManager.notify(tag, notificationId, notification);
//         } catch (Exception e) {
//             //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
//             //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
//         }
//     }
// 
//     public static void initializeChannels(Context context) {
// 
//         if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
//             return;
//         }
// 
//         NotificationManager manager = ContextCompat.getSystemService(context, NotificationManager.class);
// 
//         NotificationChannel persistentChannel = new NotificationChannel(
//                 Channels.PERSISTENT,
//                 context.getString(R.string.notification_channel_persistent),
//                 NotificationManager.IMPORTANCE_MIN);
// 
//         manager.createNotificationChannel(persistentChannel);
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.DEFAULT,
//                 context.getString(R.string.notification_channel_default),
//                 NotificationManager.IMPORTANCE_DEFAULT)
//         );
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.MEDIA_CONTROL,
//                 context.getString(R.string.notification_channel_media_control),
//                 NotificationManager.IMPORTANCE_LOW)
//         );
// 
//         NotificationChannel fileTransfer = new NotificationChannel(
//                 Channels.FILETRANSFER,
//                 context.getString(R.string.notification_channel_filetransfer),
//                 NotificationManager.IMPORTANCE_LOW);
// 
//         fileTransfer.enableVibration(false);
// 
//         manager.createNotificationChannel(fileTransfer);
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.RECEIVENOTIFICATION,
//                 context.getString(R.string.notification_channel_receivenotification),
//                 NotificationManager.IMPORTANCE_DEFAULT)
//         );
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.SMS_MMS,
//                 context.getString(R.string.notification_channel_sms_mms),
//                 NotificationManager.IMPORTANCE_DEFAULT)
//         );
// 
//         NotificationChannel highPriority = new NotificationChannel(Channels.HIGHPRIORITY, context.getString(R.string.notification_channel_high_priority), NotificationManager.IMPORTANCE_HIGH);
//         manager.createNotificationChannel(highPriority);
//     }
// 
// 
//     public static void setPersistentNotificationEnabled(Context context, boolean enabled) {
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         prefs.edit().putBoolean("persistentNotification", enabled).apply();
//     }
// 
//     public static boolean isPersistentNotificationEnabled(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//             return true;
//         }
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         return prefs.getBoolean("persistentNotification", false);
//     }
// 
// }


import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import org.apache.commons.lang3.ArrayUtils;
import org.kde.kdeconnect.Helpers.DeviceHelper;
import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.MyApplication;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.io.IOException;
                showBroadcastNotification();
            } else {
                showActivityNotification();
            }
        }

        return true;
    }

    @RequiresApi(16)
    private void showBroadcastNotification() {
        Intent intent = new Intent(context, FindMyPhoneReceiver.class);
        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.setAction(FindMyPhoneReceiver.ACTION_FOUND_IT);
        intent.putExtra(FindMyPhoneReceiver.EXTRA_DEVICE_ID, device.getDeviceId());

        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        createNotification(pendingIntent);
    }

    private void showActivityNotification() {
        Intent intent = new Intent(context, FindMyPhoneActivity.class);
        intent.putExtra(FindMyPhoneActivity.EXTRA_DEVICE_ID, device.getDeviceId());

        PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        createNotification(pi);
    }

    private void createNotification(PendingIntent pendingIntent) {
// Path: src/org/kde/kdeconnect/Helpers/NotificationHelper.java
// public class NotificationHelper {
// 
//     public static class Channels {
//         public final static String PERSISTENT = "persistent";
//         public final static String DEFAULT = "default";
//         public final static String MEDIA_CONTROL = "media_control";
//         public final static String FILETRANSFER = "filetransfer";
//         public final static String SMS_MMS = "sms_mms";
//         public final static String RECEIVENOTIFICATION = "receive";
//         public final static String HIGHPRIORITY = "highpriority";
//     }
// 
//     public static void notifyCompat(NotificationManager notificationManager, int notificationId, Notification notification) {
//         try {
//             notificationManager.notify(notificationId, notification);
//         } catch (Exception e) {
//             //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
//             //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
//         }
//     }
// 
//     public static void notifyCompat(NotificationManager notificationManager, String tag, int notificationId, Notification notification) {
//         try {
//             notificationManager.notify(tag, notificationId, notification);
//         } catch (Exception e) {
//             //4.1 will throw an exception about not having the VIBRATE permission, ignore it.
//             //https://android.googlesource.com/platform/frameworks/base/+/android-4.2.1_r1.2%5E%5E!/
//         }
//     }
// 
//     public static void initializeChannels(Context context) {
// 
//         if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
//             return;
//         }
// 
//         NotificationManager manager = ContextCompat.getSystemService(context, NotificationManager.class);
// 
//         NotificationChannel persistentChannel = new NotificationChannel(
//                 Channels.PERSISTENT,
//                 context.getString(R.string.notification_channel_persistent),
//                 NotificationManager.IMPORTANCE_MIN);
// 
//         manager.createNotificationChannel(persistentChannel);
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.DEFAULT,
//                 context.getString(R.string.notification_channel_default),
//                 NotificationManager.IMPORTANCE_DEFAULT)
//         );
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.MEDIA_CONTROL,
//                 context.getString(R.string.notification_channel_media_control),
//                 NotificationManager.IMPORTANCE_LOW)
//         );
// 
//         NotificationChannel fileTransfer = new NotificationChannel(
//                 Channels.FILETRANSFER,
//                 context.getString(R.string.notification_channel_filetransfer),
//                 NotificationManager.IMPORTANCE_LOW);
// 
//         fileTransfer.enableVibration(false);
// 
//         manager.createNotificationChannel(fileTransfer);
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.RECEIVENOTIFICATION,
//                 context.getString(R.string.notification_channel_receivenotification),
//                 NotificationManager.IMPORTANCE_DEFAULT)
//         );
// 
//         manager.createNotificationChannel(new NotificationChannel(
//                 Channels.SMS_MMS,
//                 context.getString(R.string.notification_channel_sms_mms),
//                 NotificationManager.IMPORTANCE_DEFAULT)
//         );
// 
//         NotificationChannel highPriority = new NotificationChannel(Channels.HIGHPRIORITY, context.getString(R.string.notification_channel_high_priority), NotificationManager.IMPORTANCE_HIGH);
//         manager.createNotificationChannel(highPriority);
//     }
// 
// 
//     public static void setPersistentNotificationEnabled(Context context, boolean enabled) {
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         prefs.edit().putBoolean("persistentNotification", enabled).apply();
//     }
// 
//     public static boolean isPersistentNotificationEnabled(Context context) {
//         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//             return true;
//         }
//         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//         return prefs.getBoolean("persistentNotification", false);
//     }
// 
// }


// Path: src/org/kde/kdeconnect/Plugins/FindMyPhonePlugin/FindMyPhonePlugin.java
import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import org.apache.commons.lang3.ArrayUtils;
import org.kde.kdeconnect.Helpers.DeviceHelper;
import org.kde.kdeconnect.Helpers.NotificationHelper;
import org.kde.kdeconnect.MyApplication;
import org.kde.kdeconnect.NetworkPacket;
import org.kde.kdeconnect.Plugins.Plugin;
import org.kde.kdeconnect.Plugins.PluginFactory;
import org.kde.kdeconnect.UserInterface.PluginSettingsFragment;
import org.kde.kdeconnect_tp.R;
import java.io.IOException;

                showBroadcastNotification();
            } else {
                showActivityNotification();
            }
        }

        return true;
    }

    @RequiresApi(16)
    private void showBroadcastNotification() {
        Intent intent = new Intent(context, FindMyPhoneReceiver.class);
        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.setAction(FindMyPhoneReceiver.ACTION_FOUND_IT);
        intent.putExtra(FindMyPhoneReceiver.EXTRA_DEVICE_ID, device.getDeviceId());

        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        createNotification(pendingIntent);
    }

    private void showActivityNotification() {
        Intent intent = new Intent(context, FindMyPhoneActivity.class);
        intent.putExtra(FindMyPhoneActivity.EXTRA_DEVICE_ID, device.getDeviceId());

        PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        createNotification(pi);
    }

    private void createNotification(PendingIntent pendingIntent) {
        NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NotificationHelper.Channels.HIGHPRIORITY);