Skip to content

Commit

Permalink
Fixes on Build Gradle Kts files, Add GIT_SHORT_SHA build config
Browse files Browse the repository at this point in the history
  • Loading branch information
KreitinnSoftware committed Aug 31, 2024
1 parent 24641ea commit f853185
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 68 deletions.
20 changes: 18 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import java.io.ByteArrayOutputStream

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

Expand All @@ -22,8 +24,11 @@ android {
buildTypes {
debug {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
file("proguard-rules.pro"))
ndk {
//noinspection ChromeOsAbiSupport
abiFilters += "arm64-v8a"
}
}
Expand All @@ -43,6 +48,7 @@ android {
buildTypes {
getByName("debug") {
isMinifyEnabled = false
buildConfigField("String", "GIT_SHORT_SHA", "\"${getGitShortSHA()}\"")
}
}

Expand All @@ -54,6 +60,7 @@ android {

buildFeatures {
aidl = true
buildConfig = true
viewBinding = true
}

Expand Down Expand Up @@ -86,3 +93,12 @@ dependencies {
implementation("com.google.code.gson:gson:2.10.1")
implementation(project(":app:stub"))
}

fun getGitShortSHA(): String {
val stdout = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
return stdout.toString().trim()
}
55 changes: 0 additions & 55 deletions app/src/main/java/com/micewine/emu/views/HWInfoView.kt

This file was deleted.

62 changes: 62 additions & 0 deletions app/src/main/java/com/micewine/emu/views/OnScreenInfoView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.micewine.emu.views

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View
import com.micewine.emu.activities.MainActivity.Companion.d3dxRenderer
import com.micewine.emu.activities.MainActivity.Companion.enableCpuCounter
import com.micewine.emu.activities.MainActivity.Companion.enableDebugInfo
import com.micewine.emu.activities.MainActivity.Companion.enableRamCounter
import com.micewine.emu.activities.MainActivity.Companion.memoryStats
import com.micewine.emu.activities.MainActivity.Companion.miceWineVersion
import com.micewine.emu.activities.MainActivity.Companion.selectedDXVK
import com.micewine.emu.activities.MainActivity.Companion.selectedWineD3D
import com.micewine.emu.activities.MainActivity.Companion.totalCpuUsage

class HWInfoView @JvmOverloads constructor (context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0): View(context, attrs, defStyleAttr) {
private val paint: Paint = Paint().apply {
textSize = 30F
strokeWidth = 8F
}

override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)

if (enableRamCounter) {
drawText("RAM: $memoryStats", 20F, 40F, canvas)
}

if (enableCpuCounter) {
drawText("CPU: $totalCpuUsage", 20F, 80F, canvas)
}

if (enableDebugInfo) {
onScreenInfo(canvas)
}

invalidate()
}

private fun onScreenInfo(c: Canvas) {
drawText(miceWineVersion, c.width - paint.measureText(miceWineVersion) - 20F, 40F, c)

if (d3dxRenderer == "DXVK") {
drawText(selectedDXVK!!, c.width - paint.measureText(selectedDXVK) - 20F, 80F, c)
} else if (d3dxRenderer == "WineD3D") {
drawText(selectedWineD3D!!, c.width - paint.measureText(selectedWineD3D) - 20F, 80F, c)
}
}

private fun drawText(text: String, x: Float, y: Float, c: Canvas) {
paint.style = Paint.Style.STROKE
paint.color = Color.BLACK
c.drawText(text, x, y, paint)

paint.style = Paint.Style.FILL
paint.color = Color.WHITE
c.drawText(text, x, y, paint)
}
}
4 changes: 0 additions & 4 deletions app/stub/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ android {
minSdk = 28
}

buildFeatures {
buildConfig = false
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ plugins {
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
kotlin("jvm") version "1.9.20" apply false
kotlin("plugin.serialization") version "1.9.20" apply false
}

allprojects {
repositories {
mavenCentral()
google()
}
}
7 changes: 0 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ pluginManagement {
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

include(":app")
include(":app:stub")

0 comments on commit f853185

Please sign in to comment.