2023-04-13 12:25:43 +02:00
|
|
|
package com.denizk0461.studip.fragment
|
|
|
|
|
|
2023-04-16 18:19:06 +02:00
|
|
|
import android.annotation.SuppressLint
|
2023-04-13 12:25:43 +02:00
|
|
|
import android.content.Intent
|
|
|
|
|
import android.net.Uri
|
|
|
|
|
import android.os.Bundle
|
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
|
import com.denizk0461.studip.BuildConfig
|
2023-04-16 18:19:06 +02:00
|
|
|
import com.denizk0461.studip.activity.FetcherActivity
|
2023-04-13 12:25:43 +02:00
|
|
|
import com.denizk0461.studip.data.Misc
|
|
|
|
|
import com.denizk0461.studip.databinding.FragmentSettingsBinding
|
|
|
|
|
|
|
|
|
|
class SettingsFragment : Fragment() {
|
|
|
|
|
|
|
|
|
|
private var _binding: FragmentSettingsBinding? = null
|
|
|
|
|
// This property is only valid between onCreateView and
|
|
|
|
|
// onDestroyView.
|
|
|
|
|
private val binding get() = _binding!!
|
|
|
|
|
private var appVersionClick = 0
|
|
|
|
|
|
2023-04-13 19:21:53 +02:00
|
|
|
private var isQuarterChecked = false
|
|
|
|
|
|
2023-04-13 12:25:43 +02:00
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
|
|
|
|
_binding = FragmentSettingsBinding.inflate(inflater, container, false)
|
|
|
|
|
return binding.root
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
2023-04-13 19:21:53 +02:00
|
|
|
// binding.layoutQuarter.setOnClickListener {
|
|
|
|
|
// isQuarterChecked = !isQuarterChecked
|
|
|
|
|
// binding.switchQuarter.isChecked = isQuarterChecked
|
|
|
|
|
// }
|
|
|
|
|
|
2023-04-16 18:19:06 +02:00
|
|
|
binding.buttonRefreshSchedule.setOnClickListener {
|
|
|
|
|
launchWebView()
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 19:21:53 +02:00
|
|
|
binding.switchQuarter.setOnClickListener {
|
|
|
|
|
isQuarterChecked = !isQuarterChecked
|
|
|
|
|
}
|
2023-04-13 12:25:43 +02:00
|
|
|
|
|
|
|
|
binding.buttonAppVersion.setOnClickListener {
|
|
|
|
|
when (appVersionClick) {
|
|
|
|
|
19 -> {
|
|
|
|
|
appVersionClick += 1
|
|
|
|
|
}
|
|
|
|
|
20 -> {
|
|
|
|
|
appVersionClick += 1
|
|
|
|
|
}
|
|
|
|
|
21 -> {
|
|
|
|
|
appVersionClick += 1
|
|
|
|
|
}
|
|
|
|
|
22 -> {
|
|
|
|
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(Misc.mysteryLink)))
|
|
|
|
|
appVersionClick = 0
|
|
|
|
|
}
|
|
|
|
|
else -> appVersionClick += 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-16 18:19:06 +02:00
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
|
|
binding.appVersionText.text = "${BuildConfig.VERSION_NAME}-${if (BuildConfig.DEBUG) "debug" else "release"}"
|
2023-04-13 12:25:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
|
|
super.onDestroyView()
|
|
|
|
|
_binding = null
|
|
|
|
|
}
|
2023-04-16 18:19:06 +02:00
|
|
|
|
|
|
|
|
private fun launchWebView() {
|
|
|
|
|
startActivity(Intent(context, FetcherActivity::class.java))
|
|
|
|
|
}
|
2023-04-13 12:25:43 +02:00
|
|
|
}
|