// Path: src/org/kde/kdeconnect/Helpers/TrustedNetworkHelper.java
// public class TrustedNetworkHelper {
// 
//     private static final String KEY_CUSTOM_TRUSTED_NETWORKS = "trusted_network_preference";
//     private static final String KEY_CUSTOM_TRUST_ALL_NETWORKS = "trust_all_network_preference";
//     private static final String NETWORK_SSID_DELIMITER = "#_#";
//     private static final String NOT_AVAILABLE_SSID_RESULT = "<unknown ssid>";
// 
// 
//     private final Context context;
// 
//     public TrustedNetworkHelper(Context context) {
//         this.context = context;
//     }
// 
//     public String[] read() {
//         String serializeTrustedNetwork = PreferenceManager.getDefaultSharedPreferences(context).getString(
//                 KEY_CUSTOM_TRUSTED_NETWORKS, "");
//         if (serializeTrustedNetwork.isEmpty())
//             return ArrayUtils.EMPTY_STRING_ARRAY;
//         return serializeTrustedNetwork.split(NETWORK_SSID_DELIMITER);
//     }
// 
//     public void update(List<String> trustedNetworks) {
//         String serialized = TextUtils.join(NETWORK_SSID_DELIMITER, trustedNetworks);
//         PreferenceManager.getDefaultSharedPreferences(context).edit().putString(
//                 KEY_CUSTOM_TRUSTED_NETWORKS, serialized).apply();
//     }
// 
//     public boolean allAllowed() {
//         if (!hasPermissions()) {
//             return true;
//         }
//         return PreferenceManager
//                 .getDefaultSharedPreferences(context)
//                 .getBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, Boolean.TRUE);
//     }
// 
//     public void allAllowed(boolean isChecked) {
//         PreferenceManager
//                 .getDefaultSharedPreferences(context)
//                 .edit()
//                 .putBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, isChecked)
//                 .apply();
//     }
// 
//     public boolean hasPermissions() {
//         int result = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION);
//         return (result == PackageManager.PERMISSION_GRANTED);
//     }
// 
//     public String currentSSID() {
//         WifiManager wifiManager = ContextCompat.getSystemService(context.getApplicationContext(),
//                 WifiManager.class);
//         if (wifiManager == null) return "";
//         WifiInfo wifiInfo = wifiManager.getConnectionInfo();
//         if (wifiInfo.getSupplicantState() != SupplicantState.COMPLETED) {
//             return "";
//         }
//         String ssid = wifiInfo.getSSID();
//         if (ssid.equalsIgnoreCase(NOT_AVAILABLE_SSID_RESULT)){
//             Log.d("TrustedNetworkHelper", "Current SSID is unknown");
//             return "";
//         }
//         return ssid;
//     }
// 
//     public static boolean isTrustedNetwork(Context context) {
//         TrustedNetworkHelper trustedNetworkHelper = new TrustedNetworkHelper(context);
//         if (trustedNetworkHelper.allAllowed()){
//             return true;
//         }
//         return ArrayUtils.contains(trustedNetworkHelper.read(), trustedNetworkHelper.currentSSID());
//     }
// }


import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ListView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.android.internal.util.ArrayUtils;
import org.kde.kdeconnect.Helpers.TrustedNetworkHelper;
import org.kde.kdeconnect_tp.R;
import org.kde.kdeconnect_tp.databinding.TrustedNetworkListBinding;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
package org.kde.kdeconnect.UserInterface;






public class TrustedNetworksActivity extends AppCompatActivity {
    private TrustedNetworkListBinding binding;
    private List<String> trustedNetworks;

    private ListView trustedNetworksView;
    private CheckBox allowAllCheckBox;
// Path: src/org/kde/kdeconnect/Helpers/TrustedNetworkHelper.java
// public class TrustedNetworkHelper {
// 
//     private static final String KEY_CUSTOM_TRUSTED_NETWORKS = "trusted_network_preference";
//     private static final String KEY_CUSTOM_TRUST_ALL_NETWORKS = "trust_all_network_preference";
//     private static final String NETWORK_SSID_DELIMITER = "#_#";
//     private static final String NOT_AVAILABLE_SSID_RESULT = "<unknown ssid>";
// 
// 
//     private final Context context;
// 
//     public TrustedNetworkHelper(Context context) {
//         this.context = context;
//     }
// 
//     public String[] read() {
//         String serializeTrustedNetwork = PreferenceManager.getDefaultSharedPreferences(context).getString(
//                 KEY_CUSTOM_TRUSTED_NETWORKS, "");
//         if (serializeTrustedNetwork.isEmpty())
//             return ArrayUtils.EMPTY_STRING_ARRAY;
//         return serializeTrustedNetwork.split(NETWORK_SSID_DELIMITER);
//     }
// 
//     public void update(List<String> trustedNetworks) {
//         String serialized = TextUtils.join(NETWORK_SSID_DELIMITER, trustedNetworks);
//         PreferenceManager.getDefaultSharedPreferences(context).edit().putString(
//                 KEY_CUSTOM_TRUSTED_NETWORKS, serialized).apply();
//     }
// 
//     public boolean allAllowed() {
//         if (!hasPermissions()) {
//             return true;
//         }
//         return PreferenceManager
//                 .getDefaultSharedPreferences(context)
//                 .getBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, Boolean.TRUE);
//     }
// 
//     public void allAllowed(boolean isChecked) {
//         PreferenceManager
//                 .getDefaultSharedPreferences(context)
//                 .edit()
//                 .putBoolean(KEY_CUSTOM_TRUST_ALL_NETWORKS, isChecked)
//                 .apply();
//     }
// 
//     public boolean hasPermissions() {
//         int result = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION);
//         return (result == PackageManager.PERMISSION_GRANTED);
//     }
// 
//     public String currentSSID() {
//         WifiManager wifiManager = ContextCompat.getSystemService(context.getApplicationContext(),
//                 WifiManager.class);
//         if (wifiManager == null) return "";
//         WifiInfo wifiInfo = wifiManager.getConnectionInfo();
//         if (wifiInfo.getSupplicantState() != SupplicantState.COMPLETED) {
//             return "";
//         }
//         String ssid = wifiInfo.getSSID();
//         if (ssid.equalsIgnoreCase(NOT_AVAILABLE_SSID_RESULT)){
//             Log.d("TrustedNetworkHelper", "Current SSID is unknown");
//             return "";
//         }
//         return ssid;
//     }
// 
//     public static boolean isTrustedNetwork(Context context) {
//         TrustedNetworkHelper trustedNetworkHelper = new TrustedNetworkHelper(context);
//         if (trustedNetworkHelper.allAllowed()){
//             return true;
//         }
//         return ArrayUtils.contains(trustedNetworkHelper.read(), trustedNetworkHelper.currentSSID());
//     }
// }


// Path: src/org/kde/kdeconnect/UserInterface/TrustedNetworksActivity.java
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ListView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.android.internal.util.ArrayUtils;
import org.kde.kdeconnect.Helpers.TrustedNetworkHelper;
import org.kde.kdeconnect_tp.R;
import org.kde.kdeconnect_tp.databinding.TrustedNetworkListBinding;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

package org.kde.kdeconnect.UserInterface;






public class TrustedNetworksActivity extends AppCompatActivity {
    private TrustedNetworkListBinding binding;
    private List<String> trustedNetworks;

    private ListView trustedNetworksView;
    private CheckBox allowAllCheckBox;
    private TrustedNetworkHelper trustedNetworkHelper;