mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-10 12:55:06 +00:00
Clear All data binding
This commit is contained in:
parent
c41e9966f3
commit
939468d3d2
20 changed files with 439 additions and 525 deletions
|
@ -48,7 +48,7 @@ android {
|
|||
}
|
||||
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
dataBinding true // ObservableField migrate to flow or liveData
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.vanced.manager.adapter
|
|||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.florent37.viewtooltip.ViewTooltip
|
||||
|
@ -15,6 +17,7 @@ import com.vanced.manager.ui.viewmodels.HomeViewModel
|
|||
class AppListAdapter(
|
||||
private val context: FragmentActivity,
|
||||
private val viewModel: HomeViewModel,
|
||||
private val lifecycleOwner: LifecycleOwner,
|
||||
private val tooltip: ViewTooltip
|
||||
) : RecyclerView.Adapter<AppListAdapter.ListViewHolder>() {
|
||||
|
||||
|
@ -30,14 +33,36 @@ class AppListAdapter(
|
|||
val appCard = binding.appCard
|
||||
|
||||
fun bind(position: Int) {
|
||||
binding.viewModel = viewModel
|
||||
binding.dataModel = if (isRoot) rootDataModels[position] else dataModels[position]
|
||||
binding.app = apps[position]
|
||||
val dataModel = if (isRoot) rootDataModels[position] else dataModels[position]
|
||||
with(binding) {
|
||||
appName.text = dataModel?.appName
|
||||
dataModel?.buttonTxt?.observe(this@AppListAdapter.lifecycleOwner) {
|
||||
appInstallButton.text = it
|
||||
}
|
||||
appInstallButton.setOnClickListener {
|
||||
viewModel.openInstallDialog(it, apps[position])
|
||||
}
|
||||
appUninstall.setOnClickListener {
|
||||
dataModel?.appPkg?.let { it1 -> viewModel.uninstallPackage(it1) }
|
||||
}
|
||||
appUninstall.isVisible = dataModel?.isAppInstalled?.value == true
|
||||
appSettings.setOnClickListener {
|
||||
viewModel.openMicrogSettings()
|
||||
}
|
||||
appSettings.isVisible =
|
||||
apps[position] == context.getString(R.string.microg) && dataModel?.isAppInstalled?.value == true
|
||||
dataModel?.versionName?.observe(this@AppListAdapter.lifecycleOwner) {
|
||||
appRemoteVersion.text = it
|
||||
}
|
||||
dataModel?.installedVersionName?.observe(this@AppListAdapter.lifecycleOwner) {
|
||||
appInstalledVersion.text = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListViewHolder {
|
||||
val view = ViewAppBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val view = ViewAppBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||
return ListViewHolder(view)
|
||||
}
|
||||
|
||||
|
@ -49,7 +74,7 @@ class AppListAdapter(
|
|||
AppInfoDialog.newInstance(
|
||||
appName = apps[position],
|
||||
appIcon = dataModels[position]?.appIcon,
|
||||
changelog = dataModels[position]?.changelog?.get()
|
||||
changelog = dataModels[position]?.changelog?.value
|
||||
).show(context.supportFragmentManager, "info")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.databinding.ViewNotificationSettingBinding
|
||||
import com.vanced.manager.model.NotifModel
|
||||
|
||||
class GetNotifAdapter(context: Context) : RecyclerView.Adapter<GetNotifAdapter.GetNotifViewHolder>() {
|
||||
class GetNotifAdapter(private val context: Context) :
|
||||
RecyclerView.Adapter<GetNotifAdapter.GetNotifViewHolder>() {
|
||||
|
||||
private val vanced = NotifModel(
|
||||
"Vanced-Update",
|
||||
|
@ -36,12 +37,18 @@ class GetNotifAdapter(context: Context) : RecyclerView.Adapter<GetNotifAdapter.G
|
|||
val switch = binding.notifSwitch
|
||||
|
||||
fun bind(position: Int) {
|
||||
binding.app = apps[position]
|
||||
with(binding.notifSwitch) {
|
||||
setKey(apps[position].key)
|
||||
setSummary(apps[position].switchSummary)
|
||||
setTitle(apps[position].switchTitle)
|
||||
setDefaultValue(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GetNotifViewHolder {
|
||||
val view = ViewNotificationSettingBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val view =
|
||||
ViewNotificationSettingBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||
return GetNotifViewHolder(view)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,10 @@ import com.vanced.manager.databinding.ViewSocialLinkBinding
|
|||
import com.vanced.manager.model.LinkModel
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
|
||||
class LinkAdapter(context: Context, private val viewModel: HomeViewModel) : RecyclerView.Adapter<LinkAdapter.LinkViewHolder>() {
|
||||
class LinkAdapter(
|
||||
private val context: Context,
|
||||
private val viewModel: HomeViewModel
|
||||
) : RecyclerView.Adapter<LinkAdapter.LinkViewHolder>() {
|
||||
|
||||
private val instagram = LinkModel(
|
||||
AppCompatResources.getDrawable(context, R.drawable.ic_instagram),
|
||||
|
@ -55,16 +58,18 @@ class LinkAdapter(context: Context, private val viewModel: HomeViewModel) : Recy
|
|||
val links = arrayOf(instagram, youtube, github, website, telegram, twitter, discord, reddit)
|
||||
|
||||
inner class LinkViewHolder(private val binding: ViewSocialLinkBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
val logo = binding.linkImage
|
||||
fun bind(position: Int) {
|
||||
binding.viewModel = viewModel
|
||||
binding.linkModel = links[position]
|
||||
}
|
||||
|
||||
val logo = binding.linkImage
|
||||
|
||||
fun bind(position: Int) {
|
||||
binding.linkBg.setOnClickListener {
|
||||
viewModel.openUrl(links[position].linkUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LinkViewHolder {
|
||||
val view = ViewSocialLinkBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val view = ViewSocialLinkBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||
return LinkViewHolder(view)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,8 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.databinding.ViewAppCheckboxBinding
|
||||
import com.vanced.manager.model.SelectAppModel
|
||||
|
||||
class SelectAppsAdapter(context: Context) : RecyclerView.Adapter<SelectAppsAdapter.SelectAppsViewHolder>() {
|
||||
class SelectAppsAdapter(private val context: Context) :
|
||||
RecyclerView.Adapter<SelectAppsAdapter.SelectAppsViewHolder>() {
|
||||
|
||||
private val prefs by lazy { getDefaultSharedPreferences(context) }
|
||||
|
||||
|
@ -37,7 +38,7 @@ class SelectAppsAdapter(context: Context) : RecyclerView.Adapter<SelectAppsAdapt
|
|||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SelectAppsViewHolder {
|
||||
val view = ViewAppCheckboxBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val view = ViewAppCheckboxBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||
return SelectAppsViewHolder(view)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.vanced.manager.model.SponsorModel
|
|||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
|
||||
class SponsorAdapter(
|
||||
context: Context,
|
||||
private val context: Context,
|
||||
private val viewModel: HomeViewModel,
|
||||
//private val json: ObservableField<JsonObject?>
|
||||
) : RecyclerView.Adapter<SponsorAdapter.LinkViewHolder>() {
|
||||
|
@ -35,14 +35,17 @@ class SponsorAdapter(
|
|||
) {
|
||||
val logo = binding.sponsorLogo
|
||||
fun bind(position: Int) {
|
||||
binding.viewModel = viewModel
|
||||
binding.sponsor = sponsors[position]
|
||||
with(binding) {
|
||||
sponsorName.text = sponsors[position].name
|
||||
cardSponsor.setOnClickListener {
|
||||
viewModel.openUrl(sponsors[position].url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LinkViewHolder {
|
||||
val view = ViewSponsorBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
val view = ViewSponsorBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||
return LinkViewHolder(view)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,8 @@ import android.content.Context
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import androidx.databinding.Observable
|
||||
import androidx.databinding.ObservableBoolean
|
||||
import androidx.databinding.ObservableField
|
||||
import androidx.databinding.ObservableInt
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.beust.klaxon.JsonObject
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.utils.PackageHelper.isPackageInstalled
|
||||
|
@ -22,24 +21,28 @@ open class DataModel(
|
|||
val appIcon: Drawable?,
|
||||
) {
|
||||
|
||||
private val versionCode = ObservableInt()
|
||||
private val installedVersionCode = ObservableInt()
|
||||
private val versionCode = MutableLiveData<Int>()
|
||||
private val installedVersionCode = MutableLiveData<Int>()
|
||||
|
||||
val isAppInstalled = ObservableBoolean()
|
||||
val versionName = ObservableField<String>()
|
||||
val installedVersionName = ObservableField<String>()
|
||||
val buttonTxt = ObservableField<String>()
|
||||
val changelog = ObservableField<String>()
|
||||
val isAppInstalled = MutableLiveData<Boolean>()
|
||||
val versionName = MutableLiveData<String>()
|
||||
val installedVersionName = MutableLiveData<String>()
|
||||
val buttonTxt = MutableLiveData<String>()
|
||||
val changelog = MutableLiveData<String>()
|
||||
|
||||
fun fetch() = CoroutineScope(Dispatchers.IO).launch {
|
||||
val jobj = jsonObject.get()
|
||||
isAppInstalled.set(isPackageInstalled(appPkg, context.packageManager))
|
||||
versionName.set(jobj?.string("version")?.removeSuffix("-vanced") ?: context.getString(R.string.unavailable))
|
||||
installedVersionName.set(getPkgVersionName(isAppInstalled.get(), appPkg))
|
||||
versionCode.set(jobj?.int("versionCode") ?: 0)
|
||||
installedVersionCode.set(getPkgVersionCode(isAppInstalled.get(), appPkg))
|
||||
buttonTxt.set(compareInt(installedVersionCode.get(), versionCode.get()))
|
||||
changelog.set(jobj?.string("changelog") ?: context.getString(R.string.unavailable))
|
||||
isAppInstalled.postValue(isPackageInstalled(appPkg, context.packageManager))
|
||||
versionName.postValue(
|
||||
jobj?.string("version")?.removeSuffix("-vanced") ?: context.getString(
|
||||
R.string.unavailable
|
||||
)
|
||||
)
|
||||
installedVersionName.postValue(getPkgVersionName(isAppInstalled.value, appPkg))
|
||||
versionCode.postValue(jobj?.int("versionCode") ?: 0)
|
||||
installedVersionCode.postValue(getPkgVersionCode(isAppInstalled.value, appPkg))
|
||||
buttonTxt.postValue(compareInt(installedVersionCode.value, versionCode.value))
|
||||
changelog.postValue(jobj?.string("changelog") ?: context.getString(R.string.unavailable))
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -51,9 +54,9 @@ open class DataModel(
|
|||
})
|
||||
}
|
||||
|
||||
private fun getPkgVersionName(toCheck: Boolean, pkg: String): String {
|
||||
private fun getPkgVersionName(toCheck: Boolean?, pkg: String): String {
|
||||
val pm = context.packageManager
|
||||
return if (toCheck) {
|
||||
return if (toCheck == true) {
|
||||
pm.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced")
|
||||
} else {
|
||||
context.getString(R.string.unavailable)
|
||||
|
@ -61,23 +64,25 @@ open class DataModel(
|
|||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun getPkgVersionCode(toCheck: Boolean, pkg: String): Int {
|
||||
return if (toCheck) {
|
||||
private fun getPkgVersionCode(toCheck: Boolean?, pkg: String): Int {
|
||||
return if (toCheck == true) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
context.packageManager.getPackageInfo(pkg, 0).longVersionCode.and(0xFFFFFFFF).toInt()
|
||||
context.packageManager.getPackageInfo(pkg, 0).longVersionCode.and(0xFFFFFFFF)
|
||||
.toInt()
|
||||
else
|
||||
context.packageManager.getPackageInfo(pkg, 0).versionCode
|
||||
} else 0
|
||||
}
|
||||
|
||||
private fun compareInt(int1: Int, int2: Int): String {
|
||||
private fun compareInt(int1: Int?, int2: Int?): String {
|
||||
if (int2 != null && int1 != null) {
|
||||
return when {
|
||||
int1 == 0 -> context.getString(R.string.install)
|
||||
int2 > int1 -> context.getString(R.string.update)
|
||||
int2 == int1 || int1 > int2 -> context.getString(R.string.button_reinstall)
|
||||
else -> context.getString(R.string.install)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return context.getString(R.string.install)
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ import android.util.Log
|
|||
import android.view.MenuItem
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
|
@ -56,12 +55,15 @@ class MainActivity : AppCompatActivity() {
|
|||
if (ENABLE_CROWDIN_AUTH)
|
||||
authCrowdin()
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
|
||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
with(binding) {
|
||||
lifecycleOwner = this@MainActivity
|
||||
setSupportActionBar(toolbar)
|
||||
toolbar.setupWithNavController(this@MainActivity.navHost, AppBarConfiguration(this@MainActivity.navHost.graph))
|
||||
toolbar.setupWithNavController(
|
||||
this@MainActivity.navHost,
|
||||
AppBarConfiguration(this@MainActivity.navHost.graph)
|
||||
)
|
||||
}
|
||||
navHost.addOnDestinationChangedListener { _, currFrag: NavDestination, _ ->
|
||||
setDisplayHomeAsUpEnabled(currFrag.id != R.id.home_fragment)
|
||||
|
|
|
@ -2,19 +2,16 @@ package com.vanced.manager.ui
|
|||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.findNavController
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.ActivityWelcomeBinding
|
||||
|
||||
class WelcomeActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityWelcomeBinding
|
||||
private val navHost by lazy { findNavController(R.id.welcome_navhost) }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_welcome)
|
||||
setContentView(R.layout.activity_welcome)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
|
|
@ -6,10 +6,9 @@ import android.view.LayoutInflater
|
|||
import android.widget.CompoundButton
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.content.edit
|
||||
import androidx.databinding.BindingAdapter
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.vanced.manager.R
|
||||
import kotlinx.android.synthetic.main.view_preference_switch.view.*
|
||||
import com.vanced.manager.databinding.ViewPreferenceSwitchBinding
|
||||
|
||||
class PreferenceSwitch @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -18,26 +17,50 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
defStyleRes: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyle, defStyleRes) {
|
||||
|
||||
interface OnCheckedListener {
|
||||
fun onChecked(buttonView: CompoundButton, isChecked: Boolean)
|
||||
}
|
||||
|
||||
private val prefs by lazy { getDefaultSharedPreferences(context) }
|
||||
|
||||
var prefKey: String = ""
|
||||
private set
|
||||
|
||||
var defValue: Boolean = false
|
||||
private set
|
||||
|
||||
private var mListener: OnCheckedListener? = null
|
||||
|
||||
private var _binding: ViewPreferenceSwitchBinding? = null
|
||||
|
||||
val binding: ViewPreferenceSwitchBinding
|
||||
get() = requireNotNull(_binding)
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_preference_switch, this, true)
|
||||
initAttrs(context, attrs)
|
||||
_binding = ViewPreferenceSwitchBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
attrs?.let { mAttrs ->
|
||||
with(context.obtainStyledAttributes(mAttrs, R.styleable.PreferenceSwitch, 0, 0)) {
|
||||
val title = getText(R.styleable.PreferenceSwitch_switch_title)
|
||||
val summary = getText(R.styleable.PreferenceSwitch_switch_summary)
|
||||
val key = getText(R.styleable.PreferenceSwitch_switch_key)
|
||||
setDefaultValue(getBoolean(R.styleable.PreferenceSwitch_switch_def_value, false))
|
||||
setKey(key)
|
||||
setTitle(title)
|
||||
setSummary(summary)
|
||||
recycle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
setOnClickListener {
|
||||
preference_switch.isChecked = !preference_switch.isChecked
|
||||
binding.preferenceSwitch.isChecked = !binding.preferenceSwitch.isChecked
|
||||
}
|
||||
preference_switch.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
binding.preferenceSwitch.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
prefs.edit { putBoolean(prefKey, isChecked) }
|
||||
mListener?.onChecked(buttonView, isChecked)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun setOnCheckedListener(method: (buttonView: CompoundButton, isChecked: Boolean) -> Unit) {
|
||||
|
@ -52,62 +75,21 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
mListener = listener
|
||||
}
|
||||
|
||||
private fun initAttrs(context: Context, attrs: AttributeSet?) {
|
||||
attrs?.let { mAttrs ->
|
||||
val typedArray = context.obtainStyledAttributes(mAttrs, R.styleable.PreferenceSwitch, 0, 0)
|
||||
val title = typedArray.getText(R.styleable.PreferenceSwitch_switch_title)
|
||||
val summary = typedArray.getText(R.styleable.PreferenceSwitch_switch_summary)
|
||||
val key = typedArray.getText(R.styleable.PreferenceSwitch_switch_key)
|
||||
val value = typedArray.getBoolean(R.styleable.PreferenceSwitch_switch_def_value, false)
|
||||
fun setTitle(title: CharSequence?) {
|
||||
binding.preferenceSwitchTitle.text = title
|
||||
}
|
||||
|
||||
if (key != null) {
|
||||
fun setSummary(summary: CharSequence?) {
|
||||
binding.preferenceSwitchSummary.text = summary
|
||||
}
|
||||
|
||||
fun setKey(key: CharSequence?) {
|
||||
prefKey = key.toString()
|
||||
preference_switch.isChecked = prefs.getBoolean(key.toString(), value)
|
||||
binding.preferenceSwitch.isChecked = prefs.getBoolean(prefKey, defValue)
|
||||
}
|
||||
|
||||
defValue = value
|
||||
preference_switch_title.text = title
|
||||
|
||||
if (summary != null) {
|
||||
preference_switch_summary.text = summary
|
||||
fun setDefaultValue(newVal: Boolean) {
|
||||
defValue = newVal
|
||||
binding.preferenceSwitch.isChecked = prefs.getBoolean(prefKey, defValue)
|
||||
}
|
||||
|
||||
typedArray.recycle()
|
||||
}
|
||||
}
|
||||
|
||||
interface OnCheckedListener {
|
||||
fun onChecked(buttonView: CompoundButton, isChecked: Boolean)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("app:switch_title")
|
||||
fun setTitle(view: PreferenceSwitch, newTitle: String) {
|
||||
view.preference_switch_title.text = newTitle
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("app:switch_summary")
|
||||
fun setSummary(view: PreferenceSwitch, newSummary: String) {
|
||||
view.preference_switch_summary.text = newSummary
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("app:switch_key")
|
||||
fun setKey(view: PreferenceSwitch, newKey: String) {
|
||||
view.prefKey = newKey
|
||||
view.preference_switch.isChecked = view.prefs.getBoolean(view.prefKey, view.defValue)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("app:switch_def_value")
|
||||
fun setDefaultValue(view: PreferenceSwitch, newVal: Boolean) {
|
||||
view.defValue = newVal
|
||||
view.preference_switch.isChecked = view.prefs.getBoolean(view.prefKey, view.defValue)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -77,7 +77,7 @@ open class HomeFragment : BindingFragment<FragmentHomeBinding>() {
|
|||
|
||||
recyclerAppList.apply {
|
||||
layoutManager = LinearLayoutManager(requireActivity())
|
||||
adapter = AppListAdapter(requireActivity(), this@HomeFragment.viewModel, tooltip)
|
||||
adapter = AppListAdapter(requireActivity(), viewModel, viewLifecycleOwner, tooltip)
|
||||
setHasFixedSize(true)
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ open class HomeFragment : BindingFragment<FragmentHomeBinding>() {
|
|||
lm.justifyContent = JustifyContent.SPACE_EVENLY
|
||||
layoutManager = lm
|
||||
setHasFixedSize(true)
|
||||
adapter = SponsorAdapter(requireActivity(), this@HomeFragment.viewModel)
|
||||
adapter = SponsorAdapter(requireActivity(), viewModel)
|
||||
}
|
||||
|
||||
recyclerLinks.apply {
|
||||
|
@ -94,7 +94,7 @@ open class HomeFragment : BindingFragment<FragmentHomeBinding>() {
|
|||
lm.justifyContent = JustifyContent.SPACE_EVENLY
|
||||
layoutManager = lm
|
||||
setHasFixedSize(true)
|
||||
adapter = LinkAdapter(requireActivity(), this@HomeFragment.viewModel)
|
||||
adapter = LinkAdapter(requireActivity(), viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ open class HomeViewModel(private val activity: FragmentActivity): ViewModel() {
|
|||
|
||||
fun openInstallDialog(view: View, app: String) {
|
||||
val variant = prefs.getString("vanced_variant", "nonroot")
|
||||
if (variant == "nonroot" && app != activity.getString(R.string.microg) && !microg.get()?.isAppInstalled?.get()!!) {
|
||||
if (variant == "nonroot" && app != activity.getString(R.string.microg) && !microg.get()?.isAppInstalled?.value!!) {
|
||||
microgToast.show()
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout 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">
|
||||
|
||||
<RelativeLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?colorSurface"
|
||||
|
@ -23,7 +21,6 @@
|
|||
android:background="?colorSurface"
|
||||
app:titleTextAppearance="@style/ToolbarTextTitle"
|
||||
tools:title="Manager" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<fragment
|
||||
|
@ -34,7 +31,4 @@
|
|||
android:layout_below="@id/app_bar"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/mobile_navigation" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</layout>
|
||||
</RelativeLayout>
|
|
@ -1,7 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout 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"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -15,7 +13,4 @@
|
|||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/welcome_navigation" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</layout>
|
||||
</RelativeLayout>
|
|
@ -1,8 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.core.widget.NestedScrollView 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"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -28,7 +25,7 @@
|
|||
app:switch_def_value="true"
|
||||
app:switch_key="@{@string/use_custom_tabs}"
|
||||
app:switch_summary="@string/link_custom_tabs"
|
||||
app:switch_title="@string/link_title"/>
|
||||
app:switch_title="@string/link_title" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/notifications_recycler"
|
||||
|
@ -36,7 +33,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:nestedScrollingEnabled="false"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/view_preference_switch"/>
|
||||
tools:listitem="@layout/view_preference_switch" />
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceSwitch
|
||||
android:id="@+id/firebase"
|
||||
|
@ -45,20 +42,19 @@
|
|||
app:switch_def_value="true"
|
||||
app:switch_key="@{@string/firebase}"
|
||||
app:switch_summary="@string/firebase_summary"
|
||||
app:switch_title="@string/firebase_title"/>
|
||||
app:switch_title="@string/firebase_title" />
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/manager_variant"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="@string/variant"/>
|
||||
app:preference_title="@string/variant" />
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/clearFiles"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="@string/clear_files"/>
|
||||
|
||||
app:preference_title="@string/clear_files" />
|
||||
</com.vanced.manager.ui.core.PreferenceCategory>
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceCategory
|
||||
|
@ -84,17 +80,13 @@
|
|||
android:id="@+id/manager_language"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="@string/language_title"/>
|
||||
app:preference_title="@string/language_title" />
|
||||
|
||||
<com.vanced.manager.ui.core.EmptyPreference
|
||||
android:id="@+id/select_apps"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:preference_title="@string/select_apps"/>
|
||||
app:preference_title="@string/select_apps" />
|
||||
</com.vanced.manager.ui.core.PreferenceCategory>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</layout>
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -1,27 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
|
||||
<variable
|
||||
name="dataModel"
|
||||
type="com.vanced.manager.model.DataModel" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
<variable
|
||||
name="app"
|
||||
type="String" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/app_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -44,7 +24,6 @@
|
|||
<TextView
|
||||
android:id="@+id/app_name"
|
||||
style="@style/CardTextHeader"
|
||||
android:text="@{dataModel.appName}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@string/vanced" />
|
||||
|
@ -53,8 +32,6 @@
|
|||
android:id="@+id/app_install_button"
|
||||
style="@style/OutlinedButtonStyle"
|
||||
android:layout_marginTop="4dp"
|
||||
android:onClick="@{(v)-> viewModel.openInstallDialog(v, app)}"
|
||||
android:text="@{dataModel.buttonTxt}"
|
||||
android:textColor="?colorPrimary"
|
||||
app:layout_constraintBottom_toTopOf="@id/app_uninstall"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -65,10 +42,8 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:onClick="@{()-> viewModel.uninstallPackage(dataModel.appPkg)}"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_delete_black_24dp"
|
||||
android:visibility="@{dataModel.isAppInstalled() ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_install_button"
|
||||
app:tint="?colorLinkImage" />
|
||||
|
@ -79,9 +54,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:onClick="@{()-> viewModel.openMicrogSettings()}"
|
||||
android:src="@drawable/ic_app_settings_black_24dp"
|
||||
android:visibility="@{(app.equals(@string/microg) && dataModel.isAppInstalled()) ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toStartOf="@id/app_uninstall"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_install_button"
|
||||
app:tint="?colorLinkImage" />
|
||||
|
@ -104,9 +77,7 @@
|
|||
<TextView
|
||||
android:id="@+id/app_remote_version"
|
||||
style="@style/AppVersionText"
|
||||
android:layout_marginStart="4dp"
|
||||
android:text="@{dataModel.versionName}" />
|
||||
|
||||
android:layout_marginStart="4dp" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
|
@ -127,14 +98,7 @@
|
|||
<TextView
|
||||
android:id="@+id/app_installed_version"
|
||||
style="@style/AppVersionText"
|
||||
android:layout_marginStart="4dp"
|
||||
android:text="@{dataModel.installedVersionName}" />
|
||||
|
||||
android:layout_marginStart="4dp" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -1,9 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/app_checkbox_bg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -50,7 +48,4 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:checked="true" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,21 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="app"
|
||||
type="com.vanced.manager.model.NotifModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.vanced.manager.ui.core.PreferenceSwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.vanced.manager.ui.core.PreferenceSwitch xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/notif_switch"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:switch_def_value="true"
|
||||
app:switch_key="@{app.key}"
|
||||
app:switch_summary="@{app.switchSummary}"
|
||||
app:switch_title="@{app.switchTitle}" />
|
||||
|
||||
</layout>
|
||||
android:layout_height="wrap_content" />
|
|
@ -1,19 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
<variable
|
||||
name="linkModel"
|
||||
type="com.vanced.manager.model.LinkModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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"
|
||||
android:id="@+id/link_bg"
|
||||
|
@ -22,7 +8,6 @@
|
|||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:onClick="@{()-> viewModel.openUrl(linkModel.linkUrl)}"
|
||||
app:cardBackgroundColor="?colorLinkBG"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp"
|
||||
|
@ -38,7 +23,4 @@
|
|||
android:layout_gravity="center"
|
||||
app:tint="?colorLinkImage"
|
||||
tools:src="@drawable/ic_instagram" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -1,25 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
<variable
|
||||
name="sponsor"
|
||||
type="com.vanced.manager.model.SponsorModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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"
|
||||
android:id="@+id/card_sponsor"
|
||||
android:layout_width="165dp"
|
||||
android:layout_height="97dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:onClick="@{()-> viewModel.openUrl(sponsor.url)}"
|
||||
app:cardBackgroundColor="?colorLinkBG"
|
||||
app:cardCornerRadius="12dp"
|
||||
app:cardElevation="0dp"
|
||||
|
@ -43,7 +29,6 @@
|
|||
android:id="@+id/sponsor_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{sponsor.name}"
|
||||
android:textColor="?colorLinkImage"
|
||||
app:layout_constraintBottom_toTopOf="@id/sponsor_description"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -55,14 +40,10 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/support_us"
|
||||
android:textColor="?colorLinkImage"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?colorLinkImage"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sponsor_name" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</layout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
Loading…
Reference in a new issue