0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-22 11:15:10 +00:00

Merge pull request #280 from HaliksaR/improvement/view-binding

Clear All data binding
This commit is contained in:
Tornike Khintibidze 2020-11-24 00:59:51 +04:00 committed by GitHub
commit 477bda0459
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 439 additions and 525 deletions

View file

@ -48,7 +48,7 @@ android {
}
buildFeatures {
dataBinding true
dataBinding true // ObservableField migrate to flow or liveData
viewBinding true
}

View file

@ -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")
}
}

View file

@ -9,19 +9,20 @@ 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",
context.getString(R.string.push_notifications, context.getString(R.string.vanced)),
context.getString(R.string.push_notifications_summary, context.getString(R.string.vanced)),
"vanced_notifs"
"Vanced-Update",
context.getString(R.string.push_notifications, context.getString(R.string.vanced)),
context.getString(R.string.push_notifications_summary, context.getString(R.string.vanced)),
"vanced_notifs"
)
private val music = NotifModel(
"MicroG-Update",
context.getString(R.string.push_notifications, context.getString(R.string.music)),
context.getString(R.string.push_notifications_summary, context.getString(R.string.music)),
"music_notifs"
"MicroG-Update",
context.getString(R.string.push_notifications, context.getString(R.string.music)),
context.getString(R.string.push_notifications_summary, context.getString(R.string.music)),
"music_notifs"
)
private val microg = NotifModel(
"Music-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)
}

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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 {
@ -50,10 +53,10 @@ 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 {
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)
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)
}
}
}

View file

@ -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)

View file

@ -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() {

View file

@ -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)
if (key != null) {
prefKey = key.toString()
preference_switch.isChecked = prefs.getBoolean(key.toString(), value)
}
defValue = value
preference_switch_title.text = title
if (summary != null) {
preference_switch_summary.text = summary
}
typedArray.recycle()
}
fun setTitle(title: CharSequence?) {
binding.preferenceSwitchTitle.text = title
}
interface OnCheckedListener {
fun onChecked(buttonView: CompoundButton, isChecked: Boolean)
fun setSummary(summary: CharSequence?) {
binding.preferenceSwitchSummary.text = summary
}
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)
}
fun setKey(key: CharSequence?) {
prefKey = key.toString()
binding.preferenceSwitch.isChecked = prefs.getBoolean(prefKey, defValue)
}
fun setDefaultValue(newVal: Boolean) {
defValue = newVal
binding.preferenceSwitch.isChecked = prefs.getBoolean(prefKey, defValue)
}
}

View file

@ -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)
}
}
}

View file

@ -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
}

View file

@ -1,40 +1,34 @@
<?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">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorSurface"
tools:context=".ui.MainActivity">
<RelativeLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorSurface"
app:elevation="0dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?colorSurface"
app:titleTextAppearance="@style/ToolbarTextTitle"
tools:title="Manager" />
</com.google.android.material.appbar.AppBarLayout>
<fragment
android:id="@+id/nav_host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorSurface"
tools:context=".ui.MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorSurface"
app:elevation="0dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?colorSurface"
app:titleTextAppearance="@style/ToolbarTextTitle"
tools:title="Manager" />
</com.google.android.material.appbar.AppBarLayout>
<fragment
android:id="@+id/nav_host"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/app_bar"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />
</RelativeLayout>
</layout>
android:layout_below="@id/app_bar"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />
</RelativeLayout>

View file

@ -1,21 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<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"
android:layout_height="match_parent"
tools:context=".ui.WelcomeActivity">
<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"
<fragment
android:id="@+id/welcome_navhost"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.WelcomeActivity">
<fragment
android:id="@+id/welcome_navhost"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/welcome_navigation" />
</RelativeLayout>
</layout>
app:defaultNavHost="true"
app:navGraph="@navigation/welcome_navigation" />
</RelativeLayout>

View file

