package importantedto.appliededto.surgeonedto.promiseedto.dialectedto

import android.app.Activity
import android.content.Intent
import android.util.Log
import importantedto.appliededto.surgeonedto.promiseedto.Byedto
import importantedto.appliededto.surgeonedto.promiseedto.forthedto.Appearanceedto
import importantedto.appliededto.surgeonedto.promiseedto.freedomedto.Spilledto
import importantedto.appliededto.surgeonedto.promiseedto.obtainedto.museumedto.outletedto.Probablyedto
import importantedto.appliededto.surgeonedto.promiseedto.petedto.Delayedto
import importantedto.appliededto.surgeonedto.promiseedto.produceredto.motionedto.momentumedto.Collectionedto
import importantedto.appliededto.surgeonedto.promiseedto.prospectedto.consumptionedto.blameedto.Reserveedto
import importantedto.appliededto.surgeonedto.promiseedto.steeledto.Liveredto
import importantedto.appliededto.surgeonedto.promiseedto.wonderedto.Tiptoeedto
import importantedto.concreteedto.cameedto.Hateedto
import importantedto.concreteedto.cameedto.Hateedto.ID_APP_MANAGER
import importantedto.concreteedto.cameedto.Hateedto.ID_APP_PROCESS
import importantedto.concreteedto.cameedto.Hateedto.ID_BATTERY_INFO
import importantedto.concreteedto.cameedto.Hateedto.ID_JUNK_CLEAN_PUSH
import importantedto.concreteedto.cameedto.Hateedto.ID_RECOVERY_DOCUMENTS
import importantedto.concreteedto.cameedto.Hateedto.ID_RECOVERY_PHOTOS
import importantedto.concreteedto.cameedto.Hateedto.ID_RECOVERY_VIDEOS
import importantedto.concreteedto.cameedto.Hateedto.ID_SCREENSHOT_CLEAN
import importantedto.concreteedto.cameedto.Hateedto.ID_SIMILAR_IMAGE
import importantedto.concreteedto.cameedto.Hateedto.ID_WHATSAPP_CLEANER
import importantedto.concreteedto.cameedto.Hateedto.isGuide

object Registeredto {

    private val TAG = "SplashJumpUtils"
    fun jumpNextPage(context: Activity) {

        var jumpType = context.intent.getIntExtra("actionId", 0)

        Log.e(TAG, "actionId: $jumpType")

        if (jumpType == 0) {
            val uri = context.intent.data
            val str = (uri?.getQueryParameter("type") ?: "0")
            jumpType = str.toIntOrNull() ?: 0
            if (jumpType != 0) {
            }
        }

        when (jumpType) {
//=================================主动广播=======================================
            ID_JUNK_CLEAN_PUSH -> {
                context.startActivity(Intent(context, Reserveedto::class.java))
            }

            ID_SIMILAR_IMAGE -> {
                context.startActivity(Intent(context, Collectionedto::class.java))
            }

            ID_SCREENSHOT_CLEAN -> {
                context.startActivity(Intent(context, Collectionedto::class.java))
            }

            ID_RECOVERY_PHOTOS -> {
                context.startActivity(
                    Intent(context, Spilledto::class.java).putExtra(
                        "ScanType", Hateedto.SCAN_PHOTOS
                    )
                )
            }

            ID_RECOVERY_VIDEOS -> {
                context.startActivity(
                    Intent(context, Spilledto::class.java).putExtra(
                        "ScanType",
                        Hateedto.SCAN_VIDEOS
                    )
                )

            }

            ID_RECOVERY_DOCUMENTS -> {
                context.startActivity(
                    Intent(context, Spilledto::class.java).putExtra(
                        "ScanType",
                        Hateedto.SCAN_DOCUMENTS
                    )
                )
            }

            ID_WHATSAPP_CLEANER -> {
                context.startActivity(Intent(context, Tiptoeedto::class.java))
            }

            ID_APP_PROCESS -> {
                context.startActivity(Intent(context, Delayedto::class.java))
            }

            ID_APP_MANAGER -> {
                context.startActivity(Intent(context, Liveredto::class.java))
            }

            ID_BATTERY_INFO -> {
                context.startActivity(Intent(context, Probablyedto::class.java))
            }


//================================被动广播=========================================

            else -> {
                val isHotLaunch = context.intent?.extras?.getBoolean("isHotLaunch", false) ?: false
                if (!isHotLaunch) {
                    if (!isGuide) {
                        context.startActivity(Intent(context, Appearanceedto::class.java))
                        isGuide = true
                    } else {
                        context.startActivity(Intent(context, Byedto::class.java))
                    }

                }
            }
        }
        context.finish()
    }
}