Skip to content

Commit

Permalink
feat(feature_custom_rpc): add Share Config Option
Browse files Browse the repository at this point in the history
add new strinngs
  • Loading branch information
dead8309 committed Aug 4, 2023
1 parent ffea387 commit 6d1ae46
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 1 deletion.
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-fil/strings.xml
Expand Up @@ -88,4 +88,5 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>
</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-fr/strings.xml
Expand Up @@ -88,4 +88,5 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>
</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-hr/strings.xml
Expand Up @@ -89,4 +89,5 @@
<string name="set_previous_run_config_in_custom_rpc">Postavite zadnju konfiguraciju za pokretanje u polja prilagođenog Rpc-a</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatski postavite polja u prilagođenom rpc-u iz posljednjeg rpc-a</string>
<string name="clear_all_fields">Očisti sva polja</string>
<string name="share_config">Share Config</string>
</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-in/strings.xml
Expand Up @@ -88,6 +88,7 @@
<string name="set_previous_run_config_in_custom_rpc">Setel ke Konfigurasi yang Dijalankan Sebelumnya ke Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Otomatis setel fields ke Kustom rpc dari rpc yang di Jalakan sebelunya</string>
<string name="clear_all_fields">Bersihkan Semua Fields</string>
<string name="share_config">Share Config</string>


</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-it/strings.xml
Expand Up @@ -88,4 +88,5 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>
</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-mm/strings.xml
Expand Up @@ -88,4 +88,5 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>
</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-nl/strings.xml
Expand Up @@ -88,6 +88,7 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>


</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-pl/strings.xml
Expand Up @@ -88,5 +88,6 @@
<string name="set_previous_run_config_in_custom_rpc">Ustaw poprzednio uruchomioną konfigurację do pól własnego RPC</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatycznie wypełnij pola w własnym rpc z ostatnio uruchomionego rpc</string>
<string name="clear_all_fields">Wyczyść wszystkie pola</string>
<string name="share_config">Share Config</string>

</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-pt/strings.xml
Expand Up @@ -88,5 +88,6 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>

</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-ru/strings.xml
Expand Up @@ -88,4 +88,5 @@
<string name="set_previous_run_config_in_custom_rpc">Установить конфигурацию предыдущего запуска в поля Custom RPC</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Автоматически установить поля в Custom RPC из последнего запуска RPC</string>
<string name="clear_all_fields">Очистить все поля</string>
<string name="share_config">Share Config</string>
</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-tr/strings.xml
Expand Up @@ -88,5 +88,6 @@
<string name="set_previous_run_config_in_custom_rpc">Özel RPC Alanlarında önceki RPC\'de çalıştırılan yapılandırmayı kullan</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Özel RPC\'deki ayarları son çalıştırılan RPC\'den uygula</string>
<string name="clear_all_fields">Tüm Alanları Temizle</string>
<string name="share_config">Share Config</string>

</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-vi/strings.xml
Expand Up @@ -88,4 +88,5 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>
</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values-zh/strings.xml
Expand Up @@ -88,6 +88,7 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>


</resources>
1 change: 1 addition & 0 deletions common/resources/src/main/res/values/strings.xml
Expand Up @@ -89,4 +89,5 @@
<string name="set_previous_run_config_in_custom_rpc">Set Previous Run config to Custom Rpc Fields</string>
<string name="set_previous_run_config_in_custom_rpc_desc">Automatically set fields in custom rpc from the last run rpc</string>
<string name="clear_all_fields">Clear All Fields</string>
<string name="share_config">Share Config</string>
</resources>
Expand Up @@ -40,6 +40,7 @@ import com.my.kizzy.feature_custom_rpc.components.sheet.LoadConfig
import com.my.kizzy.feature_custom_rpc.components.sheet.PreviewDialog
import com.my.kizzy.feature_custom_rpc.components.sheet.RequestStoragePermissionDialog
import com.my.kizzy.feature_custom_rpc.components.sheet.SaveConfigDialog
import com.my.kizzy.feature_custom_rpc.components.sheet.ShareConfig
import com.my.kizzy.feature_custom_rpc.components.sheet.dataToString
import com.my.kizzy.feature_rpc_base.AppUtils
import com.my.kizzy.feature_rpc_base.services.AppDetectionService
Expand All @@ -54,7 +55,6 @@ import com.my.kizzy.ui.components.SwitchBar
import kotlinx.coroutines.launch
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import java.util.*

