Skip to content

Commit

Permalink
Build warnings cleanup (#6827)
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeTroglodyte authored May 19, 2022
1 parent f464ac2 commit 3d6a01d
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 124 deletions.
7 changes: 5 additions & 2 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />

<!--
Known Lint warnings:
UnusedAttribute: Since we're targeting a range of API levels, it's OK that e.g. appCategory will be ignored by OLD devices
IconDensities: See https://developer.android.com/training/tv/start/start#banner for the banner attribute, where they recommend supplying only one density.
-->
<application
android:allowBackup="true"
android:icon="@mipmap/uncivicon"
Expand All @@ -24,7 +29,6 @@
android:name="com.unciv.app.AndroidLauncher"
android:launchMode="singleTask"
android:exported="true"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
tools:ignore="LockedOrientationActivity">
<intent-filter>
Expand All @@ -45,7 +49,6 @@

<activity
android:name="com.unciv.app.AndroidTvLauncher"
android:label="@string/app_name"
android:exported="true"
android:theme="@style/GdxTheme">

Expand Down
9 changes: 5 additions & 4 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
versionCode = BuildConfig.appCodeNumber
versionName = BuildConfig.appVersion

base.archivesBaseName = "Unciv"
base.archivesName.set("Unciv")
}

// necessary for Android Work lib
Expand All @@ -53,14 +53,14 @@ android {

buildTypes {
getByName("release") {
// If you make this true you get a version of the game that just flat-out does't run
// If you make this true you get a version of the game that just flat-out doesn't run
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}

}
lint {
disable.add("MissingTranslation")
disable += "MissingTranslation" // see res/values/strings.xml
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -123,8 +123,9 @@ tasks.register<JavaExec>("run") {
}

dependencies {
// Updating to latest version would require upgrading sourceCompatability and targetCompatability to 1_8 -
// Updating to latest version would require upgrading sourceCompatibility and targetCompatibility to 1_8, and targetSdk to 31 -
// run `./gradlew build --scan` to see details
// Known Android Lint warning: "GradleDependency"
implementation("androidx.core:core-ktx:1.6.0")
implementation("androidx.work:work-runtime-ktx:2.6.0")
}
3 changes: 3 additions & 0 deletions android/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Known Lint warning: MissingTranslation. Yes, _fr_ is incomplete. Suppressed in android/build.gradle.kts
-->
<string name="app_name">UnCiv</string>
<string name="Notify_YourTurn_Short">Unciv - It\'s your turn!</string>
<string name="Notify_YourTurn_Long">Your friends are waiting for your turn in [gameName].</string>
Expand Down
16 changes: 12 additions & 4 deletions android/src/com/unciv/app/MultiplayerTurnCheckWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.unciv.app
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.PendingIntent.FLAG_IMMUTABLE
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
Expand Down Expand Up @@ -121,9 +123,11 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
* It is not technically necessary for the Worker, since it is not a Service.
*/
fun showPersistentNotification(appContext: Context, lastTimeChecked: String, checkPeriod: String) {
val flags = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) FLAG_IMMUTABLE else 0) or
FLAG_UPDATE_CURRENT
val pendingIntent: PendingIntent =
Intent(appContext, AndroidLauncher::class.java).let { notificationIntent ->
PendingIntent.getActivity(appContext, 0, notificationIntent, 0)
PendingIntent.getActivity(appContext, 0, notificationIntent, flags)
}

val notification: NotificationCompat.Builder = NotificationCompat.Builder(appContext, NOTIFICATION_CHANNEL_ID_SERVICE)
Expand Down Expand Up @@ -152,7 +156,9 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
action = Intent.ACTION_VIEW
data = Uri.parse("https://unciv.app/multiplayer?id=${game.second}")
}
val pendingIntent = PendingIntent.getActivity(applicationContext, 0, intent, 0)
val flags = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) FLAG_IMMUTABLE else 0) or
FLAG_UPDATE_CURRENT
val pendingIntent = PendingIntent.getActivity(applicationContext, 0, intent, flags)

val contentTitle = applicationContext.resources.getString(R.string.Notify_YourTurn_Short)
val notification: NotificationCompat.Builder = NotificationCompat.Builder(applicationContext, NOTIFICATION_CHANNEL_ID_INFO)
Expand Down Expand Up @@ -367,14 +373,16 @@ class MultiplayerTurnCheckWorker(appContext: Context, workerParams: WorkerParame
}

