Compare commits
1 Commits
feature-hi
...
feature-ba
| Author | SHA1 | Date | |
|---|---|---|---|
| 105a29f311 |
@ -38,10 +38,6 @@ class VideoCardH extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final int aid = videoItem.aid;
|
final int aid = videoItem.aid;
|
||||||
final String bvid = videoItem.bvid;
|
final String bvid = videoItem.bvid;
|
||||||
String type = 'video';
|
|
||||||
try {
|
|
||||||
type = videoItem.type;
|
|
||||||
} catch (_) {}
|
|
||||||
final String heroTag = Utils.makeHeroTag(aid);
|
final String heroTag = Utils.makeHeroTag(aid);
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
@ -57,10 +53,6 @@ class VideoCardH extends StatelessWidget {
|
|||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
try {
|
try {
|
||||||
if (type == 'ketang') {
|
|
||||||
SmartDialog.showToast('课堂视频暂不支持播放');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int cid =
|
final int cid =
|
||||||
videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||||
Get.toNamed('/video?bvid=$bvid&cid=$cid',
|
Get.toNamed('/video?bvid=$bvid&cid=$cid',
|
||||||
@ -103,20 +95,12 @@ class VideoCardH extends StatelessWidget {
|
|||||||
height: maxHeight,
|
height: maxHeight,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (videoItem.duration != 0)
|
|
||||||
PBadge(
|
PBadge(
|
||||||
text: Utils.timeFormat(videoItem.duration!),
|
text: Utils.timeFormat(videoItem.duration!),
|
||||||
right: 6.0,
|
right: 6.0,
|
||||||
bottom: 6.0,
|
bottom: 6.0,
|
||||||
type: 'gray',
|
type: 'gray',
|
||||||
),
|
),
|
||||||
if (type != 'video')
|
|
||||||
PBadge(
|
|
||||||
text: type,
|
|
||||||
left: 6.0,
|
|
||||||
bottom: 6.0,
|
|
||||||
type: 'primary',
|
|
||||||
),
|
|
||||||
// if (videoItem.rcmdReason != null &&
|
// if (videoItem.rcmdReason != null &&
|
||||||
// videoItem.rcmdReason.content != '')
|
// videoItem.rcmdReason.content != '')
|
||||||
// pBadge(videoItem.rcmdReason.content, context,
|
// pBadge(videoItem.rcmdReason.content, context,
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import 'package:pilipala/pages/search/index.dart';
|
|||||||
import 'package:pilipala/pages/video/detail/index.dart';
|
import 'package:pilipala/pages/video/detail/index.dart';
|
||||||
import 'package:pilipala/router/app_pages.dart';
|
import 'package:pilipala/router/app_pages.dart';
|
||||||
import 'package:pilipala/pages/main/view.dart';
|
import 'package:pilipala/pages/main/view.dart';
|
||||||
|
import 'package:pilipala/services/disable_battery_opt.dart';
|
||||||
import 'package:pilipala/services/service_locator.dart';
|
import 'package:pilipala/services/service_locator.dart';
|
||||||
import 'package:pilipala/utils/app_scheme.dart';
|
import 'package:pilipala/utils/app_scheme.dart';
|
||||||
import 'package:pilipala/utils/data.dart';
|
import 'package:pilipala/utils/data.dart';
|
||||||
@ -71,6 +72,7 @@ void main() async {
|
|||||||
));
|
));
|
||||||
Data.init();
|
Data.init();
|
||||||
PiliSchame.init();
|
PiliSchame.init();
|
||||||
|
DisableBatteryOpt();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -85,9 +85,7 @@ class SearchVideoItemModel {
|
|||||||
// title = json['title'].replaceAll(RegExp(r'<.*?>'), '');
|
// title = json['title'].replaceAll(RegExp(r'<.*?>'), '');
|
||||||
title = Em.regTitle(json['title']);
|
title = Em.regTitle(json['title']);
|
||||||
description = json['description'];
|
description = json['description'];
|
||||||
pic = json['pic'] != null && json['pic'].startsWith('//')
|
pic = 'https:${json['pic']}';
|
||||||
? 'https:${json['pic']}'
|
|
||||||
: json['pic'] ?? '';
|
|
||||||
videoReview = json['video_review'];
|
videoReview = json['video_review'];
|
||||||
pubdate = json['pubdate'];
|
pubdate = json['pubdate'];
|
||||||
senddate = json['senddate'];
|
senddate = json['senddate'];
|
||||||
|
|||||||
@ -201,6 +201,7 @@ class _AboutPageState extends State<AboutPage> {
|
|||||||
var cleanStatus = await CacheManage().clearCacheAll();
|
var cleanStatus = await CacheManage().clearCacheAll();
|
||||||
if (cleanStatus) {
|
if (cleanStatus) {
|
||||||
getCacheSize();
|
getCacheSize();
|
||||||
|
SmartDialog.showToast('清除成功');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: const Text('清除缓存'),
|
title: const Text('清除缓存'),
|
||||||
@ -253,16 +254,12 @@ class AboutController extends GetxController {
|
|||||||
// 获取远程版本
|
// 获取远程版本
|
||||||
Future getRemoteApp() async {
|
Future getRemoteApp() async {
|
||||||
var result = await Request().get(Api.latestApp, extra: {'ua': 'pc'});
|
var result = await Request().get(Api.latestApp, extra: {'ua': 'pc'});
|
||||||
isLoading.value = false;
|
|
||||||
if (result.data == null || result.data.isEmpty) {
|
|
||||||
SmartDialog.showToast('获取远程版本失败,请检查网络');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
data = LatestDataModel.fromJson(result.data);
|
data = LatestDataModel.fromJson(result.data);
|
||||||
remoteAppInfo = data;
|
remoteAppInfo = data;
|
||||||
remoteVersion.value = data.tagName!;
|
remoteVersion.value = data.tagName!;
|
||||||
isUpdate.value =
|
isUpdate.value =
|
||||||
Utils.needUpdate(currentVersion.value, remoteVersion.value);
|
Utils.needUpdate(currentVersion.value, remoteVersion.value);
|
||||||
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转下载/本地更新
|
// 跳转下载/本地更新
|
||||||
@ -280,7 +277,7 @@ class AboutController extends GetxController {
|
|||||||
|
|
||||||
githubRelease() {
|
githubRelease() {
|
||||||
launchUrl(
|
launchUrl(
|
||||||
Uri.parse('https://github.com/guozhigq/pilipala/releases'),
|
Uri.parse('https://github.com/guozhigq/pilipala/release'),
|
||||||
mode: LaunchMode.externalApplication,
|
mode: LaunchMode.externalApplication,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ class BottomControl extends StatefulWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
class _BottomControlState extends State<BottomControl> {
|
class _BottomControlState extends State<BottomControl> {
|
||||||
late PlayUrlModel videoInfo;
|
late PlayUrlModel videoInfo;
|
||||||
|
List<PlaySpeed> playSpeed = PlaySpeed.values;
|
||||||
TextStyle subTitleStyle = const TextStyle(fontSize: 12);
|
TextStyle subTitleStyle = const TextStyle(fontSize: 12);
|
||||||
TextStyle titleStyle = const TextStyle(fontSize: 14);
|
TextStyle titleStyle = const TextStyle(fontSize: 14);
|
||||||
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
||||||
|
|||||||
@ -173,12 +173,6 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
setKey: SettingBoxKey.enableAi,
|
setKey: SettingBoxKey.enableAi,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
),
|
),
|
||||||
const SetSwitchItem(
|
|
||||||
title: '相关视频推荐',
|
|
||||||
subTitle: '视频详情页推荐相关视频',
|
|
||||||
setKey: SettingBoxKey.enableRelatedVideo,
|
|
||||||
defaultVal: true,
|
|
||||||
),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
title: Text('评论展示', style: titleStyle),
|
title: Text('评论展示', style: titleStyle),
|
||||||
|
|||||||
@ -17,7 +17,6 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
Box videoStorage = GStrorage.video;
|
Box videoStorage = GStrorage.video;
|
||||||
Box settingStorage = GStrorage.setting;
|
Box settingStorage = GStrorage.setting;
|
||||||
late double playSpeedDefault;
|
late double playSpeedDefault;
|
||||||
late List<double> playSpeedSystem;
|
|
||||||
late double longPressSpeedDefault;
|
late double longPressSpeedDefault;
|
||||||
late List customSpeedsList;
|
late List customSpeedsList;
|
||||||
late bool enableAutoLongPressSpeed;
|
late bool enableAutoLongPressSpeed;
|
||||||
@ -54,9 +53,6 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
// 系统预设倍速
|
|
||||||
playSpeedSystem =
|
|
||||||
videoStorage.get(VideoBoxKey.playSpeedSystem, defaultValue: playSpeed);
|
|
||||||
// 默认倍速
|
// 默认倍速
|
||||||
playSpeedDefault =
|
playSpeedDefault =
|
||||||
videoStorage.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
|
videoStorage.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
|
||||||
@ -68,7 +64,6 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
videoStorage.get(VideoBoxKey.customSpeedsList, defaultValue: []);
|
videoStorage.get(VideoBoxKey.customSpeedsList, defaultValue: []);
|
||||||
enableAutoLongPressSpeed = settingStorage
|
enableAutoLongPressSpeed = settingStorage
|
||||||
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
|
.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
|
||||||
// 开启动态长按倍速时不展示
|
|
||||||
if (enableAutoLongPressSpeed) {
|
if (enableAutoLongPressSpeed) {
|
||||||
Map newItem = sheetMenu[1];
|
Map newItem = sheetMenu[1];
|
||||||
newItem['show'] = false;
|
newItem['show'] = false;
|
||||||
@ -128,7 +123,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设定倍速弹窗
|
// 设定倍速弹窗
|
||||||
void showBottomSheet(String type, int i) {
|
void showBottomSheet(type, i) {
|
||||||
showModalBottomSheet<void>(
|
showModalBottomSheet<void>(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
@ -164,11 +159,18 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void menuAction(type, int index, id) async {
|
void menuAction(type, index, id) async {
|
||||||
double chooseSpeed = 1.0;
|
double chooseSpeed = 1.0;
|
||||||
|
if (type == 'system' && id == -1) {
|
||||||
|
SmartDialog.showToast('系统预设倍速不支持删除');
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 获取当前选中的倍速值
|
// 获取当前选中的倍速值
|
||||||
chooseSpeed =
|
if (type == 'system') {
|
||||||
type == 'system' ? playSpeedSystem[index] : customSpeedsList[index];
|
chooseSpeed = PlaySpeed.values[index].value;
|
||||||
|
} else {
|
||||||
|
chooseSpeed = customSpeedsList[index];
|
||||||
|
}
|
||||||
// 设置
|
// 设置
|
||||||
if (id == 1) {
|
if (id == 1) {
|
||||||
// 设置默认倍速
|
// 设置默认倍速
|
||||||
@ -180,22 +182,17 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
videoStorage.put(
|
videoStorage.put(
|
||||||
VideoBoxKey.longPressSpeedDefault, longPressSpeedDefault);
|
VideoBoxKey.longPressSpeedDefault, longPressSpeedDefault);
|
||||||
} else if (id == -1) {
|
} else if (id == -1) {
|
||||||
late List speedsList =
|
if (customSpeedsList[index] == playSpeedDefault) {
|
||||||
type == 'system' ? playSpeedSystem : customSpeedsList;
|
playSpeedDefault = 1.0;
|
||||||
if (speedsList[index] == playSpeedDefault) {
|
videoStorage.put(VideoBoxKey.playSpeedDefault, playSpeedDefault);
|
||||||
SmartDialog.showToast('默认倍速不可删除');
|
|
||||||
}
|
}
|
||||||
if (speedsList[index] == longPressSpeedDefault) {
|
if (customSpeedsList[index] == longPressSpeedDefault) {
|
||||||
longPressSpeedDefault = 2.0;
|
longPressSpeedDefault = 2.0;
|
||||||
videoStorage.put(
|
videoStorage.put(
|
||||||
VideoBoxKey.longPressSpeedDefault, longPressSpeedDefault);
|
VideoBoxKey.longPressSpeedDefault, longPressSpeedDefault);
|
||||||
}
|
}
|
||||||
speedsList.removeAt(index);
|
customSpeedsList.removeAt(index);
|
||||||
await videoStorage.put(
|
await videoStorage.put(VideoBoxKey.customSpeedsList, customSpeedsList);
|
||||||
type == 'system'
|
|
||||||
? VideoBoxKey.playSpeedSystem
|
|
||||||
: VideoBoxKey.customSpeedsList,
|
|
||||||
speedsList);
|
|
||||||
}
|
}
|
||||||
setState(() {});
|
setState(() {});
|
||||||
SmartDialog.showToast('操作成功');
|
SmartDialog.showToast('操作成功');
|
||||||
@ -252,7 +249,6 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
subtitle: Text(longPressSpeedDefault.toString()),
|
subtitle: Text(longPressSpeedDefault.toString()),
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
if (playSpeedSystem.isNotEmpty) ...[
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 14,
|
left: 14,
|
||||||
@ -276,16 +272,15 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
|
|||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 2,
|
runSpacing: 2,
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < playSpeedSystem.length; i++) ...[
|
for (var i in PlaySpeed.values) ...[
|
||||||
FilledButton.tonal(
|
FilledButton.tonal(
|
||||||
onPressed: () => showBottomSheet('system', i),
|
onPressed: () => showBottomSheet('system', i.index),
|
||||||
child: Text(playSpeedSystem[i].toString()),
|
child: Text(i.description),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 14,
|
left: 14,
|
||||||
|
|||||||
@ -91,7 +91,6 @@ class VideoDetailController extends GetxController
|
|||||||
late int cacheAudioQa;
|
late int cacheAudioQa;
|
||||||
|
|
||||||
PersistentBottomSheetController? replyReplyBottomSheetCtr;
|
PersistentBottomSheetController? replyReplyBottomSheetCtr;
|
||||||
late bool enableRelatedVideo;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -114,8 +113,7 @@ class VideoDetailController extends GetxController
|
|||||||
autoPlay.value =
|
autoPlay.value =
|
||||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||||
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
||||||
enableRelatedVideo =
|
|
||||||
setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true);
|
|
||||||
if (userInfo == null ||
|
if (userInfo == null ||
|
||||||
localCache.get(LocalCacheKey.historyPause) == true) {
|
localCache.get(LocalCacheKey.historyPause) == true) {
|
||||||
enableHeart = false;
|
enableHeart = false;
|
||||||
|
|||||||
@ -521,9 +521,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
.withOpacity(0.06),
|
.withOpacity(0.06),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (videoDetailController.videoType ==
|
|
||||||
SearchType.video &&
|
|
||||||
videoDetailController.enableRelatedVideo)
|
|
||||||
const RelatedVideoPanel(),
|
const RelatedVideoPanel(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
class _HeaderControlState extends State<HeaderControl> {
|
class _HeaderControlState extends State<HeaderControl> {
|
||||||
late PlayUrlModel videoInfo;
|
late PlayUrlModel videoInfo;
|
||||||
|
List<PlaySpeed> playSpeed = PlaySpeed.values;
|
||||||
static const TextStyle subTitleStyle = TextStyle(fontSize: 12);
|
static const TextStyle subTitleStyle = TextStyle(fontSize: 12);
|
||||||
static const TextStyle titleStyle = TextStyle(fontSize: 14);
|
static const TextStyle titleStyle = TextStyle(fontSize: 14);
|
||||||
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
Size get preferredSize => const Size(double.infinity, kToolbarHeight);
|
||||||
|
|||||||
@ -292,19 +292,11 @@ class PlPlayerController {
|
|||||||
_longPressSpeed.value = videoStorage
|
_longPressSpeed.value = videoStorage
|
||||||
.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 2.0);
|
.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 2.0);
|
||||||
}
|
}
|
||||||
// 自定义倍速集合
|
|
||||||
speedsList = List<double>.from(videoStorage
|
speedsList = List<double>.from(videoStorage
|
||||||
.get(VideoBoxKey.customSpeedsList, defaultValue: <double>[]));
|
.get(VideoBoxKey.customSpeedsList, defaultValue: <double>[]));
|
||||||
// 默认倍速
|
for (final PlaySpeed i in PlaySpeed.values) {
|
||||||
speedsList = List<double>.from(videoStorage
|
speedsList.add(i.value);
|
||||||
.get(VideoBoxKey.customSpeedsList, defaultValue: <double>[]));
|
}
|
||||||
//playSpeedSystem
|
|
||||||
final List<double> playSpeedSystem =
|
|
||||||
videoStorage.get(VideoBoxKey.playSpeedSystem, defaultValue: playSpeed);
|
|
||||||
|
|
||||||
// for (final PlaySpeed i in PlaySpeed.values) {
|
|
||||||
speedsList.addAll(playSpeedSystem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) {
|
// _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) {
|
||||||
// if (status == PlayerStatus.playing) {
|
// if (status == PlayerStatus.playing) {
|
||||||
@ -684,6 +676,18 @@ class PlPlayerController {
|
|||||||
_playbackSpeed.value = speed;
|
_playbackSpeed.value = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 设置倍速
|
||||||
|
// Future<void> togglePlaybackSpeed() async {
|
||||||
|
// List<double> allowedSpeeds =
|
||||||
|
// PlaySpeed.values.map<double>((e) => e.value).toList();
|
||||||
|
// int index = allowedSpeeds.indexOf(_playbackSpeed.value);
|
||||||
|
// if (index < allowedSpeeds.length - 1) {
|
||||||
|
// setPlaybackSpeed(allowedSpeeds[index + 1]);
|
||||||
|
// } else {
|
||||||
|
// setPlaybackSpeed(allowedSpeeds[0]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/// 播放视频
|
/// 播放视频
|
||||||
/// TODO _duration.value丢失
|
/// TODO _duration.value丢失
|
||||||
Future<void> play(
|
Future<void> play(
|
||||||
|
|||||||
@ -1,15 +1,39 @@
|
|||||||
List<double> generatePlaySpeedList() {
|
enum PlaySpeed {
|
||||||
List<double> playSpeed = [];
|
pointTwoFive,
|
||||||
double startSpeed = 0.25;
|
pointFive,
|
||||||
double endSpeed = 2.0;
|
pointSevenFive,
|
||||||
double increment = 0.25;
|
|
||||||
|
|
||||||
for (double speed = startSpeed; speed <= endSpeed; speed += increment) {
|
one,
|
||||||
playSpeed.add(speed);
|
onePointTwoFive,
|
||||||
|
onePointFive,
|
||||||
|
onePointSevenFive,
|
||||||
|
|
||||||
|
two,
|
||||||
}
|
}
|
||||||
|
|
||||||
return playSpeed;
|
extension PlaySpeedExtension on PlaySpeed {
|
||||||
}
|
static final List<String> _descList = [
|
||||||
|
'0.25',
|
||||||
|
'0.5',
|
||||||
|
'0.75',
|
||||||
|
'正常',
|
||||||
|
'1.25',
|
||||||
|
'1.5',
|
||||||
|
'1.75',
|
||||||
|
'2.0',
|
||||||
|
];
|
||||||
|
String get description => _descList[index];
|
||||||
|
|
||||||
// 导出 playSpeed 列表
|
static final List<double> _valueList = [
|
||||||
List<double> playSpeed = generatePlaySpeedList();
|
0.25,
|
||||||
|
0.5,
|
||||||
|
0.75,
|
||||||
|
1.0,
|
||||||
|
1.25,
|
||||||
|
1.5,
|
||||||
|
1.75,
|
||||||
|
2.0,
|
||||||
|
];
|
||||||
|
double get value => _valueList[index];
|
||||||
|
double get defaultValue => _valueList[3];
|
||||||
|
}
|
||||||
|
|||||||
40
lib/services/disable_battery_opt.dart
Normal file
40
lib/services/disable_battery_opt.dart
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:disable_battery_optimization/disable_battery_optimization.dart';
|
||||||
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
void DisableBatteryOpt() async {
|
||||||
|
if (!Platform.isAndroid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 本地缓存中读取 是否禁用了电池优化 默认未禁用
|
||||||
|
bool isDisableBatteryOptLocal =
|
||||||
|
GStrorage.localCache.get('isDisableBatteryOptLocal', defaultValue: false);
|
||||||
|
if (!isDisableBatteryOptLocal) {
|
||||||
|
final isBatteryOptimizationDisabled =
|
||||||
|
await DisableBatteryOptimization.isBatteryOptimizationDisabled;
|
||||||
|
if (isBatteryOptimizationDisabled == false) {
|
||||||
|
final hasDisabled = await DisableBatteryOptimization
|
||||||
|
.showDisableBatteryOptimizationSettings();
|
||||||
|
// 设置为已禁用
|
||||||
|
GStrorage.localCache.put('isDisableBatteryOptLocal', hasDisabled == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isManufacturerBatteryOptimizationDisabled = GStrorage.localCache
|
||||||
|
.get('isManufacturerBatteryOptimizationDisabled', defaultValue: false);
|
||||||
|
if (!isManufacturerBatteryOptimizationDisabled) {
|
||||||
|
final isManBatteryOptimizationDisabled = await DisableBatteryOptimization
|
||||||
|
.isManufacturerBatteryOptimizationDisabled;
|
||||||
|
if (isManBatteryOptimizationDisabled == false) {
|
||||||
|
final hasDisabled = await DisableBatteryOptimization
|
||||||
|
.showDisableManufacturerBatteryOptimizationSettings(
|
||||||
|
"当前设备可能有额外的电池优化",
|
||||||
|
"按照步骤操作以禁用电池优化,以保证应用在后台正常运行",
|
||||||
|
);
|
||||||
|
// 设置为已禁用
|
||||||
|
GStrorage.localCache.put(
|
||||||
|
'isManufacturerBatteryOptimizationDisabled', hasDisabled == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -99,9 +99,11 @@ class CacheManage {
|
|||||||
try {
|
try {
|
||||||
// 清除缓存 图片缓存
|
// 清除缓存 图片缓存
|
||||||
await clearLibraryCache();
|
await clearLibraryCache();
|
||||||
|
Timer(const Duration(milliseconds: 500), () {
|
||||||
SmartDialog.dismiss().then((res) {
|
SmartDialog.dismiss().then((res) {
|
||||||
SmartDialog.showToast('清除完成');
|
SmartDialog.showToast('清除完成');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
SmartDialog.showToast(err.toString());
|
SmartDialog.showToast(err.toString());
|
||||||
|
|||||||
@ -131,8 +131,7 @@ class SettingBoxKey {
|
|||||||
enableSearchWord = 'enableSearchWord',
|
enableSearchWord = 'enableSearchWord',
|
||||||
enableSystemProxy = 'enableSystemProxy',
|
enableSystemProxy = 'enableSystemProxy',
|
||||||
enableAi = 'enableAi',
|
enableAi = 'enableAi',
|
||||||
defaultHomePage = 'defaultHomePage',
|
defaultHomePage = 'defaultHomePage';
|
||||||
enableRelatedVideo = 'enableRelatedVideo';
|
|
||||||
|
|
||||||
/// 外观
|
/// 外观
|
||||||
static const String themeMode = 'themeMode',
|
static const String themeMode = 'themeMode',
|
||||||
@ -171,6 +170,10 @@ class LocalCacheKey {
|
|||||||
// 代理host port
|
// 代理host port
|
||||||
systemProxyHost = 'systemProxyHost',
|
systemProxyHost = 'systemProxyHost',
|
||||||
systemProxyPort = 'systemProxyPort';
|
systemProxyPort = 'systemProxyPort';
|
||||||
|
|
||||||
|
static const String isDisableBatteryOptLocal = 'isDisableBatteryOptLocal',
|
||||||
|
isManufacturerBatteryOptimizationDisabled =
|
||||||
|
'isManufacturerBatteryOptimizationDisabled';
|
||||||
}
|
}
|
||||||
|
|
||||||
class VideoBoxKey {
|
class VideoBoxKey {
|
||||||
@ -182,8 +185,6 @@ class VideoBoxKey {
|
|||||||
videoSpeed = 'videoSpeed',
|
videoSpeed = 'videoSpeed',
|
||||||
// 播放顺序
|
// 播放顺序
|
||||||
playRepeat = 'playRepeat',
|
playRepeat = 'playRepeat',
|
||||||
// 系统预设倍速
|
|
||||||
playSpeedSystem = 'playSpeedSystem',
|
|
||||||
// 默认倍速
|
// 默认倍速
|
||||||
playSpeedDefault = 'playSpeedDefault',
|
playSpeedDefault = 'playSpeedDefault',
|
||||||
// 默认长按倍速
|
// 默认长按倍速
|
||||||
|
|||||||
@ -50,9 +50,6 @@ class Utils {
|
|||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
if (time < 3600) {
|
if (time < 3600) {
|
||||||
if (time == 0) {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
final int minute = time ~/ 60;
|
final int minute = time ~/ 60;
|
||||||
final double res = time / 60;
|
final double res = time / 60;
|
||||||
if (minute != res) {
|
if (minute != res) {
|
||||||
@ -90,9 +87,6 @@ class Utils {
|
|||||||
|
|
||||||
// 时间显示,刚刚,x分钟前
|
// 时间显示,刚刚,x分钟前
|
||||||
static String dateFormat(timeStamp, {formatType = 'list'}) {
|
static String dateFormat(timeStamp, {formatType = 'list'}) {
|
||||||
if (timeStamp == 0 || timeStamp == null || timeStamp == '') {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// 当前时间
|
// 当前时间
|
||||||
int time = (DateTime.now().millisecondsSinceEpoch / 1000).round();
|
int time = (DateTime.now().millisecondsSinceEpoch / 1000).round();
|
||||||
// 对比
|
// 对比
|
||||||
@ -109,7 +103,6 @@ class Utils {
|
|||||||
toInt: false,
|
toInt: false,
|
||||||
formatType: formatType);
|
formatType: formatType);
|
||||||
}
|
}
|
||||||
print('distance: $distance');
|
|
||||||
if (distance <= 60) {
|
if (distance <= 60) {
|
||||||
return '刚刚';
|
return '刚刚';
|
||||||
} else if (distance <= 3600) {
|
} else if (distance <= 3600) {
|
||||||
@ -243,10 +236,6 @@ class Utils {
|
|||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
var currentInfo = await PackageInfo.fromPlatform();
|
var currentInfo = await PackageInfo.fromPlatform();
|
||||||
var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
|
var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
|
||||||
if (result.data == null || result.data.isEmpty) {
|
|
||||||
SmartDialog.showToast('获取远程版本失败,请检查网络');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LatestDataModel data = LatestDataModel.fromJson(result.data);
|
LatestDataModel data = LatestDataModel.fromJson(result.data);
|
||||||
bool isUpdate = Utils.needUpdate(currentInfo.version, data.tagName!);
|
bool isUpdate = Utils.needUpdate(currentInfo.version, data.tagName!);
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
@ -355,8 +344,9 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static List<int> generateRandomBytes(int minLength, int maxLength) {
|
static List<int> generateRandomBytes(int minLength, int maxLength) {
|
||||||
return List<int>.generate(random.nextInt(maxLength - minLength + 1),
|
return List<int>.generate(
|
||||||
(_) => random.nextInt(0x60) + 0x20);
|
random.nextInt(maxLength-minLength+1), (_) => random.nextInt(0x60) + 0x20
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String base64EncodeRandomString(int minLength, int maxLength) {
|
static String base64EncodeRandomString(int minLength, int maxLength) {
|
||||||
|
|||||||
@ -393,6 +393,14 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.0"
|
||||||
|
disable_battery_optimization:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: disable_battery_optimization
|
||||||
|
sha256: "6b2ba802f984af141faf1b6b5fb956d5ef01f9cd555597c35b9cc335a03185ba"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.1"
|
||||||
dismissible_page:
|
dismissible_page:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -140,6 +140,8 @@ dependencies:
|
|||||||
catcher_2: ^1.1.0
|
catcher_2: ^1.1.0
|
||||||
logger: ^2.0.2+1
|
logger: ^2.0.2+1
|
||||||
path: 1.8.3
|
path: 1.8.3
|
||||||
|
# 电池优化
|
||||||
|
disable_battery_optimization: ^1.1.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user