Skip to content

Commit

Permalink
feat: 《一些更新》
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Dec 22, 2024
1 parent 659455e commit d26257e
Show file tree
Hide file tree
Showing 97 changed files with 3,076 additions and 1,604 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ flutter --version
Android相关版本:
> JDK: 21.0.4
> gradle: 8.10.2
> kotlin: 1.9.22
> kotlin: 2.0.20
> minSdk: 21
> targetSdk: 34
> compileSdk: 34
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ flutter {
}

dependencies {
implementation 'androidx.annotation:annotation:1.9.0'
implementation 'org.conscrypt:conscrypt-android:2.5.2'
api 'androidx.annotation:annotation:1.9.0'
api 'org.conscrypt:conscrypt-android:2.5.2'
}

ext.abiCodes = ["x86_64": 1, "armeabi-v7a": 2, "arm64-v8a": 3]
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.orz12.PiliPalaX">
xmlns:tools="http://schemas.android.com/tools">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
5 changes: 3 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.orz12.PiliPalaX">
xmlns:tools="http://schemas.android.com/tools"
>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -39,7 +40,6 @@
android:label="PiliPalaX"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
xmlns:tools="http://schemas.android.com/tools"
android:enableOnBackInvokedCallback="false"
android:allowBackup="false"
android:fullBackupContent="false"
Expand Down Expand Up @@ -193,6 +193,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" tools:ignore="ProtectedPermissions"/>
<!--
Media access permissions.
Android 13 or higher.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.orz12.PiliPalaX
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
//import io.flutter.plugin.common.MethodChannel
//import com.ryanheise.audioservice.AudioServiceActivity
import com.ryanheise.audioservice.AudioServiceActivity
import com.ryanheise.audioservice.AudioServicePlugin
import android.os.Build
import android.os.Bundle
Expand All @@ -13,7 +13,7 @@ import android.content.Context
import androidx.annotation.NonNull

