package com.trace.ar.drawing;

import android.app.Application;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.Log;

import com.anythink.core.api.ATSDK;
import com.anythink.core.api.NetTrafficeCallback;
import com.google.firebase.FirebaseApp;
import com.trace.ar.drawing.helper.ObjectBox;
import com.trace.ar.drawing.topon.AdManager;

public class ARApp extends Application {
    public static String Key_ViewDir = "pre_dir";
    public static String Key_ISMAIN = "ismain";
    public static String Key_Camera = "camera_data";

    public static String Key_TYPE = "key_type";
    public static String VALUE_TYPE_0 = "key_type_0_asset";
    public static String VALUE_TYPE_1 = "key_type_1_import";

    public static String TAG = "------------AR-------";


    public static ARApp app;
    //    public static String APP_KEY = "";
    public static Context context;
//    public static final String AD_BROADCAST = "on_success_action";
//    private static final String MAX_SDK = "27z51PI2aTeTbobe3ORmbnMCb97dZbW8zfHEBfRFzb2DlCRJaTQCNebHHVZ2aepZGpqkvO1J7noD4s8W2UwJew";
//    public static Boolean initSDK = false;

    public static Typeface defaultFont;

    private static final String AppKey = "ab3514befb0b4acafee6fc1d9bc5a9381";
    private static final String APPId = "h674b1f3b3d3a2";

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        context = getApplicationContext();
        AssetManager assets = getAssets();
        defaultFont = Typeface.createFromAsset(assets, "75_SemiBold.ttf");

        // 确保Firebase初始化
//        FirebaseApp.initializeApp(this);
//
//        // 输出日志以确认Firebase初始化
//        if (!FirebaseApp.getApps(this).isEmpty()) {
//            Log.d(TAG, "Firebase 初始化成功");
//        } else {
//            Log.e(TAG, "Firebase 初始化失败");
//        }

        initSdk();

        ObjectBox.init(this);

    }


    private void initSdk() {

        ATSDK.checkIsEuTraffic(this, new NetTrafficeCallback() {

            @Override
            public void onResultCallback(boolean isEU) {
                Log.e(TAG, "onResultCallback:" + isEU);
                if (isEU && ATSDK.getGDPRDataLevel(ARApp.this) == ATSDK.UNKNOWN) {
                    ATSDK.showGdprAuth(ARApp.this);
                }

            }

            @Override
            public void onErrorCallback(String errorMsg) {
                Log.e(TAG, "onErrorCallback:" + errorMsg);
            }
        });

        ATSDK.init( this, APPId, AppKey);
        AdManager.loadAllAd();
        //测试工具
//        ATDebuggerUITest.showDebuggerUI(this,debug_KEy);
//
//        ATSDK.setNetworkLogDebug(true);

    }

}
