package com.ccwangluo.cc_quickly.ui

import android.Manifest
import android.os.Bundle
import com.ccwangluo.accelerator.ui.BottomNavigationFragment
import com.ccwangluo.accelerator.utils.LoginUtils
import com.ccwangluo.accelerator.utils.PhoneUtils
import com.karumi.dexter.Dexter
import com.karumi.dexter.PermissionToken
import com.karumi.dexter.listener.PermissionDeniedResponse
import com.karumi.dexter.listener.PermissionGrantedResponse
import com.karumi.dexter.listener.PermissionRequest
import com.karumi.dexter.listener.single.PermissionListener
import com.tencent.mmkv.MMKV
import com.xuexiang.xpage.base.XPageActivity
import com.xuexiang.xpage.core.PageOption


class MainActivity() : XPageActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        MMKV.initialize(this)
        initPhoneUtils()
        //获取权限
        Dexter.withContext(this)
            .withPermission(Manifest.permission.READ_PHONE_STATE)
            .withListener(object : PermissionListener {
                override fun onPermissionGranted(response: PermissionGrantedResponse) {

                }

                override fun onPermissionDenied(response: PermissionDeniedResponse) {

                }

                override fun onPermissionRationaleShouldBeShown(
                    permission: PermissionRequest,
                    token: PermissionToken
                ) {

                }
            }).check()
        PageOption.to(BottomNavigationFragment::class.java).open(this)

    }

    private fun initPhoneUtils() {
        PhoneUtils.getPhoneInfo()
    }

    override fun onDestroy() {
        super.onDestroy()
        LoginUtils.clearToken()
    }



}