feat: new ui (#1455)

This commit is contained in:
Levi authored and GitHub committed 2026-09-05 19:53:41 +08:00
1 parent 3be8db664c
commit 177c225f16
742 files changed
+59951 -5934

No files matched your search

+3 -1
View File
@@ -5,9 +5,11 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
.cxx/
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
/app/libs/libgopeed.aar
-88
View File
@@ -1,88 +0,0 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
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.gopeed.gopeed'
compileSdk 36
ndkVersion flutter.ndkVersion
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
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.gopeed.gopeed'
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdk flutter.minSdkVersion
targetSdk 35
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias 'upload'
keyPassword System.getenv('APK_KEY_PASSWORD')
storeFile file('upload-keystore.jks')
storePassword System.getenv('APK_STORE_PASSWORD')
}
}
buildTypes {
release {
if (signingConfigs.release.keyPassword != null) {
signingConfig signingConfigs.release
} else {
signingConfig signingConfigs.debug
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
}
flutter {
source '../..'
}
dependencies {
implementation(name: 'libgopeed', ext: 'aar')
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
}
+143
View File
@@ -0,0 +1,143 @@
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
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")
}
val apkKeyPassword = System.getenv("APK_KEY_PASSWORD")
val apkStorePassword = System.getenv("APK_STORE_PASSWORD")
android {
namespace = "com.gopeed.gopeed"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.gopeed.gopeed"
// 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
}
signingConfigs {
create("release") {
keyAlias = "upload"
keyPassword = apkKeyPassword
storeFile = file("upload-keystore.jks")
storePassword = apkStorePassword
}
}
buildTypes {
release {
signingConfig =
if (!apkKeyPassword.isNullOrEmpty() && !apkStorePassword.isNullOrEmpty()) {
signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
}
}
packaging {
jniLibs {
// Go and Flutter native libraries are large and compress well. Gopeed is
// primarily distributed as APKs, so preserve the smaller legacy layout.
useLegacyPackaging = true
}
}
}
flutter {
source = "../.."
}
dependencies {
// Generated by gomobile from bind/mobile before an Android build.
implementation(files("libs/libgopeed.aar"))
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}
// shadcn_flutter 0.0.53 unconditionally declares every Geist font and all
// country_flags assets. Android uses platform fonts below and Gopeed does not use
// PhoneInput/CountryFlag, so keep those transitive assets out of release APKs.
val pruneReleaseFlutterAssets =
tasks.register("pruneReleaseFlutterAssets") {
dependsOn("compileFlutterBuildRelease")
val generatedFlutterAssets =
layout.buildDirectory.dir("intermediates/flutter/release/flutter_assets")
doLast {
val flutterAssets = generatedFlutterAssets.get().asFile
if (!flutterAssets.isDirectory) {
throw GradleException("Generated Flutter assets not found: $flutterAssets")
}
val dartSources = fileTree(file("../../lib")) { include("**/*.dart") }
val unsupportedUsage = Regex("\\b(CountryFlag|PhoneInput)\\b|Geist(?:Sans|Mono)")
val appTheme = file("../../lib/shared/theme/app_theme.dart").canonicalFile
val allowedWindowsFontReference =
"fontFamily: 'packages/shadcn_flutter/GeistSans',"
val usageFile =
dartSources.files.firstOrNull { sourceFile ->
val source = sourceFile.readText()
val guardedSource =
if (sourceFile.canonicalFile == appTheme) {
source.replaceFirst(allowedWindowsFontReference, "")
} else {
source
}
unsupportedUsage.containsMatchIn(guardedSource)
}
if (usageFile != null) {
throw GradleException(
"Android release asset pruning is incompatible with ${usageFile.relativeTo(projectDir)}",
)
}
listOf(
flutterAssets.resolve("packages/country_flags/res/si"),
flutterAssets.resolve("packages/shadcn_flutter/lib/fonts"),
).forEach { assetDirectory ->
if (assetDirectory.exists() && !assetDirectory.deleteRecursively()) {
throw GradleException("Unable to prune Flutter assets: $assetDirectory")
}
}
val fontManifest = flutterAssets.resolve("FontManifest.json")
if (!fontManifest.isFile) {
throw GradleException("Flutter font manifest not found: $fontManifest")
}
val fonts = JsonSlurper().parse(fontManifest) as List<*>
val optimizedFonts =
fonts.filterNot { entry ->
val family = (entry as? Map<*, *>)?.get("family")
family == "packages/shadcn_flutter/GeistSans" ||
family == "packages/shadcn_flutter/GeistMono"
}
fontManifest.writeText(JsonOutput.toJson(optimizedFonts))
}
}
tasks.matching { it.name == "copyFlutterAssetsRelease" }.configureEach {
dependsOn(pruneReleaseFlutterAssets)
}
+1
View File
@@ -0,0 +1 @@
@@ -3,5 +3,5 @@
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
@@ -1,100 +1,77 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application
android:requestLegacyExternalStorage="true"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="Gopeed"
android:extractNativeLibs="true">
android:name="${applicationName}"
android:requestLegacyExternalStorage="true"
android:extractNativeLibs="true"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleInstance"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CreateDialogActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:excludeFromRecents="true"
android:exported="true"
android:finishOnTaskLaunch="true"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:theme="@style/DialogLaunchTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="file"
android:host="*"
android:pathPattern=".*torrent" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="file"
android:host="*"
android:mimeType="application/x-bittorrent" />
<data android:scheme="gopeed" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="content"
android:host="*"
android:pathPattern=".*torrent" />
<data android:scheme="magnet" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="content"
android:host="*"
android:mimeType="application/x-bittorrent" />
<data android:scheme="file" android:host="*" android:pathPattern=".*torrent" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="magnet" />
<data android:scheme="file" android:host="*" android:mimeType="application/x-bittorrent" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" android:host="*" android:pathPattern=".*torrent" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" android:host="*" android:mimeType="application/x-bittorrent" />
</intent-filter>
<!-- Handle http/https URLs with common downloadable mimeTypes -->
<intent-filter android:label="Gopeed">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -110,26 +87,29 @@
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/DialogNormalTheme" />
</activity>
<!-- Add android:stopWithTask option only when necessary. -->
<service
android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
android:foregroundServiceType="dataSync"
android:exported="false" />
android:exported="false"
android:foregroundServiceType="dataSync" />
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
@@ -1,31 +0,0 @@
package com.gopeed.gopeed
import android.os.Bundle
import android.view.Gravity
import android.view.WindowManager
import io.flutter.embedding.android.FlutterActivityLaunchConfigs
class CreateDialogActivity : MainActivity() {
override fun isDialogMode(): Boolean = true
override fun getBackgroundMode(): FlutterActivityLaunchConfigs.BackgroundMode {
return FlutterActivityLaunchConfigs.BackgroundMode.transparent
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val metrics = resources.displayMetrics
val width = (metrics.widthPixels * 0.92f).toInt()
val maxHeight = (metrics.heightPixels * 0.62f).toInt()
val preferredHeight = (420 * metrics.density).toInt()
window.setGravity(Gravity.CENTER)
window.setDimAmount(0.28f)
window.setLayout(width, minOf(maxHeight, preferredHeight))
val attrs = window.attributes
attrs.flags = attrs.flags or WindowManager.LayoutParams.FLAG_DIM_BEHIND
window.attributes = attrs
}
}
@@ -1,49 +1,41 @@
package com.gopeed.gopeed
import androidx.annotation.NonNull
import com.gopeed.libgopeed.Libgopeed
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.StandardMethodCodec
open class MainActivity : FlutterActivity() {
private val CHANNEL = "gopeed.com/libgopeed"
protected open fun isDialogMode(): Boolean = false
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
class MainActivity : FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
val taskQueue =
flutterEngine.dartExecutor.binaryMessenger.makeBackgroundTaskQueue()
MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
CHANNEL,
LIBGOPEED_CHANNEL,
StandardMethodCodec.INSTANCE,
taskQueue
taskQueue,
).setMethodCallHandler { call, result ->
when (call.method) {
"start" -> {
val cfg = call.argument<String>("cfg")
try {
val port = Libgopeed.start(cfg)
result.success(port)
} catch (e: Exception) {
result.error("ERROR", e.message, null)
result.success(Libgopeed.start(call.argument<String>("cfg")))
} catch (error: Exception) {
result.error("ERROR", error.message, null)
}
}
"stop" -> {
Libgopeed.stop()
result.success(null)
}
"isDialogMode" -> {
result.success(isDialogMode())
}
else -> {
result.notImplemented()
}
else -> result.notImplemented()
}
}
}
private companion object {
const val LIBGOPEED_CHANNEL = "gopeed.com/libgopeed"
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

@@ -15,18 +15,4 @@
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
<style name="DialogLaunchTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="DialogNormalTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
@@ -15,18 +15,4 @@
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
<style name="DialogLaunchTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="DialogNormalTheme" parent="@android:style/Theme.Translucent.NoTitleBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
@@ -3,5 +3,5 @@
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
-36
View File
@@ -1,36 +0,0 @@
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
subprojects { subproject ->
subproject.plugins.withId('com.android.library') {
subproject.android {
if (namespace == null || namespace.isEmpty()) {
def manifest = file("${subproject.projectDir}/src/main/AndroidManifest.xml")
if (manifest.exists()) {
def manifestContent = manifest.getText()
def packagePattern = /package\s*=\s*["']([^"']+)["']/
def matcher = (manifestContent =~ packagePattern)
if (matcher.find()) {
namespace = matcher.group(1)
}
}
}
}
}
}
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
+24
View File
@@ -0,0 +1,24 @@
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
+1 -5
View File
@@ -1,6 +1,2 @@
org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
android.nonTransitiveRClass=true
android.nonFinalResIds=true
android.defaults.buildfeatures.buildconfig=true
@@ -1,6 +1,5 @@
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip
-25
View File
@@ -1,25 +0,0 @@
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file('local.properties').withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty('flutter.sdk')
assert flutterSdkPath != null, 'flutter.sdk not set in local.properties'
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id 'dev.flutter.flutter-plugin-loader' version '1.0.0'
id 'com.android.application' version '8.7.3' apply false
id 'org.jetbrains.kotlin.android' version '2.1.0' apply false
}
include ':app'
+26
View File
@@ -0,0 +1,26 @@
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.11.1" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
}
include(":app")