Skip to content

Commit

Permalink
Automatic preset importing
Browse files Browse the repository at this point in the history
Thanks to @syntaxticsugr for helping with the preset detection regexes.
  • Loading branch information
programminghoch10 committed Aug 5, 2023
1 parent 4d742d1 commit 864fafa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ It contains many useability enhancements and all the major fixes needed to run `
but is usually not needed either.
You can still combine `ViPER4Android` with other audio mods
using [`Audio Modification Library`](https://github.com/Magisk-Modules-Repo/aml) if you want to.
* **Automatic VDC and IRS import** \
If you have [bought a VDC file](https://t.me/vdcservice) or downloaded an IRS file
which now lays in your Download directory,
* **Automatic VDC, IRS and preset import** \
If you have [bought a VDC file](https://t.me/vdcservice)
or downloaded an IRS file or preset,
you don't have to copy it over manually.
The installer automatically finds and copies them to the correct place
for `ViPER4Android` to find them
Expand Down
21 changes: 21 additions & 0 deletions magiskmodule/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,27 @@ if $CUSTOM_IRS_FOUND; then
done
fi

presetCompatible() {
local file="$1"
grep -q '<int name="32775" value="[12]" />' < "$file" || return 1
grep -q '<string name="65540;65541;65542">.*</string>' < "$file" || return 1
return 0
}

mkdir -p "$FOLDER"/Preset
CUSTOM_PRESET_FILES=$(find $SDCARD -name '*.xml' -not -path "$SDCARD/Android/*")
if [ -n "$CUSTOM_PRESET_FILES" ]; then
ui_print "- Copying custom preset files"
for file in $CUSTOM_PRESET_FILES; do
! presetCompatible "$file" && continue
ui_print " $file"
cp -f "$file" "$FOLDER"/Preset
done
else
ui_print "- Skipping preset copy"
ui_print " custom preset files have not been found"
fi

ui_print "- Patching system audio files"
AUDIO_EFFECTS_FILES="$( \
find -H \
Expand Down

0 comments on commit 864fafa

Please sign in to comment.