Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #993: Add blocked and enabled status in the app header #1046

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
Expand All @@ -47,7 +46,6 @@ import com.merxury.blocker.core.designsystem.theme.BlockerTheme
import com.merxury.blocker.core.domain.model.MatchedHeaderData
import com.merxury.blocker.core.domain.model.MatchedItem
import com.merxury.blocker.core.model.data.ComponentInfo
import com.merxury.blocker.core.ui.R.plurals
import com.merxury.blocker.core.ui.R.string
import com.merxury.blocker.core.ui.previewparameter.ComponentListPreviewParameterProvider

Expand Down Expand Up @@ -113,7 +111,12 @@ fun CollapsibleItem(
Spacer(modifier = Modifier.width(16.dp))
MatchedAppInfo(
label = matchedItem.header.title,
matchedComponentCount = matchedItem.componentList.size,
blockedCount = matchedItem.componentList
.filterNot { it.enabled() }
.size,
enabledCount = matchedItem.componentList
.filter { it.enabled() }
.size,
modifier = Modifier.fillMaxWidth(0.8f),
)
Spacer(modifier = Modifier.weight(1f))
Expand All @@ -128,18 +131,20 @@ fun CollapsibleItem(
@Composable
private fun MatchedAppInfo(
label: String,
matchedComponentCount: Int,
blockedCount: Int,
enabledCount: Int,
modifier: Modifier = Modifier,
) {
Column(modifier) {
BlockerBodyLargeText(
text = label,
)
BlockerBodyMediumText(
text = pluralStringResource(
id = plurals.core_ui_matched_component,
matchedComponentCount,
matchedComponentCount,
text = stringResource(
id = string.core_ui_matched,
blockedCount + enabledCount,
blockedCount,
enabledCount,
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.merxury.blocker.core.ui.collapseList

import androidx.annotation.StringRes
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.Orientation.Vertical
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
Expand Down Expand Up @@ -58,7 +57,6 @@ import com.merxury.blocker.core.ui.R.string
import com.merxury.blocker.core.ui.component.ComponentListItem
import timber.log.Timber

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun CollapsibleList(
list: List<MatchedItem>,
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
<string name="core_ui_found">موجود</string>
<string name="core_ui_not_found">ليس موجودا</string>
<string name="core_ui_do_you_want_to_uninstall_this_app">هل تريد إلغاء تثبيت هذا التطبيق؟</string>
<string name="core_ui_matched">%1$d مطابق، %2$d محظور، %3$d مفعّل.</string>
</resources>
6 changes: 1 addition & 5 deletions core/ui/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
<string name="core_ui_launch_activity">Iniciar actividad</string>
<string name="core_ui_stop_service">Detener el servicio</string>
<string name="core_ui_no_components">Sin componentes</string>
<plurals name="core_ui_matched_component">
<item quantity="one">%1$d componente coincidente</item>
<item quantity="many">%1$d componentes coincidentes</item>
<item quantity="other">%1$d componentes coincidentes</item>
</plurals>
<string name="core_ui_matched">%1$d coinciden, %2$d bloqueados, %3$d habilitados.</string>
<plurals name="core_ui_matched_apps">
<item quantity="one">%1$d aplicación coincidente</item>
<item quantity="many">%1$d aplicaciones coincidentes</item>
Expand Down
6 changes: 1 addition & 5 deletions core/ui/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@
<string name="core_ui_launch_activity">Lancer l\'activité</string>
<string name="core_ui_stop_service">Arrêter le service</string>
<string name="core_ui_no_components">Pas de composants</string>
<plurals name="core_ui_matched_component">
<item quantity="one">%1$d composant correspondant</item>
<item quantity="other">%1$d composants correspondants</item>
<item quantity="many">%1$d composants correspondants</item>
</plurals>
<string name="core_ui_matched">%1$d correspond, %2$d bloqués, %3$d activés.</string>
<plurals name="core_ui_matched_apps">
<item quantity="one">%1$d application correspondante</item>
<item quantity="other">%1$d applications correspondantes</item>
Expand Down
4 changes: 1 addition & 3 deletions core/ui/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
<string name="core_ui_copy_full_name">Salin nama lengkap</string>
<string name="core_ui_launch_activity">Akses aktivitas</string>
<string name="core_ui_stop_service">Stop layanan</string>
<plurals name="core_ui_matched_component">
<item quantity="other">%1$d komponen cocok</item>
</plurals>
<string name="core_ui_matched">%1$d cocok, %2$d diblokir, %3$d diaktifkan.</string>
<plurals name="core_ui_matched_apps">
<item quantity="other">%1$d apl cocok</item>
</plurals>
Expand Down
7 changes: 1 addition & 6 deletions core/ui/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@
<string name="core_ui_block_selected">Отключить выбранное</string>
<string name="core_ui_select_all">Выбрать все</string>
<string name="core_ui_enable_selected">Включить выбранное</string>
<plurals name="core_ui_matched_component" tools:ignore="MissingQuantity">
<item quantity="one">Обнаружен %1$d компонент</item>
<item quantity="few">Обнаружено %1$d компонента</item>
<item quantity="many">Обнаружено %1$d компонентов</item>
<item quantity="other">Обнаружено %1$d компонентов</item>
</plurals>
<string name="core_ui_matched">%1$d совпадает, %2$d заблокировано, %3$d включено.</string>
<plurals name="core_ui_matched_apps">
<item quantity="one">Обнаружено в %1$d пр.</item>
<item quantity="few">Обнаружено в %1$d пр.</item>
Expand Down
4 changes: 1 addition & 3 deletions core/ui/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
<string name="core_ui_launch_activity">启动活动</string>
<string name="core_ui_stop_service">停止服务</string>
<string name="core_ui_no_components">无组件</string>
<plurals name="core_ui_matched_component">
<item quantity="other">%1$d 个组件</item>
</plurals>
<string name="core_ui_matched">%1$d 匹配,%2$d 阻止,%3$d 启用。</string>
<plurals name="core_ui_matched_apps">
<item quantity="other">匹配 %1$d 个应用</item>
</plurals>
Expand Down
4 changes: 1 addition & 3 deletions core/ui/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
<string name="core_ui_block_selected">禁用選中</string>
<string name="core_ui_select_all">全選</string>
<string name="core_ui_enable_selected">啟用選中</string>
<plurals name="core_ui_matched_component">
<item quantity="other">%1$d個組件</item>
</plurals>
<string name="core_ui_matched">%1$d 匹配,%2$d 阻擋,%3$d 啟用。</string>
<plurals name="core_ui_matched_apps">
<item quantity="other">匹配%1$d個應用</item>
</plurals>
Expand Down
5 changes: 1 addition & 4 deletions core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
<string name="core_ui_launch_activity">Launch activity</string>
<string name="core_ui_stop_service">Stop service</string>
<string name="core_ui_no_components">No components</string>
<plurals name="core_ui_matched_component">
<item quantity="one">%1$d matched component</item>
<item quantity="other">%1$d matched components</item>
</plurals>
<string name="core_ui_matched">%1$d matched, %2$d blocked, %3$d enabled.</string>
Dismissed Show dismissed Hide dismissed
<plurals name="core_ui_matched_apps">
<item quantity="one">%1$d matched app</item>
<item quantity="other">%1$d matched apps</item>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ class AppDetailViewModel @Inject constructor(
@VisibleForTesting
fun loadTabInfo() = viewModelScope.launch {
val screen = AppDetailTabs.fromName(appDetailArgs.tabs)
if (screen == null) {
Timber.e("Cannot find tab: ${appDetailArgs.tabs}")
return@launch
}
Timber.v("Jump to tab: $screen")
_tabState.update { it.copy(selectedItem = screen) }
_appBarUiState.update {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified feature/ruledetail/src/test/screenshots/RuleDetailScreen_phone.png
Binary file modified feature/ruledetail/src/test/screenshots/RuleDetailScreen_tablet.png