Skip to content

Commit

Permalink
BraveNewPipe: add gradle task that will rename NewPipe to BraveNewPip…
Browse files Browse the repository at this point in the history
…e in the workspace

This task should be used before building a release. Run it only once.
  • Loading branch information
evermind-zz committed Nov 10, 2023
1 parent 3d3bb12 commit 91ffdb4
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions app/replace-newpipe-with-bravenewpipe-strings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ def cleanupDirBefore = { dir ->
delete "${dir}"
}

// the return value points to the new srcDir containing the modified files
ext.copyFilesAndReplaceStrings = { dir, tmpTargetDir ->
println "[BraveNewPipe string replacing] source dir: " + dir
println "[BraveNewPipe string replacing] target dir: " + tmpTargetDir
ext.copyStringsXmlFiles = { dir, tmpTargetDir ->
copy {
from(dir)
include '**/strings.xml'
Expand All @@ -41,24 +38,42 @@ ext.copyFilesAndReplaceStrings = { dir, tmpTargetDir ->
line ->
if (shouldWeReplaceStuffInThisLine(line)) {
line
.replace('NewPipe', 'BraveNewPipe')
.replace('Newpipe', 'BraveNewPipe')
.replace('নিউপাইপ', 'সাহসী নিউপাইপ') // bn (bengali)
.replace('نیوپایپ', 'لوله جدید شجاع') // fa, czk (farsi)
.replace('NewPipe', 'BraveNewPipe')
.replace('Newpipe', 'BraveNewPipe')
.replace('নিউপাইপ', 'সাহসী নিউপাইপ') // bn (bengali)
.replace('نیوپایپ', 'لوله جدید شجاع') // fa, czk (farsi)
} else {
line
}
}
into("${tmpTargetDir}")
}
}

ext.copyNonStringsXmlFiles = { dir, tmpTargetDir ->
copy {
from(dir)
exclude '**/strings.xml'
into("${tmpTargetDir}")
}
}

// the return value points to the new srcDir containing the modified files
ext.copyFilesAndReplaceStrings = { dir, tmpTargetDir ->
println "[BraveNewPipe string replacing] source dir: " + dir
println "[BraveNewPipe string replacing] target dir: " + tmpTargetDir
copyStringsXmlFiles(dir, tmpTargetDir)
copyNonStringsXmlFiles(dir, tmpTargetDir)
return "${tmpTargetDir}"
}

ext.copyFiles = { dir, tmpTargetDir ->
copy {
from(dir)
into("${tmpTargetDir}")
}
}

// replace variables content for specific files
ext.alterFilesAndVerify = { targetDir, isTest ->

Expand Down Expand Up @@ -154,6 +169,27 @@ task testReplacingStrings() {
copyFilesAndReplaceStrings(sourceDir, targetDir)
}

ext.replaceNewPipeWithBraveNewPipeStrings = {

println "[BraveNewPipe string replacing]"

// modify .{xml} files
def relativeDirFile = 'src/main/res'
def sourceDir = "${rootDir}/app/${relativeDirFile}/"
def targetDir = "${buildDir}/tmp/${relativeDirFile}/test_output"
copyStringsXmlFiles(sourceDir, targetDir)
copyFiles(targetDir, sourceDir)
}

task bravify() {
group = 'brave'
description = 'replaces string NewPipe with BraveNewPipe'

doLast {
replaceNewPipeWithBraveNewPipeStrings()
}
}

// Patch NewPipe to use BraveNewPipe's:
// - support email address
// - the update json data URL
Expand Down

0 comments on commit 91ffdb4

Please sign in to comment.