[MIN_ENGINE_VER]
1

[AUTHOR]
apkeditor

[PACKAGE]
*

# Merge resources and smali files inside extra.zip
# The IDs inside smali files will be refactored
[MERGE]
SOURCE:
    extra.zip
[/MERGE]

# Add the ttf file
[ADD_FILES]
NAME:
    add_ttf
SOURCE:
    Pacifico.ttf
TARGET:
    assets/Pacifico.ttf
[/ADD_FILES]

# If already contains self-defined application, skip the manifest modification
[MATCH_GOTO]
TARGET:
    AndroidManifest.xml
MATCH:
    <application .*android:name=.*>
REGEX:
    true
GOTO:
    modify_application
[/MATCH_GOTO]

# Add android:name="apkeditor.patch.customfont.MyApplication" in application tag
[MATCH_REPLACE]
NAME:
    modify_manifest
TARGET:
    AndroidManifest.xml
MATCH:
    <application (.*)>
REGEX:
    true
REPLACE:
    <application android:name="apkeditor.patch.customfont.MyApplication" ${GROUP1}>
[/MATCH_REPLACE]

[GOTO]
GOTO:
    modify_activities
[/GOTO]

# Add some code inside onCreate method after "invoke-super xxx"
[MATCH_REPLACE]
NAME:
    modify_application
TARGET:
    [APPLICATION]
MATCH:
    \.method (public|protected) onCreate\(\)V\n(.+invoke-super.+->onCreate\(\)V)
REGEX:
    true
DOTALL:
    true
REPLACE:
.method ${GROUP1} onCreate()V
${GROUP2}
    invoke-static {}, Lapkeditor/patch/customfont/MyApplication;->init()V
[/MATCH_REPLACE]

# add attachBaseContext method before onCreate
# The onCreate method can be public or protected, thus use a regular expression
[MATCH_REPLACE]
NAME:
    modify_activities
TARGET:
    [ACTIVITIES]
MATCH:
    \.method .+ onCreate\(Landroid/os/Bundle;\)V
REGEX:
    true
REPLACE:
.method protected attachBaseContext(Landroid/content/Context;)V
    .registers 3

    invoke-static {p1}, Luk/co/chrisjenx/calligraphy/CalligraphyContextWrapper;->wrap(Landroid/content/Context;)Landroid/content/ContextWrapper;

    move-result-object v0

    invoke-super {p0, v0}, Landroid/app/Activity;->attachBaseContext(Landroid/content/Context;)V

    return-void
.end method
.method public onCreate(Landroid/os/Bundle;)V
[/MATCH_REPLACE]
