Second Activity and bitmap
This commit is contained in:
parent
76729430ec
commit
1f22b5c8c8
7 changed files with 66 additions and 6 deletions
|
|
@ -11,7 +11,7 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.mirenkov.ktheightmap"
|
applicationId = "com.mirenkov.ktheightmap"
|
||||||
minSdk = 24
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0"
|
versionName = "1.0"
|
||||||
|
|
@ -44,6 +44,9 @@ dependencies {
|
||||||
implementation(libs.androidx.room.common.jvm)
|
implementation(libs.androidx.room.common.jvm)
|
||||||
implementation(libs.androidx.room.runtime.android)
|
implementation(libs.androidx.room.runtime.android)
|
||||||
implementation(libs.androidx.lifecycle.viewmodel.compose.android)
|
implementation(libs.androidx.lifecycle.viewmodel.compose.android)
|
||||||
|
implementation(libs.androidx.appcompat)
|
||||||
|
implementation(libs.material)
|
||||||
|
implementation(libs.androidx.activity)
|
||||||
val room_version = "2.7.2"
|
val room_version = "2.7.2"
|
||||||
|
|
||||||
ksp("androidx.room:room-compiler:$room_version")
|
ksp("androidx.room:room-compiler:$room_version")
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.KtHeightMap"
|
android:theme="@style/Theme.KtHeightMap"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".SettingsActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|
|
||||||
12
app/src/main/java/com/mirenkov/ktheightmap/Config.kt
Normal file
12
app/src/main/java/com/mirenkov/ktheightmap/Config.kt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.mirenkov.ktheightmap
|
||||||
|
|
||||||
|
class Config {
|
||||||
|
companion object {
|
||||||
|
private var INSTANCE: Config = Config()
|
||||||
|
fun getInstance(): Config {
|
||||||
|
synchronized(this) {
|
||||||
|
return INSTANCE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.mirenkov.ktheightmap
|
package com.mirenkov.ktheightmap
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
|
|
@ -80,9 +81,11 @@ fun Main(vm: TileViewModel = viewModel()) {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ToolButton() {
|
fun ToolButton() {
|
||||||
|
val context = LocalContext.current
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
Log.i(TAG, "Hello, gryadki!")
|
val intent = Intent(context, SettingsActivity::class.java)
|
||||||
|
context.startActivity(intent)
|
||||||
}
|
}
|
||||||
) { Icon(Icons.Filled.Build, contentDescription = "Tools") }
|
) { Icon(Icons.Filled.Build, contentDescription = "Tools") }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.mirenkov.ktheightmap
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import com.mirenkov.ktheightmap.ui.theme.KtHeightMapTheme
|
||||||
|
|
||||||
|
class SettingsActivity : ComponentActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContent {
|
||||||
|
KtHeightMapTheme {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.mirenkov.ktheightmap
|
package com.mirenkov.ktheightmap
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import java.util.Base64
|
||||||
|
|
||||||
@Entity(tableName = "tiles", primaryKeys = [ "x", "y", "level" ])
|
@Entity(tableName = "tiles", primaryKeys = [ "x", "y", "level" ])
|
||||||
class Tile {
|
class Tile {
|
||||||
|
|
@ -18,13 +20,26 @@ class Tile {
|
||||||
@ColumnInfo(name = "data")
|
@ColumnInfo(name = "data")
|
||||||
var base64: String? = null
|
var base64: String? = null
|
||||||
|
|
||||||
|
constructor()
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
constructor(x: Int, y: Int, level: Int) {
|
constructor(x: Int, y: Int, level: Int) {
|
||||||
this.x = x
|
this.x = x
|
||||||
this.y = y
|
this.y = y
|
||||||
this.level = level
|
this.level = level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(x: Int, y: Int, level: Int, base64: String) {
|
||||||
|
this.x = x
|
||||||
|
this.y = y
|
||||||
|
this.level = level
|
||||||
|
this.base64 = base64
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBitmap(): Bitmap? {
|
||||||
|
if (this.base64 == null)
|
||||||
|
return null
|
||||||
|
val ba = Base64.getDecoder().decode(this.base64)
|
||||||
|
val bmp = BitmapFactory.decodeByteArray(ba, 0, ba.size)
|
||||||
|
return bmp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,6 +11,9 @@ composeBom = "2024.09.00"
|
||||||
roomCommonJvm = "2.7.2"
|
roomCommonJvm = "2.7.2"
|
||||||
roomRuntimeAndroid = "2.7.2"
|
roomRuntimeAndroid = "2.7.2"
|
||||||
lifecycleViewmodelComposeAndroid = "2.9.2"
|
lifecycleViewmodelComposeAndroid = "2.9.2"
|
||||||
|
appcompat = "1.6.1"
|
||||||
|
material = "1.10.0"
|
||||||
|
activity = "1.10.1"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
|
|
@ -30,6 +33,9 @@ androidx-material3 = { group = "androidx.compose.material3", name = "material3"
|
||||||
androidx-room-common-jvm = { group = "androidx.room", name = "room-common-jvm", version.ref = "roomCommonJvm" }
|
androidx-room-common-jvm = { group = "androidx.room", name = "room-common-jvm", version.ref = "roomCommonJvm" }
|
||||||
androidx-room-runtime-android = { group = "androidx.room", name = "room-runtime-android", version.ref = "roomRuntimeAndroid" }
|
androidx-room-runtime-android = { group = "androidx.room", name = "room-runtime-android", version.ref = "roomRuntimeAndroid" }
|
||||||
androidx-lifecycle-viewmodel-compose-android = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose-android", version.ref = "lifecycleViewmodelComposeAndroid" }
|
androidx-lifecycle-viewmodel-compose-android = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose-android", version.ref = "lifecycleViewmodelComposeAndroid" }
|
||||||
|
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||||
|
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||||
|
androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue