diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f936129af..81326d85fd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ jobs: docker: - image: circleci/android:api-29 environment: - JAVA_TOOL_OPTIONS: -Xmx5024m + GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false steps: - checkout - run: @@ -33,7 +33,7 @@ jobs: docker: - image: circleci/android:api-29 environment: - JAVA_TOOL_OPTIONS: -Xmx5024m + GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false steps: - checkout - run: @@ -48,29 +48,29 @@ jobs: key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "player/build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "util/build.gradle" }}-{{ checksum "draw/build.gradle" }}-{{ checksum "emoji/build.gradle" }}-{{ checksum "suggestions/build.gradle" }} - run: name: Download Dependencies - command: ./gradlew --no-daemon androidDependencies --quiet --console=plain + command: ./gradlew androidDependencies - save_cache: paths: - ~/.gradle/caches - ~/.gradle/wrapper key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "player/build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "util/build.gradle" }}-{{ checksum "draw/build.gradle" }}-{{ checksum "emoji/build.gradle" }}-{{ checksum "suggestions/build.gradle" }} - run: - name: Run Lint #, Checkstyles, PMD, Findbugs... - command: ./gradlew --no-daemon lint + name: Run Lint + command: ./gradlew lint - run: name: Run Unit test - command: ./gradlew --no-daemon test + command: ./gradlew test - run: name: Compile Instrumentation test - command: ./gradlew --no-daemon assembleAndroidTest + command: ./gradlew assembleAndroidTest - store_artifacts: path: app/build/reports/ destination: reports - build-play-apk: + build-aab: docker: - image: circleci/android:api-29 environment: - JAVA_TOOL_OPTIONS: -Xmx5024m + GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false steps: - checkout - run: @@ -90,24 +90,23 @@ jobs: key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "player/build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "util/build.gradle" }}-{{ checksum "draw/build.gradle" }}-{{ checksum "emoji/build.gradle" }}-{{ checksum "suggestions/build.gradle" }} - run: name: Download Dependencies - command: ./gradlew --no-daemon androidDependencies --quiet --console=plain + command: ./gradlew androidDependencies - save_cache: paths: - ~/.gradle/caches - ~/.gradle/wrapper key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "player/build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "util/build.gradle" }}-{{ checksum "draw/build.gradle" }}-{{ checksum "emoji/build.gradle" }}-{{ checksum "suggestions/build.gradle" }} - run: - name: Build APK - command: | - ./gradlew --no-daemon assemblePlayRelease --info --console=plain --stacktrace + name: Build AAB + command: ./gradlew bundleRelease - store_artifacts: - path: app/build/outputs/apk - destination: apks + path: app/build/outputs/bundle + destination: bundle build-foss-apk: docker: - image: circleci/android:api-29 environment: - JAVA_TOOL_OPTIONS: -Xmx5024m + GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false steps: - checkout - run: @@ -127,7 +126,7 @@ jobs: key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "player/build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "util/build.gradle" }}-{{ checksum "draw/build.gradle" }}-{{ checksum "emoji/build.gradle" }}-{{ checksum "suggestions/build.gradle" }} - run: name: Download Dependencies - command: ./gradlew --no-daemon androidDependencies --quiet --console=plain + command: ./gradlew androidDependencies - save_cache: paths: - ~/.gradle/caches @@ -135,8 +134,7 @@ jobs: key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}-{{ checksum "player/build.gradle" }}-{{ checksum "core/build.gradle" }}-{{ checksum "util/build.gradle" }}-{{ checksum "draw/build.gradle" }}-{{ checksum "emoji/build.gradle" }}-{{ checksum "suggestions/build.gradle" }} - run: name: Build APK - command: | - ./gradlew --no-daemon assembleFossRelease --info --console=plain --stacktrace + command: ./gradlew assembleFossRelease - store_artifacts: path: app/build/outputs/apk destination: apks @@ -154,7 +152,7 @@ workflows: - develop - develop-2.x - master - - build-play-apk: + - build-aab: requires: - build-kotlin-sdk - build-foss-apk: diff --git a/app/build.gradle b/app/build.gradle index ad9bea7f20..9bfe286740 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,7 +18,7 @@ android { applicationId "chat.rocket.android" minSdkVersion versions.minSdk targetSdkVersion versions.targetSdk - versionCode 2075 + versionCode 2077 versionName "3.5.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true diff --git a/app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt b/app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt index 986f9f3ec1..d7f40f9709 100644 --- a/app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt +++ b/app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt @@ -45,7 +45,7 @@ class MessageInfoFragment : Fragment(), MessageInfoView { val bundle = arguments if (bundle != null) { - messageId = bundle.getString(BUNDLE_MESSAGE_ID) + messageId = bundle.getString(BUNDLE_MESSAGE_ID, "") } else { requireNotNull(bundle) { "no arguments supplied when the fragment was instantiated" } } diff --git a/app/src/main/java/chat/rocket/android/chatroom/domain/UriInteractor.kt b/app/src/main/java/chat/rocket/android/chatroom/domain/UriInteractor.kt index e9ec9554e8..6c91ba4ab2 100644 --- a/app/src/main/java/chat/rocket/android/chatroom/domain/UriInteractor.kt +++ b/app/src/main/java/chat/rocket/android/chatroom/domain/UriInteractor.kt @@ -15,7 +15,7 @@ class UriInteractor @Inject constructor(private val context: Context) { /** * Returns the MimeType from the [Uri]. */ - fun getMimeType(uri: Uri): String = uri.getMimeType(context) + fun getMimeType(uri: Uri): String = uri.getMimeType(context) ?: ".png" /** * Returns the file size from the [Uri]. diff --git a/app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt b/app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt index 7dafb1cfe5..72f123b008 100644 --- a/app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt +++ b/app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt @@ -639,8 +639,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR override fun copyToClipboard(message: String) { ui { - val clipboard = it.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - clipboard.primaryClip = ClipData.newPlainText("", message) + (it.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager).apply { + setPrimaryClip(ClipData.newPlainText("", message)) + } } } diff --git a/app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt b/app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt index b8514523df..7a5e5140de 100644 --- a/app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt +++ b/app/src/main/java/chat/rocket/android/chatroom/ui/Dialog.kt @@ -20,7 +20,7 @@ fun ChatRoomFragment.showFileAttachmentDialog(uri: Uri) { var bitmap: Bitmap? = null activity?.let { context -> - uri.getMimeType(context).let { + uri.getMimeType(context)?.let { mimeType = it description.text.clear() when { diff --git a/app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt b/app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt index 14637d78cc..66390b8ed0 100644 --- a/app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt +++ b/app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt @@ -89,7 +89,7 @@ class MainActivity : AppCompatActivity(), HasActivityInjector, val config = Configuration() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - config.locales = LocaleList(locale) + config.setLocales(LocaleList(locale)) } else { config.locale = locale } diff --git a/app/src/main/java/chat/rocket/android/util/extensions/Intent.kt b/app/src/main/java/chat/rocket/android/util/extensions/Intent.kt index 4cae255afa..28549f4c0d 100644 --- a/app/src/main/java/chat/rocket/android/util/extensions/Intent.kt +++ b/app/src/main/java/chat/rocket/android/util/extensions/Intent.kt @@ -4,8 +4,8 @@ import android.app.Activity import android.content.Intent fun Intent.isSupportedLink(activity: Activity): Boolean { - return (action == Intent.ACTION_VIEW && data != null && (data.isDynamicLink(activity) || - data.isAuthenticationDeepLink(activity) || - data.isCustomSchemeRoomLink() || - data.isWebSchemeRoomLink())) + return (action == Intent.ACTION_VIEW && data != null && (data?.isDynamicLink(activity) == true || + data?.isAuthenticationDeepLink(activity) == true || + data?.isCustomSchemeRoomLink() == true || + data?.isWebSchemeRoomLink() == true)) } \ No newline at end of file diff --git a/app/src/main/java/chat/rocket/android/util/extensions/Uri.kt b/app/src/main/java/chat/rocket/android/util/extensions/Uri.kt index f3212fd09e..b0a5a75b86 100644 --- a/app/src/main/java/chat/rocket/android/util/extensions/Uri.kt +++ b/app/src/main/java/chat/rocket/android/util/extensions/Uri.kt @@ -53,7 +53,7 @@ fun Uri.getFileSize(context: Context): Int { return fileSize?.toIntOrNull() ?: -1 } -fun Uri.getMimeType(context: Context): String { +fun Uri.getMimeType(context: Context): String? { return if (scheme == ContentResolver.SCHEME_CONTENT) { context.contentResolver?.getType(this) ?: "" } else { @@ -121,7 +121,7 @@ fun Uri.getDeepLinkInfo(context: Context): DeepLinkInfo? { return when { isAuthenticationDeepLink(context) -> { val host = getQueryParameter("host") - val url = if (host.startsWith("http")) host else "https://$host" + val url = if (host?.startsWith("http") == true) host else "https://$host" val userId = getQueryParameter("userId") val token = getQueryParameter("token") try { @@ -133,12 +133,12 @@ fun Uri.getDeepLinkInfo(context: Context): DeepLinkInfo? { } isCustomSchemeRoomLink() -> { val hostValue = getQueryParameter("host") - val url = if (hostValue.startsWith("http")) hostValue else "https://$hostValue" + val url = if (hostValue?.startsWith("http") == true) hostValue else "https://$hostValue" val rid = getQueryParameter("rid") val pathValue = getQueryParameter("path") - val pathSplit = pathValue.split("/") - val roomType = pathSplit[0] - val roomName = pathSplit[1] + val pathSplit = pathValue?.split("/") + val roomType = pathSplit?.get(0) + val roomName = pathSplit?.get(1) try { DeepLinkInfo(url, null, null, rid, roomType, roomName) } catch (ex: Exception) { @@ -148,9 +148,9 @@ fun Uri.getDeepLinkInfo(context: Context): DeepLinkInfo? { } isWebSchemeRoomLink() -> { val url = "https://$host" - val pathSplit = path.split("/") - val roomType = pathSplit[1] - val roomName = pathSplit[2] + val pathSplit = path?.split("/") + val roomType = pathSplit?.get(1) + val roomName = pathSplit?.get(2) try { DeepLinkInfo(url, null, null, null, roomType, roomName) } catch (ex: Exception) { @@ -163,7 +163,7 @@ fun Uri.getDeepLinkInfo(context: Context): DeepLinkInfo? { } fun Uri.isDynamicLink(activity: Activity): Boolean { - return (host != null && host.contains(activity.getString(R.string.dynamic_link_host_url))) + return (host != null && host?.contains(activity.getString(R.string.dynamic_link_host_url)) == true) } // Authentication deep link defined here: https://rocket.chat/docs/developer-guides/deeplink/#authentication @@ -177,17 +177,11 @@ fun Uri.isAuthenticationDeepLink(context: Context): Boolean { // Custom scheme room deep link defined here: https://rocket.chat/docs/developer-guides/deeplink/#channel--group--dm fun Uri.isCustomSchemeRoomLink(): Boolean { - if (scheme.startsWith("rocketchat") && - host == "room") - return true - return false + return (scheme?.startsWith("rocketchat")) == true && host == "room" } // http(s) scheme deep link not yet documented. Ex: https://open.rocket.chat/direct/testuser1 fun Uri.isWebSchemeRoomLink(): Boolean { - val roomType = path.split("/")[1] - if (scheme.startsWith("http") && - (roomType == "channel" || roomType == "group" || roomType == "direct")) - return true - return false + val roomType = path?.split("/")?.get(1) + return (scheme?.startsWith("http")) == true && (roomType == "channel" || roomType == "group" || roomType == "direct") } diff --git a/build.gradle b/build.gradle index f28559fd6d..c144baa2e3 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" classpath "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}" classpath 'com.google.gms:google-services:4.3.0' diff --git a/dependencies.gradle b/dependencies.gradle index 74fe1ffcdc..3f4752e38a 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -3,8 +3,8 @@ ext { // For project configuration java : JavaVersion.VERSION_1_8, minSdk : 21, - compileSdk : 28, - targetSdk : 28, + compileSdk : 29, + targetSdk : 29, buildTools : '29.0.1', dokka : '0.9.16', diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cad5cceecd..5a9e5e9510 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ -#Tue May 14 21:15:38 BRT 2019 +#Wed Aug 21 11:31:33 BRT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip -distributionSha256Sum=53b71812f18cdb2777e9f1b2a0f2038683907c90bdc406bc64d8b400e1fb2c3b +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip