// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
//     loadTranslationData(context, false);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_PACKAGE_ALLOW = "package_allow";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     try {
//         return String.valueOf(pref.getInt(key, 0));
//     } catch (Exception e) {
//         // Nothing to do
//     }
//     return pref.getString(key, "");
// }


import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import java.lang.ref.WeakReference;
import java.util.Locale;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaConstants.PREF_PACKAGE_ALLOW;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
            Log.e("KCA", "lang: " + newConfig.locale.getLanguage() + " " + newConfig.locale.getCountry());
            KcaApplication.defaultLocale = newConfig.locale;
        }
        if(getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE).startsWith("default")) {
            LocaleUtils.setLocale(Locale.getDefault());
        } else {
            String[] pref = getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE).split("-");
            LocaleUtils.setLocale(new Locale(pref[0], pref[1]));
        }
        loadTranslationData(getApplicationContext());
        super.onConfigurationChanged(newConfig);
    }

    private static class UpdateHandler extends Handler {
        private final WeakReference<PackageFilterActivity> mActivity;

        UpdateHandler(PackageFilterActivity activity) {
            mActivity = new WeakReference<PackageFilterActivity>(activity);
        }

        @Override
        public void handleMessage(Message msg) {
            PackageFilterActivity activity = mActivity.get();
            if (activity != null) {
                activity.setAllowCount();
            }
        }
    }

    public void setAllowCount() {
// Path: app/src/main/java/com/antest1/kcanotify/KcaApiData.java
// public static void loadTranslationData(Context context) {
//     loadTranslationData(context, false);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_KCA_LANGUAGE = "kca_language";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_PACKAGE_ALLOW = "package_allow";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringPreferences(Context ctx, String key) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     try {
//         return String.valueOf(pref.getInt(key, 0));
//     } catch (Exception e) {
//         // Nothing to do
//     }
//     return pref.getString(key, "");
// }


// Path: app/src/main/java/com/antest1/kcanotify/PackageFilterActivity.java
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import java.lang.ref.WeakReference;
import java.util.Locale;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaConstants.PREF_PACKAGE_ALLOW;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;

            Log.e("KCA", "lang: " + newConfig.locale.getLanguage() + " " + newConfig.locale.getCountry());
            KcaApplication.defaultLocale = newConfig.locale;
        }
        if(getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE).startsWith("default")) {
            LocaleUtils.setLocale(Locale.getDefault());
        } else {
            String[] pref = getStringPreferences(getApplicationContext(), PREF_KCA_LANGUAGE).split("-");
            LocaleUtils.setLocale(new Locale(pref[0], pref[1]));
        }
        loadTranslationData(getApplicationContext());
        super.onConfigurationChanged(newConfig);
    }

    private static class UpdateHandler extends Handler {
        private final WeakReference<PackageFilterActivity> mActivity;

        UpdateHandler(PackageFilterActivity activity) {
            mActivity = new WeakReference<PackageFilterActivity>(activity);
        }

        @Override
        public void handleMessage(Message msg) {
            PackageFilterActivity activity = mActivity.get();
            if (activity != null) {
                activity.setAllowCount();
            }
        }
    }

    public void setAllowCount() {
        JsonArray data = new JsonParser().parse(getStringPreferences(getApplicationContext(), PREF_PACKAGE_ALLOW)).getAsJsonArray();