From afb55cce5d6d283194cff209be0219d04148f3db Mon Sep 17 00:00:00 2001 From: COVIDSafe Support <64945427+covidsafe-support@users.noreply.github.com> Date: Wed, 5 Aug 2020 11:27:40 +1000 Subject: [PATCH] COVIDSafe code from version 1.0.48 (#22) --- README.md | 6 + app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 7 +- .../au/gov/health/covidsafe/HomeActivity.kt | 22 +- .../au/gov/health/covidsafe/Preference.kt | 11 + .../java/au/gov/health/covidsafe/Utils.kt | 15 + .../extensions/PermissionExtensions.kt | 42 +- ...ageAndPerformScanWithExponentialBackOff.kt | 14 +- .../gov/health/covidsafe/links/LinkBuilder.kt | 3 + .../covidsafe/networking/service/AwsClient.kt | 9 +- .../scheduler/GetMessagesScheduler.kt | 73 +- .../services/CovidFirebaseMessagingService.kt | 6 +- .../gov/health/covidsafe/streetpass/Work.kt | 23 +- .../health/covidsafe/ui/PagerChildFragment.kt | 13 +- .../gov/health/covidsafe/ui/PagerContainer.kt | 2 +- .../health/covidsafe/ui/home/HelpFragment.kt | 22 +- .../health/covidsafe/ui/home/HomeFragment.kt | 56 +- .../ui/onboarding/OnboardingActivity.kt | 29 +- .../dataprivacy/DataPrivacyFragment.kt | 2 +- .../enternumber/EnterNumberFragment.kt | 6 +- .../fragment/enterpin/EnterPinFragment.kt | 4 +- .../fragment/howitworks/HowItWorksFragment.kt | 2 +- .../introduction/IntroductionFragment.kt | 2 +- .../PermissionDeviceNameFragment.kt | 40 +- .../fragment/permission/PermissionFragment.kt | 13 +- .../PermissionSuccessFragment.kt | 4 +- .../personal/PersonalDetailsFragment.kt | 2 +- .../RegistrationConsentFragment.kt | 2 +- .../undersixteen/UnderSixteenFragment.kt | 2 +- .../ui/upload/UploadContainerFragment.kt | 10 +- .../presentation/UploadFinishedFragment.kt | 2 +- .../presentation/UploadInitialFragment.kt | 2 +- .../presentation/UploadStepFourFragment.kt | 2 +- .../presentation/VerifyUploadPinFragment.kt | 2 +- app/src/main/res/drawable/ic_globe.xml | 27 + .../main/res/layout/activity_onboarding.xml | 29 +- .../main/res/layout/fragment_enter_number.xml | 3 +- .../main/res/layout/fragment_enter_pin.xml | 2 +- app/src/main/res/layout/fragment_home.xml | 80 +- .../layout/fragment_home_external_links.xml | 25 + .../fragment_permission_device_name.xml | 3 +- .../res/layout/fragment_personal_details.xml | 2 +- .../layout/fragment_registration_consent.xml | 1 - .../res/layout/fragment_upload_master.xml | 10 - app/src/main/res/values-ar/strings.xml | 659 +++++++++------- app/src/main/res/values-el-rGR/strings.xml | 706 +++++++++++------- app/src/main/res/values-it-rIT/strings.xml | 561 ++++++++------ app/src/main/res/values-ko/strings.xml | 685 ++++++++++------- app/src/main/res/values-vi/strings.xml | 547 +++++++++----- app/src/main/res/values-zh-rCN/strings.xml | 543 +++++++++----- app/src/main/res/values-zh-rTW/strings.xml | 685 ++++++++++------- app/src/main/res/values/strings.xml | 671 ++++++++++------- 52 files changed, 3528 insertions(+), 2165 deletions(-) create mode 100644 app/src/main/res/drawable/ic_globe.xml diff --git a/README.md b/README.md index 2cf13c3..a1827d8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # COVIDSafe app +Thank you for viewing the GitHub repository for the COVIDSafe app by the Australian Government. +If you need help with troubleshooting issues with the app, please use our support channels: +Email: support@covidsafe.gov.au +Phone: 1800 020 080 +COVIDSafe online help [https://covidsafe.gov.au/help-topics.html](https://covidsafe.gov.au/help-topics.html) + # Please report any security vulnerabilities using the details from [https://covidsafe.gov.au/.well-known/security.txt](https://covidsafe.gov.au/.well-known/security.txt) # [Terms and Conditions for access to COVIDSafe App code](https://github.com/AU-COVIDSafe/mobile-android/blob/master/LICENSE.md) diff --git a/app/build.gradle b/app/build.gradle index f996e50..fe90bb9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,8 +41,8 @@ android { Before you increase the targetSdkVersion make sure that all its usage are still working */ targetSdkVersion 28 - versionCode 39 - versionName "1.0.39" + versionCode 48 + versionName "1.0.48" buildConfigField "String", "GITHASH", "\"${getGitHash()}\"" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0a04319..d20850c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -52,7 +52,12 @@ + android:windowSoftInputMode="adjustPan" > + + + + + diff --git a/app/src/main/java/au/gov/health/covidsafe/HomeActivity.kt b/app/src/main/java/au/gov/health/covidsafe/HomeActivity.kt index 49d8212..2baaf6b 100644 --- a/app/src/main/java/au/gov/health/covidsafe/HomeActivity.kt +++ b/app/src/main/java/au/gov/health/covidsafe/HomeActivity.kt @@ -4,13 +4,13 @@ import android.os.Bundle import androidx.fragment.app.FragmentActivity import au.gov.health.covidsafe.logging.CentralLog import au.gov.health.covidsafe.scheduler.GetMessagesScheduler +import au.gov.health.covidsafe.ui.home.HomeFragment import com.google.android.gms.tasks.OnCompleteListener import com.google.firebase.iid.FirebaseInstanceId private const val TAG = "HomeActivity" class HomeActivity : FragmentActivity() { - /** * Provides notification support to inform users to update to the latest version of the app. * This feature will also allow for troubleshooting of the app in the future and allow for @@ -38,6 +38,9 @@ class HomeActivity : FragmentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + CentralLog.d(TAG, "onCreate() intent.action = ${intent.action}") + setContentView(R.layout.activity_home) Utils.startBluetoothMonitoringService(this) @@ -47,4 +50,21 @@ class HomeActivity : FragmentActivity() { // GetMessagesScheduler.getMessages() GetMessagesScheduler.scheduleGetMessagesJob() } + + override fun onResume() { + super.onResume() + + CentralLog.d(TAG, "onResume() intent.action = ${intent.action}") + + if (intent.action == "au.gov.health.covidsafe.UPGRADE_APP"){ + Utils.gotoPlayStore(this) + } + } + + override fun onWindowFocusChanged(hasFocus: Boolean) { + CentralLog.d(TAG, "onWindowFocusChanged(hasFocus = $hasFocus)") + HomeFragment.instanceWeakRef?.get()?.refreshSetupCompleteOrIncompleteUi() + + super.onWindowFocusChanged(hasFocus) + } } \ No newline at end of file diff --git a/app/src/main/java/au/gov/health/covidsafe/Preference.kt b/app/src/main/java/au/gov/health/covidsafe/Preference.kt index 272949c..bd9d17b 100644 --- a/app/src/main/java/au/gov/health/covidsafe/Preference.kt +++ b/app/src/main/java/au/gov/health/covidsafe/Preference.kt @@ -9,6 +9,7 @@ import au.gov.health.covidsafe.security.crypto.AESEncryptionForPreAndroidM object Preference { private const val PREF_ID = "Tracer_pref" private const val IS_ONBOARDED = "IS_ONBOARDED" + private const val HAS_DEVICE_NAME_NOTIFICATION_DISPLAYED = "HAS_DEVICE_NAME_NOTIFICATION_DISPLAYED" private const val CALLING_CODE = "CALLING_CODE" private const val AUSTRALIA_CALLING_CODE = 61 private const val COUNTRY_NAME_RES_ID = "COUNTRY_NAME" @@ -122,6 +123,16 @@ object Preference { .getBoolean(IS_ONBOARDED, false) } + fun putHasDeviceNameNotificationDisplayed(context: Context, value: Boolean) { + context.getSharedPreferences(PREF_ID, Context.MODE_PRIVATE) + .edit().putBoolean(HAS_DEVICE_NAME_NOTIFICATION_DISPLAYED, value).apply() + } + + fun getHasDeviceNameNotificationDisplayed(context: Context): Boolean { + return context.getSharedPreferences(PREF_ID, Context.MODE_PRIVATE) + .getBoolean(HAS_DEVICE_NAME_NOTIFICATION_DISPLAYED, false) + } + fun putPhoneNumber(context: Context, value: String) { context.getSharedPreferences(PREF_ID, Context.MODE_PRIVATE) .edit().putString(PHONE_NUMBER, value).apply() diff --git a/app/src/main/java/au/gov/health/covidsafe/Utils.kt b/app/src/main/java/au/gov/health/covidsafe/Utils.kt index fbe0bf4..a9fb58c 100644 --- a/app/src/main/java/au/gov/health/covidsafe/Utils.kt +++ b/app/src/main/java/au/gov/health/covidsafe/Utils.kt @@ -3,6 +3,7 @@ package au.gov.health.covidsafe import android.Manifest import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothDevice +import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent import android.content.pm.PackageManager @@ -28,6 +29,8 @@ import java.io.File import java.text.SimpleDateFormat import java.util.* +private const val APP_PACKAGE_NAME = "au.gov.health.covidsafe" + object Utils { private const val TAG = "Utils" @@ -272,4 +275,16 @@ object Utils { CentralLog.e(TAG, "announceForAccessibility throws exception.", e) } } + + fun gotoPlayStore(context: Context) { + try { + context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$APP_PACKAGE_NAME")).also { + it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + }) + } catch (anfe: ActivityNotFoundException) { + context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$APP_PACKAGE_NAME")).also { + it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + }) + } + } } diff --git a/app/src/main/java/au/gov/health/covidsafe/extensions/PermissionExtensions.kt b/app/src/main/java/au/gov/health/covidsafe/extensions/PermissionExtensions.kt index da059db..4f529d6 100644 --- a/app/src/main/java/au/gov/health/covidsafe/extensions/PermissionExtensions.kt +++ b/app/src/main/java/au/gov/health/covidsafe/extensions/PermissionExtensions.kt @@ -24,7 +24,7 @@ const val LOCATION = 345 const val BATTERY_OPTIMISER = 789 fun Fragment.requestAllPermissions(onEndCallback: () -> Unit) { - if (isBlueToothEnabled() ?: true) { + if (requireContext().isBlueToothEnabled() ?: true) { requestFineLocationAndCheckBleSupportThenNextPermission(onEndCallback) } else { requestBlueToothPermissionThenNextPermission() @@ -104,44 +104,36 @@ fun Fragment.gotoPushNotificationSettings() { context.startActivity(intent) } -fun Fragment.isBlueToothEnabled(): Boolean? { - val bluetoothManager = activity?.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager? +fun Context.isBlueToothEnabled(): Boolean? { + val bluetoothManager = this.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager? return bluetoothManager?.adapter?.isEnabled } -fun Fragment.isPushNotificationEnabled(): Boolean? { - return activity?.let { activity -> - NotificationManagerCompat.from(activity).areNotificationsEnabled() - } +fun Context.isPushNotificationEnabled(): Boolean? { + return NotificationManagerCompat.from(this).areNotificationsEnabled() } -fun Fragment.isLocationPermissionAllowed(): Boolean? { - return activity?.let { activity -> - EasyPermissions.hasPermissions(activity, ACCESS_COARSE_LOCATION) - } +fun Context.isLocationPermissionAllowed(): Boolean? { + return EasyPermissions.hasPermissions(this, ACCESS_COARSE_LOCATION) } -fun Fragment.isLocationEnabledOnDevice(): Boolean { - val locationManager = context?.getSystemService(Context.LOCATION_SERVICE) as LocationManager? +fun Context.isLocationEnabledOnDevice(): Boolean { + val locationManager = this.getSystemService(Context.LOCATION_SERVICE) as LocationManager? return locationManager?.let { it.isProviderEnabled(LocationManager.GPS_PROVIDER) || it.isProviderEnabled(LocationManager.NETWORK_PROVIDER) } ?: false } -fun Fragment.isBatteryOptimizationDisabled(): Boolean? { - return activity?.let { activity -> - val powerManager = activity.getSystemService(AppCompatActivity.POWER_SERVICE) as PowerManager? - val packageName = activity.packageName +fun Context.isBatteryOptimizationDisabled(): Boolean? { + val powerManager = this.getSystemService(AppCompatActivity.POWER_SERVICE) as PowerManager? + val packageName = this.packageName - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - powerManager?.isIgnoringBatteryOptimizations(packageName) ?: true - } else { - null - } - } ?: run { - null + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + return powerManager?.isIgnoringBatteryOptimizations(packageName) ?: true } + + return null } fun Fragment.askForLocationPermission() { @@ -154,7 +146,7 @@ fun Fragment.askForLocationPermission() { .build()) } - !isLocationEnabledOnDevice() -> { + !it.isLocationEnabledOnDevice() -> { AlertDialog.Builder(it).apply { setMessage(R.string.need_location_service) setPositiveButton(android.R.string.ok) { _, _ -> diff --git a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt index 7fba051..aceaeab 100644 --- a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt +++ b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt @@ -10,17 +10,19 @@ import au.gov.health.covidsafe.interactor.Either import au.gov.health.covidsafe.interactor.Failure import au.gov.health.covidsafe.interactor.Success import au.gov.health.covidsafe.interactor.UseCase +import au.gov.health.covidsafe.logging.CentralLog import au.gov.health.covidsafe.networking.response.BroadcastMessageResponse import au.gov.health.covidsafe.networking.service.AwsClient import kotlin.math.pow +private const val TAG = "UpdateBroadcastMessage" +private const val RETRIES_LIMIT = 3 +private const val GET_TEMP_ID_API_VERSION = 2 + class UpdateBroadcastMessageAndPerformScanWithExponentialBackOff(private val awsClient: AwsClient, private val context: Context, lifecycle: Lifecycle) : UseCase(lifecycle) { - private val TAG = this.javaClass.simpleName - private val RETRIES_LIMIT = 3 - override suspend fun run(params: Void?): Either { val jwtToken = Preference.getEncrypterJWTToken(context) return jwtToken?.let { jwtToken -> @@ -60,8 +62,12 @@ class UpdateBroadcastMessageAndPerformScanWithExponentialBackOff(private val aws private fun call(jwtToken: String): Response? { return try { - awsClient.getTempId("Bearer $jwtToken").execute() + awsClient.getTempId( + "Bearer $jwtToken", + GET_TEMP_ID_API_VERSION + ).execute() } catch (e: Exception) { + CentralLog.e(TAG, " awsClient.getTempId() failed.", e) null } } diff --git a/app/src/main/java/au/gov/health/covidsafe/links/LinkBuilder.kt b/app/src/main/java/au/gov/health/covidsafe/links/LinkBuilder.kt index 70de689..10da2ba 100644 --- a/app/src/main/java/au/gov/health/covidsafe/links/LinkBuilder.kt +++ b/app/src/main/java/au/gov/health/covidsafe/links/LinkBuilder.kt @@ -66,6 +66,9 @@ object LinkBuilder { return url } + fun getHelpTopicsUrlWithAnchor(anchor : String) = + getHelpTopicsUrl() + anchor + private fun getBluetoothPairingRequestUrl() = getHelpTopicsUrl() + HELP_TOPICS_ANCHOR_BLUETOOTH_PAIRING_REQUEST diff --git a/app/src/main/java/au/gov/health/covidsafe/networking/service/AwsClient.kt b/app/src/main/java/au/gov/health/covidsafe/networking/service/AwsClient.kt index 2dfb6cb..46b74ef 100644 --- a/app/src/main/java/au/gov/health/covidsafe/networking/service/AwsClient.kt +++ b/app/src/main/java/au/gov/health/covidsafe/networking/service/AwsClient.kt @@ -16,7 +16,10 @@ interface AwsClient { fun respondToAuthChallenge(@Body body: AuthChallengeRequest): Call @GET(BuildConfig.END_POINT_PREFIX + "/getTempId") - fun getTempId(@Header("Authorization") jwtToken: String?): Call + fun getTempId( + @Header("Authorization") jwtToken: String?, + @Query("version") apiVersion: Int + ): Call @GET(BuildConfig.END_POINT_PREFIX + "/initiateDataUpload") fun initiateUpload( @@ -35,7 +38,9 @@ interface AwsClient { @Header("Authorization") jwtToken: String?, @Query("os") os: String, @Query("appversion") appversion: String, - @Query("token") token: String + @Query("token") token: String, + @Query("healthcheck") healthcheck: String, + @Query("preferredLanguages") preferredLanguages: String ): Call } \ No newline at end of file diff --git a/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt b/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt index a83960d..b27b979 100644 --- a/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt +++ b/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt @@ -9,35 +9,73 @@ import android.content.Context import au.gov.health.covidsafe.BuildConfig import au.gov.health.covidsafe.Preference import au.gov.health.covidsafe.TracerApp +import au.gov.health.covidsafe.extensions.isBatteryOptimizationDisabled +import au.gov.health.covidsafe.extensions.isBlueToothEnabled +import au.gov.health.covidsafe.extensions.isLocationEnabledOnDevice +import au.gov.health.covidsafe.extensions.isLocationPermissionAllowed import au.gov.health.covidsafe.factory.NetworkFactory.Companion.awsClient import au.gov.health.covidsafe.logging.CentralLog import au.gov.health.covidsafe.networking.response.MessagesResponse +import au.gov.health.covidsafe.scheduler.GetMessagesScheduler.mostRecentRecordTimestamp +import au.gov.health.covidsafe.streetpass.persistence.StreetPassRecord +import au.gov.health.covidsafe.streetpass.persistence.StreetPassRecordDatabase +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch import retrofit2.Call import retrofit2.Callback import retrofit2.Response +import java.util.* private const val TAG = "GetMessagesScheduler" private const val GET_MESSAGES_JOB_ID = 1 private const val TWENTY_FOUR_HOURS_IN_MILLIS = 24 * 60 * 60 * 1000L +private const val SEVEN_DAYS_IN_MILLIS = 7 * TWENTY_FOUR_HOURS_IN_MILLIS + +private const val HEALTH_CHECK_RESULT_OK = "OK" +private const val HEALTH_CHECK_RESULT_POSSIBLE_ERROR = "POSSIBLE_ERROR" // for testing only //private const val TWENTY_FOUR_HOURS_IN_MILLIS = 16 * 60 * 1000L class GetMessagesJobSchedulerService : JobService() { + private val mostRecentRecordLiveData = StreetPassRecordDatabase.getDatabase(TracerApp.AppContext).recordDao().getMostRecentRecord() + + private val mostRecentRecordObserver = androidx.lifecycle.Observer { + mostRecentRecordTimestamp = it?.timestamp ?: 0 + CentralLog.d(TAG, "mostRecentRecordObserver updates mostRecentRecordTimestamp to $mostRecentRecordTimestamp") + } + override fun onStartJob(params: JobParameters): Boolean { CentralLog.d(TAG, "onStartJob()") - GetMessagesScheduler.getMessages(this, params) + + mostRecentRecordLiveData.observeForever(mostRecentRecordObserver) + + GlobalScope.launch(Dispatchers.IO) { + delay(1000) + + GlobalScope.launch(Dispatchers.Main) { + GetMessagesScheduler.getMessages(this@GetMessagesJobSchedulerService, params) + } + } + return true } override fun onStopJob(params: JobParameters): Boolean { CentralLog.d(TAG, "onStopJob()") + + mostRecentRecordLiveData.removeObserver(mostRecentRecordObserver) + return true } } object GetMessagesScheduler { + var mostRecentRecordTimestamp: Long = 0 + fun scheduleGetMessagesJob() { CentralLog.d(TAG, "scheduleGetMessagesJob()") @@ -66,11 +104,42 @@ object GetMessagesScheduler { val appVersion = "${BuildConfig.VERSION_CODE}" val token = Preference.getFirebaseInstanceID(context) + val isBlueToothEnabled = context.isBlueToothEnabled() != false + val isBatteryOptimizationDisabled = context.isBatteryOptimizationDisabled() != false + val isLocationPermissionAllowed = context.isLocationPermissionAllowed() != false + val isLocationEnabledOnDevice = context.isLocationEnabledOnDevice() + val isLastRecordWithinSevenDays = + (System.currentTimeMillis() - mostRecentRecordTimestamp) <= SEVEN_DAYS_IN_MILLIS + + CentralLog.d(TAG, "isBlueToothEnabled = $isBlueToothEnabled") + CentralLog.d(TAG, "isBatteryOptimizationDisabled = $isBatteryOptimizationDisabled") + CentralLog.d(TAG, "isLocationPermissionAllowed = $isLocationPermissionAllowed") + CentralLog.d(TAG, "isLocationEnabledOnDevice = $isLocationEnabledOnDevice") + CentralLog.d(TAG, "isLastRecordWithinSevenDays = $isLastRecordWithinSevenDays (mostRecentRecordTimestamp = $mostRecentRecordTimestamp)") + + val healthCheck = if ( + isBlueToothEnabled && + isBatteryOptimizationDisabled && + isLocationPermissionAllowed && + isLocationEnabledOnDevice && + isLastRecordWithinSevenDays + ) { + HEALTH_CHECK_RESULT_OK + } else { + HEALTH_CHECK_RESULT_POSSIBLE_ERROR + } + + CentralLog.d(TAG, "healthCheck = $healthCheck") + + val preferredLanguages = Locale.getDefault().language + val messagesCall: Call = awsClient.getMessages( "Bearer $jwtToken", os, appVersion, - token + token, + healthCheck, + preferredLanguages ) CentralLog.d(TAG, "getMessages() to be called with InstanceID = $token") diff --git a/app/src/main/java/au/gov/health/covidsafe/services/CovidFirebaseMessagingService.kt b/app/src/main/java/au/gov/health/covidsafe/services/CovidFirebaseMessagingService.kt index dfb830d..39178c5 100644 --- a/app/src/main/java/au/gov/health/covidsafe/services/CovidFirebaseMessagingService.kt +++ b/app/src/main/java/au/gov/health/covidsafe/services/CovidFirebaseMessagingService.kt @@ -1,6 +1,7 @@ package au.gov.health.covidsafe.services import au.gov.health.covidsafe.* +import au.gov.health.covidsafe.Utils.gotoPlayStore import au.gov.health.covidsafe.logging.CentralLog import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage @@ -28,8 +29,11 @@ class CovidFirebaseMessagingService : FirebaseMessagingService() { // log notification payload. remoteMessage.notification?.let { - CentralLog.d(TAG, "onMessageReceived() notification = ${it.title} ${it.body}") + CentralLog.d(TAG, "onMessageReceived() notification = ${it.title} ${it.body} ${it.clickAction}") + if (it.clickAction == "au.gov.health.covidsafe.UPGRADE_APP"){ + gotoPlayStore(applicationContext) + } } // log data payload. diff --git a/app/src/main/java/au/gov/health/covidsafe/streetpass/Work.kt b/app/src/main/java/au/gov/health/covidsafe/streetpass/Work.kt index 709c75e..6964c00 100644 --- a/app/src/main/java/au/gov/health/covidsafe/streetpass/Work.kt +++ b/app/src/main/java/au/gov/health/covidsafe/streetpass/Work.kt @@ -2,6 +2,7 @@ package au.gov.health.covidsafe.streetpass import android.bluetooth.BluetoothDevice import android.bluetooth.BluetoothGatt +import android.bluetooth.BluetoothGattCallback import android.content.Context import android.os.Build import au.gov.health.covidsafe.logging.CentralLog @@ -40,7 +41,27 @@ class Work constructor( gatt = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { device.connectGatt(context, false, gattCallback, BluetoothDevice.TRANSPORT_LE) } else { - device.connectGatt(context, false, gattCallback) + // use reflection to call connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback, int transport) + try { + device.javaClass.getMethod( + "connectGatt", + Context::class.java, + Boolean::class.java, + BluetoothGattCallback::class.java, + Int::class.java + ).invoke( + device, + context, + false, + gattCallback, + 2 // BluetoothDevice.TRANSPORT_LE = 2 + ) as BluetoothGatt + } catch (e: Exception) { + CentralLog.e(TAG, "Reflection call of connectGatt() failed.") + + // reflection failed; call connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback) instead + device.connectGatt(context, false, gattCallback) + } } if (gatt == null) { diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/PagerChildFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/PagerChildFragment.kt index 0361612..0955226 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/PagerChildFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/PagerChildFragment.kt @@ -13,8 +13,8 @@ abstract class PagerChildFragment : BaseFragment() { } private fun updateProgressBar() { - (parentFragment?.parentFragment as? PagerContainer)?.updateProgressBar(stepProgress) - (activity as? PagerContainer)?.updateProgressBar(stepProgress) + (parentFragment?.parentFragment as? PagerContainer)?.updateSteps(step, totalSteps) + (activity as? PagerContainer)?.updateSteps(step, totalSteps) } private fun updateToolBar() { @@ -37,6 +37,11 @@ abstract class PagerChildFragment : BaseFragment() { (activity as? PagerContainer)?.refreshButton(updateButtonLayout) } + fun disableNavigationButton(){ + (parentFragment?.parentFragment as? PagerContainer)?.setNavigationIcon(null) + (activity as? PagerContainer)?.setNavigationIcon(null) + } + fun enableContinueButton() { (parentFragment?.parentFragment as? PagerContainer)?.enableNextButton() (activity as? PagerContainer)?.enableNextButton() @@ -59,7 +64,9 @@ abstract class PagerChildFragment : BaseFragment() { protected open var navigationIconResId: Int? = au.gov.health.covidsafe.R.drawable.ic_up - abstract var stepProgress: Int? + abstract var step: Int? + private val totalSteps = 4 + abstract fun getUploadButtonLayout(): UploadButtonLayout abstract fun updateButtonState() } diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/PagerContainer.kt b/app/src/main/java/au/gov/health/covidsafe/ui/PagerContainer.kt index 30d4504..35683a1 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/PagerContainer.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/PagerContainer.kt @@ -7,7 +7,7 @@ interface PagerContainer { fun disableNextButton() fun showLoading() fun hideLoading(@StringRes stringRes: Int?) - fun updateProgressBar(stepProgress: Int?) + fun updateSteps(step: Int?, totalSteps: Int) fun setNavigationIcon(navigationIcon: Int?) fun refreshButton(updateButtonLayout: UploadButtonLayout) } \ No newline at end of file diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt index 4e8e4c2..d89b10f 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt @@ -12,19 +12,19 @@ import android.webkit.WebView import android.webkit.WebViewClient import androidx.core.view.isVisible import androidx.navigation.fragment.findNavController +import au.gov.health.covidsafe.R +import au.gov.health.covidsafe.links.LinkBuilder +import au.gov.health.covidsafe.ui.BaseFragment import com.atlassian.mobilekit.module.feedback.FeedbackModule import kotlinx.android.synthetic.main.fragment_help.* import kotlinx.android.synthetic.main.fragment_help.view.* -import au.gov.health.covidsafe.R -import au.gov.health.covidsafe.links.LinkBuilder -import au.gov.health.covidsafe.logging.CentralLog -import au.gov.health.covidsafe.ui.BaseFragment -import kotlinx.android.synthetic.main.activity_country_code_selection.* -import java.util.* private const val TAG = "HelpFragment" class HelpFragment : BaseFragment() { + companion object { + var anchor: String? = null + } override fun onCreateView( inflater: LayoutInflater, @@ -37,7 +37,14 @@ class HelpFragment : BaseFragment() { val webView = view.helpWebView webView.settings.javaScriptEnabled = true webView.webViewClient = createWebVieClient(view) - webView.loadUrl(LinkBuilder.getHelpTopicsUrl()) + + val url = when (val anchorReadonly = anchor) { + null -> LinkBuilder.getHelpTopicsUrl() + else -> LinkBuilder.getHelpTopicsUrlWithAnchor(anchorReadonly) + } + + webView.loadUrl(url) + reportAnIssue.setOnClickListener { FeedbackModule.showFeedbackScreen() } @@ -87,7 +94,6 @@ class HelpFragment : BaseFragment() { } - } diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt index 55251e0..8b33382 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt @@ -31,6 +31,7 @@ import kotlinx.android.synthetic.main.fragment_home_setup_complete_header.* import kotlinx.android.synthetic.main.fragment_home_setup_incomplete_content.* import pub.devrel.easypermissions.AppSettingsDialog import pub.devrel.easypermissions.EasyPermissions +import java.lang.ref.WeakReference import java.text.SimpleDateFormat import java.util.* @@ -39,6 +40,10 @@ private const val FOURTEEN_DAYS_IN_MILLIS = 14 * ONE_DAY_IN_MILLIS class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { + companion object{ + var instanceWeakRef: WeakReference? = null + } + private lateinit var presenter: HomePresenter private var mIsBroadcastListenerRegistered = false @@ -78,8 +83,11 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + view.home_header_help.setOnClickListener { + HelpFragment.anchor = null findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToHelpFragment()) + } if (BuildConfig.ENABLE_DEBUG_SCREEN) { view.header_background.setOnClickListener { @@ -96,6 +104,8 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { override fun onResume() { super.onResume() + instanceWeakRef = WeakReference(this) + // display app update reminder // if (System.currentTimeMillis() // - @@ -125,18 +135,25 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { home_setup_complete_app.setOnClickListener { goToCovidApp() } + help_topics_link.setOnClickListener { + HelpFragment.anchor = null findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToHelpFragment()) } - go_to_play_store.setOnClickListener { - app_update_reminder.visibility = GONE + change_language_link.setOnClickListener { + HelpFragment.anchor = "#other-languages" + findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToHelpFragment()) } - remind_me_later.setOnClickListener { - Preference.putAppUpdateReminderDismissedTime(requireContext()) - app_update_reminder.visibility = GONE - } +// go_to_play_store.setOnClickListener { +// app_update_reminder.visibility = GONE +// } +// +// remind_me_later.setOnClickListener { +// Preference.putAppUpdateReminderDismissedTime(requireContext()) +// app_update_reminder.visibility = GONE +// } if (!mIsBroadcastListenerRegistered) { registerBroadcast() @@ -149,6 +166,9 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { override fun onPause() { super.onPause() + + instanceWeakRef = null + bluetooth_card_view.setOnClickListener(null) location_card_view.setOnClickListener(null) battery_card_view.setOnClickListener(null) @@ -189,7 +209,7 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { } @SuppressLint("SetTextI18n") - private fun refreshSetupCompleteOrIncompleteUi() { + fun refreshSetupCompleteOrIncompleteUi() { context?.let { val isAllPermissionsEnabled = allPermissionsEnabled() val isDataUploadedInPast14Days = isDataUploadedInPast14Days(it) @@ -270,16 +290,18 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { } private fun allPermissionsEnabled(): Boolean { - val bluetoothEnabled = isBlueToothEnabled() ?: false - val pushNotificationEnabled = isPushNotificationEnabled() ?: true - val nonBatteryOptimizationAllowed = isBatteryOptimizationDisabled() ?: true - val locationStatusAllowed = isLocationPermissionAllowed() ?: true + val context = requireContext() + + val bluetoothEnabled = context.isBlueToothEnabled() ?: false + val pushNotificationEnabled = context.isPushNotificationEnabled() ?: true + val nonBatteryOptimizationAllowed = context.isBatteryOptimizationDisabled() ?: true + val locationStatusAllowed = context.isLocationPermissionAllowed() ?: true return bluetoothEnabled && pushNotificationEnabled && nonBatteryOptimizationAllowed && locationStatusAllowed && - isLocationEnabledOnDevice() + context.isLocationEnabledOnDevice() } private fun registerBroadcast() { @@ -302,7 +324,7 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { } private fun updateBlueToothStatus() { - isBlueToothEnabled()?.let { + requireContext().isBlueToothEnabled()?.let { bluetooth_card_view.visibility = VISIBLE bluetooth_card_view.render(formatBlueToothTitle(it), it) } ?: run { @@ -311,7 +333,7 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { } private fun updatePushNotificationStatus() { - isPushNotificationEnabled()?.let { + requireContext().isPushNotificationEnabled()?.let { push_card_view.visibility = VISIBLE push_card_view.render( formatPushNotificationTitle(it), @@ -324,7 +346,7 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { } private fun updateBatteryOptimizationStatus() { - isBatteryOptimizationDisabled()?.let { + requireContext().isBatteryOptimizationDisabled()?.let { battery_card_view.visibility = VISIBLE battery_card_view.render( formatNonBatteryOptimizationTitle(!it), @@ -337,8 +359,8 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks { } private fun updateLocationStatus() { - isLocationPermissionAllowed()?.let { - val locationWorking = it && isLocationEnabledOnDevice() + requireContext().isLocationPermissionAllowed()?.let { + val locationWorking = it && requireContext().isLocationEnabledOnDevice() location_card_view.visibility = VISIBLE location_card_view.render(formatLocationTitle(locationWorking), locationWorking) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/OnboardingActivity.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/OnboardingActivity.kt index 122ed25..9de88d5 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/OnboardingActivity.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/OnboardingActivity.kt @@ -9,6 +9,7 @@ import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import au.gov.health.covidsafe.HasBlockingState +import au.gov.health.covidsafe.Preference import au.gov.health.covidsafe.R import au.gov.health.covidsafe.ui.PagerContainer import au.gov.health.covidsafe.ui.UploadButtonLayout @@ -47,20 +48,35 @@ class OnboardingActivity : FragmentActivity(), HasBlockingState, PagerContainer } } - override fun updateProgressBar(stepProgress: Int?) { - stepProgress?.let { progress -> - onboarding_progress_bar.visibility = VISIBLE - onboarding_progress_bar.progress = progress - } ?: run { - onboarding_progress_bar.visibility = GONE + override fun onBackPressed() { + if (Preference.isOnBoarded(this)) { + finish() + } else { + super.onBackPressed() + } + } + + override fun updateSteps(step: Int?, totalSteps: Int) { + when (step) { + null -> { + textViewSteps.visibility = GONE + } + else -> { + textViewSteps.visibility = VISIBLE + textViewSteps.text = String.format(getString(R.string.stepCounter), step, totalSteps) + } } } override fun setNavigationIcon(navigationIcon: Int?) { if (navigationIcon == null) { toolbar.navigationIcon = null + toolbar.visibility = GONE + toolbarReplacer.visibility = VISIBLE } else { toolbar.navigationIcon = ContextCompat.getDrawable(this, navigationIcon) + toolbar.visibility = VISIBLE + toolbarReplacer.visibility = GONE } } @@ -118,5 +134,4 @@ class OnboardingActivity : FragmentActivity(), HasBlockingState, PagerContainer onboarding_next.hideProgress(newTextRes = stringRes) } } - } diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/dataprivacy/DataPrivacyFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/dataprivacy/DataPrivacyFragment.kt index 57ecaf6..208bc53 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/dataprivacy/DataPrivacyFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/dataprivacy/DataPrivacyFragment.kt @@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.fragment_data_privacy.view.* class DataPrivacyFragment : PagerChildFragment() { - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View? = inflater.inflate(R.layout.fragment_data_privacy, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enternumber/EnterNumberFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enternumber/EnterNumberFragment.kt index 9065da1..53c9472 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enternumber/EnterNumberFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enternumber/EnterNumberFragment.kt @@ -38,7 +38,7 @@ class EnterNumberFragment : PagerChildFragment() { const val ENTER_NUMBER_PROGRESS = "progress" } - override var stepProgress: Int? = 2 + override var step: Int? = 2 private val enterNumberPresenter = EnterNumberPresenter(this) private var alertDialog: AlertDialog? = null @@ -67,7 +67,7 @@ class EnterNumberFragment : PagerChildFragment() { arguments?.let { destinationId = it.getInt(ENTER_NUMBER_DESTINATION_ID) - stepProgress = if (it.containsKey(ENTER_NUMBER_PROGRESS)) it.getInt(ENTER_PIN_PROGRESS) else null + step = if (it.containsKey(ENTER_NUMBER_PROGRESS)) it.getInt(ENTER_PIN_PROGRESS) else null } } @@ -166,7 +166,7 @@ class EnterNumberFragment : PagerChildFragment() { ENTER_PIN_CALLING_CODE to callingCode, ENTER_PIN_PHONE_NUMBER to phoneNumber, ENTER_PIN_DESTINATION_ID to destinationId).also { bundle -> - stepProgress?.let { + step?.let { bundle.putInt(ENTER_PIN_PROGRESS, it + 1) } } diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinFragment.kt index ac4f45c..1d82d49 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinFragment.kt @@ -34,7 +34,7 @@ class EnterPinFragment : PagerChildFragment() { const val ENTER_PIN_PROGRESS = "progress" } - override var stepProgress: Int? = 3 + override var step: Int? = 3 private val COUNTDOWN_DURATION = 5 * 60L // OTP Code expiry @@ -57,7 +57,7 @@ class EnterPinFragment : PagerChildFragment() { val phoneNumber = it.getString(ENTER_PIN_PHONE_NUMBER)!! destinationId = it.getInt(ENTER_PIN_DESTINATION_ID) - stepProgress = if (it.containsKey(ENTER_PIN_PROGRESS)) it.getInt(ENTER_PIN_PROGRESS) else null + step = if (it.containsKey(ENTER_PIN_PROGRESS)) it.getInt(ENTER_PIN_PROGRESS) else null enter_pin_headline.text = resources.getString(R.string.enter_pin_headline, "+$callingCode", phoneNumber) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/howitworks/HowItWorksFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/howitworks/HowItWorksFragment.kt index b93f197..ba1ee11 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/howitworks/HowItWorksFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/howitworks/HowItWorksFragment.kt @@ -16,7 +16,7 @@ import kotlinx.android.synthetic.main.fragment_how_it_works.view.* class HowItWorksFragment : PagerChildFragment() { - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View? = inflater.inflate(R.layout.fragment_how_it_works, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/introduction/IntroductionFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/introduction/IntroductionFragment.kt index 1f462fd..d99a2c1 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/introduction/IntroductionFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/introduction/IntroductionFragment.kt @@ -14,7 +14,7 @@ import kotlinx.android.synthetic.main.fragment_intro.* class IntroductionFragment : PagerChildFragment() { override var navigationIconResId: Int? = null - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View? = inflater.inflate(R.layout.fragment_intro, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionDeviceNameFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionDeviceNameFragment.kt index 2acd67b..3fd9a65 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionDeviceNameFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionDeviceNameFragment.kt @@ -2,7 +2,7 @@ package au.gov.health.covidsafe.ui.onboarding.fragment.permission import android.bluetooth.BluetoothAdapter import android.os.Bundle -import android.text.Html +import android.provider.Settings import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -16,7 +16,7 @@ import kotlinx.android.synthetic.main.fragment_permission_device_name.* class PermissionDeviceNameFragment : PagerChildFragment() { - override var stepProgress: Int? = 5 + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View? = inflater.inflate(R.layout.fragment_permission_device_name, container, false) @@ -25,44 +25,30 @@ class PermissionDeviceNameFragment : PagerChildFragment() { super.onResume() context?.let { - val deviceName = "${BluetoothAdapter.getDefaultAdapter()?.name}" - - val paragraph1 = it.getString(R.string.change_device_name_content_line_1, deviceName) - val paragraph2 = "

" + it.getString(R.string.change_device_name_content_line_2) - - val paragraphs = "$paragraph1$paragraph2" - - change_device_name_content.text = - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { - Html.fromHtml(paragraphs, Html.FROM_HTML_MODE_COMPACT) - } else { - Html.fromHtml(paragraphs) - } + change_device_name_content.setText(R.string.change_device_name_content_line_2) + change_device_name_text_box.setText(Settings.Secure.getString(it.contentResolver, "bluetooth_name")) } - change_device_name_headline.setHeading() change_device_name_headline.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) + + disableNavigationButton() } private fun navigateToNextPage() { navigateTo(R.id.action_permissionDeviceNameFragment_to_permissionSuccessFragment) } - override fun getUploadButtonLayout() = UploadButtonLayout.TwoChoiceContinueLayout( - R.string.change_device_name_primary_action, - { - BluetoothAdapter.getDefaultAdapter()?.name = change_device_name_text_box.text.toString() - navigateToNextPage() - }, - R.string.change_device_name_secondary_action, - { - navigateToNextPage() - } - ) + override fun getUploadButtonLayout() = UploadButtonLayout.ContinueLayout( + R.string.change_device_name_primary_action + ) { + BluetoothAdapter.getDefaultAdapter()?.name = change_device_name_text_box.text.toString() + navigateToNextPage() + } override fun updateButtonState() { enableContinueButton() + disableNavigationButton() } override fun onDestroyView() { diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionFragment.kt index 908c041..795395d 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permission/PermissionFragment.kt @@ -34,7 +34,7 @@ class PermissionFragment : PagerChildFragment(), EasyPermissions.PermissionCallb ) } - override var stepProgress: Int? = 4 + override var step: Int? = 4 private var navigationStarted = false @@ -48,6 +48,12 @@ class PermissionFragment : PagerChildFragment(), EasyPermissions.PermissionCallb permission_headline.setHeading() permission_headline.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) + + disableNavigationButton() + + activity?.let { + Preference.putIsOnBoarded(it, true) + } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { @@ -76,7 +82,7 @@ class PermissionFragment : PagerChildFragment(), EasyPermissions.PermissionCallb private fun hasAllPermissionsAndBluetoothOn(): Boolean { val context = TracerApp.AppContext - return isBlueToothEnabled() == true + return context.isBlueToothEnabled() == true && requiredPermissions.all { ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_GRANTED } && ContextCompat.getSystemService(context, PowerManager::class.java)?.isIgnoringBatteryOptimizations(context.packageName) ?: true } @@ -108,9 +114,6 @@ class PermissionFragment : PagerChildFragment(), EasyPermissions.PermissionCallb override fun getUploadButtonLayout() = UploadButtonLayout.ContinueLayout(R.string.permission_button) { disableContinueButton() navigationStarted = true - activity?.let { - Preference.putIsOnBoarded(it, true) - } requestAllPermissions { navigateToNextPage() } diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permissionsuccess/PermissionSuccessFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permissionsuccess/PermissionSuccessFragment.kt index 77ba38f..118663f 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permissionsuccess/PermissionSuccessFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/permissionsuccess/PermissionSuccessFragment.kt @@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.fragment_permission_success.* class PermissionSuccessFragment : PagerChildFragment() { - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View? = inflater.inflate(R.layout.fragment_permission_success, container, false) @@ -30,6 +30,8 @@ class PermissionSuccessFragment : PagerChildFragment() { permission_success_content.text = LinkBuilder.getHowPermissionSuccessContent(requireContext()) permission_success_content.movementMethod = LinkMovementMethod.getInstance() + + disableNavigationButton() } private fun navigateToNextPage() { diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/personal/PersonalDetailsFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/personal/PersonalDetailsFragment.kt index 610b5e4..6712920 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/personal/PersonalDetailsFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/personal/PersonalDetailsFragment.kt @@ -32,7 +32,7 @@ private val NAME_REGEX = Pattern.compile("^[A-Za-z0-9\\u00C0-\\u017F][A-Za-z'0-9 class PersonalDetailsFragment : PagerChildFragment() { private var alertDialog: AlertDialog? = null - override var stepProgress: Int? = 1 + override var step: Int? = 1 private lateinit var name: String private lateinit var postcode: String diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/registrationconsent/RegistrationConsentFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/registrationconsent/RegistrationConsentFragment.kt index 939eef9..0987b28 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/registrationconsent/RegistrationConsentFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/registrationconsent/RegistrationConsentFragment.kt @@ -14,7 +14,7 @@ import kotlinx.android.synthetic.main.fragment_registration_consent.* class RegistrationConsentFragment : PagerChildFragment() { - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View? = inflater.inflate(R.layout.fragment_registration_consent, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/undersixteen/UnderSixteenFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/undersixteen/UnderSixteenFragment.kt index fed5567..8edc727 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/undersixteen/UnderSixteenFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/undersixteen/UnderSixteenFragment.kt @@ -15,7 +15,7 @@ import kotlinx.android.synthetic.main.fragment_under_sixteen.* class UnderSixteenFragment : PagerChildFragment() { - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) : View? = inflater.inflate(R.layout.fragment_under_sixteen, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/upload/UploadContainerFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/upload/UploadContainerFragment.kt index 774b2e3..c1db2be 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/upload/UploadContainerFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/upload/UploadContainerFragment.kt @@ -13,7 +13,6 @@ import au.gov.health.covidsafe.ui.PagerContainer import au.gov.health.covidsafe.ui.UploadButtonLayout import com.github.razir.progressbutton.hideProgress import com.github.razir.progressbutton.showProgress -import kotlinx.android.synthetic.main.fragment_help.* import kotlinx.android.synthetic.main.fragment_upload_master.* import kotlinx.android.synthetic.main.fragment_upload_master.toolbar @@ -38,13 +37,8 @@ class UploadContainerFragment : Fragment(), PagerContainer { toolbar.setNavigationOnClickListener(null) } - override fun updateProgressBar(stepProgress: Int?) { - if (stepProgress == null) { - upload_progress.visibility = INVISIBLE - } else { - upload_progress.visibility = VISIBLE - upload_progress.progress = stepProgress - } + override fun updateSteps(step: Int?, totalSteps: Int) { + // do nothing } override fun setNavigationIcon(navigationIcon: Int?) { diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadFinishedFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadFinishedFragment.kt index 15428c3..0cd0d23 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadFinishedFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadFinishedFragment.kt @@ -14,7 +14,7 @@ import kotlinx.android.synthetic.main.fragment_upload_finished.* class UploadFinishedFragment : PagerChildFragment() { override var navigationIconResId: Int? = null - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_upload_finished, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadInitialFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadInitialFragment.kt index b055784..481e2a6 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadInitialFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadInitialFragment.kt @@ -14,7 +14,7 @@ import kotlinx.android.synthetic.main.fragment_upload_page_4.root class UploadInitialFragment : PagerChildFragment() { - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_upload_initial, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadStepFourFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadStepFourFragment.kt index 4b7cf21..584e691 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadStepFourFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/UploadStepFourFragment.kt @@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.fragment_upload_page_4.* class UploadStepFourFragment : PagerChildFragment() { private var alertDialog: AlertDialog? = null - override var stepProgress: Int? = null + override var step: Int? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_upload_page_4, container, false) diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/VerifyUploadPinFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/VerifyUploadPinFragment.kt index c180fb3..205c42e 100644 --- a/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/VerifyUploadPinFragment.kt +++ b/app/src/main/java/au/gov/health/covidsafe/ui/upload/presentation/VerifyUploadPinFragment.kt @@ -38,7 +38,7 @@ class VerifyUploadPinFragment : PagerChildFragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? = inflater.inflate(R.layout.fragment_verify_upload_pin, container, false) - override var stepProgress: Int? = null + override var step: Int? = null override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/app/src/main/res/drawable/ic_globe.xml b/app/src/main/res/drawable/ic_globe.xml new file mode 100644 index 0000000..3c0e61a --- /dev/null +++ b/app/src/main/res/drawable/ic_globe.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/app/src/main/res/layout/activity_onboarding.xml b/app/src/main/res/layout/activity_onboarding.xml index 28ca64b..f0b06bc 100644 --- a/app/src/main/res/layout/activity_onboarding.xml +++ b/app/src/main/res/layout/activity_onboarding.xml @@ -15,8 +15,21 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:navigationIcon="@drawable/ic_up" - app:navigationContentDescription="@string/navigation_back_button_content_description"/> + app:navigationContentDescription="@string/navigation_back_button_content_description" + app:navigationIcon="@drawable/ic_up" /> + + + + - -