Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase targetSdk to 29 #1176

Merged
merged 20 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Features ✨:

Improvements 🙌:
- Verification DM / Handle concurrent .start after .ready (#794)
- Reimplementation of multiple attachment picker
- CrossSigning / Update Shield Logic for DM (#963)
- Xsigning | Complete security new session design update (#1135)

Expand All @@ -19,7 +20,7 @@ Translations 🗣:
-

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

Build 🧱:
-
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,8 @@
* limitations under the License.
*/

@file:Suppress("DEPRECATION")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment explaining why we ignore warning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the comment, but it is not marked as "outdated". Please see "Files Changed" section.


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 @@ -25,8 +25,9 @@ internal class Debouncer(private val handler: Handler) {
fun debounce(identifier: String, r: Runnable, millis: Long): Boolean {
if (runnables.containsKey(identifier)) {
// debounce
val old = runnables[identifier]
handler.removeCallbacks(old)
runnables[identifier]?.let {
handler.removeCallbacks(it)
}
}
insertRunnable(identifier, r, millis)
return true
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
17 changes: 13 additions & 4 deletions vector/src/main/java/im/vector/riotx/core/files/FileSaver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

package im.vector.riotx.core.files

import android.app.DownloadManager
import android.content.ContentValues
import android.content.Context
import android.provider.MediaStore
import androidx.annotation.WorkerThread
import arrow.core.Try
import okio.buffer
Expand Down Expand Up @@ -54,10 +55,18 @@ 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)
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() })
}
}
} 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import android.content.Context
import android.media.Ringtone
import android.media.RingtoneManager
import android.net.Uri
import android.preference.PreferenceManager
import androidx.preference.PreferenceManager
import androidx.core.content.edit
import im.vector.riotx.features.settings.VectorPreferences

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fun requestDisablingBatteryOptimization(activity: Activity, fragment: Fragment?,
*/
fun copyToClipboard(context: Context, text: CharSequence, showToast: Boolean = true, @StringRes toastMessage: Int = R.string.copied_to_clipboard) {
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.primaryClip = ClipData.newPlainText("", text)
clipboard.setPrimaryClip(ClipData.newPlainText("", text))
if (showToast) {
context.toast(toastMessage)
}
Expand Down
4 changes: 2 additions & 2 deletions vector/src/main/java/im/vector/riotx/core/utils/TextUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ object TextUtils {
if (value < 1000) return value.toString() // deal with easy case

val e = suffixes.floorEntry(value)
val divideBy = e.key
val suffix = e.value
val divideBy = e?.key
val suffix = e?.value

val truncated = value / (divideBy!! / 10) // the number part of the output times 10
val hasDecimal = truncated < 100 && truncated / 10.0 != (truncated / 10).toDouble()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AttachmentsPreviewActivity : VectorBaseActivity(), ToolbarConfigurable {
}

fun getOutput(intent: Intent): List<ContentAttachmentData> {
return intent.getParcelableArrayListExtra(ATTACHMENTS_PREVIEW_RESULT)
return intent.getParcelableArrayListExtra(ATTACHMENTS_PREVIEW_RESULT) ?: emptyList()
}

fun getKeepOriginalSize(intent: Intent): Boolean {
Expand Down
Loading