2020-04-12 12:00:14 +00:00
|
|
|
package com.vanced.manager.ui.fragments
|
|
|
|
|
2020-08-04 10:02:36 +00:00
|
|
|
import android.annotation.SuppressLint
|
2020-04-12 12:00:14 +00:00
|
|
|
import android.os.Bundle
|
2020-04-24 16:10:29 +00:00
|
|
|
import android.view.LayoutInflater
|
2020-08-04 10:02:36 +00:00
|
|
|
import android.view.MotionEvent
|
2020-04-24 16:10:29 +00:00
|
|
|
import android.view.ViewGroup
|
2020-08-04 10:02:36 +00:00
|
|
|
import android.widget.Toast
|
2020-11-15 09:49:40 +00:00
|
|
|
import androidx.appcompat.content.res.AppCompatResources
|
2020-11-05 16:35:49 +00:00
|
|
|
import androidx.core.content.edit
|
2020-06-05 12:45:36 +00:00
|
|
|
import androidx.fragment.app.viewModels
|
2020-08-04 10:02:36 +00:00
|
|
|
import androidx.preference.PreferenceManager
|
2020-04-12 12:00:14 +00:00
|
|
|
import com.vanced.manager.R
|
2020-11-26 15:37:03 +00:00
|
|
|
import com.vanced.manager.core.ui.base.BindingFragment
|
|
|
|
import com.vanced.manager.core.ui.ext.showDialog
|
2020-06-05 12:45:36 +00:00
|
|
|
import com.vanced.manager.databinding.FragmentAboutBinding
|
2020-11-15 14:11:44 +00:00
|
|
|
import com.vanced.manager.ui.dialogs.AppInfoDialog
|
2020-06-05 12:45:36 +00:00
|
|
|
import com.vanced.manager.ui.viewmodels.AboutViewModel
|
2020-11-15 09:49:40 +00:00
|
|
|
import com.vanced.manager.utils.InternetTools.manager
|
2020-04-12 12:00:14 +00:00
|
|
|
|
2020-11-14 21:05:35 +00:00
|
|
|
class AboutFragment : BindingFragment<FragmentAboutBinding>() {
|
2020-04-19 17:21:40 +00:00
|
|
|
|
2020-09-20 14:41:28 +00:00
|
|
|
private val viewModel: AboutViewModel by viewModels()
|
2020-08-04 10:02:36 +00:00
|
|
|
private var count = 0
|
|
|
|
private var startMillSec: Long = 0
|
2020-06-05 12:45:36 +00:00
|
|
|
|
2020-11-14 21:05:35 +00:00
|
|
|
override fun binding(
|
|
|
|
inflater: LayoutInflater,
|
|
|
|
container: ViewGroup?,
|
2020-04-12 12:00:14 +00:00
|
|
|
savedInstanceState: Bundle?
|
2020-11-14 21:05:35 +00:00
|
|
|
) = FragmentAboutBinding.inflate(inflater, container, false)
|
2020-06-05 12:45:36 +00:00
|
|
|
|
2020-11-14 21:05:35 +00:00
|
|
|
override fun otherSetups() {
|
|
|
|
dataBind()
|
|
|
|
}
|
2020-08-04 10:02:36 +00:00
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
2020-11-14 21:05:35 +00:00
|
|
|
private fun dataBind() {
|
|
|
|
requireActivity().title = getString(R.string.title_about)
|
2020-11-15 14:11:44 +00:00
|
|
|
binding.aboutHeader.root.setOnClickListener {
|
|
|
|
showDialog(
|
|
|
|
AppInfoDialog.newInstance(
|
|
|
|
appName = getString(R.string.app_name),
|
|
|
|
appIcon = AppCompatResources.getDrawable(requireActivity(), R.mipmap.ic_launcher),
|
|
|
|
changelog = manager.get()?.string("changelog")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
2020-11-14 21:05:35 +00:00
|
|
|
binding.root.setOnTouchListener { _, event: MotionEvent ->
|
2020-08-04 10:02:36 +00:00
|
|
|
val eventAction = event.action
|
|
|
|
if (eventAction == MotionEvent.ACTION_UP) {
|
|
|
|
val time = System.currentTimeMillis()
|
|
|
|
if (startMillSec == 0L || time - startMillSec > 3000) {
|
|
|
|
startMillSec = time
|
|
|
|
count = 1
|
|
|
|
} else {
|
|
|
|
count++
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count == 5) {
|
|
|
|
val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
|
|
|
val devSettings = prefs.getBoolean("devSettings", false)
|
|
|
|
if (!devSettings) {
|
|
|
|
Toast.makeText(requireContext(), "Dev options unlocked!", Toast.LENGTH_SHORT).show()
|
2020-11-05 16:35:49 +00:00
|
|
|
prefs.edit { putBoolean("devSettings", true) }
|
2020-08-04 10:02:36 +00:00
|
|
|
} else
|
|
|
|
Toast.makeText(requireContext(), "Dev options already unlocked", Toast.LENGTH_SHORT).show()
|
|
|
|
|
|
|
|
}
|
|
|
|
return@setOnTouchListener true
|
|
|
|
}
|
|
|
|
false
|
|
|
|
}
|
2020-11-14 21:05:35 +00:00
|
|
|
binding.aboutSources.aboutGithubButton.setOnClickListener { viewModel.openUrl("https://github.com/YTVanced/VancedInstaller") }
|
|
|
|
binding.aboutSources.aboutLicenseButton.setOnClickListener { viewModel.openUrl("https://raw.githubusercontent.com/YTVanced/VancedInstaller/dev/LICENSE") }
|
2020-08-04 10:02:36 +00:00
|
|
|
}
|
2020-04-12 12:00:14 +00:00
|
|
|
}
|