manager: refactor to use AGP 8.0.0 (#414)

This commit is contained in:
Nullptr 2023-04-21 16:19:49 +08:00 committed by GitHub
parent 76b1165572
commit f9d19a957a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 312 additions and 421 deletions

View File

@ -1,16 +1,17 @@
name: Build Manager name: Build Manager
on: on:
push: push:
branches: [ "main" ] branches: [ "main" ]
paths: paths:
- '.github/workflows/build-manager.yml' - '.github/workflows/build-manager.yml'
- 'manager/**' - 'manager/**'
- 'userspace/ksud/**' - 'userspace/ksud/**'
pull_request: pull_request:
branches: [ "main" ] branches: [ "main" ]
paths: paths:
- 'manager/**' - 'manager/**'
workflow_call:
jobs: jobs:
build-ksud: build-ksud:
strategy: strategy:
@ -21,87 +22,104 @@ jobs:
uses: ./.github/workflows/ksud.yml uses: ./.github/workflows/ksud.yml
with: with:
target: ${{ matrix.target }} target: ${{ matrix.target }}
build-manager: build-manager:
needs: build-ksud needs: build-ksud
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults: defaults:
run: run:
working-directory: ./manager working-directory: ./manager
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
with: uses: actions/checkout@v3
fetch-depth: 0 with:
- name: Setup need_upload fetch-depth: 0
id: need_upload
run: | - name: Setup need_upload
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then id: need_upload
echo "UPLOAD=true" >> $GITHUB_OUTPUT run: |
else if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
echo "UPLOAD=false" >> $GITHUB_OUTPUT echo "UPLOAD=true" >> $GITHUB_OUTPUT
fi else
- name: set up JDK 11 echo "UPLOAD=false" >> $GITHUB_OUTPUT
uses: actions/setup-java@v3 fi
with:
java-version: '11' - name: Write key
distribution: 'temurin' if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }}
cache: gradle run: |
- uses: nttld/setup-ndk@v1 if [ ! -z "${{ secrets.KEYSTORE }}" ]; then
with: echo KEYSTORE_PASSWORD='${{ secrets.KEYSTORE_PASSWORD }}' >> gradle.properties
ndk-version: r25b echo KEY_ALIAS='${{ secrets.KEY_ALIAS }}' >> gradle.properties
local-cache: true echo KEY_PASSWORD='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
- name: Extract keystore echo KEYSTORE_FILE='../key.jks' >> gradle.properties
if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }} echo ${{ secrets.KEYSTORE }} | base64 --decode > key.jks
run: | fi
if [ ! -z "${{ secrets.KEYSTORE }}" ]; then
echo KEYSTORE_PASSWORD='${{ secrets.KEYSTORE_PASSWORD }}' >> sign.properties - name: Setup Java
echo KEY_ALIAS='${{ secrets.KEY_ALIAS }}' >> sign.properties uses: actions/setup-java@v3
echo KEY_PASSWORD='${{ secrets.KEY_PASSWORD }}' >> sign.properties with:
echo KEYSTORE_FILE='../key.jks' >> sign.properties distribution: "temurin"
echo ${{ secrets.KEYSTORE }} | base64 --decode > key.jks java-version: "17"
fi
- name: Download arm64 ksud - name: Setup Gradle
uses: actions/download-artifact@v3 uses: gradle/gradle-build-action@v2
with: with:
name: ksud-aarch64-linux-android gradle-home-cache-cleanup: true
path: .
- name: Download x86_64 ksud - name: Download arm64 ksud
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: ksud-x86_64-linux-android name: ksud-aarch64-linux-android
path: . path: .
- name: Copy ksud to app jniLibs
run: | - name: Download x86_64 ksud
mkdir -p app/src/main/jniLibs/arm64-v8a uses: actions/download-artifact@v3
mkdir -p app/src/main/jniLibs/x86_64 with:
cp -f ../aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud.so name: ksud-x86_64-linux-android
cp -f ../x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud.so path: .
- name: Grant execute permission for gradlew
run: chmod +x gradlew - name: Copy ksud to app jniLibs
- name: Build with Gradle run: |
run: ./gradlew clean assembleRelease mkdir -p app/src/main/jniLibs/arm64-v8a
- name: Upload build artifact mkdir -p app/src/main/jniLibs/x86_64
uses: actions/upload-artifact@v3 cp -f ../aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud.so
with: cp -f ../x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud.so
name: manager
path: manager/app/build/outputs/apk/release/*.apk - name: Build with Gradle
- name: Setup mutex for uploading run: |
uses: ben-z/gh-action-mutex@v1.0-alpha-7 echo 'org.gradle.parallel=true' >> gradle.properties
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' echo 'org.gradle.vfs.watch=true' >> gradle.properties
- name: Upload to telegram echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' echo 'android.native.buildOutput=verbose' >> gradle.properties
env: sed -i 's/org.gradle.configuration-cache=true//g' gradle.properties
CHAT_ID: ${{ secrets.CHAT_ID }} ./gradlew clean assembleRelease
CACHE_CHAT_ID: ${{ secrets.CACHE_CHAT_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} - name: Upload build artifact
MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }} uses: actions/upload-artifact@v3
COMMIT_MESSAGE: ${{ github.event.head_commit.message }} with:
COMMIT_URL: ${{ github.event.head_commit.url }} name: manager
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} path: manager/app/build/outputs/apk/release/*.apk
TITLE: Manager
run: | - name: Setup mutex for uploading
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then uses: ben-z/gh-action-mutex@v1.0-alpha-7
export VERSION=$(git rev-list --count HEAD) if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
APK=$(find ./app/build/outputs/apk/release -name "*.apk")
pip3 install python-telegram-bot - name: Upload to telegram
python3 $GITHUB_WORKSPACE/scripts/ksubot.py $APK if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true'
fi env:
CHAT_ID: ${{ secrets.CHAT_ID }}
CACHE_CHAT_ID: ${{ secrets.CACHE_CHAT_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMMIT_URL: ${{ github.event.head_commit.url }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
TITLE: Manager
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
export VERSION=$(git rev-list --count HEAD)
APK=$(find ./app/build/outputs/apk/release -name "*.apk")
pip3 install python-telegram-bot
python3 $GITHUB_WORKSPACE/scripts/ksubot.py $APK
fi

3
.gitignore vendored
View File

@ -1 +1,2 @@
.vscode/ .idea
.vscode

18
manager/.gitignore vendored
View File

@ -1,17 +1,9 @@
*.iml *.iml
.gradle .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 local.properties
sign.properties .idea
.DS_Store
build
captures
.cxx
key.jks key.jks

3
manager/.idea/.gitignore generated vendored
View File

@ -1,3 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml

1
manager/.idea/.name generated
View File

@ -1 +0,0 @@
KernelSU

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Embedded JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

View File

@ -1,37 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
</profile>
</component>

10
manager/.idea/misc.xml generated
View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

6
manager/.idea/vcs.xml generated
View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -1,37 +1,51 @@
import com.android.build.gradle.internal.api.BaseVariantOutputImpl import com.android.build.gradle.internal.api.BaseVariantOutputImpl
plugins { plugins {
id("com.android.application") alias(libs.plugins.agp.app)
id("com.google.devtools.ksp") alias(libs.plugins.kotlin)
kotlin("android") alias(libs.plugins.ksp)
alias(libs.plugins.lsplugin.apksign)
}
val managerVersionCode: Int by rootProject.extra
val managerVersionName: String by rootProject.extra
apksign {
storeFileProperty = "KEYSTORE_FILE"
storePasswordProperty = "KEYSTORE_PASSWORD"
keyAliasProperty = "KEY_ALIAS"
keyPasswordProperty = "KEY_PASSWORD"
} }
android { android {
namespace = "me.weishu.kernelsu" namespace = "me.weishu.kernelsu"
ndkVersion = "25.1.8937393" buildTypes {
release {
defaultConfig { isMinifyEnabled = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
ndk {
abiFilters += listOf("arm64-v8a", "x86_64")
} }
} }
lint {
checkReleaseBuilds = false
}
buildFeatures { buildFeatures {
aidl = true
buildConfig = true
compose = true compose = true
} }
composeOptions { kotlinOptions {
kotlinCompilerExtensionVersion = "1.3.2" jvmTarget = "17"
} }
packagingOptions { composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}
packaging {
jniLibs {
useLegacyPackaging = true
}
resources { resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}" excludes += "/META-INF/{AL2.0,LGPL2.1}"
} }
@ -39,15 +53,14 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path(file("src/main/cpp/CMakeLists.txt")) path("src/main/cpp/CMakeLists.txt")
version = "3.18.1"
} }
} }
applicationVariants.all { applicationVariants.all {
outputs.forEach { outputs.forEach {
val output = it as BaseVariantOutputImpl val output = it as BaseVariantOutputImpl
output.outputFileName = "KernelSU_$versionName-${buildType.name}.apk" output.outputFileName = "KernelSU_${managerVersionName}_${managerVersionCode}-$name.apk"
} }
kotlin.sourceSets { kotlin.sourceSets {
@ -59,40 +72,40 @@ android {
} }
dependencies { dependencies {
val accompanistVersion = "0.28.0" implementation(libs.androidx.activity.compose)
val composeDestinationsVersion = "1.7.27-beta" implementation(libs.androidx.navigation.compose)
implementation(platform("androidx.compose:compose-bom:2023.04.00"))
debugImplementation("androidx.compose.ui:ui-test-manifest")
debugImplementation("androidx.compose.ui:ui-tooling")
implementation("androidx.activity:activity-compose:1.7.0")
implementation("androidx.compose.material:material:1.5.0-alpha01")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
implementation("androidx.navigation:navigation-compose:2.5.3")
implementation("com.google.accompanist:accompanist-drawablepainter:$accompanistVersion")
implementation("com.google.accompanist:accompanist-navigation-animation:$accompanistVersion")
implementation("com.google.accompanist:accompanist-systemuicontroller:$accompanistVersion")
implementation("io.github.raamcosta.compose-destinations:animations-core:$composeDestinationsVersion")
implementation("io.coil-kt:coil-compose:2.3.0") implementation(platform(libs.androidx.compose.bom))
implementation("me.zhanghai.android.appiconloader:appiconloader-coil:1.5.0") implementation(libs.androidx.compose.material.icons.extended)
implementation(libs.androidx.compose.material)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
val libsuVersion = "5.0.5" debugImplementation(libs.androidx.compose.ui.test.manifest)
// change to official build(com.github.topjohnwu.libsu) when this pr is merged: debugImplementation(libs.androidx.compose.ui.tooling)
// https://github.com/topjohnwu/libsu/pull/151
implementation("com.github.tiann.libsu:core:$libsuVersion")
implementation("com.github.tiann.libsu:service:$libsuVersion")
implementation("dev.rikka.rikkax.parcelablelist:parcelablelist:2.0.0")
implementation("com.github.alorma:compose-settings-ui-m3:0.22.0") implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.viewmodel.compose)
ksp("io.github.raamcosta.compose-destinations:ksp:$composeDestinationsVersion") implementation(libs.com.google.accompanist.drawablepainter)
implementation(libs.com.google.accompanist.navigation.animation)
implementation(libs.com.google.accompanist.systemuicontroller)
testImplementation("junit:junit:4.13.2") implementation(libs.compose.destinations.animations.core)
androidTestImplementation("androidx.test.ext:junit:1.1.4") ksp(libs.compose.destinations.ksp)
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
implementation(libs.com.github.alorma.compose.settings.ui.m3)
implementation(libs.com.github.topjohnwu.libsu.core)
implementation(libs.com.github.topjohnwu.libsu.service)
implementation(libs.dev.rikka.rikkax.parcelablelist)
implementation(libs.io.coil.kt.coil.compose)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.me.zhanghai.android.appiconloader.coil)
} }

View File

@ -1,21 +1,9 @@
# Add project specific ProGuard rules here. -dontwarn org.bouncycastle.jsse.BCSSLParameters
# You can control the set of applied configuration files using the -dontwarn org.bouncycastle.jsse.BCSSLSocket
# proguardFiles setting in build.gradle. -dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
# -dontwarn org.conscrypt.Conscrypt$Version
# For more details, see -dontwarn org.conscrypt.Conscrypt
# http://developer.android.com/guide/developing/tools/proguard.html -dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
# If your project uses WebView with JS, uncomment the following -dontwarn org.openjsse.javax.net.ssl.SSLSocket
# and specify the fully qualified class name to the JavaScript interface -dontwarn org.openjsse.net.ssl.OpenJSSE
# 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

View File

@ -1,24 +0,0 @@
package me.weishu.kernelsu
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("me.weishu.kernelsu", appContext.packageName)
}
}

View File

@ -6,14 +6,13 @@
android:name=".KernelSUApplication" android:name=".KernelSUApplication"
android:allowBackup="true" android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules" android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:enableOnBackInvokedCallback="true" android:enableOnBackInvokedCallback="true"
android:extractNativeLibs="true" android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.KernelSU" android:theme="@style/Theme.KernelSU"
tools:targetApi="31"> tools:targetApi="33">
<activity <activity
android:name=".ui.MainActivity" android:name=".ui.MainActivity"
android:exported="true" android:exported="true"

View File

@ -5,23 +5,30 @@ import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.* import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
import com.google.accompanist.navigation.animation.rememberAnimatedNavController import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.ramcosta.composedestinations.DestinationsNavHost import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.navigation.popBackStack
import com.ramcosta.composedestinations.utils.isRouteOnBackStackAsState
import me.weishu.kernelsu.ui.component.rememberDialogHostState import me.weishu.kernelsu.ui.component.rememberDialogHostState
import me.weishu.kernelsu.ui.screen.BottomBarDestination import me.weishu.kernelsu.ui.screen.BottomBarDestination
import me.weishu.kernelsu.ui.screen.NavGraphs import me.weishu.kernelsu.ui.screen.NavGraphs
import me.weishu.kernelsu.ui.screen.appCurrentDestinationAsState import me.weishu.kernelsu.ui.screen.appCurrentDestinationAsState
import me.weishu.kernelsu.ui.screen.destinations.Destination
import me.weishu.kernelsu.ui.screen.startAppDestination
import me.weishu.kernelsu.ui.theme.KernelSUTheme import me.weishu.kernelsu.ui.theme.KernelSUTheme
import me.weishu.kernelsu.ui.util.LocalDialogHost import me.weishu.kernelsu.ui.util.LocalDialogHost
import me.weishu.kernelsu.ui.util.LocalSnackbarHost import me.weishu.kernelsu.ui.util.LocalSnackbarHost
@ -58,31 +65,28 @@ class MainActivity : ComponentActivity() {
@Composable @Composable
private fun BottomBar(navController: NavHostController) { private fun BottomBar(navController: NavHostController) {
val topDestination: Destination = navController.appCurrentDestinationAsState().value val topDestination by navController.appCurrentDestinationAsState()
?: NavGraphs.root.startAppDestination
val bottomBarRoutes = remember {
BottomBarDestination.values().map { it.direction.route }
}
NavigationBar(tonalElevation = 8.dp) { NavigationBar(tonalElevation = 8.dp) {
BottomBarDestination.values().forEach { destination -> BottomBarDestination.values().forEach { destination ->
val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction)
NavigationBarItem( NavigationBarItem(
selected = topDestination.route == destination.direction.route, selected = isCurrentDestOnBackStack,
onClick = { onClick = {
val firstRoute = navController.backQueue.reversed().first { if (isCurrentDestOnBackStack) {
it.destination.route in bottomBarRoutes navController.popBackStack(destination.direction, false)
}.destination.route }
navController.navigate(destination.direction.route) { navController.navigate(destination.direction.route) {
popUpTo(navController.graph.findStartDestination().id) { popUpTo(NavGraphs.root.route) {
saveState = firstRoute != destination.direction.route saveState = true
} }
launchSingleTop = true launchSingleTop = true
restoreState = true restoreState = true
} }
}, },
icon = { icon = {
if (topDestination.route == destination.direction.route) { if (topDestination?.route == destination.direction.route) {
Icon(destination.iconSelected, stringResource(destination.label)) Icon(destination.iconSelected, stringResource(destination.label))
} else { } else {
Icon(destination.iconNotSelected, stringResource(destination.label)) Icon(destination.iconNotSelected, stringResource(destination.label))

View File

@ -1,17 +0,0 @@
package me.weishu.kernelsu
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View File

@ -1,33 +1,46 @@
import com.android.build.api.dsl.ApplicationExtension import com.android.build.api.dsl.ApplicationDefaultConfig
import com.android.build.gradle.BaseExtension import com.android.build.api.dsl.CommonExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import com.android.build.gradle.api.AndroidBasePlugin
import org.jetbrains.kotlin.konan.properties.Properties
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
plugins { plugins {
id("com.android.application") apply false alias(libs.plugins.agp.app) apply false
id("com.android.library") apply false alias(libs.plugins.agp.lib) apply false
kotlin("android") apply false alias(libs.plugins.kotlin) apply false
alias(libs.plugins.lsplugin.cmaker)
} }
buildscript { cmaker {
repositories { default {
google() arguments.addAll(
mavenCentral() arrayOf(
"-DANDROID_STL=c++_static",
)
)
val flags = arrayOf(
"-Wno-gnu-string-literal-operator-template",
"-Wno-c++2b-extensions",
)
cFlags.addAll(flags)
cppFlags.addAll(flags)
abiFilters("arm64-v8a", "x86_64")
} }
dependencies { buildTypes {
classpath(kotlin("gradle-plugin", version = "1.7.20")) if (it.name == "release") {
arguments += "-DDEBUG_SYMBOLS_PATH=${buildDir.absolutePath}/symbols"
}
} }
} }
val androidMinSdk = 26 val androidMinSdkVersion = 26
val androidTargetSdk = 33 val androidTargetSdkVersion = 33
val androidCompileSdk = 33 val androidCompileSdkVersion = 33
val androidBuildToolsVersion = "33.0.1" val androidBuildToolsVersion = "33.0.2"
val androidSourceCompatibility = JavaVersion.VERSION_11 val androidCompileNdkVersion = "25.2.9519653"
val androidTargetCompatibility = JavaVersion.VERSION_11 val androidSourceCompatibility = JavaVersion.VERSION_17
val managerVersionCode = getVersionCode() val androidTargetCompatibility = JavaVersion.VERSION_17
val managerVersionName = getVersionName() val managerVersionCode by extra(getVersionCode())
val managerVersionName by extra(getVersionName())
tasks.register<Delete>("clean") { tasks.register<Delete>("clean") {
delete(rootProject.buildDir) delete(rootProject.buildDir)
@ -61,71 +74,31 @@ fun getVersionName(): String {
return getGitDescribe() return getGitDescribe()
} }
fun Project.configureBaseExtension() { subprojects {
extensions.findByType<BaseExtension>()?.run { plugins.withType(AndroidBasePlugin::class.java) {
compileSdkVersion(androidCompileSdk) extensions.configure(CommonExtension::class.java) {
buildToolsVersion = androidBuildToolsVersion compileSdk = androidCompileSdkVersion
ndkVersion = androidCompileNdkVersion
buildToolsVersion = androidBuildToolsVersion
defaultConfig { defaultConfig {
minSdk = androidMinSdk minSdk = androidMinSdkVersion
targetSdk = androidTargetSdk if (this is ApplicationDefaultConfig) {
versionCode = managerVersionCode targetSdk = androidTargetSdkVersion
versionName = managerVersionName versionCode = managerVersionCode
versionName = managerVersionName
consumerProguardFiles("proguard-rules.pro")
}
val signFile = rootProject.file("sign.properties")
val config = if (signFile.canRead()) {
val prop = Properties()
prop.load(signFile.inputStream())
signingConfigs.create("config") {
storeFile = file(prop.getProperty("KEYSTORE_FILE"))
storePassword = prop.getProperty("KEYSTORE_PASSWORD")
keyAlias = prop.getProperty("KEY_ALIAS")
keyPassword = prop.getProperty("KEY_PASSWORD")
}
} else {
signingConfigs["debug"]
}
buildTypes {
all {
signingConfig = config
}
named("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
extensions.findByType<ApplicationExtension>()?.run {
buildTypes {
named("release") {
isShrinkResources = true
} }
} }
}
extensions.findByType<KotlinCompile>()?.run { lint {
kotlinOptions { abortOnError = true
jvmTarget = "11" checkReleaseBuilds = false
}
compileOptions {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
} }
} }
} }
} }
subprojects {
plugins.withId("com.android.application") {
configureBaseExtension()
}
plugins.withId("com.android.library") {
configureBaseExtension()
}
}

View File

@ -1,23 +1,3 @@
# Project-wide Gradle settings. android.experimental.enableNewResourceShrinker.preciseShrinking=true
# IDE (e.g. Android Studio) users: android.enableAppCompileTimeRClass=true
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

View File

@ -0,0 +1,55 @@
[versions]
agp = "8.0.0"
kotlin = "1.8.10"
ksp = "1.8.10-1.0.9"
compose-bom = "2023.04.01"
lifecycle = "2.6.1"
accompanist = "0.30.0"
navigation = "2.5.3"
compose-destination = "1.9.40-beta"
libsu = "5.0.5"
[plugins]
agp-app = { id = "com.android.application", version.ref = "agp" }
agp-lib = { id = "com.android.library", version.ref = "agp" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
lsplugin-apksign = { id = "org.lsposed.lsplugin.apksign", version = "1.1" }
lsplugin-cmaker = { id = "org.lsposed.lsplugin.cmaker", version = "1.1" }
[libraries]
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version = "1.7.1" }
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
androidx-compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
androidx-compose-material = { group = "androidx.compose.material", name = "material" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" }
androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" }
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version = "lifecycle" }
com-google-accompanist-drawablepainter = { group = "com.google.accompanist", name = "accompanist-drawablepainter", version.ref = "accompanist" }
com-google-accompanist-navigation-animation = { group = "com.google.accompanist", name = "accompanist-navigation-animation", version.ref = "accompanist" }
com-google-accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanist" }
com-github-alorma-compose-settings-ui-m3 = { module = "com.github.alorma:compose-settings-ui-m3", version = "0.22.0" }
com-github-topjohnwu-libsu-core = { group = "com.github.topjohnwu.libsu", name = "core", version.ref = "libsu" }
com-github-topjohnwu-libsu-service = { group = "com.github.topjohnwu.libsu", name = "service", version.ref = "libsu" }
dev-rikka-rikkax-parcelablelist = { module = "dev.rikka.rikkax.parcelablelist:parcelablelist", version = "2.0.1" }
io-coil-kt-coil-compose = { group = "io.coil-kt", name = "coil-compose", version = "2.3.0" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4" }
me-zhanghai-android-appiconloader-coil = { group = "me.zhanghai.android.appiconloader", name = "appiconloader-coil", version = "1.5.0" }
compose-destinations-animations-core = { group = "io.github.raamcosta.compose-destinations", name = "animations-core", version.ref = "compose-destination" }
compose-destinations-ksp = { group = "io.github.raamcosta.compose-destinations", name = "ksp", version.ref = "compose-destination" }

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -6,14 +6,6 @@ pluginManagement {
google() google()
mavenCentral() mavenCentral()
} }
plugins {
val agp = "7.4.2"
val kotlin = "1.7.20"
id("com.android.application") version agp
id("com.android.library") version agp
id("com.google.devtools.ksp") version "$kotlin-1.0.8"
kotlin("android") version kotlin
}
} }
dependencyResolutionManagement { dependencyResolutionManagement {