// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_QUESTVIEW = "Q";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_QUESTVIEW = "OpenQuestView";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Context getContextWithLocale(Context ac, Context bc) {
//     Locale locale;
//     String[] pref_locale = getStringPreferences(ac, PREF_KCA_LANGUAGE).split("-");
//     if (pref_locale[0].toLowerCase().equals("default") || pref_locale.length < 2) {
//         locale = Locale.getDefault();
//     } else {
//         locale = new Locale(pref_locale[0], pref_locale[1]);
//     }
//     Configuration configuration = new Configuration(ac.getResources().getConfiguration());
//     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//         configuration.setLocale(locale);
//         return bc.createConfigurationContext(configuration);
//     } else {
//         configuration.locale = locale;
//         DisplayMetrics metrics = new DisplayMetrics();
//         bc.getResources().updateConfiguration(configuration, bc.getResources().getDisplayMetrics());
//         return bc;
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
//     try {
//         Field idField = c.getDeclaredField(resourceName);
//         return idField.getInt(idField);
//     } catch (Exception e) {
//         throw new RuntimeException("No resource ID found for: "
//                 + resourceName + " / " + c, e);
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
//     StringWriter errors = new StringWriter();
//     ex.printStackTrace(new PrintWriter(errors));
//     return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
//     int windowLayoutType = -1;
//     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//         windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
//     } else {
//         windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
//     }
//     return windowLayoutType;
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
//     Bundle params = new Bundle();
//     FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
//     if (value != null) {
//         for (String key: value.keySet()) {
//             params.putString(key, value.get(key).getAsString());
//         }
//     }
//     mFirebaseAnalytics.logEvent(event, params);
// }


import android.annotation.SuppressLint;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.Calendar;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_QUESTVIEW;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_QUESTVIEW;
import static com.antest1.kcanotify.KcaUtils.getContextWithLocale;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;
            }
            Log.e("KCA", currentQuestList.toString());
            if (checkValid) {
                questTracker.clearInvalidQuestTrack();
                helper.checkValidQuest(currentQuestList, tab_id);
                int filter = -1;
                if (filter_id > -1) filter = filterCategoryList[filter_id];
                setQuestView(currentQuestList, true, filter);
            }
            questDescPopupView.setVisibility(View.GONE);
            return 0;
        } catch (Exception e) {
            e.printStackTrace();
            sendReport(e, 0);
            return 1;
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
                && !Settings.canDrawOverlays(getApplicationContext())) {
            // Can not draw overlays: pass
            stopSelf();
        } else {
            try {
                active = true;
                helper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
                questTracker = new KcaQuestTracker(getApplicationContext(), null, KCANOTIFY_QTDB_VERSION);
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String ERROR_TYPE_QUESTVIEW = "Q";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_DB_VERSION = 5;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final int KCANOTIFY_QTDB_VERSION = 3;
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUseStatConstant.java
// public final static String OPEN_QUESTVIEW = "OpenQuestView";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Context getContextWithLocale(Context ac, Context bc) {
//     Locale locale;
//     String[] pref_locale = getStringPreferences(ac, PREF_KCA_LANGUAGE).split("-");
//     if (pref_locale[0].toLowerCase().equals("default") || pref_locale.length < 2) {
//         locale = Locale.getDefault();
//     } else {
//         locale = new Locale(pref_locale[0], pref_locale[1]);
//     }
//     Configuration configuration = new Configuration(ac.getResources().getConfiguration());
//     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
//         configuration.setLocale(locale);
//         return bc.createConfigurationContext(configuration);
//     } else {
//         configuration.locale = locale;
//         DisplayMetrics metrics = new DisplayMetrics();
//         bc.getResources().updateConfiguration(configuration, bc.getResources().getDisplayMetrics());
//         return bc;
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getId(String resourceName, Class<?> c) {
//     try {
//         Field idField = c.getDeclaredField(resourceName);
//         return idField.getInt(idField);
//     } catch (Exception e) {
//         throw new RuntimeException("No resource ID found for: "
//                 + resourceName + " / " + c, e);
//     }
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
//     StringWriter errors = new StringWriter();
//     ex.printStackTrace(new PrintWriter(errors));
//     return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static int getWindowLayoutType() {
//     int windowLayoutType = -1;
//     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//         windowLayoutType = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
//     } else {
//         windowLayoutType = WindowManager.LayoutParams.TYPE_PHONE;
//     }
//     return windowLayoutType;
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static void sendUserAnalytics(Context context, String event, JsonObject value) {
//     Bundle params = new Bundle();
//     FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
//     if (value != null) {
//         for (String key: value.keySet()) {
//             params.putString(key, value.get(key).getAsString());
//         }
//     }
//     mFirebaseAnalytics.logEvent(event, params);
// }


// Path: app/src/main/java/com/antest1/kcanotify/KcaQuestViewService.java
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import android.os.IBinder;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.Calendar;
import static com.antest1.kcanotify.KcaConstants.ERROR_TYPE_QUESTVIEW;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_QTDB_VERSION;
import static com.antest1.kcanotify.KcaUseStatConstant.OPEN_QUESTVIEW;
import static com.antest1.kcanotify.KcaUtils.getContextWithLocale;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
import static com.antest1.kcanotify.KcaUtils.sendUserAnalytics;

            }
            Log.e("KCA", currentQuestList.toString());
            if (checkValid) {
                questTracker.clearInvalidQuestTrack();
                helper.checkValidQuest(currentQuestList, tab_id);
                int filter = -1;
                if (filter_id > -1) filter = filterCategoryList[filter_id];
                setQuestView(currentQuestList, true, filter);
            }
            questDescPopupView.setVisibility(View.GONE);
            return 0;
        } catch (Exception e) {
            e.printStackTrace();
            sendReport(e, 0);
            return 1;
        }
    }

    @Override
    public void onCreate() {
        super.onCreate();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
                && !Settings.canDrawOverlays(getApplicationContext())) {
            // Can not draw overlays: pass
            stopSelf();
        } else {
            try {
                active = true;
                helper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
                questTracker = new KcaQuestTracker(getApplicationContext(), null, KCANOTIFY_QTDB_VERSION);
                contextWithLocale = getContextWithLocale(getApplicationContext(), getBaseContext());