From 719296d1a67eb0512b842e3f89bc43a6ee1aec91 Mon Sep 17 00:00:00 2001 From: Juraj Hilje Date: Thu, 7 Sep 2023 15:03:21 +0200 Subject: [PATCH] fix: declare POST_NOTIFICATIONS permission in AndroidManifest.xml --- core/build.gradle | 2 +- core/src/main/AndroidManifest.xml | 14 ++++--- .../bindings/ImageViewSrcBindingAdapter.kt | 4 +- .../ivpn/core/v2/connect/ConnectFragment.kt | 9 +++++ .../main/java/net/ivpn/core/v2/map/MapView.kt | 36 +++++++++-------- .../ivpn/core/v2/map/animation/MapAnimator.kt | 40 +++++++++---------- fdroid/build.gradle | 2 +- liboqs-android/build.gradle | 2 +- site/build.gradle | 2 +- store/build.gradle | 2 +- 10 files changed, 65 insertions(+), 48 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index e77f20ee0..9445c1e58 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -25,7 +25,7 @@ android { } } - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { minSdkVersion 21 targetSdkVersion 33 diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml index bc3399afb..82047bb81 100644 --- a/core/src/main/AndroidManifest.xml +++ b/core/src/main/AndroidManifest.xml @@ -5,24 +5,28 @@ - + - + - + - + + - + + + + override fun onCreateView( inflater: LayoutInflater, @@ -135,6 +139,11 @@ class ConnectFragment : Fragment(), MultiHopViewModel.MultiHopNavigator, LOGGER.info("On view created") IVPNApplication.appComponent.provideActivityComponent().create().inject(this) initViews() + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + requestPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()) {} + requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) + } } override fun onViewStateRestored(savedInstanceState: Bundle?) { diff --git a/core/src/main/java/net/ivpn/core/v2/map/MapView.kt b/core/src/main/java/net/ivpn/core/v2/map/MapView.kt index 017374d7c..59493e8e0 100644 --- a/core/src/main/java/net/ivpn/core/v2/map/MapView.kt +++ b/core/src/main/java/net/ivpn/core/v2/map/MapView.kt @@ -22,6 +22,7 @@ package net.ivpn.core.v2.map along with the IVPN Android app. If not, see . */ +import android.annotation.SuppressLint import android.content.Context import android.graphics.Bitmap import android.graphics.Canvas @@ -95,10 +96,10 @@ class MapView @JvmOverloads constructor( } override fun onScroll( - e1: MotionEvent?, - e2: MotionEvent?, - distanceX: Float, - distanceY: Float + e1: MotionEvent, + e2: MotionEvent, + distanceX: Float, + distanceY: Float ): Boolean { math.appendX(distanceX) math.appendY(distanceY) @@ -120,30 +121,27 @@ class MapView @JvmOverloads constructor( return super.onSingleTapUp(event) } - override fun onDoubleTap(e: MotionEvent?): Boolean { - return super.onDoubleTap(e) - } } private val gestureDetector = GestureDetector(this.context, gestureListener) private val scaleGestureListener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() { - override fun onScale(detector: ScaleGestureDetector?): Boolean { + override fun onScale(detector: ScaleGestureDetector): Boolean { serverLocationsData.isReady = false locationData.isReady = false - detector?.let { + detector.let { math.applyScaleFactor(it.scaleFactor, it.focusX, it.focusY) } return true } - override fun onScaleEnd(detector: ScaleGestureDetector?) { + override fun onScaleEnd(detector: ScaleGestureDetector) { updateCoordinates() super.onScaleEnd(detector) } - override fun onScaleBegin(detector: ScaleGestureDetector?): Boolean { + override fun onScaleBegin(detector: ScaleGestureDetector): Boolean { serverLocationsData.isReady = false locationData.isReady = false return super.onScaleBegin(detector) @@ -172,9 +170,14 @@ class MapView @JvmOverloads constructor( } } + @SuppressLint("ClickableViewAccessibility") override fun onTouchEvent(event: MotionEvent?): Boolean { - scaleGestureDetector.onTouchEvent(event) - gestureDetector.onTouchEvent(event) + if (event != null) { + scaleGestureDetector.onTouchEvent(event) + } + if (event != null) { + gestureDetector.onTouchEvent(event) + } return true } @@ -478,7 +481,7 @@ class MapView @JvmOverloads constructor( updateCoordinates(true) } - var coordinateJob: Job? = null + private var coordinateJob: Job? = null private fun updateCoordinates(isFirstInit: Boolean = false) { coordinateJob?.cancel() @@ -524,7 +527,7 @@ class MapView @JvmOverloads constructor( } } - var bitmapCache: LruCache? = null + private var bitmapCache: LruCache? = null private var thumbnails: HashMap? = null private fun initTiles() { val path = resources.getString(R.string.path_to_tiles) @@ -574,7 +577,7 @@ class MapView @JvmOverloads constructor( return prepareBitmapJob } - val defaultTransparentDrawable = ResourcesCompat.getDrawable( + private val defaultTransparentDrawable = ResourcesCompat.getDrawable( context.resources, R.drawable.fill_transparent, null @@ -601,6 +604,7 @@ class MapView @JvmOverloads constructor( } } + @SuppressLint("DiscouragedApi") private fun getIdentifier(context: Context, name: String): Int { return context.resources.getIdentifier(name, "drawable", IVPNApplication.application.packageName) } diff --git a/core/src/main/java/net/ivpn/core/v2/map/animation/MapAnimator.kt b/core/src/main/java/net/ivpn/core/v2/map/animation/MapAnimator.kt index 946d71cdc..4f2df4e1f 100644 --- a/core/src/main/java/net/ivpn/core/v2/map/animation/MapAnimator.kt +++ b/core/src/main/java/net/ivpn/core/v2/map/animation/MapAnimator.kt @@ -54,18 +54,18 @@ class MapAnimator(val listener: AnimatorListener) { val movementAnimator = ValueAnimator.ofFloat(0f, 1f) movementAnimator.duration = MapView.CENTER_ANIMATION_DURATION movementAnimator.addListener(object : Animator.AnimatorListener { - override fun onAnimationRepeat(animation: Animator?) { + override fun onAnimationRepeat(animation: Animator) { } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { animationState = AnimationState.NONE listener.onCenterAnimationFinish(locations, dialogState) } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { } }) @@ -87,18 +87,18 @@ class MapAnimator(val listener: AnimatorListener) { val movementAnimator = ValueAnimator.ofFloat(0f, 1f) movementAnimator.duration = MapView.CENTER_ANIMATION_DURATION movementAnimator.addListener(object : Animator.AnimatorListener { - override fun onAnimationRepeat(animation: Animator?) { + override fun onAnimationRepeat(animation: Animator) { } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { animationState = AnimationState.NONE listener.onCenterAnimationFinish(null, dialogState) } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { } }) @@ -115,18 +115,18 @@ class MapAnimator(val listener: AnimatorListener) { val hideAnimator = ValueAnimator.ofFloat(0f, 1f) hideAnimator.duration = MapView.HIDE_ANIMATION_DURATION hideAnimator.addListener(object : Animator.AnimatorListener { - override fun onAnimationRepeat(animation: Animator?) { + override fun onAnimationRepeat(animation: Animator) { } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { startMovementAnimation(startX, startY) // listener.onEndMovementAnimation() } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { stopWaveAnimation() } @@ -146,18 +146,18 @@ class MapAnimator(val listener: AnimatorListener) { val movementAnimator = ValueAnimator.ofFloat(0f, 1f) movementAnimator.duration = MapView.MOVEMENT_ANIMATION_DURATION movementAnimator.addListener(object : Animator.AnimatorListener { - override fun onAnimationRepeat(animation: Animator?) { + override fun onAnimationRepeat(animation: Animator) { } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { startAppearAnimation() listener.onEndMovementAnimation() } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { stopWaveAnimation() listener.onStartMovementAnimation() } @@ -175,18 +175,18 @@ class MapAnimator(val listener: AnimatorListener) { val appearAnimator = ValueAnimator.ofFloat(0f, 1f) appearAnimator.duration = MapView.APPEAR_ANIMATION_DURATION appearAnimator.addListener(object : Animator.AnimatorListener { - override fun onAnimationRepeat(animation: Animator?) { + override fun onAnimationRepeat(animation: Animator) { } - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { animationState = AnimationState.NONE listener.onEndAppearAnimation() } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { } - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { } }) diff --git a/fdroid/build.gradle b/fdroid/build.gradle index 2803ddd2b..8ab7425a5 100644 --- a/fdroid/build.gradle +++ b/fdroid/build.gradle @@ -24,7 +24,7 @@ android { } } - compileSdkVersion 32 + compileSdkVersion 33 buildToolsVersion "30.0.3" defaultConfig { diff --git a/liboqs-android/build.gradle b/liboqs-android/build.gradle index b7ca5c632..e8e3b1743 100644 --- a/liboqs-android/build.gradle +++ b/liboqs-android/build.gradle @@ -3,7 +3,7 @@ plugins { } android { - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { minSdkVersion 21 targetSdkVersion 33 diff --git a/site/build.gradle b/site/build.gradle index 8ae44a3bd..de66aa182 100644 --- a/site/build.gradle +++ b/site/build.gradle @@ -24,7 +24,7 @@ android { } } - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId "net.ivpn.client" diff --git a/store/build.gradle b/store/build.gradle index 60eb9dedd..85d8389b5 100644 --- a/store/build.gradle +++ b/store/build.gradle @@ -25,7 +25,7 @@ android { } } - compileSdkVersion 32 + compileSdkVersion 33 defaultConfig { applicationId "net.ivpn.client"