Android: minor update
(cherry picked from commit d2408a9324f08fde9cb109490bf8fbf04f748531)
This commit is contained in:
parent
6fbceface0
commit
478a488348
@ -47,6 +47,7 @@ android {
|
||||
abi {
|
||||
enable true
|
||||
reset()
|
||||
//noinspection ChromeOsAbiSupport
|
||||
include 'armeabi-v7a', 'arm64-v8a', 'x86_64'
|
||||
}
|
||||
}
|
||||
@ -66,7 +67,7 @@ android {
|
||||
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
task prepareAssetsFiles() {
|
||||
tasks.register('prepareAssetsFiles') {
|
||||
def assetsFolder = "build/assets/Files"
|
||||
def projRoot = "../.."
|
||||
|
||||
@ -94,20 +95,22 @@ task prepareAssetsFiles() {
|
||||
copy {
|
||||
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.
|
||||
def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1, 'x86_64': 2]
|
||||
android.applicationVariants.all { variant ->
|
||||
android.applicationVariants.configureEach { variant ->
|
||||
variant.outputs.each {
|
||||
output ->
|
||||
def abiName = output.filters[0].identifier
|
||||
@ -124,5 +127,5 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat-resources:1.6.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.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'
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import android.provider.Settings
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.*
|
||||
import com.multicraft.game.R
|
||||
@ -41,7 +42,7 @@ import java.io.InputStream
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
// Activity extensions
|
||||
fun Activity.getIcon() = try {
|
||||
fun AppCompatActivity.getIcon() = try {
|
||||
packageManager.getApplicationIcon(packageName)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
ContextCompat.getDrawable(this, R.mipmap.ic_launcher)
|
||||
@ -63,7 +64,7 @@ fun Activity.finishApp(restart: Boolean) {
|
||||
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)
|
||||
.setIcon(getIcon())
|
||||
.setTitle(title)
|
||||
@ -72,7 +73,7 @@ fun Activity.defaultDialog(title: Int, view: View, style: Int = R.style.CustomDi
|
||||
return builder.create()
|
||||
}
|
||||
|
||||
fun Activity.headlessDialog(
|
||||
fun AppCompatActivity.headlessDialog(
|
||||
view: View,
|
||||
style: Int = R.style.LightTheme,
|
||||
isCancelable: Boolean = false
|
||||
@ -83,16 +84,15 @@ fun Activity.headlessDialog(
|
||||
return builder.create()
|
||||
}
|
||||
|
||||
fun Activity.show(dialog: AlertDialog) {
|
||||
fun AppCompatActivity.show(dialog: AlertDialog) {
|
||||
window?.makeFullScreen()
|
||||
if (!isFinishing) dialog.show()
|
||||
}
|
||||
|
||||
fun Activity.showConnectionDialog(listener: (() -> Unit)? = null) {
|
||||
fun AppCompatActivity.showConnectionDialog(listener: (() -> Unit)? = null) {
|
||||
val binding = ConnDialogBinding.inflate(layoutInflater)
|
||||
val dialog = defaultDialog(R.string.conn_title, binding.root)
|
||||
binding.wifi.setOnClickListener {
|
||||
@Suppress("DEPRECATION")
|
||||
dialog.dismiss()
|
||||
startActivityForResult(
|
||||
Intent(Settings.ACTION_WIFI_SETTINGS),
|
||||
@ -100,7 +100,6 @@ fun Activity.showConnectionDialog(listener: (() -> Unit)? = null) {
|
||||
)
|
||||
}
|
||||
binding.mobile.setOnClickListener {
|
||||
@Suppress("DEPRECATION")
|
||||
dialog.dismiss()
|
||||
startActivityForResult(
|
||||
Intent(Settings.ACTION_WIRELESS_SETTINGS),
|
||||
@ -114,7 +113,7 @@ fun Activity.showConnectionDialog(listener: (() -> Unit)? = null) {
|
||||
show(dialog)
|
||||
}
|
||||
|
||||
fun Activity.showRestartDialog(isRestart: Boolean = true) {
|
||||
fun AppCompatActivity.showRestartDialog(isRestart: Boolean = true) {
|
||||
val message =
|
||||
if (isRestart) getString(R.string.restart) else getString(R.string.no_space)
|
||||
val binding = RestartDialogBinding.inflate(layoutInflater)
|
||||
@ -125,7 +124,7 @@ fun Activity.showRestartDialog(isRestart: Boolean = true) {
|
||||
show(dialog)
|
||||
}
|
||||
|
||||
fun Activity.isConnected(): Boolean {
|
||||
fun AppCompatActivity.isConnected(): Boolean {
|
||||
val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
if (ApiLevelHelper.isMarshmallow()) {
|
||||
val activeNetwork = cm.activeNetwork ?: return false
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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_height="wrap_content">
|
||||
|
||||
@ -35,7 +36,7 @@
|
||||
android:paddingTop="4dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:src="@drawable/sad" />
|
||||
app:srcCompat="@drawable/sad" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/error_desc"
|
||||
|
@ -11,14 +11,14 @@
|
||||
|
||||
<style name="LightTheme" parent="Theme.MaterialComponents.Light.Dialog">
|
||||
<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="windowMinWidthMinor">0%</item>
|
||||
</style>
|
||||
|
||||
<style name="CustomDialog" parent="Theme.MaterialComponents.Light.Dialog.Alert">
|
||||
<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 name="FullScreenDialogStyle" parent="Theme.MaterialComponents.DayNight.Dialog">
|
||||
|
@ -16,7 +16,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.0.1'
|
||||
classpath 'com.android.tools.build:gradle:8.0.2'
|
||||
//noinspection GradleDependency
|
||||
classpath 'de.undercouch:gradle-download-task:4.1.2'
|
||||
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 'native/deps'
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ android {
|
||||
abi {
|
||||
enable true
|
||||
reset()
|
||||
//noinspection ChromeOsAbiSupport
|
||||
include 'armeabi-v7a', 'arm64-v8a', 'x86_64'
|
||||
}
|
||||
}
|
||||
@ -49,14 +50,15 @@ android {
|
||||
}
|
||||
|
||||
// get precompiled deps
|
||||
task downloadDeps(type: Download) {
|
||||
def VERSION = "20042023"
|
||||
tasks.register('downloadDeps', Download) {
|
||||
def VERSION = "29052023"
|
||||
src "https://github.com/MultiCraft/deps_android/releases/download/$VERSION/deps_android.zip"
|
||||
dest new File(buildDir, 'deps.zip')
|
||||
overwrite false
|
||||
}
|
||||
|
||||
task getDeps(dependsOn: downloadDeps, type: Copy) {
|
||||
tasks.register('getDeps', Copy) {
|
||||
dependsOn downloadDeps
|
||||
def deps = file('deps')
|
||||
def f = file("$buildDir/deps_android")
|
||||
|
||||
|
@ -86,7 +86,6 @@ LOCAL_CFLAGS += \
|
||||
-DUSE_SQLITE=0 \
|
||||
-DUSE_LUAJIT=1 \
|
||||
-DUSE_GETTEXT=1 \
|
||||
-D_IRR_COMPILE_WITH_SDL_DEVICE_ \
|
||||
-DVERSION_MAJOR=${versionMajor} \
|
||||
-DVERSION_MINOR=${versionMinor} \
|
||||
-DVERSION_PATCH=${versionPatch} \
|
||||
|
Loading…
x
Reference in New Issue
Block a user