Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Hosted Weblate 2025-02-13 23:01:53 +00:00
commit 1b1a183213
No known key found for this signature in database
GPG key ID: A3FAAA06E6569B4C
9 changed files with 38 additions and 6 deletions

View file

@ -15,6 +15,7 @@ import android.os.Looper
import android.util.Log import android.util.Log
import android.util.SizeF import android.util.SizeF
import android.widget.RemoteViews import android.widget.RemoteViews
import androidx.core.graphics.createBitmap
import androidx.core.net.toUri import androidx.core.net.toUri
import app.loup.streams_channel.StreamsChannel import app.loup.streams_channel.StreamsChannel
import deckers.thibault.aves.channel.AvesByteSendingMethodCodec import deckers.thibault.aves.channel.AvesByteSendingMethodCodec
@ -218,7 +219,7 @@ class HomeWidgetProvider : AppWidgetProvider() {
val heightPx = (sizeDip.height * devicePixelRatio).roundToInt() val heightPx = (sizeDip.height * devicePixelRatio).roundToInt()
try { try {
val bitmap = Bitmap.createBitmap(widthPx, heightPx, Bitmap.Config.ARGB_8888).also { val bitmap = createBitmap(widthPx, heightPx, Bitmap.Config.ARGB_8888).also {
bitmaps.add(it) bitmaps.add(it)
it.copyPixelsFromBuffer(ByteBuffer.wrap(bytes)) it.copyPixelsFromBuffer(ByteBuffer.wrap(bytes))
} }

View file

@ -6,6 +6,7 @@ import android.graphics.Canvas
import android.graphics.Rect import android.graphics.Rect
import android.graphics.RectF import android.graphics.RectF
import android.net.Uri import android.net.Uri
import androidx.core.graphics.createBitmap
import com.caverock.androidsvg.PreserveAspectRatio import com.caverock.androidsvg.PreserveAspectRatio
import com.caverock.androidsvg.RenderOptions import com.caverock.androidsvg.RenderOptions
import com.caverock.androidsvg.SVG import com.caverock.androidsvg.SVG
@ -100,7 +101,7 @@ class SvgRegionFetcher internal constructor(
return return
} }
var bitmap = Bitmap.createBitmap( var bitmap = createBitmap(
targetBitmapWidth + bleedX * 2, targetBitmapWidth + bleedX * 2,
targetBitmapHeight + bleedY * 2, targetBitmapHeight + bleedY * 2,
Bitmap.Config.ARGB_8888 Bitmap.Config.ARGB_8888

View file

@ -77,8 +77,12 @@ class ActivityWindowHandler(private val activity: Activity) : WindowHandler(acti
) )
} }
override fun supportsWideGamut(call: MethodCall, result: MethodChannel.Result) {
result.success(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && activity.resources.configuration.isScreenWideColorGamut)
}
override fun supportsHdr(call: MethodCall, result: MethodChannel.Result) { override fun supportsHdr(call: MethodCall, result: MethodChannel.Result) {
result.success(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && activity.getDisplayCompat()?.isHdr ?: false) result.success(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && activity.resources.configuration.isScreenHdr)
} }
override fun setHdrColorMode(call: MethodCall, result: MethodChannel.Result) { override fun setHdrColorMode(call: MethodCall, result: MethodChannel.Result) {

View file

@ -29,6 +29,10 @@ class ServiceWindowHandler(service: Service) : WindowHandler(service) {
result.success(HashMap<String, Any>()) result.success(HashMap<String, Any>())
} }
override fun supportsWideGamut(call: MethodCall, result: MethodChannel.Result) {
result.success(false)
}
override fun supportsHdr(call: MethodCall, result: MethodChannel.Result) { override fun supportsHdr(call: MethodCall, result: MethodChannel.Result) {
result.success(false) result.success(false)
} }

View file

@ -18,6 +18,7 @@ abstract class WindowHandler(private val contextWrapper: ContextWrapper) : Metho
"requestOrientation" -> Coresult.safe(call, result, ::requestOrientation) "requestOrientation" -> Coresult.safe(call, result, ::requestOrientation)
"isCutoutAware" -> Coresult.safe(call, result, ::isCutoutAware) "isCutoutAware" -> Coresult.safe(call, result, ::isCutoutAware)
"getCutoutInsets" -> Coresult.safe(call, result, ::getCutoutInsets) "getCutoutInsets" -> Coresult.safe(call, result, ::getCutoutInsets)
"supportsWideGamut" -> Coresult.safe(call, result, ::supportsWideGamut)
"supportsHdr" -> Coresult.safe(call, result, ::supportsHdr) "supportsHdr" -> Coresult.safe(call, result, ::supportsHdr)
"setHdrColorMode" -> Coresult.safe(call, result, ::setHdrColorMode) "setHdrColorMode" -> Coresult.safe(call, result, ::setHdrColorMode)
else -> result.notImplemented() else -> result.notImplemented()
@ -46,6 +47,8 @@ abstract class WindowHandler(private val contextWrapper: ContextWrapper) : Metho
abstract fun getCutoutInsets(call: MethodCall, result: MethodChannel.Result) abstract fun getCutoutInsets(call: MethodCall, result: MethodChannel.Result)
abstract fun supportsWideGamut(call: MethodCall, result: MethodChannel.Result)
abstract fun supportsHdr(call: MethodCall, result: MethodChannel.Result) abstract fun supportsHdr(call: MethodCall, result: MethodChannel.Result)
abstract fun setHdrColorMode(call: MethodCall, result: MethodChannel.Result) abstract fun setHdrColorMode(call: MethodCall, result: MethodChannel.Result)

View file

@ -22,6 +22,7 @@ import deckers.thibault.aves.metadata.SVGParserBufferedInputStream
import deckers.thibault.aves.metadata.SvgHelper.normalizeSize import deckers.thibault.aves.metadata.SvgHelper.normalizeSize
import deckers.thibault.aves.utils.StorageUtils import deckers.thibault.aves.utils.StorageUtils
import kotlin.math.ceil import kotlin.math.ceil
import androidx.core.graphics.createBitmap
@GlideModule @GlideModule
class SvgGlideModule : LibraryGlideModule() { class SvgGlideModule : LibraryGlideModule() {
@ -68,7 +69,7 @@ internal class SvgFetcher(val model: SvgImage, val width: Int, val height: Int)
bitmapWidth = width bitmapWidth = width
bitmapHeight = ceil(svgHeight * width / svgWidth).toInt() bitmapHeight = ceil(svgHeight * width / svgWidth).toInt()
} }
val bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888) val bitmap = createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap) val canvas = Canvas(bitmap)
svg.renderToCanvas(canvas) svg.renderToCanvas(canvas)

