Updated developer section to be horizontally scrollable instead of vertically
In order to make room for more information
This commit is contained in:
parent
5f4718cd13
commit
df3a37b0a3
@ -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
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
<data>
|
||||
|
||||
<import type="com.topjohnwu.magisk.R" />
|
||||
|
||||
<import type="com.topjohnwu.magisk.Info" />
|
||||
|
||||
<import type="com.topjohnwu.magisk.BuildConfig" />
|
||||
@ -29,9 +31,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingEnd="@dimen/l1">
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -272,186 +272,20 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_support_list"
|
||||
dividerHorizontal="@{R.drawable.divider_l1}"
|
||||
itemBinding="@{viewModel.itemDeveloperBinding}"
|
||||
items="@{viewModel.items}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l2">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/support_icon_mainline"
|
||||
style="?styleIconNormal"
|
||||
android:padding="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_mainline_dev" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="?styleCardNormal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@+id/support_icon_mainline"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/l1">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="\@topjohnwu"
|
||||
android:textAppearance="?appearanceTextCaptionNormal"
|
||||
android:textStyle="bold"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
itemBinding="@{viewModel.itemBinding}"
|
||||
items="@{viewModel.itemsMainline}"
|
||||
nestedScrollingEnabled="@{false}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:fadingEdgeLength="@dimen/l1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/l1"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_developer" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l1">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/support_icon_app"
|
||||
style="?styleIconNormal"
|
||||
android:padding="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_app_dev" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="?styleCardNormal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/support_icon_app"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/l1">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="\@diareuse"
|
||||
android:textAppearance="?appearanceTextCaptionNormal"
|
||||
android:textStyle="bold"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
itemBinding="@{viewModel.itemBinding}"
|
||||
items="@{viewModel.itemsApp}"
|
||||
nestedScrollingEnabled="@{false}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:fadingEdgeLength="@dimen/l1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/l1"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:reverseLayout="true"
|
||||
tools:listitem="@layout/item_developer" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l1">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/support_icon_common"
|
||||
style="?styleIconNormal"
|
||||
android:padding="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_project" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="?styleCardNormal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@+id/support_icon_common"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/l1">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_links_project"
|
||||
android:textAppearance="?appearanceTextCaptionNormal"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
itemBinding="@{viewModel.itemBinding}"
|
||||
items="@{viewModel.itemsProject}"
|
||||
nestedScrollingEnabled="@{false}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:fadingEdgeLength="@dimen/l1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/l1"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_developer" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:layout_marginTop="@dimen/l2"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingEnd="@dimen/l1"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_developer" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<variable
|
||||
name="item"
|
||||
type="com.topjohnwu.magisk.model.entity.recycler.HomeItem" />
|
||||
type="com.topjohnwu.magisk.model.entity.recycler.DeveloperItem" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
@ -18,41 +18,62 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:onClick="@{() -> viewModel.onLinkPressed(item.link)}"
|
||||
tools:layout_gravity="center"
|
||||
android:padding="@dimen/l_50">
|
||||
tools:layout_gravity="center|start">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/developer_link"
|
||||
style="?styleImageNormal"
|
||||
app:tint="?colorOnSurface"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:id="@+id/developer_icon"
|
||||
style="?styleIconNormal"
|
||||
android:padding="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@{item.icon}"
|
||||
tools:srcCompat="@drawable/ic_paypal" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@drawable/ic_mainline_dev" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/developer_link_name"
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="?styleCardNormal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/l_50"
|
||||
android:text="@{item.title}"
|
||||
android:textAppearance="?appearanceTextCaptionNormal"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/developer_link"
|
||||
tools:text="Paypal" />
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintStart_toEndOf="@+id/developer_icon"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
style="?styleImageSmall"
|
||||
android:layout_height="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/developer_link_name"
|
||||
app:layout_constraintStart_toEndOf="@+id/developer_link_name"
|
||||
app:layout_constraintTop_toTopOf="@+id/developer_link_name"
|
||||
app:srcCompat="@drawable/ic_more"
|
||||
app:tint="?colorTextTransient" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/l1">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{item.name}"
|
||||
android:textAppearance="?appearanceTextCaptionNormal"
|
||||
android:textStyle="bold"
|
||||
tools:text="\@topjohnwu" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
itemBinding="@{viewModel.itemBinding}"
|
||||
items="@{item.items}"
|
||||
nestedScrollingEnabled="@{false}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:fadingEdgeLength="@dimen/l1"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/l_50"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:itemCount="3"
|
||||
tools:listitem="@layout/item_developer_link" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
48
app/src/main/res/layout/item_developer_link.xml
Normal file
48
app/src/main/res/layout/item_developer_link.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout 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>
|
||||
|
||||
<variable
|
||||
name="item"
|
||||
type="com.topjohnwu.magisk.model.entity.recycler.HomeItem" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.topjohnwu.magisk.redesign.home.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:onClick="@{() -> viewModel.onLinkPressed(item.link)}"
|
||||
android:padding="@dimen/l_50"
|
||||
tools:layout_gravity="center">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/developer_link"
|
||||
style="?styleImageSmall"
|
||||
app:layout_constraintEnd_toStartOf="@+id/developer_more"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@{item.icon}"
|
||||
app:tint="?colorOnSurface"
|
||||
tools:srcCompat="@drawable/ic_paypal" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/developer_more"
|
||||
style="?styleImageSmall"
|
||||
android:layout_height="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/developer_link"
|
||||
app:layout_constraintStart_toEndOf="@+id/developer_link"
|
||||
app:layout_constraintTop_toTopOf="@+id/developer_link"
|
||||
app:srcCompat="@drawable/ic_more"
|
||||
app:tint="?colorTextTransient" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
@ -19,6 +19,8 @@
|
||||
<string name="obsolete_md2">can be updated!</string>
|
||||
<string name="loading_md2">is loading…</string>
|
||||
|
||||
<string name="home_links_mainline">\@topjohnwu</string>
|
||||
<string name="home_links_app">\@diareuse</string>
|
||||
<string name="home_links_project">Project links</string>
|
||||
<string name="home_item_paypal">PayPal</string>
|
||||
<string name="home_item_patreon">Patreon</string>
|
||||
|
Loading…
Reference in New Issue
Block a user