Updated gradle, added ru translation
This commit is contained in:
parent
9ceb3787c2
commit
996f71258e
11 changed files with 309 additions and 163 deletions
|
|
@ -42,6 +42,7 @@ import androidx.compose.ui.draw.rotate
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
||||
|
|
@ -139,27 +140,27 @@ fun ToolButton(viewModel: TileViewModel) {
|
|||
onDismissRequest = { expanded = false }
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text("Toggle debug") },
|
||||
text = { Text(stringResource(R.string.pop_toggle_debug)) },
|
||||
onClick = {
|
||||
debug = !debug
|
||||
expanded = false
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text("Place point") },
|
||||
text = { Text(stringResource(R.string.pop_place_point)) },
|
||||
onClick = {
|
||||
pointRequested = true
|
||||
expanded = false
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text("Set location") },
|
||||
text = { Text(stringResource(R.string.pop_set_location)) },
|
||||
onClick = {
|
||||
dialogShown.value = true
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text("Settings") },
|
||||
text = { Text(stringResource(R.string.pop_settings)) },
|
||||
onClick = {
|
||||
expanded = false
|
||||
val intent = Intent(context, SettingsActivity::class.java)
|
||||
|
|
@ -182,7 +183,7 @@ fun SetLocationDialog(vm: TileViewModel, dialogShown: MutableState<Boolean>) {
|
|||
var offsetY by remember { vm.mapOffsetY }
|
||||
AlertDialog (
|
||||
onDismissRequest = { showLocationDialog = false },
|
||||
title = { Text("Input coordinates") },
|
||||
title = { Text(stringResource(R.string.dialog_input_coords)) },
|
||||
text = {
|
||||
Column {
|
||||
TextField(
|
||||
|
|
@ -190,7 +191,7 @@ fun SetLocationDialog(vm: TileViewModel, dialogShown: MutableState<Boolean>) {
|
|||
onValueChange = { newValue ->
|
||||
latitudeText = newValue
|
||||
},
|
||||
label = { Text("Latitude") },
|
||||
label = { Text(stringResource(R.string.lat)) },
|
||||
placeholder = { Text("60.086763") },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
|
||||
)
|
||||
|
|
@ -199,7 +200,7 @@ fun SetLocationDialog(vm: TileViewModel, dialogShown: MutableState<Boolean>) {
|
|||
onValueChange = { newValue ->
|
||||
longitudeText = newValue
|
||||
},
|
||||
label = { Text("Longitude") },
|
||||
label = { Text(stringResource(R.string.lon)) },
|
||||
placeholder = { Text("30.014658") },
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
|
||||
)
|
||||
|
|
@ -211,11 +212,11 @@ fun SetLocationDialog(vm: TileViewModel, dialogShown: MutableState<Boolean>) {
|
|||
offsetX = SphereMercator.mercateLon(longitude, vm.scale.floatValue.toInt(), -vm.halvedOffsetX!!.toDouble() - TILE_SIZE).toFloat()
|
||||
offsetY = SphereMercator.mercateLat(latitude, vm.scale.floatValue.toInt(), -vm.halvedOffsetY!!.toDouble() - TILE_SIZE).toFloat()
|
||||
}) {
|
||||
Text("Confirm".uppercase())
|
||||
Text(stringResource(R.string.confirm).uppercase())
|
||||
} },
|
||||
dismissButton = { TextButton(onClick = { showLocationDialog = false }) {
|
||||
Text("Cancel".uppercase())
|
||||
Text(stringResource(R.string.cancel).uppercase())
|
||||
} }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import androidx.compose.ui.text.font.FontWeight
|
|||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.mirenkov.ktheightmap.Global.Companion.fileIsValidZip
|
||||
|
|
@ -86,26 +87,26 @@ fun SettingsMain(vm: TileViewModel, launcher: ActivityResultLauncher<DocumentFil
|
|||
var enableClearTiles by remember { mutableStateOf(vm.repository.containsTiles()) }
|
||||
var enableClearHeight by remember { mutableStateOf(KhmParser.fileExists(ctx)) }
|
||||
|
||||
val loadToast = Toast.makeText(ctx, "File successfully loaded.", Toast.LENGTH_LONG)
|
||||
val clearTilesToast = Toast.makeText(ctx, "Tiles removed from database.", Toast.LENGTH_LONG)
|
||||
val clearHeightToast = Toast.makeText(ctx, "Height data removed.", Toast.LENGTH_LONG)
|
||||
val loadToast = Toast.makeText(ctx, stringResource(R.string.toast_file_loaded), Toast.LENGTH_LONG)
|
||||
val clearTilesToast = Toast.makeText(ctx, stringResource(R.string.toast_db_cleared), Toast.LENGTH_LONG)
|
||||
val clearHeightToast = Toast.makeText(ctx, stringResource(R.string.toast_khm_cleared), Toast.LENGTH_LONG)
|
||||
|
||||
val selectedFileText = if (pathIsNotNull) filePath!!.split('/').last() else "none"
|
||||
val selectedFileText = if (pathIsNotNull) filePath!!.split('/').last() else stringResource(R.string.set_selected_none_file)
|
||||
|
||||
val fileSelectorRow = @Composable () {
|
||||
Row(Modifier.fillMaxWidth()) {
|
||||
Button({ launcher.launch(null); launcherActive = true }) { Text("Select") }
|
||||
Text("Selected file: $selectedFileText", Modifier.padding(8.dp, 0.dp).align(Alignment.CenterVertically))
|
||||
Button({ launcher.launch(null); launcherActive = true }) { Text(stringResource(R.string.select)) }
|
||||
Text(stringResource(R.string.set_selected_file_template, selectedFileText), Modifier.padding(8.dp, 0.dp).align(Alignment.CenterVertically))
|
||||
}
|
||||
}
|
||||
|
||||
KtHeightMapTheme {
|
||||
Scaffold(floatingActionButton = { if (showLoading || launcherActive) CircularProgressIndicator() }) { paddingValues ->
|
||||
Column(Modifier.padding(paddingValues)) {
|
||||
LabeledSection("Select file:", Modifier.padding(24.dp, 8.dp)) {
|
||||
LabeledSection(stringResource(R.string.set_select_file_label), Modifier.padding(24.dp, 8.dp)) {
|
||||
fileSelectorRow()
|
||||
}
|
||||
LabeledSection("Load file as...", Modifier.padding(24.dp, 8.dp)) {
|
||||
LabeledSection(stringResource(R.string.set_load_file_label), Modifier.padding(24.dp, 8.dp)) {
|
||||
Button({ filePath?.let {
|
||||
showLoading = true
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
|
|
@ -113,7 +114,7 @@ fun SettingsMain(vm: TileViewModel, launcher: ActivityResultLauncher<DocumentFil
|
|||
enableClearTiles = true
|
||||
coroutineScope.launch(Dispatchers.Main) { loadToast.show(); showLoading = false }
|
||||
}
|
||||
} }, enabled = pathContainsSQLite) { Text("SQLite (.zip)") }
|
||||
} }, enabled = pathContainsSQLite) { Text(stringResource(R.string.set_sqlite_filetype)) }
|
||||
Button({ filePath?.let {
|
||||
showLoading = true
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
|
|
@ -121,7 +122,7 @@ fun SettingsMain(vm: TileViewModel, launcher: ActivityResultLauncher<DocumentFil
|
|||
enableClearTiles = true
|
||||
coroutineScope.launch(Dispatchers.Main) { loadToast.show(); showLoading = false }
|
||||
}
|
||||
} }, enabled = pathIsValidZip && !pathContainsSQLite) { Text("JPEG (.zip)") }
|
||||
} }, enabled = pathIsValidZip && !pathContainsSQLite) { Text(stringResource(R.string.set_jpeg_filetype)) }
|
||||
Button({ filePath?.let {
|
||||
showLoading = true
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
|
|
@ -129,20 +130,20 @@ fun SettingsMain(vm: TileViewModel, launcher: ActivityResultLauncher<DocumentFil
|
|||
enableClearHeight = true
|
||||
coroutineScope.launch(Dispatchers.Main) { loadToast.show(); showLoading = false }
|
||||
}
|
||||
} }, enabled = pathIsValidKhm) { Text("Height data (.khm)") }
|
||||
} }, enabled = pathIsValidKhm) { Text(stringResource(R.string.set_khm_filetype)) }
|
||||
}
|
||||
LabeledSection("Clear...", Modifier.padding(24.dp, 8.dp)) {
|
||||
LabeledSection(stringResource(R.string.set_clear_label), Modifier.padding(24.dp, 8.dp)) {
|
||||
Button({ coroutineScope.launch {
|
||||
showLoading = true
|
||||
vm.repository.clearTiles()
|
||||
enableClearTiles = false
|
||||
coroutineScope.launch(Dispatchers.Main) { clearTilesToast.show(); showLoading = false }
|
||||
} }, enabled = enableClearTiles) { Text("Tile data") }
|
||||
} }, enabled = enableClearTiles) { Text(stringResource(R.string.set_clear_db)) }
|
||||
Button({
|
||||
KhmParser.clear(ctx)
|
||||
enableClearHeight = false
|
||||
clearHeightToast.show()
|
||||
}, enabled = enableClearHeight) { Text("Height data") }
|
||||
}, enabled = enableClearHeight) { Text(stringResource(R.string.set_clear_khm)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -166,4 +167,4 @@ fun LabeledSection(text: String, modifier: Modifier = Modifier, content: @Compos
|
|||
modifier = modifier.fillMaxWidth()
|
||||
) { content() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
34
app/src/main/res/values-ru/strings.xml
Normal file
34
app/src/main/res/values-ru/strings.xml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<resources>
|
||||
<string name="app_name">KtHeightMap</string>
|
||||
|
||||
<string name="confirm">Подтвердить</string>
|
||||
<string name="cancel">Отменить</string>
|
||||
<string name="select">Выбрать</string>
|
||||
|
||||
<string name="lat">Широта</string>
|
||||
<string name="lon">Долгота</string>
|
||||
|
||||
<string name="pop_toggle_debug">Вкл/выкл отладку</string>
|
||||
<string name="pop_place_point">Установить точку</string>
|
||||
<string name="pop_set_location">Установить координаты</string>
|
||||
<string name="pop_settings">Открыть настройки</string>
|
||||
|
||||
<string name="dialog_input_coords">Введите координаты</string>
|
||||
|
||||
<string name="toast_file_loaded">Файл успешно загружен.</string>
|
||||
<string name="toast_db_cleared">Тайлы удалены из базы данных.</string>
|
||||
<string name="toast_khm_cleared">Высотные данные удалены.</string>
|
||||
|
||||
<string name="set_select_file_label">Выбрать файл:</string>
|
||||
<string name="set_load_file_label">Загрузить как...</string>
|
||||
<string name="set_clear_label">Удалить...</string>
|
||||
|
||||
<string name="set_selected_file_template">Выбранный файл: %1$s</string>
|
||||
<string name="set_selected_none_file">пусто</string>
|
||||
<string name="set_sqlite_filetype">SQLite (.zip)</string>
|
||||
<string name="set_jpeg_filetype">JPEG (.zip)</string>
|
||||
<string name="set_khm_filetype">Высотные данные (.khm)</string>
|
||||
|
||||
<string name="set_clear_db">Тайлы</string>
|
||||
<string name="set_clear_khm">Высотные данные</string>
|
||||
</resources>
|
||||
|
|
@ -1,3 +1,34 @@
|
|||
<resources>
|
||||
<string name="app_name">KtHeightMap</string>
|
||||
</resources>
|
||||
|
||||
<string name="confirm">Confirm</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="select">Select</string>
|
||||
|
||||
<string name="lat">Latitude</string>
|
||||
<string name="lon">Longitude</string>
|
||||
|
||||
<string name="pop_toggle_debug">Toggle debug</string>
|
||||
<string name="pop_place_point">Place point</string>
|
||||
<string name="pop_set_location">Set location</string>
|
||||
<string name="pop_settings">Open settings</string>
|
||||
|
||||
<string name="dialog_input_coords">Input coordinates</string>
|
||||
|
||||
<string name="toast_file_loaded">File successfully loaded.</string>
|
||||
<string name="toast_db_cleared">Tiles removed from database.</string>
|
||||
<string name="toast_khm_cleared">Height data removed.</string>
|
||||
|
||||
<string name="set_select_file_label">Select file:</string>
|
||||
<string name="set_load_file_label">Load file as...</string>
|
||||
<string name="set_clear_label">Clear...</string>
|
||||
|
||||
<string name="set_selected_file_template">Selected file: %1$s</string>
|
||||
<string name="set_selected_none_file">none</string>
|
||||
<string name="set_sqlite_filetype">SQLite (.zip)</string>
|
||||
<string name="set_jpeg_filetype">JPEG (.zip)</string>
|
||||
<string name="set_khm_filetype">Height data (.khm)</string>
|
||||
|
||||
<string name="set_clear_db">Tile data</string>
|
||||
<string name="set_clear_khm">Height data</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue