Skip to content

Commit

Permalink
chores(PR): Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianDevel committed Jan 30, 2024
1 parent 4a5c70f commit 4dc6c3b
Show file tree
Hide file tree
Showing 18 changed files with 416 additions and 484 deletions.
237 changes: 106 additions & 131 deletions .idea/navEditor.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class PermissionsOnboardingPagerFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?): Unit = with(binding) {
super.onViewCreated(view, savedInstanceState)

requireActivity().window.statusBarColor = localSettings.accentColor.getOnboardingSecondaryBackground(context)

permissionUtils.apply {
registerReadContactsPermission(fragment = this@PermissionsOnboardingPagerFragment)
registerNotificationsPermissionIfNeeded(fragment = this@PermissionsOnboardingPagerFragment)
Expand Down Expand Up @@ -84,8 +86,6 @@ class PermissionsOnboardingPagerFragment : Fragment() {
1 -> permissionUtils.requestNotificationsPermissionIfNeeded { leaveOnboarding() }
}
}

requireActivity().window.statusBarColor = localSettings.accentColor.getOnboardingSecondaryBackground(context)
}

override fun onSaveInstanceState(outState: Bundle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,16 @@
*/
package com.infomaniak.mail.ui.main.onboarding

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.infomaniak.mail.utils.PermissionUtils

class PermissionsPagerAdapter(
manager: FragmentManager,
lifecycle: Lifecycle,
) : FragmentStateAdapter(manager, lifecycle) {
class PermissionsPagerAdapter(manager: FragmentManager, lifecycle: Lifecycle) : FragmentStateAdapter(manager, lifecycle) {

override fun getItemCount() = PermissionUtils.getMainPermissions(mustRequireNotification = true).count()

override fun createFragment(position: Int): Fragment {
return PermissionsOnboardingFragment().apply {
arguments = PermissionsOnboardingFragmentArgs(position).toBundle()
}
override fun createFragment(position: Int) = PermissionsOnboardingFragment().apply {
arguments = PermissionsOnboardingFragmentArgs(position).toBundle()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class PermissionUtils @Inject constructor(private val activity: FragmentActivity

/**
* Register notifications permission only for Android API above or equal 33 and if user never manually disabled it.
* Manually disabled means the permission was granted at one point, but is no more.
*/
fun registerNotificationsPermissionIfNeeded(fragment: Fragment) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !localSettings.hasAlreadyEnabledNotifications) {
Expand All @@ -96,6 +97,7 @@ class PermissionUtils @Inject constructor(private val activity: FragmentActivity

/**
* Request notifications permission only for Android API above or equal 33 and if user never manually disabled it.
* Manually disabled means the permission was granted at one point, but is no more.
*/
fun requestNotificationsPermissionIfNeeded(notificationsCallback: (Boolean) -> Unit) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !localSettings.hasAlreadyEnabledNotifications) {
Expand Down Expand Up @@ -137,7 +139,8 @@ class PermissionUtils @Inject constructor(private val activity: FragmentActivity
private const val STORAGE_PERMISSION = Manifest.permission.WRITE_EXTERNAL_STORAGE

/**
* If the user has manually disabled notifications permissions, stop requesting it.
* The field 'mustRequireNotification' is for when the user has manually disabled notifications permissions,
* so we need to stop requesting it.
* Manually disabled means the permission was granted at one point, but is no more.
*/
fun getMainPermissions(mustRequireNotification: Boolean): Array<String> {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
android:fillColor="#1A1A1A"
android:pathData="M155,103.65L214.14,103.37A3.65,3.65 134.73,0 1,217.81 107L217.85,116.47A3.65,3.65 134.73,0 1,214.22 120.14L155.08,120.42A3.65,3.65 134.73,0 1,151.41 116.79L151.37,107.32A3.65,3.65 134.73,0 1,155 103.65z" />
<path
android:fillColor="#00000000"
android:pathData="M155,103.65L214.14,103.37A3.65,3.65 134.73,0 1,217.81 107L217.85,116.47A3.65,3.65 134.73,0 1,214.22 120.14L155.08,120.42A3.65,3.65 134.73,0 1,151.41 116.79L151.37,107.32A3.65,3.65 134.73,0 1,155 103.65z"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D" />
Expand All @@ -72,25 +71,21 @@
android:pathData="M156.2,109.56L161.37,111.12L158.77,113.39C158.57,113.56 158.27,113.5 158.15,113.28L156.2,109.56Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M168.53,108.66H195.68"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.53,112.81H191.91"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.53,115.07H188.14"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M204.73,108.66H214.16"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
Expand All @@ -99,7 +94,6 @@
android:fillColor="#1A1A1A"
android:pathData="M155.12,129.12L214.26,128.84A3.65,3.65 134.73,0 1,217.93 132.47L217.97,141.95A3.65,3.65 134.73,0 1,214.34 145.61L155.2,145.89A3.65,3.65 134.73,0 1,151.53 142.26L151.49,132.79A3.65,3.65 134.73,0 1,155.12 129.12z" />
<path
android:fillColor="#00000000"
android:pathData="M155.12,129.12L214.26,128.84A3.65,3.65 134.73,0 1,217.93 132.47L217.97,141.95A3.65,3.65 134.73,0 1,214.34 145.61L155.2,145.89A3.65,3.65 134.73,0 1,151.53 142.26L151.49,132.79A3.65,3.65 134.73,0 1,155.12 129.12z"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D" />
Expand All @@ -123,25 +117,21 @@
android:pathData="M156.32,135.03L161.49,136.59L158.89,138.86C158.69,139.03 158.39,138.98 158.27,138.75L156.32,135.03Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M168.65,134.13H195.8"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.65,138.28H192.03"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.65,140.54H188.26"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M204.85,134.13H214.28"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
Expand Down Expand Up @@ -174,25 +164,21 @@
android:pathData="M188,53L201.72,57.13L194.82,63.15C194.31,63.6 193.5,63.45 193.18,62.85L188,53Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M218,51H290"
android:strokeWidth="3"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M218,62H280"
android:strokeWidth="1.2"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M218,68H270"
android:strokeWidth="1.2"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M314,51H339"
android:strokeWidth="3"
android:strokeColor="#4D4D4D"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
android:fillColor="#1A1A1A"
android:pathData="M155,103.65L214.14,103.37A3.65,3.65 134.73,0 1,217.81 107L217.85,116.47A3.65,3.65 134.73,0 1,214.22 120.14L155.08,120.42A3.65,3.65 134.73,0 1,151.41 116.79L151.37,107.32A3.65,3.65 134.73,0 1,155 103.65z" />
<path
android:fillColor="#00000000"
android:pathData="M155,103.65L214.14,103.37A3.65,3.65 134.73,0 1,217.81 107L217.85,116.47A3.65,3.65 134.73,0 1,214.22 120.14L155.08,120.42A3.65,3.65 134.73,0 1,151.41 116.79L151.37,107.32A3.65,3.65 134.73,0 1,155 103.65z"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D" />
Expand All @@ -72,25 +71,21 @@
android:pathData="M156.2,109.56L161.37,111.12L158.77,113.39C158.57,113.56 158.27,113.5 158.15,113.28L156.2,109.56Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M168.53,108.66H195.68"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.53,112.81H191.91"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.53,115.07H188.14"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M204.73,108.66H214.16"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
Expand All @@ -99,7 +94,6 @@
android:fillColor="#1A1A1A"
android:pathData="M155.12,129.12L214.26,128.84A3.65,3.65 134.73,0 1,217.93 132.47L217.97,141.95A3.65,3.65 134.73,0 1,214.34 145.61L155.2,145.89A3.65,3.65 134.73,0 1,151.53 142.26L151.49,132.79A3.65,3.65 134.73,0 1,155.12 129.12z" />
<path
android:fillColor="#00000000"
android:pathData="M155.12,129.12L214.26,128.84A3.65,3.65 134.73,0 1,217.93 132.47L217.97,141.95A3.65,3.65 134.73,0 1,214.34 145.61L155.2,145.89A3.65,3.65 134.73,0 1,151.53 142.26L151.49,132.79A3.65,3.65 134.73,0 1,155.12 129.12z"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D" />
Expand All @@ -123,25 +117,21 @@
android:pathData="M156.32,135.03L161.49,136.59L158.89,138.86C158.69,139.03 158.39,138.98 158.27,138.75L156.32,135.03Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M168.65,134.13H195.8"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.65,138.28H192.03"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.65,140.54H188.26"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M204.85,134.13H214.28"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
Expand Down Expand Up @@ -174,25 +164,21 @@
android:pathData="M188,53L201.72,57.13L194.82,63.15C194.31,63.6 193.5,63.45 193.18,62.85L188,53Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M218,51H290"
android:strokeWidth="3"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M218,62H280"
android:strokeWidth="1.2"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M218,68H270"
android:strokeWidth="1.2"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M314,51H339"
android:strokeWidth="3"
android:strokeColor="#4D4D4D"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
android:fillColor="#1A1A1A"
android:pathData="M155,103.65L214.14,103.37A3.65,3.65 134.73,0 1,217.81 107L217.85,116.47A3.65,3.65 134.73,0 1,214.22 120.14L155.08,120.42A3.65,3.65 134.73,0 1,151.41 116.79L151.37,107.32A3.65,3.65 134.73,0 1,155 103.65z" />
<path
android:fillColor="#00000000"
android:pathData="M155,103.65L214.14,103.37A3.65,3.65 134.73,0 1,217.81 107L217.85,116.47A3.65,3.65 134.73,0 1,214.22 120.14L155.08,120.42A3.65,3.65 134.73,0 1,151.41 116.79L151.37,107.32A3.65,3.65 134.73,0 1,155 103.65z"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D" />
Expand All @@ -72,25 +71,21 @@
android:pathData="M156.2,109.56L161.37,111.12L158.77,113.39C158.57,113.56 158.27,113.5 158.15,113.28L156.2,109.56Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M168.53,108.66H195.68"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.53,112.81H191.91"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.53,115.07H188.14"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M204.73,108.66H214.16"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
Expand All @@ -99,7 +94,6 @@
android:fillColor="#1A1A1A"
android:pathData="M155.12,129.12L214.26,128.84A3.65,3.65 134.73,0 1,217.93 132.47L217.97,141.95A3.65,3.65 134.73,0 1,214.34 145.61L155.2,145.89A3.65,3.65 134.73,0 1,151.53 142.26L151.49,132.79A3.65,3.65 134.73,0 1,155.12 129.12z" />
<path
android:fillColor="#00000000"
android:pathData="M155.12,129.12L214.26,128.84A3.65,3.65 134.73,0 1,217.93 132.47L217.97,141.95A3.65,3.65 134.73,0 1,214.34 145.61L155.2,145.89A3.65,3.65 134.73,0 1,151.53 142.26L151.49,132.79A3.65,3.65 134.73,0 1,155.12 129.12z"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D" />
Expand All @@ -123,25 +117,21 @@
android:pathData="M156.32,135.03L161.49,136.59L158.89,138.86C158.69,139.03 158.39,138.98 158.27,138.75L156.32,135.03Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M168.65,134.13H195.8"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.65,138.28H192.03"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M168.65,140.54H188.26"
android:strokeWidth="0.7"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M204.85,134.13H214.28"
android:strokeWidth="1.7"
android:strokeColor="#4D4D4D"
Expand Down Expand Up @@ -174,25 +164,21 @@
android:pathData="M188,53L201.72,57.13L194.82,63.15C194.31,63.6 193.5,63.45 193.18,62.85L188,53Z" />
</group>
<path
android:fillColor="#00000000"
android:pathData="M218,51H290"
android:strokeWidth="3"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M218,62H280"
android:strokeWidth="1.2"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M218,68H270"
android:strokeWidth="1.2"
android:strokeColor="#4D4D4D"
android:strokeLineCap="round" />
<path
android:fillColor="#00000000"
android:pathData="M314,51H339"
android:strokeWidth="3"
android:strokeColor="#4D4D4D"
Expand Down
Loading

0 comments on commit 4dc6c3b

Please sign in to comment.