API 33: fix compilation warnings

This commit is contained in:
Benoit Marty 2022-09-28 14:37:59 +02:00
parent 61a4dd2128
commit f2bbdc3906
67 changed files with 287 additions and 104 deletions

View File

@ -316,10 +316,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
} }
return false return false
} }
override fun onDoubleTap(e: MotionEvent?): Boolean {
return super.onDoubleTap(e)
}
}) })
override fun onEvent(event: AttachmentEvents) { override fun onEvent(event: AttachmentEvents) {

View File

@ -113,11 +113,11 @@ internal fun ViewPropertyAnimator.setAnimatorListener(
onAnimationStart: ((Animator?) -> Unit)? = null onAnimationStart: ((Animator?) -> Unit)? = null
) = this.setListener( ) = this.setListener(
object : AnimatorListenerAdapter() { object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) { override fun onAnimationEnd(animation: Animator) {
onAnimationEnd?.invoke(animation) onAnimationEnd?.invoke(animation)
} }
override fun onAnimationStart(animation: Animator?) { override fun onAnimationStart(animation: Animator) {
onAnimationStart?.invoke(animation) onAnimationStart?.invoke(animation)
} }
}) })

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.lib.core.utils.compat
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import java.io.Serializable
inline fun <reified T> Intent.getParcelableExtraCompat(key: String): T? = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelableExtra(key, T::class.java)
else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T?
}
inline fun <reified T : Parcelable> Intent.getParcelableArrayListExtraCompat(key: String): ArrayList<T>? = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelableArrayListExtra(key, T::class.java)
else -> @Suppress("DEPRECATION") getParcelableArrayListExtra<T>(key)
}
inline fun <reified T> Bundle.getParcelableCompat(key: String): T? = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelable(key, T::class.java)
else -> @Suppress("DEPRECATION") getParcelable(key) as? T?
}
inline fun <reified T : Serializable> Bundle.getSerializableCompat(key: String): T? = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializable(key, T::class.java)
else -> @Suppress("DEPRECATION") getSerializable(key) as? T?
}
inline fun <reified T : Serializable> Intent.getSerializableExtraCompat(key: String): T? = when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializableExtra(key, T::class.java)
else -> @Suppress("DEPRECATION") getSerializableExtra(key) as? T?
}
fun PackageManager.queryIntentActivitiesCompat(data: Intent, flags: Int): List<ResolveInfo> {
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> queryIntentActivities(
data,
PackageManager.ResolveInfoFlags.of(flags.toLong())
)
else -> @Suppress("DEPRECATION") queryIntentActivities(data, flags)
}
}
fun PackageManager.resolveActivityCompat(data: Intent, flags: Int): ResolveInfo? {
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> resolveActivity(
data,
PackageManager.ResolveInfoFlags.of(flags.toLong())
)
else -> @Suppress("DEPRECATION") resolveActivity(data, flags)
}
}

View File

