-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcutsGenerator.gradle
26 lines (24 loc) · 1.39 KB
/
shortcutsGenerator.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import groovy.xml.MarkupBuilder
ext.fileBuilder = { File shortcutsFile, twaManifest ->
def xmlWriter = new StringWriter()
def xmlMarkup = new MarkupBuilder(new IndentPrinter(xmlWriter, " ", true))
xmlMarkup
.'shortcuts'('xmlns:android': 'http://schemas.android.com/apk/res/android') {
twaManifest.shortcuts.eachWithIndex { s, int i ->
'shortcut'(
'android:shortcutId': 'shortcut' + i,
'android:enabled': 'true',
'android:icon': '@drawable/' + (s.icon as String),
'android:shortcutShortLabel': '@string/shortcut_short_name_' + i,
'android:shortcutLongLabel': '@string/shortcut_name_' + i) {
'intent'(
'android:action': 'android.intent.action.MAIN',
'android:targetPackage': twaManifest.applicationId,
'android:targetClass': 'com.google.androidbrowserhelper.trusted.LauncherActivity',
'android:data': 'https://' + (twaManifest.hostName as String) + (s.url as String))
'categories'('android:name': 'android.intent.category.LAUNCHER')
}
}
}
shortcutsFile.text = xmlWriter.toString() + '\n'
}