mirror of
https://github.com/topjohnwu/Magisk.git
synced 2026-01-15 14:24:15 -08:00
Updated developer section to be horizontally scrollable instead of vertically
In order to make room for more information
This commit is contained in:
@@ -10,7 +10,7 @@ sealed class HomeItem : ComparableRvItem<HomeItem>() {
|
||||
abstract val title: Int
|
||||
abstract val link: String
|
||||
|
||||
override val layoutRes = R.layout.item_developer
|
||||
override val layoutRes = R.layout.item_developer_link
|
||||
|
||||
override fun contentSameAs(other: HomeItem) = itemSameAs(other)
|
||||
override fun itemSameAs(other: HomeItem) = this == other
|
||||
@@ -20,6 +20,9 @@ sealed class HomeItem : ComparableRvItem<HomeItem>() {
|
||||
return icon == other.icon && title == other.title && link == other.link
|
||||
}
|
||||
|
||||
override fun hashCode() =
|
||||
icon.hashCode() + title.hashCode() + link.hashCode() + layoutRes.hashCode()
|
||||
|
||||
// region Children
|
||||
sealed class PayPal : HomeItem() {
|
||||
override val icon = R.drawable.ic_paypal
|
||||
@@ -72,3 +75,47 @@ sealed class HomeItem : ComparableRvItem<HomeItem>() {
|
||||
}
|
||||
// endregion
|
||||
}
|
||||
|
||||
sealed class DeveloperItem : ComparableRvItem<DeveloperItem>() {
|
||||
|
||||
abstract val items: List<HomeItem>
|
||||
abstract val icon: Int
|
||||
abstract val name: Int
|
||||
|
||||
override val layoutRes = R.layout.item_developer
|
||||
|
||||
override fun contentSameAs(other: DeveloperItem) = itemSameAs(other)
|
||||
override fun itemSameAs(other: DeveloperItem) = this == other
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is DeveloperItem) return false
|
||||
return icon == other.icon && name == other.name && items == other.items
|
||||
}
|
||||
|
||||
override fun hashCode() =
|
||||
icon.hashCode() + name.hashCode() + items.hashCode() + layoutRes.hashCode()
|
||||
|
||||
//region Children
|
||||
object Mainline : DeveloperItem() {
|
||||
override val items =
|
||||
listOf(HomeItem.PayPal.Mainline, HomeItem.Patreon, HomeItem.Twitter.Mainline)
|
||||
override val icon = R.drawable.ic_mainline_dev
|
||||
override val name = R.string.home_links_mainline
|
||||
}
|
||||
|
||||
object App : DeveloperItem() {
|
||||
override val items =
|
||||
listOf(HomeItem.PayPal.App, HomeItem.Twitter.App)
|
||||
override val icon = R.drawable.ic_mainline_dev
|
||||
override val name = R.string.home_links_app
|
||||
}
|
||||
|
||||
object Project : DeveloperItem() {
|
||||
override val items =
|
||||
listOf(HomeItem.Github, HomeItem.Xda)
|
||||
override val icon = R.drawable.ic_project
|
||||
override val name = R.string.home_links_project
|
||||
}
|
||||
//endregion
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.topjohnwu.magisk.redesign.home
|
||||
|
||||
import android.graphics.Insets
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearSnapHelper
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.FragmentHomeMd2Binding
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatFragment
|
||||
@@ -17,4 +20,9 @@ class HomeFragment : CompatFragment<HomeViewModel, FragmentHomeMd2Binding>() {
|
||||
super.onStart()
|
||||
activity.title = resources.getString(R.string.section_home)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
LinearSnapHelper().attachToRecyclerView(binding.homeSupportList)
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.topjohnwu.magisk.model.entity.ManagerJson
|
||||
import com.topjohnwu.magisk.model.entity.UpdateInfo
|
||||
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Magisk
|
||||
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Manager
|
||||
import com.topjohnwu.magisk.model.entity.recycler.DeveloperItem
|
||||
import com.topjohnwu.magisk.model.entity.recycler.HomeItem
|
||||
import com.topjohnwu.magisk.model.events.OpenInappLinkEvent
|
||||
import com.topjohnwu.magisk.model.events.dialog.EnvFixDialog
|
||||
@@ -67,15 +68,13 @@ class HomeViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
val itemsMainline =
|
||||
listOf(HomeItem.PayPal.Mainline, HomeItem.Patreon, HomeItem.Twitter.Mainline)
|
||||
val itemsApp =
|
||||
listOf(HomeItem.PayPal.App, HomeItem.Twitter.App)
|
||||
val itemsProject =
|
||||
listOf(HomeItem.Github, HomeItem.Xda)
|
||||
val items = listOf(DeveloperItem.Mainline, DeveloperItem.App, DeveloperItem.Project)
|
||||
val itemBinding = itemBindingOf<HomeItem> {
|
||||
it.bindExtra(BR.viewModel, this)
|
||||
}
|
||||
val itemDeveloperBinding = itemBindingOf<DeveloperItem> {
|
||||
it.bindExtra(BR.viewModel, this)
|
||||
}
|
||||
|
||||
private var shownDialog = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user