Skip to content

Commit

Permalink
Merge release/7.79 into main (#3349)
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Halligon <[email protected]>
Co-authored-by: Michał Sikora <[email protected]>
Co-authored-by: Philip Simpson <[email protected]>
Co-authored-by: Ashita Agrawal <[email protected]>
Co-authored-by: Philip Simpson <[email protected]>
  • Loading branch information
6 people authored Dec 10, 2024
1 parent b0ce4f3 commit 1649f2e
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 52 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
source 'https://rubygems.org'

gem 'danger-dangermattic', '~> 1.2.1'
gem 'fastlane', '~> 2.216'
# gem 'fastlane', '~> 2.216' # FIXME: Switch back to official release once https://github.com/fastlane/fastlane/pull/28960 is merged and included in next release
gem 'fastlane', git: '[email protected]:fastlane/fastlane.git', branch: 'supply/update-draft-release-status'

# These lines are kept to help with testing Release Toolkit changes
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 12.3'
# gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../release-toolkit'
Expand Down
98 changes: 52 additions & 46 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
GIT
remote: [email protected]:fastlane/fastlane.git
revision: 86a97f5dd0c9779b120ccfb5090ba415913d9815
branch: supply/update-draft-release-status
specs:
fastlane (2.225.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored (~> 1.2)
commander (~> 4.6)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
excon (>= 0.71.0, < 1.0.0)
faraday (~> 1.0)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
fastlane-sirp (>= 1.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-env (>= 1.6.0, < 2.0.0)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
http-cookie (~> 1.0.5)
json (< 3.0.0)
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (>= 2.0.0, < 3.0.0)
naturally (~> 2.2)
optparse (>= 0.1.1, < 1.0.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.5)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 3)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.4.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -123,48 +171,6 @@ GEM
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.225.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored (~> 1.2)
commander (~> 4.6)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
excon (>= 0.71.0, < 1.0.0)
faraday (~> 1.0)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
fastlane-sirp (>= 1.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-env (>= 1.6.0, < 2.0.0)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
http-cookie (~> 1.0.5)
json (< 3.0.0)
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (>= 2.0.0, < 3.0.0)
naturally (~> 2.2)
optparse (>= 0.1.1, < 1.0.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.5)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 3)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-wpmreleasetoolkit (12.3.4)
activesupport (>= 6.1.7.1)
buildkit (~> 1.5)
Expand Down Expand Up @@ -288,7 +294,7 @@ GEM
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.3.9)
rouge (2.0.7)
rouge (3.28.0)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down Expand Up @@ -339,8 +345,8 @@ GEM
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty (0.4.0)
rouge (~> 3.28.0)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)

Expand All @@ -355,7 +361,7 @@ PLATFORMS

DEPENDENCIES
danger-dangermattic (~> 1.2.1)
fastlane (~> 2.216)
fastlane!
fastlane-plugin-wpmreleasetoolkit (~> 12.3)

BUNDLED WITH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.core.graphics.applyCanvas
import androidx.core.graphics.createBitmap
import androidx.core.graphics.drawable.toBitmap
import androidx.core.graphics.scale
import au.com.shiftyjelly.pocketcasts.endofyear.ui.backgroundColor
import au.com.shiftyjelly.pocketcasts.models.to.Story
import au.com.shiftyjelly.pocketcasts.utils.fitToAspectRatio
import au.com.shiftyjelly.pocketcasts.utils.log.LogBuffer
import au.com.shiftyjelly.pocketcasts.utils.log.LogBuffer.TAG_CRASH
import dev.shreyaspatil.capturable.controller.CaptureController
Expand Down Expand Up @@ -77,7 +79,7 @@ internal fun rememberStoryCaptureController(): StoryCaptureController {
delay(50) // A small delay to settle stories animations before capturing a screenshot
val controller = captureController(story)
val file = runCatching {
val bitmap: Bitmap = withContext(Dispatchers.Default) {
val bitmap = withContext(Dispatchers.Default) {
val background = controller.captureAsync().await()
.asAndroidBitmap()
.copy(Bitmap.Config.ARGB_8888, false)
Expand All @@ -88,7 +90,7 @@ internal fun rememberStoryCaptureController(): StoryCaptureController {
.toBitmap()
.scale(width = logoWidth, height = logoHeight)

Bitmap.createBitmap(background.width, background.height, Bitmap.Config.ARGB_8888).applyCanvas {
createBitmap(background.width, background.height).applyCanvas {
// Draw captured bitmap
drawBitmap(background, 0f, 0f, null)
// Hide bottom button behind an empty rect
Expand All @@ -110,7 +112,7 @@ internal fun rememberStoryCaptureController(): StoryCaptureController {
(height - buttonHeightPx + (buttonHeightPx - pcLogo.height) / 2).toFloat(),
null,
)
}
}.fitToAspectRatio(9f / 16)
}
withContext(Dispatchers.IO) {
val file = File(context.cacheDir, "pocket-casts-playback-screenshot.png")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package au.com.shiftyjelly.pocketcasts.utils

import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Paint
import androidx.annotation.ColorInt
import androidx.core.graphics.applyCanvas
import kotlin.math.abs
import kotlin.math.roundToInt

fun Bitmap.fitToAspectRatio(
aspectRatio: Float,
@ColorInt backgroundColor: Int = Color.BLACK,
bitmapConfig: Bitmap.Config = Bitmap.Config.ARGB_8888,
): Bitmap {
val (newWidth, newHeight) = calculateNearestSize(width, height, aspectRatio)
return Bitmap.createBitmap(newWidth, newHeight, bitmapConfig).applyCanvas {
val paint = Paint().apply {
isDither = true
color = backgroundColor
}
drawRect(0f, 0f, width.toFloat(), height.toFloat(), paint)
drawBitmap(
this@fitToAspectRatio,
abs(width - this@fitToAspectRatio.width).toFloat() / 2,
abs(height - this@fitToAspectRatio.height).toFloat() / 2,
null,
)
}
}

internal fun calculateNearestSize(
width: Int,
height: Int,
aspectRatio: Float,
): Pair<Int, Int> {
check(aspectRatio > 0) { "Aspect ratio must be a positive number: $aspectRatio" }
return when (width.toFloat() / height) {
aspectRatio -> width to height
in 0f..aspectRatio -> (height * aspectRatio).roundToInt() to height
else -> width to (width / aspectRatio).roundToInt()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package au.com.shiftyjelly.pocketcasts.utils

import org.junit.Assert.assertEquals
import org.junit.Test

class BitmapUtilTest {
@Test
fun `fail for zero aspect ratio`() {
try {
calculateNearestSize(0, 0, aspectRatio = 0f)
} catch (e: IllegalStateException) {
assertEquals("Aspect ratio must be a positive number: 0.0", e.message)
}
}

@Test
fun `fail for negative aspect ratio`() {
try {
calculateNearestSize(0, 0, aspectRatio = -1f)
} catch (e: IllegalStateException) {
assertEquals("Aspect ratio must be a positive number: -1.0", e.message)
}
}

@Test
fun `calculate to fit horizontally`() {
val size = calculateNearestSize(width = 100, height = 200, aspectRatio = 9f / 16)

assertEquals(113 to 200, size)
}

@Test
fun `calculate to fit vertically`() {
val size = calculateNearestSize(width = 200, height = 100, aspectRatio = 9f / 16)

assertEquals(200 to 356, size)
}
}
4 changes: 2 additions & 2 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=7.79-rc-1
versionCode=9293
versionName=7.79-rc-2
versionCode=9295

0 comments on commit 1649f2e

Please sign in to comment.