filter integration selection with a package name
This commit is contained in:
parent
816ef0abe0
commit
07b04f2d8e
1 changed files with 36 additions and 1 deletions
37
revanced.ps1
37
revanced.ps1
|
@ -251,6 +251,14 @@ class Integration {
|
|||
if ($compatiblePackage.length -eq 0 ) { return $false }
|
||||
return $compatiblePackage.Contains($version)
|
||||
}
|
||||
|
||||
[System.Collections.ArrayList] compatiblePackageNames() {
|
||||
$rvalue =[System.Collections.ArrayList]::new($this.compatiblePackages.Count)
|
||||
foreach ($i in $this.compatiblePackages) {
|
||||
[void] $rvalue.Add($i.name)
|
||||
}
|
||||
return $rvalue
|
||||
}
|
||||
}
|
||||
|
||||
class IntegrationList : System.Collections.ArrayList<#Integration#> {
|
||||
|
@ -302,6 +310,26 @@ class IntegrationList : System.Collections.ArrayList<#Integration#> {
|
|||
}
|
||||
return $rvalue
|
||||
}
|
||||
|
||||
[FormItems] getForm([String] $packageName) {
|
||||
$rvalue = [FormItems]::new()
|
||||
foreach ($i in $this) {
|
||||
if (-not $i.compatiblePackageNames().Contains($packageName)) { continue }
|
||||
[void] $rvalue.Add([FormItem]::new($i.name, "$($i.name) - $($i.description)"))
|
||||
}
|
||||
return $rvalue
|
||||
}
|
||||
|
||||
[System.Collections.ArrayList] getAllCompatiblePackagesNames() {
|
||||
$rvalue = [System.Collections.ArrayList]::new()
|
||||
foreach ($i in $this) {
|
||||
foreach ($j in $i.compatiblePackages) {
|
||||
if ($rvalue.Contains($j.name)) { continue }
|
||||
[void] $rvalue.Add($j.name)
|
||||
}
|
||||
}
|
||||
return $rvalue
|
||||
}
|
||||
}
|
||||
|
||||
function main {
|
||||
|
@ -348,10 +376,17 @@ function main {
|
|||
|
||||
$integrations = [IntegrationList]::new(".\app\revanced-patches.json")
|
||||
|
||||
# get package name
|
||||
# FIXME: How to extract package name from its apk file?
|
||||
|
||||
$packageNamesForm = [FormItems]::new($integrations.getAllCompatiblePackagesNames())
|
||||
|
||||
$packageName = renderForm -items $packageNamesForm -label "Which package is it?" -title "Installer for ReVanced - package name" -mode One
|
||||
|
||||
# integrations selector
|
||||
|
||||
$integrationsToInclude = [System.Collections.ArrayList]::new()
|
||||
$integrationsForm = $integrations.getForm()
|
||||
$integrationsForm = $integrations.getForm($packageName)
|
||||
for ($i = 0; $i -lt $integrationsForm.Count; $i++) {
|
||||
if (-not $config.config.included.Contains($integrationsForm[$i].value)) { continue }
|
||||
$integrationsForm[$i].selected = $true
|
||||
|
|
Reference in a new issue