Add EditorChoice apps bulletins & description

This commit is contained in:
Rahul Kumar Patel
2021-02-22 09:39:44 +05:30
parent 12215ab769
commit e57c6863c3
8 changed files with 143 additions and 22 deletions

View File

@@ -172,7 +172,7 @@ dependencies {
implementation "com.github.topjohnwu.libsu:core:${versions.libsu}" implementation "com.github.topjohnwu.libsu:core:${versions.libsu}"
//Love <3 //Love <3
api("com.gitlab.AuroraOSS:gplayapi:d7ebd3855a") api("com.gitlab.AuroraOSS:gplayapi:bac20177ce")
} }
Properties props = new Properties() Properties props = new Properties()

View File

@@ -30,13 +30,10 @@ import com.aurora.store.view.epoxy.views.EditorImageViewModel_
class EditorChoiceModelGroup( class EditorChoiceModelGroup(
editorChoiceCluster: EditorChoiceCluster, editorChoiceCluster: EditorChoiceCluster,
callbacks: EditorChoiceController.Callbacks callbacks: EditorChoiceController.Callbacks
) : ) : EpoxyModelGroup(
EpoxyModelGroup( R.layout.model_editorchoice_group,
R.layout.model_editorchoice_group, buildModels( buildModels(editorChoiceCluster, callbacks)
editorChoiceCluster, ) {
callbacks
)
) {
companion object { companion object {
private fun buildModels( private fun buildModels(
editorChoiceCluster: EditorChoiceCluster, editorChoiceCluster: EditorChoiceCluster,
@@ -61,6 +58,7 @@ class EditorChoiceModelGroup(
EditorHeadViewModel_() EditorHeadViewModel_()
.id("header_${idPrefix}") .id("header_${idPrefix}")
.title(editorChoiceCluster.clusterTitle) .title(editorChoiceCluster.clusterTitle)
.click { _ -> callbacks.onClick(editorChoiceCluster) }
) )
editorChoiceCluster.clusterArtwork editorChoiceCluster.clusterArtwork

View File

@@ -22,6 +22,8 @@ package com.aurora.store.view.epoxy.views
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.RelativeLayout import android.widget.RelativeLayout
import androidx.core.text.HtmlCompat
import com.airbnb.epoxy.CallbackProp
import com.airbnb.epoxy.ModelProp import com.airbnb.epoxy.ModelProp
import com.airbnb.epoxy.ModelView import com.airbnb.epoxy.ModelView
import com.aurora.store.R import com.aurora.store.R
@@ -56,6 +58,11 @@ class EditorHeadView : RelativeLayout {
B = ViewEditorHeadBinding.bind(view) B = ViewEditorHeadBinding.bind(view)
} }
@CallbackProp
fun click(onClickListener: OnClickListener?) {
B.root.setOnClickListener(onClickListener)
}
@ModelProp @ModelProp
fun title(title: String) { fun title(title: String) {
B.title.text = title B.title.text = title

View File

@@ -0,0 +1,57 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.aurora.store.view.epoxy.views
import android.content.Context
import android.util.AttributeSet
import android.widget.RelativeLayout
import com.airbnb.epoxy.ModelView
import com.aurora.store.R
import com.aurora.store.databinding.ViewDividerBinding
@ModelView(
autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT,
baseModelClass = BaseView::class
)
class HorizontalDividerView : RelativeLayout {
private lateinit var B: ViewDividerBinding
constructor(context: Context?) : super(context) {
init(context, null)
}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
init(context, attrs)
}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
init(context, attrs)
}
private fun init(context: Context?, attrs: AttributeSet?) {
val view = inflate(context, R.layout.view_divider, this)
B = ViewDividerBinding.bind(view)
}
}

View File

@@ -27,6 +27,8 @@ import com.aurora.gplayapi.data.models.App
import com.aurora.store.databinding.ActivityGenericRecyclerBinding import com.aurora.store.databinding.ActivityGenericRecyclerBinding
import com.aurora.store.util.extensions.close import com.aurora.store.util.extensions.close
import com.aurora.store.view.epoxy.groups.CarouselHorizontalModel_ import com.aurora.store.view.epoxy.groups.CarouselHorizontalModel_
import com.aurora.store.view.epoxy.views.EditorHeadViewModel_
import com.aurora.store.view.epoxy.views.HorizontalDividerViewModel_
import com.aurora.store.view.epoxy.views.app.AppListViewModel_ import com.aurora.store.view.epoxy.views.app.AppListViewModel_
import com.aurora.store.view.epoxy.views.details.MiniScreenshotView import com.aurora.store.view.epoxy.views.details.MiniScreenshotView
import com.aurora.store.view.epoxy.views.details.MiniScreenshotViewModel_ import com.aurora.store.view.epoxy.views.details.MiniScreenshotViewModel_
@@ -95,10 +97,10 @@ class EditorStreamBrowseActivity : BaseActivity() {
) )
} }
} else { } else {
appList.forEach { appList.forEach { app ->
val screenshotsViewModels = mutableListOf<EpoxyModel<*>>() val screenshotsViewModels = mutableListOf<EpoxyModel<*>>()
for ((position, artwork) in it.screenshots.withIndex()) { for ((position, artwork) in app.screenshots.withIndex()) {
screenshotsViewModels.add( screenshotsViewModels.add(
MiniScreenshotViewModel_() MiniScreenshotViewModel_()
.id(artwork.url) .id(artwork.url)
@@ -106,25 +108,54 @@ class EditorStreamBrowseActivity : BaseActivity() {
.artwork(artwork) .artwork(artwork)
.callback(object : MiniScreenshotView.ScreenshotCallback { .callback(object : MiniScreenshotView.ScreenshotCallback {
override fun onClick(position: Int) { override fun onClick(position: Int) {
openScreenshotActivity(it, position) openScreenshotActivity(app, position)
} }
}) })
) )
} }
add(
AppListViewModel_()
.id("app_${app.id}")
.app(app)
.click { _ -> openDetailsActivity(app) }
)
app.editorReason?.let { editorReason ->
add(
EditorHeadViewModel_()
.id("bulletin_${app.id}")
.title(
editorReason.bulletins
.joinToString(transform = { "\n$it" })
.substringAfter(delimiter = "\n")
)
.click { _ -> openDetailsActivity(app) }
)
}
if (screenshotsViewModels.isNotEmpty()) { if (screenshotsViewModels.isNotEmpty()) {
add( add(
CarouselHorizontalModel_() CarouselHorizontalModel_()
.id("${it.id}_screenshots") .id("screenshots_${app.id}")
.models(screenshotsViewModels) .models(screenshotsViewModels)
) )
} }
app.editorReason?.let { editorReason ->
if (editorReason.description.isNotEmpty()) {
add( add(
AppListViewModel_() EditorHeadViewModel_()
.id(it.packageName.hashCode()) .id("description_${app.id}")
.app(it) .title(editorReason.description)
.click { _ -> openDetailsActivity(it) } .click { _ -> openDetailsActivity(app) }
)
}
}
add(
HorizontalDividerViewModel_()
.id("divider_${app.id}")
) )
} }
} }

View File

@@ -60,7 +60,7 @@ class EditorBrowseViewModel(application: Application) : BaseAndroidViewModel(app
streamHelper.getNextStreamResponse(browseResponse.browseTab.listUrl) streamHelper.getNextStreamResponse(browseResponse.browseTab.listUrl)
listResponse.itemList.forEach { listResponse.itemList.forEach {
it?.let{ it?.let {
it.subItemList.forEach { it.subItemList.forEach {
appList.addAll(streamHelper.getAppsFromItem(it)) appList.addAll(streamHelper.getAppsFromItem(it))
} }

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Aurora Store
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
~
~ Aurora Store is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 2 of the License, or
~ (at your option) any later version.
~
~ Aurora Store is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
~
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_small">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/title"
android:backgroundTint="?colorControlNormal"
android:layout_width="48dp"
android:layout_height="2dp"
android:layout_centerInParent="true"
android:background="@drawable/divider_line" />
</RelativeLayout>

View File

@@ -27,9 +27,5 @@
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"/>
android:maxLines="4"
android:singleLine="false"
android:textAppearance="@style/TextAppearance.Aurora.Line1"
app:drawableTint="?colorControlNormal" />
</RelativeLayout> </RelativeLayout>