-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes New menu forgets its "Hide accounts" setting
- Loading branch information
1 parent
fb561e3
commit 4ac65b3
Showing
22 changed files
with
190 additions
and
32 deletions.
There are no files selected for viewing
9 changes: 8 additions & 1 deletion
9
.../src/main/kotlin/app/k9mail/feature/navigation/drawer/NavigationDrawerExternalContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package app.k9mail.feature.navigation.drawer | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface NavigationDrawerExternalContract { | ||
|
||
data class DrawerConfig( | ||
val showUnifiedFolders: Boolean, | ||
val showStarredCount: Boolean, | ||
val showAccountSelector: Boolean, | ||
) | ||
|
||
fun interface DrawerConfigLoader { | ||
fun loadDrawerConfig(): DrawerConfig | ||
fun loadDrawerConfigFlow(): Flow<DrawerConfig> | ||
} | ||
|
||
fun interface DrawerConfigWriter { | ||
fun writeDrawerConfig(drawerConfig: DrawerConfig) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...r/src/main/kotlin/app/k9mail/feature/navigation/drawer/domain/usecase/SaveDrawerConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package app.k9mail.feature.navigation.drawer.domain.usecase | ||
|
||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract | ||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfigWriter | ||
import app.k9mail.feature.navigation.drawer.domain.DomainContract.UseCase | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
|
||
internal class SaveDrawerConfig( | ||
private val drawerConfigWriter: DrawerConfigWriter, | ||
) : UseCase.SaveDrawerConfig { | ||
override fun invoke(drawerConfig: NavigationDrawerExternalContract.DrawerConfig): Flow<Unit> { | ||
return flow { | ||
emit(drawerConfigWriter.writeDrawerConfig(drawerConfig)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
...rc/test/kotlin/app/k9mail/feature/navigation/drawer/domain/usecase/GetDrawerConfigTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
package app.k9mail.feature.navigation.drawer.domain.usecase | ||
|
||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfig | ||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract.DrawerConfigLoader | ||
import assertk.assertThat | ||
import assertk.assertions.isEqualTo | ||
import kotlin.test.Test | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.flowOf | ||
import kotlinx.coroutines.test.runTest | ||
import org.mockito.Mockito.mock | ||
import org.mockito.kotlin.whenever | ||
|
||
internal class GetDrawerConfigTest { | ||
|
||
@Test | ||
fun `should get drawer config`() = runTest { | ||
val configProver: DrawerConfigLoader = mock() | ||
val drawerConfig = DrawerConfig( | ||
showUnifiedFolders = true, | ||
showStarredCount = true, | ||
showAccountSelector = true, | ||
) | ||
|
||
val testSubject = GetDrawerConfig( | ||
configProver = { drawerConfig }, | ||
) | ||
val testSubject = GetDrawerConfig(configProver = configProver) | ||
whenever(configProver.loadDrawerConfigFlow()).thenReturn(flowOf(drawerConfig)) | ||
|
||
val result = testSubject().first() | ||
|
||
assertThat(result).isEqualTo( | ||
DrawerConfig( | ||
showUnifiedFolders = true, | ||
showStarredCount = true, | ||
), | ||
) | ||
assertThat(result).isEqualTo(drawerConfig) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
legacy/common/src/main/java/com/fsck/k9/feature/NavigationDrawerConfigWriter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.fsck.k9.feature | ||
|
||
import app.k9mail.feature.navigation.drawer.NavigationDrawerExternalContract | ||
import app.k9mail.legacy.preferences.DrawerConfigManager | ||
|
||
class NavigationDrawerConfigWriter( | ||
private val drawerConfigManager: DrawerConfigManager, | ||
) : NavigationDrawerExternalContract.DrawerConfigWriter { | ||
override fun writeDrawerConfig(drawerConfig: NavigationDrawerExternalContract.DrawerConfig) { | ||
drawerConfigManager.save(drawerConfig) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.