diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..0f326ef --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,69 @@ +name: Preview Build +on: + workflow_dispatch: + inputs: +jobs: + libcore: + name: Native Build (LibCore) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Golang Status + run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status + - name: Libcore Status + run: git ls-files libcore | xargs cat | sha1sum > libcore_status + - name: LibCore Cache + id: cache + uses: actions/cache@v4 + with: + path: | + app/libs/libcore.aar + key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }} + - name: Install Golang + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/setup-go@v5 + with: + go-version: ^1.24 + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run lib core + build: + name: Build OSS APK + runs-on: ubuntu-latest + needs: + - libcore + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Golang Status + run: find buildScript libcore/*.sh | xargs cat | sha1sum > golang_status + - name: Libcore Status + run: git ls-files libcore | xargs cat | sha1sum > libcore_status + - name: LibCore Cache + uses: actions/cache@v4 + with: + path: | + app/libs/libcore.aar + key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }} + - name: Gradle cache + uses: actions/cache@v4 + with: + path: ~/.gradle + key: gradle-oss-${{ hashFiles('**/*.gradle.kts') }} + - name: Gradle Build + env: + BUILD_PLUGIN: none + run: | + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/25.0.8775105" >> local.properties + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" + ./run init action gradle + ./gradlew app:assemblePreviewRelease + APK=$(find app/build/outputs/apk -name '*arm64-v8a*.apk') + APK=$(dirname $APK) + echo "APK=$APK" >> $GITHUB_ENV + - uses: actions/upload-artifact@v4 + with: + name: APKs + path: ${{ env.APK }} diff --git a/app/src/main/java/io/nekohasekai/sagernet/ktx/Utils.kt b/app/src/main/java/io/nekohasekai/sagernet/ktx/Utils.kt index 98bbc20..4023c9b 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ktx/Utils.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ktx/Utils.kt @@ -271,11 +271,9 @@ fun Context.getColorAttr(@AttrRes resId: Int): Int { } val isExpert: Boolean by lazy { BuildConfig.DEBUG || DataStore.isExpert } - -val isExpertFlavor = ((BuildConfig.FLAVOR == "expert") || BuildConfig.DEBUG) const val isOss = BuildConfig.FLAVOR == "oss" -const val isFdroid = BuildConfig.FLAVOR == "fdroid" const val isPlay = BuildConfig.FLAVOR == "play" +const val isPreview = BuildConfig.FLAVOR == "preview" fun Continuation.tryResume(value: T) { try { diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/MainActivity.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/MainActivity.kt index e8a17fc..9e63cab 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/MainActivity.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/MainActivity.kt @@ -41,6 +41,7 @@ import io.nekohasekai.sagernet.group.GroupInterfaceAdapter import io.nekohasekai.sagernet.group.GroupUpdater import io.nekohasekai.sagernet.ktx.alert import io.nekohasekai.sagernet.ktx.isPlay +import io.nekohasekai.sagernet.ktx.isPreview import io.nekohasekai.sagernet.ktx.launchCustomTab import io.nekohasekai.sagernet.ktx.onMainDispatcher import io.nekohasekai.sagernet.ktx.parseProxies @@ -114,6 +115,13 @@ class MainActivity : ThemedActivity(), ) } } + + if (isPreview) { + MaterialAlertDialogBuilder(this).setTitle(R.string.preview_version) + .setMessage(R.string.preview_version_hint) + .setPositiveButton(android.R.string.ok, null) + .show() + } } fun refreshNavMenu(clashApi: Boolean) { diff --git a/app/src/main/java/moe/matsuri/nb4a/ui/ColorPickerPreference.kt b/app/src/main/java/moe/matsuri/nb4a/ui/ColorPickerPreference.kt index 69a3edb..da87e9c 100644 --- a/app/src/main/java/moe/matsuri/nb4a/ui/ColorPickerPreference.kt +++ b/app/src/main/java/moe/matsuri/nb4a/ui/ColorPickerPreference.kt @@ -20,7 +20,6 @@ import androidx.preference.PreferenceViewHolder import com.google.android.material.dialog.MaterialAlertDialogBuilder import io.nekohasekai.sagernet.R import io.nekohasekai.sagernet.ktx.getColorAttr -import io.nekohasekai.sagernet.ktx.isExpertFlavor import kotlin.math.roundToInt class ColorPickerPreference diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 2dbb97f..4bb98ef 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -486,4 +486,6 @@ 总是跳过 TLS 证书验证 当网络发生变化时重置出站连接 当设备从睡眠状态唤醒时重置出站连接 + 预览版 + 本应用为预览版,可能存在诸多问题。若您不愿参与测试,请前往GitHub下载正式发布版本! \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1899df1..b72a057 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -566,4 +566,6 @@ Padding Reset outbound connections when network changes Reset outbound connections when device wake from sleep + Preview version + This application is a preview version and may contain many problems. If you do not want to test it, please go to GitHub to download the Release version! \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Helpers.kt b/buildSrc/src/main/kotlin/Helpers.kt index ceb9049..ff687e6 100644 --- a/buildSrc/src/main/kotlin/Helpers.kt +++ b/buildSrc/src/main/kotlin/Helpers.kt @@ -209,6 +209,7 @@ fun Project.setupApp() { create("oss") create("fdroid") create("play") + create("preview") } applicationVariants.all {