mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-03 01:28:17 +08:00
committed by
GitHub
parent
6a75061dbb
commit
d4d9fc3405
108
lib/utils/android/android_helper.dart
Normal file
108
lib/utils/android/android_helper.dart
Normal file
@@ -0,0 +1,108 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:PiliPlus/utils/android/bindings.g.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:jni/jni.dart';
|
||||
|
||||
abstract final class PiliAndroidHelper {
|
||||
@pragma('vm:prefer-inline')
|
||||
static void back() => AndroidHelper.back();
|
||||
|
||||
static void biliSendCommAntifraud(
|
||||
int action,
|
||||
int oid,
|
||||
int type,
|
||||
int rpId,
|
||||
int root,
|
||||
int parent,
|
||||
int ctime,
|
||||
String commentText,
|
||||
List pictures,
|
||||
String sourceId,
|
||||
int uid,
|
||||
String cookie,
|
||||
) {
|
||||
final jCommentText = commentText.toJString();
|
||||
final jSourceId = sourceId.toJString();
|
||||
final jCookie = cookie.toJString();
|
||||
final jPictures = pictures.isEmpty
|
||||
? null
|
||||
: jsonEncode(pictures).toJString();
|
||||
|
||||
try {
|
||||
AndroidHelper.biliSendCommAntifraud(
|
||||
action,
|
||||
oid,
|
||||
type,
|
||||
rpId,
|
||||
root,
|
||||
parent,
|
||||
ctime,
|
||||
jCommentText,
|
||||
jPictures,
|
||||
jSourceId,
|
||||
uid,
|
||||
jCookie,
|
||||
);
|
||||
} catch (e) {
|
||||
Utils.reportError(e);
|
||||
} finally {
|
||||
jCommentText.release();
|
||||
jSourceId.release();
|
||||
jCookie.release();
|
||||
jPictures?.release();
|
||||
}
|
||||
}
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
static void openLinkVerifySettings() =>
|
||||
AndroidHelper.openLinkVerifySettings();
|
||||
|
||||
static bool openMusic(String title, String? artist, String? album) {
|
||||
final jTitle = title.toJString();
|
||||
final jArtist = artist?.toJString();
|
||||
final jAlbum = album?.toJString();
|
||||
try {
|
||||
return AndroidHelper.openMusic(jTitle, jArtist, jAlbum);
|
||||
} finally {
|
||||
jTitle.release();
|
||||
jArtist?.release();
|
||||
jAlbum?.release();
|
||||
}
|
||||
}
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
static void setPipAutoEnterEnabled(bool autoEnable) =>
|
||||
AndroidHelper.setPipAutoEnterEnabled(
|
||||
autoEnable,
|
||||
PlatformDispatcher.instance.engineId!,
|
||||
);
|
||||
|
||||
static (int, int)? maxScreenSize() {
|
||||
final jIArr = AndroidHelper.maxScreenSize();
|
||||
if (jIArr != null) {
|
||||
try {
|
||||
return (jIArr[0], jIArr[1]);
|
||||
} finally {
|
||||
jIArr.release();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static void createShortcut(String id, String uri, String label, String path) {
|
||||
final jId = id.toJString();
|
||||
final jUri = uri.toJString();
|
||||
final jLabel = label.toJString();
|
||||
final jPath = path.toJString();
|
||||
try {
|
||||
AndroidHelper.createShortcut(jId, jUri, jLabel, jPath);
|
||||
} finally {
|
||||
jId.release();
|
||||
jUri.release();
|
||||
jLabel.release();
|
||||
jPath.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
586
lib/utils/android/bindings.g.dart
Normal file
586
lib/utils/android/bindings.g.dart
Normal file
@@ -0,0 +1,586 @@
|
||||
// AUTO GENERATED BY JNIGEN 0.17.0. DO NOT EDIT!
|
||||
|
||||
// ignore_for_file: annotate_overrides
|
||||
// ignore_for_file: argument_type_not_assignable
|
||||
// ignore_for_file: camel_case_extensions
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: doc_directive_unknown
|
||||
// ignore_for_file: file_names
|
||||
// ignore_for_file: inference_failure_on_untyped_parameter
|
||||
// ignore_for_file: invalid_internal_annotation
|
||||
// ignore_for_file: invalid_use_of_internal_member
|
||||
// ignore_for_file: library_prefixes
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
// ignore_for_file: no_leading_underscores_for_local_identifiers
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
// ignore_for_file: only_throw_errors
|
||||
// ignore_for_file: overridden_fields
|
||||
// ignore_for_file: prefer_double_quotes
|
||||
// ignore_for_file: unintended_html_in_doc_comment
|
||||
// ignore_for_file: unnecessary_cast
|
||||
// ignore_for_file: unnecessary_non_null_assertion
|
||||
// ignore_for_file: unnecessary_parenthesis
|
||||
// ignore_for_file: unused_element
|
||||
// ignore_for_file: unused_field
|
||||
// ignore_for_file: unused_import
|
||||
// ignore_for_file: unused_local_variable
|
||||
// ignore_for_file: unused_shown_name
|
||||
// ignore_for_file: use_super_parameters
|
||||
|
||||
import 'dart:core' as core$_;
|
||||
import 'dart:core' show Object, String;
|
||||
|
||||
import 'package:jni/_internal.dart' as jni$_;
|
||||
import 'package:jni/jni.dart' as jni$_;
|
||||
|
||||
const _$jniVersionCheck = jni$_.JniVersionCheck(1, 0);
|
||||
|
||||
/// from: `com.example.piliplus.AndroidHelper$ToDart`
|
||||
extension type AndroidHelper$ToDart._(jni$_.JObject _$this)
|
||||
implements jni$_.JObject {
|
||||
static final _class = jni$_.JClass.forName(
|
||||
r'com/example/piliplus/AndroidHelper$ToDart',
|
||||
);
|
||||
|
||||
/// The type which includes information such as the signature of this class.
|
||||
static const jni$_.JType<AndroidHelper$ToDart> type =
|
||||
$AndroidHelper$ToDart$Type$();
|
||||
static final _id_onUserLeaveHint = _class.staticFieldId(
|
||||
r'onUserLeaveHint',
|
||||
r'Ljava/lang/Runnable;',
|
||||
);
|
||||
|
||||
/// from: `static public bridge java.lang.Runnable onUserLeaveHint`
|
||||
/// The returned object must be released after use, by calling the [release] method.
|
||||
static Runnable? get onUserLeaveHint =>
|
||||
_id_onUserLeaveHint.getNullable(_class, Runnable.type) as Runnable?;
|
||||
|
||||
/// from: `static public bridge java.lang.Runnable onUserLeaveHint`
|
||||
/// The returned object must be released after use, by calling the [release] method.
|
||||
static set onUserLeaveHint(Runnable? value) =>
|
||||
_id_onUserLeaveHint.set(_class, Runnable.type, value);
|
||||
|
||||
static final _id_onConfigurationChanged = _class.staticFieldId(
|
||||
r'onConfigurationChanged',
|
||||
r'Ljava/lang/Runnable;',
|
||||
);
|
||||
|
||||
/// from: `static public bridge java.lang.Runnable onConfigurationChanged`
|
||||
/// The returned object must be released after use, by calling the [release] method.
|
||||
static Runnable? get onConfigurationChanged =>
|
||||
_id_onConfigurationChanged.getNullable(_class, Runnable.type)
|
||||
as Runnable?;
|
||||
|
||||
/// from: `static public bridge java.lang.Runnable onConfigurationChanged`
|
||||
/// The returned object must be released after use, by calling the [release] method.
|
||||
static set onConfigurationChanged(Runnable? value) =>
|
||||
_id_onConfigurationChanged.set(_class, Runnable.type, value);
|
||||
}
|
||||
|
||||
final class $AndroidHelper$ToDart$Type$
|
||||
extends jni$_.JType<AndroidHelper$ToDart> {
|
||||
@jni$_.internal
|
||||
const $AndroidHelper$ToDart$Type$();
|
||||
|
||||
@jni$_.internal
|
||||
@core$_.override
|
||||
String get signature => r'Lcom/example/piliplus/AndroidHelper$ToDart;';
|
||||
}
|
||||
|
||||
/// from: `com.example.piliplus.AndroidHelper`
|
||||
extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
static final _class = jni$_.JClass.forName(
|
||||
r'com/example/piliplus/AndroidHelper',
|
||||
);
|
||||
|
||||
/// The type which includes information such as the signature of this class.
|
||||
static const jni$_.JType<AndroidHelper> type = $AndroidHelper$Type$();
|
||||
static final _id_isFoldable = _class.staticFieldId(
|
||||
r'isFoldable',
|
||||
r'Z',
|
||||
);
|
||||
|
||||
/// from: `static public bridge boolean isFoldable`
|
||||
static core$_.bool get isFoldable =>
|
||||
_id_isFoldable.getNullable(_class, jni$_.jboolean.type) as core$_.bool;
|
||||
|
||||
/// from: `static public bridge boolean isFoldable`
|
||||
static set isFoldable(core$_.bool value) =>
|
||||
_id_isFoldable.set(_class, jni$_.jboolean.type, value);
|
||||
|
||||
static final _id_back = _class.staticMethodId(
|
||||
r'back',
|
||||
r'()V',
|
||||
);
|
||||
|
||||
static final _back =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void back()`
|
||||
static void back() {
|
||||
final _$$classRef = _class.reference;
|
||||
_back(_$$classRef.pointer, _id_back.pointer).check();
|
||||
}
|
||||
|
||||
static final _id_biliSendCommAntifraud = _class.staticMethodId(
|
||||
r'biliSendCommAntifraud',
|
||||
r'(IJIJJJJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;JLjava/lang/String;)V',
|
||||
);
|
||||
|
||||
static final _biliSendCommAntifraud =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<
|
||||
(
|
||||
jni$_.Int32,
|
||||
jni$_.Int64,
|
||||
jni$_.Int32,
|
||||
jni$_.Int64,
|
||||
jni$_.Int64,
|
||||
jni$_.Int64,
|
||||
jni$_.Int64,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Int64,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
core$_.int,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void biliSendCommAntifraud(int i, long j, int i1, long j1, long j2, long j3, long j4, java.lang.String string, java.lang.String string1, java.lang.String string2, long j5, java.lang.String string3)`
|
||||
static void biliSendCommAntifraud(
|
||||
core$_.int i,
|
||||
core$_.int j,
|
||||
core$_.int i1,
|
||||
core$_.int j1,
|
||||
core$_.int j2,
|
||||
core$_.int j3,
|
||||
core$_.int j4,
|
||||
jni$_.JString string,
|
||||
jni$_.JString? string1,
|
||||
jni$_.JString string2,
|
||||
core$_.int j5,
|
||||
jni$_.JString string3,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
final _$string = string.reference;
|
||||
final _$string1 = string1?.reference ?? jni$_.jNullReference;
|
||||
final _$string2 = string2.reference;
|
||||
final _$string3 = string3.reference;
|
||||
_biliSendCommAntifraud(
|
||||
_$$classRef.pointer,
|
||||
_id_biliSendCommAntifraud.pointer,
|
||||
i,
|
||||
j,
|
||||
i1,
|
||||
j1,
|
||||
j2,
|
||||
j3,
|
||||
j4,
|
||||
_$string.pointer,
|
||||
_$string1.pointer,
|
||||
_$string2.pointer,
|
||||
j5,
|
||||
_$string3.pointer,
|
||||
).check();
|
||||
}
|
||||
|
||||
static final _id_openLinkVerifySettings = _class.staticMethodId(
|
||||
r'openLinkVerifySettings',
|
||||
r'()V',
|
||||
);
|
||||
|
||||
static final _openLinkVerifySettings =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void openLinkVerifySettings()`
|
||||
static void openLinkVerifySettings() {
|
||||
final _$$classRef = _class.reference;
|
||||
_openLinkVerifySettings(
|
||||
_$$classRef.pointer,
|
||||
_id_openLinkVerifySettings.pointer,
|
||||
).check();
|
||||
}
|
||||
|
||||
static final _id_openMusic = _class.staticMethodId(
|
||||
r'openMusic',
|
||||
r'(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z',
|
||||
);
|
||||
|
||||
static final _openMusic =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JniResult Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<
|
||||
(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticBooleanMethod')
|
||||
.asFunction<
|
||||
jni$_.JniResult Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public boolean openMusic(java.lang.String string, java.lang.String string1, java.lang.String string2)`
|
||||
static core$_.bool openMusic(
|
||||
jni$_.JString string,
|
||||
jni$_.JString? string1,
|
||||
jni$_.JString? string2,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
final _$string = string.reference;
|
||||
final _$string1 = string1?.reference ?? jni$_.jNullReference;
|
||||
final _$string2 = string2?.reference ?? jni$_.jNullReference;
|
||||
return _openMusic(
|
||||
_$$classRef.pointer,
|
||||
_id_openMusic.pointer,
|
||||
_$string.pointer,
|
||||
_$string1.pointer,
|
||||
_$string2.pointer,
|
||||
).boolean;
|
||||
}
|
||||
|
||||
static final _id_setPipAutoEnterEnabled = _class.staticMethodId(
|
||||
r'setPipAutoEnterEnabled',
|
||||
r'(ZJ)V',
|
||||
);
|
||||
|
||||
static final _setPipAutoEnterEnabled =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<(jni$_.Int32, jni$_.Int64)>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
core$_.int,
|
||||
core$_.int,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void setPipAutoEnterEnabled(boolean z, long j)`
|
||||
static void setPipAutoEnterEnabled(
|
||||
core$_.bool z,
|
||||
core$_.int j,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
_setPipAutoEnterEnabled(
|
||||
_$$classRef.pointer,
|
||||
_id_setPipAutoEnterEnabled.pointer,
|
||||
z ? 1 : 0,
|
||||
j,
|
||||
).check();
|
||||
}
|
||||
|
||||
static final _id_maxScreenSize = _class.staticMethodId(
|
||||
r'maxScreenSize',
|
||||
r'()[I',
|
||||
);
|
||||
|
||||
static final _maxScreenSize =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JniResult Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticObjectMethod')
|
||||
.asFunction<
|
||||
jni$_.JniResult Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public int[] maxScreenSize()`
|
||||
/// The returned object must be released after use, by calling the [release] method.
|
||||
static jni$_.JIntArray? maxScreenSize() {
|
||||
final _$$classRef = _class.reference;
|
||||
return _maxScreenSize(
|
||||
_$$classRef.pointer,
|
||||
_id_maxScreenSize.pointer,
|
||||
).object<jni$_.JIntArray?>();
|
||||
}
|
||||
|
||||
static final _id_createShortcut = _class.staticMethodId(
|
||||
r'createShortcut',
|
||||
r'(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V',
|
||||
);
|
||||
|
||||
static final _createShortcut =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<
|
||||
(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void createShortcut(java.lang.String string, java.lang.String string1, java.lang.String string2, java.lang.String string3)`
|
||||
static void createShortcut(
|
||||
jni$_.JString string,
|
||||
jni$_.JString string1,
|
||||
jni$_.JString string2,
|
||||
jni$_.JString string3,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
final _$string = string.reference;
|
||||
final _$string1 = string1.reference;
|
||||
final _$string2 = string2.reference;
|
||||
final _$string3 = string3.reference;
|
||||
_createShortcut(
|
||||
_$$classRef.pointer,
|
||||
_id_createShortcut.pointer,
|
||||
_$string.pointer,
|
||||
_$string1.pointer,
|
||||
_$string2.pointer,
|
||||
_$string3.pointer,
|
||||
).check();
|
||||
}
|
||||
}
|
||||
|
||||
final class $AndroidHelper$Type$ extends jni$_.JType<AndroidHelper> {
|
||||
@jni$_.internal
|
||||
const $AndroidHelper$Type$();
|
||||
|
||||
@jni$_.internal
|
||||
@core$_.override
|
||||
String get signature => r'Lcom/example/piliplus/AndroidHelper;';
|
||||
}
|
||||
|
||||
/// from: `java.lang.Runnable`
|
||||
extension type Runnable._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
static final _class = jni$_.JClass.forName(r'java/lang/Runnable');
|
||||
|
||||
/// The type which includes information such as the signature of this class.
|
||||
static const jni$_.JType<Runnable> type = $Runnable$Type$();
|
||||
|
||||
/// Maps a specific port to the implemented interface.
|
||||
static final core$_.Map<core$_.int, $Runnable> _$impls = {};
|
||||
static jni$_.JObjectPtr _$invoke(
|
||||
core$_.int port,
|
||||
jni$_.JObjectPtr descriptor,
|
||||
jni$_.JObjectPtr args,
|
||||
) {
|
||||
return _$invokeMethod(
|
||||
port,
|
||||
jni$_.MethodInvocation.fromAddresses(
|
||||
0,
|
||||
descriptor.address,
|
||||
args.address,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static final jni$_.Pointer<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JObjectPtr Function(jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)
|
||||
>
|
||||
>
|
||||
_$invokePointer = jni$_.Pointer.fromFunction(_$invoke);
|
||||
|
||||
static jni$_.Pointer<jni$_.Void> _$invokeMethod(
|
||||
core$_.int $p,
|
||||
jni$_.MethodInvocation $i,
|
||||
) {
|
||||
try {
|
||||
final $d = $i.methodDescriptor.toDartString(releaseOriginal: true);
|
||||
final $a = $i.args;
|
||||
if ($d == r'run()V') {
|
||||
_$impls[$p]!.run();
|
||||
return jni$_.nullptr;
|
||||
}
|
||||
} catch (e) {
|
||||
return jni$_.ProtectedJniExtensions.newDartException(e);
|
||||
}
|
||||
return jni$_.nullptr;
|
||||
}
|
||||
|
||||
static void implementIn(
|
||||
jni$_.JImplementer implementer,
|
||||
$Runnable $impl,
|
||||
) {
|
||||
late final jni$_.RawReceivePort $p;
|
||||
$p = jni$_.RawReceivePort(($m) {
|
||||
if ($m == null) {
|
||||
_$impls.remove($p.sendPort.nativePort);
|
||||
$p.close();
|
||||
return;
|
||||
}
|
||||
final $i = jni$_.MethodInvocation.fromMessage($m);
|
||||
final $r = _$invokeMethod($p.sendPort.nativePort, $i);
|
||||
jni$_.ProtectedJniExtensions.returnResult($i.result, $r);
|
||||
});
|
||||
implementer.add(
|
||||
r'java.lang.Runnable',
|
||||
$p,
|
||||
_$invokePointer,
|
||||
[
|
||||
if ($impl.run$async) r'run()V',
|
||||
],
|
||||
);
|
||||
final $a = $p.sendPort.nativePort;
|
||||
_$impls[$a] = $impl;
|
||||
}
|
||||
|
||||
factory Runnable.implement(
|
||||
$Runnable $impl,
|
||||
) {
|
||||
final $i = jni$_.JImplementer();
|
||||
implementIn($i, $impl);
|
||||
return $i.implement<Runnable>();
|
||||
}
|
||||
}
|
||||
|
||||
extension Runnable$$Methods on Runnable {
|
||||
static final _id_run = Runnable._class.instanceMethodId(
|
||||
r'run',
|
||||
r'()V',
|
||||
);
|
||||
|
||||
static final _run =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `public abstract void run()`
|
||||
void run() {
|
||||
final _$$selfRef = reference;
|
||||
_run(_$$selfRef.pointer, _id_run.pointer).check();
|
||||
}
|
||||
}
|
||||
|
||||
abstract base mixin class $Runnable {
|
||||
factory $Runnable({
|
||||
required void Function() run,
|
||||
core$_.bool run$async,
|
||||
}) = _$Runnable;
|
||||
|
||||
void run();
|
||||
core$_.bool get run$async => false;
|
||||
}
|
||||
|
||||
final class _$Runnable with $Runnable {
|
||||
_$Runnable({
|
||||
required void Function() run,
|
||||
this.run$async = false,
|
||||
}) : _run = run;
|
||||
|
||||
final void Function() _run;
|
||||
final core$_.bool run$async;
|
||||
|
||||
void run() {
|
||||
return _run();
|
||||
}
|
||||
}
|
||||
|
||||
final class $Runnable$Type$ extends jni$_.JType<Runnable> {
|
||||
@jni$_.internal
|
||||
const $Runnable$Type$();
|
||||
|
||||
@jni$_.internal
|
||||
@core$_.override
|
||||
String get signature => r'Ljava/lang/Runnable;';
|
||||
}
|
||||
@@ -1,36 +1,26 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/services.dart' show MethodChannel;
|
||||
import 'package:PiliPlus/utils/android/android_helper.dart';
|
||||
import 'package:PiliPlus/utils/android/bindings.g.dart';
|
||||
|
||||
abstract final class MaxScreenSize {
|
||||
static int? _maxWidth;
|
||||
static int? _maxHeight;
|
||||
|
||||
static Future<void> init() {
|
||||
return Future.wait([_initFoldable(), _initScreenSize()]);
|
||||
}
|
||||
|
||||
static Future<void> _initFoldable() async {
|
||||
final isFoldable = await Utils.channel.invokeMethod('isFoldable');
|
||||
if (isFoldable == true) {
|
||||
const MethodChannel('ScreenChannel').setMethodCallHandler((call) {
|
||||
if (call.method == 'onConfigChanged') {
|
||||
_handleRes(call.arguments);
|
||||
}
|
||||
return Future.syncValue(null);
|
||||
});
|
||||
static void init() {
|
||||
_initScreenSize();
|
||||
if (AndroidHelper.isFoldable) {
|
||||
AndroidHelper$ToDart.onUserLeaveHint = Runnable.implement(
|
||||
$Runnable(run: _initScreenSize),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> _initScreenSize() {
|
||||
return Utils.channel.invokeMethod('maxScreenSize').then(_handleRes);
|
||||
}
|
||||
|
||||
static void _handleRes(dynamic res) {
|
||||
if (res is Map) {
|
||||
_maxWidth = res['maxWidth'];
|
||||
_maxHeight = res['maxHeight'];
|
||||
static void _initScreenSize() {
|
||||
final size = PiliAndroidHelper.maxScreenSize();
|
||||
if (size != null) {
|
||||
_maxWidth = size.$1;
|
||||
_maxHeight = size.$2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:convert' show jsonEncode;
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||
@@ -8,6 +7,7 @@ import 'package:PiliPlus/http/reply.dart';
|
||||
import 'package:PiliPlus/models/common/reply/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/android/android_helper.dart';
|
||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
@@ -55,11 +55,11 @@ abstract final class ReplyUtils {
|
||||
required int type,
|
||||
required int id,
|
||||
required String message,
|
||||
dynamic root,
|
||||
dynamic parent,
|
||||
dynamic ctime,
|
||||
List? pictures,
|
||||
dynamic mid,
|
||||
required int root,
|
||||
required int parent,
|
||||
required int ctime,
|
||||
required List pictures,
|
||||
required int mid,
|
||||
bool isManual = false,
|
||||
required bool biliSendCommAntifraud,
|
||||
required sourceId,
|
||||
@@ -67,27 +67,24 @@ abstract final class ReplyUtils {
|
||||
// biliSendCommAntifraud
|
||||
if (Platform.isAndroid && biliSendCommAntifraud) {
|
||||
try {
|
||||
final String cookieString = Accounts.main.cookieJar
|
||||
final cookieString = Accounts.main.cookieJar
|
||||
.toJson()
|
||||
.entries
|
||||
.map((i) => '${i.key}=${i.value}')
|
||||
.join(';');
|
||||
Utils.channel.invokeMethod(
|
||||
'biliSendCommAntifraud',
|
||||
{
|
||||
'action': 0,
|
||||
'oid': oid,
|
||||
'type': type,
|
||||
'rpid': id,
|
||||
'root': root,
|
||||
'parent': parent,
|
||||
'ctime': ctime,
|
||||
'comment_text': message,
|
||||
if (pictures?.isNotEmpty == true) 'pictures': jsonEncode(pictures),
|
||||
'source_id': '$sourceId',
|
||||
'uid': mid,
|
||||
'cookies': [cookieString],
|
||||
},
|
||||
PiliAndroidHelper.biliSendCommAntifraud(
|
||||
0,
|
||||
oid,
|
||||
type,
|
||||
id,
|
||||
root,
|
||||
parent,
|
||||
ctime,
|
||||
message,
|
||||
pictures,
|
||||
sourceId,
|
||||
mid,
|
||||
cookieString,
|
||||
);
|
||||
} catch (e) {
|
||||
if (kDebugMode) debugPrint('biliSendCommAntifraud: $e');
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import 'dart:convert' show JsonEncoder, base64;
|
||||
import 'dart:math' show Random;
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:catcher_2/catcher_2.dart';
|
||||
import 'package:flutter/services.dart'
|
||||
show Clipboard, ClipboardData, MethodChannel;
|
||||
import 'package:flutter/services.dart' show Clipboard, ClipboardData;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
abstract final class Utils {
|
||||
static final random = Random();
|
||||
|
||||
static const channel = MethodChannel(Constants.appName);
|
||||
|
||||
static const jsonEncoder = JsonEncoder.withIndent(' ');
|
||||
|
||||
static final numericRegex = RegExp(r'^[\d\.]+$');
|
||||
|
||||
Reference in New Issue
Block a user