mirror of
https://github.com/YTVanced/VancedManager
synced 2025-01-06 23:41:00 +00:00
UI tests
This commit is contained in:
parent
f89ad86cb0
commit
a537aa92ed
6 changed files with 22 additions and 28 deletions
|
@ -130,7 +130,7 @@ class VancedDownloadService: Service() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareInstall(variant: String) {
|
private fun prepareInstall(variant: String) {
|
||||||
val intent = Intent(HomeFragment.VANCED_DOWNLOADED)
|
val intent = Intent()
|
||||||
intent.action = HomeFragment.VANCED_DOWNLOADED
|
intent.action = HomeFragment.VANCED_DOWNLOADED
|
||||||
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
|
||||||
if (variant == "root")
|
if (variant == "root")
|
||||||
|
|
|
@ -23,19 +23,7 @@ open class Home : BaseFragment(), View.OnClickListener {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val microginstallbtn = view.findViewById<MaterialButton>(R.id.microg_installbtn)
|
|
||||||
val vancedinstallbtn = view.findViewById<MaterialButton>(R.id.vanced_installbtn)
|
|
||||||
val microguninstallbtn = view.findViewById<ImageView>(R.id.microg_uninstallbtn)
|
|
||||||
val vanceduninstallbtn = view.findViewById<ImageView>(R.id.vanced_uninstallbtn)
|
|
||||||
val rootswitch = view.findViewById<MaterialButton>(R.id.root_switch)
|
|
||||||
val nonrootswitch = view.findViewById<MaterialButton>(R.id.nonroot_switch)
|
|
||||||
|
|
||||||
vancedinstallbtn.setOnClickListener(this)
|
|
||||||
microginstallbtn.setOnClickListener(this)
|
|
||||||
microguninstallbtn.setOnClickListener(this)
|
|
||||||
vanceduninstallbtn.setOnClickListener(this)
|
|
||||||
rootswitch.setOnClickListener(this)
|
|
||||||
nonrootswitch.setOnClickListener(this)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.vanced.manager.ui.fragments
|
||||||
|
|
||||||
import android.content.*
|
import android.content.*
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.animation.AccelerateDecelerateInterpolator
|
import android.view.animation.AccelerateDecelerateInterpolator
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
@ -16,7 +17,7 @@ import com.vanced.manager.core.fragments.Home
|
||||||
import com.vanced.manager.databinding.FragmentHomeBinding
|
import com.vanced.manager.databinding.FragmentHomeBinding
|
||||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||||
|
|
||||||
class HomeFragment : Home() {
|
class HomeFragment : Home(), View.OnClickListener {
|
||||||
|
|
||||||
private lateinit var binding: FragmentHomeBinding
|
private lateinit var binding: FragmentHomeBinding
|
||||||
private var isExpanded: Boolean = false
|
private var isExpanded: Boolean = false
|
||||||
|
@ -48,6 +49,15 @@ class HomeFragment : Home() {
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
with(binding) {
|
||||||
|
rootSwitch.setOnClickListener(this@HomeFragment)
|
||||||
|
nonrootSwitch.setOnClickListener(this@HomeFragment)
|
||||||
|
|
||||||
|
includeVancedLayout.vancedInstallbtn.setOnClickListener(this@HomeFragment)
|
||||||
|
includeVancedLayout.vancedUninstallbtn.setOnClickListener(this@HomeFragment)
|
||||||
|
includeMicrogLayout.microgInstallbtn.setOnClickListener(this@HomeFragment)
|
||||||
|
includeMicrogLayout.microgUninstallbtn.setOnClickListener(this@HomeFragment)
|
||||||
|
}
|
||||||
|
|
||||||
binding.includeChangelogsLayout.changelogButton.setOnClickListener {
|
binding.includeChangelogsLayout.changelogButton.setOnClickListener {
|
||||||
cardExpandCollapse()
|
cardExpandCollapse()
|
||||||
|
@ -55,7 +65,7 @@ class HomeFragment : Home() {
|
||||||
|
|
||||||
binding.includeVancedLayout.vancedCard.setOnLongClickListener {
|
binding.includeVancedLayout.vancedCard.setOnLongClickListener {
|
||||||
val clip = requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
val clip = requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
clip.setPrimaryClip(ClipData.newPlainText("vanced", this.viewModel.vancedInstalledVersion.get()))
|
clip.setPrimaryClip(ClipData.newPlainText("vanced", viewModel.vancedInstalledVersion.get()))
|
||||||
versionToast("Vanced")
|
versionToast("Vanced")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -75,7 +85,6 @@ class HomeFragment : Home() {
|
||||||
0 -> tab.text = "Vanced"
|
0 -> tab.text = "Vanced"
|
||||||
1 -> tab.text = "Manager"
|
1 -> tab.text = "Manager"
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
when (position) {
|
when (position) {
|
||||||
0 -> tab.text = "Vanced"
|
0 -> tab.text = "Vanced"
|
||||||
|
@ -93,7 +102,7 @@ class HomeFragment : Home() {
|
||||||
|
|
||||||
private fun cardExpandCollapse() {
|
private fun cardExpandCollapse() {
|
||||||
with(binding.includeChangelogsLayout) {
|
with(binding.includeChangelogsLayout) {
|
||||||
activity?.runOnUiThread { viewModel?.expanded?.set(!isExpanded) }
|
binding.viewModel.expanded.set(!isExpanded)
|
||||||
changelogButton.animate().apply {
|
changelogButton.animate().apply {
|
||||||
rotation(if (isExpanded) 0F else 180F)
|
rotation(if (isExpanded) 0F else 180F)
|
||||||
interpolator = AccelerateDecelerateInterpolator()
|
interpolator = AccelerateDecelerateInterpolator()
|
||||||
|
@ -112,7 +121,10 @@ class HomeFragment : Home() {
|
||||||
when (intent.action) {
|
when (intent.action) {
|
||||||
MICROG_DOWNLOADED -> binding.includeMicrogLayout.microgInstalling.visibility = View.VISIBLE
|
MICROG_DOWNLOADED -> binding.includeMicrogLayout.microgInstalling.visibility = View.VISIBLE
|
||||||
VANCED_DOWNLOADED -> binding.includeVancedLayout.vancedInstalling.visibility = View.VISIBLE
|
VANCED_DOWNLOADED -> binding.includeVancedLayout.vancedInstalling.visibility = View.VISIBLE
|
||||||
REFRESH_HOME -> activity?.runOnUiThread { viewModel.fetchData() }
|
REFRESH_HOME -> {
|
||||||
|
binding.viewModel.fetchData()
|
||||||
|
Log.d("VMRefresh", "Refreshing home page")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,7 @@ class UpdateCheckFragment : DialogFragment() {
|
||||||
view?.findViewById<Button>(R.id.update_center_recheck)?.visibility = View.GONE
|
view?.findViewById<Button>(R.id.update_center_recheck)?.visibility = View.GONE
|
||||||
checkingTxt?.text = getString(R.string.update_found)
|
checkingTxt?.text = getString(R.string.update_found)
|
||||||
|
|
||||||
updatebtn?.setOnClickListener {
|
updatebtn?.setOnClickListener { upgradeManager() }
|
||||||
upgradeManager()
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
checkingTxt?.text = getString(R.string.update_notfound)
|
checkingTxt?.text = getString(R.string.update_notfound)
|
||||||
}
|
}
|
||||||
|
@ -118,7 +116,7 @@ class UpdateCheckFragment : DialogFragment() {
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
if (intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) == downloadId) {
|
if (intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) == downloadId) {
|
||||||
activity?.let {
|
activity?.let {
|
||||||
val apk = File("${activity?.filesDir?.path}/manager.apk")
|
val apk = File("${activity?.getExternalFilesDir("apk")}/manager.apk")
|
||||||
val uri =
|
val uri =
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
FileProvider.getUriForFile(activity!!, "${activity?.packageName}.provider", apk)
|
FileProvider.getUriForFile(activity!!, "${activity?.packageName}.provider", apk)
|
||||||
|
|
|
@ -49,10 +49,9 @@
|
||||||
android:id="@+id/vanced_installbtn"
|
android:id="@+id/vanced_installbtn"
|
||||||
style="@style/ButtonStyle"
|
style="@style/ButtonStyle"
|
||||||
android:text="@{viewModel.vancedInstallButtonTxt}"
|
android:text="@{viewModel.vancedInstallButtonTxt}"
|
||||||
android:textColor="@{viewModel.shouldBeDisabled ? @color/LightGray : @color/White}"
|
android:textColor="@color/White"
|
||||||
android:backgroundTint="@{viewModel.shouldBeDisabled ? @drawable/Gray : @drawable/Accent}"
|
android:backgroundTint="?colorPrimary"
|
||||||
app:icon="@{viewModel.vancedInstallButtonIcon}"
|
app:icon="@{viewModel.vancedInstallButtonIcon}"
|
||||||
android:clickable="@{!viewModel.shouldBeDisabled}"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,4 @@
|
||||||
|
|
||||||
<color name="Accent">?attr/colorPrimary</color>
|
<color name="Accent">?attr/colorPrimary</color>
|
||||||
|
|
||||||
<drawable name="Accent">?attr/colorPrimary</drawable>
|
|
||||||
<drawable name="Gray">@color/Gray</drawable>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue