From 69c7a7bc2357d57ecbbe119053be3fb136739913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20N=C3=BCsse?= Date: Wed, 18 Oct 2023 11:13:46 +0200 Subject: [PATCH] fix alarm slide not working properly update images and texts --- .../Activities/OnboardingActivity.kt | 70 ++++++--- .../main/res/drawable/undraw_completion.xml | 86 +++++++++++ .../res/drawable/undraw_time_management.xml | 140 ++++++++++++++++++ app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values/strings.xml | 5 +- 5 files changed, 278 insertions(+), 25 deletions(-) create mode 100644 app/src/main/res/drawable/undraw_completion.xml create mode 100644 app/src/main/res/drawable/undraw_time_management.xml diff --git a/app/src/main/java/ca/pkay/rcloneexplorer/Activities/OnboardingActivity.kt b/app/src/main/java/ca/pkay/rcloneexplorer/Activities/OnboardingActivity.kt index 142e6d44..bcfb5425 100644 --- a/app/src/main/java/ca/pkay/rcloneexplorer/Activities/OnboardingActivity.kt +++ b/app/src/main/java/ca/pkay/rcloneexplorer/Activities/OnboardingActivity.kt @@ -51,6 +51,12 @@ class OnboardingActivity : AppIntro2() { } else { false } + } else if(permission == Manifest.permission.WRITE_EXTERNAL_STORAGE) { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + Environment.isExternalStorageManager() + } else { + ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED + } } else { return context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED } @@ -65,6 +71,7 @@ class OnboardingActivity : AppIntro2() { private var storageRequested = false private var storageGranted = false private var alarmRequested = false + private var alarmGranted = false private var color = R.color.intro_color1 @@ -122,7 +129,7 @@ class OnboardingActivity : AppIntro2() { AppIntroFragment.newInstance( title = getString(R.string.intro_permission_changed_title), description = getString(R.string.intro_permission_changed_description), - imageDrawable = R.drawable.undraw_the_world_is_mine, + imageDrawable = R.drawable.undraw_completion, backgroundColor = resources.getColor(color) )) switchColor() @@ -131,7 +138,7 @@ class OnboardingActivity : AppIntro2() { } - if(!checkExternalStorageManagerPermission()) { + if(!checkGenericPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { addSlide( AppIntroFragment.newInstance( title = getString(R.string.intro_storage_title), @@ -169,7 +176,7 @@ class OnboardingActivity : AppIntro2() { AppIntroFragment.newInstance( title = getString(R.string.intro_alarms_title), description = getString(R.string.intro_alarms_description), - imageDrawable = R.drawable.undraw_post_online, + imageDrawable = R.drawable.undraw_time_management, backgroundColor = resources.getColor(color), )) switchColor() @@ -209,21 +216,21 @@ class OnboardingActivity : AppIntro2() { return true } - if (isAlarmSlide && alarmRequested) { + if (isAlarmSlide && alarmGranted) { return true } if(isStorageSlide) { - if(checkExternalStorageManagerPermission()){ + if(checkGenericPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)){ storageGranted = true return true } - tryGrantingAllStorageAccess() + requestStoragePermission() } if(isAlarmSlide) { if(checkGenericPermission(this, Manifest.permission.SCHEDULE_EXACT_ALARM)){ - alarmRequested = true + alarmGranted = true return true } requestAlarmPermission() @@ -244,13 +251,12 @@ class OnboardingActivity : AppIntro2() { finish() } - private fun tryGrantingAllStorageAccess() { + private fun requestStoragePermission() { if(storageRequested) { return } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) intent.data = Uri.fromParts( "package", @@ -267,38 +273,58 @@ class OnboardingActivity : AppIntro2() { storageRequested = true } - private fun checkExternalStorageManagerPermission(): Boolean { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - Environment.isExternalStorageManager() - } else { - ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED + private fun requestAlarmPermission(){ + if (alarmRequested) { + return } + startActivity(Intent(ACTION_REQUEST_SCHEDULE_EXACT_ALARM)) + alarmRequested = true } override fun onResume() { super.onResume() if(isStorageSlide) { - if(checkExternalStorageManagerPermission()){ - Toasty.success(this, getString(R.string.intro_manage_external_storage_granted), Toast.LENGTH_SHORT, true).show() + if(checkGenericPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)){ storageGranted = true goToNextSlide() } else { - Toasty.info(this, getString(R.string.intro_manage_external_storage_failed), Toast.LENGTH_LONG, true).show() + denied(Manifest.permission.WRITE_EXTERNAL_STORAGE) storageRequested = false } } if(isAlarmSlide) { - + if(checkGenericPermission(this, Manifest.permission.SCHEDULE_EXACT_ALARM)){ + alarmGranted = true + goToNextSlide() + } else { + denied(Manifest.permission.SCHEDULE_EXACT_ALARM) + alarmRequested = false + } } } - private fun requestAlarmPermission(){ - if (alarmRequested) { - return + override fun onUserDeniedPermission(permissionName: String) { + super.onUserDeniedPermission(permissionName) + denied(permissionName) + + } + + override fun onUserDisabledPermission(permissionName: String) { + super.onUserDisabledPermission(permissionName) + denied(permissionName) + } + private fun denied(permissionName: String){ + if(permissionName == Manifest.permission.POST_NOTIFICATIONS) { + Toasty.info(this, getString(R.string.intro_notifications_denied), Toast.LENGTH_SHORT, true).show() } - startActivity(Intent(ACTION_REQUEST_SCHEDULE_EXACT_ALARM)) + if(permissionName == Manifest.permission.WRITE_EXTERNAL_STORAGE) { + Toasty.info(this, getString(R.string.intro_write_external_storage_denied), Toast.LENGTH_LONG, true).show() + } + //if(permissionName == Manifest.permission.SCHEDULE_EXACT_ALARM) { + // Toasty.info(this, getString(R.string.intro_alarms_denied), Toast.LENGTH_SHORT, true).show() + //} } private fun switchColor() { diff --git a/app/src/main/res/drawable/undraw_completion.xml b/app/src/main/res/drawable/undraw_completion.xml new file mode 100644 index 00000000..62bcd15f --- /dev/null +++ b/app/src/main/res/drawable/undraw_completion.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/undraw_time_management.xml b/app/src/main/res/drawable/undraw_time_management.xml new file mode 100644 index 00000000..7e3a78bd --- /dev/null +++ b/app/src/main/res/drawable/undraw_time_management.xml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index dc6bbb2a..5ef66151 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -405,7 +405,7 @@ Bidirektional Dies bestimmt die Quelle und das Ziel für den Datentransfer. Du kannst nun loslegen! - Dateizugriff nicht erlaubt. + Dateizugriff nicht erlaubt. Die problematische Datei: Benutze md5-Prüfsummen Wenn eingeschaltet überschreibt diese die globale Einstellung bezüglich des Datentransfers über WLan diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e14a57e9..61e96515 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -486,8 +486,7 @@ Make sure local and remote storage have the same files by transferring, downloading, and deleting files as needed to maintain an identical folder structure. Success! You are now ready to start! - File access permission granted! - File access permission not granted + File access permission not granted "The offending File: " Use md5 checksum If enabled, this setting overrides the global setting to only transfer files over Wi-Fi @@ -531,4 +530,6 @@ We need to be able to set alarms to schedule sync\'s. Dont worry, we will never ring your phone! Started Sync Sync was cancelled + You wont get notifications. + We can\'t schedule alarms now.