Skip to content

Commit 92a2420

Browse files
authored
Merge pull request #7293 from vector-im/feature/bma/android13
Android 13
2 parents 237c18c + c17b55b commit 92a2420

File tree

112 files changed

+618
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+618
-237
lines changed

dependencies.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ext.versions = [
22

33
'minSdk' : 21,
4-
'compileSdk' : 32,
5-
'targetSdk' : 32,
4+
'compileSdk' : 33,
5+
'targetSdk' : 33,
66
'sourceCompat' : JavaVersion.VERSION_11,
77
'targetCompat' : JavaVersion.VERSION_11,
88
]
@@ -50,10 +50,10 @@ ext.libs = [
5050
'coroutinesTest' : "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutines"
5151
],
5252
androidx : [
53-
'activity' : "androidx.activity:activity:1.5.1",
53+
'activity' : "androidx.activity:activity-ktx:1.6.0",
5454
'appCompat' : "androidx.appcompat:appcompat:1.5.1",
5555
'biometric' : "androidx.biometric:biometric:1.1.0",
56-
'core' : "androidx.core:core-ktx:1.8.0",
56+
'core' : "androidx.core:core-ktx:1.9.0",
5757
'recyclerview' : "androidx.recyclerview:recyclerview:1.2.1",
5858
'exifinterface' : "androidx.exifinterface:exifinterface:1.3.4",
5959
'fragmentKtx' : "androidx.fragment:fragment-ktx:$fragment",

library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,6 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
316316
}
317317
return false
318318
}
319-
320-
override fun onDoubleTap(e: MotionEvent?): Boolean {
321-
return super.onDoubleTap(e)
322-
}
323319
})
324320

325321
override fun onEvent(event: AttachmentEvents) {

library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeToDismissHandler.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,27 @@ class SwipeToDismissHandler(
9696
.setDuration(ANIMATION_DURATION)
9797
.setInterpolator(AccelerateInterpolator())
9898
.setUpdateListener { onSwipeViewMove(swipeView.translationY, translationLimit) }
99-
.setAnimatorListener(onAnimationEnd = {
99+
.setAnimatorEndListener {
100100
if (translationTo != 0f) {
101101
onDismiss()
102102
}
103103

104104
// remove the update listener, otherwise it will be saved on the next animation execution:
105105
swipeView.animate().setUpdateListener(null)
106-
})
106+
}
107107
.start()
108108
}
109109
}
110110

111-
internal fun ViewPropertyAnimator.setAnimatorListener(
112-
onAnimationEnd: ((Animator?) -> Unit)? = null,
113-
onAnimationStart: ((Animator?) -> Unit)? = null
114-
) = this.setListener(
111+
private fun ViewPropertyAnimator.setAnimatorEndListener(
112+
onAnimationEnd: () -> Unit,
113+
) = setListener(
115114
object : AnimatorListenerAdapter() {
116-
override fun onAnimationEnd(animation: Animator?) {
117-
onAnimationEnd?.invoke(animation)
118-
}
119-
120-
override fun onAnimationStart(animation: Animator?) {
121-
onAnimationStart?.invoke(animation)
115+
override fun onAnimationEnd(animation: Animator) {
116+
onAnimationEnd()
122117
}
123-
})
118+
}
119+
)
124120

125-
internal val View?.hitRect: Rect
126-
get() = Rect().also { this?.getHitRect(it) }
121+
private val View.hitRect: Rect
122+
get() = Rect().also { getHitRect(it) }
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2022 New Vector Ltd
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.lib.core.utils.compat
18+
19+
import android.content.Intent
20+
import android.content.pm.PackageManager
21+
import android.content.pm.ResolveInfo
22+
import android.os.Build
23+
import android.os.Bundle
24+
import android.os.Parcelable
25+
import java.io.Serializable
26+
27+
inline fun <reified T> Intent.getParcelableExtraCompat(key: String): T? = when {
28+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelableExtra(key, T::class.java)
29+
else -> @Suppress("DEPRECATION") getParcelableExtra(key) as? T?
30+
}
31+
32+
inline fun <reified T : Parcelable> Intent.getParcelableArrayListExtraCompat(key: String): ArrayList<T>? = when {
33+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelableArrayListExtra(key, T::class.java)
34+
else -> @Suppress("DEPRECATION") getParcelableArrayListExtra<T>(key)
35+
}
36+
37+
inline fun <reified T> Bundle.getParcelableCompat(key: String): T? = when {
38+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getParcelable(key, T::class.java)
39+
else -> @Suppress("DEPRECATION") getParcelable(key) as? T?
40+
}
41+
42+
inline fun <reified T : Serializable> Bundle.getSerializableCompat(key: String): T? = when {
43+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializable(key, T::class.java)
44+
else -> @Suppress("DEPRECATION") getSerializable(key) as? T?
45+
}
46+
47+
inline fun <reified T : Serializable> Intent.getSerializableExtraCompat(key: String): T? = when {
48+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> getSerializableExtra(key, T::class.java)
49+
else -> @Suppress("DEPRECATION") getSerializableExtra(key) as? T?
50+
}
51+
52+
fun PackageManager.queryIntentActivitiesCompat(data: Intent, flags: Int): List<ResolveInfo> {
53+
return when {
54+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> queryIntentActivities(
55+
data,
56+
PackageManager.ResolveInfoFlags.of(flags.toLong())
57+
)
58+
else -> @Suppress("DEPRECATION") queryIntentActivities(data, flags)
59+
}
60+
}
61+
62+
fun PackageManager.resolveActivityCompat(data: Intent, flags: Int): ResolveInfo? {
63+
return when {
64+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> resolveActivity(
65+
data,
66+
PackageManager.ResolveInfoFlags.of(flags.toLong())
67+
)
68+
else -> @Suppress("DEPRECATION") resolveActivity(data, flags)
69+
}
70+
}

