FilePicker and basic zip handling
This commit is contained in:
parent
783a700f04
commit
ea08a1317a
6 changed files with 59 additions and 11 deletions
|
|
@ -29,11 +29,8 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
}
|
|
||||||
kotlinOptions {
|
|
||||||
jvmTarget = "11"
|
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
compose = true
|
compose = true
|
||||||
|
|
@ -51,6 +48,8 @@ dependencies {
|
||||||
|
|
||||||
ksp("androidx.room:room-compiler:$room_version")
|
ksp("androidx.room:room-compiler:$room_version")
|
||||||
|
|
||||||
|
implementation("io.github.chochanaresh:filepicker:0.6.0")
|
||||||
|
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||||
implementation(libs.androidx.activity.compose)
|
implementation(libs.androidx.activity.compose)
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@ fun Main(vm: TileViewModel = viewModel()) {
|
||||||
Box(modifier = Modifier.safeDrawingPadding()
|
Box(modifier = Modifier.safeDrawingPadding()
|
||||||
.align(Alignment.CenterEnd)
|
.align(Alignment.CenterEnd)
|
||||||
.rotate(-90F)
|
.rotate(-90F)
|
||||||
.size(240.dp, 40.dp)
|
.size(200.dp, 40.dp)
|
||||||
.offset(0.dp, 80.dp)
|
.offset(0.dp, 60.dp)
|
||||||
) {
|
) {
|
||||||
Slider(
|
Slider(
|
||||||
value = sliderValue.floatValue,
|
value = sliderValue.floatValue,
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,66 @@
|
||||||
package com.mirenkov.ktheightmap
|
package com.mirenkov.ktheightmap
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import com.mirenkov.ktheightmap.ui.theme.KtHeightMapTheme
|
import com.mirenkov.ktheightmap.ui.theme.KtHeightMapTheme
|
||||||
|
import com.nareshchocha.filepickerlibrary.FilePickerResultContracts
|
||||||
|
import com.nareshchocha.filepickerlibrary.models.PickerData
|
||||||
|
import com.nareshchocha.filepickerlibrary.models.PopUpConfig
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
|
||||||
class SettingsActivity : ComponentActivity() {
|
class SettingsActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
val launcher = registerForActivityResult(FilePickerResultContracts.PickDocumentFile()) { result ->
|
||||||
|
if (result.errorMessage != null) {
|
||||||
|
Log.e("Picker", result.errorMessage ?: "")
|
||||||
|
} else {
|
||||||
|
val filePath = result.selectedFilePath
|
||||||
|
filePath?.let {
|
||||||
|
if (!it.endsWith(".zip"))
|
||||||
|
return@let
|
||||||
|
ZipInputStream(FileInputStream(it)).use { zipInputStream ->
|
||||||
|
var entry = zipInputStream.nextEntry
|
||||||
|
while (entry != null) {
|
||||||
|
with(entry.name) {
|
||||||
|
if (count { it == '/' } == 4 && endsWith(".jpg"))
|
||||||
|
processEntry(entry)
|
||||||
|
}
|
||||||
|
entry = zipInputStream.nextEntry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
setContent {
|
setContent {
|
||||||
KtHeightMapTheme {
|
KtHeightMapTheme {
|
||||||
|
Column(Modifier.fillMaxSize()
|
||||||
|
.safeDrawingPadding()) {
|
||||||
|
Button(onClick = {
|
||||||
|
launcher.launch(null)
|
||||||
|
}) { Text(text = "Load database") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun processEntry(entry: ZipEntry) {
|
||||||
|
Log.i(TAG, entry.name)
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application) apply false
|
alias(libs.plugins.android.application) apply false
|
||||||
alias(libs.plugins.kotlin.android) apply false
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
alias(libs.plugins.kotlin.compose) apply false
|
alias(libs.plugins.kotlin.compose) apply false
|
||||||
id("com.google.devtools.ksp") version "2.0.21-1.0.27" apply false
|
id("com.google.devtools.ksp") version "2.2.0-2.0.2" apply false
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[versions]
|
[versions]
|
||||||
agp = "8.10.1"
|
agp = "8.12.0"
|
||||||
kotlin = "2.0.21"
|
kotlin = "2.2.0"
|
||||||
coreKtx = "1.16.0"
|
coreKtx = "1.16.0"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.2.1"
|
junitVersion = "1.2.1"
|
||||||
|
|
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
#Thu Jul 24 13:19:06 MSK 2025
|
#Thu Jul 24 13:19:06 MSK 2025
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue