Merge pull request #595 from vector-im/feature/lib_upgrade

Upgrade some dependencies
This commit is contained in:
Benoit Marty 2019-10-07 16:22:30 +02:00 committed by GitHub
commit 51554f7be0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 251 additions and 251 deletions

View file

@ -3,7 +3,7 @@ import javax.tools.JavaCompiler
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.3.21' ext.kotlin_version = '1.3.50'
repositories { repositories {
google() google()
jcenter() jcenter()
@ -12,11 +12,11 @@ buildscript {
} }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.4.1' classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.gms:google-services:4.3.2'
classpath "com.airbnb.okreplay:gradle-plugin:1.4.0" classpath "com.airbnb.okreplay:gradle-plugin:1.5.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2' classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5' classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View file

@ -1,6 +1,6 @@
#Tue Mar 19 09:53:05 CET 2019 #Fri Sep 27 10:10:35 CEST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

View file

@ -29,12 +29,14 @@ android {
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
kotlinOptions {
jvmTarget = "1.8"
}
} }
dependencies { dependencies {
implementation project(":matrix-sdk-android") implementation project(":matrix-sdk-android")
implementation 'androidx.appcompat:appcompat:1.1.0-beta01' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
// Paging // Paging

View file

@ -67,6 +67,10 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
kotlinOptions {
jvmTarget = "1.8"
}
} }
static def gitRevision() { static def gitRevision() {
@ -86,29 +90,28 @@ static def gitRevisionDate() {
dependencies { dependencies {
def arrow_version = "0.8.0" def arrow_version = "0.8.2"
def support_version = '1.1.0-beta01'
def moshi_version = '1.8.0' def moshi_version = '1.8.0'
def lifecycle_version = '2.0.0' def lifecycle_version = '2.1.0'
def coroutines_version = "1.0.1" def coroutines_version = "1.3.2"
def markwon_version = '3.0.0' def markwon_version = '3.1.0'
def daggerVersion = '2.23.1' def daggerVersion = '2.24'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "androidx.appcompat:appcompat:1.1.0-rc01" implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.recyclerview:recyclerview:1.1.0-beta01" implementation "androidx.recyclerview:recyclerview:1.1.0-beta04"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
// Network // Network
implementation 'com.squareup.retrofit2:retrofit:2.6.0' implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:converter-moshi:2.4.0' implementation 'com.squareup.retrofit2:converter-moshi:2.6.2'
implementation 'com.squareup.okhttp3:okhttp:3.14.1' implementation 'com.squareup.okhttp3:okhttp:4.2.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.2.0'
implementation 'com.novoda:merlin:1.2.0' implementation 'com.novoda:merlin:1.2.0'
implementation "com.squareup.moshi:moshi-adapters:$moshi_version" implementation "com.squareup.moshi:moshi-adapters:$moshi_version"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version" kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
@ -120,7 +123,7 @@ dependencies {
kapt 'dk.ilios:realmfieldnameshelper:1.1.1' kapt 'dk.ilios:realmfieldnameshelper:1.1.1'
// Work // Work
implementation "androidx.work:work-runtime-ktx:2.1.0-rc01" implementation "androidx.work:work-runtime-ktx:2.3.0-alpha01"
// FP // FP
implementation "io.arrow-kt:arrow-core:$arrow_version" implementation "io.arrow-kt:arrow-core:$arrow_version"
@ -132,24 +135,24 @@ dependencies {
// DI // DI
implementation "com.google.dagger:dagger:$daggerVersion" implementation "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion" kapt "com.google.dagger:dagger-compiler:$daggerVersion"
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.4.0' compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0'
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.4.0' kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.0'
// Logging // Logging
implementation 'com.jakewharton.timber:timber:4.7.1' implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0' implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
// Bus // Bus
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'
debugImplementation 'com.airbnb.okreplay:okreplay:1.4.0' debugImplementation 'com.airbnb.okreplay:okreplay:1.5.0'
releaseImplementation 'com.airbnb.okreplay:noop:1.4.0' releaseImplementation 'com.airbnb.okreplay:noop:1.5.0'
androidTestImplementation 'com.airbnb.okreplay:espresso:1.4.0' androidTestImplementation 'com.airbnb.okreplay:espresso:1.5.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:4.0.2' testImplementation 'org.robolectric:robolectric:4.3'
//testImplementation 'org.robolectric:shadows-support-v4:3.0' //testImplementation 'org.robolectric:shadows-support-v4:3.0'
testImplementation "io.mockk:mockk:1.8.13.kotlin13" testImplementation 'io.mockk:mockk:1.9.3.kotlin12'
testImplementation 'org.amshove.kluent:kluent-android:1.44' testImplementation 'org.amshove.kluent:kluent-android:1.44'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
@ -159,7 +162,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'org.amshove.kluent:kluent-android:1.44' androidTestImplementation 'org.amshove.kluent:kluent-android:1.44'
androidTestImplementation "io.mockk:mockk-android:1.8.13.kotlin13" androidTestImplementation 'io.mockk:mockk-android:1.9.3.kotlin12'
androidTestImplementation "androidx.arch.core:core-testing:$lifecycle_version" androidTestImplementation "androidx.arch.core:core-testing:$lifecycle_version"
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

View file

@ -52,12 +52,12 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
var compressed = false var compressed = false
var curlCmd = "curl" var curlCmd = "curl"
if (curlOptions != null) { curlOptions?.let {
curlCmd += " " + curlOptions!! curlCmd += " $it"
} }
curlCmd += " -X " + request.method() curlCmd += " -X " + request.method
val requestBody = request.body() val requestBody = request.body
if (requestBody != null) { if (requestBody != null) {
if (requestBody.contentLength() > 100_000) { if (requestBody.contentLength() > 100_000) {
Timber.w("Unable to log curl command data, size is too big (${requestBody.contentLength()})") Timber.w("Unable to log curl command data, size is too big (${requestBody.contentLength()})")
@ -76,9 +76,9 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
} }
} }
val headers = request.headers() val headers = request.headers
var i = 0 var i = 0
val count = headers.size() val count = headers.size
while (i < count) { while (i < count) {
val name = headers.name(i) val name = headers.name(i)
val value = headers.value(i) val value = headers.value(i)
@ -89,7 +89,7 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
i++ i++
} }
curlCmd += ((if (compressed) " --compressed " else " ") + "'" + request.url().toString() curlCmd += ((if (compressed) " --compressed " else " ") + "'" + request.url.toString()
// Replace localhost for emulator by localhost for shell // Replace localhost for emulator by localhost for shell
.replace("://10.0.2.2:8080/".toRegex(), "://127.0.0.1:8080/") .replace("://10.0.2.2:8080/".toRegex(), "://127.0.0.1:8080/")
+ "'") + "'")
@ -97,7 +97,7 @@ internal class CurlLoggingInterceptor @Inject constructor(private val logger: Ht
// Add Json formatting // Add Json formatting
curlCmd += " | python -m json.tool" curlCmd += " | python -m json.tool"
logger.log("--- cURL (" + request.url() + ")") logger.log("--- cURL (" + request.url + ")")
logger.log(curlCmd) logger.log(curlCmd)
return chain.proceed(request) return chain.proceed(request)

View file

@ -43,7 +43,7 @@ internal class ProgressRequestBody(private val delegate: RequestBody,
@Throws(IOException::class) @Throws(IOException::class)
override fun writeTo(sink: BufferedSink) { override fun writeTo(sink: BufferedSink) {
countingSink = CountingSink(sink) countingSink = CountingSink(sink)
val bufferedSink = Okio.buffer(countingSink) val bufferedSink = countingSink.buffer()
delegate.writeTo(bufferedSink) delegate.writeTo(bufferedSink)
bufferedSink.flush() bufferedSink.flush()
} }

View file

@ -80,7 +80,7 @@ internal fun <T> Response<T>.toFailure(): Failure {
* Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError * Convert a okhttp3 Response to a Failure, and eventually parse errorBody to convert it to a MatrixError
*/ */
internal fun okhttp3.Response.toFailure(): Failure { internal fun okhttp3.Response.toFailure(): Failure {
return toFailure(body(), code()) return toFailure(body, code)
} }
private fun toFailure(errorBody: ResponseBody?, httpCode: Int): Failure { private fun toFailure(errorBody: ResponseBody?, httpCode: Int): Failure {

View file

@ -57,7 +57,7 @@ constructor(trustPinned: Array<TrustManager>, acceptedTlsVersions: List<TlsVersi
context.init(null, trustPinned, SecureRandom()) context.init(null, trustPinned, SecureRandom())
internalSSLSocketFactory = context.socketFactory internalSSLSocketFactory = context.socketFactory
enabledProtocols = Array(acceptedTlsVersions.size) { enabledProtocols = Array(acceptedTlsVersions.size) {
acceptedTlsVersions[it].javaName() acceptedTlsVersions[it].javaName
} }
} }

View file

@ -72,8 +72,8 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
.build() .build()
val response = okHttpClient.newCall(request).execute() val response = okHttpClient.newCall(request).execute()
val inputStream = response.body()?.byteStream() val inputStream = response.body?.byteStream()
Timber.v("Response size ${response.body()?.contentLength()} - Stream available: ${inputStream?.available()}") Timber.v("Response size ${response.body?.contentLength()} - Stream available: ${inputStream?.available()}")
if (!response.isSuccessful if (!response.isSuccessful
|| inputStream == null) { || inputStream == null) {
throw IOException() throw IOException()

View file

@ -23,6 +23,8 @@ import im.vector.matrix.android.internal.network.ProgressRequestBody
import im.vector.matrix.android.internal.network.awaitResponse import im.vector.matrix.android.internal.network.awaitResponse
import im.vector.matrix.android.internal.network.toFailure import im.vector.matrix.android.internal.network.toFailure
import okhttp3.* import okhttp3.*
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import javax.inject.Inject import javax.inject.Inject
@ -41,7 +43,7 @@ internal class FileUploader @Inject constructor(@Authenticated
filename: String?, filename: String?,
mimeType: String, mimeType: String,
progressListener: ProgressRequestBody.Listener? = null): ContentUploadResponse { progressListener: ProgressRequestBody.Listener? = null): ContentUploadResponse {
val uploadBody = RequestBody.create(MediaType.parse(mimeType), file) val uploadBody = RequestBody.create(mimeType.toMediaTypeOrNull(), file)
return upload(uploadBody, filename, progressListener) return upload(uploadBody, filename, progressListener)
} }
@ -50,13 +52,13 @@ internal class FileUploader @Inject constructor(@Authenticated
filename: String?, filename: String?,
mimeType: String, mimeType: String,
progressListener: ProgressRequestBody.Listener? = null): ContentUploadResponse { progressListener: ProgressRequestBody.Listener? = null): ContentUploadResponse {
val uploadBody = RequestBody.create(MediaType.parse(mimeType), byteArray) val uploadBody = RequestBody.create(mimeType.toMediaTypeOrNull(), byteArray)
return upload(uploadBody, filename, progressListener) return upload(uploadBody, filename, progressListener)
} }
private suspend fun upload(uploadBody: RequestBody, filename: String?, progressListener: ProgressRequestBody.Listener?): ContentUploadResponse { private suspend fun upload(uploadBody: RequestBody, filename: String?, progressListener: ProgressRequestBody.Listener?): ContentUploadResponse {
val urlBuilder = HttpUrl.parse(uploadUrl)?.newBuilder() ?: throw RuntimeException() val urlBuilder = uploadUrl.toHttpUrlOrNull()?.newBuilder() ?: throw RuntimeException()
val httpUrl = urlBuilder val httpUrl = urlBuilder
.addQueryParameter("filename", filename) .addQueryParameter("filename", filename)
@ -73,7 +75,7 @@ internal class FileUploader @Inject constructor(@Authenticated
if (!response.isSuccessful) { if (!response.isSuccessful) {
throw response.toFailure() throw response.toFailure()
} else { } else {
response.body()?.source()?.let { response.body?.source()?.let {
responseAdapter.fromJson(it) responseAdapter.fromJson(it)
} }
?: throw IOException() ?: throw IOException()

View file

@ -17,7 +17,9 @@
package im.vector.matrix.android.internal.util package im.vector.matrix.android.internal.util
import androidx.annotation.WorkerThread import androidx.annotation.WorkerThread
import okio.Okio import okio.buffer
import okio.sink
import okio.source
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
@ -26,8 +28,8 @@ import java.io.InputStream
*/ */
@WorkerThread @WorkerThread
fun writeToFile(inputStream: InputStream, outputFile: File) { fun writeToFile(inputStream: InputStream, outputFile: File) {
Okio.buffer(Okio.source(inputStream)).use { input -> inputStream.source().buffer().use { input ->
Okio.buffer(Okio.sink(outputFile)).use { output -> outputFile.sink().buffer().use { output ->
output.writeAll(input) output.writeAll(input)
} }
} }

View file

@ -208,18 +208,22 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
kotlinOptions {
jvmTarget = "1.8"
}
} }
dependencies { dependencies {
def epoxy_version = "3.7.0" def epoxy_version = '3.8.0'
def arrow_version = "0.8.2" def arrow_version = "0.8.2"
def coroutines_version = "1.0.1" def coroutines_version = "1.3.2"
def markwon_version = '3.0.0' def markwon_version = '3.1.0'
def big_image_viewer_version = '1.5.6' def big_image_viewer_version = '1.5.6'
def glide_version = '4.9.0' def glide_version = '4.10.0'
def moshi_version = '1.8.0' def moshi_version = '1.8.0'
def daggerVersion = '2.23.1' def daggerVersion = '2.24'
implementation project(":matrix-sdk-android") implementation project(":matrix-sdk-android")
implementation project(":matrix-sdk-android-rx") implementation project(":matrix-sdk-android-rx")
@ -229,10 +233,10 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation 'androidx.appcompat:appcompat:1.1.0-beta01' implementation 'androidx.appcompat:appcompat:1.1.0'
//Do not use beta2 at the moment, as it breaks things //Do not use beta2 at the moment, as it breaks things
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'androidx.core:core-ktx:1.0.2' implementation 'androidx.core:core-ktx:1.1.0'
implementation "org.threeten:threetenbp:1.4.0:no-tzdb" implementation "org.threeten:threetenbp:1.4.0:no-tzdb"
implementation "com.gabrielittner.threetenbp:lazythreetenbp:0.7.0" implementation "com.gabrielittner.threetenbp:lazythreetenbp:0.7.0"
@ -247,12 +251,12 @@ dependencies {
implementation 'com.jakewharton.timber:timber:4.7.1' implementation 'com.jakewharton.timber:timber:4.7.1'
// Debug // Debug
implementation 'com.facebook.stetho:stetho:1.5.0' implementation 'com.facebook.stetho:stetho:1.5.1'
// rx // rx
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0' implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.0' implementation 'com.jakewharton.rxrelay2:rxrelay:2.1.1'
// RXBinding // RXBinding
implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0' implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0'
implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0' implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0'
@ -261,10 +265,10 @@ dependencies {
implementation("com.airbnb.android:epoxy:$epoxy_version") implementation("com.airbnb.android:epoxy:$epoxy_version")
kapt "com.airbnb.android:epoxy-processor:$epoxy_version" kapt "com.airbnb.android:epoxy-processor:$epoxy_version"
implementation "com.airbnb.android:epoxy-paging:$epoxy_version" implementation "com.airbnb.android:epoxy-paging:$epoxy_version"
implementation 'com.airbnb.android:mvrx:1.0.1' implementation 'com.airbnb.android:mvrx:1.1.0'
// Work // Work
implementation "androidx.work:work-runtime-ktx:2.1.0-rc01" implementation "androidx.work:work-runtime-ktx:2.3.0-alpha01"
// Paging // Paging
implementation "androidx.paging:paging-runtime-ktx:2.1.0" implementation "androidx.paging:paging-runtime-ktx:2.1.0"
@ -273,11 +277,11 @@ dependencies {
implementation "io.arrow-kt:arrow-core:$arrow_version" implementation "io.arrow-kt:arrow-core:$arrow_version"
// Pref // Pref
implementation 'androidx.preference:preference:1.0.0' implementation 'androidx.preference:preference:1.1.0'
// UI // UI
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.google.android.material:material:1.1.0-alpha08' implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'me.gujun.android:span:1.7' implementation 'me.gujun.android:span:1.7'
implementation "ru.noties.markwon:core:$markwon_version" implementation "ru.noties.markwon:core:$markwon_version"
implementation "ru.noties.markwon:html:$markwon_version" implementation "ru.noties.markwon:html:$markwon_version"
@ -288,7 +292,7 @@ dependencies {
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'
// Passphrase strength helper // Passphrase strength helper
implementation 'com.nulab-inc:zxcvbn:1.2.5' implementation 'com.nulab-inc:zxcvbn:1.2.7'
//Alerter //Alerter
implementation 'com.tapadoo.android:alerter:4.0.3' implementation 'com.tapadoo.android:alerter:4.0.3'
@ -296,8 +300,8 @@ dependencies {
implementation 'com.otaliastudios:autocomplete:1.1.0' implementation 'com.otaliastudios:autocomplete:1.1.0'
// Butterknife // Butterknife
implementation 'com.jakewharton:butterknife:10.1.0' implementation 'com.jakewharton:butterknife:10.2.0'
kapt 'com.jakewharton:butterknife-compiler:10.1.0' kapt 'com.jakewharton:butterknife-compiler:10.2.0'
// Shake detection // Shake detection
implementation 'com.squareup:seismic:1.0.2' implementation 'com.squareup:seismic:1.0.2'
@ -312,7 +316,7 @@ dependencies {
implementation 'com.danikula:videocache:2.7.1' implementation 'com.danikula:videocache:2.7.1'
// Badge for compatibility // Badge for compatibility
implementation 'me.leolin:ShortcutBadger:1.1.2@aar' implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
// File picker // File picker
implementation 'com.github.jaiselrahman:FilePicker:1.2.2' implementation 'com.github.jaiselrahman:FilePicker:1.2.2'
@ -320,11 +324,13 @@ dependencies {
// DI // DI
implementation "com.google.dagger:dagger:$daggerVersion" implementation "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion" kapt "com.google.dagger:dagger-compiler:$daggerVersion"
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.4.0' compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0'
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.4.0' kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.0'
// gplay flavor only // gplay flavor only
gplayImplementation('com.google.firebase:firebase-messaging:19.0.1') { // Warning: due to the exclude, Android Studio does not propose to upgrade. Uncomment next line to be proposed to upgrade
// implementation 'com.google.firebase:firebase-messaging:20.0.0'
gplayImplementation('com.google.firebase:firebase-messaging:20.0.0') {
exclude group: 'com.google.firebase', module: 'firebase-core' exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics' exclude group: 'com.google.firebase', module: 'firebase-analytics'
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector' exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'

View file

@ -33,9 +33,8 @@ class TestBackgroundRestrictions @Inject constructor(private val context: AppCom
// Checks if the device is on a metered network // Checks if the device is on a metered network
if (isActiveNetworkMetered) { if (isActiveNetworkMetered) {
// Checks users Data Saver settings. // Checks users Data Saver settings.
val restrictBackgroundStatus = ConnectivityManagerCompat.getRestrictBackgroundStatus(this) when (ConnectivityManagerCompat.getRestrictBackgroundStatus(this)) {
when (restrictBackgroundStatus) { ConnectivityManagerCompat.RESTRICT_BACKGROUND_STATUS_ENABLED -> {
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED -> {
// Background data usage is blocked for this app. Wherever possible, // Background data usage is blocked for this app. Wherever possible,
// the app should also use less data in the foreground. // the app should also use less data in the foreground.
description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_failed, description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_failed,
@ -43,7 +42,7 @@ class TestBackgroundRestrictions @Inject constructor(private val context: AppCom
status = TestStatus.FAILED status = TestStatus.FAILED
quickFix = null quickFix = null
} }
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_WHITELISTED -> { ConnectivityManagerCompat.RESTRICT_BACKGROUND_STATUS_WHITELISTED -> {
// The app is whitelisted. Wherever possible, // The app is whitelisted. Wherever possible,
// the app should use less data in the foreground and background. // the app should use less data in the foreground and background.
description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_success, description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_success,
@ -51,7 +50,7 @@ class TestBackgroundRestrictions @Inject constructor(private val context: AppCom
status = TestStatus.SUCCESS status = TestStatus.SUCCESS
quickFix = null quickFix = null
} }
ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED -> { ConnectivityManagerCompat.RESTRICT_BACKGROUND_STATUS_DISABLED -> {
// Data Saver is disabled. Since the device is connected to a // Data Saver is disabled. Since the device is connected to a
// metered network, the app should use less data wherever possible. // metered network, the app should use less data wherever possible.
description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_success, description = stringProvider.getString(R.string.settings_troubleshoot_test_bg_restricted_success,

View file

@ -73,16 +73,12 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
* *
* @param message the message * @param message the message
*/ */
override fun onMessageReceived(message: RemoteMessage?) { override fun onMessageReceived(message: RemoteMessage) {
if (!vectorPreferences.areNotificationEnabledForDevice()) { if (!vectorPreferences.areNotificationEnabledForDevice()) {
Timber.i("Notification are disabled for this device") Timber.i("Notification are disabled for this device")
return return
} }
if (message == null || message.data == null) {
Timber.e("## onMessageReceived() : received a null message or message with no data")
return
}
if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) { if (BuildConfig.LOW_PRIVACY_LOG_ENABLE) {
Timber.i("## onMessageReceived() %s", message.data.toString()) Timber.i("## onMessageReceived() %s", message.data.toString())
Timber.i("## onMessageReceived() from FCM with priority %s", message.priority) Timber.i("## onMessageReceived() from FCM with priority %s", message.priority)
@ -103,15 +99,11 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
* when the InstanceID token is initially generated, so this is where * when the InstanceID token is initially generated, so this is where
* you retrieve the token. * you retrieve the token.
*/ */
override fun onNewToken(refreshedToken: String?) { override fun onNewToken(refreshedToken: String) {
Timber.i("onNewToken: FCM Token has been updated") Timber.i("onNewToken: FCM Token has been updated")
FcmHelper.storeFcmToken(this, refreshedToken) FcmHelper.storeFcmToken(this, refreshedToken)
if (refreshedToken == null) { if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
Timber.w("onNewToken:received null token") pusherManager.registerPusherWithFcmKey(refreshedToken)
} else {
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
pusherManager.registerPusherWithFcmKey(refreshedToken)
}
} }
} }
@ -226,8 +218,7 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
} else { } else {
if (notifiableEvent is NotifiableMessageEvent) { if (notifiableEvent is NotifiableMessageEvent) {
if (TextUtils.isEmpty(notifiableEvent.senderName)) { if (TextUtils.isEmpty(notifiableEvent.senderName)) {
notifiableEvent.senderName = data["sender_display_name"] notifiableEvent.senderName = data["sender_display_name"] ?: data["sender"] ?: ""
?: data["sender"] ?: ""
} }
if (TextUtils.isEmpty(notifiableEvent.roomName)) { if (TextUtils.isEmpty(notifiableEvent.roomName)) {
notifiableEvent.roomName = findRoomNameBestEffort(data, session) ?: "" notifiableEvent.roomName = findRoomNameBestEffort(data, session) ?: ""
@ -272,11 +263,11 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
try { try {
return Event(eventId = data["event_id"], return Event(eventId = data["event_id"],
senderId = data["sender"], senderId = data["sender"],
roomId = data["room_id"], roomId = data["room_id"],
type = data.getValue("type"), type = data.getValue("type"),
// TODO content = data.getValue("content"), // TODO content = data.getValue("content"),
originServerTs = System.currentTimeMillis()) originServerTs = System.currentTimeMillis())
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "buildEvent fails ") Timber.e(e, "buildEvent fails ")
} }

View file

@ -20,10 +20,10 @@ import android.app.DownloadManager
import android.content.Context import android.content.Context
import androidx.annotation.WorkerThread import androidx.annotation.WorkerThread
import arrow.core.Try import arrow.core.Try
import okio.Okio import okio.buffer
import okio.sink
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
import java.io.InputStream
/** /**
* Save a string to a file with Okio * Save a string to a file with Okio
@ -31,9 +31,9 @@ import java.io.InputStream
@WorkerThread @WorkerThread
fun writeToFile(str: String, file: File): Try<Unit> { fun writeToFile(str: String, file: File): Try<Unit> {
return Try { return Try {
val sink = Okio.sink(file) val sink = file.sink()
val bufferedSink = Okio.buffer(sink) val bufferedSink = sink.buffer()
bufferedSink.writeString(str, Charsets.UTF_8) bufferedSink.writeString(str, Charsets.UTF_8)
@ -48,9 +48,9 @@ fun writeToFile(str: String, file: File): Try<Unit> {
@WorkerThread @WorkerThread
fun writeToFile(data: ByteArray, file: File): Try<Unit> { fun writeToFile(data: ByteArray, file: File): Try<Unit> {
return Try { return Try {
val sink = Okio.sink(file) val sink = file.sink()
val bufferedSink = Okio.buffer(sink) val bufferedSink = sink.buffer()
bufferedSink.write(data) bufferedSink.write(data)

View file

@ -34,7 +34,6 @@ import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
import java.io.IOException import java.io.IOException
import java.io.InputStream import java.io.InputStream
import com.bumptech.glide.load.engine.Resource as Resource1
class VectorGlideModelLoaderFactory(private val activeSessionHolder: ActiveSessionHolder) class VectorGlideModelLoaderFactory(private val activeSessionHolder: ActiveSessionHolder)
@ -112,8 +111,8 @@ class VectorGlideDataFetcher(private val activeSessionHolder: ActiveSessionHolde
.build() .build()
val response = client.newCall(request).execute() val response = client.newCall(request).execute()
val inputStream = response.body()?.byteStream() val inputStream = response.body?.byteStream()
Timber.v("Response size ${response.body()?.contentLength()} - Stream available: ${inputStream?.available()}") Timber.v("Response size ${response.body?.contentLength()} - Stream available: ${inputStream?.available()}")
if (!response.isSuccessful) { if (!response.isSuccessful) {
callback.onLoadFailed(IOException("Unexpected code $response")) callback.onLoadFailed(IOException("Unexpected code $response"))
return return

View file

@ -20,7 +20,6 @@ import android.content.Context
import android.os.Build import android.os.Build
import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.Session
import me.leolin.shortcutbadger.ShortcutBadger import me.leolin.shortcutbadger.ShortcutBadger
import timber.log.Timber
/** /**
* Manage application badge (displayed in the launcher) * Manage application badge (displayed in the launcher)
@ -45,12 +44,7 @@ object BadgeProxy {
return return
} }
try { ShortcutBadger.applyCount(context, badgeValue)
ShortcutBadger.setBadge(context, badgeValue)
} catch (e: Exception) {
Timber.e(e, "## updateBadgeCount(): Exception Msg=" + e.message)
}
} }
/** /**

View file

@ -37,6 +37,8 @@ import im.vector.riotx.features.settings.VectorLocale
import im.vector.riotx.features.themes.ThemeUtils import im.vector.riotx.features.themes.ThemeUtils
import im.vector.riotx.features.version.VersionProvider import im.vector.riotx.features.version.VersionProvider
import okhttp3.* import okhttp3.*
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.asRequestBody
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import timber.log.Timber import timber.log.Timber
@ -53,7 +55,7 @@ import javax.inject.Singleton
@Singleton @Singleton
class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSessionHolder, class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSessionHolder,
private val versionProvider: VersionProvider, private val versionProvider: VersionProvider,
private val vectorFileLogger : VectorFileLogger) { private val vectorFileLogger: VectorFileLogger) {
var inMultiWindowMode = false var inMultiWindowMode = false
companion object { companion object {
@ -248,7 +250,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
// add the gzipped files // add the gzipped files
for (file in gzippedFiles) { for (file in gzippedFiles) {
builder.addFormDataPart("compressed-log", file.name, RequestBody.create(MediaType.parse("application/octet-stream"), file)) builder.addFormDataPart("compressed-log", file.name, file.asRequestBody("application/octet-stream".toMediaTypeOrNull()))
} }
mBugReportFiles.addAll(gzippedFiles) mBugReportFiles.addAll(gzippedFiles)
@ -270,7 +272,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
fos.close() fos.close()
builder.addFormDataPart("file", builder.addFormDataPart("file",
logCatScreenshotFile.name, RequestBody.create(MediaType.parse("application/octet-stream"), logCatScreenshotFile)) logCatScreenshotFile.name, logCatScreenshotFile.asRequestBody("application/octet-stream".toMediaTypeOrNull()))
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## sendBugReport() : fail to write screenshot$e") Timber.e(e, "## sendBugReport() : fail to write screenshot$e")
} }
@ -336,9 +338,9 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
try { try {
mBugReportCall = mOkHttpClient.newCall(request) mBugReportCall = mOkHttpClient.newCall(request)
response = mBugReportCall!!.execute() response = mBugReportCall!!.execute()
responseCode = response!!.code() responseCode = response.code
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "response " + e.message) Timber.e(e, "response")
errorMessage = e.localizedMessage errorMessage = e.localizedMessage
} }
@ -346,44 +348,42 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
if (responseCode != HttpURLConnection.HTTP_OK) { if (responseCode != HttpURLConnection.HTTP_OK) {
if (null != errorMessage) { if (null != errorMessage) {
serverError = "Failed with error $errorMessage" serverError = "Failed with error $errorMessage"
} else if (null == response || null == response.body()) { } else if (null == response || null == response.body) {
serverError = "Failed with error $responseCode" serverError = "Failed with error $responseCode"
} else { } else {
var inputStream: InputStream? = null var inputStream: InputStream? = null
try { try {
inputStream = response.body()!!.byteStream() inputStream = response.body!!.byteStream()
if (null != inputStream) { var ch = inputStream.read()
var ch = inputStream.read() val b = StringBuilder()
val b = StringBuilder() while (ch != -1) {
while (ch != -1) { b.append(ch.toChar())
b.append(ch.toChar()) ch = inputStream.read()
ch = inputStream.read() }
} serverError = b.toString()
serverError = b.toString() inputStream.close()
inputStream.close()
// check if the error message // check if the error message
try { try {
val responseJSON = JSONObject(serverError) val responseJSON = JSONObject(serverError)
serverError = responseJSON.getString("error") serverError = responseJSON.getString("error")
} catch (e: JSONException) { } catch (e: JSONException) {
Timber.e(e, "doInBackground ; Json conversion failed " + e.message) Timber.e(e, "doInBackground ; Json conversion failed")
} }
// should never happen // should never happen
if (null == serverError) { if (null == serverError) {
serverError = "Failed with error $responseCode" serverError = "Failed with error $responseCode"
}
} }
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## sendBugReport() : failed to parse error " + e.message) Timber.e(e, "## sendBugReport() : failed to parse error")
} finally { } finally {
try { try {
inputStream?.close() inputStream?.close()
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## sendBugReport() : failed to close the error stream " + e.message) Timber.e(e, "## sendBugReport() : failed to close the error stream")
} }
} }
@ -398,9 +398,9 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
override fun onProgressUpdate(vararg progress: Int?) { override fun onProgressUpdate(vararg progress: Int?) {
if (null != listener) { if (null != listener) {
try { try {
listener.onProgress(progress?.get(0) ?: 0) listener.onProgress(progress[0] ?: 0)
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## onProgress() : failed " + e.message) Timber.e(e, "## onProgress() : failed")
} }
} }
@ -424,7 +424,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
listener.onUploadFailed(reason) listener.onUploadFailed(reason)
} }
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## onPostExecute() : failed " + e.message) Timber.e(e, "## onPostExecute() : failed")
} }
} }
@ -637,13 +637,13 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
line = reader.readLine() line = reader.readLine()
} }
} catch (e: IOException) { } catch (e: IOException) {
Timber.e(e, "getLog fails with " + e.localizedMessage) Timber.e(e, "getLog fails")
} finally { } finally {
if (reader != null) { if (reader != null) {
try { try {
reader.close() reader.close()
} catch (e: IOException) { } catch (e: IOException) {
Timber.e(e, "getLog fails with " + e.localizedMessage) Timber.e(e, "getLog fails with")
} }
} }
@ -661,7 +661,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
* @return the gzipped file * @return the gzipped file
*/ */
private fun compressFile(fin: File): File? { private fun compressFile(fin: File): File? {
Timber.v("## compressFile() : compress " + fin.name) Timber.v("## compressFile() : compress ${fin.name}")
val dstFile = File(fin.parent, fin.name + ".gz") val dstFile = File(fin.parent, fin.name + ".gz")
@ -688,19 +688,19 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
gos.close() gos.close()
inputStream.close() inputStream.close()
Timber.v("## compressFile() : " + fin.length() + " compressed to " + dstFile.length() + " bytes") Timber.v("## compressFile() : ${fin.length()} compressed to ${dstFile.length()} bytes")
return dstFile return dstFile
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## compressFile() failed " + e.message) Timber.e(e, "## compressFile() failed")
} catch (oom: OutOfMemoryError) { } catch (oom: OutOfMemoryError) {
Timber.e(oom, "## compressFile() failed " + oom.message) Timber.e(oom, "## compressFile() failed")
} finally { } finally {
try { try {
fos?.close() fos?.close()
gos?.close() gos?.close()
inputStream?.close() inputStream?.close()
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "## compressFile() failed to close inputStream " + e.message) Timber.e(e, "## compressFile() failed to close inputStream")
} }
} }

View file

@ -66,7 +66,7 @@ public class BugReporterMultipartBody extends RequestBody {
private BugReporterMultipartBody(ByteString boundary, List<Part> parts) { private BugReporterMultipartBody(ByteString boundary, List<Part> parts) {
mBoundary = boundary; mBoundary = boundary;
mContentType = MediaType.parse(FORM + "; boundary=" + boundary.utf8()); mContentType = MediaType.parse(FORM + "; boundary=" + boundary.utf8());
mParts = Util.immutableList(parts); mParts = Util.toImmutableList(parts);
} }
@Override @Override

View file

@ -28,6 +28,7 @@ import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.extensions.withArgs import im.vector.riotx.core.extensions.withArgs
import im.vector.riotx.core.preference.BingRule import im.vector.riotx.core.preference.BingRule
import im.vector.riotx.core.preference.BingRulePreference import im.vector.riotx.core.preference.BingRulePreference
import im.vector.riotx.core.preference.VectorPreference
import im.vector.riotx.features.notifications.NotificationUtils import im.vector.riotx.features.notifications.NotificationUtils
import javax.inject.Inject import javax.inject.Inject
@ -54,7 +55,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
override fun bindPref() { override fun bindPref() {
val callNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_CALL_NOTIFICATION_PREFERENCE_KEY) val callNotificationsSystemOptions = findPreference<VectorPreference>(VectorPreferences.SETTINGS_SYSTEM_CALL_NOTIFICATION_PREFERENCE_KEY)!!
if (NotificationUtils.supportNotificationChannels()) { if (NotificationUtils.supportNotificationChannels()) {
callNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener { callNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener {
NotificationUtils.openSystemSettingsForCallCategory(this) NotificationUtils.openSystemSettingsForCallCategory(this)
@ -64,7 +65,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
callNotificationsSystemOptions.isVisible = false callNotificationsSystemOptions.isVisible = false
} }
val noisyNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_NOISY_NOTIFICATION_PREFERENCE_KEY) val noisyNotificationsSystemOptions = findPreference<VectorPreference>(VectorPreferences.SETTINGS_SYSTEM_NOISY_NOTIFICATION_PREFERENCE_KEY)!!
if (NotificationUtils.supportNotificationChannels()) { if (NotificationUtils.supportNotificationChannels()) {
noisyNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener { noisyNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener {
NotificationUtils.openSystemSettingsForNoisyCategory(this) NotificationUtils.openSystemSettingsForNoisyCategory(this)
@ -74,7 +75,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
noisyNotificationsSystemOptions.isVisible = false noisyNotificationsSystemOptions.isVisible = false
} }
val silentNotificationsSystemOptions = findPreference(VectorPreferences.SETTINGS_SYSTEM_SILENT_NOTIFICATION_PREFERENCE_KEY) val silentNotificationsSystemOptions = findPreference<VectorPreference>(VectorPreferences.SETTINGS_SYSTEM_SILENT_NOTIFICATION_PREFERENCE_KEY)!!
if (NotificationUtils.supportNotificationChannels()) { if (NotificationUtils.supportNotificationChannels()) {
silentNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener { silentNotificationsSystemOptions.onPreferenceClickListener = Preference.OnPreferenceClickListener {
NotificationUtils.openSystemSettingsForSilentCategory(this) NotificationUtils.openSystemSettingsForSilentCategory(this)
@ -86,7 +87,7 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
// Ringtone // Ringtone
val ringtonePreference = findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY) val ringtonePreference = findPreference<VectorPreference>(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY)!!
if (NotificationUtils.supportNotificationChannels()) { if (NotificationUtils.supportNotificationChannels()) {
ringtonePreference.isVisible = false ringtonePreference.isVisible = false
@ -106,45 +107,43 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
} }
for (preferenceKey in mPrefKeyToBingRuleId.keys) { for (preferenceKey in mPrefKeyToBingRuleId.keys) {
val preference = findPreference(preferenceKey) val preference = findPreference<VectorPreference>(preferenceKey)
if (null != preference) { if (preference is BingRulePreference) {
if (preference is BingRulePreference) { //preference.isEnabled = null != rules && isConnected && pushManager.areDeviceNotificationsAllowed()
//preference.isEnabled = null != rules && isConnected && pushManager.areDeviceNotificationsAllowed() val rule: BingRule? = null // TODO session.dataHandler.pushRules()?.findDefaultRule(mPrefKeyToBingRuleId[preferenceKey])
val rule: BingRule? = null // TODO session.dataHandler.pushRules()?.findDefaultRule(mPrefKeyToBingRuleId[preferenceKey])
if (rule == null) { if (rule == null) {
// The rule is not defined, hide the preference // The rule is not defined, hide the preference
preference.isVisible = false preference.isVisible = false
} else { } else {
preference.isVisible = true preference.isVisible = true
preference.setBingRule(rule) preference.setBingRule(rule)
preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> preference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
val rule = preference.createRule(newValue as Int) val rule = preference.createRule(newValue as Int)
if (null != rule) { if (null != rule) {
/* /*
TODO TODO
displayLoadingView() displayLoadingView()
session.dataHandler.bingRulesManager.updateRule(preference.rule, session.dataHandler.bingRulesManager.updateRule(preference.rule,
rule, rule,
object : BingRulesManager.onBingRuleUpdateListener { object : BingRulesManager.onBingRuleUpdateListener {
private fun onDone() { private fun onDone() {
refreshDisplay() refreshDisplay()
hideLoadingView() hideLoadingView()
} }
override fun onBingRuleUpdateSuccess() { override fun onBingRuleUpdateSuccess() {
onDone() onDone()
} }
override fun onBingRuleUpdateFailure(errorMessage: String) { override fun onBingRuleUpdateFailure(errorMessage: String) {
activity?.toast(errorMessage) activity?.toast(errorMessage)
onDone() onDone()
} }
}) })
*/ */
}
false
} }
false
} }
} }
} }
@ -166,7 +165,8 @@ class VectorSettingsAdvancedNotificationPreferenceFragment : VectorSettingsBaseF
val notificationRingToneName = vectorPreferences.getNotificationRingToneName() val notificationRingToneName = vectorPreferences.getNotificationRingToneName()
if (null != notificationRingToneName) { if (null != notificationRingToneName) {
vectorPreferences.setNotificationRingTone(vectorPreferences.getNotificationRingTone()) vectorPreferences.setNotificationRingTone(vectorPreferences.getNotificationRingTone())
findPreference(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY).summary = notificationRingToneName findPreference<VectorPreference>(VectorPreferences.SETTINGS_NOTIFICATION_RINGTONE_SELECTION_PREFERENCE_KEY)!!
.summary = notificationRingToneName
} }
} }
} }

View file

@ -30,7 +30,7 @@ class VectorSettingsFlairFragment : VectorSettingsBaseFragment() {
// Group Flairs // Group Flairs
private val mGroupsFlairCategory by lazy { private val mGroupsFlairCategory by lazy {
findPreference(VectorPreferences.SETTINGS_GROUPS_FLAIR_KEY) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_GROUPS_FLAIR_KEY)!!
} }
override fun bindPref() { override fun bindPref() {

View file

@ -61,25 +61,25 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
private var mDisplayedPhoneNumber = ArrayList<String>() private var mDisplayedPhoneNumber = ArrayList<String>()
private val mUserSettingsCategory by lazy { private val mUserSettingsCategory by lazy {
findPreference(VectorPreferences.SETTINGS_USER_SETTINGS_PREFERENCE_KEY) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_USER_SETTINGS_PREFERENCE_KEY)!!
} }
private val mUserAvatarPreference by lazy { private val mUserAvatarPreference by lazy {
findPreference(VectorPreferences.SETTINGS_PROFILE_PICTURE_PREFERENCE_KEY) as UserAvatarPreference findPreference<UserAvatarPreference>(VectorPreferences.SETTINGS_PROFILE_PICTURE_PREFERENCE_KEY)!!
} }
private val mDisplayNamePreference by lazy { private val mDisplayNamePreference by lazy {
findPreference(VectorPreferences.SETTINGS_DISPLAY_NAME_PREFERENCE_KEY) as EditTextPreference findPreference<EditTextPreference>(VectorPreferences.SETTINGS_DISPLAY_NAME_PREFERENCE_KEY)!!
} }
private val mPasswordPreference by lazy { private val mPasswordPreference by lazy {
findPreference(VectorPreferences.SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_CHANGE_PASSWORD_PREFERENCE_KEY)!!
} }
// Local contacts // Local contacts
private val mContactSettingsCategory by lazy { private val mContactSettingsCategory by lazy {
findPreference(VectorPreferences.SETTINGS_CONTACT_PREFERENCE_KEYS) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_CONTACT_PREFERENCE_KEYS)!!
} }
private val mContactPhonebookCountryPreference by lazy { private val mContactPhonebookCountryPreference by lazy {
findPreference(VectorPreferences.SETTINGS_CONTACTS_PHONEBOOK_COUNTRY_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_CONTACTS_PHONEBOOK_COUNTRY_PREFERENCE_KEY)!!
} }
@ -111,7 +111,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
} }
// Add Email // Add Email
(findPreference(ADD_EMAIL_PREFERENCE_KEY) as EditTextPreference).let { findPreference<EditTextPreference>(ADD_EMAIL_PREFERENCE_KEY)!!.let {
// It does not work on XML, do it here // It does not work on XML, do it here
it.icon = activity?.let { it.icon = activity?.let {
ThemeUtils.tintDrawable(it, ThemeUtils.tintDrawable(it,
@ -129,7 +129,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
} }
// Add phone number // Add phone number
findPreference(ADD_PHONE_NUMBER_PREFERENCE_KEY).let { findPreference<VectorPreference>(ADD_PHONE_NUMBER_PREFERENCE_KEY)!!.let {
// It does not work on XML, do it here // It does not work on XML, do it here
it.icon = activity?.let { it.icon = activity?.let {
ThemeUtils.tintDrawable(it, ThemeUtils.tintDrawable(it,
@ -147,15 +147,15 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
// Advanced settings // Advanced settings
// user account // user account
findPreference(VectorPreferences.SETTINGS_LOGGED_IN_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_LOGGED_IN_PREFERENCE_KEY)!!
.summary = session.myUserId .summary = session.myUserId
// home server // home server
findPreference(VectorPreferences.SETTINGS_HOME_SERVER_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_HOME_SERVER_PREFERENCE_KEY)!!
.summary = session.sessionParams.homeServerConnectionConfig.homeServerUri.toString() .summary = session.sessionParams.homeServerConnectionConfig.homeServerUri.toString()
// identity server // identity server
findPreference(VectorPreferences.SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY)!!
.summary = session.sessionParams.homeServerConnectionConfig.identityServerUri.toString() .summary = session.sessionParams.homeServerConnectionConfig.identityServerUri.toString()
@ -165,7 +165,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
setContactsPreferences() setContactsPreferences()
// clear cache // clear cache
findPreference(VectorPreferences.SETTINGS_CLEAR_CACHE_PREFERENCE_KEY).let { findPreference<VectorPreference>(VectorPreferences.SETTINGS_CLEAR_CACHE_PREFERENCE_KEY)!!.let {
/* /*
TODO TODO
MXSession.getApplicationSizeCaches(activity, object : SimpleApiCallback<Long>() { MXSession.getApplicationSizeCaches(activity, object : SimpleApiCallback<Long>() {
@ -185,7 +185,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
} }
// clear medias cache // clear medias cache
findPreference(VectorPreferences.SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY).let { findPreference<VectorPreference>(VectorPreferences.SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY)!!.let {
val size = getSizeOfFiles(requireContext(), val size = getSizeOfFiles(requireContext(),
File(requireContext().cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR)) File(requireContext().cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_DIR))
@ -218,7 +218,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
} }
// Sign out // Sign out
findPreference("SETTINGS_SIGN_OUT_KEY") findPreference<VectorPreference>("SETTINGS_SIGN_OUT_KEY")!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
activity?.let { activity?.let {
SignOutUiWorker(requireActivity()) SignOutUiWorker(requireActivity())
@ -232,7 +232,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
// Deactivate account section // Deactivate account section
// deactivate account // deactivate account
findPreference(VectorPreferences.SETTINGS_DEACTIVATE_ACCOUNT_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_DEACTIVATE_ACCOUNT_KEY)!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
activity?.let { activity?.let {
notImplemented() notImplemented()
@ -478,7 +478,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
run { run {
var index = 0 var index = 0
while (true) { while (true) {
val preference = mUserSettingsCategory.findPreference(EMAIL_PREFERENCE_KEY_BASE + index) val preference = mUserSettingsCategory.findPreference<VectorPreference>(EMAIL_PREFERENCE_KEY_BASE + index)
if (null != preference) { if (null != preference) {
mUserSettingsCategory.removePreference(preference) mUserSettingsCategory.removePreference(preference)
@ -492,8 +492,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() {
// add new emails list // add new emails list
mDisplayedEmails = newEmailsList mDisplayedEmails = newEmailsList
val addEmailBtn = mUserSettingsCategory.findPreference(ADD_EMAIL_PREFERENCE_KEY) val addEmailBtn = mUserSettingsCategory.findPreference<VectorPreference>(ADD_EMAIL_PREFERENCE_KEY) ?: return
?: return
var order = addEmailBtn.order var order = addEmailBtn.order

View file

@ -24,6 +24,7 @@ import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import im.vector.matrix.android.api.Matrix import im.vector.matrix.android.api.Matrix
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.di.ScreenComponent import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.preference.VectorPreference
import im.vector.riotx.core.utils.copyToClipboard import im.vector.riotx.core.utils.copyToClipboard
import im.vector.riotx.core.utils.displayInWebView import im.vector.riotx.core.utils.displayInWebView
import im.vector.riotx.features.version.VersionProvider import im.vector.riotx.features.version.VersionProvider
@ -42,7 +43,7 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() {
override fun bindPref() { override fun bindPref() {
// preference to start the App info screen, to facilitate App permissions access // preference to start the App info screen, to facilitate App permissions access
findPreference(APP_INFO_LINK_PREFERENCE_KEY) findPreference<VectorPreference>(APP_INFO_LINK_PREFERENCE_KEY)!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
activity?.let { activity?.let {
@ -61,7 +62,7 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() {
} }
// application version // application version
(findPreference(VectorPreferences.SETTINGS_VERSION_PREFERENCE_KEY)).let { findPreference<VectorPreference>(VectorPreferences.SETTINGS_VERSION_PREFERENCE_KEY)!!.let {
it.summary = versionProvider.getVersion(longFormat = false, useBuildNumber = true) it.summary = versionProvider.getVersion(longFormat = false, useBuildNumber = true)
it.setOnPreferenceClickListener { pref -> it.setOnPreferenceClickListener { pref ->
@ -71,7 +72,7 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() {
} }
// SDK version // SDK version
(findPreference(VectorPreferences.SETTINGS_SDK_VERSION_PREFERENCE_KEY)).let { findPreference<VectorPreference>(VectorPreferences.SETTINGS_SDK_VERSION_PREFERENCE_KEY)!!.let {
it.summary = Matrix.getSdkVersion() it.summary = Matrix.getSdkVersion()
it.setOnPreferenceClickListener { pref -> it.setOnPreferenceClickListener { pref ->
@ -81,38 +82,38 @@ class VectorSettingsHelpAboutFragment : VectorSettingsBaseFragment() {
} }
// olm version // olm version
findPreference(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_OLM_VERSION_PREFERENCE_KEY)!!
.summary = session.getCryptoVersion(requireContext(), false) .summary = session.getCryptoVersion(requireContext(), false)
// copyright // copyright
findPreference(VectorPreferences.SETTINGS_COPYRIGHT_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_COPYRIGHT_PREFERENCE_KEY)!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
activity?.displayInWebView(VectorSettingsUrls.COPYRIGHT) activity?.displayInWebView(VectorSettingsUrls.COPYRIGHT)
false false
} }
// terms & conditions // terms & conditions
findPreference(VectorPreferences.SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_APP_TERM_CONDITIONS_PREFERENCE_KEY)!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
activity?.displayInWebView(VectorSettingsUrls.TAC) activity?.displayInWebView(VectorSettingsUrls.TAC)
false false
} }
// privacy policy // privacy policy
findPreference(VectorPreferences.SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_PRIVACY_POLICY_PREFERENCE_KEY)!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
activity?.displayInWebView(VectorSettingsUrls.PRIVACY_POLICY) activity?.displayInWebView(VectorSettingsUrls.PRIVACY_POLICY)
false false
} }
// third party notice // third party notice
findPreference(VectorPreferences.SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_THIRD_PARTY_NOTICES_PREFERENCE_KEY)!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
activity?.displayInWebView(VectorSettingsUrls.THIRD_PARTY_LICENSES) activity?.displayInWebView(VectorSettingsUrls.THIRD_PARTY_LICENSES)
false false
} }
findPreference(VectorPreferences.SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_OTHER_THIRD_PARTY_NOTICES_PREFERENCE_KEY)!!
.onPreferenceClickListener = Preference.OnPreferenceClickListener { .onPreferenceClickListener = Preference.OnPreferenceClickListener {
// See https://developers.google.com/android/guides/opensource // See https://developers.google.com/android/guides/opensource
startActivity(Intent(requireActivity(), OssLicensesMenuActivity::class.java)) startActivity(Intent(requireActivity(), OssLicensesMenuActivity::class.java))

View file

@ -20,12 +20,9 @@ import androidx.appcompat.app.AlertDialog
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceCategory import androidx.preference.PreferenceCategory
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.preference.VectorPreference
import java.util.ArrayList import java.util.ArrayList
import kotlin.Comparator import kotlin.Comparator
import kotlin.String
import kotlin.getValue
import kotlin.lazy
import kotlin.let
class VectorSettingsIgnoredUsersFragment : VectorSettingsBaseFragment() { class VectorSettingsIgnoredUsersFragment : VectorSettingsBaseFragment() {
@ -34,10 +31,10 @@ class VectorSettingsIgnoredUsersFragment : VectorSettingsBaseFragment() {
// displayed the ignored users list // displayed the ignored users list
private val mIgnoredUserSettingsCategoryDivider by lazy { private val mIgnoredUserSettingsCategoryDivider by lazy {
findPreference(VectorPreferences.SETTINGS_IGNORE_USERS_DIVIDER_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_IGNORE_USERS_DIVIDER_PREFERENCE_KEY)!!
} }
private val mIgnoredUserSettingsCategory by lazy { private val mIgnoredUserSettingsCategory by lazy {
findPreference(VectorPreferences.SETTINGS_IGNORED_USERS_PREFERENCE_KEY) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_IGNORED_USERS_PREFERENCE_KEY)!!
} }
override fun bindPref() { override fun bindPref() {

View file

@ -25,6 +25,7 @@ import im.vector.matrix.android.api.pushrules.RuleKind
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.di.ActiveSessionHolder import im.vector.riotx.core.di.ActiveSessionHolder
import im.vector.riotx.core.di.ScreenComponent import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.preference.VectorSwitchPreference
import im.vector.riotx.core.pushers.PushersManager import im.vector.riotx.core.pushers.PushersManager
import im.vector.riotx.push.fcm.FcmHelper import im.vector.riotx.push.fcm.FcmHelper
import javax.inject.Inject import javax.inject.Inject
@ -40,7 +41,7 @@ class VectorSettingsNotificationPreferenceFragment : VectorSettingsBaseFragment(
@Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var vectorPreferences: VectorPreferences
override fun bindPref() { override fun bindPref() {
findPreference(VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY).let { pref -> findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY)!!.let { pref ->
val pushRuleService = session val pushRuleService = session
val mRuleMaster = pushRuleService.getPushRules() val mRuleMaster = pushRuleService.getPushRules()
.find { it.ruleId == RuleIds.RULE_ID_DISABLE_ALL } .find { it.ruleId == RuleIds.RULE_ID_DISABLE_ALL }

View file

@ -27,6 +27,8 @@ import androidx.preference.Preference
import androidx.preference.SwitchPreference import androidx.preference.SwitchPreference
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.di.ScreenComponent import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.preference.VectorListPreference
import im.vector.riotx.core.preference.VectorPreference
import im.vector.riotx.features.configuration.VectorConfiguration import im.vector.riotx.features.configuration.VectorConfiguration
import im.vector.riotx.features.themes.ThemeUtils import im.vector.riotx.features.themes.ThemeUtils
import javax.inject.Inject import javax.inject.Inject
@ -37,10 +39,10 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() {
override val preferenceXmlRes = R.xml.vector_settings_preferences override val preferenceXmlRes = R.xml.vector_settings_preferences
private val selectedLanguagePreference by lazy { private val selectedLanguagePreference by lazy {
findPreference(VectorPreferences.SETTINGS_INTERFACE_LANGUAGE_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_INTERFACE_LANGUAGE_PREFERENCE_KEY)!!
} }
private val textSizePreference by lazy { private val textSizePreference by lazy {
findPreference(VectorPreferences.SETTINGS_INTERFACE_TEXT_SIZE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_INTERFACE_TEXT_SIZE_KEY)!!
} }
@Inject lateinit var vectorConfiguration: VectorConfiguration @Inject lateinit var vectorConfiguration: VectorConfiguration
@ -56,7 +58,7 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() {
setUserInterfacePreferences() setUserInterfacePreferences()
// Themes // Themes
findPreference(ThemeUtils.APPLICATION_THEME_KEY) findPreference<VectorListPreference>(ThemeUtils.APPLICATION_THEME_KEY)!!
.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> .onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
if (newValue is String) { if (newValue is String) {
vectorConfiguration.updateApplicationTheme(newValue) vectorConfiguration.updateApplicationTheme(newValue)
@ -73,7 +75,7 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() {
} }
// Url preview // Url preview
(findPreference(VectorPreferences.SETTINGS_SHOW_URL_PREVIEW_KEY) as SwitchPreference).let { findPreference<SwitchPreference>(VectorPreferences.SETTINGS_SHOW_URL_PREVIEW_KEY)!!.let {
/* /*
TODO TODO
it.isChecked = session.isURLPreviewEnabled it.isChecked = session.isURLPreviewEnabled
@ -113,7 +115,7 @@ class VectorSettingsPreferencesFragment : VectorSettingsBaseFragment() {
} }
// update keep medias period // update keep medias period
findPreference(VectorPreferences.SETTINGS_MEDIA_SAVING_PERIOD_KEY).let { findPreference<VectorPreference>(VectorPreferences.SETTINGS_MEDIA_SAVING_PERIOD_KEY)!!.let {
it.summary = vectorPreferences.getSelectedMediasSavingPeriodString() it.summary = vectorPreferences.getSelectedMediasSavingPeriodString()
it.onPreferenceClickListener = Preference.OnPreferenceClickListener { it.onPreferenceClickListener = Preference.OnPreferenceClickListener {

View file

@ -50,6 +50,7 @@ import im.vector.riotx.core.intent.getFilenameFromUri
import im.vector.riotx.core.platform.SimpleTextWatcher import im.vector.riotx.core.platform.SimpleTextWatcher
import im.vector.riotx.core.preference.ProgressBarPreference import im.vector.riotx.core.preference.ProgressBarPreference
import im.vector.riotx.core.preference.VectorPreference import im.vector.riotx.core.preference.VectorPreference
import im.vector.riotx.core.preference.VectorPreferenceDivider
import im.vector.riotx.core.utils.* import im.vector.riotx.core.utils.*
import im.vector.riotx.features.crypto.keys.KeysExporter import im.vector.riotx.features.crypto.keys.KeysExporter
import im.vector.riotx.features.crypto.keys.KeysImporter import im.vector.riotx.features.crypto.keys.KeysImporter
@ -76,57 +77,57 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
// cryptography // cryptography
private val mCryptographyCategory by lazy { private val mCryptographyCategory by lazy {
findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_CRYPTOGRAPHY_PREFERENCE_KEY)!!
} }
private val mCryptographyCategoryDivider by lazy { private val mCryptographyCategoryDivider by lazy {
findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY) findPreference<VectorPreferenceDivider>(VectorPreferences.SETTINGS_CRYPTOGRAPHY_DIVIDER_PREFERENCE_KEY)!!
} }
// cryptography manage // cryptography manage
private val mCryptographyManageCategory by lazy { private val mCryptographyManageCategory by lazy {
findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_PREFERENCE_KEY)!!
} }
private val mCryptographyManageCategoryDivider by lazy { private val mCryptographyManageCategoryDivider by lazy {
findPreference(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_DIVIDER_PREFERENCE_KEY) findPreference<VectorPreferenceDivider>(VectorPreferences.SETTINGS_CRYPTOGRAPHY_MANAGE_DIVIDER_PREFERENCE_KEY)!!
} }
// displayed pushers // displayed pushers
private val mPushersSettingsDivider by lazy { private val mPushersSettingsDivider by lazy {
findPreference(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGET_DIVIDER_PREFERENCE_KEY) findPreference<VectorPreferenceDivider>(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGET_DIVIDER_PREFERENCE_KEY)!!
} }
private val mPushersSettingsCategory by lazy { private val mPushersSettingsCategory by lazy {
findPreference(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGETS_PREFERENCE_KEY) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_NOTIFICATIONS_TARGETS_PREFERENCE_KEY)!!
} }
private val mDevicesListSettingsCategory by lazy { private val mDevicesListSettingsCategory by lazy {
findPreference(VectorPreferences.SETTINGS_DEVICES_LIST_PREFERENCE_KEY) as PreferenceCategory findPreference<PreferenceCategory>(VectorPreferences.SETTINGS_DEVICES_LIST_PREFERENCE_KEY)!!
} }
private val mDevicesListSettingsCategoryDivider by lazy { private val mDevicesListSettingsCategoryDivider by lazy {
findPreference(VectorPreferences.SETTINGS_DEVICES_DIVIDER_PREFERENCE_KEY) findPreference<VectorPreferenceDivider>(VectorPreferences.SETTINGS_DEVICES_DIVIDER_PREFERENCE_KEY)!!
} }
private val cryptoInfoDeviceNamePreference by lazy { private val cryptoInfoDeviceNamePreference by lazy {
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY) as VectorPreference findPreference<VectorPreference>(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_NAME_PREFERENCE_KEY)!!
} }
private val cryptoInfoDeviceIdPreference by lazy { private val cryptoInfoDeviceIdPreference by lazy {
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY)!!
} }
private val manageBackupPref by lazy { private val manageBackupPref by lazy {
findPreference(VectorPreferences.SETTINGS_SECURE_MESSAGE_RECOVERY_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_SECURE_MESSAGE_RECOVERY_PREFERENCE_KEY)!!
} }
private val exportPref by lazy { private val exportPref by lazy {
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_EXPORT_E2E_ROOM_KEYS_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_ENCRYPTION_EXPORT_E2E_ROOM_KEYS_PREFERENCE_KEY)!!
} }
private val importPref by lazy { private val importPref by lazy {
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_IMPORT_E2E_ROOM_KEYS_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_ENCRYPTION_IMPORT_E2E_ROOM_KEYS_PREFERENCE_KEY)!!
} }
private val cryptoInfoTextPreference by lazy { private val cryptoInfoTextPreference by lazy {
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_KEY_PREFERENCE_KEY)!!
} }
// encrypt to unverified devices // encrypt to unverified devices
private val sendToUnverifiedDevicesPref by lazy { private val sendToUnverifiedDevicesPref by lazy {
findPreference(VectorPreferences.SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY) as SwitchPreference findPreference<SwitchPreference>(VectorPreferences.SETTINGS_ENCRYPTION_NEVER_SENT_TO_PREFERENCE_KEY)!!
} }
@Inject lateinit var vectorPreferences: VectorPreferences @Inject lateinit var vectorPreferences: VectorPreferences
@ -148,7 +149,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
// Analytics // Analytics
// Analytics tracking management // Analytics tracking management
(findPreference(VectorPreferences.SETTINGS_USE_ANALYTICS_KEY) as SwitchPreference).let { findPreference<SwitchPreference>(VectorPreferences.SETTINGS_USE_ANALYTICS_KEY)!!.let {
// On if the analytics tracking is activated // On if the analytics tracking is activated
it.isChecked = vectorPreferences.useAnalytics() it.isChecked = vectorPreferences.useAnalytics()
@ -159,7 +160,7 @@ class VectorSettingsSecurityPrivacyFragment : VectorSettingsBaseFragment() {
} }
// Rageshake Management // Rageshake Management
(findPreference(VectorPreferences.SETTINGS_USE_RAGE_SHAKE_KEY) as SwitchPreference).let { findPreference<SwitchPreference>(VectorPreferences.SETTINGS_USE_RAGE_SHAKE_KEY)!!.let {
it.isChecked = vectorPreferences.useRageshake() it.isChecked = vectorPreferences.useRageshake()
it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->

View file

@ -23,6 +23,7 @@ import android.net.Uri
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.SwitchPreference import androidx.preference.SwitchPreference
import im.vector.riotx.R import im.vector.riotx.R
import im.vector.riotx.core.preference.VectorPreference
import im.vector.riotx.core.utils.getCallRingtoneName import im.vector.riotx.core.utils.getCallRingtoneName
import im.vector.riotx.core.utils.getCallRingtoneUri import im.vector.riotx.core.utils.getCallRingtoneUri
import im.vector.riotx.core.utils.setCallRingtoneUri import im.vector.riotx.core.utils.setCallRingtoneUri
@ -34,10 +35,10 @@ class VectorSettingsVoiceVideoFragment : VectorSettingsBaseFragment() {
override val preferenceXmlRes = R.xml.vector_settings_voice_video override val preferenceXmlRes = R.xml.vector_settings_voice_video
private val mUseRiotCallRingtonePreference by lazy { private val mUseRiotCallRingtonePreference by lazy {
findPreference(VectorPreferences.SETTINGS_CALL_RINGTONE_USE_RIOT_PREFERENCE_KEY) as SwitchPreference findPreference<SwitchPreference>(VectorPreferences.SETTINGS_CALL_RINGTONE_USE_RIOT_PREFERENCE_KEY)!!
} }
private val mCallRingtonePreference by lazy { private val mCallRingtonePreference by lazy {
findPreference(VectorPreferences.SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY) findPreference<VectorPreference>(VectorPreferences.SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY)!!
} }
override fun bindPref() { override fun bindPref() {

View file

@ -79,7 +79,7 @@
<im.vector.riotx.core.preference.VectorPreference <im.vector.riotx.core.preference.VectorPreference
android:key="SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY" android:key="SETTINGS_IDENTITY_SERVER_PREFERENCE_KEY"
android:title="@string/settings_identity_server" android:title="@string/settings_identity_server"
tools:summary="@string/default_identity_server_url" /> tools:summary="https://identity.server.url" />
<im.vector.riotx.core.preference.VectorPreference <im.vector.riotx.core.preference.VectorPreference
android:key="SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY" android:key="SETTINGS_CLEAR_MEDIA_CACHE_PREFERENCE_KEY"