Light theme default + yt-dlp search fallback
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
param(
|
||||
[string]$ProjectRoot = (Get-Location).Path
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "=== YouTube Personal - Correctif R8 Release v2 ===" -ForegroundColor Cyan
|
||||
Write-Host "Projet : $ProjectRoot"
|
||||
Write-Host ""
|
||||
|
||||
$androidApp = Join-Path $ProjectRoot "android\app"
|
||||
$kts = Join-Path $androidApp "build.gradle.kts"
|
||||
$groovy = Join-Path $androidApp "build.gradle"
|
||||
$proguard = Join-Path $androidApp "proguard-rules.pro"
|
||||
|
||||
if (-not (Test-Path $androidApp)) {
|
||||
throw "Dossier Android introuvable : $androidApp"
|
||||
}
|
||||
|
||||
# 1) Cree/complete proguard-rules.pro
|
||||
$rule = '-dontwarn java.beans.**'
|
||||
if (-not (Test-Path $proguard)) {
|
||||
Set-Content -Path $proguard -Value $rule -Encoding UTF8
|
||||
Write-Host "[OK] proguard-rules.pro cree." -ForegroundColor Green
|
||||
} else {
|
||||
$ptext = Get-Content $proguard -Raw
|
||||
if ($ptext -notmatch '(?m)^\s*-dontwarn\s+java\.beans\.\*\*\s*$') {
|
||||
Add-Content -Path $proguard -Value "`r`n# Rhino / NewPipeExtractor`r`n$rule" -Encoding UTF8
|
||||
Write-Host "[OK] Regle java.beans ajoutee." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[OK] Regle java.beans deja presente." -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
function Backup-Once([string]$Path) {
|
||||
$backup = "$Path.before_r8_fix_v2"
|
||||
if (-not (Test-Path $backup)) {
|
||||
Copy-Item $Path $backup
|
||||
Write-Host "[OK] Sauvegarde : $backup" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
# 2) Branche proguard-rules.pro dans le build type release.
|
||||
# Contrairement a la v1, ce script ne suppose PAS la presence de
|
||||
# isMinifyEnabled = true. Flutter/AGP peut lancer R8 sans cette ligne
|
||||
# explicite dans le fichier utilisateur.
|
||||
if (Test-Path $kts) {
|
||||
Backup-Once $kts
|
||||
$text = Get-Content $kts -Raw
|
||||
|
||||
if ($text -match 'proguard-rules\.pro') {
|
||||
Write-Host "[OK] build.gradle.kts utilise deja proguard-rules.pro." -ForegroundColor Green
|
||||
} else {
|
||||
$pattern = '(?m)^(\s*)release\s*\{\s*(?://.*)?$'
|
||||
$m = [regex]::Match($text, $pattern)
|
||||
if (-not $m.Success) {
|
||||
throw "Bloc release { introuvable dans android/app/build.gradle.kts. Aucune modification Gradle effectuee."
|
||||
}
|
||||
|
||||
$indent = $m.Groups[1].Value + ' '
|
||||
$line = $indent + 'proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")'
|
||||
$replacement = $m.Value + "`r`n" + $line
|
||||
$rx = [regex]::new($pattern)
|
||||
$text = $rx.Replace($text, $replacement, 1)
|
||||
Set-Content -Path $kts -Value $text -Encoding UTF8
|
||||
Write-Host "[OK] proguard-rules.pro branche dans release (Kotlin DSL)." -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
elseif (Test-Path $groovy) {
|
||||
Backup-Once $groovy
|
||||
$text = Get-Content $groovy -Raw
|
||||
|
||||
if ($text -match 'proguard-rules\.pro') {
|
||||
Write-Host "[OK] build.gradle utilise deja proguard-rules.pro." -ForegroundColor Green
|
||||
} else {
|
||||
$pattern = '(?m)^(\s*)release\s*\{\s*(?://.*)?$'
|
||||
$m = [regex]::Match($text, $pattern)
|
||||
if (-not $m.Success) {
|
||||
throw "Bloc release { introuvable dans android/app/build.gradle. Aucune modification Gradle effectuee."
|
||||
}
|
||||
|
||||
$indent = $m.Groups[1].Value + ' '
|
||||
$line = $indent + "proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'"
|
||||
$replacement = $m.Value + "`r`n" + $line
|
||||
$rx = [regex]::new($pattern)
|
||||
$text = $rx.Replace($text, $replacement, 1)
|
||||
Set-Content -Path $groovy -Value $text -Encoding UTF8
|
||||
Write-Host "[OK] proguard-rules.pro branche dans release (Groovy)." -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw "Aucun android/app/build.gradle.kts ni android/app/build.gradle trouve."
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "=== Verification ===" -ForegroundColor Cyan
|
||||
if (Test-Path $kts) {
|
||||
Select-String -Path $kts -Pattern 'release\s*\{|proguardFiles|isMinifyEnabled' | ForEach-Object { Write-Host $_.Line }
|
||||
} elseif (Test-Path $groovy) {
|
||||
Select-String -Path $groovy -Pattern 'release\s*\{|proguardFiles|minifyEnabled' | ForEach-Object { Write-Host $_.Line }
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Correctif applique." -ForegroundColor Green
|
||||
Write-Host "Lance maintenant :" -ForegroundColor Yellow
|
||||
Write-Host " flutter clean"
|
||||
Write-Host " flutter pub get"
|
||||
Write-Host " flutter build apk --release"
|
||||
Write-Host ""
|
||||
Reference in New Issue
Block a user