You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright 2019 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import groovy.xml.MarkupBuilder
  17. apply plugin: 'com.android.application'
  18. def twaManifest = [
  19. applicationId: 'org.jitsi.meet',
  20. hostName: 'meet.jit.si', // The domain being opened in the TWA.
  21. launchUrl: '/', // The start path for the TWA. Must be relative to the domain.
  22. name: 'Jitsi Meet', // The application name.
  23. launcherName: 'Jitsi Meet', // The name shown on the Android Launcher.
  24. themeColor: '#17A0DB', // The color used for the status bar.
  25. navigationColor: '#000000', // The color used for the navigation bar.
  26. navigationColorDark: '#000000', // The color used for the dark navbar.
  27. navigationDividerColor: '#000000', // The navbar divider color.
  28. navigationDividerColorDark: '#000000', // The dark navbar divider color.
  29. backgroundColor: '#17A0DB', // The color used for the splash screen background.
  30. enableNotifications: false, // Set to true to enable notification delegation.
  31. // Every shortcut must include the following fields:
  32. // - name: String that will show up in the shortcut.
  33. // - short_name: Shorter string used if |name| is too long.
  34. // - url: Absolute path of the URL to launch the app with (e.g '/create').
  35. // - icon: Name of the resource in the drawable folder to use as an icon.
  36. shortcuts: [],
  37. // The duration of fade out animation in milliseconds to be played when removing splash screen.
  38. splashScreenFadeOutDuration: 300,
  39. generatorApp: 'bubblewrap-cli', // Application that generated the Android Project
  40. // The fallback strategy for when Trusted Web Activity is not avilable. Possible values are
  41. // 'customtabs' and 'webview'.
  42. fallbackType: 'customtabs',
  43. enableSiteSettingsShortcut: 'true',
  44. ]
  45. android {
  46. compileSdkVersion 29
  47. defaultConfig {
  48. applicationId "org.jitsi.meet"
  49. minSdkVersion 19
  50. targetSdkVersion 29
  51. versionCode 2000000000
  52. versionName "1.0.0"
  53. // The name for the application
  54. resValue "string", "appName", twaManifest.name
  55. // The name for the application on the Android Launcher
  56. resValue "string", "launcherName", twaManifest.launcherName
  57. // The URL that will be used when launching the TWA from the Android Launcher
  58. def launchUrl = "https://" + twaManifest.hostName + twaManifest.launchUrl
  59. resValue "string", "launchUrl", launchUrl
  60. // The URL the Web Manifest for the Progressive Web App that the TWA points to. This
  61. // is used by Chrome OS to open the Web version of the PWA instead of the TWA, as it
  62. // will probably give a better user experience for non-mobile devices.
  63. resValue "string", "webManifestUrl", 'https://meet.jit.si/manifest.json'
  64. // The hostname is used when building the intent-filter, so the TWA is able to
  65. // handle Intents to open https://svgomg.firebaseapp.com.
  66. resValue "string", "hostName", twaManifest.hostName
  67. // This variable below expresses the relationship between the app and the site,
  68. // as documented in the TWA documentation at
  69. // https://developers.google.com/web/updates/2017/10/using-twa#set_up_digital_asset_links_in_an_android_app
  70. // and is injected into the AndroidManifest.xml
  71. resValue "string", "assetStatements",
  72. '[{ \\"relation\\": [\\"delegate_permission/common.handle_all_urls\\"],' +
  73. '\\"target\\": {\\"namespace\\": \\"web\\", \\"site\\": \\"https://' +
  74. twaManifest.hostName + '\\"}}]'
  75. // This attribute sets the status bar color for the TWA. It can be either set here or in
  76. // `res/values/colors.xml`. Setting in both places is an error and the app will not
  77. // compile. If not set, the status bar color defaults to #FFFFFF - white.
  78. resValue "color", "colorPrimary", twaManifest.themeColor
  79. // This attribute sets the navigation bar color for the TWA. It can be either set here or
  80. // in `res/values/colors.xml`. Setting in both places is an error and the app will not
  81. // compile. If not set, the navigation bar color defaults to #FFFFFF - white.
  82. resValue "color", "navigationColor", twaManifest.navigationColor
  83. // This attribute sets the dark navigation bar color for the TWA. It can be either set here
  84. // or in `res/values/colors.xml`. Setting in both places is an error and the app will not
  85. // compile. If not set, the navigation bar color defaults to #000000 - black.
  86. resValue "color", "navigationColorDark", twaManifest.navigationColorDark
  87. // This attribute sets the navbar divider color for the TWA. It can be either
  88. // set here or in `res/values/colors.xml`. Setting in both places is an error and the app
  89. // will not compile. If not set, the divider color defaults to #00000000 - transparent.
  90. resValue "color", "navigationDividerColor", twaManifest.navigationDividerColor
  91. // This attribute sets the dark navbar divider color for the TWA. It can be either
  92. // set here or in `res/values/colors.xml`. Setting in both places is an error and the
  93. //app will not compile. If not set, the divider color defaults to #000000 - black.
  94. resValue "color", "navigationDividerColorDark", twaManifest.navigationDividerColorDark
  95. // Sets the color for the background used for the splash screen when launching the
  96. // Trusted Web Activity.
  97. resValue "color", "backgroundColor", twaManifest.backgroundColor
  98. // Defines a provider authority fot the Splash Screen
  99. resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider'
  100. // The enableNotification resource is used to enable or disable the
  101. // TrustedWebActivityService, by changing the android:enabled and android:exported
  102. // attributes
  103. resValue "bool", "enableNotification", twaManifest.enableNotifications.toString()
  104. twaManifest.shortcuts.eachWithIndex { shortcut, index ->
  105. resValue "string", "shortcut_name_$index", "$shortcut.name"
  106. resValue "string", "shortcut_short_name_$index", "$shortcut.short_name"
  107. }
  108. // The splashScreenFadeOutDuration resource is used to set the duration of fade out animation in milliseconds
  109. // to be played when removing splash screen. The default is 0 (no animation).
  110. resValue "integer", "splashScreenFadeOutDuration", twaManifest.splashScreenFadeOutDuration.toString()
  111. resValue "string", "generatorApp", twaManifest.generatorApp
  112. resValue "string", "fallbackType", twaManifest.fallbackType
  113. resValue "bool", "enableSiteSettingsShortcut", twaManifest.enableSiteSettingsShortcut
  114. }
  115. buildTypes {
  116. release {
  117. minifyEnabled true
  118. }
  119. }
  120. compileOptions {
  121. sourceCompatibility JavaVersion.VERSION_1_8
  122. targetCompatibility JavaVersion.VERSION_1_8
  123. }
  124. }
  125. task generateShorcutsFile {
  126. assert twaManifest.shortcuts.size() < 5, "You can have at most 4 shortcuts."
  127. twaManifest.shortcuts.eachWithIndex { s, i ->
  128. assert s.name != null, 'Missing `name` in shortcut #' + i
  129. assert s.short_name != null, 'Missing `short_name` in shortcut #' + i
  130. assert s.url != null, 'Missing `icon` in shortcut #' + i
  131. assert s.icon != null, 'Missing `url` in shortcut #' + i
  132. }
  133. def shortcutsFile = new File("$projectDir/src/main/res/xml", "shortcuts.xml")
  134. def xmlWriter = new StringWriter()
  135. def xmlMarkup = new MarkupBuilder(new IndentPrinter(xmlWriter, " ", true))
  136. xmlMarkup
  137. .'shortcuts'('xmlns:android': 'http://schemas.android.com/apk/res/android') {
  138. twaManifest.shortcuts.eachWithIndex { s, i ->
  139. 'shortcut'(
  140. 'android:shortcutId': 'shortcut' + i,
  141. 'android:enabled': 'true',
  142. 'android:icon': '@drawable/' + s.icon,
  143. 'android:shortcutShortLabel': '@string/shortcut_short_name_' + i,
  144. 'android:shortcutLongLabel': '@string/shortcut_name_' + i) {
  145. 'intent'(
  146. 'android:action': 'android.intent.action.MAIN',
  147. 'android:targetPackage': twaManifest.applicationId,
  148. 'android:targetClass': twaManifest.applicationId + '.LauncherActivity',
  149. 'android:data': s.url)
  150. 'categories'('android:name': 'android.intent.category.LAUNCHER')
  151. }
  152. }
  153. }
  154. shortcutsFile.text = xmlWriter.toString() + '\n'
  155. }
  156. preBuild.dependsOn(generateShorcutsFile)
  157. repositories {
  158. }
  159. dependencies {
  160. implementation fileTree(include: ['*.jar'], dir: 'libs')
  161. implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.0.0'
  162. }