diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 8411a6c..af7781c 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -2,7 +2,7 @@ name: Build and Push Images Based on Version # 在这里定义统一版本号 env: - VERSION: "v3.1.2" + VERSION: "1.4.2" on: push: diff --git a/.gitignore b/.gitignore index 6c9ac04..f547152 100644 --- a/.gitignore +++ b/.gitignore @@ -254,9 +254,6 @@ gitee/ # 证书文件 *.crt *.cert -android-app/ -ios-app/ doraemon.jks -flux.ipa device.id commit.sh \ No newline at end of file diff --git a/android-app/.gitignore b/android-app/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/android-app/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/android-app/app/.gitignore b/android-app/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/android-app/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/android-app/app/build.gradle b/android-app/app/build.gradle new file mode 100644 index 0000000..9479e51 --- /dev/null +++ b/android-app/app/build.gradle @@ -0,0 +1,45 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'com.flux' + compileSdk 34 + + defaultConfig { + applicationId "com.flux" + minSdk 24 + targetSdk 34 + versionCode 1 + versionName "1.0.1" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.7.1' + implementation 'com.google.android.material:material:1.12.0' + implementation 'androidx.constraintlayout:constraintlayout:2.2.1' + implementation 'androidx.webkit:webkit:1.8.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0' +} \ No newline at end of file diff --git a/android-app/app/proguard-rules.pro b/android-app/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/android-app/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/android-app/app/release/flux.apk b/android-app/app/release/flux.apk new file mode 100644 index 0000000..a04c67f Binary files /dev/null and b/android-app/app/release/flux.apk differ diff --git a/android-app/app/release/output-metadata.json b/android-app/app/release/output-metadata.json new file mode 100644 index 0000000..0b32f7f --- /dev/null +++ b/android-app/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.flux", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0.1", + "outputFile": "app-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/android-app/app/src/androidTest/java/com/flux/ExampleInstrumentedTest.kt b/android-app/app/src/androidTest/java/com/flux/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..1f124ec --- /dev/null +++ b/android-app/app/src/androidTest/java/com/flux/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.flux + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.flux", appContext.packageName) + } +} \ No newline at end of file diff --git a/android-app/app/src/main/AndroidManifest.xml b/android-app/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..952f2e9 --- /dev/null +++ b/android-app/app/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android-app/app/src/main/ic_launcher-playstore.png b/android-app/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..80c80a0 Binary files /dev/null and b/android-app/app/src/main/ic_launcher-playstore.png differ diff --git a/android-app/app/src/main/java/com/flux/MainActivity.kt b/android-app/app/src/main/java/com/flux/MainActivity.kt new file mode 100644 index 0000000..c766e9a --- /dev/null +++ b/android-app/app/src/main/java/com/flux/MainActivity.kt @@ -0,0 +1,214 @@ +package com.flux + +import androidx.core.content.edit +import android.graphics.Color +import android.os.Build +import android.os.Bundle +import android.view.View +import android.view.WindowInsetsController +import androidx.appcompat.app.AppCompatActivity +import android.webkit.* +import android.content.res.Configuration +import org.json.JSONArray +import org.json.JSONObject + + +class MainActivity : AppCompatActivity() { + + private lateinit var webView: WebView + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + webView = findViewById(R.id.webView) + WebView.setWebContentsDebuggingEnabled(true) + setupWebView() + loadUrl() + + setupSystemBars() + setupRootBackground() + } + + private fun setupWebView() { + val settings = webView.settings + settings.javaScriptEnabled = true + settings.domStorageEnabled = true + settings.databaseEnabled = true + settings.loadWithOverviewMode = true + settings.useWideViewPort = true + settings.setSupportZoom(true) + settings.builtInZoomControls = true + settings.displayZoomControls = false + + // 隐藏滚动条但不影响滚动 + webView.isVerticalScrollBarEnabled = false + webView.isHorizontalScrollBarEnabled = false + webView.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY + webView.overScrollMode = View.OVER_SCROLL_NEVER + + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW + } + + val isDarkTheme = resources.configuration.uiMode and + Configuration.UI_MODE_NIGHT_MASK == + Configuration.UI_MODE_NIGHT_YES + + webView.setBackgroundColor(if (isDarkTheme) Color.BLACK else Color.WHITE) + + + // 添加JavaScript接口 + webView.addJavascriptInterface(object { + + @android.webkit.JavascriptInterface + fun getPanelAddresses(callback: String) { + val sharedPrefs = getSharedPreferences("panel_config", MODE_PRIVATE) + val addresses = sharedPrefs.getString("panel_addresses", "[]") + webView.post { + webView.evaluateJavascript("window.$callback($addresses);", null) + } + } + + @android.webkit.JavascriptInterface + fun savePanelAddress(name: String, address: String) { + val json = JSONObject() + json.put("name", name) + json.put("address", address) + json.put("inx", false) + val sharedPrefs = getSharedPreferences("panel_config", MODE_PRIVATE) + val addresses = sharedPrefs.getString("panel_addresses", "[]") + val jsonArray = JSONArray(addresses) + jsonArray.put(json) + sharedPrefs.edit { + putString("panel_addresses", jsonArray.toString()) + } + webView.post { + webView.evaluateJavascript("window.setPanelAddresses(${jsonArray.toString()});", null) + } + } + + @android.webkit.JavascriptInterface + fun setCurrentPanelAddress(name: String) { + + val sharedPrefs = getSharedPreferences("panel_config", MODE_PRIVATE) + val addresses = sharedPrefs.getString("panel_addresses", "[]") + val jsonArray = JSONArray(addresses) + for (i in 0 until jsonArray.length()) { + val obj = jsonArray.getJSONObject(i) + if (name == obj.getString("name")) { + obj.put("inx", true) + }else{ + obj.put("inx", false) + } + } + sharedPrefs.edit { + putString("panel_addresses", jsonArray.toString()) + } + webView.post { + webView.evaluateJavascript("window.setPanelAddresses(${jsonArray.toString()});", null) + } + } + + @android.webkit.JavascriptInterface + fun deletePanelAddress(name: String) { + val jsonArray = JSONArray() + val sharedPrefs = getSharedPreferences("panel_config", MODE_PRIVATE) + val addresses = sharedPrefs.getString("panel_addresses", "[]") + val jsonArraya = JSONArray(addresses) + for (i in 0 until jsonArraya.length()) { + val obj = jsonArraya.getJSONObject(i) + if (name != obj.getString("name")) { + jsonArray.put(obj) + } + } + sharedPrefs.edit { + putString("panel_addresses", jsonArray.toString()) + } + webView.post { + webView.evaluateJavascript("window.setPanelAddresses(${jsonArray.toString()});", null) + } + } + }, "JsInterface") + + } + + private fun loadUrl() { + //webView.loadUrl("http://192.168.100.9:3000") + webView.loadUrl("file:///android_asset/index.html") + } + + private fun setupSystemBars() { + val isDarkTheme = resources.configuration.uiMode and + Configuration.UI_MODE_NIGHT_MASK == + Configuration.UI_MODE_NIGHT_YES + + if (isDarkTheme) { + window.statusBarColor = Color.BLACK + window.navigationBarColor = Color.BLACK + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + window.insetsController?.setSystemBarsAppearance( + 0, + WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS or + WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS + ) + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + @Suppress("DEPRECATION") + window.decorView.systemUiVisibility = + window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + @Suppress("DEPRECATION") + window.decorView.systemUiVisibility = + window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv() + } + } + } else { + window.statusBarColor = Color.WHITE + window.navigationBarColor = Color.WHITE + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + window.insetsController?.setSystemBarsAppearance( + WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS or + WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, + WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS or + WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS + ) + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + @Suppress("DEPRECATION") + window.decorView.systemUiVisibility = + window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + @Suppress("DEPRECATION") + window.decorView.systemUiVisibility = + window.decorView.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR + } + } + } + } + + override fun onBackPressed() { + if (webView.canGoBack()) webView.goBack() else super.onBackPressed() + } + + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + setupSystemBars() + setupWebViewBackground() + setupRootBackground() + } + + private fun setupWebViewBackground() { + val isDarkTheme = resources.configuration.uiMode and + Configuration.UI_MODE_NIGHT_MASK == + Configuration.UI_MODE_NIGHT_YES + webView.setBackgroundColor(if (isDarkTheme) Color.BLACK else Color.WHITE) + } + + private fun setupRootBackground() { + val isDarkTheme = resources.configuration.uiMode and + Configuration.UI_MODE_NIGHT_MASK == + Configuration.UI_MODE_NIGHT_YES + val rootView = findViewById(android.R.id.content) + rootView.setBackgroundColor(if (isDarkTheme) Color.BLACK else Color.WHITE) + } +} diff --git a/android-app/app/src/main/res/drawable/ic_launcher_background.xml b/android-app/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..ca3826a --- /dev/null +++ b/android-app/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android-app/app/src/main/res/drawable/ic_launcher_foreground.xml b/android-app/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/android-app/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android-app/app/src/main/res/layout/activity_main.xml b/android-app/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..7f11c64 --- /dev/null +++ b/android-app/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/android-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..c4a603d --- /dev/null +++ b/android-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..c4a603d --- /dev/null +++ b/android-app/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android-app/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/android-app/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..3c965f7 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/android-app/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/android-app/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..b0cc786 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ diff --git a/android-app/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/android-app/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9c7cc2c Binary files /dev/null and b/android-app/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/android-app/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/android-app/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..15b2494 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/android-app/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/android-app/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..bdc56f3 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ diff --git a/android-app/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/android-app/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..39f430d Binary files /dev/null and b/android-app/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..0a50157 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..1412240 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ diff --git a/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..80f2aef Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..6794017 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..ebce376 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ diff --git a/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..d3178ed Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..99e51c9 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp new file mode 100644 index 0000000..1fee8d3 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ diff --git a/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..2f58dc7 Binary files /dev/null and b/android-app/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/android-app/app/src/main/res/values-night/themes.xml b/android-app/app/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..6252187 --- /dev/null +++ b/android-app/app/src/main/res/values-night/themes.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/android-app/app/src/main/res/values/colors.xml b/android-app/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..aacedae --- /dev/null +++ b/android-app/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #FF000000 + #FFFFFFFF + + \ No newline at end of file diff --git a/android-app/app/src/main/res/values/strings.xml b/android-app/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..fc68ff2 --- /dev/null +++ b/android-app/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Flux + \ No newline at end of file diff --git a/android-app/app/src/main/res/values/themes.xml b/android-app/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..560737c --- /dev/null +++ b/android-app/app/src/main/res/values/themes.xml @@ -0,0 +1,11 @@ + + + + +