Skip to content

Commit

Permalink
Merge pull request #241 from Henry-ZHR/master
Browse files Browse the repository at this point in the history
更新gradle wrapper & 添加CI及优化相关代码
  • Loading branch information
rRemix authored Apr 1, 2024
2 parents b791df5 + 12d1bb8 commit a11aa40
Show file tree
Hide file tree
Showing 12 changed files with 357 additions and 191 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Android CI

on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Build with Gradle
run: ./gradlew app:assembleDebug app:assembleCiRelease
- name: Upload outputs
uses: actions/upload-artifact@v4
with:
name: snapshot
path: app/build/outputs/
23 changes: 17 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ fun readProperties(file: File): Properties {
return properties
}

val properties =
readProperties(File(project.rootProject.projectDir, "local.properties"))
val properties = readProperties(rootProject.file("local.properties"))

kotlin {
jvmToolchain(17)
Expand Down Expand Up @@ -68,8 +67,8 @@ android {
)
buildConfigField(
"String",
"GITHUB_SECRET_KEY",
"\"${properties.getProperty("GITHUB_SECRET_KEY")}\""
"GITHUB_SHA",
"\"${System.getenv("GITHUB_SHA")}\""
)

ndk {
Expand All @@ -86,14 +85,18 @@ android {

signingConfigs {
create("debugConfig") {
storeFile = File(projectDir, "Debug.jks")
storeFile = project.file("Debug.jks")
storePassword = "123456"
keyAlias = "Debug"
keyPassword = "123456"

enableV1Signing = true
enableV2Signing = true
enableV3Signing = true
}

create("releaseConfig") {
storeFile = File(properties.getProperty("keystore.storeFile") ?: "null")
storeFile = File(properties.getProperty("keystore.storeFile") ?: "")
storePassword = properties.getProperty("keystore.storePassword")
keyAlias = properties.getProperty("keystore.keyAlias")
keyPassword = properties.getProperty("keystore.keyPassword")
Expand Down Expand Up @@ -126,6 +129,14 @@ android {
)
)
}

// For CI builds only
create("ciRelease") {
initWith(getByName("release"))
signingConfig = signingConfigs["debugConfig"]
applicationIdSuffix = ".ci"
versionNameSuffix = "-CI"
}
}

sourceSets {
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/java/remix/myplayer/bean/misc/Feedback.kt

This file was deleted.

16 changes: 16 additions & 0 deletions app/src/main/java/remix/myplayer/misc/AppInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package remix.myplayer.misc

import remix.myplayer.BuildConfig

object AppInfo {
val prettyPrinted by lazy {
"""
APPLICATION_ID: ${BuildConfig.APPLICATION_ID}
VERSION_CODE: ${BuildConfig.VERSION_CODE}
VERSION_NAME: ${BuildConfig.VERSION_NAME}
FLAVOR: ${BuildConfig.FLAVOR}
BUILD_TYPE: ${BuildConfig.BUILD_TYPE}
GITHUB_SHA: ${BuildConfig.GITHUB_SHA}
""".trimIndent()
}
}
25 changes: 25 additions & 0 deletions app/src/main/java/remix/myplayer/misc/SystemInfo.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package remix.myplayer.misc

import android.os.Build

object SystemInfo {
private val supportedAbis: Array<String> by lazy {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Build.SUPPORTED_ABIS
} else {
@Suppress("deprecation")
arrayOf(Build.CPU_ABI, Build.CPU_ABI2)
}
}

val prettyPrinted: String by lazy {
"""
DISPLAY: ${Build.DISPLAY}
SUPPORTED_ABIS: ${supportedAbis.contentToString()}
MANUFACTURER: ${Build.MANUFACTURER}
MODEL: ${Build.MODEL}
RELEASE: ${Build.VERSION.RELEASE}
SDK_INT: ${Build.VERSION.SDK_INT}
""".trimIndent()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import retrofit2.http.*
*/
interface ApiService {
@GET("repos/{owner}/{repo}/releases/latest")
@Headers("token: " + BuildConfig.GITHUB_SECRET_KEY)
fun fetchLatestRelease(@Path("owner") owner: String?, @Path("repo") repo: String?): Single<Release>

//New Api
Expand Down
25 changes: 21 additions & 4 deletions app/src/main/java/remix/myplayer/ui/activity/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import android.os.Bundle
import remix.myplayer.BuildConfig
import remix.myplayer.R
import remix.myplayer.databinding.ActivityAboutBinding
import remix.myplayer.misc.AppInfo
import remix.myplayer.theme.Theme
import remix.myplayer.theme.ThemeStore
import remix.myplayer.theme.TintHelper

class AboutActivity : ToolbarActivity() {
private lateinit var binding: ActivityAboutBinding
Expand All @@ -14,10 +18,23 @@ class AboutActivity : ToolbarActivity() {
super.onCreate(savedInstanceState)
binding = ActivityAboutBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.aboutText.text =
"v${BuildConfig.VERSION_NAME}" +
" (${BuildConfig.VERSION_CODE})" +
" (${BuildConfig.FLAVOR})"

binding.aboutText.text = "v${BuildConfig.VERSION_NAME}"
binding.aboutText.setOnLongClickListener {
Theme.getBaseDialog(this)
.content(AppInfo.prettyPrinted)
.positiveText(R.string.close)
.build()
.run {
with(contentView ?: return@setOnLongClickListener false) {
TintHelper.setTint(this, ThemeStore.accentColor, false)
setTextIsSelectable(true)
}
show()
}
true
}

setUpToolbar(getString(R.string.about))
}
}
23 changes: 6 additions & 17 deletions app/src/main/java/remix/myplayer/ui/activity/SettingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import kotlinx.coroutines.withContext
import remix.myplayer.App.Companion.IS_GOOGLEPLAY
import remix.myplayer.BuildConfig
import remix.myplayer.R
import remix.myplayer.bean.misc.Feedback
import remix.myplayer.bean.misc.Library
import remix.myplayer.bean.misc.Library.Companion.getAllLibraryString
import remix.myplayer.bean.mp3.Song
Expand All @@ -50,7 +49,9 @@ import remix.myplayer.helper.M3UHelper.exportPlayListToFile
import remix.myplayer.helper.M3UHelper.importLocalPlayList
import remix.myplayer.helper.M3UHelper.importM3UFile
import remix.myplayer.helper.ShakeDetector
import remix.myplayer.misc.AppInfo
import remix.myplayer.misc.MediaScanner
import remix.myplayer.misc.SystemInfo
import remix.myplayer.misc.cache.DiskCache
import remix.myplayer.misc.floatpermission.FloatWindowManager
import remix.myplayer.misc.handler.MsgHandler
Expand Down Expand Up @@ -723,24 +724,12 @@ class SettingActivity : ToolbarActivity(), ColorChooserDialog.ColorCallback,

private fun gotoEmail() {
fun send(sendLog: Boolean) {
val feedBack = Feedback(
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE.toString(),
Build.DISPLAY,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Build.SUPPORTED_ABIS.joinToString(", ", "[", "]")
} else {
@Suppress("DEPRECATION")
"[" + Build.CPU_ABI + ", " + Build.CPU_ABI2 + "]"
},
Build.MANUFACTURER,
Build.MODEL,
Build.VERSION.RELEASE,
Build.VERSION.SDK_INT.toString()
)
val emailIntent = Intent()
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback))
emailIntent.putExtra(Intent.EXTRA_TEXT, "\n\n\n" + feedBack)
emailIntent.putExtra(
Intent.EXTRA_TEXT,
"\n\n\nApp info:\n${AppInfo.prettyPrinted}\n\nSystem info:\n${SystemInfo.prettyPrinted}"
)

tryLaunch(catch = {
Timber.w(it)
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Sun Mar 17 20:26:37 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit a11aa40

Please sign in to comment.