diff --git a/CHANGES.md b/CHANGES.md index a49507b516..6c536503c6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -32,6 +32,7 @@ Other changes: - Rename package `im.vector.riotx.attachmentviewer` to `im.vector.lib.attachmentviewer` - Rename package `im.vector.riotx.multipicker` to `im.vector.lib.multipicker` - Rename package `im.vector.riotx` to `im.vector.app` + - Remove old code that was used on devices with api level <21 Changes in Element 1.0.4 (2020-08-03) =================================================== diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/Helper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/Helper.kt index 98098686cc..978c82303e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/Helper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/Helper.kt @@ -18,7 +18,6 @@ package org.matrix.android.sdk.internal.crypto.store.db import android.util.Base64 -import org.matrix.android.sdk.internal.util.CompatUtil import io.realm.Realm import io.realm.RealmConfiguration import io.realm.RealmObject @@ -26,6 +25,7 @@ import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.ObjectOutputStream import java.util.zip.GZIPInputStream +import java.util.zip.GZIPOutputStream /** * Get realm, invoke the action, close realm, and return the result of the action @@ -78,7 +78,7 @@ fun serializeForRealm(o: Any?): String? { } val baos = ByteArrayOutputStream() - val gzis = CompatUtil.createGzipOutputStream(baos) + val gzis = GZIPOutputStream(baos) val out = ObjectOutputStream(gzis) out.use { it.writeObject(o) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt index 0d898e46ce..2ae115f325 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt @@ -44,10 +44,7 @@ import javax.crypto.CipherInputStream import javax.crypto.CipherOutputStream import javax.crypto.KeyGenerator import javax.crypto.SecretKey -import javax.crypto.SecretKeyFactory import javax.crypto.spec.GCMParameterSpec -import javax.crypto.spec.IvParameterSpec -import javax.crypto.spec.PBEKeySpec import javax.crypto.spec.SecretKeySpec import javax.inject.Inject import javax.security.auth.x500.X500Principal @@ -127,9 +124,8 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte @Throws(Exception::class) fun securelyStoreString(secret: String, keyAlias: String): ByteArray? { return when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> encryptStringM(secret, keyAlias) - Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT -> encryptStringK(secret, keyAlias) - else -> encryptForOldDevicesNotGood(secret, keyAlias) + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> encryptStringM(secret, keyAlias) + else -> encryptString(secret, keyAlias) } } @@ -139,25 +135,22 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte @Throws(Exception::class) fun loadSecureSecret(encrypted: ByteArray, keyAlias: String): String? { return when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> decryptStringM(encrypted, keyAlias) - Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT -> decryptStringK(encrypted, keyAlias) - else -> decryptForOldDevicesNotGood(encrypted, keyAlias) + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> decryptStringM(encrypted, keyAlias) + else -> decryptString(encrypted, keyAlias) } } fun securelyStoreObject(any: Any, keyAlias: String, output: OutputStream) { when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> saveSecureObjectM(keyAlias, output, any) - Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT -> saveSecureObjectK(keyAlias, output, any) - else -> saveSecureObjectOldNotGood(keyAlias, output, any) + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> saveSecureObjectM(keyAlias, output, any) + else -> saveSecureObject(keyAlias, output, any) } } fun loadSecureSecret(inputStream: InputStream, keyAlias: String): T? { return when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> loadSecureObjectM(keyAlias, inputStream) - Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT -> loadSecureObjectK(keyAlias, inputStream) - else -> loadSecureObjectOldNotGood(keyAlias, inputStream) + Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> loadSecureObjectM(keyAlias, inputStream) + else -> loadSecureObject(keyAlias, inputStream) } } @@ -188,7 +181,6 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte - Store the encrypted AES Generate a key pair for encryption */ - @RequiresApi(Build.VERSION_CODES.KITKAT) fun getOrGenerateKeyPairForAlias(alias: String): KeyStore.PrivateKeyEntry { val privateKeyEntry = (keyStore.getEntry(alias, null) as? KeyStore.PrivateKeyEntry) @@ -238,8 +230,7 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte return String(cipher.doFinal(encryptedText), Charsets.UTF_8) } - @RequiresApi(Build.VERSION_CODES.KITKAT) - private fun encryptStringK(text: String, keyAlias: String): ByteArray? { + private fun encryptString(text: String, keyAlias: String): ByteArray? { // we generate a random symmetric key val key = ByteArray(16) secureRandom.nextBytes(key) @@ -256,47 +247,13 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte return format1Make(encryptedKey, iv, encryptedBytes) } - private fun encryptForOldDevicesNotGood(text: String, keyAlias: String): ByteArray { - val salt = ByteArray(8) - secureRandom.nextBytes(salt) - val factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256") - val spec = PBEKeySpec(keyAlias.toCharArray(), salt, 10000, 128) - val tmp = factory.generateSecret(spec) - val sKey = SecretKeySpec(tmp.encoded, "AES") - - val cipher = Cipher.getInstance(AES_MODE) - cipher.init(Cipher.ENCRYPT_MODE, sKey) - val iv = cipher.iv - val encryptedBytes: ByteArray = cipher.doFinal(text.toByteArray(Charsets.UTF_8)) - - return format2Make(salt, iv, encryptedBytes) - } - - private fun decryptForOldDevicesNotGood(data: ByteArray, keyAlias: String): String? { - val (salt, iv, encrypted) = format2Extract(ByteArrayInputStream(data)) - val factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256") - val spec = PBEKeySpec(keyAlias.toCharArray(), salt, 10_000, 128) - val tmp = factory.generateSecret(spec) - val sKey = SecretKeySpec(tmp.encoded, "AES") - - val cipher = Cipher.getInstance(AES_MODE) -// cipher.init(Cipher.ENCRYPT_MODE, sKey) -// val encryptedBytes: ByteArray = cipher.doFinal(text.toByteArray(Charsets.UTF_8)) - - val specIV = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) IvParameterSpec(iv) else GCMParameterSpec(128, iv) - cipher.init(Cipher.DECRYPT_MODE, sKey, specIV) - - return String(cipher.doFinal(encrypted), Charsets.UTF_8) - } - - @RequiresApi(Build.VERSION_CODES.KITKAT) - private fun decryptStringK(data: ByteArray, keyAlias: String): String? { + private fun decryptString(data: ByteArray, keyAlias: String): String? { val (encryptedKey, iv, encrypted) = format1Extract(ByteArrayInputStream(data)) // we need to decrypt the key val sKeyBytes = rsaDecrypt(keyAlias, ByteArrayInputStream(encryptedKey)) val cipher = Cipher.getInstance(AES_MODE) - val spec = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) IvParameterSpec(iv) else GCMParameterSpec(128, iv) + val spec = GCMParameterSpec(128, iv) cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(sKeyBytes, "AES"), spec) return String(cipher.doFinal(encrypted), Charsets.UTF_8) @@ -323,8 +280,7 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte output.write(doFinal) } - @RequiresApi(Build.VERSION_CODES.KITKAT) - private fun saveSecureObjectK(keyAlias: String, output: OutputStream, writeObject: Any) { + private fun saveSecureObject(keyAlias: String, output: OutputStream, writeObject: Any) { // we generate a random symmetric key val key = ByteArray(16) secureRandom.nextBytes(key) @@ -352,32 +308,6 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte output.write(bos1.toByteArray()) } - private fun saveSecureObjectOldNotGood(keyAlias: String, output: OutputStream, writeObject: Any) { - val salt = ByteArray(8) - secureRandom.nextBytes(salt) - val factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256") - val tmp = factory.generateSecret(PBEKeySpec(keyAlias.toCharArray(), salt, 10000, 128)) - val secretKey = SecretKeySpec(tmp.encoded, "AES") - - val cipher = Cipher.getInstance(AES_MODE) - cipher.init(Cipher.ENCRYPT_MODE, secretKey) - val iv = cipher.iv - - val bos1 = ByteArrayOutputStream() - ObjectOutputStream(bos1).use { - it.writeObject(writeObject) - } - // Have to do it like that if i encapsulate the output stream, the cipher could fail saying reuse IV - val doFinal = cipher.doFinal(bos1.toByteArray()) - - output.write(FORMAT_2.toInt()) - output.write(salt.size) - output.write(salt) - output.write(iv.size) - output.write(iv) - output.write(doFinal) - } - // @RequiresApi(Build.VERSION_CODES.M) // @Throws(IOException::class) // fun saveSecureObjectM(keyAlias: String, file: File, writeObject: Any) { @@ -418,15 +348,14 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte } } - @RequiresApi(Build.VERSION_CODES.KITKAT) @Throws(IOException::class) - private fun loadSecureObjectK(keyAlias: String, inputStream: InputStream): T? { + private fun loadSecureObject(keyAlias: String, inputStream: InputStream): T? { val (encryptedKey, iv, encrypted) = format1Extract(inputStream) // we need to decrypt the key val sKeyBytes = rsaDecrypt(keyAlias, ByteArrayInputStream(encryptedKey)) val cipher = Cipher.getInstance(AES_MODE) - val spec = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) IvParameterSpec(iv) else GCMParameterSpec(128, iv) + val spec = GCMParameterSpec(128, iv) cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(sKeyBytes, "AES"), spec) val encIS = ByteArrayInputStream(encrypted) @@ -440,31 +369,6 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte } } - @Throws(Exception::class) - private fun loadSecureObjectOldNotGood(keyAlias: String, inputStream: InputStream): T? { - val (salt, iv, encrypted) = format2Extract(inputStream) - - val factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256") - val tmp = factory.generateSecret(PBEKeySpec(keyAlias.toCharArray(), salt, 10000, 128)) - val sKey = SecretKeySpec(tmp.encoded, "AES") - // we need to decrypt the key - - val cipher = Cipher.getInstance(AES_MODE) - val spec = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) IvParameterSpec(iv) else GCMParameterSpec(128, iv) - cipher.init(Cipher.DECRYPT_MODE, sKey, spec) - - val encIS = ByteArrayInputStream(encrypted) - - CipherInputStream(encIS, cipher).use { - ObjectInputStream(it).use { ois -> - val readObject = ois.readObject() - @Suppress("UNCHECKED_CAST") - return readObject as? T - } - } - } - - @RequiresApi(Build.VERSION_CODES.KITKAT) @Throws(Exception::class) private fun rsaEncrypt(alias: String, secret: ByteArray): ByteArray { val privateKeyEntry = getOrGenerateKeyPairForAlias(alias) @@ -480,7 +384,6 @@ internal class SecretStoringUtils @Inject constructor(private val context: Conte return outputStream.toByteArray() } - @RequiresApi(Build.VERSION_CODES.KITKAT) @Throws(Exception::class) private fun rsaDecrypt(alias: String, encrypted: InputStream): ByteArray { val privateKeyEntry = getOrGenerateKeyPairForAlias(alias) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt index 0f8f2c1f94..395484433b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/widgets/DefaultWidgetPostAPIMediator.kt @@ -17,7 +17,6 @@ package org.matrix.android.sdk.internal.session.widgets -import android.os.Build import android.webkit.JavascriptInterface import android.webkit.WebView import com.squareup.moshi.Moshi @@ -172,11 +171,7 @@ internal class DefaultWidgetPostAPIMediator @Inject constructor(private val mosh val functionLine = "sendResponseFromRiotAndroid('" + eventData["_id"] + "' , " + jsString + ");" Timber.v("BRIDGE sendResponse: $functionLine") // call the javascript method - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - webView?.loadUrl("javascript:$functionLine") - } else { - webView?.evaluateJavascript(functionLine, null) - } + webView?.evaluateJavascript(functionLine, null) } catch (e: Exception) { Timber.e(e, "## sendResponse() failed ") } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CompatUtil.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CompatUtil.kt index 0836d96af9..6583dc89ea 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CompatUtil.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/CompatUtil.kt @@ -27,7 +27,6 @@ import android.security.KeyPairGeneratorSpec import android.security.keystore.KeyGenParameterSpec import android.security.keystore.KeyProperties import android.util.Base64 -import androidx.annotation.RequiresApi import androidx.core.content.edit import timber.log.Timber import java.io.IOException @@ -48,7 +47,6 @@ import java.security.cert.CertificateException import java.security.spec.AlgorithmParameterSpec import java.security.spec.RSAKeyGenParameterSpec import java.util.Calendar -import java.util.zip.GZIPOutputStream import javax.crypto.Cipher import javax.crypto.CipherInputStream import javax.crypto.CipherOutputStream @@ -82,22 +80,6 @@ object CompatUtil { */ private val prng: SecureRandom by lazy(LazyThreadSafetyMode.NONE) { SecureRandom() } - /** - * Create a GZIPOutputStream instance - * Special treatment on KitKat device, force the syncFlush param to false - * Before Kitkat, this param does not exist and after Kitkat it is set to false by default - * - * @param outputStream the output stream - */ - @Throws(IOException::class) - fun createGzipOutputStream(outputStream: OutputStream): GZIPOutputStream { - return if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { - GZIPOutputStream(outputStream, false) - } else { - GZIPOutputStream(outputStream) - } - } - /** * Returns the AES key used for local storage encryption/decryption with AES/GCM. * The key is created if it does not exist already in the keystore. @@ -107,7 +89,6 @@ object CompatUtil { * * @param context the context holding the application shared preferences */ - @RequiresApi(Build.VERSION_CODES.KITKAT) @Synchronized @Throws(KeyStoreException::class, CertificateException::class, @@ -249,10 +230,6 @@ object CompatUtil { KeyStoreException::class, IllegalBlockSizeException::class) fun createCipherOutputStream(out: OutputStream, context: Context): OutputStream? { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return out - } - val keyAndVersion = getAesGcmLocalProtectionKey(context) val cipher = Cipher.getInstance(AES_GCM_CIPHER_TYPE) @@ -298,10 +275,6 @@ object CompatUtil { InvalidAlgorithmParameterException::class, IOException::class) fun createCipherInputStream(`in`: InputStream, context: Context): InputStream? { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return `in` - } - val iv_len = `in`.read() if (iv_len != AES_GCM_IV_LENGTH) { Timber.e(TAG, "Invalid IV length $iv_len") diff --git a/vector/src/main/java/im/vector/app/core/hardware/HardwareInfo.kt b/vector/src/main/java/im/vector/app/core/hardware/HardwareInfo.kt index dac9102a93..a9aa7be267 100644 --- a/vector/src/main/java/im/vector/app/core/hardware/HardwareInfo.kt +++ b/vector/src/main/java/im/vector/app/core/hardware/HardwareInfo.kt @@ -22,7 +22,6 @@ import android.content.Context import android.hardware.Camera import android.hardware.camera2.CameraCharacteristics import android.hardware.camera2.CameraManager -import android.os.Build import androidx.core.content.getSystemService import javax.inject.Inject @@ -33,10 +32,6 @@ class HardwareInfo @Inject constructor( * Tell if the device has a back (or external) camera */ fun hasBackCamera(): Boolean { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - return Camera.getNumberOfCameras() > 0 - } - val manager = context.getSystemService() ?: return Camera.getNumberOfCameras() > 0 return manager.cameraIdList.any { diff --git a/vector/src/main/java/im/vector/app/core/intent/ExternalIntentAnalyser.kt b/vector/src/main/java/im/vector/app/core/intent/ExternalIntentAnalyser.kt index 44bc842447..24e03b4f40 100644 --- a/vector/src/main/java/im/vector/app/core/intent/ExternalIntentAnalyser.kt +++ b/vector/src/main/java/im/vector/app/core/intent/ExternalIntentAnalyser.kt @@ -20,7 +20,6 @@ import android.content.ClipData import android.content.ClipDescription import android.content.Intent import android.net.Uri -import android.os.Build import androidx.core.util.PatternsCompat.WEB_URL /** @@ -87,13 +86,9 @@ fun analyseIntent(intent: Intent): List { } } - var clipData: ClipData? = null + val clipData: ClipData? = intent.clipData var mimeTypes: List? = null - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - clipData = intent.clipData - } - // multiple data if (null != clipData) { if (null != clipData.description) { diff --git a/vector/src/main/java/im/vector/app/core/ui/views/BottomSheetActionButton.kt b/vector/src/main/java/im/vector/app/core/ui/views/BottomSheetActionButton.kt index 193f57f96b..0259898ee3 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/BottomSheetActionButton.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/BottomSheetActionButton.kt @@ -19,7 +19,6 @@ package im.vector.app.core.ui.views import android.content.Context import android.content.res.ColorStateList import android.graphics.drawable.Drawable -import android.os.Build import android.util.AttributeSet import android.view.View import android.widget.FrameLayout @@ -105,13 +104,7 @@ class BottomSheetActionButton @JvmOverloads constructor( var tint: Int? = null set(value) { field = value - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - leftIconImageView.imageTintList = value?.let { ColorStateList.valueOf(value) } - } else { - leftIcon?.let { - leftIcon = ThemeUtils.tintDrawable(context, it, value ?: ThemeUtils.getColor(context, android.R.attr.textColor)) - } - } + leftIconImageView.imageTintList = value?.let { ColorStateList.valueOf(value) } } init { diff --git a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt index bb4fe38390..5ea3d54e6d 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt @@ -134,9 +134,7 @@ fun openFileSelection(activity: Activity, allowMultipleSelection: Boolean, requestCode: Int) { val fileIntent = Intent(Intent.ACTION_GET_CONTENT) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - fileIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultipleSelection) - } + fileIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, allowMultipleSelection) fileIntent.addCategory(Intent.CATEGORY_OPENABLE) fileIntent.type = "*/*" diff --git a/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt b/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt index 1f2263889c..0e722da34a 100644 --- a/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt +++ b/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt @@ -101,15 +101,10 @@ fun startNotificationSettingsIntent(activity: AppCompatActivity, requestCode: In if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS intent.putExtra(Settings.EXTRA_APP_PACKAGE, activity.packageName) - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + } else { intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS intent.putExtra("app_package", activity.packageName) intent.putExtra("app_uid", activity.applicationInfo?.uid) - } else { - intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS - intent.addCategory(Intent.CATEGORY_DEFAULT) - val uri = Uri.fromParts("package", activity.packageName, null) - intent.data = uri } activity.startActivityForResult(intent, requestCode) } @@ -140,11 +135,7 @@ fun startAddGoogleAccountIntent(context: AppCompatActivity, requestCode: Int) { fun startSharePlainTextIntent(fragment: Fragment, chooserTitle: String?, text: String, subject: String? = null, requestCode: Int? = null) { val share = Intent(Intent.ACTION_SEND) share.type = "text/plain" - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - share.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT) - } else { - share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) - } + share.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT) // Add data to the intent, the receiving app will decide what to do with it. share.putExtra(Intent.EXTRA_SUBJECT, subject) share.putExtra(Intent.EXTRA_TEXT, text) diff --git a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt index fa35ac3fd8..1d6ea7339d 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt @@ -18,10 +18,8 @@ package im.vector.app.features.attachments import android.animation.Animator import android.animation.AnimatorListenerAdapter -import android.annotation.TargetApi import android.content.Context import android.graphics.drawable.BitmapDrawable -import android.os.Build import android.util.Pair import android.view.Gravity import android.view.LayoutInflater @@ -109,25 +107,19 @@ class AttachmentTypeSelectorView(context: Context, showAtLocation(anchor, Gravity.NO_GRAVITY, 0, anchorCoordinates[1] - contentViewHeight) } contentView.doOnNextLayout { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - animateWindowInCircular(anchor, contentView) - } else { - animateWindowInTranslate(contentView) - } - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - animateButtonIn(galleryButton, ANIMATION_DURATION / 2) - animateButtonIn(cameraButton, ANIMATION_DURATION / 2) - animateButtonIn(fileButton, ANIMATION_DURATION / 4) - animateButtonIn(audioButton, ANIMATION_DURATION / 2) - animateButtonIn(contactButton, ANIMATION_DURATION / 4) - animateButtonIn(stickersButton, 0) + animateWindowInCircular(anchor, contentView) } + animateButtonIn(galleryButton, ANIMATION_DURATION / 2) + animateButtonIn(cameraButton, ANIMATION_DURATION / 2) + animateButtonIn(fileButton, ANIMATION_DURATION / 4) + animateButtonIn(audioButton, ANIMATION_DURATION / 2) + animateButtonIn(contactButton, ANIMATION_DURATION / 4) + animateButtonIn(stickersButton, 0) } override fun dismiss() { val capturedAnchor = anchor - if (capturedAnchor != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (capturedAnchor != null) { animateWindowOutCircular(capturedAnchor, contentView) } else { animateWindowOutTranslate(contentView) @@ -144,7 +136,6 @@ class AttachmentTypeSelectorView(context: Context, button.startAnimation(animation) } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) private fun animateWindowInCircular(anchor: View, contentView: View) { val coordinates = getClickCoordinates(anchor, contentView) val animator = ViewAnimationUtils.createCircularReveal(contentView, @@ -162,7 +153,6 @@ class AttachmentTypeSelectorView(context: Context, getContentView().startAnimation(animation) } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) private fun animateWindowOutCircular(anchor: View, contentView: View) { val coordinates = getClickCoordinates(anchor, contentView) val animator = ViewAnimationUtils.createCircularReveal(getContentView(), diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt index ba171b9937..4d6c4e3add 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt @@ -23,7 +23,6 @@ import android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP import android.os.Build import android.os.Bundle import android.os.Parcelable -import android.view.KeyEvent import android.view.View import android.view.Window import android.view.WindowManager @@ -334,20 +333,6 @@ class VectorCallActivity : VectorBaseActivity(), CallControlsView.InteractionLis surfaceRenderersAreInitialized = true } - override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - // for newer version, it will be passed automatically to active media session - // in call service - when (keyCode) { - KeyEvent.KEYCODE_HEADSETHOOK -> { - callViewModel.handle(VectorCallViewActions.HeadSetButtonPressed) - return true - } - } - } - return super.onKeyDown(keyCode, event) - } - private fun handleViewEvents(event: VectorCallViewEvents?) { Timber.v("## VOIP handleViewEvents $event") when (event) { diff --git a/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt b/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt index cfebafb04e..bb6312a8ce 100644 --- a/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/WebRtcPeerConnectionManager.kt @@ -18,8 +18,6 @@ package im.vector.app.features.call import android.content.Context import android.hardware.camera2.CameraManager -import android.os.Build -import androidx.annotation.RequiresApi import androidx.core.content.getSystemService import im.vector.app.ActiveSessionDataSource import im.vector.app.core.services.BluetoothHeadsetReceiver @@ -363,11 +361,6 @@ class WebRtcPeerConnectionManager @Inject constructor( } } else -> { - // Fallback for old android, try to restart capture when attached - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && capturerIsInError && call.mxCall.isVideoCall) { - // try to restart capture? - videoCapturer?.startCapture(currentCaptureMode.width, currentCaptureMode.height, currentCaptureMode.fps) - } // sink existing tracks (configuration change, e.g screen rotation) attachViewRenderersInternal() } @@ -478,12 +471,10 @@ class WebRtcPeerConnectionManager @Inject constructor( // We then register in order to restart capture as soon as the camera is available again Timber.v("## VOIP onCameraClosed") this@WebRtcPeerConnectionManager.capturerIsInError = true - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - val restarter = CameraRestarter(cameraInUse?.name ?: "", callContext.mxCall.callId) - callContext.cameraAvailabilityCallback = restarter - val cameraManager = context.getSystemService()!! - cameraManager.registerAvailabilityCallback(restarter, null) - } + val restarter = CameraRestarter(cameraInUse?.name ?: "", callContext.mxCall.callId) + callContext.cameraAvailabilityCallback = restarter + val cameraManager = context.getSystemService()!! + cameraManager.registerAvailabilityCallback(restarter, null) } }) @@ -792,10 +783,8 @@ class WebRtcPeerConnectionManager @Inject constructor( currentCall?.localVideoTrack?.setEnabled(false) currentCall?.cameraAvailabilityCallback?.let { cameraAvailabilityCallback -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - val cameraManager = context.getSystemService()!! - cameraManager.unregisterAvailabilityCallback(cameraAvailabilityCallback) - } + val cameraManager = context.getSystemService()!! + cameraManager.unregisterAvailabilityCallback(cameraAvailabilityCallback) } if (originatedByMe) { @@ -1041,7 +1030,6 @@ class WebRtcPeerConnectionManager @Inject constructor( } } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) inner class CameraRestarter(val cameraId: String, val callId: String) : CameraManager.AvailabilityCallback() { override fun onCameraAvailable(cameraId: String) { diff --git a/vector/src/main/java/im/vector/app/features/configuration/VectorConfiguration.kt b/vector/src/main/java/im/vector/app/features/configuration/VectorConfiguration.kt index 312e0a01ea..5567a138de 100644 --- a/vector/src/main/java/im/vector/app/features/configuration/VectorConfiguration.kt +++ b/vector/src/main/java/im/vector/app/features/configuration/VectorConfiguration.kt @@ -82,9 +82,7 @@ class VectorConfiguration @Inject constructor(private val context: Context) { } else { @Suppress("DEPRECATION") configuration.locale = locale - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - configuration.setLayoutDirection(locale) - } + configuration.setLayoutDirection(locale) @Suppress("DEPRECATION") resources.updateConfiguration(configuration, resources.displayMetrics) return context diff --git a/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt b/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt index 978850d788..c6658925af 100644 --- a/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt @@ -16,7 +16,6 @@ package im.vector.app.features.login -import android.os.Build import android.os.Bundle import android.view.View import androidx.annotation.CallSuper @@ -48,9 +47,7 @@ abstract class AbstractLoginFragment : VectorBaseFragment(), OnBackPressed { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move) - } + sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move) } @CallSuper diff --git a/vector/src/main/java/im/vector/app/features/login/LoginWebFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginWebFragment.kt index a2659316eb..6d943fd99f 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginWebFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginWebFragment.kt @@ -22,7 +22,6 @@ import android.annotation.SuppressLint import android.content.DialogInterface import android.graphics.Bitmap import android.net.http.SslError -import android.os.Build import android.os.Bundle import android.view.KeyEvent import android.view.View @@ -102,14 +101,6 @@ class LoginWebFragment @Inject constructor( launchWebView(state) } else { if (!cookieManager.hasCookies()) { - launchWebView(state) - } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - try { - cookieManager.removeAllCookie() - } catch (e: Exception) { - Timber.e(e, " cookieManager.removeAllCookie() fails") - } - launchWebView(state) } else { try { diff --git a/vector/src/main/java/im/vector/app/features/media/ImageMediaViewerActivity.kt b/vector/src/main/java/im/vector/app/features/media/ImageMediaViewerActivity.kt index 4482990d93..fa7f397b8f 100644 --- a/vector/src/main/java/im/vector/app/features/media/ImageMediaViewerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/media/ImageMediaViewerActivity.kt @@ -19,12 +19,10 @@ package im.vector.app.features.media import android.content.Context import android.content.Intent import android.graphics.drawable.Drawable -import android.os.Build import android.os.Bundle import android.view.MenuItem import android.view.View import android.view.ViewTreeObserver -import androidx.annotation.RequiresApi import androidx.appcompat.widget.Toolbar import androidx.core.net.toUri import androidx.core.transition.addListener @@ -84,7 +82,7 @@ class ImageMediaViewerActivity : VectorBaseActivity() { configureToolbar(imageMediaViewerToolbar, mediaData) - if (isFirstCreation() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && addTransitionListener()) { + if (isFirstCreation() && addTransitionListener()) { // Encrypted image imageTransitionView.isVisible = true imageMediaViewerImageView.isVisible = false @@ -183,7 +181,6 @@ class ImageMediaViewerActivity : VectorBaseActivity() { * * @return true if we were successful in adding a listener to the enter transition */ - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) private fun addTransitionListener(): Boolean { val transition = window.sharedElementEnterTransition diff --git a/vector/src/main/java/im/vector/app/features/reactions/EmojiDrawView.kt b/vector/src/main/java/im/vector/app/features/reactions/EmojiDrawView.kt index 1866ac4bba..fec185b1c3 100644 --- a/vector/src/main/java/im/vector/app/features/reactions/EmojiDrawView.kt +++ b/vector/src/main/java/im/vector/app/features/reactions/EmojiDrawView.kt @@ -20,6 +20,7 @@ import android.content.Context import android.graphics.Canvas import android.graphics.Color import android.graphics.Typeface +import android.os.Trace import android.text.StaticLayout import android.text.TextPaint import android.util.AttributeSet @@ -43,7 +44,7 @@ class EmojiDrawView @JvmOverloads constructor( var emoji: String? = null override fun onDraw(canvas: Canvas?) { - EmojiRecyclerAdapter.beginTraceSession("EmojiDrawView.onDraw") + Trace.beginSection("EmojiDrawView.onDraw") super.onDraw(canvas) canvas?.save() val space = abs((width - emojiSize) / 2f) @@ -52,7 +53,7 @@ class EmojiDrawView @JvmOverloads constructor( mLayout!!.draw(canvas) } canvas?.restore() - EmojiRecyclerAdapter.endTraceSession() + Trace.endSection() } companion object { diff --git a/vector/src/main/java/im/vector/app/features/reactions/EmojiRecyclerAdapter.kt b/vector/src/main/java/im/vector/app/features/reactions/EmojiRecyclerAdapter.kt index fcf1ab9b9c..92bc21be25 100644 --- a/vector/src/main/java/im/vector/app/features/reactions/EmojiRecyclerAdapter.kt +++ b/vector/src/main/java/im/vector/app/features/reactions/EmojiRecyclerAdapter.kt @@ -125,7 +125,7 @@ class EmojiRecyclerAdapter @Inject constructor( } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - beginTraceSession("MyAdapter.onCreateViewHolder") + Trace.beginSection("MyAdapter.onCreateViewHolder") val inflater = LayoutInflater.from(parent.context) val itemView = inflater.inflate(viewType, parent, false) itemView.setOnClickListener(itemClickListener) @@ -133,16 +133,16 @@ class EmojiRecyclerAdapter @Inject constructor( R.layout.grid_section_header -> SectionViewHolder(itemView) else -> EmojiViewHolder(itemView) } - endTraceSession() + Trace.endSection() return viewHolder } override fun getItemViewType(position: Int): Int { - beginTraceSession("MyAdapter.getItemViewType") + Trace.beginSection("MyAdapter.getItemViewType") if (isSection(position)) { return R.layout.grid_section_header } - endTraceSession() + Trace.endSection() return R.layout.grid_item_emoji } @@ -183,7 +183,7 @@ class EmojiRecyclerAdapter @Inject constructor( } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - beginTraceSession("MyAdapter.onBindViewHolder") + Trace.beginSection("MyAdapter.onBindViewHolder") val sectionNumber = getSectionForAbsoluteIndex(position) if (isSection(position)) { holder.bind(dataSource.rawData.categories[sectionNumber].name) @@ -202,7 +202,7 @@ class EmojiRecyclerAdapter @Inject constructor( holder.bind(null) } } - endTraceSession() + Trace.endSection() } override fun onViewRecycled(holder: ViewHolder) { @@ -259,18 +259,6 @@ class EmojiRecyclerAdapter @Inject constructor( } companion object { - fun endTraceSession() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - Trace.endSection() - } - } - - fun beginTraceSession(sectionName: String) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - Trace.beginSection(sectionName) - } - } - private val staticLayoutCache = HashMap() private fun getStaticLayoutForEmoji(emoji: String): StaticLayout { diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt index 57f80264d2..d2f92e300e 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorLocale.kt @@ -18,7 +18,6 @@ package im.vector.app.features.settings import android.content.Context import android.content.res.Configuration -import android.os.Build import androidx.core.content.edit import androidx.preference.PreferenceManager import im.vector.app.BuildConfig @@ -108,13 +107,11 @@ object VectorLocale { putString(APPLICATION_LOCALE_VARIANT_KEY, variant) } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - val script = locale.script - if (script.isEmpty()) { - remove(APPLICATION_LOCALE_SCRIPT_KEY) - } else { - putString(APPLICATION_LOCALE_SCRIPT_KEY, script) - } + val script = locale.script + if (script.isEmpty()) { + remove(APPLICATION_LOCALE_SCRIPT_KEY) + } else { + putString(APPLICATION_LOCALE_SCRIPT_KEY, script) } } } @@ -128,40 +125,15 @@ object VectorLocale { * @return the localized string */ private fun getString(context: Context, locale: Locale, resourceId: Int): String { - val result: String - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - val config = Configuration(context.resources.configuration) - config.setLocale(locale) - result = try { - context.createConfigurationContext(config).getText(resourceId).toString() - } catch (e: Exception) { - Timber.e(e, "## getString() failed") - // use the default one - context.getString(resourceId) - } - } else { - val resources = context.resources - val conf = resources.configuration - - @Suppress("DEPRECATION") - val savedLocale = conf.locale - @Suppress("DEPRECATION") - conf.locale = locale - @Suppress("DEPRECATION") - resources.updateConfiguration(conf, null) - - // retrieve resources from desired locale - result = resources.getString(resourceId) - - // restore original locale - @Suppress("DEPRECATION") - conf.locale = savedLocale - @Suppress("DEPRECATION") - resources.updateConfiguration(conf, null) + val config = Configuration(context.resources.configuration) + config.setLocale(locale) + return try { + context.createConfigurationContext(config).getText(resourceId).toString() + } catch (e: Exception) { + Timber.e(e, "## getString() failed") + // use the default one + context.getString(resourceId) } - - return result } /** @@ -194,22 +166,18 @@ object VectorLocale { } val list = knownLocalesSet.mapNotNull { (language, country, script) -> - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - try { - Locale.Builder() - .setLanguage(language) - .setRegion(country) - .setScript(script) - .build() - } catch (exception: IllformedLocaleException) { - if (BuildConfig.DEBUG) { - throw exception - } - // Ignore this locale in production - null + try { + Locale.Builder() + .setLanguage(language) + .setRegion(country) + .setScript(script) + .build() + } catch (exception: IllformedLocaleException) { + if (BuildConfig.DEBUG) { + throw exception } - } else { - Locale(language, country) + // Ignore this locale in production + null } } // sort by human display names @@ -229,9 +197,7 @@ object VectorLocale { return buildString { append(locale.getDisplayLanguage(locale)) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP - && locale.script != ISO_15924_LATN - && locale.getDisplayScript(locale).isNotEmpty()) { + if (locale.script != ISO_15924_LATN && locale.getDisplayScript(locale).isNotEmpty()) { append(" - ") append(locale.getDisplayScript(locale)) } @@ -254,7 +220,7 @@ object VectorLocale { return buildString { append("[") append(locale.displayLanguage) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && locale.script != ISO_15924_LATN) { + if (locale.script != ISO_15924_LATN) { append(" - ") append(locale.displayScript) } diff --git a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt index b1f9b412f5..1ccd7b6735 100644 --- a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt +++ b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt @@ -15,7 +15,6 @@ */ package im.vector.app.features.settings.troubleshoot -import android.os.Build import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -87,9 +86,7 @@ class NotificationTroubleshootRecyclerViewAdapter(val tests: ArrayList= Build.VERSION_CODES.LOLLIPOP) { - statusIconImage.imageTintList = null - } + statusIconImage.imageTintList = null descriptionText.setTextColor(ContextCompat.getColor(context, R.color.riotx_notice)) } diff --git a/vector/src/main/java/im/vector/app/features/webview/VectorWebViewActivity.kt b/vector/src/main/java/im/vector/app/features/webview/VectorWebViewActivity.kt index f90f2b8821..e49109b1d6 100644 --- a/vector/src/main/java/im/vector/app/features/webview/VectorWebViewActivity.kt +++ b/vector/src/main/java/im/vector/app/features/webview/VectorWebViewActivity.kt @@ -18,7 +18,6 @@ package im.vector.app.features.webview import android.content.Context import android.content.Intent -import android.os.Build import android.webkit.WebChromeClient import android.webkit.WebView import androidx.annotation.CallSuper @@ -70,10 +69,8 @@ class VectorWebViewActivity : VectorBaseActivity() { displayZoomControls = false } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - val cookieManager = android.webkit.CookieManager.getInstance() - cookieManager.setAcceptThirdPartyCookies(simple_webview, true) - } + val cookieManager = android.webkit.CookieManager.getInstance() + cookieManager.setAcceptThirdPartyCookies(simple_webview, true) val url = intent.extras?.getString(EXTRA_URL) val title = intent.extras?.getString(EXTRA_TITLE, USE_TITLE_FROM_WEB_PAGE) diff --git a/vector/src/main/java/im/vector/app/features/webview/VectorWebViewClient.kt b/vector/src/main/java/im/vector/app/features/webview/VectorWebViewClient.kt index 47036d6fce..597486491c 100644 --- a/vector/src/main/java/im/vector/app/features/webview/VectorWebViewClient.kt +++ b/vector/src/main/java/im/vector/app/features/webview/VectorWebViewClient.kt @@ -26,7 +26,6 @@ import android.webkit.WebResourceRequest import android.webkit.WebResourceResponse import android.webkit.WebView import android.webkit.WebViewClient -import androidx.annotation.RequiresApi /** * This class inherits from WebViewClient. It has to be used with a WebView. @@ -58,7 +57,6 @@ class VectorWebViewClient(private val eventListener: WebViewEventListener) : Web } } - @RequiresApi(Build.VERSION_CODES.LOLLIPOP) override fun onReceivedHttpError(view: WebView, request: WebResourceRequest, errorResponse: WebResourceResponse) { super.onReceivedHttpError(view, request, errorResponse) eventListener.onHttpError(request.url.toString(), diff --git a/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt b/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt index 63e54ab074..2c0aff3289 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/permissions/RoomWidgetPermissionBottomSheet.kt @@ -16,7 +16,6 @@ package im.vector.app.features.widgets.permissions import android.content.DialogInterface -import android.os.Build import android.text.Spannable import android.text.SpannableStringBuilder import android.text.style.BulletSpan @@ -71,18 +70,7 @@ class RoomWidgetPermissionBottomSheet : VectorBaseBottomSheetDialogFragment() { permissionData.permissionsList.forEach { infoBuilder.append("\n") val bulletPoint = getString(it) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - infoBuilder.append(bulletPoint, BulletSpan(resources.getDimension(R.dimen.quote_gap).toInt()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) - } else { - val start = infoBuilder.length - infoBuilder.append(bulletPoint) - infoBuilder.setSpan( - BulletSpan(resources.getDimension(R.dimen.quote_gap).toInt()), - start, - bulletPoint.length, - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE - ) - } + infoBuilder.append(bulletPoint, BulletSpan(resources.getDimension(R.dimen.quote_gap).toInt()), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) } infoBuilder.append("\n") widgetPermissionSharedInfo.text = infoBuilder diff --git a/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt b/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt index 7042e14599..446bc1663f 100644 --- a/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt +++ b/vector/src/main/java/im/vector/app/features/widgets/webview/WidgetWebView.kt @@ -17,7 +17,6 @@ package im.vector.app.features.widgets.webview import android.annotation.SuppressLint -import android.os.Build import android.view.ViewGroup import android.webkit.CookieManager import android.webkit.PermissionRequest @@ -68,10 +67,8 @@ fun WebView.setupForWidget(webViewEventListener: WebViewEventListener) { } webViewClient = VectorWebViewClient(webViewEventListener) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - val cookieManager = CookieManager.getInstance() - cookieManager.setAcceptThirdPartyCookies(this, false) - } + val cookieManager = CookieManager.getInstance() + cookieManager.setAcceptThirdPartyCookies(this, false) } fun WebView.clearAfterWidget() { diff --git a/vector/src/main/res/values-v17/styles.xml b/vector/src/main/res/values-v17/styles.xml deleted file mode 100644 index e80438a187..0000000000 --- a/vector/src/main/res/values-v17/styles.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/vector/src/main/res/values-v21/dimens.xml b/vector/src/main/res/values-v21/dimens.xml deleted file mode 100644 index 23d45d46f2..0000000000 --- a/vector/src/main/res/values-v21/dimens.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - 16dp - - - 196dp - 44dp - - diff --git a/vector/src/main/res/values-v21/styles_login.xml b/vector/src/main/res/values-v21/styles_login.xml deleted file mode 100644 index 78554f9ebb..0000000000 --- a/vector/src/main/res/values-v21/styles_login.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/vector/src/main/res/values-v21/theme_black.xml b/vector/src/main/res/values-v21/theme_black.xml deleted file mode 100644 index 6c6d78879e..0000000000 --- a/vector/src/main/res/values-v21/theme_black.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/vector/src/main/res/values-v21/theme_dark.xml b/vector/src/main/res/values-v21/theme_dark.xml deleted file mode 100644 index 285a3a2d25..0000000000 --- a/vector/src/main/res/values-v21/theme_dark.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - diff --git a/vector/src/main/res/values-v23/theme_dark.xml b/vector/src/main/res/values-v23/theme_dark.xml index f208f6dd61..c9fb7dab28 100644 --- a/vector/src/main/res/values-v23/theme_dark.xml +++ b/vector/src/main/res/values-v23/theme_dark.xml @@ -1,7 +1,7 @@ - diff --git a/vector/src/main/res/values-v23/theme_light.xml b/vector/src/main/res/values-v23/theme_light.xml index 7e27b65124..283779cd47 100644 --- a/vector/src/main/res/values-v23/theme_light.xml +++ b/vector/src/main/res/values-v23/theme_light.xml @@ -1,7 +1,7 @@ - diff --git a/vector/src/main/res/values-v23/theme_status.xml b/vector/src/main/res/values-v23/theme_status.xml index b2e12ab55d..236864d4b8 100644 --- a/vector/src/main/res/values-v23/theme_status.xml +++ b/vector/src/main/res/values-v23/theme_status.xml @@ -1,7 +1,7 @@ - diff --git a/vector/src/main/res/values/dimens.xml b/vector/src/main/res/values/dimens.xml index 665d1819f7..ccb7ae7726 100644 --- a/vector/src/main/res/values/dimens.xml +++ b/vector/src/main/res/values/dimens.xml @@ -9,9 +9,9 @@ 32dp 50dp - 0dp - 172dp - 20dp + 16dp + 196dp + 44dp 72dp 40dp diff --git a/vector/src/main/res/values-v21/styles.xml b/vector/src/main/res/values/styles.xml similarity index 62% rename from vector/src/main/res/values-v21/styles.xml rename to vector/src/main/res/values/styles.xml index 79c4b4a9aa..09f17a77b4 100644 --- a/vector/src/main/res/values-v21/styles.xml +++ b/vector/src/main/res/values/styles.xml @@ -1,7 +1,6 @@ - - - -