Skip to content

Commit

Permalink
Stabilize resource IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Oct 15, 2019
1 parent 1b3a009 commit 34ff764
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ out
*.zip
*.jks
*.apk
config.prop
update.sh
/config.prop
/update.sh
/stub-ids.txt

# Built binaries
native/out
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/values/resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@
<string name="magiskhide" translatable="false">Magisk Hide</string>
<string name="empty" translatable="false"/>

<!-- Preserve 10 string slots for stub -->
<string name="preserve_0" translatable="false"/>
<string name="preserve_1" translatable="false"/>
<string name="preserve_2" translatable="false"/>
<string name="preserve_3" translatable="false"/>
<string name="preserve_4" translatable="false"/>
<string name="preserve_5" translatable="false"/>
<string name="preserve_6" translatable="false"/>
<string name="preserve_7" translatable="false"/>
<string name="preserve_8" translatable="false"/>
<string name="preserve_9" translatable="false"/>

</resources>
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ subprojects {
}

aaptOptions {
// Preserve stub resource IDs
File publicTxt = rootProject.file('stub-public.txt')
if (publicTxt.exists()) {
additionalParameters "--stable-ids", "${publicTxt.absolutePath}"
} else if (module.name == 'stub') {
additionalParameters "--emit-ids", "${publicTxt.absolutePath}"
}
// Handle resource IDs
File resIds = rootProject.file('stable-ids.txt')
File stubIds = rootProject.file('stub-ids.txt')
if (module.name == 'app' && resIds.exists())
additionalParameters "--stable-ids", "${resIds.absolutePath}"
else if (module.name == 'stub')
additionalParameters "--emit-ids", "${stubIds.absolutePath}"
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions stable-ids.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
com.topjohnwu.magisk:color/ic_launcher_background = 0x7f010000
com.topjohnwu.magisk:drawable/ic_launcher = 0x7f020000
com.topjohnwu.magisk:drawable/ic_logo = 0x7f020001
com.topjohnwu.magisk:drawable/ic_magisk = 0x7f020002
com.topjohnwu.magisk:drawable/ic_splash_activity = 0x7f020003
com.topjohnwu.magisk:style/SplashTheme = 0x7f040000
com.topjohnwu.magisk:style/SplashThemeBase = 0x7f040001
com.topjohnwu.magisk:style/SplashThemeBase.V19 = 0x7f040002
com.topjohnwu.magisk:xml/file_paths = 0x7f050000

com.topjohnwu.magisk:string/preserve_0 = 0x7f030000
com.topjohnwu.magisk:string/preserve_1 = 0x7f030001
com.topjohnwu.magisk:string/preserve_2 = 0x7f030002
com.topjohnwu.magisk:string/preserve_3 = 0x7f030003
com.topjohnwu.magisk:string/preserve_4 = 0x7f030004
com.topjohnwu.magisk:string/preserve_5 = 0x7f030005
com.topjohnwu.magisk:string/preserve_6 = 0x7f030006
com.topjohnwu.magisk:string/preserve_7 = 0x7f030007
com.topjohnwu.magisk:string/preserve_8 = 0x7f030008
com.topjohnwu.magisk:string/preserve_9 = 0x7f030009

0 comments on commit 34ff764

Please sign in to comment.