@Composable
fun CustomRPC(
Expand Down Expand Up @@ -85,6 +85,13 @@ fun CustomRPC(
}
)
}
if (state.showShareDialog) {
ShareConfig(
onDismiss = {
onEvent(UiEvent.SheetEvent.TriggerShareDialog)
}
)
}
if (state.showStoragePermissionRequestDialog) {
RequestStoragePermissionDialog(
onDismiss = { onEvent(UiEvent.SheetEvent.TriggerStoragePermissionRequest) }
Expand Down
Expand Up @@ -121,6 +121,13 @@ class CustomScreenViewModel @Inject constructor(
)
}

UiEvent.SheetEvent.TriggerShareDialog -> {
_uiState.value = _uiState.value.copy(
showShareDialog = !_uiState.value.showShareDialog,
showBottomSheet = false
)
}

UiEvent.SheetEvent.TriggerPreviewDialog -> {
_uiState.value = _uiState.value.copy(
showPreviewDialog = !_uiState.value.showPreviewDialog,
Expand Down
Expand Up @@ -25,6 +25,7 @@ sealed interface UiEvent {

sealed interface SheetEvent: UiEvent {
object TriggerLoadDialog: SheetEvent
object TriggerShareDialog: SheetEvent
object TriggerSaveDialog: SheetEvent
object TriggerDeleteDialog: SheetEvent
object TriggerPreviewDialog: SheetEvent
Expand Down
Expand Up @@ -18,6 +18,7 @@ data class UiState(
val activityTypeIsExpanded: Boolean = false,
val showBottomSheet: Boolean = false,
val showLoadDialog: Boolean = false,
val showShareDialog: Boolean = false,
val showSaveDialog: Boolean = false,
val showDeleteDialog: Boolean = false,
val showPreviewDialog: Boolean = false,
Expand Down
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.material.icons.outlined.ClearAll
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.FileOpen
import androidx.compose.material.icons.outlined.SaveAs
import androidx.compose.material.icons.outlined.Share
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.rememberModalBottomSheetState
Expand Down Expand Up @@ -102,6 +103,17 @@ fun BottomSheet(onEvent: (UiEvent.SheetEvent) -> Unit,onDismiss: () -> Unit) {
},
icon = Icons.Outlined.ClearAll
)

SheetItem(
title = stringResource(id = R.string.share_config),
icon = Icons.Outlined.Share,
onClick = {
scope.launch {
state.hide()
onEvent(UiEvent.SheetEvent.TriggerShareDialog)
}
}
)
}
}
}
Expand Down
@@ -0,0 +1,51 @@
/*
*
* ******************************************************************
* * * Copyright (C) 2022
* * * LoadConfigDialog.kt is part of Kizzy
* * * and can not be copied and/or distributed without the express
* * * permission of yzziK(Vaibhav)
* * *****************************************************************
*
*
*/

package com.my.kizzy.feature_custom_rpc.components.sheet

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.my.kizzy.data.utils.shareFile
import com.my.kizzy.resources.R
import com.my.kizzy.ui.components.dialog.SingleChoiceItem
import java.io.File

@Composable
fun ShareConfig(
onDismiss: () -> Unit
) {
val ctx = LocalContext.current
val dir = ctx.dir()
dir.mkdirs()
AlertDialog(onDismissRequest = { onDismiss() },
confirmButton = {},
title = { Text(text = stringResource(id = R.string.select_a_config)) }, text = {
LazyColumn {
val files = dir.list(FILE_FILTER)?.asList()
files?.forEach { file ->
item {
SingleChoiceItem(
text = file.dropLast(5),
selected = false
) {
onDismiss()
ctx.shareFile(File(dir,file))
}
}
}
}
})
}

0 comments on commit 6d1ae46

Please sign in to comment.