Skip to content

Commit 7117e37

Browse files
committed
sync with master
2 parents d297d60 + c9bae32 commit 7117e37

File tree

67 files changed

+4609
-2188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4609
-2188
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.bat text eol=crlf

.github/workflows/android.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ on:
1212

1313
jobs:
1414
build:
15-
1615
runs-on: ubuntu-latest
1716

1817
steps:
19-
- uses: actions/checkout@v2
20-
- name: set up JDK 11
21-
uses: actions/setup-java@v2.3.0
18+
- uses: actions/checkout@v3
19+
- name: set up JDK 17
20+
uses: actions/setup-java@v3
2221
with:
23-
java-version: '11'
24-
distribution: 'adopt'
25-
- name: Build with Gradle
22+
java-version: '17'
23+
distribution: 'temurin'
24+
cache: 'gradle'
25+
26+
- name: Assemble
27+
run: ./gradlew assemble
28+
29+
- name: Build And Test
2630
run: ./gradlew build

app/build.gradle

Lines changed: 0 additions & 93 deletions
This file was deleted.

app/build.gradle.kts

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import org.jetbrains.kotlin.config.JvmTarget
2+
import java.io.ByteArrayOutputStream
3+
4+
plugins {
5+
id("com.android.application")
6+
id("org.jetbrains.kotlin.android")
7+
}
8+
9+
// The last code is 20001, make sure the result is greater than it.
10+
val vCode = 20000 + getVersionCode()
11+
val vName = getVersionName()
12+
logger.lifecycle("App Version: $vName ($vCode)")
13+
14+
android {
15+
namespace = "cc.chenhe.qqnotifyevo"
16+
compileSdk = 34
17+
defaultConfig {
18+
applicationId = "cc.chenhe.qqnotifyevo"
19+
minSdk = 26
20+
targetSdk = 33
21+
versionCode = vCode
22+
versionName = vName
23+
}
24+
buildFeatures {
25+
viewBinding = true
26+
compose = true
27+
}
28+
composeOptions {
29+
// must correspond to kotlin version: https://developer.android.com/jetpack/androidx/releases/compose-kotlin#pre-release_kotlin_compatibility
30+
kotlinCompilerExtensionVersion = "1.5.3"
31+
}
32+
buildTypes {
33+
release {
34+
isMinifyEnabled = true
35+
isShrinkResources = true
36+
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
37+
}
38+
}
39+
compileOptions {
40+
sourceCompatibility = JavaVersion.VERSION_1_8
41+
targetCompatibility = JavaVersion.VERSION_1_8
42+
}
43+
kotlinOptions {
44+
jvmTarget = JvmTarget.JVM_1_8.description
45+
}
46+
}
47+
48+
dependencies {
49+
val lifecycleVersion = "2.6.2"
50+
51+
// compose
52+
val composeBom = platform("androidx.compose:compose-bom:2023.10.01")
53+
implementation(composeBom)
54+
androidTestImplementation(composeBom)
55+
implementation("androidx.compose.material3:material3")
56+
implementation("androidx.compose.material:material-icons-extended")
57+
implementation("androidx.compose.ui:ui-tooling-preview")
58+
debugImplementation("androidx.compose.ui:ui-tooling")
59+
implementation("androidx.activity:activity-compose:1.8.0")
60+
61+
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
62+
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycleVersion")
63+
implementation("androidx.lifecycle:lifecycle-runtime-compose:$lifecycleVersion")
64+
implementation("androidx.lifecycle:lifecycle-service:$lifecycleVersion")
65+
66+
implementation("androidx.navigation:navigation-compose:2.7.5")
67+
implementation("androidx.datastore:datastore-preferences:1.0.0")
68+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
69+
implementation("androidx.preference:preference-ktx:1.2.1")
70+
implementation("androidx.core:core-ktx:1.12.0")
71+
implementation("androidx.concurrent:concurrent-futures-ktx:1.1.0") // support ListenableFuture
72+
implementation("com.oasisfeng.nevo:sdk:2.0.0-rc01")
73+
implementation("com.jakewharton.timber:timber:5.0.1")
74+
75+
testImplementation("junit:junit:4.13.2")
76+
testImplementation("io.kotest:kotest-assertions-core:5.7.2")
77+
testImplementation("org.json:json:20231013") // JSONObject
78+
}
79+
80+
fun String.runCommand(currentWorkingDir: File = file("./")): String {
81+
val byteOut = ByteArrayOutputStream()
82+
project.exec {
83+
workingDir = currentWorkingDir
84+
commandLine = this@runCommand.split(" ")
85+
standardOutput = byteOut
86+
}
87+
return String(byteOut.toByteArray()).trim()
88+
}
89+
90+
fun getVersionCode(): Int {
91+
val cmd = "git rev-list HEAD --first-parent --count"
92+
return try {
93+
cmd.runCommand().toInt()
94+
} catch (e: Exception) {
95+
logger.error("Failed to get version code with git, return 1 by default.\n${e.message}")
96+
1
97+
}
98+
}
99+
100+
101+
fun getVersionName(): String {
102+
val cmd = "git describe --tags --long --first-parent --abbrev=7 --dirty=_dev"
103+
try {
104+
val v = cmd.runCommand()
105+
val pattern = """^v(?<v>[\d|.]+)-\d+-g[A-Za-z0-9]{7}(?<s>_dev)?$""".toRegex()
106+
val g = pattern.matchEntire(v)?.groups
107+
if (g == null || g["v"] == null) {
108+
logger.error(
109+
"Failed to get version name with git.\n" +
110+
"Cannot match git tag describe, return <UNKNOWN> by default. raw=$v"
111+
)
112+
return "UNKNOWN"
113+
}
114+
return g["v"]!!.value + (g["s"]?.value ?: "")
115+
} catch (e: Exception) {
116+
logger.error("Failed to get version name with git, return <UNKNOWN> by default.\n${e.message}")
117+
return "UNKNOWN"
118+
}
119+
}

app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="cc.chenhe.qqnotifyevo">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
53

64
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
75
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
86
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
7+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
98

109
<queries>
1110
<package android:name="com.tencent.mobileqq" />
@@ -57,8 +56,7 @@
5756
android:directBootAware="true"
5857
android:exported="true"
5958
android:label="@string/nevo_name"
60-
android:permission="com.oasisfeng.nevo.permission.BIND_DECORATOR_SERVICE"
61-
tools:targetApi="N">
59+
android:permission="com.oasisfeng.nevo.permission.BIND_DECORATOR_SERVICE">
6260
<intent-filter android:priority="5">
6361
<action android:name="com.oasisfeng.nevo.Decorator" />
6462
</intent-filter>
@@ -76,12 +74,13 @@
7674
android:exported="true">
7775
<intent-filter>
7876
<action android:name="android.intent.action.BOOT_COMPLETED" />
77+
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
7978
<action android:name="dnotShowNevoMultiMsgTips" />
8079
</intent-filter>
8180
</receiver>
8281

8382
<activity
84-
android:name=".preference.PreferenceAty"
83+
android:name=".ui.MainActivity"
8584
android:excludeFromRecents="false"
8685
android:exported="true"
8786
android:label="@string/activity_splash"

0 commit comments

Comments
 (0)