1
0

Android: minor update

This commit is contained in:
Maksym H 2023-06-12 21:14:29 +03:00
parent 9b1209a68a
commit d2408a9324
7 changed files with 33 additions and 29 deletions

View File

@ -47,6 +47,7 @@ android {
abi { abi {
enable true enable true
reset() reset()
//noinspection ChromeOsAbiSupport
include 'armeabi-v7a', 'arm64-v8a', 'x86_64' include 'armeabi-v7a', 'arm64-v8a', 'x86_64'
} }
} }
@ -66,7 +67,7 @@ android {
import org.apache.tools.ant.taskdefs.condition.Os import org.apache.tools.ant.taskdefs.condition.Os
task prepareAssetsFiles() { tasks.register('prepareAssetsFiles') {
def assetsFolder = "build/assets/Files" def assetsFolder = "build/assets/Files"
def projRoot = "../.." def projRoot = "../.."
@ -94,20 +95,22 @@ task prepareAssetsFiles() {
copy { copy {
from "${projRoot}/textures" into "${assetsFolder}/textures" exclude '*.txt' from "${projRoot}/textures" into "${assetsFolder}/textures" exclude '*.txt'
} }
task zipAssetsFiles(type: Zip) {
archiveFileName = "Files.zip"
destinationDirectory = file("src/main/assets/data")
from "${assetsFolder}"
}
} }
preBuild.dependsOn zipAssetsFiles tasks.register('zipAssetsFiles', Zip) {
dependsOn prepareAssetsFiles
archiveFileName = 'assets.zip'
destinationDirectory = file('src/main/assets/data')
from('build/assets/Files')
}
tasks.named("preBuild") {
dependsOn(zipAssetsFiles)
}
// Map for the version code that gives each ABI a value. // Map for the version code that gives each ABI a value.
def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1, 'x86_64': 2] def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1, 'x86_64': 2]
android.applicationVariants.all { variant -> android.applicationVariants.configureEach { variant ->
variant.outputs.each { variant.outputs.each {
output -> output ->
def abiName = output.filters[0].identifier def abiName = output.filters[0].identifier
@ -124,5 +127,5 @@ dependencies {
implementation 'androidx.appcompat:appcompat-resources:1.6.1' implementation 'androidx.appcompat:appcompat-resources:1.6.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.work:work-runtime-ktx:2.8.1' implementation 'androidx.work:work-runtime-ktx:2.8.1'
implementation 'com.google.android.material:material:1.8.0' implementation 'com.google.android.material:material:1.9.0'
} }

View File

@ -30,6 +30,7 @@ import android.provider.Settings
import android.view.View import android.view.View
import android.view.Window import android.view.Window
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.* import androidx.core.view.*
import com.multicraft.game.R import com.multicraft.game.R
@ -41,7 +42,7 @@ import java.io.InputStream
import kotlin.system.exitProcess import kotlin.system.exitProcess
// Activity extensions // Activity extensions
fun Activity.getIcon() = try { fun AppCompatActivity.getIcon() = try {
packageManager.getApplicationIcon(packageName) packageManager.getApplicationIcon(packageName)
} catch (e: PackageManager.NameNotFoundException) { } catch (e: PackageManager.NameNotFoundException) {
ContextCompat.getDrawable(this, R.mipmap.ic_launcher) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)
@ -63,7 +64,7 @@ fun Activity.finishApp(restart: Boolean) {
exitProcess(0) exitProcess(0)
} }
fun Activity.defaultDialog(title: Int, view: View, style: Int = R.style.CustomDialog): AlertDialog { fun AppCompatActivity.defaultDialog(title: Int, view: View, style: Int = R.style.CustomDialog): AlertDialog {
val builder = AlertDialog.Builder(this, style) val builder = AlertDialog.Builder(this, style)
.setIcon(getIcon()) .setIcon(getIcon())
.setTitle(title) .setTitle(title)
@ -72,7 +73,7 @@ fun Activity.defaultDialog(title: Int, view: View, style: Int = R.style.CustomDi
return builder.create() return builder.create()
} }
fun Activity.headlessDialog( fun AppCompatActivity.headlessDialog(
view: View, view: View,
style: Int = R.style.LightTheme, style: Int = R.style.LightTheme,
isCancelable: Boolean = false isCancelable: Boolean = false
@ -83,16 +84,15 @@ fun Activity.headlessDialog(
return builder.create() return builder.create()
} }
fun Activity.show(dialog: AlertDialog) { fun AppCompatActivity.show(dialog: AlertDialog) {
window?.makeFullScreen() window?.makeFullScreen()
if (!isFinishing) dialog.show() if (!isFinishing) dialog.show()
} }
fun Activity.showConnectionDialog(listener: (() -> Unit)? = null) { fun AppCompatActivity.showConnectionDialog(listener: (() -> Unit)? = null) {
val binding = ConnDialogBinding.inflate(layoutInflater) val binding = ConnDialogBinding.inflate(layoutInflater)
val dialog = defaultDialog(R.string.conn_title, binding.root) val dialog = defaultDialog(R.string.conn_title, binding.root)
binding.wifi.setOnClickListener { binding.wifi.setOnClickListener {
@Suppress("DEPRECATION")
dialog.dismiss() dialog.dismiss()
startActivityForResult( startActivityForResult(
Intent(Settings.ACTION_WIFI_SETTINGS), Intent(Settings.ACTION_WIFI_SETTINGS),
@ -100,7 +100,6 @@ fun Activity.showConnectionDialog(listener: (() -> Unit)? = null) {
) )
} }
binding.mobile.setOnClickListener { binding.mobile.setOnClickListener {
@Suppress("DEPRECATION")
dialog.dismiss() dialog.dismiss()
startActivityForResult( startActivityForResult(
Intent(Settings.ACTION_WIRELESS_SETTINGS), Intent(Settings.ACTION_WIRELESS_SETTINGS),
@ -114,7 +113,7 @@ fun Activity.showConnectionDialog(listener: (() -> Unit)? = null) {
show(dialog) show(dialog)
} }
fun Activity.showRestartDialog(isRestart: Boolean = true) { fun AppCompatActivity.showRestartDialog(isRestart: Boolean = true) {
val message = val message =
if (isRestart) getString(R.string.restart) else getString(R.string.no_space) if (isRestart) getString(R.string.restart) else getString(R.string.no_space)
val binding = RestartDialogBinding.inflate(layoutInflater) val binding = RestartDialogBinding.inflate(layoutInflater)
@ -125,7 +124,7 @@ fun Activity.showRestartDialog(isRestart: Boolean = true) {
show(dialog) show(dialog)
} }
fun Activity.isConnected(): Boolean { fun AppCompatActivity.isConnected(): Boolean {
val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
if (ApiLevelHelper.isMarshmallow()) { if (ApiLevelHelper.isMarshmallow()) {
val activeNetwork = cm.activeNetwork ?: return false val activeNetwork = cm.activeNetwork ?: return false

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -35,7 +36,7 @@
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingEnd="12dp" android:paddingEnd="12dp"
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:src="@drawable/sad" /> app:srcCompat="@drawable/sad" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/error_desc" android:id="@+id/error_desc"

View File

@ -11,14 +11,14 @@
<style name="LightTheme" parent="Theme.MaterialComponents.Light.Dialog"> <style name="LightTheme" parent="Theme.MaterialComponents.Light.Dialog">
<item name="android:windowBackground">@drawable/bg_common</item> <item name="android:windowBackground">@drawable/bg_common</item>
<item name="android:background">@android:color/transparent</item> <item name="background">@android:color/transparent</item>
<item name="windowMinWidthMajor">0%</item> <item name="windowMinWidthMajor">0%</item>
<item name="windowMinWidthMinor">0%</item> <item name="windowMinWidthMinor">0%</item>
</style> </style>
<style name="CustomDialog" parent="Theme.MaterialComponents.Light.Dialog.Alert"> <style name="CustomDialog" parent="Theme.MaterialComponents.Light.Dialog.Alert">
<item name="android:windowBackground">@drawable/bg_common</item> <item name="android:windowBackground">@drawable/bg_common</item>
<item name="android:background">@android:color/transparent</item> <item name="background">@android:color/transparent</item>
</style> </style>
<style name="FullScreenDialogStyle" parent="Theme.MaterialComponents.DayNight.Dialog"> <style name="FullScreenDialogStyle" parent="Theme.MaterialComponents.DayNight.Dialog">

View File

@ -16,7 +16,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:8.0.1' classpath 'com.android.tools.build:gradle:8.0.2'
//noinspection GradleDependency //noinspection GradleDependency
classpath 'de.undercouch:gradle-download-task:4.1.2' classpath 'de.undercouch:gradle-download-task:4.1.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20'
@ -32,7 +32,7 @@ allprojects {
} }
} }
task clean(type: Delete) { tasks.register('clean', Delete) {
delete rootProject.buildDir delete rootProject.buildDir
delete 'native/deps' delete 'native/deps'
} }

View File

@ -32,6 +32,7 @@ android {
abi { abi {
enable true enable true
reset() reset()
//noinspection ChromeOsAbiSupport
include 'armeabi-v7a', 'arm64-v8a', 'x86_64' include 'armeabi-v7a', 'arm64-v8a', 'x86_64'
} }
} }
@ -49,14 +50,15 @@ android {
} }
// get precompiled deps // get precompiled deps
task downloadDeps(type: Download) { tasks.register('downloadDeps', Download) {
def VERSION = "20042023" def VERSION = "29052023"
src "https://github.com/MultiCraft/deps_android/releases/download/$VERSION/deps_android.zip" src "https://github.com/MultiCraft/deps_android/releases/download/$VERSION/deps_android.zip"
dest new File(buildDir, 'deps.zip') dest new File(buildDir, 'deps.zip')
overwrite false overwrite false
} }
task getDeps(dependsOn: downloadDeps, type: Copy) { tasks.register('getDeps', Copy) {
dependsOn downloadDeps
def deps = file('deps') def deps = file('deps')
def f = file("$buildDir/deps_android") def f = file("$buildDir/deps_android")

View File

@ -86,7 +86,6 @@ LOCAL_CFLAGS += \
-DUSE_SQLITE=0 \ -DUSE_SQLITE=0 \
-DUSE_LUAJIT=1 \ -DUSE_LUAJIT=1 \
-DUSE_GETTEXT=1 \ -DUSE_GETTEXT=1 \
-D_IRR_COMPILE_WITH_SDL_DEVICE_ \
-DVERSION_MAJOR=${versionMajor} \ -DVERSION_MAJOR=${versionMajor} \
-DVERSION_MINOR=${versionMinor} \ -DVERSION_MINOR=${versionMinor} \
-DVERSION_PATCH=${versionPatch} \ -DVERSION_PATCH=${versionPatch} \