Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

build.gradle 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. // Use the number of seconds/10 since Jan 1 2019 as the versionCode.
  46. // This lets us upload a new build at most every 10 seconds for the
  47. // next ~680 years.
  48. // https://stackoverflow.com/a/38643838
  49. def vcode = (int) (((new Date().getTime() / 1000) - 1546297200) / 10)
  50. android {
  51. compileSdkVersion 29
  52. defaultConfig {
  53. applicationId "org.jitsi.meet"
  54. minSdkVersion 19
  55. targetSdkVersion 29
  56. versionCode vcode
  57. versionName "20.5.0"
  58. // The name for the application
  59. resValue "string", "appName", twaManifest.name
  60. // The name for the application on the Android Launcher
  61. resValue "string", "launcherName", twaManifest.launcherName
  62. // The URL that will be used when launching the TWA from the Android Launcher
  63. def launchUrl = "https://" + twaManifest.hostName + twaManifest.launchUrl
  64. resValue "string", "launchUrl", launchUrl
  65. // The URL the Web Manifest for the Progressive Web App that the TWA points to. This
  66. // is used by Chrome OS to open the Web version of the PWA instead of the TWA, as it
  67. // will probably give a better user experience for non-mobile devices.
  68. resValue "string", "webManifestUrl", 'https://meet.jit.si/static/pwa/manifest.json'
  69. // The hostname is used when building the intent-filter, so the TWA is able to
  70. // handle Intents to open https://svgomg.firebaseapp.com.
  71. resValue "string", "hostName", twaManifest.hostName
  72. // This variable below expresses the relationship between the app and the site,
  73. // as documented in the TWA documentation at
  74. // https://developers.google.com/web/updates/2017/10/using-twa#set_up_digital_asset_links_in_an_android_app
  75. // and is injected into the AndroidManifest.xml
  76. resValue "string", "assetStatements",
  77. '[{ \\"relation\\": [\\"delegate_permission/common.handle_all_urls\\"],' +
  78. '\\"target\\": {\\"namespace\\": \\"web\\", \\"site\\": \\"https://' +
  79. twaManifest.hostName + '\\"}}]'
  80. // This attribute sets the status bar color for the TWA. It can be either set here or in
  81. // `res/values/colors.xml`. Setting in both places is an error and the app will not
  82. // compile. If not set, the status bar color defaults to #FFFFFF - white.
  83. resValue "color", "colorPrimary", twaManifest.themeColor
  84. // This attribute sets the navigation bar color for the TWA. It can be either set here or
  85. // in `res/values/colors.xml`. Setting in both places is an error and the app will not
  86. // compile. If not set, the navigation bar color defaults to #FFFFFF - white.
  87. resValue "color", "navigationColor", twaManifest.navigationColor
  88. // This attribute sets the dark navigation bar color for the TWA. It can be either set here
  89. // or in `res/values/colors.xml`. Setting in both places is an error and the app will not
  90. // compile. If not set, the navigation bar color defaults to #000000 - black.
  91. resValue "color", "navigationColorDark", twaManifest.navigationColorDark
  92. // This attribute sets the navbar divider color for the TWA. It can be either
  93. // set here or in `res/values/colors.xml`. Setting in both places is an error and the app
  94. // will not compile. If not set, the divider color defaults to #00000000 - transparent.
  95. resValue "color", "navigationDividerColor", twaManifest.navigationDividerColor
  96. // This attribute sets the dark navbar divider color for the TWA. It can be either
  97. // set here or in `res/values/colors.xml`. Setting in both places is an error and the
  98. //app will not compile. If not set, the divider color defaults to #000000 - black.
  99. resValue "color", "navigationDividerColorDark", twaManifest.navigationDividerColorDark
  100. // Sets the color for the background used for the splash screen when launching the
  101. // Trusted Web Activity.
  102. resValue "color", "backgroundColor", twaManifest.backgroundColor
  103. // Defines a provider authority fot the Splash Screen
  104. resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider'
  105. // The enableNotification resource is used to enable or disable the
  106. // TrustedWebActivityService, by changing the android:enabled and android:exported
  107. // attributes
  108. resValue "bool", "enableNotification", twaManifest.enableNotifications.toString()
  109. twaManifest.shortcuts.eachWithIndex { shortcut, index ->
  110. resValue "string", "shortcut_name_$index", "$shortcut.name"
  111. resValue "string", "shortcut_short_name_$index", "$shortcut.short_name"
  112. }
  113. // The splashScreenFadeOutDuration resource is used to set the duration of fade out animation in milliseconds
  114. // to be played when removing splash screen. The default is 0 (no animation).
  115. resValue "integer", "splashScreenFadeOutDuration", twaManifest.splashScreenFadeOutDuration.toString()
  116. resValue "string", "generatorApp", twaManifest.generatorApp
  117. resValue "string", "fallbackType", twaManifest.fallbackType
  118. resValue "bool", "enableSiteSettingsShortcut", twaManifest.enableSiteSettingsShortcut
  119. }
  120. buildTypes {
  121. release {
  122. minifyEnabled true
  123. }
  124. }
  125. compileOptions {
  126. sourceCompatibility JavaVersion.VERSION_1_8
  127. targetCompatibility JavaVersion.VERSION_1_8
  128. }
  129. }
  130. task generateShorcutsFile {
  131. assert twaManifest.shortcuts.size() < 5, "You can have at most 4 shortcuts."
  132. twaManifest.shortcuts.eachWithIndex { s, i ->
  133. assert s.name != null, 'Missing `name` in shortcut #' + i
  134. assert s.short_name != null, 'Missing `short_name` in shortcut #' + i
  135. assert s.url != null, 'Missing `icon` in shortcut #' + i
  136. assert s.icon != null, 'Missing `url` in shortcut #' + i
  137. }
  138. def shortcutsFile = new File("$projectDir/src/main/res/xml", "shortcuts.xml")
  139. def xmlWriter = new StringWriter()
  140. def xmlMarkup = new MarkupBuilder(new IndentPrinter(xmlWriter, " ", true))
  141. xmlMarkup
  142. .'shortcuts'('xmlns:android': 'http://schemas.android.com/apk/res/android') {
  143. twaManifest.shortcuts.eachWithIndex { s, i ->
  144. 'shortcut'(
  145. 'android:shortcutId': 'shortcut' + i,
  146. 'android:enabled': 'true',
  147. 'android:icon': '@drawable/' + s.icon,
  148. 'android:shortcutShortLabel': '@string/shortcut_short_name_' + i,
  149. 'android:shortcutLongLabel': '@string/shortcut_name_' + i) {
  150. 'intent'(
  151. 'android:action': 'android.intent.action.MAIN',
  152. 'android:targetPackage': twaManifest.applicationId,
  153. 'android:targetClass': twaManifest.applicationId + '.LauncherActivity',
  154. 'android:data': s.url)
  155. 'categories'('android:name': 'android.intent.category.LAUNCHER')
  156. }
  157. }
  158. }
  159. shortcutsFile.text = xmlWriter.toString() + '\n'
  160. }
  161. preBuild.dependsOn(generateShorcutsFile)
  162. repositories {
  163. }
  164. dependencies {
  165. implementation fileTree(include: ['*.jar'], dir: 'libs')
  166. implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.0.0'
  167. }