Archived
Fully documented all Kotlin files and added TODOs to functions that need to be updated in some way
This commit is contained in:
@@ -7,23 +7,32 @@ 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
|
||||
import com.denizk0461.studip.activity.FetcherActivity
|
||||
import com.denizk0461.studip.data.Misc
|
||||
import com.denizk0461.studip.databinding.FragmentSettingsBinding
|
||||
|
||||
/**
|
||||
* User-facing fragment view that is used to change app settings.
|
||||
*/
|
||||
class SettingsFragment : Fragment() {
|
||||
|
||||
// Nullable view binding reference
|
||||
private var _binding: FragmentSettingsBinding? = null
|
||||
// This property is only valid between onCreateView and
|
||||
// onDestroyView.
|
||||
|
||||
/*
|
||||
* Non-null reference to the view binding. This property is only valid between onCreateView and
|
||||
* onDestroyView.
|
||||
*/
|
||||
private val binding get() = _binding!!
|
||||
|
||||
// Click counter on the app version button
|
||||
private var appVersionClick = 0
|
||||
|
||||
private var isQuarterChecked = false
|
||||
// 222
|
||||
private val mysteryLink = "https://www.youtube.com/watch?v=nhIQMCXJzLI"
|
||||
|
||||
// Instantiate the view binding
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
_binding = FragmentSettingsBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
@@ -32,47 +41,39 @@ class SettingsFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
// binding.layoutQuarter.setOnClickListener {
|
||||
// isQuarterChecked = !isQuarterChecked
|
||||
// binding.switchQuarter.isChecked = isQuarterChecked
|
||||
// }
|
||||
|
||||
// Launch the Stud.IP schedule fetcher activity
|
||||
binding.buttonRefreshSchedule.setOnClickListener {
|
||||
launchWebView()
|
||||
}
|
||||
|
||||
binding.switchQuarter.setOnClickListener {
|
||||
isQuarterChecked = !isQuarterChecked
|
||||
}
|
||||
|
||||
// Set click listener for the app version button
|
||||
binding.buttonAppVersion.setOnClickListener {
|
||||
when (appVersionClick) {
|
||||
19 -> {
|
||||
appVersionClick += 1
|
||||
}
|
||||
20 -> {
|
||||
appVersionClick += 1
|
||||
}
|
||||
21 -> {
|
||||
appVersionClick += 1
|
||||
}
|
||||
22 -> {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(Misc.mysteryLink)))
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(mysteryLink)))
|
||||
appVersionClick = 0
|
||||
}
|
||||
else -> appVersionClick += 1
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Display the app's version as set in the build.gradle. Also display if the app is a
|
||||
* development version.
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
binding.appVersionText.text = "${BuildConfig.VERSION_NAME}-${if (BuildConfig.DEBUG) "debug" else "release"}"
|
||||
binding.appVersionText.text = "${BuildConfig.VERSION_NAME}-${if (BuildConfig.DEBUG) "dev" else "release"}"
|
||||
}
|
||||
|
||||
// Invalidate the view binding
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch the Stud.IP schedule fetcher activity.
|
||||
*/
|
||||
private fun launchWebView() {
|
||||
startActivity(Intent(context, FetcherActivity::class.java))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user