Commit df3a37b0 authored by Viktor De Pasquale's avatar Viktor De Pasquale

Updated developer section to be horizontally scrollable instead of vertically

In order to make room for more information
parent 5f4718cd
......@@ -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
}
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)
}
}
\ No newline at end of file
......@@ -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
......
......@@ -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>
......
<?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>
\ No newline at end of file
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment