Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Target Android 11 (DEV) #3310

Merged
merged 24 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a74762b
Target Android 11
mtwalli May 22, 2021
d04c2a2
Update QrCodeFullScreenFragment.kt
mtwalli May 23, 2021
522f5b3
Consistency on different versions
mtwalli May 23, 2021
10fc466
Move to IntentBuilder constructor
mtwalli May 24, 2021
13a8e8c
Merge branch 'release/2.4.x' into dev/android-11
mtwalli May 27, 2021
bf594dc
Run screenshots
mtwalli May 27, 2021
70a51c4
Fix notification test
mtwalli May 27, 2021
bd1be6c
Merge branch 'release/2.4.x' into dev/android-11
mtwalli May 27, 2021
170201b
Merge branch 'release/2.4.x' into dev/android-11
mtwalli May 27, 2021
d81b2c7
Merge branch 'release/2.4.x' into dev/android-11
harambasicluka May 28, 2021
c26b1bb
Merge branch 'release/2.4.x' into dev/android-11
mtwalli May 28, 2021
1fa67cc
Merge branch 'release/2.4.x' into dev/android-11
mtwalli May 28, 2021
4ba8ec0
Merge branch 'release/2.4.x' into dev/android-11
harambasicluka May 28, 2021
e27950d
Update ScreenShotter.kt
mtwalli May 29, 2021
4ee5040
Delete ScreenshotUnderTest.kt
mtwalli May 29, 2021
93fdf93
Update ScreenShotter.kt
mtwalli May 29, 2021
32aff27
Docs
mtwalli May 29, 2021
8c57ea3
Revert
mtwalli May 29, 2021
32897eb
Merge branch 'release/2.4.x' into dev/android-11
mtwalli May 29, 2021
f1387d0
Merge branch 'release/2.4.x' into dev/android-11
BMItr May 31, 2021
ce5625a
Merge branch 'release/2.4.x' into dev/android-11
mtwalli Jun 1, 2021
abafd1f
Merge branch 'release/2.4.x' into dev/android-11
mtwalli Jun 1, 2021
fd2399b
Merge branch 'release/2.4.x' into dev/android-11
mtwalli Jun 1, 2021
9ec75cb
Merge branch 'release/2.4.x' into dev/android-11
mtwalli Jun 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ workflows:
requires:
- ktlint_check
- detekt
- firebase_screenshots:
requires:
- ktlint_check
- detekt
mtwalli marked this conversation as resolved.
Show resolved Hide resolved

