This repository was archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathWelcomeFragment.kt
More file actions
76 lines (63 loc) · 2.78 KB
/
Copy pathWelcomeFragment.kt
File metadata and controls
76 lines (63 loc) · 2.78 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package mozilla.lockbox.view
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import io.reactivex.Observable
import com.jakewharton.rxbinding2.view.clicks
import kotlinx.android.synthetic.main.fragment_welcome.view.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.lockbox.R
import mozilla.lockbox.presenter.WelcomePresenter
import mozilla.lockbox.presenter.WelcomeView
class WelcomeFragment : Fragment(), WelcomeView {
@ExperimentalCoroutinesApi
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val chinaBuild = resources.configuration.locales.get(0).toString().equals("zh_CN_#Hans") &&
resources.configuration.locales.get(0).displayLanguage.equals("中文") &&
(!"com.android.vending".equals(context!!.packageManager.getInstallerPackageName(context!!.packageName)))
presenter = WelcomePresenter(this, chinaBuild)
val view = inflater.inflate(R.layout.fragment_welcome, container, false)
val appLabel = getString(R.string.app_label)
view.textViewInstructions.text = getString(R.string.welcome_instructions, appLabel)
view.lockwiseIcon.contentDescription = getString(R.string.app_logo, appLabel)
return view
}
override fun showExistingAccount(email: String) {
view?.apply {
buttonGetStarted.text = getString(R.string.welcome_start_automatic_btn, email)
buttonGetStarted.visibility = View.VISIBLE
buttonGetStartedManually.text = getString(R.string.welcome_start_force_manual_btn)
buttonGetStartedManually.visibility = View.VISIBLE
}
}
override fun hideExistingAccount() {
view?.apply {
buttonGetStarted.visibility = View.GONE
buttonGetStartedManually.text = getString(R.string.welcome_start_btn)
buttonGetStartedManually.visibility = View.VISIBLE
}
}
override fun hideSwitchService() {
view?.apply {
textViewSwitchService.visibility = View.GONE
}
}
override val getStartedAutomaticallyClicks: Observable<Unit>
get() = view!!.buttonGetStarted.clicks()
override val getStartedManuallyClicks: Observable<Unit>
get() = view!!.buttonGetStartedManually.clicks()
override val learnMoreClicks: Observable<Unit>
get() = view!!.textViewLearnMore.clicks()
override val switchServiceClicks: Observable<Unit>
get() = view!!.textViewSwitchService.clicks()
}