// 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_SHIPINFO_SORTKEY = "shipinfo_sortkey";
// 
// 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/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     SharedPreferences.Editor editor = pref.edit();
//     if (value instanceof String) {
//         editor.putString(key, (String) value);
//     } else if (value instanceof Boolean) {
//         editor.putBoolean(key, (Boolean) value);
//     } else if (value instanceof Integer) {
//         editor.putString(key, String.valueOf(value));
//     } else {
//         editor.putString(key, value.toString());
//     }
//     editor.commit();
// }


import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import static android.widget.Toast.makeText;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaConstants.PREF_SHIPINFO_SORTKEY;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;
    }

    @Override
    public void onBackPressed() {
        setValueAndFinish();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                setValueAndFinish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Log.e("KCA", "lang: " + newConfig.getLocales().get(0).getLanguage() + " " + newConfig.getLocales().get(0).getCountry());
            KcaApplication.defaultLocale = newConfig.getLocales().get(0);
        } else {
            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 {
// 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_SHIPINFO_SORTKEY = "shipinfo_sortkey";
// 
// 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/KcaUtils.java
// public static void setPreferences(Context ctx, String key, Object value) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     SharedPreferences.Editor editor = pref.edit();
//     if (value instanceof String) {
//         editor.putString(key, (String) value);
//     } else if (value instanceof Boolean) {
//         editor.putBoolean(key, (Boolean) value);
//     } else if (value instanceof Integer) {
//         editor.putString(key, String.valueOf(value));
//     } else {
//         editor.putString(key, value.toString());
//     }
//     editor.commit();
// }


// Path: app/src/main/java/com/antest1/kcanotify/ShipInfoSortActivity.java
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.google.gson.Gson;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import static android.widget.Toast.makeText;
import static com.antest1.kcanotify.KcaApiData.loadTranslationData;
import static com.antest1.kcanotify.KcaConstants.PREF_KCA_LANGUAGE;
import static com.antest1.kcanotify.KcaConstants.PREF_SHIPINFO_SORTKEY;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.setPreferences;

    }

    @Override
    public void onBackPressed() {
        setValueAndFinish();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                setValueAndFinish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Log.e("KCA", "lang: " + newConfig.getLocales().get(0).getLanguage() + " " + newConfig.getLocales().get(0).getCountry());
            KcaApplication.defaultLocale = newConfig.getLocales().get(0);
        } else {
            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("-");