Skip to content

Commit

Permalink
sync with master
Browse files Browse the repository at this point in the history
  • Loading branch information
ichenhe committed Nov 13, 2023
2 parents d297d60 + c9bae32 commit 7117e37
Show file tree
Hide file tree
Showing 67 changed files with 4,609 additions and 2,188 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.bat text eol=crlf
18 changes: 11 additions & 7 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: set up JDK 11
uses: actions/setup-java@v2.3.0
- uses: actions/checkout@v3
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Build with Gradle
java-version: '17'
distribution: 'temurin'
cache: 'gradle'

- name: Assemble
run: ./gradlew assemble

- name: Build And Test
run: ./gradlew build
93 changes: 0 additions & 93 deletions app/build.gradle

This file was deleted.

119 changes: 119 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import org.jetbrains.kotlin.config.JvmTarget
import java.io.ByteArrayOutputStream

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}

// The last code is 20001, make sure the result is greater than it.
val vCode = 20000 + getVersionCode()
val vName = getVersionName()
logger.lifecycle("App Version: $vName ($vCode)")

android {
namespace = "cc.chenhe.qqnotifyevo"
compileSdk = 34
defaultConfig {
applicationId = "cc.chenhe.qqnotifyevo"
minSdk = 26
targetSdk = 33
versionCode = vCode
versionName = vName
}
buildFeatures {
viewBinding = true
compose = true
}
composeOptions {
// must correspond to kotlin version: https://developer.android.com/jetpack/androidx/releases/compose-kotlin#pre-release_kotlin_compatibility
kotlinCompilerExtensionVersion = "1.5.3"
}
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JvmTarget.JVM_1_8.description
}
}

dependencies {
val lifecycleVersion = "2.6.2"

// compose
val composeBom = platform("androidx.compose:compose-bom:2023.10.01")
implementation(composeBom)
androidTestImplementation(composeBom)
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")
implementation("androidx.activity:activity-compose:1.8.0")

implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-runtime-compose:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-service:$lifecycleVersion")

implementation("androidx.navigation:navigation-compose:2.7.5")
implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.concurrent:concurrent-futures-ktx:1.1.0") // support ListenableFuture
implementation("com.oasisfeng.nevo:sdk:2.0.0-rc01")
implementation("com.jakewharton.timber:timber:5.0.1")

testImplementation("junit:junit:4.13.2")
testImplementation("io.kotest:kotest-assertions-core:5.7.2")
testImplementation("org.json:json:20231013") // JSONObject
}

fun String.runCommand(currentWorkingDir: File = file("./")): String {
val byteOut = ByteArrayOutputStream()
project.exec {
workingDir = currentWorkingDir
commandLine = this@runCommand.split(" ")
standardOutput = byteOut
}
return String(byteOut.toByteArray()).trim()
}

fun getVersionCode(): Int {
val cmd = "git rev-list HEAD --first-parent --count"
return try {
cmd.runCommand().toInt()
} catch (e: Exception) {
logger.error("Failed to get version code with git, return 1 by default.\n${e.message}")
1
}
}


fun getVersionName(): String {
val cmd = "git describe --tags --long --first-parent --abbrev=7 --dirty=_dev"
try {
val v = cmd.runCommand()
val pattern = """^v(?<v>[\d|.]+)-\d+-g[A-Za-z0-9]{7}(?<s>_dev)?$""".toRegex()
val g = pattern.matchEntire(v)?.groups
if (g == null || g["v"] == null) {
logger.error(
"Failed to get version name with git.\n" +
"Cannot match git tag describe, return <UNKNOWN> by default. raw=$v"
)
return "UNKNOWN"
}
return g["v"]!!.value + (g["s"]?.value ?: "")
} catch (e: Exception) {
logger.error("Failed to get version name with git, return <UNKNOWN> by default.\n${e.message}")
return "UNKNOWN"
}
}
11 changes: 5 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="cc.chenhe.qqnotifyevo">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<queries>
<package android:name="com.tencent.mobileqq" />
Expand Down Expand Up @@ -57,8 +56,7 @@
android:directBootAware="true"
android:exported="true"
android:label="@string/nevo_name"
android:permission="com.oasisfeng.nevo.permission.BIND_DECORATOR_SERVICE"
tools:targetApi="N">
android:permission="com.oasisfeng.nevo.permission.BIND_DECORATOR_SERVICE">
<intent-filter android:priority="5">
<action android:name="com.oasisfeng.nevo.Decorator" />
</intent-filter>
Expand All @@ -76,12 +74,13 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="dnotShowNevoMultiMsgTips" />
</intent-filter>
</receiver>

<activity
android:name=".preference.PreferenceAty"
android:name=".ui.MainActivity"
android:excludeFromRecents="false"
android:exported="true"
android:label="@string/activity_splash"
Expand Down
Loading

0 comments on commit 7117e37

Please sign in to comment.