@ -1,65 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<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"
android:layout_height="match_parent">
<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"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingHorizontal="8dp"
android:paddingTop="16dp">
<LinearLayout
<com.vanced.manager.ui.core.PreferenceCategory
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingHorizontal="8dp"
android:paddingTop="16dp">
android:layout_height="wrap_content"
android:background="@drawable/category_background"
app:category_title="@string/category_behaviour">
<com.vanced.manager.ui.core.PreferenceCategory
<com.vanced.manager.ui.core.PreferenceSwitch
android:id="@+id/use_custom_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/category_background"
app:category_title="@string/category_behaviour">
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" />
<com.vanced.manager.ui.core.PreferenceSwitch
android:id="@+id/use_custom_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notifications_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
tools:itemCount="3"
tools:listitem="@layout/view_preference_switch" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/notifications_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
tools:itemCount="3"
tools:listitem="@layout/view_preference_switch"/>
<com.vanced.manager.ui.core.PreferenceSwitch
android:id="@+id/firebase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:switch_def_value="true"
app:switch_key="@{@string/firebase}"
app:switch_summary="@string/firebase_summary"
app:switch_title="@string/firebase_title" />
<com.vanced.manager.ui.core.PreferenceSwitch
android:id="@+id/firebase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:switch_def_value="true"
app:switch_key="@{@string/firebase}"
app:switch_summary="@string/firebase_summary"
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" />
<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"/>
<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"/>
</com.vanced.manager.ui.core.PreferenceCategory>
<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" />
</com.vanced.manager.ui.core.PreferenceCategory>
<com.vanced.manager.ui.core.PreferenceCategory
android:layout_width="match_parent"
@ -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>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -1,113 +1,84 @@
<?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">
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/app_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:cardBackgroundColor="?colorLinkBG"
app:cardCornerRadius="16dp"
app:cardElevation="0dp"
app:contentPaddingBottom="4dp"
app:contentPaddingLeft="16dp"
app:contentPaddingRight="16dp"
app:contentPaddingTop="8dp">
<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
android:id="@+id/app_card"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/app_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:cardBackgroundColor="?colorLinkBG"
app:cardCornerRadius="16dp"
app:cardElevation="0dp"
app:contentPaddingBottom="4dp"
app:contentPaddingLeft="16dp"
app:contentPaddingRight="16dp"
app:contentPaddingTop="8dp">
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/app_view_container"
<TextView
android:id="@+id/app_name"
style="@style/CardTextHeader"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/vanced" />
<com.google.android.material.button.MaterialButton
android:id="@+id/app_install_button"
style="@style/OutlinedButtonStyle"
android:layout_marginTop="4dp"
android:textColor="?colorPrimary"
app:layout_constraintBottom_toTopOf="@id/app_uninstall"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/app_uninstall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:src="@drawable/ic_delete_black_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_install_button"
app:tint="?colorLinkImage" />
<ImageButton
android:id="@+id/app_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:background="@android:color/transparent"
android:src="@drawable/ic_app_settings_black_24dp"
app:layout_constraintEnd_toStartOf="@id/app_uninstall"
app:layout_constraintTop_toBottomOf="@id/app_install_button"
app:tint="?colorLinkImage" />
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/app_remote_version_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:flexWrap="wrap"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@id/app_installed_version_container"
app:layout_constraintEnd_toStartOf="@id/app_install_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toBottomOf="@id/app_name">
<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" />
style="@style/AppVersionText"
android:text="@string/latest" />
<com.google.android.material.button.MaterialButton
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"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/app_uninstall"
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" />
<ImageButton
android:id="@+id/app_settings"
android:layout_width="wrap_content"
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) &amp;&amp; dataModel.isAppInstalled()) ? View.VISIBLE : View.GONE}"
app:layout_constraintEnd_toStartOf="@id/app_uninstall"
app:layout_constraintTop_toBottomOf="@id/app_install_button"
app:tint="?colorLinkImage" />
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/app_remote_version_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:flexWrap="wrap"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@id/app_installed_version_container"
app:layout_constraintEnd_toStartOf="@id/app_install_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_name">
<TextView
style="@style/AppVersionText"
android:text="@string/latest" />
<TextView
android:id="@+id/app_remote_version"
style="@style/AppVersionText"
android:layout_marginStart="4dp"
android:text="@{dataModel.versionName}" />
</com.google.android.flexbox.FlexboxLayout>
<TextView
android:id="@+id/app_remote_version"
style="@style/AppVersionText"
android:layout_marginStart="4dp" />
</com.google.android.flexbox.FlexboxLayout>
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/app_installed_version_container"
@ -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>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

