diff --git a/.github/workflows/prbuild.yml b/.github/workflows/prbuild.yml index a0a1a09b..8ca04834 100644 --- a/.github/workflows/prbuild.yml +++ b/.github/workflows/prbuild.yml @@ -39,7 +39,7 @@ jobs: - run: flutter pub get # 打包apk - name: Collect Apks - run: flutter build apk --release --split-per-abi + run: flutter build apk --debug --split-per-abi env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }} diff --git a/android/.gitignore b/android/.gitignore index 55afd919..6f568019 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -7,7 +7,7 @@ gradle-wrapper.jar GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. -# See https://flutter.dev/to/reference-keystore +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties **/*.keystore **/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle index dad97a8d..47db0a34 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,44 +1,67 @@ plugins { id "com.android.application" id "kotlin-android" - // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id "dev.flutter.flutter-gradle-plugin" } +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + android { - namespace = "com.example.ss" - compileSdk = flutter.compileSdkVersion - ndkVersion = flutter.ndkVersion + namespace "com.example.kazumi" + compileSdk flutter.compileSdkVersion + ndkVersion flutter.ndkVersion compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.example.ss" + applicationId "com.predidit.kazumi" // You can update the following values to match your application needs. - // For more information, see: https://flutter.dev/to/review-gradle-config. - minSdk = flutter.minSdkVersion - targetSdk = flutter.targetSdkVersion - versionCode = flutter.versionCode - versionName = flutter.versionName + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.debug + signingConfig signingConfigs.debug } } } flutter { - source = "../.." + source '../..' } + +dependencies {} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index e9c1a2e1..db4f79a1 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,13 +1,13 @@ + + + + + + + + + + diff --git a/android/app/src/main/kotlin/com/example/kazumi/MainActivity.kt b/android/app/src/main/kotlin/com/example/kazumi/MainActivity.kt new file mode 100644 index 00000000..ce6bbe96 --- /dev/null +++ b/android/app/src/main/kotlin/com/example/kazumi/MainActivity.kt @@ -0,0 +1,38 @@ +package com.example.kazumi + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import androidx.annotation.NonNull +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugin.common.MethodChannel +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { + private val CHANNEL = "com.predidit.kazumi/intent" + + override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result -> + if (call.method == "openWithMime") { + val url = call.argument("url") + val mimeType = call.argument("mimeType") + if (url != null && mimeType != null) { + openWithMime(url, mimeType) + result.success(null) + } else { + result.error("INVALID_ARGUMENT", "URL and MIME type required", null) + } + } else { + result.notImplemented() + } + } + } + + private fun openWithMime(url: String, mimeType: String) { + val intent = Intent() + intent.action = Intent.ACTION_VIEW + intent.setDataAndType(Uri.parse(url), mimeType) + startActivity(intent) + } +} diff --git a/android/app/src/main/kotlin/com/example/ss/MainActivity.kt b/android/app/src/main/kotlin/com/example/ss/MainActivity.kt deleted file mode 100644 index 578c8d86..00000000 --- a/android/app/src/main/kotlin/com/example/ss/MainActivity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.example.ss - -import io.flutter.embedding.android.FlutterActivity - -class MainActivity: FlutterActivity() diff --git a/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..6a33ac2f Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..8855db85 Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..b3a14d62 Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..5715379f Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 00000000..e89bc773 Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..5f349f7f --- /dev/null +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index db77bb4b..9127e85f 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index 17987b79..a8504ab8 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 09d43914..01802efe 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index d5f1c8d3..94279e0c 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 4d6372ee..1bc56742 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..ab983282 --- /dev/null +++ b/android/app/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #ffffff + \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index d2ffbffa..bc157bd1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,12 +5,12 @@ allprojects { } } -rootProject.buildDir = "../build" +rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(":app") + project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { diff --git a/android/gradle.properties b/android/gradle.properties index 25971708..598d13fe 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx4G android.useAndroidX=true android.enableJetifier=true diff --git a/android/settings.gradle b/android/settings.gradle index a17a49e8..1d6d19b7 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -5,9 +5,10 @@ pluginManagement { def flutterSdkPath = properties.getProperty("flutter.sdk") assert flutterSdkPath != null, "flutter.sdk not set in local.properties" return flutterSdkPath - }() + } + settings.ext.flutterSdkPath = flutterSdkPath() - includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") repositories { google() @@ -19,7 +20,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.0" apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply true + id "org.jetbrains.kotlin.android" version "1.7.10" apply false } include ":app" diff --git a/lib/views/pages/watch/video/video_player_content.dart b/lib/views/pages/watch/video/video_player_content.dart index 72265092..c9b8f1ad 100644 --- a/lib/views/pages/watch/video/video_player_content.dart +++ b/lib/views/pages/watch/video/video_player_content.dart @@ -467,6 +467,31 @@ PopupMenuButton( ]; }, ), + PopupMenuButton( + tooltip: "Toggle Danmaku", + icon: const Icon( + Icons.comment, + color: Colors.white, + ), + itemBuilder: (context) { + return [ + PopupMenuItem( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: Obx(() { + return CheckboxListTile( + value: _c.danmakuOn.value, + onChanged: (bool? value) { + if (value != null) { + _c.toggleDanmaku(); + } + }, + title: Text('Toggle Danmaku'), + ); + }), + ), + ]; + }, +), Obx(() { if (_c.currentQality.value.isEmpty) { return const SizedBox.shrink(); diff --git a/pubspec.yaml b/pubspec.yaml index 3841c0e7..a0c8264c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: flutter_code_editor: ^0.3.0 flutter_highlight: ^0.7.0 flutter_i18n: ^0.35.1 - flutter_js: ^0.8.0 + flutter_js: ^0.8.1 flutter_markdown: ^0.6.23 get: ^4.6.5 canvas_danmaku: ^0.1.8