Skip to content

Commit 8095a1f

Browse files
UshieoSumAtrIX
authored andcommitted
fix: Use compatible rather than support when referring to patch compatibility (#2422)
1 parent 90c7600 commit 8095a1f

File tree

5 files changed

+91
-88
lines changed

5 files changed

+91
-88
lines changed

app/src/main/java/app/revanced/manager/ui/model/BundleInfo.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,34 @@ import kotlinx.coroutines.flow.map
1212
data class BundleInfo(
1313
val name: String,
1414
val uid: Int,
15-
val supported: List<PatchInfo>,
16-
val unsupported: List<PatchInfo>,
15+
val compatible: List<PatchInfo>,
16+
val incompatible: List<PatchInfo>,
1717
val universal: List<PatchInfo>
1818
) {
1919
val all = sequence {
20-
yieldAll(supported)
21-
yieldAll(unsupported)
20+
yieldAll(compatible)
21+
yieldAll(incompatible)
2222
yieldAll(universal)
2323
}
2424

25-
val patchCount get() = supported.size + unsupported.size + universal.size
25+
val patchCount get() = compatible.size + incompatible.size + universal.size
2626

27-
fun patchSequence(allowUnsupported: Boolean) = if (allowUnsupported) {
27+
fun patchSequence(allowIncompatible: Boolean) = if (allowIncompatible) {
2828
all
2929
} else {
3030
sequence {
31-
yieldAll(supported)
31+
yieldAll(compatible)
3232
yieldAll(universal)
3333
}
3434
}
3535

3636
companion object Extensions {
3737
inline fun Iterable<BundleInfo>.toPatchSelection(
38-
allowUnsupported: Boolean,
38+
allowIncompatible: Boolean,
3939
condition: (Int, PatchInfo) -> Boolean
4040
): PatchSelection = this.associate { bundle ->
4141
val patches =
42-
bundle.patchSequence(allowUnsupported)
42+
bundle.patchSequence(allowIncompatible)
4343
.mapNotNullTo(mutableSetOf()) { patch ->
4444
patch.name.takeIf {
4545
condition(
@@ -60,8 +60,8 @@ data class BundleInfo(
6060
source.state.map { state ->
6161
val bundle = state.patchBundleOrNull() ?: return@map null
6262

63-
val supported = mutableListOf<PatchInfo>()
64-
val unsupported = mutableListOf<PatchInfo>()
63+
val compatible = mutableListOf<PatchInfo>()
64+
val incompatible = mutableListOf<PatchInfo>()
6565
val universal = mutableListOf<PatchInfo>()
6666

6767
bundle.patches.filter { it.compatibleWith(packageName) }.forEach {
@@ -70,15 +70,15 @@ data class BundleInfo(
7070
it.supports(
7171
packageName,
7272
version
73-
) -> supported
73+
) -> compatible
7474

75-
else -> unsupported
75+
else -> incompatible
7676
}
7777

7878
targetList.add(it)
7979
}
8080

81-
BundleInfo(source.getName(), source.uid, supported, unsupported, universal)
81+
BundleInfo(source.getName(), source.uid, compatible, incompatible, universal)
8282
}
8383
}
8484

app/src/main/java/app/revanced/manager/ui/screen/PatchesSelectorScreen.kt

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ import app.revanced.manager.ui.component.haptics.HapticExtendedFloatingActionBut
7676
import app.revanced.manager.ui.component.haptics.HapticTab
7777
import app.revanced.manager.ui.component.patches.OptionItem
7878
import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel
79+
import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel.Companion.SHOW_INCOMPATIBLE
7980
import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel.Companion.SHOW_UNIVERSAL
80-
import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel.Companion.SHOW_UNSUPPORTED
8181
import app.revanced.manager.util.Options
8282
import app.revanced.manager.util.PatchSelection
8383
import app.revanced.manager.util.isScrollingUp
@@ -147,9 +147,9 @@ fun PatchesSelectorScreen(
147147
verticalArrangement = Arrangement.spacedBy(12.dp)
148148
) {
149149
CheckedFilterChip(
150-
selected = vm.filter and SHOW_UNSUPPORTED == 0,
151-
onClick = { vm.toggleFlag(SHOW_UNSUPPORTED) },
152-
label = { Text(stringResource(R.string.supported)) }
150+
selected = vm.filter and SHOW_INCOMPATIBLE == 0,
151+
onClick = { vm.toggleFlag(SHOW_INCOMPATIBLE) },
152+
label = { Text(stringResource(R.string.this_version)) }
153153
)
154154

155155
CheckedFilterChip(
@@ -163,18 +163,18 @@ fun PatchesSelectorScreen(
163163
}
164164

165165
if (vm.compatibleVersions.isNotEmpty())
166-
UnsupportedPatchDialog(
166+
IncompatiblePatchDialog(
167167
appVersion = vm.appVersion ?: stringResource(R.string.any_version),
168-
supportedVersions = vm.compatibleVersions,
168+
compatibleVersions = vm.compatibleVersions,
169169
onDismissRequest = vm::dismissDialogs
170170
)
171-
var showUnsupportedPatchesDialog by rememberSaveable {
171+
var showIncompatiblePatchesDialog by rememberSaveable {
172172
mutableStateOf(false)
173173
}
174-
if (showUnsupportedPatchesDialog)
175-
UnsupportedPatchesDialog(
174+
if (showIncompatiblePatchesDialog)
175+
IncompatiblePatchesDialog(
176176
appVersion = vm.appVersion ?: stringResource(R.string.any_version),
177-
onDismissRequest = { showUnsupportedPatchesDialog = false }
177+
onDismissRequest = { showIncompatiblePatchesDialog = false }
178178
)
179179

180180
vm.optionsDialog?.let { (bundle, patch) ->
@@ -204,7 +204,7 @@ fun PatchesSelectorScreen(
204204
uid: Int,
205205
patches: List<PatchInfo>,
206206
visible: Boolean,
207-
supported: Boolean,
207+
compatible: Boolean,
208208
header: (@Composable () -> Unit)? = null
209209
) {
210210
if (patches.isNotEmpty() && visible) {
@@ -224,14 +224,14 @@ fun PatchesSelectorScreen(
224224
onOptionsDialog = {
225225
vm.optionsDialog = uid to patch
226226
},
227-
selected = supported && vm.isSelected(
227+
selected = compatible && vm.isSelected(
228228
uid,
229229
patch
230230
),
231231
onToggle = {
232232
when {
233-
// Open unsupported dialog if the patch is not supported
234-
!supported -> vm.openUnsupportedDialog(patch)
233+
// Open incompatible dialog if the patch is not supported
234+
!compatible -> vm.openIncompatibleDialog(patch)
235235

236236
// Show selection warning if enabled
237237
vm.selectionWarningEnabled -> showSelectionWarning = true
@@ -245,7 +245,7 @@ fun PatchesSelectorScreen(
245245
else -> vm.togglePatch(uid, patch)
246246
}
247247
},
248-
supported = supported
248+
compatible = compatible
249249
)
250250
}
251251
}
@@ -321,15 +321,15 @@ fun PatchesSelectorScreen(
321321

322322
patchList(
323323
uid = bundle.uid,
324-
patches = bundle.supported.searched(),
324+
patches = bundle.compatible.searched(),
325325
visible = true,
326-
supported = true
326+
compatible = true
327327
)
328328
patchList(
329329
uid = bundle.uid,
330330
patches = bundle.universal.searched(),
331331
visible = vm.filter and SHOW_UNIVERSAL != 0,
332-
supported = true
332+
compatible = true
333333
) {
334334
ListHeader(
335335
title = stringResource(R.string.universal_patches),
@@ -338,13 +338,13 @@ fun PatchesSelectorScreen(
338338

339339
patchList(
340340
uid = bundle.uid,
341-
patches = bundle.unsupported.searched(),
342-
visible = vm.filter and SHOW_UNSUPPORTED != 0,
343-
supported = vm.allowIncompatiblePatches
341+
patches = bundle.incompatible.searched(),
342+
visible = vm.filter and SHOW_INCOMPATIBLE != 0,
343+
compatible = vm.allowIncompatiblePatches
344344
) {
345345
ListHeader(
346-
title = stringResource(R.string.unsupported_patches),
347-
onHelpClick = { showUnsupportedPatchesDialog = true }
346+
title = stringResource(R.string.incompatible_patches),
347+
onHelpClick = { showIncompatiblePatchesDialog = true }
348348
)
349349
}
350350
}
@@ -427,29 +427,29 @@ fun PatchesSelectorScreen(
427427
) {
428428
patchList(
429429
uid = bundle.uid,
430-
patches = bundle.supported,
430+
patches = bundle.compatible,
431431
visible = true,
432-
supported = true
432+
compatible = true
433433
)
434434
patchList(
435435
uid = bundle.uid,
436436
patches = bundle.universal,
437437
visible = vm.filter and SHOW_UNIVERSAL != 0,
438-
supported = true
438+
compatible = true
439439
) {
440440
ListHeader(
441441
title = stringResource(R.string.universal_patches),
442442
)
443443
}
444444
patchList(
445445
uid = bundle.uid,
446-
patches = bundle.unsupported,
447-
visible = vm.filter and SHOW_UNSUPPORTED != 0,
448-
supported = vm.allowIncompatiblePatches
446+
patches = bundle.incompatible,
447+
visible = vm.filter and SHOW_INCOMPATIBLE != 0,
448+
compatible = vm.allowIncompatiblePatches
449449
) {
450450
ListHeader(
451-
title = stringResource(R.string.unsupported_patches),
452-
onHelpClick = { showUnsupportedPatchesDialog = true }
451+
title = stringResource(R.string.incompatible_patches),
452+
onHelpClick = { showIncompatiblePatchesDialog = true }
453453
)
454454
}
455455
}
@@ -506,24 +506,24 @@ private fun PatchItem(
506506
onOptionsDialog: () -> Unit,
507507
selected: Boolean,
508508
onToggle: () -> Unit,
509-
supported: Boolean = true
509+
compatible: Boolean = true
510510
) = ListItem(
511511
modifier = Modifier
512-
.let { if (!supported) it.alpha(0.5f) else it }
512+
.let { if (!compatible) it.alpha(0.5f) else it }
513513
.clickable(onClick = onToggle)
514514
.fillMaxSize(),
515515
leadingContent = {
516516
HapticCheckbox(
517517
checked = selected,
518518
onCheckedChange = { onToggle() },
519-
enabled = supported
519+
enabled = compatible
520520
)
521521
},
522522
headlineContent = { Text(patch.name) },
523523
supportingContent = patch.description?.let { { Text(it) } },
524524
trailingContent = {
525525
if (patch.options?.isNotEmpty() == true) {
526-
IconButton(onClick = onOptionsDialog, enabled = supported) {
526+
IconButton(onClick = onOptionsDialog, enabled = compatible) {
527527
Icon(Icons.Outlined.Settings, null)
528528
}
529529
}
@@ -559,7 +559,7 @@ fun ListHeader(
559559
}
560560

561561
@Composable
562-
private fun UnsupportedPatchesDialog(
562+
private fun IncompatiblePatchesDialog(
563563
appVersion: String,
564564
onDismissRequest: () -> Unit
565565
) = AlertDialog(
@@ -572,21 +572,21 @@ private fun UnsupportedPatchesDialog(
572572
Text(stringResource(R.string.ok))
573573
}
574574
},
575-
title = { Text(stringResource(R.string.unsupported_patches)) },
575+
title = { Text(stringResource(R.string.incompatible_patches)) },
576576
text = {
577577
Text(
578578
stringResource(
579-
R.string.unsupported_patches_dialog,
579+
R.string.incompatible_patches_dialog,
580580
appVersion
581581
)
582582
)
583583
}
584584
)
585585

586586
@Composable
587-
private fun UnsupportedPatchDialog(
587+
private fun IncompatiblePatchDialog(
588588
appVersion: String,
589-
supportedVersions: List<String>,
589+
compatibleVersions: List<String>,
590590
onDismissRequest: () -> Unit
591591
) = AlertDialog(
592592
icon = {
@@ -598,13 +598,13 @@ private fun UnsupportedPatchDialog(
598598
Text(stringResource(R.string.ok))
599599
}
600600
},
601-
title = { Text(stringResource(R.string.unsupported_patch)) },
601+
title = { Text(stringResource(R.string.incompatible_patch)) },
602602
text = {
603603
Text(
604604
stringResource(
605-
R.string.app_not_supported,
605+
R.string.app_version_not_compatible,
606606
appVersion,
607-
supportedVersions.joinToString(", ")
607+
compatibleVersions.joinToString(", ")
608608
)
609609
)
610610
}

app/src/main/java/app/revanced/manager/ui/viewmodel/PatchesSelectorViewModel.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package app.revanced.manager.ui.viewmodel
33
import android.app.Application
44
import androidx.compose.runtime.getValue
55
import androidx.compose.runtime.mutableIntStateOf
6-
import androidx.compose.runtime.setValue
76
import androidx.compose.runtime.mutableStateListOf
87
import androidx.compose.runtime.mutableStateMapOf
98
import androidx.compose.runtime.mutableStateOf
109
import androidx.compose.runtime.saveable.Saver
10+
import androidx.compose.runtime.setValue
1111
import androidx.compose.runtime.snapshots.SnapshotStateMap
1212
import androidx.lifecycle.SavedStateHandle
1313
import androidx.lifecycle.ViewModel
@@ -30,15 +30,20 @@ import app.revanced.manager.util.saver.persistentMapSaver
3030
import app.revanced.manager.util.saver.persistentSetSaver
3131
import app.revanced.manager.util.saver.snapshotStateMapSaver
3232
import app.revanced.manager.util.toast
33-
import kotlinx.coroutines.flow.first
34-
import kotlinx.coroutines.launch
35-
import org.koin.core.component.KoinComponent
36-
import org.koin.core.component.get
37-
import kotlinx.collections.immutable.*
33+
import kotlinx.collections.immutable.PersistentMap
34+
import kotlinx.collections.immutable.PersistentSet
35+
import kotlinx.collections.immutable.persistentMapOf
36+
import kotlinx.collections.immutable.persistentSetOf
37+
import kotlinx.collections.immutable.toPersistentMap
38+
import kotlinx.collections.immutable.toPersistentSet
3839
import kotlinx.coroutines.CoroutineStart
3940
import kotlinx.coroutines.async
41+
import kotlinx.coroutines.flow.first
4042
import kotlinx.coroutines.flow.flow
4143
import kotlinx.coroutines.flow.map
44+
import kotlinx.coroutines.launch
45+
import org.koin.core.component.KoinComponent
46+
import org.koin.core.component.get
4247

4348
@OptIn(SavedStateHandleSaveableApi::class)
4449
class PatchesSelectorViewModel(input: SelectedApplicationInfo.PatchesSelector.ViewModelParams) :
@@ -208,16 +213,16 @@ class PatchesSelectorViewModel(input: SelectedApplicationInfo.PatchesSelector.Vi
208213
compatibleVersions.clear()
209214
}
210215

211-
fun openUnsupportedDialog(unsupportedPatch: PatchInfo) {
212-
compatibleVersions.addAll(unsupportedPatch.compatiblePackages?.find { it.packageName == packageName }?.versions.orEmpty())
216+
fun openIncompatibleDialog(incompatiblePatch: PatchInfo) {
217+
compatibleVersions.addAll(incompatiblePatch.compatiblePackages?.find { it.packageName == packageName }?.versions.orEmpty())
213218
}
214219

215220
fun toggleFlag(flag: Int) {
216221
filter = filter xor flag
217222
}
218223

219224
companion object {
220-
const val SHOW_UNSUPPORTED = 1 // 2^0
225+
const val SHOW_INCOMPATIBLE = 1 // 2^0
221226
const val SHOW_UNIVERSAL = 2 // 2^1
222227

223228
private val optionsSaver: Saver<PersistentOptions, Options> = snapshotStateMapSaver(

0 commit comments

Comments
 (0)