package com.android.launcher3.function.setting

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.GridLayout
import android.widget.LinearLayout
import com.android.launcher3.BaseActivity
import com.android.launcher3.R
import com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView
import com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView
import com.secspace.lib.common.utils.*
import kotlinx.android.synthetic.main.activity_setting.*

class SettingActivity : BaseActivity() {
    private var mContext: Context? = null
    private var wlan: QMUICommonListItemView? = null
    private var appUse: QMUICommonListItemView? = null
    private var buy: QMUICommonListItemView? = null
    private var about: QMUICommonListItemView? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setAndroidNativeLightStatusBar(true)
        setContentView(R.layout.activity_setting)
        mContext = this
        initView()
    }

    private fun initView() {
        tv_setting_title.setText(R.string.edu_title_setting)
        wlan = grouplistview.createItemView(null,
                getString(R.string.edu_item_wlan),
                null,
                LinearLayout.HORIZONTAL,
                QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
                dp2px(48f))
        appUse = grouplistview.createItemView(null,
                getString(R.string.edu_item_appuse),
                null,
                GridLayout.HORIZONTAL,
                QMUICommonListItemView.ACCESSORY_TYPE_NONE,
                dp2px(48f))
        buy = grouplistview.createItemView(null,
                getString(R.string.edu_item_buy),
                null,
                GridLayout.HORIZONTAL,
                QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
                dp2px(48f))
        about = grouplistview.createItemView(null,
                getString(R.string.edu_item_about),
                null,
                GridLayout.HORIZONTAL,
                QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON,
                dp2px(48f))
        QMUIGroupListView.newSection(mContext)
                .addItemView(wlan) { IntentUtil.startWifiSetting(mContext) }
                .addItemView(appUse) { ToastUtil.showShort(mContext, R.string.edu_toast_wait) }
                .addItemView(buy) { startActivity(Intent(mContext, SettingBuyActivity::class.java)) }
                .addItemView(about) { startActivity(Intent(mContext, SettingAboutActivity::class.java)) }
                .addTo(grouplistview)
    }

    fun close(view: View?) {
        finish()
    }
}