From 78bcda2d7dc5a999902c84da0c06305cf9fbc0b1 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 3 May 2022 15:11:38 -0300 Subject: [PATCH] [index] remove grouping of author and donation fields at the explicit request of Hans who feels strongly about it. --- .../kotlin/org/fdroid/index/v1/AppV1.kt | 28 +++++------- .../kotlin/org/fdroid/index/v2/PackageV2.kt | 42 +++++------------- .../kotlin/org/fdroid/test/TestAppUtils.kt | 32 +++++--------- .../kotlin/org/fdroid/test/TestDataV2.kt | 40 +++++++---------- .../sharedTest/resources/index-max-v2.json | 44 +++++++++---------- .../sharedTest/resources/index-mid-v2.json | 18 ++++---- 6 files changed, 77 insertions(+), 127 deletions(-) diff --git a/index/src/commonMain/kotlin/org/fdroid/index/v1/AppV1.kt b/index/src/commonMain/kotlin/org/fdroid/index/v1/AppV1.kt index 78750b765..65cad28f5 100644 --- a/index/src/commonMain/kotlin/org/fdroid/index/v1/AppV1.kt +++ b/index/src/commonMain/kotlin/org/fdroid/index/v1/AppV1.kt @@ -3,8 +3,6 @@ package org.fdroid.index.v1 import kotlinx.serialization.Serializable import org.fdroid.index.DEFAULT_LOCALE import org.fdroid.index.mapValuesNotNull -import org.fdroid.index.v2.Author -import org.fdroid.index.v2.Donation import org.fdroid.index.v2.FileV2 import org.fdroid.index.v2.LocalizedFileListV2 import org.fdroid.index.v2.LocalizedFileV2 @@ -63,21 +61,17 @@ public data class AppV1( translation = translation, preferredSigner = preferredSigner, categories = categories, - author = Author( - name = authorName, - email = authorEmail, - website = authorWebSite, - phone = authorPhone, - ).takeIf { !it.isNull }, - donation = Donation( - url = donate, - liberapayID = liberapayID, - liberapay = liberapay, - openCollective = openCollective, - bitcoin = bitcoin, - litecoin = litecoin, - flattrID = flattrID, - ).takeIf { !it.isNull }, + authorName = authorName, + authorEmail = authorEmail, + authorWebSite = authorWebSite, + authorPhone = authorPhone, + donate = if (donate == null) emptyList() else listOf(donate), + liberapayID = liberapayID, + liberapay = liberapay, + openCollective = openCollective, + bitcoin = bitcoin, + litecoin = litecoin, + flattrID = flattrID, icon = localized.toLocalizedFileV2 { it.icon } ?: icon?.let { mapOf(locale to FileV2("/icons/$it")) }, featureGraphic = localized.toLocalizedFileV2 { it.featureGraphic }, diff --git a/index/src/commonMain/kotlin/org/fdroid/index/v2/PackageV2.kt b/index/src/commonMain/kotlin/org/fdroid/index/v2/PackageV2.kt index aea83b28c..e57b4406a 100644 --- a/index/src/commonMain/kotlin/org/fdroid/index/v2/PackageV2.kt +++ b/index/src/commonMain/kotlin/org/fdroid/index/v2/PackageV2.kt @@ -24,8 +24,17 @@ public data class MetadataV2( val translation: String? = null, val preferredSigner: String? = null, val categories: List = emptyList(), - val author: Author? = null, - val donation: Donation? = null, + val authorName: String? = null, + val authorEmail: String? = null, + val authorWebSite: String? = null, + val authorPhone: String? = null, + val donate: List = emptyList(), + val liberapayID: String? = null, + val liberapay: String? = null, + val openCollective: String? = null, + val bitcoin: String? = null, + val litecoin: String? = null, + val flattrID: String? = null, val icon: LocalizedFileV2? = null, val featureGraphic: LocalizedFileV2? = null, val promoGraphic: LocalizedFileV2? = null, @@ -34,35 +43,6 @@ public data class MetadataV2( val screenshots: Screenshots? = null, ) -@Serializable -public data class Author( - val name: String? = null, - val email: String? = null, - val website: String? = null, - val phone: String? = null, -) { - internal constructor() : this(null, null, null, null) - - val isNull: Boolean get() = (name == null && email == null && website == null && phone == null) -} - -@Serializable -public data class Donation( - val url: String? = null, - val liberapayID: String? = null, - val liberapay: String? = null, - val openCollective: String? = null, - val bitcoin: String? = null, - val litecoin: String? = null, - val flattrID: String? = null, -) { - internal constructor() : this(null, null, null, null, null, null, null) - - val isNull: Boolean - get() = url == null && liberapayID == null && liberapay == null && - openCollective == null && bitcoin == null && litecoin == null && flattrID == null -} - @Serializable public data class Screenshots( val phone: LocalizedFileListV2? = null, diff --git a/index/src/sharedTest/kotlin/org/fdroid/test/TestAppUtils.kt b/index/src/sharedTest/kotlin/org/fdroid/test/TestAppUtils.kt index 766467d0b..29cf469db 100644 --- a/index/src/sharedTest/kotlin/org/fdroid/test/TestAppUtils.kt +++ b/index/src/sharedTest/kotlin/org/fdroid/test/TestAppUtils.kt @@ -1,7 +1,5 @@ package org.fdroid.test -import org.fdroid.index.v2.Author -import org.fdroid.index.v2.Donation import org.fdroid.index.v2.FileV2 import org.fdroid.index.v2.LocalizedFileListV2 import org.fdroid.index.v2.MetadataV2 @@ -31,8 +29,17 @@ public object TestAppUtils { translation = getRandomString().orNull(), preferredSigner = getRandomString().orNull(), video = getRandomLocalizedTextV2().orNull(), - author = getRandomAuthor().orNull(), - donation = getRandomDonation().orNull(), + authorName = getRandomString().orNull(), + authorEmail = getRandomString().orNull(), + authorWebSite = getRandomString().orNull(), + authorPhone = getRandomString().orNull(), + donate = getRandomList(Random.nextInt(0, 3)) { getRandomString() }, + liberapay = getRandomString().orNull(), + liberapayID = getRandomString().orNull(), + openCollective = getRandomString().orNull(), + bitcoin = getRandomString().orNull(), + litecoin = getRandomString().orNull(), + flattrID = getRandomString().orNull(), icon = getRandomLocalizedFileV2().orNull(), featureGraphic = getRandomLocalizedFileV2().orNull(), promoGraphic = getRandomLocalizedFileV2().orNull(), @@ -42,23 +49,6 @@ public object TestAppUtils { screenshots = getRandomScreenshots().orNull(), ) - public fun getRandomAuthor(): Author = Author( - name = getRandomString().orNull(), - email = getRandomString().orNull(), - website = getRandomString().orNull(), - phone = getRandomString().orNull(), - ) - - public fun getRandomDonation(): Donation = Donation( - url = getRandomString().orNull(), - liberapay = getRandomString().orNull(), - liberapayID = getRandomString().orNull(), - openCollective = getRandomString().orNull(), - bitcoin = getRandomString().orNull(), - litecoin = getRandomString().orNull(), - flattrID = getRandomString().orNull(), - ) - public fun getRandomScreenshots(): Screenshots? = Screenshots( phone = getRandomLocalizedFileListV2().orNull(), sevenInch = getRandomLocalizedFileListV2().orNull(), diff --git a/index/src/sharedTest/kotlin/org/fdroid/test/TestDataV2.kt b/index/src/sharedTest/kotlin/org/fdroid/test/TestDataV2.kt index 4b3bbbf1b..f104542ad 100644 --- a/index/src/sharedTest/kotlin/org/fdroid/test/TestDataV2.kt +++ b/index/src/sharedTest/kotlin/org/fdroid/test/TestDataV2.kt @@ -3,9 +3,7 @@ package org.fdroid.test import org.fdroid.index.RELEASE_CHANNEL_BETA import org.fdroid.index.getV1ReleaseChannels import org.fdroid.index.v2.AntiFeatureV2 -import org.fdroid.index.v2.Author import org.fdroid.index.v2.CategoryV2 -import org.fdroid.index.v2.Donation import org.fdroid.index.v2.FeatureV2 import org.fdroid.index.v2.FileV1 import org.fdroid.index.v2.FileV2 @@ -263,7 +261,7 @@ internal object TestDataMidV2 { LOCALE to "App1", "de" to "app 1 name", ), - author = Author(name = "App1 author"), + authorName = "App1 author", license = "GPLv3", webSite = "http://min1.test.org", icon = mapOf( @@ -574,12 +572,10 @@ internal object TestDataMidV2 { translation = "https://hosted.weblate.org/projects/f-droid/f-droid", issueTracker = "https://gitlab.com/fdroid/fdroidclient/issues", sourceCode = "https://gitlab.com/fdroid/fdroidclient", - donation = Donation( - url = "https://f-droid.org/donate", - liberapayID = "27859", - openCollective = "F-Droid-Euro", - flattrID = "343053", - ), + donate = listOf("https://f-droid.org/donate"), + liberapayID = "27859", + openCollective = "F-Droid-Euro", + flattrID = "343053", preferredSigner = "43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab", license = "GPL-3.0-or-later", webSite = "https://f-droid.org", @@ -1053,21 +1049,17 @@ internal object TestDataMaxV2 { translation = "translation3", preferredSigner = "43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab", categories = listOf("Cat1", "Cat2", "Cat3"), - author = Author( - name = "App3 author", - email = "email", - website = "website", - phone = "phone", - ), - donation = Donation( - url = "donate", - liberapayID = "liberapayID", - liberapay = "liberapay", - openCollective = "openCollective", - bitcoin = "bitcoin", - litecoin = "litecoin", - flattrID = "flattrID", - ), + authorName = "App3 author", + authorEmail = "email", + authorWebSite = "website", + authorPhone = "phone", + donate = listOf("donate"), + liberapayID = "liberapayID", + liberapay = "liberapay", + openCollective = "openCollective", + bitcoin = "bitcoin", + litecoin = "litecoin", + flattrID = "flattrID", icon = mapOf( "en" to FileV2( name = "/Haoheiseeshai2que2Che0ooSa6aikeemoo2ap9Aequoh4ju5chooYuPhiev8moodahl" + diff --git a/index/src/sharedTest/resources/index-max-v2.json b/index/src/sharedTest/resources/index-max-v2.json index d8f15f5d5..842e973a0 100644 --- a/index/src/sharedTest/resources/index-max-v2.json +++ b/index/src/sharedTest/resources/index-max-v2.json @@ -153,9 +153,7 @@ "categories": [ "Cat1" ], - "author": { - "name": "App1 author" - }, + "authorName": "App1 author", "icon": { "en-US": { "name": "/icons/icon-min1.png", @@ -230,12 +228,12 @@ "NoMoreSystem", "OneMore" ], - "donation": { - "url": "https://f-droid.org/donate", - "liberapayID": "27859", - "openCollective": "F-Droid-Euro", - "flattrID": "343053" - }, + "donate": [ + "https://f-droid.org/donate" + ], + "liberapayID": "27859", + "openCollective": "F-Droid-Euro", + "flattrID": "343053", "icon": { "en-US": { "name": "/org.fdroid.fdroid/en-US/new icon", @@ -600,21 +598,19 @@ "Cat2", "Cat3" ], - "author": { - "name": "App3 author", - "email": "email", - "website": "website", - "phone": "phone" - }, - "donation": { - "url": "donate", - "liberapayID": "liberapayID", - "liberapay": "liberapay", - "openCollective": "openCollective", - "bitcoin": "bitcoin", - "litecoin": "litecoin", - "flattrID": "flattrID" - }, + "authorName": "App3 author", + "authorEmail": "email", + "authorWebSite": "website", + "authorPhone": "phone", + "donate": [ + "donate" + ], + "liberapayID": "liberapayID", + "liberapay": "liberapay", + "openCollective": "openCollective", + "bitcoin": "bitcoin", + "litecoin": "litecoin", + "flattrID": "flattrID", "icon": { "en": { "name": "/Haoheiseeshai2que2Che0ooSa6aikeemoo2ap9Aequoh4ju5chooYuPhiev8moodahlonu2oht5Eikahvushapeum5aefo6xig4aghahyaaNuezoo4eexee1Goo5UngohGha6quaeghe8uCh9iex9Oowa9aiyohzoo2ij5miifiegaeth8nie9jae6raephoowishoor1Ien5vahGhahm7eidaiy2AeCaej9iexahyooshu2ic9tea1ool8tu4Y/en/en ", diff --git a/index/src/sharedTest/resources/index-mid-v2.json b/index/src/sharedTest/resources/index-mid-v2.json index a6cb2b8cb..c31e3212f 100644 --- a/index/src/sharedTest/resources/index-mid-v2.json +++ b/index/src/sharedTest/resources/index-mid-v2.json @@ -49,7 +49,7 @@ "metadata": { "name": { "en-US": "App1", - "de" : "app 1 name" + "de": "app 1 name" }, "summary": { "en-US": "App1 summary", @@ -66,9 +66,7 @@ "categories": [ "Cat1" ], - "author": { - "name": "App1 author" - }, + "authorName": "App1 author", "icon": { "en-US": { "name": "/icons/icon-min1.png", @@ -165,12 +163,12 @@ "categories": [ "System" ], - "donation": { - "url": "https://f-droid.org/donate", - "liberapayID": "27859", - "openCollective": "F-Droid-Euro", - "flattrID": "343053" - }, + "donate": [ + "https://f-droid.org/donate" + ], + "liberapayID": "27859", + "openCollective": "F-Droid-Euro", + "flattrID": "343053", "icon": { "en-US": { "name": "/icons/org.fdroid.fdroid.1014050.png",