public static String getItemTranslation(String jp_name) {
    String name = jp_name;
    if (currentLocaleCode.equals("jp")) {
        return jp_name;
    } else if (kcItemTranslationData.has(name)) {
        name = kcItemTranslationData.get(name).getAsString();
    }
    return name;
} public static JsonObject getUserItemStatusById(int id, String list, String kclist) {
    if (helper == null || kcGameData == null) return null;
    String data = helper.getItemValue(id);
    if (data != null) {
        JsonObject userData = new JsonParser().parse(data).getAsJsonObject();
        int kc_item_id = userData.get("api_slotitem_id").getAsInt();
        JsonObject kcData = getKcItemStatusById(kc_item_id, kclist);

        if (list.equals("all")) {
            for (Map.Entry<String, JsonElement> k : userData.entrySet()) {
                kcData.add(k.getKey(), userData.get(k.getKey()));
            }
        } else {
            String[] requestList = list.split(",");
            for (int i = 0; i < requestList.length; i++) {
                String orig_api_item = requestList[i];
                String api_item = orig_api_item;
                if (!api_item.startsWith("api_")) {
                    api_item = "api_" + api_item;
                }
                if (userData.has(api_item)) {
                    kcData.add(orig_api_item, userData.get(api_item));
                }
            }
        }
        kcData.remove("");
        return kcData;
    } else {
        return null;
    }
} public static final String DB_KEY_LABSIFNO = "key_labsinfo"; public static final int KCANOTIFY_DB_VERSION = 5; public static final int LAB_STATUS_DEFENSE = 2; public static final int LAB_STATUS_REST = 4; public static final int LAB_STATUS_RETREAT = 3; public static final int LAB_STATUS_SORTIE = 1; public static final int LAB_STATUS_STANDBY = 0; 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);
    }
} 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;
}
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
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.LinearLayout;
import android.widget.TextView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.Calendar;
import static com.antest1.kcanotify.KcaApiData.getItemTranslation;
import static com.antest1.kcanotify.KcaApiData.getUserItemStatusById;
import static com.antest1.kcanotify.KcaConstants.DB_KEY_LABSIFNO;
import static com.antest1.kcanotify.KcaConstants.KCANOTIFY_DB_VERSION;
import static com.antest1.kcanotify.KcaConstants.LAB_STATUS_DEFENSE;
import static com.antest1.kcanotify.KcaConstants.LAB_STATUS_REST;
import static com.antest1.kcanotify.KcaConstants.LAB_STATUS_RETREAT;
import static com.antest1.kcanotify.KcaConstants.LAB_STATUS_SORTIE;
import static com.antest1.kcanotify.KcaConstants.LAB_STATUS_STANDBY;
import static com.antest1.kcanotify.KcaUtils.getId;
import static com.antest1.kcanotify.KcaUtils.getWindowLayoutType;
package com.antest1.kcanotify;





public class KcaLandAirBasePopupService extends Service {
    public final static String LAB_DATA_ACTION = "lab_data_action";

    private View mView, itemView;
    ;
    private WindowManager mManager;
    private int screenWidth, screenHeight;
    private int popupWidth, popupHeight;
    private KcaDBHelper dbHelper;
    KcaDeckInfo deckInfoCalc;

    WindowManager.LayoutParams mParams, itemViewParams;

    public static int type;
    public static int clickcount;
    public static boolean active = false;

    public static boolean isActive() {
        return active;
    }

    public String getStringWithLocale(int id) {
        return KcaUtils.getStringWithLocale(getApplicationContext(), getBaseContext(), id);
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @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 {
            active = true;
            clickcount = 0;
            dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
            deckInfoCalc = new KcaDeckInfo(getApplicationContext(), getBaseContext());
            KcaApiData.setDBHelper(dbHelper);
            setDefaultGameData();

            LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            mView = mInflater.inflate(R.layout.view_labinfo_view, null);
            itemView = mInflater.inflate(R.layout.view_battleview_items, null);

            mView.setOnTouchListener(mViewTouchListener);
            mView.findViewById(R.id.view_lab_head).setOnTouchListener(mViewTouchListener);
            mView.setVisibility(View.GONE);
            ((TextView) mView.findViewById(R.id.view_lab_title)).setText(getStringWithLocale(R.string.viewmenu_airbase_title));

            mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
            popupWidth = mView.getMeasuredWidth();
            popupHeight = mView.getMeasuredHeight();

            // Button (Fairy) Settings
            mParams = new WindowManager.LayoutParams(
                    WindowManager.LayoutParams.WRAP_CONTENT,
                    WindowManager.LayoutParams.WRAP_CONTENT,
                    getWindowLayoutType(),