-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#378 enable all and disable all menu buttons now affect fingerprint g…
…estures
- Loading branch information
Showing
9 changed files
with
84 additions
and
19 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
10 changes: 10 additions & 0 deletions
10
app/src/main/java/io/github/sds100/keymapper/data/usecase/MenuKeymapUseCase.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 io.github.sds100.keymapper.data.usecase | ||
|
||
/** | ||
* Created by sds100 on 06/11/20. | ||
*/ | ||
|
||
interface MenuKeymapUseCase { | ||
suspend fun enableAll() | ||
suspend fun disableAll() | ||
} |
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
51 changes: 51 additions & 0 deletions
51
app/src/main/java/io/github/sds100/keymapper/data/viewmodel/MenuFragmentViewModel.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,51 @@ | ||
package io.github.sds100.keymapper.data.viewmodel | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.lifecycle.viewModelScope | ||
import io.github.sds100.keymapper.data.repository.FingerprintGestureRepository | ||
import io.github.sds100.keymapper.data.usecase.MenuKeymapUseCase | ||
import io.github.sds100.keymapper.util.FingerprintGestureUtils | ||
import kotlinx.coroutines.launch | ||
|
||
/** | ||
* Created by sds100 on 17/11/20. | ||
*/ | ||
class MenuFragmentViewModel(private val mKeymapUseCase: MenuKeymapUseCase, | ||
private val mFingerprintGestureRepository: FingerprintGestureRepository) : ViewModel() { | ||
|
||
fun enableAll() { | ||
viewModelScope.launch { | ||
mKeymapUseCase.enableAll() | ||
} | ||
|
||
FingerprintGestureUtils.GESTURES.forEach { gestureId -> | ||
mFingerprintGestureRepository.edit(gestureId) { | ||
it.clone(isEnabled = true) | ||
} | ||
} | ||
} | ||
|
||
fun disableAll() { | ||
viewModelScope.launch { | ||
mKeymapUseCase.disableAll() | ||
} | ||
|
||
FingerprintGestureUtils.GESTURES.forEach { gestureId -> | ||
mFingerprintGestureRepository.edit(gestureId) { | ||
it.clone(isEnabled = false) | ||
} | ||
} | ||
} | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
class Factory( | ||
private val mKeymapUseCase: MenuKeymapUseCase, | ||
private val mFingerprintGestureRepository: FingerprintGestureRepository | ||
) : ViewModelProvider.NewInstanceFactory() { | ||
|
||
override fun <T : ViewModel?> create(modelClass: Class<T>): T { | ||
return MenuFragmentViewModel(mKeymapUseCase, mFingerprintGestureRepository) as T | ||
} | ||
} | ||
} |
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