package com.sunny.app.soft.timberkeyboardnew.ui.fragment

import android.content.Intent
import android.net.Uri
import android.view.View
import com.sunny.app.soft.timberkeyboardnew.App
import com.sunny.app.soft.timberkeyboardnew.R
import com.sunny.app.soft.timberkeyboardnew.databinding.FragmentSettingBinding
import com.sunny.app.soft.timberkeyboardnew.ui.activity.SetKeyboardActivity

class SettingFragment : BaseFragment(), View.OnClickListener {

    private lateinit var binding: FragmentSettingBinding
    override fun setRootView(): View {
        binding = FragmentSettingBinding.inflate(layoutInflater)
        return binding.root
    }

    override fun initView() {
        super.initView()
        binding.settingLayoutRating.setOnClickListener(this)
        binding.settingLayoutShare.setOnClickListener(this)
        binding.settingLayoutSetKeyboard.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v) {
            binding.settingLayoutRating -> {
                val url = getString(R.string.link) + App.appContext.packageName
                val intent = Intent(Intent.ACTION_VIEW)
                intent.setData(Uri.parse(url))
                startActivity(intent)
            }

            binding.settingLayoutShare -> {
                val url = getString(R.string.link) + App.appContext.packageName
                val intent = Intent(Intent.ACTION_SEND)
                intent.setType("text/plain")
                intent.putExtra(Intent.EXTRA_TEXT, url)
                startActivity(intent)
            }

            binding.settingLayoutSetKeyboard -> {

            }
        }
    }
}