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 android.view.WindowManager;
|
||||||
|
|
||||||
import androidx.annotation.Keep;
|
import androidx.annotation.Keep;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.github.dart_lang.jni_flutter.JniFlutterPlugin;
|
import com.github.dart_lang.jni_flutter.JniFlutterPlugin;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
public final class AndroidHelper {
|
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 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() {
|
private AndroidHelper() {
|
||||||
}
|
}
|
||||||
@@ -57,8 +62,8 @@ public final class AndroidHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void biliSendCommAntifraud(
|
public static void biliSendCommAntifraud(
|
||||||
int action, long oid, int type, long rpId, long root, long parent, long ctime, @NotNull String commentText,
|
int action, long oid, int type, long rpId, long root, long parent, long ctime, @NonNull String commentText,
|
||||||
String pictures, @NotNull String sourceId, long uid, @NotNull String cookie
|
String pictures, @NonNull String sourceId, long uid, @NonNull String cookie
|
||||||
) {
|
) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
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 intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_SEARCH);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.putExtra(SearchManager.QUERY, title);
|
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) {
|
public static void enterPip(int width, int height, boolean autoEnter, long engineId) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
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);
|
Activity activity = JniFlutterPlugin.getActivity(engineId);
|
||||||
assert activity != null;
|
assert activity != null;
|
||||||
|
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder()
|
||||||
|
.setAspectRatio(new Rational(width, height));
|
||||||
if (autoEnter) {
|
if (autoEnter) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
builder.setAutoEnterEnabled(true);
|
builder.setAutoEnterEnabled(true);
|
||||||
@@ -163,11 +168,12 @@ public final class AndroidHelper {
|
|||||||
|
|
||||||
public static void disableAutoEnterPip(long engineId) {
|
public static void disableAutoEnterPip(long engineId) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder()
|
|
||||||
.setAutoEnterEnabled(false);
|
|
||||||
Activity activity = JniFlutterPlugin.getActivity(engineId);
|
Activity activity = JniFlutterPlugin.getActivity(engineId);
|
||||||
if (activity != null) {
|
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) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
|
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
|
||||||
@@ -214,7 +220,7 @@ public final class AndroidHelper {
|
|||||||
@Keep
|
@Keep
|
||||||
public static final class ToDart {
|
public static final class ToDart {
|
||||||
public static volatile Runnable onUserLeaveHint;
|
public static volatile Runnable onUserLeaveHint;
|
||||||
public static volatile Runnable onConfigurationChanged;
|
public static Runnable onConfigurationChanged;
|
||||||
|
|
||||||
private ToDart() {
|
private ToDart() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.example.piliplus
|
package com.example.piliplus
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -51,17 +50,6 @@ class MainActivity : AudioServiceActivity() {
|
|||||||
window.attributes.layoutInDisplayCutoutMode =
|
window.attributes.layoutInDisplayCutoutMode =
|
||||||
LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
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() {
|
override fun onDestroy() {
|
||||||
@@ -74,9 +62,7 @@ class MainActivity : AudioServiceActivity() {
|
|||||||
AndroidHelper.ToDart.onUserLeaveHint?.run()
|
AndroidHelper.ToDart.onUserLeaveHint?.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPictureInPictureModeChanged(
|
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration?) {
|
||||||
isInPictureInPictureMode: Boolean, newConfig: Configuration?
|
|
||||||
) {
|
|
||||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||||
AndroidHelper.isPipMode = isInPictureInPictureMode
|
AndroidHelper.isPipMode = isInPictureInPictureMode
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,13 +197,19 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
|||||||
r'Z',
|
r'Z',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// from: `static public volatile boolean isFoldable`
|
/// from: `static public final boolean isFoldable`
|
||||||
static core$_.bool get isFoldable =>
|
static core$_.bool get isFoldable =>
|
||||||
_id_isFoldable.getNullable(_class, jni$_.jboolean.type) as core$_.bool;
|
_id_isFoldable.getNullable(_class, jni$_.jboolean.type) as core$_.bool;
|
||||||
|
|
||||||
/// from: `static public volatile boolean isFoldable`
|
static final _id_isPipAvailable = _class.staticFieldId(
|
||||||
static set isFoldable(core$_.bool value) =>
|
r'isPipAvailable',
|
||||||
_id_isFoldable.set(_class, jni$_.jboolean.type, value);
|
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(
|
static final _id_isPipMode = _class.staticFieldId(
|
||||||
r'isPipMode',
|
r'isPipMode',
|
||||||
@@ -218,20 +224,6 @@ extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
|||||||
static set isPipMode(core$_.bool value) =>
|
static set isPipMode(core$_.bool value) =>
|
||||||
_id_isPipMode.set(_class, jni$_.jboolean.type, 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(
|
static final _id_sdkInt = _class.staticMethodId(
|
||||||
r'sdkInt',
|
r'sdkInt',
|
||||||
r'()I',
|
r'()I',
|
||||||
@@ -660,13 +652,13 @@ extension type AndroidHelper$ToDart._(jni$_.JObject _$this)
|
|||||||
r'Ljava/lang/Runnable;',
|
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.
|
/// The returned object must be released after use, by calling the [release] method.
|
||||||
static Runnable? get onConfigurationChanged =>
|
static Runnable? get onConfigurationChanged =>
|
||||||
_id_onConfigurationChanged.getNullable(_class, Runnable.type)
|
_id_onConfigurationChanged.getNullable(_class, Runnable.type)
|
||||||
as Runnable?;
|
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.
|
/// The returned object must be released after use, by calling the [release] method.
|
||||||
static set onConfigurationChanged(Runnable? value) =>
|
static set onConfigurationChanged(Runnable? value) =>
|
||||||
_id_onConfigurationChanged.set(_class, Runnable.type, value);
|
_id_onConfigurationChanged.set(_class, Runnable.type, value);
|
||||||
|
|||||||
Reference in New Issue
Block a user