check_buildtype_device_for_testers:
jobs:
Expand Down
6 changes: 3 additions & 3 deletions Corona-Warn-App/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ android {
println("Current VERSION_PATCH: ${VERSION_PATCH}")
println("Current VERSION_BUILD: ${VERSION_BUILD}")

compileSdkVersion 29
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId 'de.rki.coronawarnapp'
minSdkVersion 23
targetSdkVersion 29
targetSdkVersion 30
mtwalli marked this conversation as resolved.
Show resolved Hide resolved

ndkVersion "21.2.6472646"

Expand Down Expand Up @@ -314,7 +314,7 @@ dependencies {
// ANDROID STANDARD
def nav_version = "2.3.3"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.core:core-ktx:1.5.0'
mtwalli marked this conversation as resolved.
Show resolved Hide resolved
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ class SettingsCrashReportDetailsFragment :

private fun shareCrashReport() {
activity?.let { activity ->
val shareIntent = ShareCompat.IntentBuilder
.from(activity)
val shareIntent = ShareCompat.IntentBuilder(activity)
.setType("text/plain")
.setText(fragmentSettingsCrashReportDetailsBinding.textViewCrashReportDetails.text)
.createChooserIntent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ class DataDonationTestFragment : Fragment(R.layout.fragment_test_datadonation),
}

vm.copyJWSEvent.observe2(this) { jws ->
val intent = ShareCompat.IntentBuilder.from(requireActivity()).apply {
setType("text/plain")
setSubject("JWS")
setText(jws)
}.createChooserIntent()
val intent = ShareCompat.IntentBuilder(requireActivity())
.setType("text/plain")
.setSubject("JWS")
.setText(jws)
.createChooserIntent()
startActivity(intent)
}

vm.copyAnalyticsEvent.observe2(this) { analytics ->
val intent = ShareCompat.IntentBuilder.from(requireActivity()).apply {
mtwalli marked this conversation as resolved.
Show resolved Hide resolved
setType("text/plain")
setSubject("Analytics")
setText(analytics)
}.createChooserIntent()
val intent = ShareCompat.IntentBuilder(requireActivity())
.setType("text/plain")
.setSubject("Analytics")
.setText(analytics)
.createChooserIntent()
startActivity(intent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ class TestRiskLevelCalculationFragment :
Timber.d("Opening Share-Intent for Exposure Windows")
val shareFileUri =
FileProvider.getUriForFile(requireContext(), requireContext().packageName + ".fileProvider", file)
val shareIntent = ShareCompat.IntentBuilder
.from(requireActivity())
val shareIntent = ShareCompat.IntentBuilder(requireActivity())
.setStream(shareFileUri)
.setType("text/plain")
.intent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class DebugLogFragment : Fragment(R.layout.bugreporting_debuglog_fragment), Auto
MaterialAlertDialogBuilder(requireContext()).apply {
setTitle(R.string.errors_generic_headline_short)
setMessage(R.string.debugging_debuglog_start_low_storage_error)
setPositiveButton(android.R.string.yes) { _, _ -> /* dismiss */ }
setPositiveButton(android.R.string.ok) { _, _ -> /* dismiss */ }
mtwalli marked this conversation as resolved.
Show resolved Hide resolved
setNeutralButton(R.string.menu_settings) { _, _ ->
try {
startActivity(Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ class ContactDiaryOverviewFragment : Fragment(R.layout.contact_diary_overview_fr
private fun exportLocationsAndPersons(exportString: String) {
Timber.d("exportLocationsAndPersons(exportString=$exportString)")
activity?.let { activity ->
val shareIntent = ShareCompat.IntentBuilder
.from(activity)
val shareIntent = ShareCompat.IntentBuilder(activity)
.setType("text/plain")
.setSubject(getString(R.string.contact_diary_export_subject))
.setText(exportString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package de.rki.coronawarnapp.presencetracing.common

import android.annotation.TargetApi
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.navigation.NavDeepLinkBuilder
Expand Down Expand Up @@ -37,13 +36,13 @@ class PresenceTracingNotifications @Inject constructor(
fun setupChannel() {
Timber.d("setupChannel()")

val channel = NotificationChannel(
val channel = NotificationChannelCompat.Builder(
channelId,
context.getString(R.string.tracelocation_notification_channel_title),
NotificationManager.IMPORTANCE_DEFAULT
).apply {
description = context.getString(R.string.tracelocation_notification_channel_description)
}
NotificationManagerCompat.IMPORTANCE_DEFAULT
)
.setName(context.getString(R.string.tracelocation_notification_channel_title))
.setDescription(context.getString(R.string.tracelocation_notification_channel_description))
.build()

notificationManagerCompat.createNotificationChannel(channel)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package de.rki.coronawarnapp.ui.qrcode.fullscreen

import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.View.SYSTEM_UI_FLAG_FULLSCREEN
import android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
import android.view.View.SYSTEM_UI_FLAG_IMMERSIVE
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
import android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
import android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
import android.view.View.SYSTEM_UI_FLAG_VISIBLE
mtwalli marked this conversation as resolved.
Show resolved Hide resolved
import android.view.animation.AccelerateInterpolator
import androidx.core.view.WindowInsetsCompat.Type
import androidx.core.view.WindowInsetsControllerCompat
import androidx.core.view.WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.navArgs
import com.google.android.material.transition.MaterialContainerTransform
Expand All @@ -29,10 +22,9 @@ import javax.inject.Inject
class QrCodeFullScreenFragment : Fragment(R.layout.fragment_qr_code_full_screen), AutoInject {

@Inject lateinit var viewModelFactory: CWAViewModelFactoryProvider.Factory

private val binding: FragmentQrCodeFullScreenBinding by viewBinding()
private val binding by viewBinding<FragmentQrCodeFullScreenBinding>()
private val args by navArgs<QrCodeFullScreenFragmentArgs>()
private val viewModel: QrCodeFullScreenViewModel by cwaViewModelsAssisted(
private val viewModel by cwaViewModelsAssisted<QrCodeFullScreenViewModel>(
factoryProducer = { viewModelFactory },
constructorCall = { factory, _ ->
factory as QrCodeFullScreenViewModel.Factory
Expand All @@ -43,6 +35,8 @@ class QrCodeFullScreenFragment : Fragment(R.layout.fragment_qr_code_full_screen)
}
)

private val insetsController by lazy { insetsController() }

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val containerTransform = MaterialContainerTransform()
Expand Down Expand Up @@ -72,53 +66,24 @@ class QrCodeFullScreenFragment : Fragment(R.layout.fragment_qr_code_full_screen)
override fun onStop() {
super.onStop()

clearSystemUiFlags()
}

private fun clearSystemUiFlags() {
decorView.systemUiVisibility = withLightUiFlags(SYSTEM_UI_FLAG_VISIBLE)
binding.toolbar.animate().translationY(0.0f)
exitImmersiveMode()
}

private fun exitImmersiveMode() {
binding.toolbar.animate().translationY(0.0f)
showSystemUI()
binding.toolbar.animate().alpha(1.0f)
insetsController.show(Type.systemBars())
}

private fun enterImmersiveMode() {
hideSystemUI()
binding.toolbar.apply {
animate().translationY(-height.toFloat())
}
}

private fun hideSystemUI() {
decorView.systemUiVisibility = withLightUiFlags(
SYSTEM_UI_FLAG_IMMERSIVE
or SYSTEM_UI_FLAG_LAYOUT_STABLE
or SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or SYSTEM_UI_FLAG_HIDE_NAVIGATION
or SYSTEM_UI_FLAG_FULLSCREEN
)
insetsController.hide(Type.systemBars())
binding.toolbar.animate().alpha(0.0f)
}

private fun showSystemUI() {
decorView.systemUiVisibility = withLightUiFlags(
SYSTEM_UI_FLAG_LAYOUT_STABLE
or SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
)
}

private val decorView: View get() = requireActivity().window.decorView

private fun withLightUiFlags(flags: Int): Int {
var uiFlags = flags
if (resources.getBoolean(R.bool.lightSystemUI)) {
uiFlags = uiFlags or SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) uiFlags = uiFlags or SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
}
return uiFlags
private fun insetsController(): WindowInsetsControllerCompat {
val window = requireActivity().window
return WindowInsetsControllerCompat(window, window.decorView)
.apply {
systemBarsBehavior = BEHAVIOR_SHOW_BARS_BY_SWIPE
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ class FileSharing @Inject constructor(
createChooserIntent: Boolean = false
): FileIntentProvider = object : FileIntentProvider {
override fun intent(activity: Activity): Intent {
val builder = ShareCompat.IntentBuilder.from(activity).apply {
setType(path.determineMimeType())
setStream(getFileUri(path))
setSubject(title)
}
val builder = ShareCompat.IntentBuilder(activity)
.setType(path.determineMimeType())
.setStream(getFileUri(path))
.setSubject(title)

val intent = if (createChooserIntent) {
builder.createChooserIntent()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.rki.coronawarnapp.presencetracing.common

import android.content.Context
import androidx.core.app.NotificationChannelCompat
import androidx.core.app.NotificationManagerCompat
import de.rki.coronawarnapp.util.BuildVersionWrap
import io.mockk.MockKAnnotations
Expand Down Expand Up @@ -33,7 +34,7 @@ class TraceLocationNotificationsTest : BaseTest() {
every { BuildVersionWrap.SDK_INT } returns 42

notificationManager.apply {
every { createNotificationChannel(any()) } just Runs
every { createNotificationChannel(any<NotificationChannelCompat>()) } just Runs
every { notify(any(), any()) } just Runs
}
}
Expand All @@ -49,7 +50,7 @@ class TraceLocationNotificationsTest : BaseTest() {
instance.sendNotification(1, mockk())

verify {
notificationManager.createNotificationChannel(any())
notificationManager.createNotificationChannel(any<NotificationChannelCompat>())
notificationManager.notify(1, any())
}
}
Expand All @@ -60,7 +61,7 @@ class TraceLocationNotificationsTest : BaseTest() {
val instance = createInstance()
instance.sendNotification(1, mockk())

verify(exactly = 0) { notificationManager.createNotificationChannel(any()) }
verify(exactly = 0) { notificationManager.createNotificationChannel(any<NotificationChannelCompat>()) }
verify { notificationManager.notify(1, any()) }
}
}