View file

@ -1,56 +1,51 @@
<?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">
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/app_checkbox_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/app_checkbox_bg"
<TextView
android:id="@+id/app_checkbox_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:letterSpacing="0.15"
android:textAllCaps="true"
android:textColor="?colorPrimary"
android:textSize="12sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/vanced" />
<TextView
android:id="@+id/app_checkbox_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp">
android:layout_marginTop="4dp"
android:layout_marginEnd="24dp"
android:gravity="start"
android:paddingBottom="4dp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/app_checkbox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_checkbox_text"
tools:text="YouTube Vanced is the stock Android YouTube App, but better!" />
<TextView
android:id="@+id/app_checkbox_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:letterSpacing="0.15"
android:textAllCaps="true"
android:textColor="?colorPrimary"
android:textSize="12sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/vanced" />
<TextView
android:id="@+id/app_checkbox_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginEnd="24dp"
android:gravity="start"
android:paddingBottom="4dp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/app_checkbox"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_checkbox_text"
tools:text="YouTube Vanced is the stock Android YouTube App, but better!" />
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/app_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="?colorError"
android:clickable="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:checked="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/app_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:buttonTint="?colorError"
android:clickable="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:checked="true" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -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"
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>
<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" />

View file

@ -1,44 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<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"
android:layout_width="80dp"
android:layout_height="68dp"
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
app:cardBackgroundColor="?colorLinkBG"
app:cardCornerRadius="12dp"
app:cardElevation="0dp"
app:contentPaddingBottom="4dp"
app:contentPaddingLeft="8dp"
app:contentPaddingRight="8dp"
app:contentPaddingTop="2dp">
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/link_bg"
android:layout_width="80dp"
android:layout_height="68dp"
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"
app:contentPaddingBottom="4dp"
app:contentPaddingLeft="8dp"
app:contentPaddingRight="8dp"
app:contentPaddingTop="2dp">
<ImageView
android:id="@+id/link_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:tint="?colorLinkImage"
tools:src="@drawable/ic_instagram" />
</com.google.android.material.card.MaterialCardView>
</layout>
<ImageView
android:id="@+id/link_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:tint="?colorLinkImage"
tools:src="@drawable/ic_instagram" />
</com.google.android.material.card.MaterialCardView>

View file

@ -1,68 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<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"
app:cardBackgroundColor="?colorLinkBG"
app:cardCornerRadius="12dp"
app:cardElevation="0dp"
app:contentPaddingTop="12dp">
<data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<variable
name="viewModel"
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
<ImageView
android:id="@+id/sponsor_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorLinkImage"
tools:src="@drawable/ic_brave" />
<variable
name="sponsor"
type="com.vanced.manager.model.SponsorModel" />
<TextView
android:id="@+id/sponsor_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?colorLinkImage"
app:layout_constraintBottom_toTopOf="@id/sponsor_description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</data>
<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: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"
app:contentPaddingTop="12dp">
<androidx.constraintlayout.widget.ConstraintLayout
<TextView
android:id="@+id/sponsor_description"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/sponsor_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorLinkImage"
tools:src="@drawable/ic_brave" />
<TextView
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"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/sponsor_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/support_us"
android:textColor="?colorLinkImage"
android:textAlignment="center"
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>
android:layout_height="wrap_content"
android:text="@string/support_us"
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>