diff --git a/android/app/src/main/kotlin/com/org/yumiparty/GiftMp4VideoPlatformView.kt b/android/app/src/main/kotlin/com/org/yumiparty/GiftMp4VideoPlatformView.kt index a616159..bc59201 100644 --- a/android/app/src/main/kotlin/com/org/yumiparty/GiftMp4VideoPlatformView.kt +++ b/android/app/src/main/kotlin/com/org/yumiparty/GiftMp4VideoPlatformView.kt @@ -440,7 +440,12 @@ private class GiftMp4AlphaRenderer( GLES20.glViewport(0, 0, viewWidth, viewHeight) GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT) - val viewport = contentViewport(viewWidth, viewHeight, layout.contentAspectRatio) + val viewport = contentViewport( + viewWidth, + viewHeight, + layout.contentAspectRatio, + cover = !layout.hasAlphaMask, + ) GLES20.glViewport(viewport.x, viewport.y, viewport.width, viewport.height) GLES20.glUseProgram(program) GLES20.glActiveTexture(GLES20.GL_TEXTURE0) @@ -610,6 +615,20 @@ private data class GiftMp4NativeLayout( fun defaultLayout(): GiftMp4NativeLayout = GiftMp4NativeLayout(GiftMp4Rect(0f, 0f, 1f, 1f), null) + fun normalLayout(width: Int, height: Int): GiftMp4NativeLayout { + val aspectRatio = + if (width > 0 && height > 0) { + width.toFloat() / height.toFloat() + } else { + 1f + } + return GiftMp4NativeLayout( + GiftMp4Rect(0f, 0f, 1f, 1f), + null, + aspectRatio, + ) + } + fun fromCreationParams(data: Any?): GiftMp4NativeLayout? = runCatching { val map = data as? Map<*, *> ?: return null val color = readLayoutRect(map["colorRect"]) ?: return null @@ -709,12 +728,15 @@ private data class GiftMp4NativeLayout( val best = sortedCandidates.firstOrNull() val runnerUpScore = sortedCandidates.drop(1).firstOrNull()?.score ?: 0.0 val selected = - if (best != null && (best.score - runnerUpScore >= 0.12 || best.score >= 0.35)) { - best.candidate - } else { - candidates.first() - } + best?.takeIf { + it.score - runnerUpScore >= 0.12 || it.score >= 0.35 + }?.candidate + val bitmapWidth = bitmap.width + val bitmapHeight = bitmap.height bitmap.recycle() + if (selected == null) { + return normalLayout(bitmapWidth, bitmapHeight) + } return GiftMp4NativeLayout(selected.colorRect, selected.alphaRect) } @@ -1056,12 +1078,18 @@ private data class GiftMp4FrameStats( val colorScore: Double, ) -private fun contentViewport(width: Int, height: Int, aspectRatio: Float): GiftMp4Viewport { +private fun contentViewport( + width: Int, + height: Int, + aspectRatio: Float, + cover: Boolean, +): GiftMp4Viewport { if (width <= 0 || height <= 0 || aspectRatio <= 0f) { return GiftMp4Viewport(0, 0, width, height) } val viewAspect = width.toFloat() / height - return if (viewAspect > aspectRatio) { + val fitByHeight = if (cover) viewAspect <= aspectRatio else viewAspect > aspectRatio + return if (fitByHeight) { val contentWidth = (height * aspectRatio).toInt().coerceAtLeast(1) GiftMp4Viewport((width - contentWidth) / 2, 0, contentWidth, height) } else { diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index ace10e4..2aea2e3 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -524,7 +524,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/RunnerRelease.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1620; + CURRENT_PROJECT_VERSION = 1630; DEVELOPMENT_TEAM = S9YG87C297; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -533,7 +533,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.6.2; + MARKETING_VERSION = 1.6.3; PRODUCT_BUNDLE_IDENTIFIER = com.org.yumiparty; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -715,7 +715,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1620; + CURRENT_PROJECT_VERSION = 1630; DEVELOPMENT_TEAM = S9YG87C297; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -724,7 +724,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.6.2; + MARKETING_VERSION = 1.6.3; PRODUCT_BUNDLE_IDENTIFIER = com.org.yumiparty; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -744,7 +744,7 @@ CODE_SIGN_ENTITLEMENTS = Runner/RunnerRelease.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1620; + CURRENT_PROJECT_VERSION = 1630; DEVELOPMENT_TEAM = S9YG87C297; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; @@ -753,7 +753,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.6.2; + MARKETING_VERSION = 1.6.3; PRODUCT_BUNDLE_IDENTIFIER = com.org.yumiparty; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/ios/Runner/GiftMp4VideoPlatformView.swift b/ios/Runner/GiftMp4VideoPlatformView.swift index 7936023..46cc605 100644 --- a/ios/Runner/GiftMp4VideoPlatformView.swift +++ b/ios/Runner/GiftMp4VideoPlatformView.swift @@ -163,6 +163,7 @@ private final class GiftMp4AlphaVideoView: UIView { imageView.isOpaque = false imageView.backgroundColor = .clear imageView.contentMode = .scaleAspectFit + imageView.clipsToBounds = true addSubview(imageView) } @@ -191,6 +192,7 @@ private final class GiftMp4AlphaVideoView: UIView { fileURL: url, cacheKey: source.cacheKey ) + imageView.contentMode = sourceLayout.hasAlphaMask ? .scaleAspectFit : .scaleAspectFill let item = AVPlayerItem(asset: asset) let output = AVPlayerItemVideoOutput(pixelBufferAttributes: [ diff --git a/lib/modules/gift/gift_page.dart b/lib/modules/gift/gift_page.dart index 12efe0d..df5b1fd 100644 --- a/lib/modules/gift/gift_page.dart +++ b/lib/modules/gift/gift_page.dart @@ -174,7 +174,7 @@ class _GiftPageState extends State with TickerProviderStateMixin { Provider.of( context, listen: false, - ).giftList(includeCustomized: false); + ).giftList(includeCustomized: true); Provider.of(context, listen: false).giftActivityList(); unawaited( Provider.of( @@ -271,7 +271,6 @@ class _GiftPageState extends State with TickerProviderStateMixin { final availableTypes = ref.giftByTab.entries .where((entry) => entry.value.isNotEmpty) - .where((entry) => entry.key != "CUSTOMIZED") .where((entry) => entry.key != _backpackGiftTab) .map((entry) => entry.key) .toList(); diff --git a/lib/services/general/sc_app_general_manager.dart b/lib/services/general/sc_app_general_manager.dart index e54c9cc..611c954 100644 --- a/lib/services/general/sc_app_general_manager.dart +++ b/lib/services/general/sc_app_general_manager.dart @@ -213,24 +213,28 @@ class SCAppGeneralManager extends ChangeNotifier { } } + String _displayGiftTab(String? giftTab) { + return giftTab == "EXCLUSIVE" ? "CUSTOMIZED" : (giftTab ?? ""); + } + void _rebuildGiftTabs({required bool includeCustomized}) { giftByTab.clear(); _giftByIdMap.clear(); _giftByStandardIdMap.clear(); for (var gift in giftResList) { - giftByTab[gift.giftTab]; - var gmap = giftByTab[gift.giftTab]; + final tab = _displayGiftTab(gift.giftTab); + var gmap = giftByTab[tab]; gmap ??= []; gmap.add(gift); - giftByTab[gift.giftTab!] = gmap; + giftByTab[tab] = gmap; var gAllMap = giftByTab["ALL"]; gAllMap ??= []; - if (gift.giftTab != "NSCIONAL_FLAG" && - gift.giftTab != "ACTIVITY" && - gift.giftTab != "LUCKY_GIFT" && - gift.giftTab != "CP" && - gift.giftTab != "CUSTOMIZED" && - gift.giftTab != "MAGIC") { + if (tab != "NSCIONAL_FLAG" && + tab != "ACTIVITY" && + tab != "LUCKY_GIFT" && + tab != "CP" && + tab != "CUSTOMIZED" && + tab != "MAGIC") { gAllMap.add(gift); } giftByTab["ALL"] = gAllMap; diff --git a/pubspec.yaml b/pubspec.yaml index a45f372..1eb64fd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.6.2+1620 +version: 1.6.3+1630 environment: