junk code cleanup and proper support of root vanced
This commit is contained in:
parent
1cf13d2d0e
commit
eb5c53e314
|
@ -4,10 +4,8 @@ import android.annotation.SuppressLint
|
|||
import android.os.Bundle
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.base.BaseFragment
|
||||
|
||||
open class About : BaseFragment() {
|
||||
|
@ -44,17 +42,6 @@ open class About : BaseFragment() {
|
|||
}
|
||||
false
|
||||
}
|
||||
|
||||
val githubSource = view.findViewById<Button>(R.id.about_github_button)
|
||||
val license = view.findViewById<Button>(R.id.about_license_button)
|
||||
|
||||
githubSource.setOnClickListener {
|
||||
openUrl("https://github.com/YTvanced/VancedInstaller", R.color.GitHub)
|
||||
}
|
||||
|
||||
license.setOnClickListener {
|
||||
openUrl("https://raw.githubusercontent.com/YTVanced/VancedInstaller/dev/LICENSE", R.color.GitHub)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -18,17 +18,9 @@ open class Home : BaseFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
//Damn that's a lot of buttons
|
||||
val microginstallbtn = view.findViewById<MaterialButton>(R.id.microg_installbtn)
|
||||
val vancedinstallbtn = view.findViewById<MaterialButton>(R.id.vanced_installbtn)
|
||||
|
||||
//val bravebtn = view.findViewById<Button>(R.id.brave_button)
|
||||
//val websitebtn = view.findViewById<Button>(R.id.website_button)
|
||||
//val discordbtn = view.findViewById<Button>(R.id.discordbtn)
|
||||
//val telegrambtn = view.findViewById<Button>(R.id.tgbtn)
|
||||
//val twitterbtn = view.findViewById<Button>(R.id.twitterbtn)
|
||||
//val redditbtn = view.findViewById<Button>(R.id.redditbtn)
|
||||
|
||||
val microgProgress = view.findViewById<ProgressBar>(R.id.microg_progress)
|
||||
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
val isVancedDownloading: Boolean? = prefs?.getBoolean("isVancedDownloading", false)
|
||||
|
@ -83,31 +75,6 @@ open class Home : BaseFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bravebtn.setOnClickListener {
|
||||
openUrl("https://brave.com/van874", R.color.Brave)
|
||||
|
||||
}
|
||||
websitebtn.setOnClickListener {
|
||||
openUrl("https://vanced.app", R.color.Vanced)
|
||||
}
|
||||
discordbtn.setOnClickListener {
|
||||
openUrl("https://discord.gg/TUVd7rd", R.color.Discord)
|
||||
|
||||
}
|
||||
telegrambtn.setOnClickListener {
|
||||
openUrl("https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w", R.color.Telegram)
|
||||
|
||||
}
|
||||
twitterbtn.setOnClickListener {
|
||||
openUrl("https://twitter.com/YTVanced", R.color.Twitter)
|
||||
|
||||
}
|
||||
redditbtn.setOnClickListener {
|
||||
openUrl("https://reddit.com/r/vanced", R.color.Reddit)
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
@ -152,9 +152,11 @@ class MainActivity : Main() {
|
|||
dialog, _ ->
|
||||
run {
|
||||
dialog.dismiss()
|
||||
recreate()
|
||||
startActivity(Intent(this@MainActivity, MainActivity::class.java))
|
||||
finish()
|
||||
}
|
||||
}
|
||||
.setCancelable(false)
|
||||
.create()
|
||||
.show()
|
||||
}
|
||||
|
|
|
@ -4,21 +4,32 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.fragments.About
|
||||
import com.vanced.manager.databinding.FragmentAboutBinding
|
||||
import com.vanced.manager.ui.viewmodels.AboutViewModel
|
||||
|
||||
/**
|
||||
* A simple [Fragment] subclass.
|
||||
*/
|
||||
class AboutFragment : About() {
|
||||
|
||||
private lateinit var binding: FragmentAboutBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
activity?.title = getString(R.string.title_about)
|
||||
return inflater.inflate(R.layout.fragment_about, container, false)
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_home, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val viewModel: AboutViewModel by viewModels()
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,12 +63,17 @@ class HomeFragment : Home() {
|
|||
|
||||
private fun initNetworkFun() {
|
||||
val pm = activity?.packageManager
|
||||
val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) }
|
||||
val vancedStatus = pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
|
||||
val vancedStatus =
|
||||
if (variant == "root") {
|
||||
pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
|
||||
} else {
|
||||
pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
|
||||
}
|
||||
val vancedinstallbtn = view?.findViewById<MaterialButton>(R.id.vanced_installbtn)
|
||||
val vancedLatestTxt = view?.findViewById<TextView>(R.id.vanced_latest_version)
|
||||
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
|
||||
val variant = getDefaultSharedPreferences(activity).getString("vanced_variant", "nonroot")
|
||||
|
||||
disposable = ReactiveNetwork.observeInternetConnectivity()
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -124,21 +129,20 @@ class HomeFragment : Home() {
|
|||
|
||||
val vancedVerCode =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
pm.getPackageInfo(
|
||||
pm?.getPackageInfo(
|
||||
vanPkgName,
|
||||
0
|
||||
).longVersionCode.and(0xFFFFFFFF).toInt()
|
||||
)?.longVersionCode?.and(0xFFFFFFFF)?.toInt()
|
||||
}
|
||||
else {
|
||||
pm.getPackageInfo(
|
||||
pm?.getPackageInfo(
|
||||
vanPkgName,
|
||||
0
|
||||
).versionCode
|
||||
)?.versionCode
|
||||
}
|
||||
|
||||
|
||||
when {
|
||||
vancedRemoteCode > vancedVerCode -> {
|
||||
vancedRemoteCode > vancedVerCode!! -> {
|
||||
vancedinstallbtn?.text =
|
||||
activity?.getString(R.string.update)
|
||||
vancedinstallbtn?.icon =
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.vanced.manager.ui.viewmodels
|
||||
|
||||
import android.app.Application
|
||||
import android.net.Uri
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import com.vanced.manager.R
|
||||
|
||||
open class AboutViewModel(application: Application): AndroidViewModel(application) {
|
||||
|
||||
fun openUrl(Url: String) {
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
builder.setToolbarColor(ContextCompat.getColor(getApplication(), R.color.GitHub))
|
||||
val customTabsIntent = builder.build()
|
||||
customTabsIntent.launchUrl(getApplication(), Uri.parse(Url))
|
||||
}
|
||||
|
||||
}
|
|
@ -107,7 +107,18 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
|||
}
|
||||
}
|
||||
|
||||
fun openUrl(Url: String, color: Int) {
|
||||
fun openUrl(Url: String) {
|
||||
val color: Int =
|
||||
when (Url) {
|
||||
"https://discord.gg/TUVd7rd" -> R.color.Discord
|
||||
"https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w" -> R.color.Telegram
|
||||
"https://twitter.com/YTVanced" -> R.color.Twitter
|
||||
"https://reddit.com/r/vanced" -> R.color.Reddit
|
||||
"https://vanced.app" -> R.color.Vanced
|
||||
"https://brave.com/van874" -> R.color.Brave
|
||||
else -> R.color.Vanced
|
||||
}
|
||||
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
builder.setToolbarColor(ContextCompat.getColor(getApplication(), color))
|
||||
val customTabsIntent = builder.build()
|
||||
|
|
|
@ -1,45 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none">
|
||||
xmlns:bind="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.AboutViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="@dimen/twelvedp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="?colorSurface"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical">
|
||||
android:fillViewport="true"
|
||||
android:scrollbars="none">
|
||||
|
||||
<include
|
||||
layout="@layout/include_about_header"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="@dimen/twelvedp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="?colorSurface"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
layout="@layout/include_about_vanced_devs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/stdp" />
|
||||
<include
|
||||
layout="@layout/include_about_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<include
|
||||
layout="@layout/include_about_app_devs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/stdp" />
|
||||
<include
|
||||
layout="@layout/include_about_vanced_devs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/stdp" />
|
||||
|
||||
<include
|
||||
layout="@layout/include_about_sources"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/stdp" />
|
||||
<include
|
||||
layout="@layout/include_about_app_devs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/stdp" />
|
||||
|
||||
</LinearLayout>
|
||||
<include
|
||||
layout="@layout/include_about_sources"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/stdp"
|
||||
bind:viewModel="@{viewModel}"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</layout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
|
|
@ -1,67 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/MaterialCard"
|
||||
app:contentPaddingTop="2dp"
|
||||
app:contentPaddingBottom="8dp">
|
||||
<layout>
|
||||
<data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.AboutViewModel" />
|
||||
</data>
|
||||
|
||||
<TextView
|
||||
style="@style/AboutCardTitle"
|
||||
android:id="@+id/about_card_vancedTeam"
|
||||
android:text="@string/sources"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/MaterialCard"
|
||||
app:contentPaddingTop="2dp"
|
||||
app:contentPaddingBottom="8dp">
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/InnerMaterialCard"
|
||||
app:contentPaddingRight="@dimen/eightdp"
|
||||
app:contentPaddingLeft="@dimen/eightdp"
|
||||
app:cardBackgroundColor="#000000">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center">
|
||||
<TextView
|
||||
style="@style/AboutCardTitle"
|
||||
android:id="@+id/about_card_vancedTeam"
|
||||
android:text="@string/sources"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/InnerMaterialCard"
|
||||
app:contentPaddingRight="@dimen/eightdp"
|
||||
app:contentPaddingLeft="@dimen/eightdp"
|
||||
app:cardBackgroundColor="#000000">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/about_github_button"
|
||||
style="@style/SocialButtonStyle"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/about_license_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:icon="@drawable/github" />
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
tools:ignore="HardcodedText"
|
||||
android:id="@+id/about_license_button"
|
||||
style="@style/SocialButtonStyle"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="GPL"
|
||||
android:textSize="21sp"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/about_github_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/SocialButtonStyle"
|
||||
android:id="@+id/about_github_button"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://github.com/YTVanced/VancedInstaller")}'
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/about_license_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:icon="@drawable/github" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
tools:ignore="HardcodedText"
|
||||
android:id="@+id/about_license_button"
|
||||
style="@style/SocialButtonStyle"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="GPL"
|
||||
android:textSize="21sp"
|
||||
android:fontFamily="@font/exo_semibold"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://raw.githubusercontent.com/YTVanced/VancedInstaller/dev/LICENSE")}'
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/about_github_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
|
|
@ -43,14 +43,14 @@
|
|||
android:text="@string/support_us"
|
||||
android:layout_marginTop="5dp"
|
||||
app:cornerRadius="@dimen/eightdp"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://brave.com/van874", @color/Brave)}'/>
|
||||
android:onClick='@{()-> viewModel.openUrl("https://brave.com/van874")}'/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/LinkButtonStyle"
|
||||
android:id="@+id/website_button"
|
||||
android:text="@string/website_text"
|
||||
app:cornerRadius="@dimen/eightdp"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://vanced.app", @color/Vanced)}'/>
|
||||
android:onClick='@{()-> viewModel.openUrl("https://vanced.app")}'/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/tgbtn"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://discord.gg/TUVd7rd", @color/Discord)}'/>
|
||||
android:onClick='@{()-> viewModel.openUrl("https://discord.gg/TUVd7rd")}'/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/tgbtn"
|
||||
|
@ -56,7 +56,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/twitterbtn"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/discordbtn"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w", @color/Telegram)}'/>
|
||||
android:onClick='@{()-> viewModel.openUrl("https://t.me/joinchat/AAAAAEHf-pi4jH1SDlAL4w")}'/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/twitterbtn"
|
||||
|
@ -65,7 +65,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/redditbtn"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tgbtn"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://twitter.com/YTVanced", @color/Twitter)}'/>
|
||||
android:onClick='@{()-> viewModel.openUrl("https://twitter.com/YTVanced")}'/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/redditbtn"
|
||||
|
@ -74,7 +74,7 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/twitterbtn"
|
||||
android:onClick='@{()-> viewModel.openUrl("https://reddit.com/r/vanced", @color/Reddit)}'/>
|
||||
android:onClick='@{()-> viewModel.openUrl("https://reddit.com/r/vanced")}'/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
Loading…
Reference in New Issue