This repository was archived by the owner on Jun 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathPreferencesPresenter.kt
More file actions
58 lines (47 loc) · 2.18 KB
/
PreferencesPresenter.kt
File metadata and controls
58 lines (47 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package chat.rocket.android.preferences.presentation
import chat.rocket.android.R
import chat.rocket.android.emoji.PhysicalKeyboardConfig
import chat.rocket.android.preferences.interactor.PhysicalKeyboardConfigInteractor
import chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import javax.inject.Inject
class PreferencesPresenter @Inject constructor(
private val view: PreferencesView,
private val analyticsTrackingInteractor: AnalyticsTrackingInteractor,
private val physicalKeyboardConfigInteractor: PhysicalKeyboardConfigInteractor
) {
private var physicalKeyboardConfig: PhysicalKeyboardConfig = PhysicalKeyboardConfig.EnterPlusControl
set(value) {
field = value
physicalKeyboardConfigInteractor.saveConfig(value)
}
get() = physicalKeyboardConfigInteractor.getConfig()
private var tempPhysicalKeyboardConfig = physicalKeyboardConfig
fun loadAnalyticsTrackingInformation() {
view.setupAnalyticsTrackingView(analyticsTrackingInteractor.get())
}
fun enableAnalyticsTracking() {
analyticsTrackingInteractor.save(true)
}
fun disableAnalyticsTracking() {
analyticsTrackingInteractor.save(false)
}
fun getPhysicalKeyboardRadioId(): Int {
return when (physicalKeyboardConfig) {
PhysicalKeyboardConfig.Enter -> R.id.radio_physical_keyboard_enter
PhysicalKeyboardConfig.EnterPlusShift -> R.id.radio_physical_keyboard_enter_shift
PhysicalKeyboardConfig.EnterPlusControl -> R.id.radio_physical_keyboard_enter_control
else -> R.id.radio_physical_keyboard_disabled
}
}
fun onPhysicalKeyboardRadioChange(checkedId: Int) {
tempPhysicalKeyboardConfig = when (checkedId) {
R.id.radio_physical_keyboard_enter -> PhysicalKeyboardConfig.Enter
R.id.radio_physical_keyboard_enter_shift -> PhysicalKeyboardConfig.EnterPlusShift
R.id.radio_physical_keyboard_enter_control -> PhysicalKeyboardConfig.EnterPlusControl
else -> PhysicalKeyboardConfig.Disable
}
}
fun onPhysicalKeyboardDialogOkClicked() {
physicalKeyboardConfig = tempPhysicalKeyboardConfig
}
}