private fun showErrorNotification(stackTraceString: String) {
val flags = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) FLAG_IMMUTABLE else 0) or
FLAG_UPDATE_CURRENT
val pendingLaunchGameIntent: PendingIntent =
Intent(applicationContext, AndroidLauncher::class.java).let { notificationIntent ->
PendingIntent.getActivity(applicationContext, 0, notificationIntent, 0)
PendingIntent.getActivity(applicationContext, 0, notificationIntent, flags)
}

val pendingCopyClipboardIntent: PendingIntent =
Intent(applicationContext, CopyToClipboardReceiver::class.java).putExtra(CLIPBOARD_EXTRA, stackTraceString)
.let { notificationIntent -> PendingIntent.getBroadcast(applicationContext,0, notificationIntent, 0)
.let { notificationIntent -> PendingIntent.getBroadcast(applicationContext,0, notificationIntent, flags)
}

val notification: NotificationCompat.Builder = NotificationCompat.Builder(applicationContext, NOTIFICATION_CHANNEL_ID_INFO)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${com.unciv.build.BuildConfig.kotlinVersion}")
classpath("de.richsource.gradle.plugins:gwt-gradle-plugin:0.6")
classpath("com.android.tools.build:gradle:7.1.0")
classpath("com.android.tools.build:gradle:7.1.3")
classpath("com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1")

// This is for wrapping the .jar file into a standalone executable
Expand Down
1 change: 0 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.unciv.build.BuildConfig

plugins {
id("kotlin")
Expand Down
3 changes: 2 additions & 1 deletion core/src/com/unciv/json/NonStringKeyMapSerializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ class NonStringKeyMapSerializer<MT: MutableMap<KT, Any>, KT>(
if (entries == null) {
readOldFormat(jsonData, json, result)
} else {
readNewFormat(entries!!, json, result)
readNewFormat(entries, json, result)
}
return result
}

@Deprecated("This is only here temporarily until all users migrate the old properties to the new ones")
private fun readOldFormat(jsonData: JsonValue, json: Json, result: MT) {
@Suppress("UNCHECKED_CAST") // We know better
val map = result as MutableMap<String, Any>
var child: JsonValue? = jsonData.child
while (child != null) {
Expand Down
3 changes: 2 additions & 1 deletion core/src/com/unciv/models/simulation/Simulation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.runBlocking
import kotlin.time.Duration
import kotlin.math.max
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.ExperimentalTime

@ExperimentalTime
Expand Down Expand Up @@ -109,7 +110,7 @@ class Simulation(
}
}
totalTurns = steps.sumOf { it.turns }
totalDuration = Duration.milliseconds(endTime - startTime)
totalDuration = (endTime - startTime).milliseconds
avgSpeed = totalTurns.toFloat() / totalDuration.inWholeSeconds
avgDuration = totalDuration / steps.size
}
Expand Down
4 changes: 2 additions & 2 deletions desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tasks.register<JavaExec>("run") {

dependsOn(tasks.getByName("classes"))

main = mainClassName
mainClass.set(mainClassName)
classpath = sourceSets.main.get().runtimeClasspath
standardInput = System.`in`
workingDir = assetsDir
Expand All @@ -42,7 +42,7 @@ tasks.register<JavaExec>("run") {
tasks.register<JavaExec>("debug") {
jvmArgs = jvmArgsForMac
dependsOn(tasks.getByName("classes"))
main = mainClassName
mainClass.set(mainClassName)
classpath = sourceSets.main.get().runtimeClasspath
standardInput = System.`in`
workingDir = assetsDir
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/com/unciv/app/desktop/DesktopLauncher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal object DesktopLauncher {
This is because if there's a crash when the instance initializes on a similar line,
it's not within the bounds of the try/catch and thus the app will crash.
*/
Native.loadLibrary("discord-rpc", DiscordRPC::class.java)
Native.load("discord-rpc", DiscordRPC::class.java)
val handlers = DiscordEventHandlers()
DiscordRPC.INSTANCE.Discord_Initialize("647066573147996161", handlers, true, null)

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit 3d6a01d

Please sign in to comment.