1
0

Android: update and improve Kotlin part (#99)

This commit is contained in:
Bektur 2022-11-11 22:45:05 +06:00 committed by GitHub
parent 8535658791
commit ecc472ab14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 511 additions and 363 deletions

View File

@ -59,6 +59,7 @@ android {
buildFeatures {
viewBinding true
}
namespace = "com.multicraft.game"
}
import org.apache.tools.ant.taskdefs.condition.Os
@ -100,24 +101,7 @@ task prepareAssetsFiles() {
}
}
task prepareAssetsGames() {
def assetsFolder = "build/assets/games"
def projRoot = "../../.."
def gameToCopy = "default"
copy {
from "${projRoot}/games/${gameToCopy}" into "${assetsFolder}/games/${gameToCopy}"
}
task zipAssetsGames(type: Zip) {
archiveFileName = "games.zip"
destinationDirectory = file("src/main/assets/data")
from "${assetsFolder}"
}
}
preBuild.dependsOn zipAssetsFiles
preBuild.dependsOn zipAssetsGames
// Map for the version code that gives each ABI a value.
def abiCodes = ['armeabi-v7a': 0, 'arm64-v8a': 1]
@ -138,5 +122,5 @@ dependencies {
implementation 'androidx.appcompat:appcompat-resources:1.5.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.work:work-runtime-ktx:2.7.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'com.google.android.material:material:1.7.0'
}

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.multicraft.game"
android:installLocation="auto">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@ -28,6 +27,7 @@
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="false"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"

View File

@ -1,7 +1,7 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View File

