-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
435 additions
and
110 deletions.
There are no files selected for viewing
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
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
53 changes: 53 additions & 0 deletions
53
...ample/util/simpletimetracker/domain/interactor/ShouldShowRecordDataSelectionInteractor.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,53 @@ | ||
package com.example.util.simpletimetracker.domain.interactor | ||
|
||
import com.example.util.simpletimetracker.domain.model.RecordDataSelectionDialogResult | ||
import javax.inject.Inject | ||
|
||
class ShouldShowRecordDataSelectionInteractor @Inject constructor( | ||
private val prefsInteractor: PrefsInteractor, | ||
private val getSelectableTagsInteractor: GetSelectableTagsInteractor, | ||
) { | ||
|
||
suspend fun execute( | ||
typeId: Long, | ||
commentInputAvailable: Boolean, | ||
): RecordDataSelectionDialogResult { | ||
val fields = mutableListOf<RecordDataSelectionDialogResult.Field>() | ||
if (needToShowTags(typeId)) { | ||
fields += RecordDataSelectionDialogResult.Field.Tags | ||
} | ||
if (needToShowComment(typeId, commentInputAvailable)) { | ||
fields += RecordDataSelectionDialogResult.Field.Comment | ||
} | ||
return RecordDataSelectionDialogResult(fields) | ||
} | ||
|
||
private suspend fun needToShowTags(typeId: Long): Boolean { | ||
if (!prefsInteractor.getShowRecordTagSelection()) return false | ||
|
||
val excludedActivities = prefsInteractor.getRecordTagSelectionExcludeActivities() | ||
|
||
// Check if activity is excluded from tag dialog. | ||
return if (typeId !in excludedActivities) { | ||
// Check if activity has tags. | ||
val assignableTags = getSelectableTagsInteractor.execute(typeId) | ||
.filterNot { it.archived } | ||
assignableTags.isNotEmpty() | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
private suspend fun needToShowComment( | ||
typeId: Long, | ||
commentInputAvailable: Boolean, | ||
): Boolean { | ||
if (!commentInputAvailable) return false | ||
if (!prefsInteractor.getShowCommentInput()) return false | ||
|
||
val excludedActivities = prefsInteractor.getCommentInputExcludeActivities() | ||
|
||
// Check if activity is excluded from comment input. | ||
return typeId !in excludedActivities | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
.../com/example/util/simpletimetracker/domain/interactor/ShouldShowTagSelectionInteractor.kt
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...n/java/com/example/util/simpletimetracker/domain/model/RecordDataSelectionDialogResult.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,10 @@ | ||
package com.example.util.simpletimetracker.domain.model | ||
|
||
data class RecordDataSelectionDialogResult( | ||
val fields: List<Field>, | ||
) { | ||
sealed interface Field { | ||
object Tags : Field | ||
object Comment : Field | ||
} | ||
} |
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
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.