mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-03 01:28:17 +08:00
@@ -73,12 +73,18 @@ abstract final class PiliAndroidHelper {
|
||||
}
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
static void setPipAutoEnterEnabled(bool autoEnable) =>
|
||||
AndroidHelper.setPipAutoEnterEnabled(
|
||||
autoEnable,
|
||||
static void enterPip(int width, int height, bool autoEnter) =>
|
||||
AndroidHelper.enterPip(
|
||||
width,
|
||||
height,
|
||||
autoEnter,
|
||||
PlatformDispatcher.instance.engineId!,
|
||||
);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
static void disableAutoEnterPip() =>
|
||||
AndroidHelper.disableAutoEnterPip(PlatformDispatcher.instance.engineId!);
|
||||
|
||||
static (int, int)? maxScreenSize() {
|
||||
final jIArr = AndroidHelper.maxScreenSize();
|
||||
if (jIArr != null) {
|
||||
|
||||
@@ -453,18 +453,20 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
).boolean;
|
||||
}
|
||||
|
||||
static final _id_setPipAutoEnterEnabled = _class.staticMethodId(
|
||||
r'setPipAutoEnterEnabled',
|
||||
r'(ZJ)V',
|
||||
static final _id_enterPip = _class.staticMethodId(
|
||||
r'enterPip',
|
||||
r'(IIZJ)V',
|
||||
);
|
||||
|
||||
static final _setPipAutoEnterEnabled =
|
||||
static final _enterPip =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<(jni$_.Int32, jni$_.Int64)>,
|
||||
jni$_.VarArgs<
|
||||
(jni$_.Int32, jni$_.Int32, jni$_.Int32, jni$_.Int64)
|
||||
>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
@@ -474,19 +476,60 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
jni$_.JMethodIDPtr,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void setPipAutoEnterEnabled(boolean autoEnable, long engineId)`
|
||||
static void setPipAutoEnterEnabled(
|
||||
core$_.bool autoEnable,
|
||||
/// from: `static public void enterPip(int width, int height, boolean autoEnter, long engineId)`
|
||||
static void enterPip(
|
||||
core$_.int width,
|
||||
core$_.int height,
|
||||
core$_.bool autoEnter,
|
||||
core$_.int engineId,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
_setPipAutoEnterEnabled(
|
||||
_enterPip(
|
||||
_$$classRef.pointer,
|
||||
_id_setPipAutoEnterEnabled.pointer,
|
||||
autoEnable ? 1 : 0,
|
||||
_id_enterPip.pointer,
|
||||
width,
|
||||
height,
|
||||
autoEnter ? 1 : 0,
|
||||
engineId,
|
||||
).check();
|
||||
}
|
||||
|
||||
static final _id_disableAutoEnterPip = _class.staticMethodId(
|
||||
r'disableAutoEnterPip',
|
||||
r'(J)V',
|
||||
);
|
||||
|
||||
static final _disableAutoEnterPip =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<(jni$_.Int64,)>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
core$_.int,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void disableAutoEnterPip(long engineId)`
|
||||
static void disableAutoEnterPip(
|
||||
core$_.int engineId,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
_disableAutoEnterPip(
|
||||
_$$classRef.pointer,
|
||||
_id_disableAutoEnterPip.pointer,
|
||||
engineId,
|
||||
).check();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ import 'package:PiliPlus/pages/common/publish/publish_route.dart';
|
||||
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/utils/android/android_helper.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/feed_back.dart';
|
||||
@@ -30,7 +30,6 @@ import 'package:PiliPlus/utils/storage_pref.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/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -187,22 +186,26 @@ abstract final class PageUtils {
|
||||
);
|
||||
}
|
||||
|
||||
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, bool autoEnter = false}) {
|
||||
if (width != null &&
|
||||
height != null &&
|
||||
!_fitsInAndroidRequirements(width, height)) {
|
||||
if (height > width) {
|
||||
width = 9;
|
||||
height = 16;
|
||||
} else {
|
||||
width = 16;
|
||||
height = 9;
|
||||
}
|
||||
}
|
||||
PiliAndroidHelper.enterPip(width ?? 16, height ?? 9, autoEnter);
|
||||
}
|
||||
|
||||
static Future<void> pushDynDetail(
|
||||
|
||||
Reference in New Issue
Block a user