@ -23,6 +23,7 @@ import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.Mavericks
import im.vector.lib.core.utils.compat.getParcelableCompat
class JSonViewerDialog : DialogFragment() { class JSonViewerDialog : DialogFragment() {
@ -36,7 +37,7 @@ class JSonViewerDialog : DialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val args: JSonViewerFragmentArgs = arguments?.getParcelable(Mavericks.KEY_ARG) ?: return val args: JSonViewerFragmentArgs = arguments?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
if (savedInstanceState == null) { if (savedInstanceState == null) {
childFragmentManager.beginTransaction() childFragmentManager.beginTransaction()
.replace( .replace(

View File

@ -28,6 +28,7 @@ import com.airbnb.mvrx.Mavericks
import com.airbnb.mvrx.MavericksView import com.airbnb.mvrx.MavericksView
import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState import com.airbnb.mvrx.withState
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@Parcelize @Parcelize
@ -53,7 +54,7 @@ class JSonViewerFragment : Fragment(), MavericksView {
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
val args: JSonViewerFragmentArgs? = arguments?.getParcelable(Mavericks.KEY_ARG) val args: JSonViewerFragmentArgs? = arguments?.getParcelableCompat(Mavericks.KEY_ARG)
val inflate = val inflate =
if (args?.wrap == true) { if (args?.wrap == true) {
inflater.inflate(R.layout.fragment_jv_recycler_view_wrap, container, false) inflater.inflate(R.layout.fragment_jv_recycler_view_wrap, container, false)

View File

@ -35,9 +35,14 @@ android {
} }
} }
kotlinOptions {
jvmTarget = "11"
}
} }
dependencies { dependencies {
implementation project(":library:core-utils")
api libs.androidx.activity api libs.androidx.activity
implementation libs.androidx.exifinterface implementation libs.androidx.exifinterface
implementation libs.androidx.core implementation libs.androidx.core

View File

@ -22,6 +22,9 @@ import android.content.pm.PackageManager
import android.content.pm.ResolveInfo import android.content.pm.ResolveInfo
import android.net.Uri import android.net.Uri
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import im.vector.lib.core.utils.compat.getParcelableArrayListExtraCompat
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import im.vector.lib.core.utils.compat.queryIntentActivitiesCompat
/** /**
* Abstract class to provide all types of Pickers. * Abstract class to provide all types of Pickers.
@ -45,13 +48,13 @@ abstract class Picker<T> {
val uriList = mutableListOf<Uri>() val uriList = mutableListOf<Uri>()
if (data.action == Intent.ACTION_SEND) { if (data.action == Intent.ACTION_SEND) {
(data.getParcelableExtra(Intent.EXTRA_STREAM) as? Uri)?.let { uriList.add(it) } data.getParcelableExtraCompat<Uri>(Intent.EXTRA_STREAM)?.let { uriList.add(it) }
} else if (data.action == Intent.ACTION_SEND_MULTIPLE) { } else if (data.action == Intent.ACTION_SEND_MULTIPLE) {
val extraUriList: List<Uri>? = data.getParcelableArrayListExtra(Intent.EXTRA_STREAM) val extraUriList: List<Uri>? = data.getParcelableArrayListExtraCompat(Intent.EXTRA_STREAM)
extraUriList?.let { uriList.addAll(it) } extraUriList?.let { uriList.addAll(it) }
} }
val resInfoList: List<ResolveInfo> = context.packageManager.queryIntentActivities(data, PackageManager.MATCH_DEFAULT_ONLY) val resInfoList: List<ResolveInfo> = context.packageManager.queryIntentActivitiesCompat(data, PackageManager.MATCH_DEFAULT_ONLY)
uriList.forEach { uriList.forEach {
for (resolveInfo in resInfoList) { for (resolveInfo in resInfoList) {
val packageName: String = resolveInfo.activityInfo.packageName val packageName: String = resolveInfo.activityInfo.packageName
@ -91,6 +94,7 @@ abstract class Picker<T> {
} else if (dataUri != null) { } else if (dataUri != null) {
selectedUriList.add(dataUri) selectedUriList.add(dataUri)
} else { } else {
@Suppress("DEPRECATION")
data?.extras?.get(Intent.EXTRA_STREAM)?.let { data?.extras?.get(Intent.EXTRA_STREAM)?.let {
(it as? List<*>)?.filterIsInstance<Uri>()?.let { uriList -> (it as? List<*>)?.filterIsInstance<Uri>()?.let { uriList ->
selectedUriList.addAll(uriList) selectedUriList.addAll(uriList)

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.api.util
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Build
fun PackageManager.getApplicationInfoCompat(packageName: String, flags: Int): ApplicationInfo {
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getApplicationInfo(
packageName,
PackageManager.ApplicationInfoFlags.of(flags.toLong())
)
else -> @Suppress("DEPRECATION") getApplicationInfo(packageName, flags)
}
}
fun PackageManager.getPackageInfoCompat(packageName: String, flags: Int): PackageInfo {
return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getPackageInfo(
packageName,
PackageManager.PackageInfoFlags.of(flags.toLong())
)
else -> @Suppress("DEPRECATION") getPackageInfo(packageName, flags)
}
}

View File

@ -20,6 +20,7 @@ import android.content.Context
import android.os.Build import android.os.Build
import org.matrix.android.sdk.BuildConfig import org.matrix.android.sdk.BuildConfig
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.util.getPackageInfoCompat
import javax.inject.Inject import javax.inject.Inject
class ComputeUserAgentUseCase @Inject constructor( class ComputeUserAgentUseCase @Inject constructor(
@ -44,7 +45,7 @@ class ComputeUserAgentUseCase @Inject constructor(
// Use appPackageName instead of appName if appName is null or contains any non-ASCII character // Use appPackageName instead of appName if appName is null or contains any non-ASCII character
appPackageName appPackageName
} }
val appVersion = tryOrNull { pm.getPackageInfo(context.applicationContext.packageName, 0).versionName } ?: FALLBACK_APP_VERSION val appVersion = tryOrNull { pm.getPackageInfoCompat(context.applicationContext.packageName, 0).versionName } ?: FALLBACK_APP_VERSION
val deviceManufacturer = Build.MANUFACTURER val deviceManufacturer = Build.MANUFACTURER
val deviceModel = Build.MODEL val deviceModel = Build.MODEL

View File

@ -27,6 +27,7 @@ import org.amshove.kluent.shouldBeEqualTo
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.matrix.android.sdk.BuildConfig import org.matrix.android.sdk.BuildConfig
import org.matrix.android.sdk.api.util.getPackageInfoCompat
import java.lang.Exception import java.lang.Exception
private const val A_PACKAGE_NAME = "org.matrix.sdk" private const val A_PACKAGE_NAME = "org.matrix.sdk"
@ -50,7 +51,7 @@ class ComputeUserAgentUseCaseTest {
every { context.packageName } returns A_PACKAGE_NAME every { context.packageName } returns A_PACKAGE_NAME
every { context.packageManager } returns packageManager every { context.packageManager } returns packageManager
every { packageManager.getApplicationInfo(any(), any()) } returns applicationInfo every { packageManager.getApplicationInfo(any(), any()) } returns applicationInfo
every { packageManager.getPackageInfo(any<String>(), any()) } returns packageInfo every { packageManager.getPackageInfoCompat(any(), any()) } returns packageInfo
} }
@Test @Test

View File

@ -19,19 +19,19 @@ package im.vector.app.core.animations
import android.animation.Animator import android.animation.Animator
open class SimpleAnimatorListener : Animator.AnimatorListener { open class SimpleAnimatorListener : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) { override fun onAnimationRepeat(animation: Animator) {
// No op // No op
} }
override fun onAnimationEnd(animation: Animator?) { override fun onAnimationEnd(animation: Animator) {
// No op // No op
} }
override fun onAnimationCancel(animation: Animator?) { override fun onAnimationCancel(animation: Animator) {
// No op // No op
} }
override fun onAnimationStart(animation: Animator?) { override fun onAnimationStart(animation: Animator) {
// No op // No op
} }
} }

View File

@ -21,6 +21,7 @@ import android.os.Parcelable
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import im.vector.app.core.platform.DefaultListUpdateCallback import im.vector.app.core.platform.DefaultListUpdateCallback
import im.vector.app.core.platform.Restorable import im.vector.app.core.platform.Restorable
import im.vector.lib.core.utils.compat.getParcelableCompat
import java.util.concurrent.atomic.AtomicReference import java.util.concurrent.atomic.AtomicReference
private const val LAYOUT_MANAGER_STATE = "LAYOUT_MANAGER_STATE" private const val LAYOUT_MANAGER_STATE = "LAYOUT_MANAGER_STATE"
@ -44,7 +45,7 @@ class LayoutManagerStateRestorer(layoutManager: RecyclerView.LayoutManager) : Re
} }
override fun onRestoreInstanceState(savedInstanceState: Bundle?) { override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
val parcelable = savedInstanceState?.getParcelable<Parcelable>(LAYOUT_MANAGER_STATE) val parcelable = savedInstanceState?.getParcelableCompat<Parcelable>(LAYOUT_MANAGER_STATE)
layoutManagerState.set(parcelable) layoutManagerState.set(parcelable)
} }

View File

@ -25,6 +25,7 @@ import com.airbnb.mvrx.MavericksViewModelProvider
inline fun <reified VM : MavericksViewModel<S>, reified S : MavericksState> ComponentActivity.lazyViewModel(): Lazy<VM> { inline fun <reified VM : MavericksViewModel<S>, reified S : MavericksState> ComponentActivity.lazyViewModel(): Lazy<VM> {
return lazy(mode = LazyThreadSafetyMode.NONE) { return lazy(mode = LazyThreadSafetyMode.NONE) {
@Suppress("DEPRECATION")
MavericksViewModelProvider.get( MavericksViewModelProvider.get(
viewModelClass = VM::class.java, viewModelClass = VM::class.java,
stateClass = S::class.java, stateClass = S::class.java,

View File

@ -22,6 +22,7 @@ import android.animation.ValueAnimator
import android.view.View import android.view.View
import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AccelerateDecelerateInterpolator
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import im.vector.app.core.animations.SimpleAnimatorListener
fun ViewPager2.setCurrentItem( fun ViewPager2.setCurrentItem(
item: Int, item: Int,
@ -45,19 +46,16 @@ fun ViewPager2.setCurrentItem(
previousValue = currentValue previousValue = currentValue
}.onFailure { animator.cancel() } }.onFailure { animator.cancel() }
} }
animator.addListener(object : Animator.AnimatorListener { animator.addListener(object : SimpleAnimatorListener() {
override fun onAnimationStart(animation: Animator?) { override fun onAnimationStart(animation: Animator) {
isUserInputEnabled = false isUserInputEnabled = false
beginFakeDrag() beginFakeDrag()
} }
override fun onAnimationEnd(animation: Animator?) { override fun onAnimationEnd(animation: Animator) {
isUserInputEnabled = true isUserInputEnabled = true
endFakeDrag() endFakeDrag()
} }
override fun onAnimationCancel(animation: Animator?) = Unit
override fun onAnimationRepeat(animation: Animator?) = Unit
}) })
animator.interpolator = interpolator animator.interpolator = interpolator
animator.duration = duration animator.duration = duration

View File

@ -19,6 +19,7 @@ package im.vector.app.core.resources
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import androidx.annotation.NonNull import androidx.annotation.NonNull
import org.matrix.android.sdk.api.util.getPackageInfoCompat
import javax.inject.Inject import javax.inject.Inject
class VersionCodeProvider @Inject constructor(private val context: Context) { class VersionCodeProvider @Inject constructor(private val context: Context) {
@ -28,7 +29,7 @@ class VersionCodeProvider @Inject constructor(private val context: Context) {
*/ */
@NonNull @NonNull
fun getVersionCode(): Long { fun getVersionCode(): Long {
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0) val packageInfo = context.packageManager.getPackageInfoCompat(context.packageName, 0)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
packageInfo.longVersionCode packageInfo.longVersionCode

View File

@ -23,6 +23,7 @@ import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter import android.content.IntentFilter
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
class BluetoothHeadsetReceiver : BroadcastReceiver() { class BluetoothHeadsetReceiver : BroadcastReceiver() {
@ -59,7 +60,7 @@ class BluetoothHeadsetReceiver : BroadcastReceiver() {
else -> return // ignore intermediate states else -> return // ignore intermediate states
} }
val device = intent.getParcelableExtra<BluetoothDevice>(BluetoothDevice.EXTRA_DEVICE) val device = intent.getParcelableExtraCompat<BluetoothDevice>(BluetoothDevice.EXTRA_DEVICE)
val deviceName = device?.name val deviceName = device?.name
when (device?.bluetoothClass?.deviceClass) { when (device?.bluetoothClass?.deviceClass) {
BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE, BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE,

View File

@ -39,6 +39,8 @@ import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.notifications.NotificationUtils
import im.vector.app.features.popup.IncomingCallAlert import im.vector.app.features.popup.IncomingCallAlert
import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.popup.PopupAlertManager
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import im.vector.lib.core.utils.compat.getSerializableExtraCompat
import org.matrix.android.sdk.api.logger.LoggerTag import org.matrix.android.sdk.api.logger.LoggerTag
import org.matrix.android.sdk.api.session.room.model.call.EndCallReason import org.matrix.android.sdk.api.session.room.model.call.EndCallReason
import org.matrix.android.sdk.api.util.MatrixItem import org.matrix.android.sdk.api.util.MatrixItem
@ -71,7 +73,7 @@ class CallAndroidService : VectorAndroidService() {
private var mediaSession: MediaSessionCompat? = null private var mediaSession: MediaSessionCompat? = null
private val mediaSessionButtonCallback = object : MediaSessionCompat.Callback() { private val mediaSessionButtonCallback = object : MediaSessionCompat.Callback() {
override fun onMediaButtonEvent(mediaButtonEvent: Intent?): Boolean { override fun onMediaButtonEvent(mediaButtonEvent: Intent?): Boolean {
val keyEvent = mediaButtonEvent?.getParcelableExtra<KeyEvent>(Intent.EXTRA_KEY_EVENT) ?: return false val keyEvent = mediaButtonEvent?.getParcelableExtraCompat<KeyEvent>(Intent.EXTRA_KEY_EVENT) ?: return false
if (keyEvent.keyCode == KeyEvent.KEYCODE_HEADSETHOOK) { if (keyEvent.keyCode == KeyEvent.KEYCODE_HEADSETHOOK) {
callManager.headSetButtonTapped() callManager.headSetButtonTapped()
return true return true
@ -158,7 +160,7 @@ class CallAndroidService : VectorAndroidService() {
val incomingCallAlert = IncomingCallAlert(callId, val incomingCallAlert = IncomingCallAlert(callId,
shouldBeDisplayedIn = { activity -> shouldBeDisplayedIn = { activity ->
if (activity is VectorCallActivity) { if (activity is VectorCallActivity) {
activity.intent.getParcelableExtra<CallArgs>(Mavericks.KEY_ARG)?.callId != call.callId activity.intent.getParcelableExtraCompat<CallArgs>(Mavericks.KEY_ARG)?.callId != call.callId
} else true } else true
} }
).apply { ).apply {
@ -188,7 +190,7 @@ class CallAndroidService : VectorAndroidService() {
private fun handleCallTerminated(intent: Intent) { private fun handleCallTerminated(intent: Intent) {
val callId = intent.getStringExtra(EXTRA_CALL_ID) ?: "" val callId = intent.getStringExtra(EXTRA_CALL_ID) ?: ""
val endCallReason = intent.getSerializableExtra(EXTRA_END_CALL_REASON) as EndCallReason val endCallReason = intent.getSerializableExtraCompat<EndCallReason>(EXTRA_END_CALL_REASON)
val rejected = intent.getBooleanExtra(EXTRA_END_CALL_REJECTED, false) val rejected = intent.getBooleanExtra(EXTRA_END_CALL_REJECTED, false)
alertManager.cancelAlert(callId) alertManager.cancelAlert(callId)
val terminatedCall = knownCalls.remove(callId) val terminatedCall = knownCalls.remove(callId)
@ -202,7 +204,7 @@ class CallAndroidService : VectorAndroidService() {
startForeground(notificationId, notification) startForeground(notificationId, notification)
if (knownCalls.isEmpty()) { if (knownCalls.isEmpty()) {
Timber.tag(loggerTag.value).v("No more call, stop the service") Timber.tag(loggerTag.value).v("No more call, stop the service")
stopForeground(true) stopForegroundCompat()
mediaSession?.isActive = false mediaSession?.isActive = false
myStopSelf() myStopSelf()
} }

View File

@ -18,6 +18,7 @@ package im.vector.app.core.services
import android.app.Service import android.app.Service
import android.content.Intent import android.content.Intent
import android.os.Build
import android.os.IBinder import android.os.IBinder
import timber.log.Timber import timber.log.Timber
@ -55,4 +56,13 @@ abstract class VectorAndroidService : Service() {
override fun onBind(intent: Intent?): IBinder? { override fun onBind(intent: Intent?): IBinder? {
return null return null
} }
protected fun stopForegroundCompat() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
stopForeground(STOP_FOREGROUND_REMOVE)
} else {
@Suppress("DEPRECATION")
stopForeground(true)
}
}
} }

View File

@ -34,6 +34,7 @@ import androidx.core.content.getSystemService
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import im.vector.app.R import im.vector.app.R
import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.notifications.NotificationUtils
import org.matrix.android.sdk.api.util.getApplicationInfoCompat
/** /**
* Tells if the application ignores battery optimizations. * Tells if the application ignores battery optimizations.
@ -63,7 +64,7 @@ fun Context.isAnimationEnabled(): Boolean {
*/ */
fun Context.getApplicationLabel(packageName: String): String { fun Context.getApplicationLabel(packageName: String): String {
return try { return try {
val ai = packageManager.getApplicationInfo(packageName, 0) val ai = packageManager.getApplicationInfoCompat(packageName, 0)
packageManager.getApplicationLabel(ai).toString() packageManager.getApplicationLabel(ai).toString()
} catch (e: PackageManager.NameNotFoundException) { } catch (e: PackageManager.NameNotFoundException) {
packageName packageName

View File

@ -57,6 +57,7 @@ import im.vector.app.features.start.StartAppViewModel
import im.vector.app.features.start.StartAppViewState import im.vector.app.features.start.StartAppViewState
import im.vector.app.features.themes.ActivityOtherThemes import im.vector.app.features.themes.ActivityOtherThemes
import im.vector.app.features.ui.UiStateRepository import im.vector.app.features.ui.UiStateRepository
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -181,7 +182,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
private fun handleAppStarted() { private fun handleAppStarted() {
if (intent.hasExtra(EXTRA_NEXT_INTENT)) { if (intent.hasExtra(EXTRA_NEXT_INTENT)) {
// Start the next Activity // Start the next Activity
val nextIntent = intent.getParcelableExtra<Intent>(EXTRA_NEXT_INTENT) val nextIntent = intent.getParcelableExtraCompat<Intent>(EXTRA_NEXT_INTENT)
startIntentAndFinish(nextIntent) startIntentAndFinish(nextIntent)
} else if (intent.hasExtra(EXTRA_INIT_SESSION)) { } else if (intent.hasExtra(EXTRA_INIT_SESSION)) {
setResult(RESULT_OK) setResult(RESULT_OK)
@ -218,7 +219,7 @@ class MainActivity : VectorBaseActivity<ActivityMainBinding>(), UnlockedActivity
} }
private fun parseArgs(): MainActivityArgs { private fun parseArgs(): MainActivityArgs {
val argsFromIntent: MainActivityArgs? = intent.getParcelableExtra(EXTRA_ARGS) val argsFromIntent: MainActivityArgs? = intent.getParcelableExtraCompat(EXTRA_ARGS)
Timber.w("Starting MainActivity with $argsFromIntent") Timber.w("Starting MainActivity with $argsFromIntent")
return MainActivityArgs( return MainActivityArgs(

View File

@ -26,6 +26,8 @@ import im.vector.app.core.dialogs.PhotoOrVideoDialog
import im.vector.app.core.platform.Restorable import im.vector.app.core.platform.Restorable
import im.vector.app.core.resources.BuildMeta import im.vector.app.core.resources.BuildMeta
import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.VectorPreferences
import im.vector.lib.core.utils.compat.getParcelableCompat
import im.vector.lib.core.utils.compat.getSerializableCompat
import im.vector.lib.multipicker.MultiPicker import im.vector.lib.multipicker.MultiPicker
import org.matrix.android.sdk.api.session.content.ContentAttachmentData import org.matrix.android.sdk.api.session.content.ContentAttachmentData
import timber.log.Timber import timber.log.Timber
@ -66,8 +68,8 @@ class AttachmentsHelper(
} }
override fun onRestoreInstanceState(savedInstanceState: Bundle?) { override fun onRestoreInstanceState(savedInstanceState: Bundle?) {
captureUri = savedInstanceState?.getParcelable(CAPTURE_PATH_KEY) as? Uri captureUri = savedInstanceState?.getParcelableCompat(CAPTURE_PATH_KEY)
pendingType = savedInstanceState?.getSerializable(PENDING_TYPE_KEY) as? AttachmentTypeSelectorView.Type pendingType = savedInstanceState?.getSerializableCompat(PENDING_TYPE_KEY)
} }
// Public Methods // Public Methods

View File

@ -24,6 +24,8 @@ import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.databinding.ActivitySimpleBinding
import im.vector.app.features.themes.ActivityOtherThemes import im.vector.app.features.themes.ActivityOtherThemes
import im.vector.lib.core.utils.compat.getParcelableArrayListExtraCompat
import im.vector.lib.core.utils.compat.getParcelableCompat
import org.matrix.android.sdk.api.session.content.ContentAttachmentData import org.matrix.android.sdk.api.session.content.ContentAttachmentData
@AndroidEntryPoint @AndroidEntryPoint
@ -41,7 +43,7 @@ class AttachmentsPreviewActivity : VectorBaseActivity<ActivitySimpleBinding>() {
} }
fun getOutput(intent: Intent): List<ContentAttachmentData> { fun getOutput(intent: Intent): List<ContentAttachmentData> {
return intent.getParcelableArrayListExtra<ContentAttachmentData>(ATTACHMENTS_PREVIEW_RESULT).orEmpty() return intent.getParcelableArrayListExtraCompat<ContentAttachmentData>(ATTACHMENTS_PREVIEW_RESULT).orEmpty()
} }
fun getKeepOriginalSize(intent: Intent): Boolean { fun getKeepOriginalSize(intent: Intent): Boolean {
@ -57,7 +59,7 @@ class AttachmentsPreviewActivity : VectorBaseActivity<ActivitySimpleBinding>() {
override fun initUiAndData() { override fun initUiAndData() {
if (isFirstCreation()) { if (isFirstCreation()) {
val fragmentArgs: AttachmentsPreviewArgs = intent?.extras?.getParcelable(EXTRA_FRAGMENT_ARGS) ?: return val fragmentArgs: AttachmentsPreviewArgs = intent?.extras?.getParcelableCompat(EXTRA_FRAGMENT_ARGS) ?: return
addFragment(views.simpleFragmentContainer, AttachmentsPreviewFragment::class.java, fragmentArgs) addFragment(views.simpleFragmentContainer, AttachmentsPreviewFragment::class.java, fragmentArgs)
} }
} }

View File

@ -69,6 +69,7 @@ import im.vector.app.features.displayname.getBestName
import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.RoomDetailActivity import im.vector.app.features.home.room.detail.RoomDetailActivity
import im.vector.app.features.home.room.detail.arguments.TimelineArgs import im.vector.app.features.home.room.detail.arguments.TimelineArgs
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import io.github.hyuwah.draggableviewlib.DraggableView import io.github.hyuwah.draggableviewlib.DraggableView
import io.github.hyuwah.draggableviewlib.setupDraggable import io.github.hyuwah.draggableviewlib.setupDraggable
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@ -178,7 +179,7 @@ class VectorCallActivity :
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent) super.onNewIntent(intent)
intent?.takeIf { it.hasExtra(Mavericks.KEY_ARG) } intent?.takeIf { it.hasExtra(Mavericks.KEY_ARG) }
?.let { intent.getParcelableExtra<CallArgs>(Mavericks.KEY_ARG) } ?.let { intent.getParcelableExtraCompat<CallArgs>(Mavericks.KEY_ARG) }
?.let { ?.let {
callViewModel.handle(VectorCallViewActions.SwitchCall(it)) callViewModel.handle(VectorCallViewActions.SwitchCall(it))
} }

View File

@ -38,6 +38,7 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityJitsiBinding import im.vector.app.databinding.ActivityJitsiBinding
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import org.jitsi.meet.sdk.JitsiMeet import org.jitsi.meet.sdk.JitsiMeet
import org.jitsi.meet.sdk.JitsiMeetActivityDelegate import org.jitsi.meet.sdk.JitsiMeetActivityDelegate
@ -200,7 +201,7 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
// Is it a switch to another conf? // Is it a switch to another conf?
intent?.takeIf { it.hasExtra(Mavericks.KEY_ARG) } intent?.takeIf { it.hasExtra(Mavericks.KEY_ARG) }
?.let { intent.getParcelableExtra<Args>(Mavericks.KEY_ARG) } ?.let { intent.getParcelableExtraCompat<Args>(Mavericks.KEY_ARG) }
?.let { ?.let {
jitsiViewModel.handle(JitsiCallViewActions.SwitchTo(it, true)) jitsiViewModel.handle(JitsiCallViewActions.SwitchTo(it, true))
} }

View File

@ -28,6 +28,7 @@ import im.vector.app.R
import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.error.ErrorFormatter
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityCallTransferBinding import im.vector.app.databinding.ActivityCallTransferBinding
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import javax.inject.Inject import javax.inject.Inject
@ -112,7 +113,7 @@ class CallTransferActivity : VectorBaseActivity<ActivityCallTransferBinding>() {
} }
fun getCallTransferResult(intent: Intent?): CallTransferResult? { fun getCallTransferResult(intent: Intent?): CallTransferResult? {
return intent?.extras?.getParcelable(EXTRA_TRANSFER_RESULT) return intent?.extras?.getParcelableCompat(EXTRA_TRANSFER_RESULT)
} }
} }
} }

View File

@ -26,6 +26,7 @@ import im.vector.app.features.home.room.detail.RoomDetailActivity
import im.vector.app.features.home.room.detail.arguments.TimelineArgs import im.vector.app.features.home.room.detail.arguments.TimelineArgs
import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.popup.PopupAlertManager
import im.vector.app.features.popup.VerificationVectorAlert import im.vector.app.features.popup.VerificationVectorAlert
import im.vector.lib.core.utils.compat.getParcelableCompat
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.verification.PendingVerificationRequest import org.matrix.android.sdk.api.session.crypto.verification.PendingVerificationRequest
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
@ -147,7 +148,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
R.drawable.ic_shield_black, R.drawable.ic_shield_black,
shouldBeDisplayedIn = { activity -> shouldBeDisplayedIn = { activity ->
if (activity is RoomDetailActivity) { if (activity is RoomDetailActivity) {
activity.intent?.extras?.getParcelable<TimelineArgs>(RoomDetailActivity.EXTRA_ROOM_DETAIL_ARGS)?.let { activity.intent?.extras?.getParcelableCompat<TimelineArgs>(RoomDetailActivity.EXTRA_ROOM_DETAIL_ARGS)?.let {
it.roomId != pr.roomId it.roomId != pr.roomId
} ?: true } ?: true
} else true } else true

View File

@ -27,6 +27,7 @@ import im.vector.app.core.extensions.cleanup
import im.vector.app.core.extensions.configureWith import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.BottomSheetVerificationChildFragmentBinding import im.vector.app.databinding.BottomSheetVerificationChildFragmentBinding
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import javax.inject.Inject import javax.inject.Inject
@ -49,7 +50,7 @@ class VerificationQRWaitingFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setupRecyclerView() setupRecyclerView()
(arguments?.getParcelable(Mavericks.KEY_ARG) as? Args)?.let { (arguments?.getParcelableCompat<Args>(Mavericks.KEY_ARG))?.let {
controller.update(it) controller.update(it)
} }
} }

View File

@ -86,6 +86,7 @@ import im.vector.app.features.spaces.share.ShareSpaceBottomSheet
import im.vector.app.features.themes.ThemeUtils import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.usercode.UserCodeActivity import im.vector.app.features.usercode.UserCodeActivity
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -245,7 +246,7 @@ class HomeActivity :
} }
.launchIn(lifecycleScope) .launchIn(lifecycleScope)
val args = intent.getParcelableExtra<HomeActivityArgs>(Mavericks.KEY_ARG) val args = intent.getParcelableExtraCompat<HomeActivityArgs>(Mavericks.KEY_ARG)
if (args?.clearNotification == true) { if (args?.clearNotification == true) {
notificationDrawerManager.clearAllEvents() notificationDrawerManager.clearAllEvents()
@ -327,7 +328,7 @@ class HomeActivity :
private fun migrateThreadsIfNeeded(checkSession: Boolean) { private fun migrateThreadsIfNeeded(checkSession: Boolean) {
if (checkSession) { if (checkSession) {
// We should check session to ensure we will only clear cache if needed // We should check session to ensure we will only clear cache if needed
val args = intent.getParcelableExtra<HomeActivityArgs>(Mavericks.KEY_ARG) val args = intent.getParcelableExtraCompat<HomeActivityArgs>(Mavericks.KEY_ARG)
if (args?.hasExistingSession == true) { if (args?.hasExistingSession == true) {
// existingSession --> Will be true only if we came from an existing active session // existingSession --> Will be true only if we came from an existing active session
Timber.i("----> Migrating threads from an existing session..") Timber.i("----> Migrating threads from an existing session..")
@ -538,7 +539,7 @@ class HomeActivity :
override fun onNewIntent(intent: Intent?) { override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent) super.onNewIntent(intent)
val parcelableExtra = intent?.getParcelableExtra<HomeActivityArgs>(Mavericks.KEY_ARG) val parcelableExtra = intent?.getParcelableExtraCompat<HomeActivityArgs>(Mavericks.KEY_ARG)
if (parcelableExtra?.clearNotification == true) { if (parcelableExtra?.clearNotification == true) {
notificationDrawerManager.clearAllEvents() notificationDrawerManager.clearAllEvents()
} }

View File

@ -41,6 +41,7 @@ import im.vector.app.features.raw.wellknown.isSecureBackupRequired
import im.vector.app.features.raw.wellknown.withElementWellKnown import im.vector.app.features.raw.wellknown.withElementWellKnown
import im.vector.app.features.session.coroutineScope import im.vector.app.features.session.coroutineScope
import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.VectorPreferences
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
@ -96,7 +97,7 @@ class HomeActivityViewModel @AssistedInject constructor(
companion object : MavericksViewModelFactory<HomeActivityViewModel, HomeActivityViewState> by hiltMavericksViewModelFactory() { companion object : MavericksViewModelFactory<HomeActivityViewModel, HomeActivityViewState> by hiltMavericksViewModelFactory() {
override fun initialState(viewModelContext: ViewModelContext): HomeActivityViewState? { override fun initialState(viewModelContext: ViewModelContext): HomeActivityViewState? {
val activity: HomeActivity = viewModelContext.activity() val activity: HomeActivity = viewModelContext.activity()
val args: HomeActivityArgs? = activity.intent.getParcelableExtra(Mavericks.KEY_ARG) val args: HomeActivityArgs? = activity.intent.getParcelableExtraCompat(Mavericks.KEY_ARG)
return args?.let { HomeActivityViewState(authenticationDescription = it.authenticationDescription) } return args?.let { HomeActivityViewState(authenticationDescription = it.authenticationDescription) }
?: super.initialState(viewModelContext) ?: super.initialState(viewModelContext)
} }

View File

@ -46,6 +46,7 @@ import im.vector.app.features.navigation.Navigator
import im.vector.app.features.room.RequireActiveMembershipAction import im.vector.app.features.room.RequireActiveMembershipAction
import im.vector.app.features.room.RequireActiveMembershipViewEvents import im.vector.app.features.room.RequireActiveMembershipViewEvents
import im.vector.app.features.room.RequireActiveMembershipViewModel import im.vector.app.features.room.RequireActiveMembershipViewModel
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import javax.inject.Inject import javax.inject.Inject
@ -99,7 +100,7 @@ class RoomDetailActivity :
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false) supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)
waitingView = views.waitingView.waitingView waitingView = views.waitingView.waitingView
val timelineArgs: TimelineArgs = intent?.extras?.getParcelable(EXTRA_ROOM_DETAIL_ARGS) ?: return val timelineArgs: TimelineArgs = intent?.extras?.getParcelableCompat(EXTRA_ROOM_DETAIL_ARGS) ?: return
intent.putExtra(Mavericks.KEY_ARG, timelineArgs) intent.putExtra(Mavericks.KEY_ARG, timelineArgs)
currentRoomId = timelineArgs.roomId currentRoomId = timelineArgs.roomId

View File

@ -774,7 +774,7 @@ class TimelineFragment :
} }
// We use a custom layout for this menu item, so we need to set a ClickListener // We use a custom layout for this menu item, so we need to set a ClickListener
menu.findItem(R.id.open_matrix_apps)?.let { menuItem -> menu.findItem(R.id.open_matrix_apps)?.let { menuItem ->
menuItem.actionView.debouncedClicks { menuItem.actionView?.debouncedClicks {
handleMenuItemSelected(menuItem) handleMenuItemSelected(menuItem)
} }
} }
@ -785,7 +785,7 @@ class TimelineFragment :
// Custom thread notification menu item // Custom thread notification menu item
menu.findItem(R.id.menu_timeline_thread_list)?.let { menuItem -> menu.findItem(R.id.menu_timeline_thread_list)?.let { menuItem ->
menuItem.actionView.debouncedClicks { menuItem.actionView?.debouncedClicks {
handleMenuItemSelected(menuItem) handleMenuItemSelected(menuItem)
} }
} }
@ -814,16 +814,16 @@ class TimelineFragment :
// icon should be default color no badge // icon should be default color no badge
val actionView = matrixAppsMenuItem.actionView val actionView = matrixAppsMenuItem.actionView
actionView actionView
.findViewById<ImageView>(R.id.action_view_icon_image) ?.findViewById<ImageView>(R.id.action_view_icon_image)
.setColorFilter(ThemeUtils.getColor(requireContext(), R.attr.vctr_content_secondary)) ?.setColorFilter(ThemeUtils.getColor(requireContext(), R.attr.vctr_content_secondary))
actionView.findViewById<TextView>(R.id.cart_badge).isVisible = false actionView?.findViewById<TextView>(R.id.cart_badge)?.isVisible = false
matrixAppsMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER) matrixAppsMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
} else { } else {
val actionView = matrixAppsMenuItem.actionView val actionView = matrixAppsMenuItem.actionView
actionView actionView
.findViewById<ImageView>(R.id.action_view_icon_image) ?.findViewById<ImageView>(R.id.action_view_icon_image)
.setColorFilter(colorProvider.getColorFromAttribute(R.attr.colorPrimary)) ?.setColorFilter(colorProvider.getColorFromAttribute(R.attr.colorPrimary))
actionView.findViewById<TextView>(R.id.cart_badge).setTextOrHide("$widgetsCount") actionView?.findViewById<TextView>(R.id.cart_badge)?.setTextOrHide("$widgetsCount")
@Suppress("AlwaysShowAction") @Suppress("AlwaysShowAction")
matrixAppsMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS) matrixAppsMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS)
} }
@ -895,7 +895,7 @@ class TimelineFragment :
*/ */
private fun updateMenuThreadNotificationBadge(menu: Menu, state: RoomDetailViewState) { private fun updateMenuThreadNotificationBadge(menu: Menu, state: RoomDetailViewState) {
val menuThreadList = menu.findItem(R.id.menu_timeline_thread_list).actionView val menuThreadList = menu.findItem(R.id.menu_timeline_thread_list).actionView
val badgeFrameLayout = menuThreadList.findViewById<FrameLayout>(R.id.threadNotificationBadgeFrameLayout) val badgeFrameLayout = menuThreadList?.findViewById<FrameLayout>(R.id.threadNotificationBadgeFrameLayout) ?: return
val badgeTextView = menuThreadList.findViewById<TextView>(R.id.threadNotificationBadgeTextView) val badgeTextView = menuThreadList.findViewById<TextView>(R.id.threadNotificationBadgeTextView)
val unreadThreadMessages = state.threadNotificationBadgeState.numberOfLocalUnreadThreads val unreadThreadMessages = state.threadNotificationBadgeState.numberOfLocalUnreadThreads

View File

@ -25,6 +25,7 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySearchBinding import im.vector.app.databinding.ActivitySearchBinding
import im.vector.lib.core.utils.compat.getParcelableCompat
@AndroidEntryPoint @AndroidEntryPoint
class SearchActivity : VectorBaseActivity<ActivitySearchBinding>() { class SearchActivity : VectorBaseActivity<ActivitySearchBinding>() {
@ -46,7 +47,7 @@ class SearchActivity : VectorBaseActivity<ActivitySearchBinding>() {
override fun initUiAndData() { override fun initUiAndData() {
if (isFirstCreation()) { if (isFirstCreation()) {
val fragmentArgs: SearchArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return val fragmentArgs: SearchArgs = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
addFragment(views.searchFragmentContainer, SearchFragment::class.java, fragmentArgs, FRAGMENT_TAG) addFragment(views.searchFragmentContainer, SearchFragment::class.java, fragmentArgs, FRAGMENT_TAG)
} }
views.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { views.searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {

View File

@ -34,6 +34,7 @@ import im.vector.app.features.home.room.detail.arguments.TimelineArgs
import im.vector.app.features.home.room.threads.arguments.ThreadListArgs import im.vector.app.features.home.room.threads.arguments.ThreadListArgs
import im.vector.app.features.home.room.threads.arguments.ThreadTimelineArgs import im.vector.app.features.home.room.threads.arguments.ThreadTimelineArgs
import im.vector.app.features.home.room.threads.list.views.ThreadListFragment import im.vector.app.features.home.room.threads.list.views.ThreadListFragment
import im.vector.lib.core.utils.compat.getParcelableCompat
import javax.inject.Inject import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint
@ -129,8 +130,8 @@ class ThreadsActivity : VectorBaseActivity<ActivityThreadsBinding>() {
return DisplayFragment.ErrorFragment return DisplayFragment.ErrorFragment
} }
private fun getThreadTimelineArgs(): ThreadTimelineArgs? = intent?.extras?.getParcelable(THREAD_TIMELINE_ARGS) private fun getThreadTimelineArgs(): ThreadTimelineArgs? = intent?.extras?.getParcelableCompat(THREAD_TIMELINE_ARGS)
private fun getThreadListArgs(): ThreadListArgs? = intent?.extras?.getParcelable(THREAD_LIST_ARGS) private fun getThreadListArgs(): ThreadListArgs? = intent?.extras?.getParcelableCompat(THREAD_LIST_ARGS)
private fun getEventIdToNavigate(): String? = intent?.extras?.getString(THREAD_EVENT_ID_TO_NAVIGATE) private fun getEventIdToNavigate(): String? = intent?.extras?.getString(THREAD_EVENT_ID_TO_NAVIGATE)
companion object { companion object {

View File

@ -78,7 +78,7 @@ class ThreadListFragment :
override fun handlePostCreateMenu(menu: Menu) { override fun handlePostCreateMenu(menu: Menu) {
// We use a custom layout for this menu item, so we need to set a ClickListener // We use a custom layout for this menu item, so we need to set a ClickListener
menu.findItem(R.id.menu_thread_list_filter)?.let { menuItem -> menu.findItem(R.id.menu_thread_list_filter)?.let { menuItem ->
menuItem.actionView.debouncedClicks { menuItem.actionView?.debouncedClicks {
handleMenuItemSelected(menuItem) handleMenuItemSelected(menuItem)
} }
} }
@ -96,7 +96,7 @@ class ThreadListFragment :
override fun handlePrepareMenu(menu: Menu) { override fun handlePrepareMenu(menu: Menu) {
withState(threadListViewModel) { state -> withState(threadListViewModel) { state ->
val filterIcon = menu.findItem(R.id.menu_thread_list_filter).actionView val filterIcon = menu.findItem(R.id.menu_thread_list_filter).actionView ?: return@withState
val filterBadge = filterIcon.findViewById<View>(R.id.threadListFilterBadge) val filterBadge = filterIcon.findViewById<View>(R.id.threadListFilterBadge)
filterBadge.isVisible = state.shouldFilterThreads filterBadge.isVisible = state.shouldFilterThreads
when (threadListViewModel.canHomeserverUseThreading()) { when (threadListViewModel.canHomeserverUseThreading()) {

View File

@ -34,6 +34,7 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.util.getPackageInfoCompat
import timber.log.Timber import timber.log.Timber
class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager: PopupAlertManager) : Application.ActivityLifecycleCallbacks { class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager: PopupAlertManager) : Application.ActivityLifecycleCallbacks {
@ -64,16 +65,16 @@ class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager
val packageManager: PackageManager = context.packageManager val packageManager: PackageManager = context.packageManager
// Get all activities from element android // Get all activities from element android
activitiesInfo = packageManager.getPackageInfo(context.packageName, PackageManager.GET_ACTIVITIES).activities activitiesInfo = packageManager.getPackageInfoCompat(context.packageName, PackageManager.GET_ACTIVITIES).activities
// Get all activities from PermissionController module // Get all activities from PermissionController module
// See https://source.android.com/docs/core/architecture/modular-system/permissioncontroller#package-format // See https://source.android.com/docs/core/architecture/modular-system/permissioncontroller#package-format
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2) {
activitiesInfo += tryOrNull { activitiesInfo += tryOrNull {
packageManager.getPackageInfo("com.google.android.permissioncontroller", PackageManager.GET_ACTIVITIES).activities packageManager.getPackageInfoCompat("com.google.android.permissioncontroller", PackageManager.GET_ACTIVITIES).activities
} ?: tryOrNull { } ?: tryOrNull {
packageManager.getModuleInfo("com.google.android.permission", 1).packageName?.let { packageManager.getModuleInfo("com.google.android.permission", 1).packageName?.let {
packageManager.getPackageInfo(it, PackageManager.GET_ACTIVITIES or PackageManager.MATCH_APEX).activities packageManager.getPackageInfoCompat(it, PackageManager.GET_ACTIVITIES or PackageManager.MATCH_APEX).activities
} }
}.orEmpty() }.orEmpty()
} }

View File

@ -24,6 +24,7 @@ import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityLocationSharingBinding import im.vector.app.databinding.ActivityLocationSharingBinding
import im.vector.app.features.location.preview.LocationPreviewFragment import im.vector.app.features.location.preview.LocationPreviewFragment
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@Parcelize @Parcelize
@ -40,7 +41,7 @@ class LocationSharingActivity : VectorBaseActivity<ActivityLocationSharingBindin
override fun getBinding() = ActivityLocationSharingBinding.inflate(layoutInflater) override fun getBinding() = ActivityLocationSharingBinding.inflate(layoutInflater)
override fun initUiAndData() { override fun initUiAndData() {
val locationSharingArgs: LocationSharingArgs? = intent?.extras?.getParcelable(EXTRA_LOCATION_SHARING_ARGS) val locationSharingArgs: LocationSharingArgs? = intent?.extras?.getParcelableCompat(EXTRA_LOCATION_SHARING_ARGS)
if (locationSharingArgs == null) { if (locationSharingArgs == null) {
finish() finish()
return return

View File

@ -25,6 +25,7 @@ import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityLocationSharingBinding import im.vector.app.databinding.ActivityLocationSharingBinding
import im.vector.app.features.MainActivity import im.vector.app.features.MainActivity
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@Parcelize @Parcelize
@ -38,7 +39,7 @@ class LiveLocationMapViewActivity : VectorBaseActivity<ActivityLocationSharingBi
override fun getBinding() = ActivityLocationSharingBinding.inflate(layoutInflater) override fun getBinding() = ActivityLocationSharingBinding.inflate(layoutInflater)
override fun initUiAndData() { override fun initUiAndData() {
val mapViewArgs: LiveLocationMapViewArgs? = intent?.extras?.getParcelable(EXTRA_LIVE_LOCATION_MAP_VIEW_ARGS) val mapViewArgs: LiveLocationMapViewArgs? = intent?.extras?.getParcelableCompat(EXTRA_LIVE_LOCATION_MAP_VIEW_ARGS)
if (mapViewArgs == null) { if (mapViewArgs == null) {
finish() finish()
return return

View File

@ -29,6 +29,7 @@ import im.vector.app.features.location.LocationTracker
import im.vector.app.features.location.live.GetLiveLocationShareSummaryUseCase import im.vector.app.features.location.live.GetLiveLocationShareSummaryUseCase
import im.vector.app.features.redaction.CheckIfEventIsRedactedUseCase import im.vector.app.features.redaction.CheckIfEventIsRedactedUseCase
import im.vector.app.features.session.coroutineScope import im.vector.app.features.session.coroutineScope
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableSharedFlow
@ -95,7 +96,7 @@ class LocationSharingAndroidService : VectorAndroidService(), LocationTracker.Ca
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
startInProgress = true startInProgress = true
val roomArgs = intent?.getParcelableExtra(EXTRA_ROOM_ARGS) as? RoomArgs val roomArgs = intent?.getParcelableExtraCompat(EXTRA_ROOM_ARGS) as? RoomArgs
Timber.i("onStartCommand. sessionId - roomId ${roomArgs?.sessionId} - ${roomArgs?.roomId}") Timber.i("onStartCommand. sessionId - roomId ${roomArgs?.sessionId} - ${roomArgs?.roomId}")
@ -191,7 +192,7 @@ class LocationSharingAndroidService : VectorAndroidService(), LocationTracker.Ca
} }
override fun onNoLocationProviderAvailable() { override fun onNoLocationProviderAvailable() {
stopForeground(true) stopForegroundCompat()
stopSelf() stopSelf()
} }

View File

@ -45,6 +45,7 @@ import im.vector.app.features.login.terms.LoginTermsFragment
import im.vector.app.features.login.terms.LoginTermsFragmentArgument import im.vector.app.features.login.terms.LoginTermsFragmentArgument
import im.vector.app.features.onboarding.AuthenticationDescription import im.vector.app.features.onboarding.AuthenticationDescription
import im.vector.app.features.pin.UnlockedActivity import im.vector.app.features.pin.UnlockedActivity
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import org.matrix.android.sdk.api.auth.registration.FlowResult import org.matrix.android.sdk.api.auth.registration.FlowResult
import org.matrix.android.sdk.api.auth.registration.Stage import org.matrix.android.sdk.api.auth.registration.Stage
import org.matrix.android.sdk.api.auth.toLocalizedLoginTerms import org.matrix.android.sdk.api.auth.toLocalizedLoginTerms
@ -96,7 +97,7 @@ open class LoginActivity : VectorBaseActivity<ActivityLoginBinding>(), UnlockedA
loginViewModel.observeViewEvents { handleLoginViewEvents(it) } loginViewModel.observeViewEvents { handleLoginViewEvents(it) }
// Get config extra // Get config extra
val loginConfig = intent.getParcelableExtra<LoginConfig?>(EXTRA_CONFIG) val loginConfig = intent.getParcelableExtraCompat<LoginConfig?>(EXTRA_CONFIG)
if (isFirstCreation()) { if (isFirstCreation()) {
loginViewModel.handle(LoginAction.InitWith(loginConfig)) loginViewModel.handle(LoginAction.InitWith(loginConfig))
} }

View File

@ -47,6 +47,8 @@ import im.vector.app.features.themes.ActivityOtherThemes
import im.vector.app.features.themes.ThemeUtils import im.vector.app.features.themes.ThemeUtils
import im.vector.lib.attachmentviewer.AttachmentCommands import im.vector.lib.attachmentviewer.AttachmentCommands
import im.vector.lib.attachmentviewer.AttachmentViewerActivity import im.vector.lib.attachmentviewer.AttachmentViewerActivity
import im.vector.lib.core.utils.compat.getParcelableArrayListExtraCompat
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -105,7 +107,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
transitionImageContainer.isVisible = true transitionImageContainer.isVisible = true
// Postpone transaction a bit until thumbnail is loaded // Postpone transaction a bit until thumbnail is loaded
val mediaData: Parcelable? = intent.getParcelableExtra(EXTRA_IMAGE_DATA) val mediaData: Parcelable? = intent.getParcelableExtraCompat(EXTRA_IMAGE_DATA)
if (mediaData is ImageContentRenderer.Data) { if (mediaData is ImageContentRenderer.Data) {
// will be shown at end of transition // will be shown at end of transition
pager2.isInvisible = true pager2.isInvisible = true
@ -130,7 +132,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
val room = args.roomId?.let { session.getRoom(it) } val room = args.roomId?.let { session.getRoom(it) }
val inMemoryData = intent.getParcelableArrayListExtra<AttachmentData>(EXTRA_IN_MEMORY_DATA) val inMemoryData = intent.getParcelableArrayListExtraCompat<AttachmentData>(EXTRA_IN_MEMORY_DATA)
val sourceProvider = if (inMemoryData != null) { val sourceProvider = if (inMemoryData != null) {
initialIndex = inMemoryData.indexOfFirst { it.eventId == args.eventId }.coerceAtLeast(0) initialIndex = inMemoryData.indexOfFirst { it.eventId == args.eventId }.coerceAtLeast(0)
dataSourceFactory.createProvider(inMemoryData, room, lifecycleScope) dataSourceFactory.createProvider(inMemoryData, room, lifecycleScope)
@ -227,7 +229,7 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), AttachmentInt
return false return false
} }
private fun args() = intent.getParcelableExtra<Args>(EXTRA_ARGS) private fun args() = intent.getParcelableExtraCompat<Args>(EXTRA_ARGS)
private fun scheduleStartPostponedTransition(sharedElement: View) { private fun scheduleStartPostponedTransition(sharedElement: View) {
sharedElement.viewTreeObserver.addOnPreDrawListener( sharedElement.viewTreeObserver.addOnPreDrawListener(

View File

@ -54,6 +54,7 @@ import im.vector.app.features.onboarding.OnboardingViewState
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthLegacyStyleTermsFragment import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthLegacyStyleTermsFragment
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsFragment import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsFragment
import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsLegacyStyleFragmentArgument import im.vector.app.features.onboarding.ftueauth.terms.FtueAuthTermsLegacyStyleFragmentArgument
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import org.matrix.android.sdk.api.auth.registration.Stage import org.matrix.android.sdk.api.auth.registration.Stage
import org.matrix.android.sdk.api.auth.toLocalizedLoginTerms import org.matrix.android.sdk.api.auth.toLocalizedLoginTerms
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
@ -107,7 +108,7 @@ class FtueAuthVariant(
} }
// Get config extra // Get config extra
val loginConfig = activity.intent.getParcelableExtra<LoginConfig?>(OnboardingActivity.EXTRA_CONFIG) val loginConfig = activity.intent.getParcelableExtraCompat<LoginConfig?>(OnboardingActivity.EXTRA_CONFIG)
if (isFirstCreation) { if (isFirstCreation) {
onboardingViewModel.handle(OnboardingAction.InitWith(loginConfig)) onboardingViewModel.handle(OnboardingAction.InitWith(loginConfig))
} }

View File

@ -23,6 +23,7 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.databinding.ActivitySimpleBinding
import im.vector.lib.core.utils.compat.getParcelableCompat
@AndroidEntryPoint @AndroidEntryPoint
class PinActivity : VectorBaseActivity<ActivitySimpleBinding>(), UnlockedActivity { class PinActivity : VectorBaseActivity<ActivitySimpleBinding>(), UnlockedActivity {
@ -41,7 +42,7 @@ class PinActivity : VectorBaseActivity<ActivitySimpleBinding>(), UnlockedActivit
override fun initUiAndData() { override fun initUiAndData() {
if (isFirstCreation()) { if (isFirstCreation()) {
val fragmentArgs: PinArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return val fragmentArgs: PinArgs = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
addFragment(views.simpleFragmentContainer, PinFragment::class.java, fragmentArgs) addFragment(views.simpleFragmentContainer, PinFragment::class.java, fragmentArgs)
} }
} }

View File

@ -23,6 +23,7 @@ import android.view.View
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.SimpleFragmentActivity
import im.vector.lib.core.utils.compat.getParcelableCompat
@AndroidEntryPoint @AndroidEntryPoint
class CreatePollActivity : SimpleFragmentActivity() { class CreatePollActivity : SimpleFragmentActivity() {
@ -31,7 +32,7 @@ class CreatePollActivity : SimpleFragmentActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
views.toolbar.visibility = View.GONE views.toolbar.visibility = View.GONE
val createPollArgs: CreatePollArgs? = intent?.extras?.getParcelable(EXTRA_CREATE_POLL_ARGS) val createPollArgs: CreatePollArgs? = intent?.extras?.getParcelableCompat(EXTRA_CREATE_POLL_ARGS)
if (isFirstCreation()) { if (isFirstCreation()) {
addFragment( addFragment(

View File

@ -128,7 +128,7 @@ class BugReportActivity :
val isValid = !views.bugReportMaskView.isVisible val isValid = !views.bugReportMaskView.isVisible
it.isEnabled = isValid it.isEnabled = isValid
it.icon.alpha = if (isValid) 255 else 100 it.icon?.alpha = if (isValid) 255 else 100
} }
} }

View File

@ -146,7 +146,7 @@ class EmojiReactionPickerActivity :
val searchItem = menu.findItem(R.id.search) val searchItem = menu.findItem(R.id.search)
(searchItem.actionView as? SearchView)?.let { searchView -> (searchItem.actionView as? SearchView)?.let { searchView ->
searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener { searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionExpand(p0: MenuItem?): Boolean { override fun onMenuItemActionExpand(p0: MenuItem): Boolean {
searchView.isIconified = false searchView.isIconified = false
searchView.requestFocusFromTouch() searchView.requestFocusFromTouch()
// we want to force the tool bar as visible even if hidden with scroll flags // we want to force the tool bar as visible even if hidden with scroll flags
@ -154,7 +154,7 @@ class EmojiReactionPickerActivity :
return true return true
} }
override fun onMenuItemActionCollapse(p0: MenuItem?): Boolean { override fun onMenuItemActionCollapse(p0: MenuItem): Boolean {
// when back, clear all search // when back, clear all search
views.emojiPickerToolbar.minimumHeight = 0 views.emojiPickerToolbar.minimumHeight = 0
searchView.setQuery("", true) searchView.setQuery("", true)

View File

@ -29,6 +29,7 @@ import im.vector.app.databinding.ActivitySimpleBinding
import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.analytics.plan.MobileScreen
import im.vector.app.features.roomdirectory.RoomDirectorySharedAction import im.vector.app.features.roomdirectory.RoomDirectorySharedAction
import im.vector.app.features.roomdirectory.RoomDirectorySharedActionViewModel import im.vector.app.features.roomdirectory.RoomDirectorySharedActionViewModel
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -46,7 +47,7 @@ class CreateRoomActivity : VectorBaseActivity<ActivitySimpleBinding>() {
override fun initUiAndData() { override fun initUiAndData() {
if (isFirstCreation()) { if (isFirstCreation()) {
val fragmentArgs: CreateRoomArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return val fragmentArgs: CreateRoomArgs = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
addFragment( addFragment(
views.simpleFragmentContainer, views.simpleFragmentContainer,
CreateRoomFragment::class.java, CreateRoomFragment::class.java,

View File

@ -24,6 +24,7 @@ import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.databinding.ActivitySimpleBinding
import im.vector.app.features.roomdirectory.RoomDirectoryData import im.vector.app.features.roomdirectory.RoomDirectoryData
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.session.permalinks.PermalinkData import org.matrix.android.sdk.api.session.permalinks.PermalinkData
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
@ -83,7 +84,7 @@ class RoomPreviewActivity : VectorBaseActivity<ActivitySimpleBinding>() {
override fun initUiAndData() { override fun initUiAndData() {
if (isFirstCreation()) { if (isFirstCreation()) {
val args = intent.getParcelableExtra<RoomPreviewData>(ARG) val args = intent.getParcelableExtraCompat<RoomPreviewData>(ARG)
if (args?.worldReadable == true) { if (args?.worldReadable == true) {
// TODO Room preview: Note: M does not recommend to use /events anymore, so for now we just display the room preview // TODO Room preview: Note: M does not recommend to use /events anymore, so for now we just display the room preview

View File

@ -28,6 +28,7 @@ import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.databinding.ActivitySimpleBinding
import im.vector.app.features.room.RequireActiveMembershipViewEvents import im.vector.app.features.room.RequireActiveMembershipViewEvents
import im.vector.app.features.room.RequireActiveMembershipViewModel import im.vector.app.features.room.RequireActiveMembershipViewModel
import im.vector.lib.core.utils.compat.getParcelableCompat
@AndroidEntryPoint @AndroidEntryPoint
class RoomMemberProfileActivity : VectorBaseActivity<ActivitySimpleBinding>() { class RoomMemberProfileActivity : VectorBaseActivity<ActivitySimpleBinding>() {
@ -48,7 +49,7 @@ class RoomMemberProfileActivity : VectorBaseActivity<ActivitySimpleBinding>() {
override fun initUiAndData() { override fun initUiAndData() {
if (isFirstCreation()) { if (isFirstCreation()) {
val fragmentArgs: RoomMemberProfileArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return val fragmentArgs: RoomMemberProfileArgs = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
addFragment(views.simpleFragmentContainer, RoomMemberProfileFragment::class.java, fragmentArgs) addFragment(views.simpleFragmentContainer, RoomMemberProfileFragment::class.java, fragmentArgs)
} }

View File

@ -38,6 +38,7 @@ import im.vector.app.features.roomprofile.notifications.RoomNotificationSettings
import im.vector.app.features.roomprofile.permissions.RoomPermissionsFragment import im.vector.app.features.roomprofile.permissions.RoomPermissionsFragment
import im.vector.app.features.roomprofile.settings.RoomSettingsFragment import im.vector.app.features.roomprofile.settings.RoomSettingsFragment
import im.vector.app.features.roomprofile.uploads.RoomUploadsFragment import im.vector.app.features.roomprofile.uploads.RoomUploadsFragment
import im.vector.lib.core.utils.compat.getParcelableCompat
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import javax.inject.Inject import javax.inject.Inject
@ -77,7 +78,7 @@ class RoomProfileActivity :
override fun initUiAndData() { override fun initUiAndData() {
sharedActionViewModel = viewModelProvider.get(RoomProfileSharedActionViewModel::class.java) sharedActionViewModel = viewModelProvider.get(RoomProfileSharedActionViewModel::class.java)
roomProfileArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return roomProfileArgs = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
if (isFirstCreation()) { if (isFirstCreation()) {
when (intent?.extras?.getInt(EXTRA_DIRECT_ACCESS, EXTRA_DIRECT_ACCESS_ROOM_ROOT)) { when (intent?.extras?.getInt(EXTRA_DIRECT_ACCESS, EXTRA_DIRECT_ACCESS_ROOM_ROOT)) {
EXTRA_DIRECT_ACCESS_ROOM_SETTINGS -> { EXTRA_DIRECT_ACCESS_ROOM_SETTINGS -> {

View File

@ -43,6 +43,7 @@ import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRul
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedFragment import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedFragment
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedState import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedState
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedViewModel import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedViewModel
import im.vector.lib.core.utils.compat.getParcelableCompat
import javax.inject.Inject import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint
@ -58,7 +59,7 @@ class RoomJoinRuleActivity : VectorBaseActivity<ActivitySimpleBinding>() {
val viewModel: RoomJoinRuleChooseRestrictedViewModel by viewModel() val viewModel: RoomJoinRuleChooseRestrictedViewModel by viewModel()
override fun initUiAndData() { override fun initUiAndData() {
roomProfileArgs = intent?.extras?.getParcelable(Mavericks.KEY_ARG) ?: return roomProfileArgs = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
if (isFirstCreation()) { if (isFirstCreation()) {
addFragment( addFragment(
views.simpleFragmentContainer, views.simpleFragmentContainer,

View File

@ -34,6 +34,7 @@ import im.vector.app.features.navigation.SettingsActivityPayload
import im.vector.app.features.settings.devices.VectorSettingsDevicesFragment import im.vector.app.features.settings.devices.VectorSettingsDevicesFragment
import im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceFragment import im.vector.app.features.settings.notifications.VectorSettingsNotificationPreferenceFragment
import im.vector.app.features.settings.threepids.ThreePidsSettingsFragment import im.vector.app.features.settings.threepids.ThreePidsSettingsFragment
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import org.matrix.android.sdk.api.failure.GlobalError import org.matrix.android.sdk.api.failure.GlobalError
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import timber.log.Timber import timber.log.Timber
@ -194,8 +195,8 @@ class VectorSettingsActivity : VectorBaseActivity<ActivityVectorSettingsBinding>
} }
} }
private fun <T : Parcelable> Activity.readPayload(default: T): T { private inline fun <reified T : Parcelable> Activity.readPayload(default: T): T {
return intent.getParcelableExtra(KEY_ACTIVITY_PAYLOAD) ?: default return intent.getParcelableExtraCompat<T>(KEY_ACTIVITY_PAYLOAD) ?: default
} }
private fun <T : Parcelable> Intent.applyPayload(payload: T): Intent { private fun <T : Parcelable> Intent.applyPayload(payload: T): Intent {

View File

@ -29,6 +29,7 @@ import im.vector.app.core.extensions.registerStartForActivityResult
import im.vector.app.core.preference.VectorPreference import im.vector.app.core.preference.VectorPreference
import im.vector.app.core.utils.RingtoneUtils import im.vector.app.core.utils.RingtoneUtils
import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.analytics.plan.MobileScreen
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import javax.inject.Inject import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint
@ -69,7 +70,7 @@ class VectorSettingsVoiceVideoFragment : VectorSettingsBaseFragment() {
private val ringtoneStartForActivityResult = registerStartForActivityResult { activityResult -> private val ringtoneStartForActivityResult = registerStartForActivityResult { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) { if (activityResult.resultCode == Activity.RESULT_OK) {
val callRingtoneUri: Uri? = activityResult.data?.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) val callRingtoneUri: Uri? = activityResult.data?.getParcelableExtraCompat(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)
if (callRingtoneUri != null) { if (callRingtoneUri != null) {
ringtoneUtils.setCallRingtoneUri(callRingtoneUri) ringtoneUtils.setCallRingtoneUri(callRingtoneUri)
mCallRingtonePreference.summary = ringtoneUtils.getCallRingtoneName() mCallRingtonePreference.summary = ringtoneUtils.getCallRingtoneName()

View File

@ -23,6 +23,7 @@ import com.airbnb.mvrx.Mavericks
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.SimpleFragmentActivity
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
/** /**
* Display the details info about a Session. * Display the details info about a Session.
@ -37,7 +38,7 @@ class SessionDetailsActivity : SimpleFragmentActivity() {
addFragment( addFragment(
container = views.container, container = views.container,
fragmentClass = SessionDetailsFragment::class.java, fragmentClass = SessionDetailsFragment::class.java,
params = intent.getParcelableExtra(Mavericks.KEY_ARG) params = intent.getParcelableExtraCompat(Mavericks.KEY_ARG)
) )
} }
} }

View File

@ -26,6 +26,7 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.SimpleFragmentActivity
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
@AndroidEntryPoint @AndroidEntryPoint
class OtherSessionsActivity : SimpleFragmentActivity() { class OtherSessionsActivity : SimpleFragmentActivity() {
@ -39,7 +40,7 @@ class OtherSessionsActivity : SimpleFragmentActivity() {
addFragment( addFragment(
container = views.container, container = views.container,
fragmentClass = OtherSessionsFragment::class.java, fragmentClass = OtherSessionsFragment::class.java,
params = intent.getParcelableExtra(Mavericks.KEY_ARG) params = intent.getParcelableExtraCompat(Mavericks.KEY_ARG)
) )
} }
} }

View File

@ -23,6 +23,7 @@ import com.airbnb.mvrx.Mavericks
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.SimpleFragmentActivity
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
/** /**
* Display the overview info about a Session. * Display the overview info about a Session.
@ -37,7 +38,7 @@ class SessionOverviewActivity : SimpleFragmentActivity() {
addFragment( addFragment(
container = views.container, container = views.container,
fragmentClass = SessionOverviewFragment::class.java, fragmentClass = SessionOverviewFragment::class.java,
params = intent.getParcelableExtra(Mavericks.KEY_ARG) params = intent.getParcelableExtraCompat(Mavericks.KEY_ARG)
) )
} }
} }

View File

@ -25,6 +25,7 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.databinding.ActivitySimpleBinding
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
/** /**
* Display the screen to rename a Session. * Display the screen to rename a Session.
@ -42,7 +43,7 @@ class RenameSessionActivity : VectorBaseActivity<ActivitySimpleBinding>() {
addFragment( addFragment(
container = views.simpleFragmentContainer, container = views.simpleFragmentContainer,
fragmentClass = RenameSessionFragment::class.java, fragmentClass = RenameSessionFragment::class.java,
params = intent.getParcelableExtra(Mavericks.KEY_ARG) params = intent.getParcelableExtraCompat(Mavericks.KEY_ARG)
) )
} }
} }

View File

@ -53,6 +53,7 @@ import im.vector.app.features.settings.BackgroundSyncModeChooserDialog
import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.VectorSettingsBaseFragment import im.vector.app.features.settings.VectorSettingsBaseFragment
import im.vector.app.features.settings.VectorSettingsFragmentInteractionListener import im.vector.app.features.settings.VectorSettingsFragmentInteractionListener
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
@ -342,7 +343,7 @@ class VectorSettingsNotificationPreferenceFragment :
private val ringtoneStartForActivityResult = registerStartForActivityResult { activityResult -> private val ringtoneStartForActivityResult = registerStartForActivityResult { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) { if (activityResult.resultCode == Activity.RESULT_OK) {
vectorPreferences.setNotificationRingTone(activityResult.data?.getParcelableExtra<Parcelable>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI) as Uri?) vectorPreferences.setNotificationRingTone(activityResult.data?.getParcelableExtraCompat<Uri>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI))
// test if the selected ring tone can be played // test if the selected ring tone can be played
val notificationRingToneName = vectorPreferences.getNotificationRingToneName() val notificationRingToneName = vectorPreferences.getNotificationRingToneName()

View File

@ -40,6 +40,7 @@ import im.vector.app.features.spaces.explore.SpaceDirectoryFragment
import im.vector.app.features.spaces.explore.SpaceDirectoryViewAction import im.vector.app.features.spaces.explore.SpaceDirectoryViewAction
import im.vector.app.features.spaces.explore.SpaceDirectoryViewEvents import im.vector.app.features.spaces.explore.SpaceDirectoryViewEvents
import im.vector.app.features.spaces.explore.SpaceDirectoryViewModel import im.vector.app.features.spaces.explore.SpaceDirectoryViewModel
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
@AndroidEntryPoint @AndroidEntryPoint
class SpaceExploreActivity : VectorBaseActivity<ActivitySimpleBinding>(), MatrixToBottomSheet.InteractionListener { class SpaceExploreActivity : VectorBaseActivity<ActivitySimpleBinding>(), MatrixToBottomSheet.InteractionListener {
@ -80,7 +81,7 @@ class SpaceExploreActivity : VectorBaseActivity<ActivitySimpleBinding>(), Matrix
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false) supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentLifecycleCallbacks, false)
if (isFirstCreation()) { if (isFirstCreation()) {
val args = intent?.getParcelableExtra<SpaceDirectoryArgs>(Mavericks.KEY_ARG) val args = intent?.getParcelableExtraCompat<SpaceDirectoryArgs>(Mavericks.KEY_ARG)
replaceFragment( replaceFragment(
views.simpleFragmentContainer, views.simpleFragmentContainer,
SpaceDirectoryFragment::class.java, SpaceDirectoryFragment::class.java,

View File

@ -27,6 +27,7 @@ import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding import im.vector.app.databinding.ActivitySimpleBinding
import im.vector.app.features.spaces.preview.SpacePreviewArgs import im.vector.app.features.spaces.preview.SpacePreviewArgs
import im.vector.app.features.spaces.preview.SpacePreviewFragment import im.vector.app.features.spaces.preview.SpacePreviewFragment
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -53,7 +54,7 @@ class SpacePreviewActivity : VectorBaseActivity<ActivitySimpleBinding>() {
.launchIn(lifecycleScope) .launchIn(lifecycleScope)
if (isFirstCreation()) { if (isFirstCreation()) {
val args = intent?.getParcelableExtra<SpacePreviewArgs>(Mavericks.KEY_ARG) val args = intent?.getParcelableExtraCompat<SpacePreviewArgs>(Mavericks.KEY_ARG)
replaceFragment( replaceFragment(
views.simpleFragmentContainer, views.simpleFragmentContainer,
SpacePreviewFragment::class.java, SpacePreviewFragment::class.java,

View File

@ -36,6 +36,7 @@ import im.vector.app.core.extensions.setTextOrHide
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleLoadingBinding import im.vector.app.databinding.ActivitySimpleLoadingBinding
import im.vector.app.features.spaces.SpaceBottomSheetSettingsArgs import im.vector.app.features.spaces.SpaceBottomSheetSettingsArgs
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import javax.inject.Inject import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint
@ -63,7 +64,7 @@ class SpaceLeaveAdvancedActivity : VectorBaseActivity<ActivitySimpleLoadingBindi
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val args = intent?.getParcelableExtra<SpaceBottomSheetSettingsArgs>(Mavericks.KEY_ARG) val args = intent?.getParcelableExtraCompat<SpaceBottomSheetSettingsArgs>(Mavericks.KEY_ARG)
if (isFirstCreation()) { if (isFirstCreation()) {
replaceFragment( replaceFragment(

View File

@ -150,12 +150,12 @@ class SpaceLeaveAdvancedFragment :
onTextChanged: (String) -> Unit onTextChanged: (String) -> Unit
) { ) {
setOnActionExpandListener(object : MenuItem.OnActionExpandListener { setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionExpand(item: MenuItem?): Boolean { override fun onMenuItemActionExpand(item: MenuItem): Boolean {
onExpanded() onExpanded()
return true return true
} }
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean { override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
onCollapsed() onCollapsed()
return true return true
} }

View File

@ -40,6 +40,7 @@ import im.vector.app.features.roomdirectory.createroom.CreateRoomFragment
import im.vector.app.features.roomprofile.RoomProfileArgs import im.vector.app.features.roomprofile.RoomProfileArgs
import im.vector.app.features.roomprofile.alias.RoomAliasFragment import im.vector.app.features.roomprofile.alias.RoomAliasFragment
import im.vector.app.features.roomprofile.permissions.RoomPermissionsFragment import im.vector.app.features.roomprofile.permissions.RoomPermissionsFragment
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@ -90,7 +91,7 @@ class SpaceManageActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>() {
} }
.launchIn(lifecycleScope) .launchIn(lifecycleScope)
val args = intent?.getParcelableExtra<SpaceManageArgs>(Mavericks.KEY_ARG) val args = intent?.getParcelableExtraCompat<SpaceManageArgs>(Mavericks.KEY_ARG)
if (isFirstCreation()) { if (isFirstCreation()) {
withState(sharedViewModel) { withState(sharedViewModel) {
when (it.manageType) { when (it.manageType) {

View File

@ -32,6 +32,7 @@ import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleLoadingBinding import im.vector.app.databinding.ActivitySimpleLoadingBinding
import im.vector.app.features.analytics.plan.ViewRoom import im.vector.app.features.analytics.plan.ViewRoom
import im.vector.app.features.spaces.share.ShareSpaceBottomSheet import im.vector.app.features.spaces.share.ShareSpaceBottomSheet
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -63,7 +64,7 @@ class SpacePeopleActivity : VectorBaseActivity<ActivitySimpleLoadingBinding>() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val args = intent?.getParcelableExtra<GenericIdArgs>(Mavericks.KEY_ARG) val args = intent?.getParcelableExtraCompat<GenericIdArgs>(Mavericks.KEY_ARG)
if (isFirstCreation()) { if (isFirstCreation()) {
replaceFragment( replaceFragment(
views.simpleFragmentContainer, views.simpleFragmentContainer,

View File

@ -25,6 +25,7 @@ import im.vector.app.R
import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.error.ErrorFormatter
import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.extensions.replaceFragment
import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.SimpleFragmentActivity
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import org.matrix.android.sdk.api.session.terms.TermsService import org.matrix.android.sdk.api.session.terms.TermsService
import javax.inject.Inject import javax.inject.Inject
@ -42,7 +43,7 @@ class ReviewTermsActivity : SimpleFragmentActivity() {
replaceFragment(views.container, ReviewTermsFragment::class.java) replaceFragment(views.container, ReviewTermsFragment::class.java)
} }
reviewTermsViewModel.termsArgs = intent.getParcelableExtra(EXTRA_INFO) ?: error("Missing parameter") reviewTermsViewModel.termsArgs = intent.getParcelableExtraCompat(EXTRA_INFO) ?: error("Missing parameter")
reviewTermsViewModel.observeViewEvents { reviewTermsViewModel.observeViewEvents {
when (it) { when (it) {

View File

@ -24,6 +24,7 @@ import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityVectorWebViewBinding import im.vector.app.databinding.ActivityVectorWebViewBinding
import im.vector.lib.core.utils.compat.getSerializableCompat
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import javax.inject.Inject import javax.inject.Inject
@ -79,7 +80,7 @@ class VectorWebViewActivity : VectorBaseActivity<ActivityVectorWebViewBinding>()
setTitle(title) setTitle(title)
} }
val webViewMode = intent.extras?.getSerializable(EXTRA_MODE) as WebViewMode val webViewMode = intent.extras?.getSerializableCompat<WebViewMode>(EXTRA_MODE)!!
val eventListener = webViewMode.eventListener(this, session) val eventListener = webViewMode.eventListener(this, session)
views.simpleWebview.webViewClient = VectorWebViewClient(eventListener) views.simpleWebview.webViewClient = VectorWebViewClient(eventListener)
views.simpleWebview.webChromeClient = object : WebChromeClient() { views.simpleWebview.webChromeClient = object : WebChromeClient() {

View File

@ -43,6 +43,8 @@ import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionBottomSheet import im.vector.app.features.widgets.permissions.RoomWidgetPermissionBottomSheet
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewEvents import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewEvents
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewModel import im.vector.app.features.widgets.permissions.RoomWidgetPermissionViewModel
import im.vector.lib.core.utils.compat.getParcelableCompat
import im.vector.lib.core.utils.compat.getSerializableCompat
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.events.model.Content import org.matrix.android.sdk.api.session.events.model.Content
import java.io.Serializable import java.io.Serializable
@ -68,7 +70,7 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun getOutput(intent: Intent): Content? { fun getOutput(intent: Intent): Content? {
return intent.extras?.getSerializable(EXTRA_RESULT) as? Content return intent.extras?.getSerializableCompat(EXTRA_RESULT) as? Content
} }
private fun createResultIntent(content: Content): Intent { private fun createResultIntent(content: Content): Intent {
@ -88,7 +90,7 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
override fun getTitleRes() = R.string.room_widget_activity_title override fun getTitleRes() = R.string.room_widget_activity_title
override fun initUiAndData() { override fun initUiAndData() {
val widgetArgs: WidgetArgs? = intent?.extras?.getParcelable(Mavericks.KEY_ARG) val widgetArgs: WidgetArgs? = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG)
if (widgetArgs == null) { if (widgetArgs == null) {
finish() finish()
return return
@ -150,7 +152,7 @@ class WidgetActivity : VectorBaseActivity<ActivityWidgetBinding>() {
override fun onUserLeaveHint() { override fun onUserLeaveHint() {
super.onUserLeaveHint() super.onUserLeaveHint()
val widgetArgs: WidgetArgs? = intent?.extras?.getParcelable(Mavericks.KEY_ARG) val widgetArgs: WidgetArgs? = intent?.extras?.getParcelableCompat(Mavericks.KEY_ARG)
if (widgetArgs?.kind?.supportsPictureInPictureMode().orFalse()) { if (widgetArgs?.kind?.supportsPictureInPictureMode().orFalse()) {
enterPictureInPicture() enterPictureInPicture()
} }

View File

@ -52,6 +52,7 @@ import im.vector.app.features.webview.WebEventListener
import im.vector.app.features.widgets.webview.WebviewPermissionUtils import im.vector.app.features.widgets.webview.WebviewPermissionUtils
import im.vector.app.features.widgets.webview.clearAfterWidget import im.vector.app.features.widgets.webview.clearAfterWidget
import im.vector.app.features.widgets.webview.setupForWidget import im.vector.app.features.widgets.webview.setupForWidget
import im.vector.lib.core.utils.compat.resolveActivityCompat
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.session.terms.TermsService import org.matrix.android.sdk.api.session.terms.TermsService
import timber.log.Timber import timber.log.Timber
@ -264,7 +265,7 @@ class WidgetFragment :
val intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME) val intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME)
if (intent != null) { if (intent != null) {
val packageManager: PackageManager = context.packageManager val packageManager: PackageManager = context.packageManager
val info = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) val info = packageManager.resolveActivityCompat(intent, PackageManager.MATCH_DEFAULT_ONLY)
if (info != null) { if (info != null) {
context.startActivity(intent) context.startActivity(intent)
} else { } else {