Skip to content

Commit

Permalink
Merge pull request #193 from Bandyer/api_34_compatibility
Browse files Browse the repository at this point in the history
chore: update compatibility for target api 34
  • Loading branch information
stefanobrusa authored Jul 4, 2024
2 parents 2a9dc8f + 93fb7ed commit 9360769
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 83 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
}

Expand Down
1 change: 0 additions & 1 deletion collaboration-suite-core-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'kotlin-kapt'
id 'maven-publish'
alias(catalog.plugins.dokka)
alias(catalog.plugins.licenseReport)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.toBitmap
import com.kaleyra.collaboration_suite_core_ui.R
import com.kaleyra.collaboration_suite_core_ui.utils.PendingIntentExtensions
import com.kaleyra.collaboration_suite_core_ui.utils.extensions.ContextExtensions.canUseFullScreenIntent
import com.kaleyra.collaboration_suite_utils.HostAppInfo

/**
Expand Down Expand Up @@ -272,7 +273,9 @@ class CallNotification {
color?.let { builder.setColor(it) }
smallIconResInt?.let { builder.setSmallIcon(it) }
contentIntent?.also { builder.setContentIntent(it) }
fullscreenIntent?.also { builder.setFullScreenIntent(it, true) }
fullscreenIntent?.takeIf { context.canUseFullScreenIntent() }.also {
builder.setFullScreenIntent(it, true)
}

var screenShareAction: NotificationCompat.Action? = null
screenShareIntent?.also {
Expand Down Expand Up @@ -319,28 +322,12 @@ class CallNotification {
declineIntent: PendingIntent? = null,
screenShareIntent: PendingIntent? = null
): Notification {
val applicationIcon =
context.applicationContext.packageManager.getApplicationIcon(HostAppInfo.name)
val applicationIcon = context.applicationContext.packageManager.getApplicationIcon(HostAppInfo.name)
val person = Person.Builder()
.setName(user?.takeIf { it.isNotEmpty() } ?: " ")
.setIcon(Icon.createWithBitmap(applicationIcon.toBitmap()))
.build()

val defaultIntent =
PendingIntent.getActivity(context, 0, Intent(), PendingIntentExtensions.updateFlags)

val style = when (type) {
Type.INCOMING -> Notification.CallStyle.forIncomingCall(
person,
declineIntent ?: defaultIntent,
answerIntent ?: defaultIntent
)
else -> Notification.CallStyle.forOngoingCall(
person,
declineIntent ?: defaultIntent
)
}

val builder = Notification.Builder(context.applicationContext, channelId)
.setAutoCancel(false)
.setOngoing(true)
Expand All @@ -353,6 +340,18 @@ class CallNotification {
.addPerson(person)

if (enableCallStyle) {
val defaultIntent = PendingIntent.getActivity(context, 0, Intent(), PendingIntentExtensions.updateFlags)
val style = when (type) {
Type.INCOMING -> Notification.CallStyle.forIncomingCall(
person,
declineIntent ?: defaultIntent,
answerIntent ?: defaultIntent
)
else -> Notification.CallStyle.forOngoingCall(
person,
declineIntent ?: defaultIntent
)
}
builder.style = style
} else {
when(type) {
Expand Down Expand Up @@ -383,7 +382,9 @@ class CallNotification {
color?.let { builder.setColor(it) }
smallIconResInt?.let { builder.setSmallIcon(it) }
contentIntent?.also { builder.setContentIntent(it) }
fullscreenIntent?.also { builder.setFullScreenIntent(it, true) }
fullscreenIntent?.takeIf { context.canUseFullScreenIntent() }?.let {
builder.setFullScreenIntent(it, true)
}
screenShareIntent?.also {
val screenShareAction = Notification.Action.Builder(
Icon.createWithResource(context, R.drawable.ic_kaleyra_screen_share),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.core.app.RemoteInput
import androidx.core.graphics.drawable.toBitmap
import com.google.android.material.color.MaterialColors
import com.kaleyra.collaboration_suite_core_ui.R
import com.kaleyra.collaboration_suite_core_ui.utils.extensions.ContextExtensions.canUseFullScreenIntent
import com.kaleyra.collaboration_suite_utils.HostAppInfo

/**
Expand Down Expand Up @@ -245,7 +246,7 @@ internal class ChatNotification {
builder.addAction(markAsReadAction)
}
// deleteIntent?.also { builder.setDeleteIntent(it) }
fullscreenIntent?.also { builder.setFullScreenIntent(it, true) }
fullscreenIntent?.takeIf { context.canUseFullScreenIntent() }?.let { builder.setFullScreenIntent(it, true) }

MaterialColors
.getColor(context, R.attr.colorSecondary, -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.graphics.drawable.toBitmap
import com.kaleyra.collaboration_suite_core_ui.R
import com.kaleyra.collaboration_suite_core_ui.utils.extensions.ContextExtensions.canUseFullScreenIntent
import com.kaleyra.collaboration_suite_utils.HostAppInfo

internal class TermsAndConditionsNotification {
Expand Down Expand Up @@ -77,7 +78,7 @@ internal class TermsAndConditionsNotification {
}

contentIntent?.also { builder.setContentIntent(it) }
fullscreenIntent?.also { builder.setFullScreenIntent(it, true) }
fullscreenIntent?.takeIf { context.canUseFullScreenIntent() }?.let { builder.setFullScreenIntent(it, true) }
deleteIntent?.also { builder.setDeleteIntent(it) }

return builder.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.kaleyra.collaboration_suite_core_ui.utils.extensions

import android.app.Activity
import android.app.NotificationManager
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
Expand Down Expand Up @@ -60,9 +61,9 @@ object ContextExtensions {
fun <T : Activity> Context.getActivity(): T? {
return when (this) {
is FragmentActivity -> this as T?
is Activity -> this as T?
is ContextWrapper -> this.baseContext.getActivity() as T?
else -> null
is Activity -> this as T?
is ContextWrapper -> this.baseContext.getActivity() as T?
else -> null
}
}

Expand Down Expand Up @@ -193,5 +194,9 @@ object ContextExtensions {
val mainIntent = Intent.makeRestartActivityTask(componentName)
startActivity(mainIntent)
}

fun Context.canUseFullScreenIntent() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
(getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).canUseFullScreenIntent()
} else true
}

1 change: 0 additions & 1 deletion collaboration-suite-glass-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.github.jk1.license.render.JsonReportRenderer
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'maven-publish'
id 'androidx.navigation.safeargs.kotlin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.kaleyra.collaboration_suite_glass_ui

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.runner.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith
Expand Down
1 change: 0 additions & 1 deletion collaboration-suite-phone-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.github.jk1.license.render.JsonReportRenderer
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'maven-publish'
alias(catalog.plugins.dokka)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,21 +551,21 @@ open class BaseKaleyraBottomSheet(
valueAnimator?.addListener(
object : Animator.AnimatorListener {
var isCanceled = false
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationRepeat(animation: Animator) {}
override fun onAnimationEnd(animation: Animator) {
if (endValue != 0f) fadeRecyclerViewLinesBelowNavigation()
isAnimating = false
if (isCanceled) return
bottomSheetLayoutContent.updateBackgroundView()
if (endValue != lp.bottomMargin.toFloat()) moveBottomSheet()
}

override fun onAnimationCancel(animation: Animator?) {
override fun onAnimationCancel(animation: Animator) {
isCanceled = true
isAnimating = false
}

override fun onAnimationStart(animation: Animator?) = Unit
override fun onAnimationStart(animation: Animator) = Unit
})

valueAnimator!!.duration = 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,27 +495,27 @@ class KaleyraBottomSheetBehaviour<V : View>(context: Context, attrs: AttributeSe
}

private val clickGestureDetector = GestureDetector(context, object : GestureDetector.OnGestureListener {
override fun onShowPress(e: MotionEvent?) {
override fun onShowPress(e: MotionEvent) {

}

override fun onSingleTapUp(e: MotionEvent): Boolean {
return e.pointerCount == 1 && (mViewRef?.get()?.parent as? ViewGroup)?.performClick() == true
}

override fun onDown(e: MotionEvent?): Boolean {
override fun onDown(e: MotionEvent): Boolean {
return false
}

override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float): Boolean {
override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
return false
}

override fun onScroll(e1: MotionEvent?, e2: MotionEvent?, distanceX: Float, distanceY: Float): Boolean {
override fun onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
return false
}

override fun onLongPress(e: MotionEvent?) {
override fun onLongPress(e: MotionEvent) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ class KaleyraCallInfoWidget @JvmOverloads constructor(context: Context, attrs: A
private fun animateHide(onHidden: (() -> Unit)? = null) {
isShowing = false
animate().translationY(-height.toFloat()).setListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationRepeat(animation: Animator) {}
override fun onAnimationEnd(animation: Animator) {
visibility = View.INVISIBLE
onHidden?.invoke()
}

override fun onAnimationCancel(animation: Animator?) {}
override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationCancel(animation: Animator) {}
override fun onAnimationStart(animation: Animator) {}
}).setDuration(AUTO_HIDE_ANIMATION_DURATION_MS).start()
}

Expand All @@ -232,13 +232,13 @@ class KaleyraCallInfoWidget @JvmOverloads constructor(context: Context, attrs: A
fun show(onShown: (() -> Unit)? = null) {
isShowing = true
animate().translationY(0f).setListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationRepeat(animation: Animator) {}
override fun onAnimationEnd(animation: Animator) {
onShown?.invoke()
}

override fun onAnimationCancel(animation: Animator?) {}
override fun onAnimationStart(animation: Animator?) {
override fun onAnimationCancel(animation: Animator) {}
override fun onAnimationStart(animation: Animator) {
visibility = View.VISIBLE
}
}).setDuration(AUTO_SHOW_ANIMATION_DURATION_MS).start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,18 @@ fun View.resizeAndMove(toSize: Int, toTop: Int, toLeft: Int, toRight: Int, durat
set.duration = duration
set.addListener(object : Animator.AnimatorListener {
private var isCanceled = false
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationRepeat(animation: Animator) {}
override fun onAnimationEnd(animation: Animator) {
if (isCanceled) return
invalidate()
requestLayout()
onResizedAndMoved.invoke()
}

override fun onAnimationCancel(animation: Animator?) {
override fun onAnimationCancel(animation: Animator) {
isCanceled = true
}
override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationStart(animation: Animator) {}
})
set.start()
return set
Expand Down Expand Up @@ -179,18 +179,17 @@ fun View.makeFloating(container: androidx.coordinatorlayout.widget.CoordinatorLa

val gestureDetector = GestureDetector(this.context, object : GestureDetector.SimpleOnGestureListener() {

override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
onFloatingViewClickListener?.onClick(this@makeFloating)
return super.onSingleTapConfirmed(e)
}

override fun onDoubleTap(e: MotionEvent?): Boolean {
override fun onDoubleTap(e: MotionEvent): Boolean {
onFloatingViewDoubleClickListener?.onDoubleClick()
return super.onDoubleTap(e)
}

override fun onFling(downEvent: MotionEvent, moveEvent: MotionEvent, velocityX: Float, velocityY: Float): Boolean {

override fun onFling(downEvent: MotionEvent?, moveEvent: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
if (!isFloating) return true

if (isFlinging) return true
Expand Down Expand Up @@ -461,10 +460,10 @@ fun View.animateToCorner(corner: CORNER, container: androidx.coordinatorlayout.w
AnimatorSet().apply {
this.duration = if (instant) 0 else 350
this.addListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {}
override fun onAnimationRepeat(animation: Animator) {}

@SuppressLint("RtlHardcoded")
override fun onAnimationEnd(animation: Animator?) {
override fun onAnimationEnd(animation: Animator) {
if (!isFloating) return

isFlinging = false
Expand Down Expand Up @@ -511,11 +510,11 @@ fun View.animateToCorner(corner: CORNER, container: androidx.coordinatorlayout.w
onSnapped?.onSnap(currentCorner!!)
}

override fun onAnimationCancel(animation: Animator?) {
override fun onAnimationCancel(animation: Animator) {
container.requestDisallowInterceptTouchEvent(false)
}

override fun onAnimationStart(animation: Animator?) {}
override fun onAnimationStart(animation: Animator) {}
})
this.playTogether(animatorX, animatorY)
this.start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ open class RoundableConstraintLayout @JvmOverloads constructor(context: Context,
/**
* @suppress
*/
override fun onDraw(canvas: Canvas?) {
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
setRoundClip(canvas)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ open class RoundableFrameLayout @JvmOverloads constructor(context: Context, attr
/**
* @suppress
*/
override fun onDraw(canvas: Canvas?) {
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
setRoundClip(canvas)
}
Expand Down
Loading

0 comments on commit 9360769

Please sign in to comment.