mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-02 00:58:19 +08:00
opt: remove volatile (#2255)
This commit is contained in:
committed by
GitHub
parent
90590faaaf
commit
fb9568a628
@@ -23,20 +23,25 @@ import android.util.Rational;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.github.dart_lang.jni_flutter.JniFlutterPlugin;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Keep
|
||||
public final class AndroidHelper {
|
||||
public static volatile boolean isFoldable = false;
|
||||
public static final boolean isFoldable;
|
||||
|
||||
public static final boolean isPipAvailable;
|
||||
|
||||
public static volatile boolean isPipMode = false;
|
||||
|
||||
public static volatile boolean isPipAvailable = false;
|
||||
static {
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
isFoldable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_HINGE_ANGLE);
|
||||
isPipAvailable = pm.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
|
||||
}
|
||||
|
||||
private AndroidHelper() {
|
||||
}
|
||||
@@ -57,8 +62,8 @@ public final class AndroidHelper {
|
||||
}
|
||||
|
||||
public static void biliSendCommAntifraud(
|
||||
int action, long oid, int type, long rpId, long root, long parent, long ctime, @NotNull String commentText,
|
||||
String pictures, @NotNull String sourceId, long uid, @NotNull String cookie
|
||||
int action, long oid, int type, long rpId, long root, long parent, long ctime, @NonNull String commentText,
|
||||
String pictures, @NonNull String sourceId, long uid, @NonNull String cookie
|
||||
) {
|
||||
Intent intent = new Intent();
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -108,7 +113,7 @@ public final class AndroidHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean openMusic(@NotNull String title, String artist, String album) {
|
||||
public static boolean openMusic(@NonNull String title, String artist, String album) {
|
||||
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(SearchManager.QUERY, title);
|
||||
@@ -146,10 +151,10 @@ public final class AndroidHelper {
|
||||
|
||||
public static void enterPip(int width, int height, boolean autoEnter, long engineId) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder()
|
||||
.setAspectRatio(new Rational(width, height));
|
||||
Activity activity = JniFlutterPlugin.getActivity(engineId);
|
||||
assert activity != null;
|
||||
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder()
|
||||
.setAspectRatio(new Rational(width, height));
|
||||
if (autoEnter) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
builder.setAutoEnterEnabled(true);
|
||||
@@ -163,11 +168,12 @@ public final class AndroidHelper {
|
||||
|
||||
public static void disableAutoEnterPip(long engineId) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder()
|
||||
.setAutoEnterEnabled(false);
|
||||
Activity activity = JniFlutterPlugin.getActivity(engineId);
|
||||
if (activity != null) {
|
||||
activity.setPictureInPictureParams(builder.build());
|
||||
activity.setPictureInPictureParams(new PictureInPictureParams.Builder()
|
||||
.setAutoEnterEnabled(false)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,7 +196,7 @@ public final class AndroidHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void createShortcut(@NotNull String id, @NotNull String uri, @NotNull String label, @NotNull String icon) {
|
||||
public static void createShortcut(@NonNull String id, @NonNull String uri, @NonNull String label, @NonNull String icon) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Context context = getContext();
|
||||
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
|
||||
@@ -214,7 +220,7 @@ public final class AndroidHelper {
|
||||
@Keep
|
||||
public static final class ToDart {
|
||||
public static volatile Runnable onUserLeaveHint;
|
||||
public static volatile Runnable onConfigurationChanged;
|
||||
public static Runnable onConfigurationChanged;
|
||||
|
||||
private ToDart() {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.example.piliplus
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
@@ -51,17 +50,6 @@ class MainActivity : AudioServiceActivity() {
|
||||
window.attributes.layoutInDisplayCutoutMode =
|
||||
LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||
}
|
||||
|
||||
AndroidHelper.isPipAvailable =
|
||||
packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
try {
|
||||
AndroidHelper.isFoldable =
|
||||
packageManager.hasSystemFeature(PackageManager.FEATURE_SENSOR_HINGE_ANGLE)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -74,9 +62,7 @@ class MainActivity : AudioServiceActivity() {
|
||||
AndroidHelper.ToDart.onUserLeaveHint?.run()
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(
|
||||
isInPictureInPictureMode: Boolean, newConfig: Configuration?
|
||||
) {
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||
AndroidHelper.isPipMode = isInPictureInPictureMode
|
||||
}
|
||||
|
||||
@@ -197,13 +197,19 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
r'Z',
|
||||
);
|
||||
|
||||
/// from: `static public volatile boolean isFoldable`
|
||||
/// from: `static public final boolean isFoldable`
|
||||
static core$_.bool get isFoldable =>
|
||||
_id_isFoldable.getNullable(_class, jni$_.jboolean.type) as core$_.bool;
|
||||
|
||||
/// from: `static public volatile boolean isFoldable`
|
||||
static set isFoldable(core$_.bool value) =>
|
||||
_id_isFoldable.set(_class, jni$_.jboolean.type, value);
|
||||
static final _id_isPipAvailable = _class.staticFieldId(
|
||||
r'isPipAvailable',
|
||||
r'Z',
|
||||
);
|
||||
|
||||
/// from: `static public final boolean isPipAvailable`
|
||||
static core$_.bool get isPipAvailable =>
|
||||
_id_isPipAvailable.getNullable(_class, jni$_.jboolean.type)
|
||||
as core$_.bool;
|
||||
|
||||
static final _id_isPipMode = _class.staticFieldId(
|
||||
r'isPipMode',
|
||||
@@ -218,20 +224,6 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
static set isPipMode(core$_.bool value) =>
|
||||
_id_isPipMode.set(_class, jni$_.jboolean.type, value);
|
||||
|
||||
static final _id_isPipAvailable = _class.staticFieldId(
|
||||
r'isPipAvailable',
|
||||
r'Z',
|
||||
);
|
||||
|
||||
/// from: `static public volatile boolean isPipAvailable`
|
||||
static core$_.bool get isPipAvailable =>
|
||||
_id_isPipAvailable.getNullable(_class, jni$_.jboolean.type)
|
||||
as core$_.bool;
|
||||
|
||||
/// from: `static public volatile boolean isPipAvailable`
|
||||
static set isPipAvailable(core$_.bool value) =>
|
||||
_id_isPipAvailable.set(_class, jni$_.jboolean.type, value);
|
||||
|
||||
static final _id_sdkInt = _class.staticMethodId(
|
||||
r'sdkInt',
|
||||
r'()I',
|
||||
@@ -660,13 +652,13 @@ extension type AndroidHelper$ToDart._(jni$_.JObject _$this)
|
||||
r'Ljava/lang/Runnable;',
|
||||
);
|
||||
|
||||
/// from: `static public volatile java.lang.Runnable onConfigurationChanged`
|
||||
/// from: `static public 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 volatile java.lang.Runnable onConfigurationChanged`
|
||||
/// from: `static public 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);
|
||||
|
||||
Reference in New Issue
Block a user