Skip to content

Commit

Permalink
encode custom list name
Browse files Browse the repository at this point in the history
  • Loading branch information
bmx666 committed Sep 28, 2024
1 parent fda2356 commit 6013520
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.github.bmx666.appcachecleaner.ui.viewmodel.FirstBootViewModel
import com.github.bmx666.appcachecleaner.ui.viewmodel.LocaleViewModel
import com.github.bmx666.appcachecleaner.ui.viewmodel.SettingsUiViewModel
import com.github.bmx666.appcachecleaner.util.LocalBroadcastManagerActivityHelper
import com.github.bmx666.appcachecleaner.util.decode

@Composable
fun AppScreen(
Expand Down Expand Up @@ -79,7 +80,7 @@ fun AppScreen(
),
) { backStackEntry ->
val action = backStackEntry.arguments?.getString("action")
val name = backStackEntry.arguments?.getString("name")
val name = backStackEntry.arguments?.getString("name")?.decode()
PackageListScreen(
navController = navController,
localBroadcastManager = localBroadcastManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import com.github.bmx666.appcachecleaner.ui.viewmodel.PermissionViewModel
import com.github.bmx666.appcachecleaner.ui.viewmodel.SettingsCustomPackageListViewModel
import com.github.bmx666.appcachecleaner.ui.viewmodel.SettingsExtraViewModel
import com.github.bmx666.appcachecleaner.util.LocalBroadcastManagerActivityHelper
import com.github.bmx666.appcachecleaner.util.encode
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.distinctUntilChanged
Expand Down Expand Up @@ -144,7 +145,7 @@ fun HomeScreen(
val root = Constant.Navigation.PACKAGE_LIST
val action = Constant.PackageListAction.CUSTOM_LIST_FILTER
navController.navigate(
route = "$root/$action?name=$selectedCustomListName"
route = "$root/$action?name=${selectedCustomListName.encode()}"
)
} else {
val pkgList = list.toMutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.bmx666.appcachecleaner.ui.compose.view.SettingsCustomListEdit
import com.github.bmx666.appcachecleaner.ui.compose.view.SettingsCustomListRemove
import com.github.bmx666.appcachecleaner.ui.compose.view.SettingsGroup
import com.github.bmx666.appcachecleaner.ui.viewmodel.SettingsCustomPackageListViewModel
import com.github.bmx666.appcachecleaner.util.encode

@Composable
internal fun SettingsScreenCustomPackageList(navController: NavController) {
Expand All @@ -45,7 +46,7 @@ internal fun SettingsScreenCustomPackageList(navController: NavController) {
val root = Constant.Navigation.PACKAGE_LIST
val action = Constant.PackageListAction.CUSTOM_LIST_ADD
navController.navigate(
route = "$root/$action?name=$name"
route = "$root/$action?name=${name.encode()}"
)
},
)
Expand All @@ -63,7 +64,7 @@ internal fun SettingsScreenCustomPackageList(navController: NavController) {
val root = Constant.Navigation.PACKAGE_LIST
val action = Constant.PackageListAction.CUSTOM_LIST_EDIT
navController.navigate(
route = "$root/$action?name=$name"
route = "$root/$action?name=${name.encode()}"
)
},
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.bmx666.appcachecleaner.util

import java.net.URLDecoder
import java.net.URLEncoder
import java.nio.charset.StandardCharsets

fun String.encode(): String {
return URLEncoder.encode(this, StandardCharsets.UTF_8.toString())
}

fun String.decode(): String {
return URLDecoder.decode(this, StandardCharsets.UTF_8.toString())
}

0 comments on commit 6013520

Please sign in to comment.