Skip to content

Commit

Permalink
Merge pull request #1176 from vector-im/feature/target-sdk-29
Browse files Browse the repository at this point in the history
Increase targetSdk to 29
  • Loading branch information
bmarty authored Apr 15, 2020
2 parents f2bca51 + 6751d88 commit c57fa3f
Show file tree
Hide file tree
Showing 45 changed files with 116 additions and 142 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ android:
- platform-tools

# The BuildTools version used by your project
- build-tools-28.0.3
- build-tools-29.0.3

# The SDK version used to compile your project
- android-28
- android-29

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
Expand Down
5 changes: 3 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Features ✨:

Improvements 🙌:
- Verification DM / Handle concurrent .start after .ready (#794)
- Reimplementation of multiple attachment picker
- Cross-Signing | Update Shield Logic for DM (#963)
- Cross-Signing | Complete security new session design update (#1135)
- Cross-Signing | Setup key backup as part of SSSS bootstrapping (#1201)
Expand All @@ -30,10 +31,10 @@ Translations 🗣:
-

SDK API changes ⚠️:
-
- Increase targetSdkVersion to 29

Build 🧱:
-
- Compile with Android SDK 29 (Android Q)

Other changes:
- Increase File Logger capacities ( + use dev log preferences)
Expand Down
4 changes: 2 additions & 2 deletions matrix-sdk-android-rx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"

Expand Down
4 changes: 2 additions & 2 deletions matrix-sdk-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ androidExtensions {
}

android {
compileSdkVersion 28
compileSdkVersion 29
testOptions.unitTests.includeAndroidResources = true

defaultConfig {
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "0.0.1"
// Multidex is useful for tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ annotation class SessionCacheDirectory
@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class CacheDirectory

@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class ExternalFilesDirectory
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ internal interface MatrixComponent {
@CacheDirectory
fun cacheDir(): File

@ExternalFilesDirectory
fun externalFilesDir(): File?

fun olmManager(): OlmManager

fun taskExecutor(): TaskExecutor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ internal object MatrixModule {
return context.cacheDir
}

@JvmStatic
@Provides
@ExternalFilesDirectory
fun providesExternalFilesDir(context: Context): File? {
return context.getExternalFilesDir(null)
}

@JvmStatic
@Provides
@MatrixScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

// This BroadcastReceiver is used only if the build code is below 24.
@file:Suppress("DEPRECATION")

package im.vector.matrix.android.internal.network

import android.content.BroadcastReceiver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package im.vector.matrix.android.internal.session

import android.os.Environment
import arrow.core.Try
import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.session.content.ContentUrlResolver
Expand All @@ -25,6 +24,7 @@ import im.vector.matrix.android.api.util.Cancelable
import im.vector.matrix.android.internal.crypto.attachments.ElementToDecrypt
import im.vector.matrix.android.internal.crypto.attachments.MXEncryptedAttachments
import im.vector.matrix.android.internal.di.CacheDirectory
import im.vector.matrix.android.internal.di.ExternalFilesDirectory
import im.vector.matrix.android.internal.di.SessionCacheDirectory
import im.vector.matrix.android.internal.di.Unauthenticated
import im.vector.matrix.android.internal.extensions.foldToCallback
Expand All @@ -44,6 +44,8 @@ import javax.inject.Inject
internal class DefaultFileService @Inject constructor(
@CacheDirectory
private val cacheDirectory: File,
@ExternalFilesDirectory
private val externalFilesDirectory: File?,
@SessionCacheDirectory
private val sessionCacheDirectory: File,
private val contentUrlResolver: ContentUrlResolver,
Expand Down Expand Up @@ -103,7 +105,7 @@ internal class DefaultFileService @Inject constructor(
private fun copyFile(file: File, downloadMode: FileService.DownloadMode): File {
return when (downloadMode) {
FileService.DownloadMode.TO_EXPORT ->
file.copyTo(File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), file.name), true)
file.copyTo(File(externalFilesDirectory, file.name), true)
FileService.DownloadMode.FOR_EXTERNAL_SHARE ->
file.copyTo(File(File(cacheDirectory, "ext_share"), file.name), true)
FileService.DownloadMode.FOR_INTERNAL_USE ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ internal class Debouncer(private val handler: Handler) {
private val runnables = HashMap<String, Runnable>()

fun debounce(identifier: String, r: Runnable, millis: Long): Boolean {
if (runnables.containsKey(identifier)) {
// debounce
val old = runnables[identifier]
handler.removeCallbacks(old)
}
// debounce
runnables[identifier]?.let { runnable -> handler.removeCallbacks(runnable) }

insertRunnable(identifier, r, millis)
return true
}
Expand Down
2 changes: 1 addition & 1 deletion tools/release/sign_apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PARAM_KEYSTORE_PATH=$1
PARAM_APK=$2

# Other params
BUILD_TOOLS_VERSION="28.0.3"
BUILD_TOOLS_VERSION="29.0.3"
MIN_SDK_VERSION=19

echo "Signing APK with build-tools version ${BUILD_TOOLS_VERSION} for min SDK version ${MIN_SDK_VERSION}..."
Expand Down
4 changes: 2 additions & 2 deletions vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ ext.abiVersionCodes = ["armeabi-v7a": 1, "arm64-v8a": 2, "x86": 3, "x86_64": 4].
def buildNumber = System.env.BUILDKITE_BUILD_NUMBER as Integer ?: 0

android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "im.vector.riotx"
// Set to API 19 because motionLayout is min API 18.
// In the future we may consider using an alternative of MotionLayout to support API 16. But for security reason, maybe not.
minSdkVersion 19
targetSdkVersion 28
targetSdkVersion 29
multiDexEnabled true

// `develop` branch will have version code from timestamp, to ensure each build from CI has a incremented versionCode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import android.preference.PreferenceManager
import androidx.preference.PreferenceManager
import androidx.core.content.edit
import im.vector.riotx.core.utils.lsFiles
import timber.log.Timber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package im.vector.riotx.push.fcm

import android.app.Activity
import android.content.Context
import android.preference.PreferenceManager
import androidx.preference.PreferenceManager
import android.widget.Toast
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
Expand Down
2 changes: 1 addition & 1 deletion vector/src/main/java/im/vector/riotx/VectorApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class VectorApplication : Application(), HasVectorInjector, MatrixConfiguration.
MultiDex.install(this)
}

override fun onConfigurationChanged(newConfig: Configuration?) {
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
vectorConfiguration.onConfigurationChanged()
}
Expand Down
23 changes: 20 additions & 3 deletions vector/src/main/java/im/vector/riotx/core/files/FileSaver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
package im.vector.riotx.core.files

import android.app.DownloadManager
import android.content.ContentValues
import android.content.Context
import android.os.Build
import android.provider.MediaStore
import androidx.annotation.WorkerThread
import arrow.core.Try
import okio.buffer
Expand Down Expand Up @@ -54,10 +57,24 @@ fun addEntryToDownloadManager(context: Context,
mimeType: String,
title: String = file.name,
description: String = file.name) {
val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager?

try {
downloadManager?.addCompletedDownload(title, description, true, mimeType, file.absolutePath, file.length(), true)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val contentValues = ContentValues().apply {
put(MediaStore.Downloads.TITLE, title)
put(MediaStore.Downloads.DISPLAY_NAME, description)
put(MediaStore.Downloads.MIME_TYPE, mimeType)
put(MediaStore.Downloads.SIZE, file.length())
}
context.contentResolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues)?.let { uri ->
context.contentResolver.openOutputStream(uri)?.use { outputStream ->
outputStream.sink().buffer().write(file.inputStream().use { it.readBytes() })
}
}
} else {
val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager?
@Suppress("DEPRECATION")
downloadManager?.addCompletedDownload(title, description, true, mimeType, file.absolutePath, file.length(), true)
}
} catch (e: Exception) {
Timber.e(e, "## addEntryToDownloadManager(): Exception")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class VectorGlideDataFetcher(private val activeSessionHolder: ActiveSessionHolde

override fun loadData(priority: Priority, callback: DataFetcher.DataCallback<in InputStream>) {
Timber.v("Load data: $data")
if (data.isLocalFile()) {
if (data.isLocalFile() && data.url != null) {
val initialFile = File(data.url)
callback.onDataReady(FileInputStream(initialFile))
return
Expand Down
72 changes: 0 additions & 72 deletions vector/src/main/java/im/vector/riotx/core/images/ImageTools.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class EllipsizingTextView @JvmOverloads constructor(context: Context, attrs: Att
* @param workingText text to strip end punctuation from
* @return Text without end punctuation.
*/
fun stripEndPunctuation(workingText: CharSequence?): String {
fun stripEndPunctuation(workingText: CharSequence): String {
return mEndPunctPattern!!.matcher(workingText).replaceFirst("")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), HasScreenInjector {
restorables.forEach { it.onSaveInstanceState(outState) }
}

override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
restorables.forEach { it.onRestoreInstanceState(savedInstanceState) }
super.onRestoreInstanceState(savedInstanceState)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ class CallService : VectorService() {
* Display a call in progress notification.
*/
private fun displayCallInProgressNotification(intent: Intent) {
val callId = intent.getStringExtra(EXTRA_CALL_ID)
val callId = intent.getStringExtra(EXTRA_CALL_ID) ?: ""

val notification = notificationUtils.buildPendingCallNotification(
intent.getBooleanExtra(EXTRA_IS_VIDEO, false),
intent.getStringExtra(EXTRA_ROOM_NAME),
intent.getStringExtra(EXTRA_ROOM_ID),
intent.getStringExtra(EXTRA_MATRIX_ID),
intent.getStringExtra(EXTRA_ROOM_NAME) ?: "",
intent.getStringExtra(EXTRA_ROOM_ID) ?: "",
intent.getStringExtra(EXTRA_MATRIX_ID) ?: "",
callId)

startForeground(NOTIFICATION_ID, notification)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package im.vector.riotx.core.ui.views

import android.content.Context
import android.preference.PreferenceManager
import androidx.preference.PreferenceManager
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
Expand Down
7 changes: 4 additions & 3 deletions vector/src/main/java/im/vector/riotx/core/utils/Debouncer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class Debouncer(private val handler: Handler) {

fun cancel(identifier: String) {
if (runnables.containsKey(identifier)) {
val old = runnables[identifier]
handler.removeCallbacks(old)
runnables.remove(identifier)
runnables[identifier]?.let {
handler.removeCallbacks(it)
runnables.remove(identifier)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private fun logAction(file: File): Boolean {
*/
private fun recursiveActionOnFile(file: File, action: ActionOnFile): Boolean {
if (file.isDirectory) {
file.list().forEach {
file.list()?.forEach {
val result = recursiveActionOnFile(File(file, it), action)

if (!result) {
Expand Down
Loading

0 comments on commit c57fa3f

Please sign in to comment.