0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2025-01-05 15:01:01 +00:00
This commit is contained in:
X1nto 2020-07-23 13:34:10 +04:00
parent f89ad86cb0
commit a537aa92ed
6 changed files with 22 additions and 28 deletions

View file

@ -130,7 +130,7 @@ class VancedDownloadService: Service() {
}
private fun prepareInstall(variant: String) {
val intent = Intent(HomeFragment.VANCED_DOWNLOADED)
val intent = Intent()
intent.action = HomeFragment.VANCED_DOWNLOADED
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
if (variant == "root")

View file

@ -23,19 +23,7 @@ open class Home : BaseFragment(), View.OnClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
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)
}

View file

@ -2,6 +2,7 @@ package com.vanced.manager.ui.fragments
import android.content.*
import android.os.Bundle
import android.util.Log
import android.view.*
import android.view.animation.AccelerateDecelerateInterpolator
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.ui.viewmodels.HomeViewModel
class HomeFragment : Home() {
class HomeFragment : Home(), View.OnClickListener {
private lateinit var binding: FragmentHomeBinding
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 {
cardExpandCollapse()
@ -55,7 +65,7 @@ class HomeFragment : Home() {
binding.includeVancedLayout.vancedCard.setOnLongClickListener {
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")
true
}
@ -75,7 +85,6 @@ class HomeFragment : Home() {
0 -> tab.text = "Vanced"
1 -> tab.text = "Manager"
}
else
when (position) {
0 -> tab.text = "Vanced"
@ -93,7 +102,7 @@ class HomeFragment : Home() {
private fun cardExpandCollapse() {
with(binding.includeChangelogsLayout) {
activity?.runOnUiThread { viewModel?.expanded?.set(!isExpanded) }
binding.viewModel.expanded.set(!isExpanded)
changelogButton.animate().apply {
rotation(if (isExpanded) 0F else 180F)
interpolator = AccelerateDecelerateInterpolator()
@ -112,7 +121,10 @@ class HomeFragment : Home() {
when (intent.action) {
MICROG_DOWNLOADED -> binding.includeMicrogLayout.microgInstalling.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")
}
}
}
}

View file

@ -62,9 +62,7 @@ class UpdateCheckFragment : DialogFragment() {
view?.findViewById<Button>(R.id.update_center_recheck)?.visibility = View.GONE
checkingTxt?.text = getString(R.string.update_found)
updatebtn?.setOnClickListener {
upgradeManager()
}
updatebtn?.setOnClickListener { upgradeManager() }
} else
checkingTxt?.text = getString(R.string.update_notfound)
}
@ -118,7 +116,7 @@ class UpdateCheckFragment : DialogFragment() {
override fun onReceive(context: Context?, intent: Intent?) {
if (intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) == downloadId) {
activity?.let {
val apk = File("${activity?.filesDir?.path}/manager.apk")
val apk = File("${activity?.getExternalFilesDir("apk")}/manager.apk")
val uri =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
FileProvider.getUriForFile(activity!!, "${activity?.packageName}.provider", apk)

View file

@ -49,10 +49,9 @@
android:id="@+id/vanced_installbtn"
style="@style/ButtonStyle"
android:text="@{viewModel.vancedInstallButtonTxt}"
android:textColor="@{viewModel.shouldBeDisabled ? @color/LightGray : @color/White}"
android:backgroundTint="@{viewModel.shouldBeDisabled ? @drawable/Gray : @drawable/Accent}"
android:textColor="@color/White"
android:backgroundTint="?colorPrimary"
app:icon="@{viewModel.vancedInstallButtonIcon}"
android:clickable="@{!viewModel.shouldBeDisabled}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

View file

@ -16,7 +16,4 @@
<color name="Accent">?attr/colorPrimary</color>
<drawable name="Accent">?attr/colorPrimary</drawable>
<drawable name="Gray">@color/Gray</drawable>
</resources>