library/external/dialpad/src/main/java/com/android/dialer/dialpadview/DialpadView.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public DialpadView(Context context, AttributeSet attrs, int defStyle) {
103103

104104
@Override
105105
protected void onFinishInflate() {
106+
super.onFinishInflate();
106107
setupKeypad();
107108
mDigits = (EditText) findViewById(R.id.digits);
108109
mDelete = (ImageButton) findViewById(R.id.deleteButton);
@@ -201,14 +202,6 @@ private void setupKeypad() {
201202
zero.setLongHoverContentDescription(resources.getText(R.string.description_image_button_plus));
202203
}
203204

204-
private Drawable getDrawableCompat(Context context, int id) {
205-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
206-
return context.getDrawable(id);
207-
} else {
208-
return context.getResources().getDrawable(id);
209-
}
210-
}
211-
212205
public void setShowVoicemailButton(boolean show) {
213206
View view = findViewById(R.id.dialpad_key_voicemail);
214207
if (view != null) {

library/external/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerDialog.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import android.view.ViewGroup
2323
import android.view.WindowManager
2424
import androidx.fragment.app.DialogFragment
2525
import com.airbnb.mvrx.Mavericks
26+
import im.vector.lib.core.utils.compat.getParcelableCompat
2627

2728
class JSonViewerDialog : DialogFragment() {
2829

@@ -36,16 +37,17 @@ class JSonViewerDialog : DialogFragment() {
3637

3738
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
3839
super.onViewCreated(view, savedInstanceState)
39-
val args: JSonViewerFragmentArgs = arguments?.getParcelable(Mavericks.KEY_ARG) ?: return
40+
val args: JSonViewerFragmentArgs = arguments?.getParcelableCompat(Mavericks.KEY_ARG) ?: return
4041
if (savedInstanceState == null) {
4142
childFragmentManager.beginTransaction()
4243
.replace(
43-
R.id.fragmentContainer, JSonViewerFragment.newInstance(
44-
args.jsonString,
45-
args.defaultOpenDepth,
46-
true,
47-
args.styleProvider
48-
)
44+
R.id.fragmentContainer,
45+
JSonViewerFragment.newInstance(
46+
args.jsonString,
47+
args.defaultOpenDepth,
48+
true,
49+
args.styleProvider
50+
)
4951
)
5052
.commitNow()
5153
}

library/external/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.airbnb.mvrx.Mavericks
2828
import com.airbnb.mvrx.MavericksView
2929
import com.airbnb.mvrx.fragmentViewModel
3030
import com.airbnb.mvrx.withState
31+
import im.vector.lib.core.utils.compat.getParcelableCompat
3132
import kotlinx.parcelize.Parcelize
3233

3334
@Parcelize
@@ -53,7 +54,7 @@ class JSonViewerFragment : Fragment(), MavericksView {
5354
container: ViewGroup?,
5455
savedInstanceState: Bundle?
5556
): View? {
56-
val args: JSonViewerFragmentArgs? = arguments?.getParcelable(Mavericks.KEY_ARG)
57+
val args: JSonViewerFragmentArgs? = arguments?.getParcelableCompat(Mavericks.KEY_ARG)
5758
val inflate =
5859
if (args?.wrap == true) {
5960
inflater.inflate(R.layout.fragment_jv_recycler_view_wrap, container, false)

library/multipicker/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,19 @@ android {
3535
}
3636
}
3737

38+
compileOptions {
39+
sourceCompatibility versions.sourceCompat
40+
targetCompatibility versions.targetCompat
41+
}
42+
43+
kotlinOptions {
44+
jvmTarget = "11"
45+
}
3846
}
3947

4048
dependencies {
49+
implementation project(":library:core-utils")
50+
4151
api libs.androidx.activity
4252
implementation libs.androidx.exifinterface
4353
implementation libs.androidx.core

library/multipicker/src/main/java/im/vector/lib/multipicker/Picker.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import android.content.pm.PackageManager
2222
import android.content.pm.ResolveInfo
2323
import android.net.Uri
2424
import androidx.activity.result.ActivityResultLauncher
25+
import im.vector.lib.core.utils.compat.getParcelableArrayListExtraCompat
26+
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
27+
import im.vector.lib.core.utils.compat.queryIntentActivitiesCompat
2528

2629
/**
2730
* Abstract class to provide all types of Pickers.
@@ -45,13 +48,13 @@ abstract class Picker<T> {
4548

4649
val uriList = mutableListOf<Uri>()
4750
if (data.action == Intent.ACTION_SEND) {
48-
(data.getParcelableExtra(Intent.EXTRA_STREAM) as? Uri)?.let { uriList.add(it) }
51+
data.getParcelableExtraCompat<Uri>(Intent.EXTRA_STREAM)?.let { uriList.add(it) }
4952
} else if (data.action == Intent.ACTION_SEND_MULTIPLE) {
50-
val extraUriList: List<Uri>? = data.getParcelableArrayListExtra(Intent.EXTRA_STREAM)
53+
val extraUriList: List<Uri>? = data.getParcelableArrayListExtraCompat(Intent.EXTRA_STREAM)
5154
extraUriList?.let { uriList.addAll(it) }
5255
}
5356

54-
val resInfoList: List<ResolveInfo> = context.packageManager.queryIntentActivities(data, PackageManager.MATCH_DEFAULT_ONLY)
57+
val resInfoList: List<ResolveInfo> = context.packageManager.queryIntentActivitiesCompat(data, PackageManager.MATCH_DEFAULT_ONLY)
5558
uriList.forEach {
5659
for (resolveInfo in resInfoList) {
5760
val packageName: String = resolveInfo.activityInfo.packageName
@@ -91,6 +94,7 @@ abstract class Picker<T> {
9194
} else if (dataUri != null) {
9295
selectedUriList.add(dataUri)
9396
} else {
97+
@Suppress("DEPRECATION")
9498
data?.extras?.get(Intent.EXTRA_STREAM)?.let {
9599
(it as? List<*>)?.filterIsInstance<Uri>()?.let { uriList ->
96100
selectedUriList.addAll(uriList)

library/ui-strings/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@
638638
<string name="permissions_rationale_msg_record_audio">${app_name} needs permission to access your microphone to perform audio calls.</string>
639639
<!-- Note to translators: the translation MUST contain the string "${app_name}", which will be replaced by the application name -->
640640
<string name="permissions_rationale_msg_camera_and_audio">${app_name} needs permission to access your camera and your microphone to perform video calls.\n\nPlease allow access on the next pop-ups to be able to make the call.</string>
641+
<!-- Note to translators: the translation MUST contain the string "${app_name}", which will be replaced by the application name -->
642+
<string name="permissions_rationale_msg_notification">${app_name} needs permission to display notifications. Notifications can display your messages, your invitations, etc.\n\nPlease allow access on the next pop-ups to be able to view notification.</string>
641643

642644
<string name="permissions_denied_qr_code">To scan a QR code, you need to allow camera access.</string>
643645
<string name="permissions_denied_add_contact">Allow permission to access your contacts.</string>
@@ -857,7 +859,9 @@
857859
<string name="settings_troubleshoot_test_system_settings_title">System Settings.</string>
858860
<string name="settings_troubleshoot_test_system_settings_success">Notifications are enabled in the system settings.</string>
859861
<string name="settings_troubleshoot_test_system_settings_failed">Notifications are disabled in the system settings.\nPlease check system settings.</string>
862+
<string name="settings_troubleshoot_test_system_settings_permission_failed">${app_name} needs the permission to show notifications.\nPlease grant the permission.</string>
860863
<string name="open_settings">Open Settings</string>
864+
<string name="grant_permission">Grant Permission</string>
861865

862866
<string name="settings_troubleshoot_test_account_settings_title">Account Settings.</string>
863867
<string name="settings_troubleshoot_test_account_settings_success">Notifications are enabled for your account.</string>

0 commit comments

Comments
 (0)