@ -1,6 +1,6 @@
/*
MultiCraft
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
@ -27,14 +27,16 @@ import android.net.Uri
import android.os.Bundle
import android.text.InputType
import android.view.*
import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.multicraft.game.MainActivity.Companion.radius
import com.multicraft.game.databinding.InputTextBinding
import com.multicraft.game.helpers.Utilities.finishApp
import com.multicraft.game.helpers.Utilities.makeFullScreen
import com.multicraft.game.databinding.MultilineInputBinding
import com.multicraft.game.helpers.*
import org.libsdl.app.SDLActivity
class GameActivity : SDLActivity() {
@ -72,7 +74,7 @@ class GameActivity : SDLActivity() {
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) makeFullScreen(window)
if (hasFocus) window.makeFullScreen()
}
@Deprecated("Deprecated in Java")
@ -87,7 +89,7 @@ class GameActivity : SDLActivity() {
override fun onResume() {
super.onResume()
makeFullScreen(window)
window.makeFullScreen()
}
override fun onConfigurationChanged(newConfig: Configuration) {
@ -105,33 +107,30 @@ class GameActivity : SDLActivity() {
@Suppress("UNUSED_PARAMETER") s: String?,
hint: String?, current: String?, editType: Int
) {
runOnUiThread { showDialogUI(hint, current, editType) }
if (editType == 1)
runOnUiThread { showMultiLineDialog(hint, current) }
else
runOnUiThread { showSingleDialog(hint, current, editType) }
}
private fun showDialogUI(hint: String?, current: String?, editType: Int) {
private fun showSingleDialog(hint: String?, current: String?, editType: Int) {
isInputActive = true
val builder = AlertDialog.Builder(this)
if (editType == 1) builder.setPositiveButton(R.string.done, null)
val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle)
val binding = InputTextBinding.inflate(layoutInflater)
val hintText = hint?.ifEmpty {
resources.getString(if (editType == 3) R.string.input_password else R.string.input_text)
}
binding.inputLayout.hint = hintText
binding.input.hint = hintText
builder.setView(binding.root)
val alertDialog = builder.create()
val editText = binding.editText
editText.requestFocus()
editText.setText(current.toString())
if (editType != 1) editText.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
editText.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
var inputType = InputType.TYPE_CLASS_TEXT
when (editType) {
1 -> {
inputType = inputType or InputType.TYPE_TEXT_FLAG_MULTI_LINE
editText.maxLines = 8
}
3 -> inputType = inputType or InputType.TYPE_TEXT_VARIATION_PASSWORD
}
if (editType == 3)
inputType = inputType or InputType.TYPE_TEXT_VARIATION_PASSWORD
editText.inputType = inputType
editText.setSelection(editText.text?.length ?: 0)
// for Android OS
@ -158,19 +157,96 @@ class GameActivity : SDLActivity() {
}
return@setOnKeyListener false
}
// should be above `show()`
alertDialog.window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
alertDialog.show()
val button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE)
button?.setOnClickListener {
binding.input.setEndIconOnClickListener {
imm.hideSoftInputFromWindow(editText.windowToken, 0)
messageReturnCode = 0
messageReturnValue = editText.text.toString()
alertDialog.dismiss()
isInputActive = false
}
binding.rl.setOnClickListener {
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
messageReturnValue = current.toString()
messageReturnCode = -1
alertDialog.dismiss()
isInputActive = false
}
val alertWindow = alertDialog.window!!
// should be above `show()`
alertWindow.setSoftInputMode(SOFT_INPUT_STATE_VISIBLE)
alertDialog.show()
if (!resources.getBoolean(R.bool.isTablet))
alertWindow.makeFullScreenAlert()
alertDialog.setOnCancelListener {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
messageReturnValue = current.toString()
messageReturnCode = -1
isInputActive = false
}
}
private fun showMultiLineDialog(hint: String?, current: String?) {
isInputActive = true
val builder = AlertDialog.Builder(this, R.style.FullScreenDialogStyle)
val binding = MultilineInputBinding.inflate(layoutInflater)
val hintText = hint?.ifEmpty {
resources.getString(R.string.input_text)
}
binding.multiInput.hint = hintText
builder.setView(binding.root)
val alertDialog = builder.create()
val editText = binding.multiEditText
editText.requestFocus()
editText.setText(current.toString())
editText.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
editText.setSelection(editText.text?.length ?: 0)
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
// for Android OS
editText.setOnEditorActionListener { _: TextView?, KeyCode: Int, _: KeyEvent? ->
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
imm.hideSoftInputFromWindow(editText.windowToken, 0)
messageReturnCode = 0
messageReturnValue = editText.text.toString()
alertDialog.dismiss()
isInputActive = false
return@setOnEditorActionListener true
}
return@setOnEditorActionListener false
}
// for Chrome OS
editText.setOnKeyListener { _: View?, KeyCode: Int, _: KeyEvent? ->
if (KeyCode == KeyEvent.KEYCODE_ENTER || KeyCode == KeyEvent.KEYCODE_ENDCALL) {
imm.hideSoftInputFromWindow(editText.windowToken, 0)
messageReturnCode = 0
messageReturnValue = editText.text.toString()
alertDialog.dismiss()
isInputActive = false
return@setOnKeyListener true
}
return@setOnKeyListener false
}
binding.multiInput.setEndIconOnClickListener {
imm.hideSoftInputFromWindow(editText.windowToken, 0)
messageReturnCode = 0
messageReturnValue = editText.text.toString()
alertDialog.dismiss()
isInputActive = false
}
binding.multiRl.setOnClickListener {
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
messageReturnValue = current.toString()
messageReturnCode = -1
alertDialog.dismiss()
isInputActive = false
}
// should be above `show()`
val alertWindow = alertDialog.window!!
alertWindow.setSoftInputMode(SOFT_INPUT_STATE_VISIBLE)
alertDialog.show()
if (!resources.getBoolean(R.bool.isTablet))
alertWindow.makeFullScreenAlert()
alertDialog.setOnCancelListener {
window.setSoftInputMode(SOFT_INPUT_STATE_ALWAYS_HIDDEN)
messageReturnValue = current.toString()
messageReturnCode = -1
isInputActive = false
@ -209,7 +285,7 @@ class GameActivity : SDLActivity() {
@Suppress("unused")
fun finishGame(exc: String?) {
finishApp(true, this)
finishApp(true)
}
@Suppress("unused")
@ -220,6 +296,7 @@ class GameActivity : SDLActivity() {
fun upgrade(item: String) {
}
@Suppress("unused")
fun getSecretKey(key: String): String {
return "Stub"
}

View File

@ -1,7 +1,7 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -20,35 +20,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
package com.multicraft.game
import android.content.*
import android.content.Intent
import android.content.SharedPreferences
import android.graphics.Color
import android.graphics.drawable.LayerDrawable
import android.os.Bundle
import android.provider.Settings.ACTION_WIFI_SETTINGS
import android.provider.Settings.ACTION_WIRELESS_SETTINGS
import android.view.*
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat
import androidx.lifecycle.*
import androidx.work.WorkInfo
import com.multicraft.game.databinding.ActivityMainBinding
import com.multicraft.game.helpers.*
import com.multicraft.game.helpers.ApiLevelHelper.isAndroid12
import com.multicraft.game.helpers.PreferenceHelper
import com.multicraft.game.helpers.PreferenceHelper.TAG_BUILD_VER
import com.multicraft.game.helpers.PreferenceHelper.TAG_LAUNCH_TIMES
import com.multicraft.game.helpers.PreferenceHelper.TAG_SHORTCUT_EXIST
import com.multicraft.game.helpers.PreferenceHelper.getBoolValue
import com.multicraft.game.helpers.PreferenceHelper.getIntValue
import com.multicraft.game.helpers.PreferenceHelper.getStringValue
import com.multicraft.game.helpers.PreferenceHelper.set
import com.multicraft.game.helpers.Utilities.addShortcut
import com.multicraft.game.helpers.Utilities.copyInputStreamToFile
import com.multicraft.game.helpers.Utilities.getIcon
import com.multicraft.game.helpers.Utilities.isConnected
import com.multicraft.game.helpers.Utilities.makeFullScreen
import com.multicraft.game.helpers.Utilities.showRestartDialog
import com.multicraft.game.workmanager.UnzipWorker.Companion.PROGRESS
import com.multicraft.game.workmanager.WorkerViewModel
import com.multicraft.game.workmanager.WorkerViewModelFactory
@ -61,8 +49,8 @@ class MainActivity : AppCompatActivity() {
private var externalStorage: File? = null
private val sep = File.separator
private lateinit var prefs: SharedPreferences
private val versionName = BuildConfig.VERSION_NAME
private val requestConnection = 104
private val versionCode = BuildConfig.VERSION_CODE
private val versionName = "${BuildConfig.VERSION_NAME}+$versionCode"
companion object {
var radius = 0
@ -73,14 +61,14 @@ class MainActivity : AppCompatActivity() {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
prefs = PreferenceHelper.init(this)
try {
prefs = PreferenceHelper.init(this)
externalStorage = getExternalFilesDir(null)
if (filesDir == null || cacheDir == null || externalStorage == null)
throw IOException("Bad disk space state")
lateInit()
} catch (e: IOException) {
showRestartDialog(this, !e.message!!.contains("ENOSPC"))
checkConnection()
} catch (e: Exception) { // Storage -> IOException, Prefs -> GeneralSecurityException
showRestartDialog(!e.message!!.contains("ENOPSC"))
}
}
@ -88,7 +76,7 @@ class MainActivity : AppCompatActivity() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@Suppress("DEPRECATION")
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == requestConnection)
if (requestCode == 104)
checkAppVersion()
}
@ -99,12 +87,12 @@ class MainActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
makeFullScreen(window)
window.makeFullScreen()
}
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) makeFullScreen(window)
if (hasFocus) window.makeFullScreen()
}
override fun onAttachedToWindow() {
@ -118,20 +106,17 @@ class MainActivity : AppCompatActivity() {
}
}
private fun addLaunchTimes() {
val launchTimes = prefs.getIntValue(TAG_LAUNCH_TIMES) + 1
prefs[TAG_LAUNCH_TIMES] = launchTimes
}
// interface
private fun showProgress(textMessage: Int, progressMessage: Int, progress: Int) {
private fun showProgress(textMessage: Int, progress: Int) {
if (binding.progressBar.visibility == View.GONE) {
binding.tvProgress.setText(textMessage)
binding.progressCircle.visibility = View.GONE
binding.progressBar.visibility = View.VISIBLE
binding.progressBar.progress = 0
} else if (progress > 0) {
binding.tvProgress.text = String.format(getString(progressMessage), progress)
val progressMessage = "${getString(textMessage)} $progress%"
binding.tvProgress.text = progressMessage
binding.progressBar.progress = progress
// colorize the progress bar
val progressBarDrawable =
@ -145,15 +130,6 @@ class MainActivity : AppCompatActivity() {
}
}
private fun lateInit() {
addLaunchTimes()
if (!prefs.getBoolValue(TAG_SHORTCUT_EXIST)) try {
addShortcut(this)
} catch (ignored: Exception) {
}
checkConnection()
}
private fun startNative() {
val initLua = File(filesDir, "builtin${sep}mainmenu${sep}init.lua")
if (initLua.exists() && initLua.canRead()) {
@ -162,7 +138,7 @@ class MainActivity : AppCompatActivity() {
startActivity(intent)
} else {
prefs[TAG_BUILD_VER] = "0"
showRestartDialog(this)
showRestartDialog()
}
}
@ -171,14 +147,11 @@ class MainActivity : AppCompatActivity() {
binding.progressCircle.visibility = View.VISIBLE
binding.progressBar.visibility = View.GONE
val filesList = listOf(
File(externalStorage, "builtin"),
File(externalStorage, "cache"), // ToDo: remove me!
File(externalStorage, "games${sep}default"),
File(externalStorage, "textures${sep}base"),
File(externalStorage, "debug.txt"),
File(filesDir, "builtin"),
File(filesDir, "games"),
File(filesDir, "textures${sep}base")
File(filesDir, "client"),
File(filesDir, "fonts"),
File(filesDir, "textures")
)
val zips = assets.list("data")!!.toList()
lifecycleScope.launch {
@ -189,19 +162,14 @@ class MainActivity : AppCompatActivity() {
File(cacheDir, it).copyInputStreamToFile(input)
}
} catch (e: IOException) {
runOnUiThread {
showRestartDialog(
this@MainActivity,
!e.message!!.contains("ENOSPC")
)
}
runOnUiThread { showRestartDialog(!e.message!!.contains("ENOSPC")) }
return@forEach
}
}
try {
startUnzipWorker(zips)
} catch (e: Exception) {
runOnUiThread { showRestartDialog(this@MainActivity) }
runOnUiThread { showRestartDialog() }
}
}
}
@ -216,10 +184,10 @@ class MainActivity : AppCompatActivity() {
// check connection available
private fun checkConnection() = lifecycleScope.launch {
val result = isConnected(this@MainActivity)
val result = isConnected()
if (result) checkAppVersion()
else try {
showConnectionDialog()
showConnectionDialog { checkAppVersion() }
} catch (e: Exception) {
checkAppVersion()
}
@ -233,11 +201,12 @@ class MainActivity : AppCompatActivity() {
if (workInfo == null)
return@Observer
val progress = workInfo.progress.getInt(PROGRESS, 0)
showProgress(R.string.loading, R.string.loadingp, progress)
showProgress(R.string.loading, progress)
if (workInfo.state.isFinished) {
if (workInfo.state == WorkInfo.State.FAILED) {
showRestartDialog(this)
val isRestart = workInfo.outputData.getBoolean("restart", true)
showRestartDialog(isRestart)
} else if (workInfo.state == WorkInfo.State.SUCCEEDED) {
prefs[TAG_BUILD_VER] = versionName
startNative()
@ -246,28 +215,4 @@ class MainActivity : AppCompatActivity() {
})
viewModel.startOneTimeWorkRequest()
}
// connection dialog
private fun showConnectionDialog() {
val builder = AlertDialog.Builder(this)
builder.setIcon(getIcon(this))
.setTitle(R.string.conn_title)
.setMessage(R.string.conn_message)
.setPositiveButton(R.string.conn_wifi) { _, _ ->
@Suppress("DEPRECATION")
startActivityForResult(Intent(ACTION_WIFI_SETTINGS), requestConnection)
}
.setNegativeButton(R.string.conn_mobile) { _, _ ->
@Suppress("DEPRECATION")
startActivityForResult(Intent(ACTION_WIRELESS_SETTINGS), requestConnection)
}
.setNeutralButton(R.string.ignore) { _, _ -> checkAppVersion() }
.setCancelable(false)
val dialog = builder.create()
makeFullScreen(dialog.window!!)
if (!isFinishing) {
dialog.show()
dialog.getButton(DialogInterface.BUTTON_NEUTRAL)?.setTextColor(Color.RED)
}
}
}

View File

@ -1,7 +1,7 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View File

@ -1,7 +1,7 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -24,9 +24,7 @@ import android.content.Context
import android.content.SharedPreferences
object PreferenceHelper {
const val TAG_SHORTCUT_EXIST = "createShortcut"
const val TAG_BUILD_VER = "buildVer"
const val TAG_LAUNCH_TIMES = "launchTimes"
fun init(context: Context): SharedPreferences =
context.getSharedPreferences("MultiCraftSettings", Context.MODE_PRIVATE)
@ -46,16 +44,6 @@ object PreferenceHelper {
else -> throw UnsupportedOperationException("Not yet implemented")
}
fun SharedPreferences.getBoolValue(key: String): Boolean = when (key) {
TAG_SHORTCUT_EXIST -> getBoolean(key, false)
else -> throw UnsupportedOperationException("Not yet implemented")
}
fun SharedPreferences.getIntValue(key: String) = when (key) {
TAG_LAUNCH_TIMES -> getInt(key, 0)
else -> throw UnsupportedOperationException("Not yet implemented")
}
fun SharedPreferences.getStringValue(key: String) = when (key) {
TAG_BUILD_VER -> getString(key, "0") as String
else -> throw UnsupportedOperationException("Not yet implemented")

View File

@ -0,0 +1,159 @@
/*
MultiCraft
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3.0 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.multicraft.game.helpers
import android.app.*
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.provider.Settings
import android.view.View
import android.view.Window
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.core.view.*
import com.multicraft.game.R
import com.multicraft.game.databinding.ConnDialogBinding
import com.multicraft.game.databinding.RestartDialogBinding
import com.multicraft.game.helpers.ApiLevelHelper.isAndroid12
import java.io.File
import java.io.InputStream
import kotlin.system.exitProcess
// Activity extensions
fun Activity.getIcon() = try {
packageManager.getApplicationIcon(packageName)
} catch (e: PackageManager.NameNotFoundException) {
ContextCompat.getDrawable(this, R.mipmap.ic_launcher)
}
fun Activity.finishApp(restart: Boolean) {
if (restart) {
val intent = Intent(this, this::class.java)
val mPendingIntentId = 1337
val flag =
if (isAndroid12()) PendingIntent.FLAG_IMMUTABLE else PendingIntent.FLAG_CANCEL_CURRENT
val mgr = getSystemService(Context.ALARM_SERVICE) as AlarmManager
mgr.set(
AlarmManager.RTC, System.currentTimeMillis(), PendingIntent.getActivity(
this, mPendingIntentId, intent, flag
)
)
}
exitProcess(0)
}
fun Activity.defaultDialog(title: Int, view: View, style: Int = R.style.CustomDialog): AlertDialog {
val builder = AlertDialog.Builder(this, style)
.setIcon(getIcon())
.setTitle(title)
.setCancelable(false)
.setView(view)
return builder.create()
}
fun Activity.headlessDialog(
view: View,
style: Int = R.style.LightTheme,
isCancelable: Boolean = false
): AlertDialog {
val builder = AlertDialog.Builder(this, style)
.setCancelable(isCancelable)
.setView(view)
return builder.create()
}
fun Activity.show(dialog: AlertDialog) {
window?.makeFullScreen()
if (!isFinishing) dialog.show()
}
fun Activity.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),
104
)
}
binding.mobile.setOnClickListener {
@Suppress("DEPRECATION")
dialog.dismiss()
startActivityForResult(
Intent(Settings.ACTION_WIRELESS_SETTINGS),
104
)
}
binding.ignore.setOnClickListener {
dialog.dismiss()
listener?.invoke()
}
show(dialog)
}
fun Activity.showRestartDialog(isRestart: Boolean = true) {
val message =
if (isRestart) getString(R.string.restart) else getString(R.string.no_space)
val binding = RestartDialogBinding.inflate(layoutInflater)
val dialog = headlessDialog(binding.root, R.style.CustomDialog)
binding.errorDesc.text = message
binding.close.setOnClickListener { finishApp(false) }
binding.restart.setOnClickListener { finishApp(true) }
show(dialog)
}
fun Activity.isConnected(): Boolean {
val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
if (ApiLevelHelper.isMarshmallow()) {
val activeNetwork = cm.activeNetwork ?: return false
val capabilities = cm.getNetworkCapabilities(activeNetwork) ?: return false
return capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
} else @Suppress("DEPRECATION") {
val activeNetworkInfo = cm.activeNetworkInfo ?: return false
return activeNetworkInfo.isConnected
}
}
// Other extensions
fun File.copyInputStreamToFile(inputStream: InputStream) =
outputStream().use { fileOut -> inputStream.copyTo(fileOut, 8192) }
fun Window.makeFullScreen() {
WindowCompat.setDecorFitsSystemWindows(this, false)
WindowInsetsControllerCompat(this, decorView).let {
it.hide(WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.navigationBars())
it.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
fun Window.makeFullScreenAlert() {
WindowInsetsControllerCompat(this, decorView).let {
it.hide(WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.navigationBars())
it.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}

View File

@ -1,139 +0,0 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3.0 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.multicraft.game.helpers
import android.app.*
import android.app.PendingIntent.FLAG_CANCEL_CURRENT
import android.app.PendingIntent.FLAG_IMMUTABLE
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.net.ConnectivityManager
import android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED
import android.view.Window
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat.Type.navigationBars
import androidx.core.view.WindowInsetsCompat.Type.statusBars
import androidx.core.view.WindowInsetsControllerCompat
import androidx.core.view.WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
import com.multicraft.game.MainActivity
import com.multicraft.game.R
import com.multicraft.game.databinding.RestartDialogBinding
import com.multicraft.game.helpers.ApiLevelHelper.isAndroid12
import com.multicraft.game.helpers.ApiLevelHelper.isMarshmallow
import com.multicraft.game.helpers.ApiLevelHelper.isOreo
import com.multicraft.game.helpers.PreferenceHelper.TAG_SHORTCUT_EXIST
import com.multicraft.game.helpers.PreferenceHelper.set
import java.io.File
import java.io.InputStream
import kotlin.system.exitProcess
object Utilities {
fun makeFullScreen(window: Window) {
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window, window.decorView).let {
it.hide(statusBars() or navigationBars())
it.systemBarsBehavior = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
fun getIcon(activity: Activity) = try {
activity.packageManager.getApplicationIcon(activity.packageName)
} catch (e: PackageManager.NameNotFoundException) {
ContextCompat.getDrawable(activity, R.mipmap.ic_launcher)
}
@Suppress("DEPRECATION")
fun addShortcut(activity: AppCompatActivity) {
if (isOreo()) return
val activityManager = activity.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val size = activityManager.launcherLargeIconSize
var shortcutIconBitmap = (getIcon(activity) as BitmapDrawable).bitmap
if (shortcutIconBitmap.width != size || shortcutIconBitmap.height != size)
shortcutIconBitmap = Bitmap.createScaledBitmap(shortcutIconBitmap, size, size, true)
val shortcutIntent = Intent(activity, MainActivity::class.java)
shortcutIntent.action = Intent.ACTION_MAIN
val addIntent = Intent()
addIntent.putExtra("duplicate", false)
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent)
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, R.string.app_name)
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, shortcutIconBitmap)
addIntent.action = "com.android.launcher.action.INSTALL_SHORTCUT"
activity.applicationContext.sendBroadcast(addIntent)
// save preference
PreferenceHelper.init(activity)[TAG_SHORTCUT_EXIST] = true
}
fun finishApp(restart: Boolean, activity: Activity) {
if (restart) {
val intent = Intent(activity, activity::class.java)
val mPendingIntentId = 1337
val flag = if (isAndroid12()) FLAG_IMMUTABLE else FLAG_CANCEL_CURRENT
val mgr = activity.getSystemService(Context.ALARM_SERVICE) as AlarmManager
mgr.set(
AlarmManager.RTC, System.currentTimeMillis(), PendingIntent.getActivity(
activity, mPendingIntentId, intent, flag
)
)
}
exitProcess(0)
}
fun showRestartDialog(activity: Activity, isRestart: Boolean = true) {
val message =
if (isRestart) activity.getString(R.string.restart) else activity.getString(R.string.no_space)
val builder = AlertDialog.Builder(activity)
builder.setIcon(getIcon(activity))
val binding = RestartDialogBinding.inflate(activity.layoutInflater)
builder.setView(binding.root)
val dialog = builder.create()
binding.errorDesc.text = message
binding.close.setOnClickListener {
dialog.dismiss()
finishApp(!isRestart, activity)
}
binding.restart.setOnClickListener { finishApp(isRestart, activity) }
dialog.window?.setBackgroundDrawableResource(R.drawable.custom_dialog_rounded_daynight)
makeFullScreen(dialog.window!!)
dialog.show()
}
fun File.copyInputStreamToFile(inputStream: InputStream) =
this.outputStream().use { fileOut -> inputStream.copyTo(fileOut, 8192) }
fun isConnected(context: Context): Boolean {
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
if (isMarshmallow()) {
val activeNetwork = cm.activeNetwork ?: return false
val capabilities = cm.getNetworkCapabilities(activeNetwork) ?: return false
return capabilities.hasCapability(NET_CAPABILITY_VALIDATED)
} else @Suppress("DEPRECATION") {
val activeNetworkInfo = cm.activeNetworkInfo ?: return false
return activeNetworkInfo.isConnected
}
}
}

View File

@ -1,7 +1,7 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@ -25,13 +25,10 @@ import android.app.NotificationManager
import android.content.Context
import android.content.Context.NOTIFICATION_SERVICE
import androidx.core.app.NotificationCompat
import androidx.work.CoroutineWorker
import androidx.work.ForegroundInfo
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import androidx.work.*
import com.multicraft.game.R
import com.multicraft.game.helpers.ApiLevelHelper.isOreo
import com.multicraft.game.helpers.Utilities.copyInputStreamToFile
import com.multicraft.game.helpers.copyInputStreamToFile
import java.io.File
import java.io.IOException
import java.util.zip.ZipFile
@ -86,7 +83,11 @@ class UnzipWorker(private val appContext: Context, workerParams: WorkerParameter
}
Result.success()
} catch (e: IOException) {
Result.failure()
val isNotEnoughSpace = e.localizedMessage!!.contains("ENOSPC")
val out = Data.Builder()
.putBoolean("restart", !isNotEnoughSpace)
.build()
Result.failure(out)
} finally {
zips.forEach { File(appContext.cacheDir, it).delete() }
}

View File

@ -1,7 +1,7 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View File

@ -1,7 +1,7 @@
/*
MultiCraft
Copyright (C) 2014-2021 MoNTE48, Maksim Gamarnik <MoNTE48@mail.ua>
Copyright (C) 2014-2021 ubulem, Bektur Mambetov <berkut87@gmail.com>
Copyright (C) 2014-2022 MoNTE48, Maksim Gamarnik <Maksym48@pm.me>
Copyright (C) 2014-2022 ubulem, Bektur Mambetov <berkut87@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/not_white" />
<corners android:radius="12dp" />
<solid android:color="@color/dark" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?attr/colorBackgroundFloating" />
<corners android:radius="12dp" />
<solid android:color="@color/light" />
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>

View File

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:autoMirrored="true"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#008C80"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z" />
</vector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

View File

@ -8,8 +8,6 @@
android:layout_width="512dp"
android:layout_height="64dp"
android:layout_centerInParent="true"
android:layout_marginLeft="120dp"
android:layout_marginRight="120dp"
android:indeterminate="false"
android:max="100"
android:progressDrawable="@drawable/progress"
@ -23,14 +21,14 @@
android:layout_centerInParent="true"
android:indeterminate="true" />
<TextView
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/progress_circle"
android:layout_centerInParent="true"
android:text="@string/loading"
android:textColor="@color/not_white"
android:textColor="@color/light"
android:textSize="14sp" />
</RelativeLayout>

View File

@ -0,0 +1,61 @@
<?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="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingLeft="16dp"
android:paddingTop="24dp"
android:paddingRight="16dp"
android:text="@string/conn_message"
android:textColor="@color/grey_900" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/ignore"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="0.3"
android:text="@string/ignore"
android:textAllCaps="false"
android:textColor="@android:color/white"
app:backgroundTint="@color/red" />
<com.google.android.material.button.MaterialButton
android:id="@+id/mobile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="0.4"
android:text="@string/conn_mobile"
android:textAllCaps="false"
android:textColor="@android:color/white"
app:backgroundTint="@color/green_mc" />
<com.google.android.material.button.MaterialButton
android:id="@+id/wifi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="0.4"
android:text="@string/conn_wifi"
android:textAllCaps="false"
android:textColor="@android:color/white"
app:backgroundTint="@color/green_mc" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -1,13 +1,25 @@
<com.google.android.material.textfield.TextInputLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/inputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp">
android:layout_height="match_parent">
<com.multicraft.game.CustomEditText
android:id="@+id/editText"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/input"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/input_text" />
</com.google.android.material.textfield.TextInputLayout>
android:layout_alignParentBottom="true"
android:background="@drawable/bg_input"
android:hint="@string/input_text"
android:padding="5dp"
app:endIconDrawable="@drawable/ic_baseline_send"
app:endIconMode="custom"
app:endIconTint="@null">
<com.multicraft.game.CustomEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="60dp" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>

View File

@ -0,0 +1,27 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/multiRl"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/multiInput"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/bg_input"
android:hint="@string/input_text"
android:padding="5dp"
app:endIconDrawable="@drawable/ic_baseline_send"
app:endIconMode="custom"
app:endIconTint="@null">
<com.multicraft.game.CustomEditText
android:id="@+id/multiEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:maxLines="8" />
</com.google.android.material.textfield.TextInputLayout>
</RelativeLayout>

View File

@ -1,15 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- подготовка к запуску -->
<string name="preparing">Подготовка к запуску&#8230;</string>
<string name="loading">Загрузка&#8230;</string>
<string name="loadingp">Загрузка&#8230; %d%%</string>
<string name="notification_title">Загрузка MultiCraft</string>
<string name="notification_description">Осталось меньше минуты&#8230;</string>
<string name="input_text">Введите Текст</string>
<string name="input_password">Пароль</string>
<string name="done">Готово</string>
<string name="input_text">Введите текст</string>
<string name="input_password">Введите пароль</string>
<!-- диалог отсутствия подключения -->
<string name="conn_title">Нет Интернет Подключения!</string>

View File

@ -0,0 +1,3 @@
<resources>
<bool name="isTablet">true</bool>
</resources>

View File

@ -0,0 +1,3 @@
<resources>
<bool name="isTablet">false</bool>
</resources>

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="green">#008c80</color>
<color name="not_white">#fefefe</color>
<color name="green">#008C80</color>
<color name="light">#FAFAFA</color>
<color name="dark">#121212</color>
<color name="red">#FF1744</color>
<color name="green_mc">#32783C</color>
<color name="grey_900">#212121</color>
</resources>

View File

@ -2,17 +2,12 @@
<resources>
<string name="app_name" translatable="false">MultiCraft</string>
<!-- preparation for start -->
<string name="preparing">Preparing to launch&#8230;</string>
<string name="loading">Loading&#8230;</string>
<string name="loadingp">Loading&#8230; %d%%</string>
<string name="notification_title">Loading MultiCraft</string>
<string name="notification_description">Less than 1 minute&#8230;</string>
<string name="ok" translatable="false">OK</string>
<string name="input_text">Text Input</string>
<string name="input_password">Password</string>
<string name="done">Done</string>
<string name="input_text">Enter text</string>
<string name="input_password">Enter password</string>
<!-- no connection dialog -->
<string name="conn_title">No Internet Connection!</string>

View File

@ -1,14 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="windowActionBar">false</item>
<item name="android:windowBackground">@drawable/bg</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="p">shortEdges</item>
<item name="fontFamily">@font/multicraftfont</item>
<item name="colorControlActivated">@color/green</item>
<item name="colorPrimary">@color/green</item>
</style>
<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="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>
</style>
<style name="FullScreenDialogStyle" parent="Theme.MaterialComponents.DayNight.Dialog">
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowEnterAnimation">@null</item>
</style>
</resources>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
<exclude
domain="sharedpref"
path="MultiCraftSettings.xml" />
</cloud-backup>
</data-extraction-rules>

View File

@ -16,10 +16,10 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:7.3.1'
//noinspection GradleDependency
classpath 'de.undercouch:gradle-download-task:4.1.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

View File

@ -45,6 +45,7 @@ android {
}
}
}
namespace = "com.multicraft"
}
// get precompiled deps

View File

@ -4,72 +4,72 @@ LOCAL_PATH := $(call my-dir)/..
include $(CLEAR_VARS)
LOCAL_MODULE := Curl
LOCAL_SRC_FILES := deps/Android/Curl/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libcurl.a
LOCAL_SRC_FILES := deps/Android/Curl/clang/$(APP_ABI)/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Freetype
LOCAL_SRC_FILES := deps/Android/Freetype/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libfreetype.a
LOCAL_SRC_FILES := deps/Android/Freetype/clang/$(APP_ABI)/libfreetype.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Irrlicht
LOCAL_SRC_FILES := deps/Android/Irrlicht/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libIrrlicht.a
LOCAL_SRC_FILES := deps/Android/Irrlicht/clang/$(APP_ABI)/libIrrlicht.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpng
LOCAL_SRC_FILES := deps/Android/libpng/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libpng.a
LOCAL_SRC_FILES := deps/Android/libpng/clang/$(APP_ABI)/libpng.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libjpeg
LOCAL_SRC_FILES := deps/Android/libjpeg/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libjpeg.a
LOCAL_SRC_FILES := deps/Android/libjpeg/clang/$(APP_ABI)/libjpeg.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := SDL2
LOCAL_SRC_FILES := deps/Android/SDL2/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libSDL2.a
LOCAL_SRC_FILES := deps/Android/SDL2/clang/$(APP_ABI)/libSDL2.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := LevelDB
LOCAL_SRC_FILES := deps/Android/LevelDB/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libleveldb.a
LOCAL_SRC_FILES := deps/Android/LevelDB/clang/$(APP_ABI)/libleveldb.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := LuaJIT
LOCAL_SRC_FILES := deps/Android/LuaJIT/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libluajit.a
LOCAL_SRC_FILES := deps/Android/LuaJIT/clang/$(APP_ABI)/libluajit.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mbedTLS
LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedtls.a
LOCAL_SRC_FILES := deps/Android/mbedTLS/clang/$(APP_ABI)/libmbedtls.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mbedx509
LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedx509.a
LOCAL_SRC_FILES := deps/Android/mbedTLS/clang/$(APP_ABI)/libmbedx509.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := mbedcrypto
LOCAL_SRC_FILES := deps/Android/mbedTLS/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libmbedcrypto.a
LOCAL_SRC_FILES := deps/Android/mbedTLS/clang/$(APP_ABI)/libmbedcrypto.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OpenAL
LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libopenal.a
LOCAL_SRC_FILES := deps/Android/OpenAL-Soft/clang/$(APP_ABI)/libopenal.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Gettext
LOCAL_SRC_FILES := deps/Android/Gettext/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libintl.a
LOCAL_SRC_FILES := deps/Android/Gettext/clang/$(APP_ABI)/libintl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := Vorbis
LOCAL_SRC_FILES := deps/Android/Vorbis/${NDK_TOOLCHAIN_VERSION}/$(APP_ABI)/libvorbis.a
LOCAL_SRC_FILES := deps/Android/Vorbis/clang/$(APP_ABI)/libvorbis.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)

View File

@ -1,34 +1,30 @@
APP_PLATFORM := ${APP_PLATFORM}
APP_ABI := ${TARGET_ABI}
APP_STL := c++_static
NDK_TOOLCHAIN_VERSION := clang
APP_SHORT_COMMANDS := true
APP_MODULES := MultiCraft
APP_CPPFLAGS := -Ofast -fvisibility=hidden -Wno-extra-tokens
APP_CFLAGS := -Ofast -fvisibility=hidden -Wno-extra-tokens
#ifeq ($(APP_ABI),x86)
#APP_CPPFLAGS += -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -funroll-loops
#APP_CFLAGS += -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -funroll-loops
#endif
ifndef NDEBUG
APP_CPPFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer
ifdef NDEBUG
APP_CFLAGS += -D__FILE__=__FILE_NAME__ -Wno-builtin-macro-redefined
else
APP_CPPFLAGS += -D__FILE__=__FILE_NAME__ -Wno-builtin-macro-redefined
APP_CFLAGS := -g -D_DEBUG -O0 -fno-omit-frame-pointer
endif
APP_CPPFLAGS += -fexceptions #-Werror=shorten-64-to-32
APP_CFLAGS += -fexceptions
APP_CXXFLAGS := $(APP_CFLAGS) -frtti -std=gnu++17 #-Werror=shorten-64-to-32
# Silence Irrlicht warnings. Comment out with real debugging!
APP_CPPFLAGS += -Wno-deprecated-declarations -Wno-inconsistent-missing-override
APP_CXXFLAGS += -Wno-deprecated-declarations -Wno-inconsistent-missing-override
APP_CFLAGS := $(APP_CPPFLAGS)
APP_CXXFLAGS := $(APP_CPPFLAGS) -frtti -std=gnu++17
APP_CPPFLAGS := $(APP_CXXFLAGS)
ifdef NDEBUG
APP_LDFLAGS := -Wl,--gc-sections,--icf=all
else
APP_LDFLAGS :=
APP_LDFLAGS := -Wl,--gc-sections,--icf=all
endif
APP_LDFLAGS += -fuse-ld=lld

View File

@ -1 +1 @@
<manifest package="com.multicraft" />
<manifest />