Allow parsing dev profile URLs

This commit is contained in:
Rahul Kumar Patel
2021-02-20 01:47:56 +05:30
parent 489783e612
commit db59843c58
18 changed files with 289 additions and 19 deletions

View File

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

View File

@@ -110,6 +110,21 @@
</intent-filter>
</activity>
<activity android:name=".view.ui.details.DevProfileActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="play.google.com" />
<data android:path="/store/apps/dev" />
</intent-filter>
</activity>
<activity android:name=".view.ui.search.SearchSuggestionActivity" />
<activity android:name=".view.ui.search.SearchResultsActivity" />
<activity android:name=".view.ui.commons.StreamBrowseActivity" />

View File

@@ -27,6 +27,7 @@ import androidx.annotation.DrawableRes
import androidx.annotation.RawRes
import com.bumptech.glide.Glide
import com.bumptech.glide.TransitionOptions
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.ViewTarget

View File

@@ -17,7 +17,7 @@
*
*/
package com.aurora.store.view.epoxy.views
package com.aurora.store.view.epoxy.views.details
import android.content.Context
import android.util.AttributeSet
@@ -30,7 +30,7 @@ import com.aurora.gplayapi.data.models.details.Badge
import com.aurora.store.R
import com.aurora.store.databinding.ViewBadgeBinding
import com.aurora.store.util.extensions.load
import com.aurora.store.view.epoxy.views.BaseView
@ModelView(
autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT,

View File

@@ -17,7 +17,7 @@
*
*/
package com.aurora.store.view.epoxy.views
package com.aurora.store.view.epoxy.views.details
import android.content.Context
import android.util.AttributeSet
@@ -29,7 +29,7 @@ import com.airbnb.epoxy.OnViewRecycled
import com.aurora.store.R
import com.aurora.store.data.model.ExodusTracker
import com.aurora.store.databinding.ViewExodusBinding
import com.aurora.store.view.epoxy.views.BaseView
@ModelView(
autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT,

View File

@@ -17,7 +17,7 @@
*
*/
package com.aurora.store.view.epoxy.views
package com.aurora.store.view.epoxy.views.details
import android.content.Context
import android.util.AttributeSet
@@ -28,6 +28,7 @@ import com.aurora.gplayapi.data.models.File
import com.aurora.store.R
import com.aurora.store.databinding.ViewFileBinding
import com.aurora.store.util.CommonUtil
import com.aurora.store.view.epoxy.views.BaseView
@ModelView(
autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT,

View File

@@ -17,7 +17,7 @@
*
*/
package com.aurora.store.view.epoxy.views
package com.aurora.store.view.epoxy.views.details
import android.content.Context
import android.content.res.Resources
@@ -34,13 +34,13 @@ import com.aurora.store.databinding.ViewScreenshotLargeBinding
import com.aurora.store.util.extensions.clear
import com.aurora.store.util.extensions.px
import com.aurora.store.util.extensions.runOnUiThread
import com.aurora.store.view.epoxy.views.BaseView
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
@ModelView(
autoLayout = ModelView.Size.MATCH_WIDTH_MATCH_HEIGHT,
baseModelClass = BaseView::class

View File

@@ -33,7 +33,6 @@ import com.aurora.store.databinding.ViewMoreBadgeBinding
import com.aurora.store.util.extensions.load
import com.aurora.store.view.epoxy.views.BaseView
@ModelView(
autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT,
baseModelClass = BaseView::class

View File

@@ -17,7 +17,7 @@
*
*/
package com.aurora.store.view.epoxy.views
package com.aurora.store.view.epoxy.views.details
import android.content.Context
import android.util.AttributeSet
@@ -32,6 +32,7 @@ import com.aurora.store.databinding.ViewReviewBinding
import com.aurora.store.util.extensions.clear
import com.aurora.store.util.extensions.load
import com.aurora.store.util.extensions.toDate
import com.aurora.store.view.epoxy.views.BaseView
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions

View File

@@ -17,7 +17,7 @@
*
*/
package com.aurora.store.view.epoxy.views
package com.aurora.store.view.epoxy.views.details
import android.content.Context
import android.util.AttributeSet
@@ -32,10 +32,10 @@ import com.aurora.store.databinding.ViewScreenshotBinding
import com.aurora.store.util.extensions.clear
import com.aurora.store.util.extensions.load
import com.aurora.store.util.extensions.px
import com.aurora.store.view.epoxy.views.BaseView
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
@ModelView(
autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT,
baseModelClass = BaseView::class
@@ -79,7 +79,7 @@ class ScreenshotView : RelativeLayout {
@ModelProp
fun artwork(artwork: Artwork) {
normalizeSize(artwork)
B.img.load(artwork.url, DrawableTransitionOptions.withCrossFade()) {
B.img.load("${artwork.url}=rw-h480-v1-e15", DrawableTransitionOptions.withCrossFade()) {
placeholder(R.drawable.bg_rounded)
transform(RoundedCorners(8.px.toInt()))
}

View File

@@ -48,6 +48,9 @@ import com.aurora.store.util.extensions.show
import com.aurora.store.util.extensions.toast
import com.aurora.store.view.custom.RatingView
import com.aurora.store.view.epoxy.views.*
import com.aurora.store.view.epoxy.views.details.ReviewViewModel_
import com.aurora.store.view.epoxy.views.details.ScreenshotView
import com.aurora.store.view.epoxy.views.details.ScreenshotViewModel_
import com.aurora.store.view.ui.commons.BaseActivity
import nl.komponents.kovenant.task
import nl.komponents.kovenant.ui.failUi

View File

@@ -29,8 +29,8 @@ import com.aurora.store.data.providers.ExodusDataProvider
import com.aurora.store.databinding.ActivityGenericRecyclerBinding
import com.aurora.store.util.extensions.browse
import com.aurora.store.util.extensions.close
import com.aurora.store.view.epoxy.views.ExodusViewModel_
import com.aurora.store.view.epoxy.views.HeaderViewModel_
import com.aurora.store.view.epoxy.views.details.ExodusViewModel_
import com.aurora.store.view.ui.commons.BaseActivity
import org.json.JSONObject

View File

@@ -29,10 +29,10 @@ import com.aurora.store.R
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.databinding.ActivityDetailsMoreBinding
import com.aurora.store.util.extensions.close
import com.aurora.store.view.epoxy.views.FileViewModel_
import com.aurora.store.view.epoxy.views.HeaderViewModel_
import com.aurora.store.view.epoxy.views.app.NoAppAltViewModel_
import com.aurora.store.view.epoxy.views.details.AppDependentViewModel_
import com.aurora.store.view.epoxy.views.details.FileViewModel_
import com.aurora.store.view.epoxy.views.details.MoreBadgeViewModel_
import com.aurora.store.view.ui.commons.BaseActivity
import nl.komponents.kovenant.task

View File

@@ -29,7 +29,7 @@ import com.aurora.store.data.ViewState
import com.aurora.store.databinding.ActivityDetailsReviewBinding
import com.aurora.store.util.extensions.close
import com.aurora.store.view.custom.recycler.EndlessRecyclerOnScrollListener
import com.aurora.store.view.epoxy.views.ReviewViewModel_
import com.aurora.store.view.epoxy.views.details.ReviewViewModel_
import com.aurora.store.view.ui.commons.BaseActivity
import com.aurora.store.viewmodel.review.ReviewViewModel

View File

@@ -0,0 +1,174 @@
/*
* 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.ui.details
import android.content.Intent
import android.os.Bundle
import com.airbnb.epoxy.EpoxyModel
import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.data.models.details.DevStream
import com.aurora.gplayapi.helpers.AppDetailsHelper
import com.aurora.store.R
import com.aurora.store.data.providers.AuthProvider
import com.aurora.store.databinding.ActivityDevProfileBinding
import com.aurora.store.util.extensions.close
import com.aurora.store.util.extensions.load
import com.aurora.store.util.extensions.toast
import com.aurora.store.view.epoxy.groups.CarouselHorizontalModel_
import com.aurora.store.view.epoxy.views.*
import com.aurora.store.view.epoxy.views.details.ScreenshotViewModel_
import com.aurora.store.view.ui.commons.BaseActivity
import nl.komponents.kovenant.task
import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi
class DevProfileActivity : BaseActivity() {
private lateinit var B: ActivityDevProfileBinding
private lateinit var authData: AuthData
override fun onConnected() {
hideNetworkConnectivitySheet()
}
override fun onDisconnected() {
showNetworkConnectivitySheet()
}
override fun onReconnected() {
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
B = ActivityDevProfileBinding.inflate(layoutInflater)
authData = AuthProvider.with(this).getAuthData()
setContentView(B.root)
attachToolbar()
onNewIntent(intent)
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
if (intent != null) {
if (intent.scheme != null && (intent.scheme == "http" || intent.scheme == "https")) {
val devId = intent.data!!.getQueryParameter("id")
if (devId.isNullOrEmpty()) {
close()
} else {
fetchDevProfile(devId)
}
}
} else {
close()
}
}
private fun attachToolbar() {
B.layoutToolbarAction.toolbar.setOnClickListener {
close()
}
B.layoutToolbarAction.txtTitle.text = getString(R.string.details_dev_profile)
}
private fun updateInfo(devStream: DevStream) {
B.layoutToolbarAction.txtTitle.text = devStream.title
B.txtDevName.text = devStream.title
B.txtDevDescription.text = devStream.description
B.imgIcon.load(devStream.imgUrl)
}
private fun updateController(devStream: DevStream) {
B.recycler
.withModels {
setFilterDuplicates(true)
for (entry in devStream.appListMap) {
val clusterViewModels = mutableListOf<EpoxyModel<*>>()
val screenshotsViewModels = mutableListOf<EpoxyModel<*>>()
if (entry.value.size == 1) {
val app = entry.value[0]
for (artwork in app.screenshots) {
screenshotsViewModels.add(
ScreenshotViewModel_()
.id(artwork.url)
.artwork(artwork)
)
}
clusterViewModels.add(
AppListViewModel_()
.id(app.id)
.app(app)
.click { _ ->
openDetailsActivity(app)
}
)
} else {
for (app in entry.value) {
clusterViewModels.add(
AppViewModel_()
.id(app.id)
.app(app)
.click { _ ->
openDetailsActivity(app)
}
)
}
}
add(
HeaderViewModel_()
.id(entry.key)
.title(entry.key)
)
if (screenshotsViewModels.isNotEmpty()) {
add(
CarouselHorizontalModel_()
.id("${entry.key}_screenshots")
.models(screenshotsViewModels)
)
}
add(
CarouselHorizontalModel_()
.id("${entry.key}_cluster")
.models(clusterViewModels)
)
}
}
}
private fun fetchDevProfile(devId: String) {
task {
AppDetailsHelper(authData).getDeveloperStream(devId)
} successUi {
updateInfo(it)
updateController(it)
} failUi {
toast("Dev profile unavailable")
close()
}
}
}

View File

@@ -26,13 +26,11 @@ import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import com.aurora.Constants
import com.aurora.gplayapi.data.models.Artwork
import com.aurora.store.R
import com.aurora.store.databinding.ActivityScreenshotBinding
import com.aurora.store.util.extensions.close
import com.aurora.store.view.epoxy.views.LargeScreenshotViewModel_
import com.aurora.store.view.epoxy.views.details.LargeScreenshotViewModel_
import com.aurora.store.view.ui.commons.BaseActivity
import com.google.gson.reflect.TypeToken
import com.tonyodev.fetch2.Status
class ScreenshotActivity : BaseActivity() {

View File

@@ -0,0 +1,77 @@
<?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/>.
~
-->
<LinearLayout 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"
android:divider="@drawable/divider"
android:orientation="vertical"
android:showDividers="middle">
<include
android:id="@+id/layout_toolbar_action"
layout="@layout/view_toolbar_action" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_normal">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/img_icon"
android:layout_width="@dimen/icon_size"
android:layout_height="@dimen/icon_size"
app:srcCompat="@drawable/bg_placeholder" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_dev_name"
style="@style/AuroraTextStyle.Subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_small"
android:layout_toEndOf="@id/img_icon"
tools:text="Developer Name" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_dev_description"
style="@style/AuroraTextStyle.Line2"
android:layout_width="match_parent"
android:maxLines="6"
android:layout_height="wrap_content"
android:layout_below="@id/txt_dev_name"
android:layout_alignStart="@id/txt_dev_name"
android:layout_alignEnd="@id/txt_dev_name"
android:layout_marginTop="@dimen/margin_small"
tools:text="Developer Name" />
</RelativeLayout>
<com.airbnb.epoxy.EpoxyRecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/layout_toolbar_action"
android:clipToPadding="true"
android:paddingBottom="@dimen/height_bottom_adj"
app:itemSpacing="@dimen/margin_normal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:stackFromEnd="false" />
</LinearLayout>

View File

@@ -133,6 +133,7 @@
<string name="details_dev_address">"Address"</string>
<string name="details_dev_details">"Developer contact"</string>
<string name="details_dev_email">"Email"</string>
<string name="details_dev_profile">"Developer profile"</string>
<string name="details_dev_reply">"Developer\'s reply"</string>
<string name="details_dev_website">"Website"</string>
<string name="details_files">"Files"</string>