mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-08 03:54:49 +08:00
@@ -357,6 +357,47 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
_$icon.pointer,
|
||||
).check();
|
||||
}
|
||||
|
||||
static final _id_enterPip = _class.staticMethodId(
|
||||
r'enterPip',
|
||||
r'(JII)V',
|
||||
);
|
||||
|
||||
static final _enterPip =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<(jni$_.Int64, jni$_.Int32, jni$_.Int32)>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void enterPip(long engineId, int width, int height)`
|
||||
static void enterPip(
|
||||
core$_.int engineId,
|
||||
core$_.int width,
|
||||
core$_.int height,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
_enterPip(
|
||||
_$$classRef.pointer,
|
||||
_id_enterPip.pointer,
|
||||
engineId,
|
||||
width,
|
||||
height,
|
||||
).check();
|
||||
}
|
||||
}
|
||||
|
||||
final class $AndroidHelper$Type$ extends jni$_.JType<AndroidHelper> {
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import 'package:floating/floating.dart';
|
||||
|
||||
extension RationalExt on Rational {
|
||||
/// Checks whether given [Rational] instance fits into Android requirements
|
||||
/// or not.
|
||||
///
|
||||
/// Android docs specified boundaries as inclusive.
|
||||
bool get fitsInAndroidRequirements {
|
||||
final aspectRatio = numerator / denominator;
|
||||
const min = 1 / 2.39;
|
||||
const max = 2.39;
|
||||
return (min <= aspectRatio) && (aspectRatio <= max);
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ import 'package:PiliPlus/pages/contact/view.dart';
|
||||
import 'package:PiliPlus/pages/fav_panel/view.dart';
|
||||
import 'package:PiliPlus/pages/share/view.dart';
|
||||
import 'package:PiliPlus/pages/webview/view.dart';
|
||||
import 'package:PiliPlus/utils/android/bindings.g.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/extension.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
@@ -29,8 +29,7 @@ import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/url_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:floating/floating.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/foundation.dart' show kDebugMode, PlatformDispatcher;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -183,22 +182,30 @@ abstract final class PageUtils {
|
||||
WebViewPage.toWebView('https://www.bilibili.com/appeal/?avid=$aid');
|
||||
}
|
||||
|
||||
static void enterPip({int? width, int? height, bool isAuto = false}) {
|
||||
if (width != null && height != null) {
|
||||
Rational aspectRatio = Rational(width, height);
|
||||
aspectRatio = aspectRatio.fitsInAndroidRequirements
|
||||
? aspectRatio
|
||||
: height > width
|
||||
? const Rational.vertical()
|
||||
: const Rational.landscape();
|
||||
Floating.enable(
|
||||
isAuto
|
||||
? AutoEnable(aspectRatio: aspectRatio)
|
||||
: EnableManual(aspectRatio: aspectRatio),
|
||||
);
|
||||
} else {
|
||||
Floating.enable(isAuto ? const AutoEnable() : const EnableManual());
|
||||
static bool _fitsInAndroidRequirements(int width, int height) {
|
||||
final aspectRatio = width / height;
|
||||
const min = 1 / 2.39;
|
||||
const max = 2.39;
|
||||
return (min <= aspectRatio) && (aspectRatio <= max);
|
||||
}
|
||||
|
||||
static void enterPip({int? width, int? height}) {
|
||||
if (width != null &&
|
||||
height != null &&
|
||||
!_fitsInAndroidRequirements(width, height)) {
|
||||
if (height > width) {
|
||||
width = 9;
|
||||
height = 16;
|
||||
} else {
|
||||
width = 16;
|
||||
height = 9;
|
||||
}
|
||||
}
|
||||
AndroidHelper.enterPip(
|
||||
PlatformDispatcher.instance.engineId!,
|
||||
width ?? 16,
|
||||
height ?? 9,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> pushDynDetail(
|
||||
|
||||
Reference in New Issue
Block a user