//class AudioServiceActivity : FlPiPActivity() {
class MainActivity : FlPiPActivity() {
class MainActivity: FlPiPActivity() {
// private lateinit var methodChannel: MethodChannel

override fun provideFlutterEngine(context: Context): FlutterEngine {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.orz12.PiliPalaX">
>
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
43 changes: 43 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,45 @@ subprojects {
namespace project.group
}
}

// Task to ensure namespace and remove package attribute
project.tasks.register("fixManifestsAndNamespace") {
doLast {
// Ensure namespace in build.gradle
def buildGradleFile = file("${project.projectDir}/build.gradle")
if (buildGradleFile.exists()) {
def buildGradleContent = buildGradleFile.getText('UTF-8')
def manifestFile = file("${project.projectDir}/src/main/AndroidManifest.xml")
if (manifestFile.exists()) {
def manifestContent = manifestFile.getText('UTF-8')
def packageName = manifestContent.find(/package="([^"]+)"/) { match, p -> p }
if (packageName && !buildGradleContent.contains("namespace")) {
println "Setting namespace in ${buildGradleFile}"
buildGradleContent = buildGradleContent.replaceFirst(
/android\s*\{/, "android {\n namespace '${packageName}'"
)
buildGradleFile.write(buildGradleContent, 'UTF-8')
}
}
}

// Remove package attribute from AndroidManifest.xml
def manifests = fileTree(dir: project.projectDir, includes: ['**/AndroidManifest.xml'])
manifests.each { File manifestFile ->
def manifestContent = manifestFile.getText('UTF-8')
if (manifestContent.contains('package=')) {
println "Removing package attribute from ${manifestFile}"
manifestContent = manifestContent.replaceAll(/package="[^"]*"/, '')
manifestFile.write(manifestContent, 'UTF-8')
}
}
}
}

// Ensure the task runs before the build process
project.tasks.matching { it.name.startsWith("preBuild") }.all {
dependsOn project.tasks.named("fixManifestsAndNamespace")
}
}
}
project.buildDir = "${rootProject.buildDir}/${project.name}"
Expand All @@ -59,3 +98,7 @@ subprojects {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

ext {
kotlin_version = '2.0.20'
}
2 changes: 1 addition & 1 deletion lib/common/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Constants {
static const String traceId =
'11111111111111111111111111111111:1111111111111111:0:0';
static const String userAgent =
'Mozilla/5.0 BiliDroid/1.46.2 ([email protected]) os/android model/vivo mobi_app/android_hd build/1462100 channel/yingyongbao innerVer/1462100 osVer/14 network/2';
'Mozilla/5.0 BiliDroid/1.46.2 ([email protected]) os/android model/vivo mobi_app/android_hd build/2001100 channel/yingyongbao innerVer/2001100 osVer/14 network/2';
static const String statistics = '%7B%22appId%22%3A5%2C%22platform%22%3A3%2C%22version%22%3A%221.46.2%22%2C%22abtest%22%3A%22%22%7D';
//Uri.encodeComponent('{"appId": 5,"platform": 3,"version": "1.46.2","abtest": ""}');

Expand Down
6 changes: 5 additions & 1 deletion lib/common/widgets/audio_video_progress_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

import '../../utils/utils.dart';

/// This is where the current time and total time labels should appear in
/// relation to the progress bar.
enum TimeLabelLocation {
Expand Down Expand Up @@ -1102,7 +1104,9 @@ class _RenderProgressBar extends RenderBox {
// description
config.textDirection = TextDirection.ltr;
config.label = '进度条'; //'Progress bar';
config.value = '${(_thumbValue * 100).round()}%';
config.value = '${(_thumbValue * 100).round()}%,'
'已播放${Utils.durationReadFormat(Utils.timeFormat(progress.inSeconds))},'
'共${Utils.durationReadFormat(Utils.timeFormat(total.inSeconds))}';

// increase action
config.onIncrease = increaseAction;
Expand Down
2 changes: 1 addition & 1 deletion lib/common/widgets/badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class PBadge extends StatelessWidget {
border: Border.all(color: borderColor),
),
child: Text(
text ?? "",
text == "ketang" ? "课堂" : text ?? "",
style: TextStyle(
height: 1,
fontSize: fs ?? fontSize,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/widgets/spring_physics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CustomTabBarViewScrollPhysics extends ScrollPhysics {

@override
SpringDescription get spring => const SpringDescription(
mass: 100,
mass: 40,
stiffness: 10,
damping: 1,
);
Expand Down
16 changes: 11 additions & 5 deletions lib/common/widgets/video_card_v.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class VideoCardV extends StatelessWidget {

void onPushDetail(heroTag) async {
String goto = videoItem.goto;
print("goto $goto");
switch (goto) {
case 'bangumi':
if (videoItem.bangumiBadge == '电影') {
Expand Down Expand Up @@ -63,12 +64,17 @@ class VideoCardV extends StatelessWidget {
}
break;
case 'av':
print("currentRoute: ${Get.currentRoute}");
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}', arguments: {
// 'videoItem': videoItem,
'pic': videoItem.pic,
'heroTag': heroTag,
});
Get.toNamed(
'/video?bvid=$bvid&cid=${videoItem.cid}',
arguments: {
// 'videoItem': videoItem,
'pic': videoItem.pic,
'heroTag': heroTag,
},
// preventDuplicates: false,
);
break;
// 动态
case 'picture':
Expand Down
64 changes: 35 additions & 29 deletions lib/common/widgets/video_popup_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,21 @@ class VideoCustomActions {
}
if (videoItem is RecVideoItemAppModel) {
RecVideoItemAppModel v = videoItem as RecVideoItemAppModel;
ThreePoint? tp = v.threePoint;
if (tp == null) {
SmartDialog.showToast("未能获取threePoint");
// ThreePoint? tp = v.threePoint;
// if (tp == null) {
// SmartDialog.showToast("未能获取threePoint");
// return;
// }
// if (tp.dislikeReasons == null && tp.feedbacks == null) {
// SmartDialog.showToast("未能获取dislikeReasons或feedbacks");
// return;
// }
if (v.dislikeReasons == null) {
SmartDialog.showToast("未能获取dislikeReasons");
return;
}
if (tp.dislikeReasons == null && tp.feedbacks == null) {
SmartDialog.showToast("未能获取dislikeReasons或feedbacks");
return;
}
Widget actionButton(DislikeReason? r, FeedbackReason? f) {
Widget actionButton(DislikeReason? r) {
//, FeedbackReason? f) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
padding:
Expand All @@ -66,16 +71,17 @@ class VideoCustomActions {
SmartDialog.showLoading(msg: '正在提交');
var res = await VideoHttp.feedDislike(
reasonId: r?.id,
feedbackId: f?.id,
// feedbackId: f?.id,
id: v.param!,
goto: v.goto!,
);
SmartDialog.dismiss();
SmartDialog.showToast(
res['status'] ? (r?.toast ?? f?.toast) : res['msg']);
SmartDialog.showToast(res['status'] ? (r?.toast) : res['msg']);
// res['status'] ? (r?.toast ?? f?.toast) : res['msg']);
Get.back();
},
child: Text(r?.name ?? f?.name ?? '未知'),
child: Text(r?.name ?? '未知'),
// child: Text(r?.name ?? f?.name ?? '未知'),
);
}

Expand All @@ -87,32 +93,32 @@ class VideoCustomActions {
content: SingleChildScrollView(
child: Column(
children: [
if (tp.dislikeReasons != null)
if (v.dislikeReasons != null)
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Text('我不想看'),
),
if (tp.dislikeReasons != null)
Wrap(
spacing: 5.0,
runSpacing: 2.0,
children: tp.dislikeReasons!.map((item) {
return actionButton(item, null);
}).toList(),
),
if (tp.feedbacks != null)
const Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Text('反馈'),
),
if (tp.feedbacks != null)
if (v.dislikeReasons != null)
Wrap(
spacing: 5.0,
runSpacing: 2.0,
children: tp.feedbacks!.map((item) {
return actionButton(null, item);
children: v.dislikeReasons!.map((item) {
return actionButton(item);
}).toList(),
),
// if (tp.feedbacks != null)
// const Padding(
// padding: EdgeInsets.symmetric(vertical: 8.0),
// child: Text('反馈'),
// ),
// if (tp.feedbacks != null)
// Wrap(
// spacing: 5.0,
// runSpacing: 2.0,
// children: tp.feedbacks!.map((item) {
// return actionButton(null, item);
// }).toList(),
// ),
//分割线
const Divider(),
ElevatedButton(
Expand Down
5 changes: 4 additions & 1 deletion lib/http/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Api {
'https://s.search.bilibili.com/main/suggest';

// 分类搜索
static const String searchByType = '/x/web-interface/search/type';
static const String searchByType = '/x/web-interface/wbi/search/type';

// 记录视频播放进度
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/report.md
Expand Down Expand Up @@ -614,6 +614,9 @@ class Api {
/// 排行榜
static const String getRankApi = "/x/web-interface/ranking/v2";

/// 分区视频
static const String getRegionApi = "/x/web-interface/dynamic/region";

/// 取消订阅-合集
static const String unfavSeason = '/x/v3/fav/season/unfav';

Expand Down
10 changes: 7 additions & 3 deletions lib/http/html.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:html/dom.dart';
import 'package:html/parser.dart';
import 'index.dart';
Expand Down Expand Up @@ -84,8 +88,9 @@ class HtmlHttp {
.group(1)!
.replaceAll(r'\u002F', '/')
.split('@')[0];
// print(avatar);
print("avatar: $avatar");
String uname = authorHeader.querySelector('.up-name')!.text.trim();
print("uname: $uname");
// 动态详情
Element opusDetail = appDom.querySelector('.article-content')!;
// 发布时间
Expand All @@ -94,8 +99,7 @@ class HtmlHttp {
// print(updateTime);

//
String opusContent =
opusDetail.querySelector('#read-article-holder')?.innerHtml ?? '';
String opusContent = opusDetail.innerHtml ?? '';
RegExp digitRegExp = RegExp(r'\d+');
Iterable<Match> matches = digitRegExp.allMatches(id);
String number = matches.first.group(0)!;
Expand Down
18 changes: 18 additions & 0 deletions lib/http/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:dio_cookie_manager/dio_cookie_manager.dart';
// import 'package:dio_http2_adapter/dio_http2_adapter.dart';
import 'package:hive/hive.dart';
import 'package:PiliPalaX/utils/id_utils.dart';
import '../utils/login.dart';
import '../utils/storage.dart';
import '../utils/utils.dart';
import 'api.dart';
Expand Down Expand Up @@ -81,6 +82,23 @@ class Request {
return token;
}

static Future<String> getBUVID() async {
List<Cookie> cookies = await cookieManager.cookieJar
.loadForRequest(Uri.parse(HttpString.apiBaseUrl));
// String token = '';
print("cookies $cookies");
if (cookies.where((e) => e.name == 'Buvid').isNotEmpty) {
return cookies.firstWhere((e) => e.name == 'Buvid').value;
}
return LoginUtils.buvid();
}

static String getRandomSessionId() {
// 返回8位随机16进制数
return List.generate(8, (index) => Random().nextInt(16).toRadixString(16))
.join();
}

static setOptionsHeaders(userInfo, bool status) {
if (status) {
dio.options.headers['x-bili-mid'] = userInfo.mid.toString();
Expand Down
Loading

0 comments on commit d26257e

Please sign in to comment.