View file

@ -18,6 +18,8 @@ abstract class WindowService {
Future<EdgeInsets> getCutoutInsets(); Future<EdgeInsets> getCutoutInsets();
Future<bool> supportsWideGamut();
Future<bool> supportsHdr(); Future<bool> supportsHdr();
Future<void> setHdrColorMode(bool on); Future<void> setHdrColorMode(bool on);
@ -26,7 +28,7 @@ abstract class WindowService {
class PlatformWindowService implements WindowService { class PlatformWindowService implements WindowService {
static const _platform = MethodChannel('deckers.thibault/aves/window'); static const _platform = MethodChannel('deckers.thibault/aves/window');
bool? _isCutoutAware, _supportsHdr; bool? _isCutoutAware, _supportsHdr, _supportsWideGamut;
@override @override
Future<bool> isActivity() async { Future<bool> isActivity() async {
@ -126,6 +128,18 @@ class PlatformWindowService implements WindowService {
return EdgeInsets.zero; return EdgeInsets.zero;
} }
@override
Future<bool> supportsWideGamut() async {
if (_supportsWideGamut != null) return SynchronousFuture(_supportsWideGamut!);
try {
final result = await _platform.invokeMethod('supportsWideGamut');
_supportsWideGamut = result as bool?;
} on PlatformException catch (e, stack) {
await reportService.recordError(e, stack);
}
return _supportsWideGamut ?? false;
}
@override @override
Future<bool> supportsHdr() async { Future<bool> supportsHdr() async {
if (_supportsHdr != null) return SynchronousFuture(_supportsHdr!); if (_supportsHdr != null) return SynchronousFuture(_supportsHdr!);

View file

@ -157,6 +157,7 @@ class _BugReportState extends State<BugReport> with FeedbackMixin {
final mediaQuery = MediaQuery.of(context); final mediaQuery = MediaQuery.of(context);
final view = View.of(context); final view = View.of(context);
final supportsHdr = await windowService.supportsHdr(); final supportsHdr = await windowService.supportsHdr();
final supportsWideGamut = await windowService.supportsWideGamut();
final connections = await Connectivity().checkConnectivity(); final connections = await Connectivity().checkConnectivity();
final storageVolumes = await storageService.getStorageVolumes(); final storageVolumes = await storageService.getStorageVolumes();
final storageGrants = await storageService.getGrantedDirectories(); final storageGrants = await storageService.getGrantedDirectories();
@ -169,7 +170,7 @@ class _BugReportState extends State<BugReport> with FeedbackMixin {
'Android build: ${androidInfo.display}', 'Android build: ${androidInfo.display}',
'Device: ${androidInfo.manufacturer} ${androidInfo.model}', 'Device: ${androidInfo.manufacturer} ${androidInfo.model}',
'Display: pixel ratio=${view.devicePixelRatio}, logical=${mediaQuery.size.width}x${mediaQuery.size.height}, physical=${view.physicalSize.width}x${view.physicalSize.height}', 'Display: pixel ratio=${view.devicePixelRatio}, logical=${mediaQuery.size.width}x${mediaQuery.size.height}, physical=${view.physicalSize.width}x${view.physicalSize.height}',
'Support: dynamic colors=${device.isDynamicColorAvailable}, geocoder=${device.hasGeocoder}, HDR=$supportsHdr', 'Support: dynamic colors=${device.isDynamicColorAvailable}, geocoder=${device.hasGeocoder}, HDR=$supportsHdr, wide gamut=$supportsWideGamut',
'Mobile services: ${mobileServices.isServiceAvailable ? 'ready' : 'not available'}', 'Mobile services: ${mobileServices.isServiceAvailable ? 'ready' : 'not available'}',
'Connectivity: ${connections.map((v) => v.name).join(', ')}', 'Connectivity: ${connections.map((v) => v.name).join(', ')}',
'System locales: ${WidgetsBinding.instance.platformDispatcher.locales.join(', ')}', 'System locales: ${WidgetsBinding.instance.platformDispatcher.locales.join(', ')}',

View file

@ -27,6 +27,7 @@ class _DebugCapabilitiesSectionState extends State<DebugCapabilitiesSection> wit
windowService.isCutoutAware(), windowService.isCutoutAware(),
windowService.isRotationLocked(), windowService.isRotationLocked(),
windowService.supportsHdr(), windowService.supportsHdr(),
windowService.supportsWideGamut(),
]); ]);
} }
@ -72,6 +73,7 @@ class _DebugCapabilitiesSectionState extends State<DebugCapabilitiesSection> wit
bool isCutoutAware, bool isCutoutAware,
bool isRotationLocked, bool isRotationLocked,
bool supportsHdr, bool supportsHdr,
bool supportsWideGamut,
] = data; ] = data;
return Padding( return Padding(
@ -85,6 +87,7 @@ class _DebugCapabilitiesSectionState extends State<DebugCapabilitiesSection> wit
'isCutoutAware': '$isCutoutAware', 'isCutoutAware': '$isCutoutAware',
'isRotationLocked': '$isRotationLocked', 'isRotationLocked': '$isRotationLocked',
'supportsHdr': '$supportsHdr', 'supportsHdr': '$supportsHdr',
'supportsWideGamut': '$supportsWideGamut',
}, },
), ),
], ],