// 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 String PREF_AKASHI_STARLIST = "akashi_starlist";
// 
// 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 Calendar getJapanCalendarInstance() {
//     Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo"), Locale.JAPAN);
//     c.setFirstDayOfWeek(Calendar.MONDAY);
//     return c;
// }
// 
// 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 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 showDataLoadErrorToast(Context ac, Context bc, String text) {
//     if (getBooleanPreferences(ac, PREF_DATALOAD_ERROR_FLAG)) {
//         KcaCustomToast customToast = new KcaCustomToast(ac);
//         showCustomToast(ac, bc, customToast, text, Toast.LENGTH_LONG, ContextCompat.getColor(ac, R.color.colorHeavyDmgStatePanel));
//     }
// }


import android.annotation.SuppressLint;
import android.app.Service;
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 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.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.TimeZone;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getContextWithLocale;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getJapanCalendarInstance;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
import static com.antest1.kcanotify.KcaUtils.showDataLoadErrorToast;
                    WindowManager.LayoutParams.WRAP_CONTENT,
                    getWindowLayoutType(),
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            mParams.gravity = Gravity.CENTER;

            mManager = (WindowManager) getSystemService(WINDOW_SERVICE);

            Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);
            displayWidth = size.x;

        } catch (Exception e) {
            active = false;
            error_flag = true;
            //sendReport(e, 1);
            stopSelf();
        }
    }

    @Override
    public void onDestroy() {
        active = false;
        mView.setVisibility(View.GONE);
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
// 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 String PREF_AKASHI_STARLIST = "akashi_starlist";
// 
// 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 Calendar getJapanCalendarInstance() {
//     Calendar c = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo"), Locale.JAPAN);
//     c.setFirstDayOfWeek(Calendar.MONDAY);
//     return c;
// }
// 
// 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 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 showDataLoadErrorToast(Context ac, Context bc, String text) {
//     if (getBooleanPreferences(ac, PREF_DATALOAD_ERROR_FLAG)) {
//         KcaCustomToast customToast = new KcaCustomToast(ac);
//         showCustomToast(ac, bc, customToast, text, Toast.LENGTH_LONG, ContextCompat.getColor(ac, R.color.colorHeavyDmgStatePanel));
//     }
// }


// Path: app/src/main/java/com/antest1/kcanotify/KcaAkashiViewService.java
import android.annotation.SuppressLint;
import android.app.Service;
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 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.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.TimeZone;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.PREF_AKASHI_STARLIST;
import static com.antest1.kcanotify.KcaUtils.getContextWithLocale;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getJapanCalendarInstance;
import static com.antest1.kcanotify.KcaUtils.getStringPreferences;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
import static com.antest1.kcanotify.KcaUtils.showDataLoadErrorToast;

                    WindowManager.LayoutParams.WRAP_CONTENT,
                    getWindowLayoutType(),
                    WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                    PixelFormat.TRANSLUCENT);
            mParams.gravity = Gravity.CENTER;

            mManager = (WindowManager) getSystemService(WINDOW_SERVICE);

            Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
            Point size = new Point();
            display.getSize(size);
            displayWidth = size.x;

        } catch (Exception e) {
            active = false;
            error_flag = true;
            //sendReport(e, 1);
            stopSelf();
        }
    }

    @Override
    public void onDestroy() {
        active = false;
        mView.setVisibility(View.GONE);
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (intent != null && intent.getAction() != null) {