Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes part of #16: Implementation of AdminAuthActivity and AddProfileActivity #327

Merged
merged 125 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
0b1fb2a
implemented get and delete
jamesxu0 Oct 23, 2019
dac9b0a
Finished test cases
jamesxu0 Oct 23, 2019
a4b46e5
added observing cachestore
jamesxu0 Oct 23, 2019
9c2f6a8
Fixed test cases
jamesxu0 Oct 24, 2019
53b5e78
Merge branch 'implement-directory-util' into Implement-profile-manage…
jamesxu0 Oct 24, 2019
ab2c396
Finished first draft of implementation
jamesxu0 Oct 24, 2019
b4f8e1f
Added additional checks to setCurrentProfileId
jamesxu0 Oct 25, 2019
36e4ac9
Added more test cases
jamesxu0 Oct 25, 2019
0309848
Finished test stubs
jamesxu0 Oct 28, 2019
2be5883
Finished test cases
jamesxu0 Oct 28, 2019
1b52ae3
Merge branch 'develop' into Implement-profile-management-controller
jamesxu0 Oct 28, 2019
509479b
Added query string to gravatar
jamesxu0 Oct 28, 2019
74c59a8
primed cache on init
jamesxu0 Oct 28, 2019
bb28e07
Fixed typo
jamesxu0 Oct 28, 2019
087cc0e
Fixed addProfile test case
jamesxu0 Oct 29, 2019
650bbbc
added create method to PersistentCacheStore
jamesxu0 Oct 29, 2019
af182a3
added setTimestamp and setAdmin
jamesxu0 Oct 29, 2019
ad952ec
Merge branch 'develop' into Implement-profile-management-controller
jamesxu0 Oct 29, 2019
71710f1
changed isAdmin to default to false
jamesxu0 Oct 29, 2019
e1b8331
Added update last logged in
jamesxu0 Oct 30, 2019
593f564
Started working on chooser
jamesxu0 Oct 29, 2019
48d600e
debugging
jamesxu0 Oct 29, 2019
6a9e197
Added UI for chooser
jamesxu0 Oct 30, 2019
b3a4641
added click functionality
jamesxu0 Oct 31, 2019
0c23eaa
Minor fixes
jamesxu0 Oct 31, 2019
b5cabbc
Started basic admin auth and add profile
jamesxu0 Oct 31, 2019
f5d854c
Updated to use deferred value from persistentCacheStore
jamesxu0 Oct 31, 2019
3bbd5b7
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Oct 31, 2019
756a759
Updated to use login
jamesxu0 Oct 31, 2019
bc477f0
Ensured result is error to post error value
jamesxu0 Oct 31, 2019
236d82c
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Oct 31, 2019
8d3b76a
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Oct 31, 2019
3ffd5ae
name can only be letters and unique check now case insensitive
jamesxu0 Oct 31, 2019
157a80b
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Oct 31, 2019
145f8c0
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Oct 31, 2019
da254a9
Added profile sorting by last accessed
jamesxu0 Nov 1, 2019
37bb898
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 1, 2019
0770d73
Fixed margins and added gradient
jamesxu0 Nov 1, 2019
663e59b
allow names to have spaces
jamesxu0 Nov 1, 2019
5e3b91b
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 1, 2019
6a0a1cb
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 1, 2019
50fb16c
Switched fragments to activities
jamesxu0 Nov 1, 2019
2409853
Finished admin auth styling
jamesxu0 Nov 1, 2019
5bd6335
Styled inputs for add profile
jamesxu0 Nov 1, 2019
109d6d2
Fixed name only letters toast
jamesxu0 Nov 1, 2019
0692938
Added support for upload image
jamesxu0 Nov 4, 2019
cc48822
Started custom view
jamesxu0 Nov 4, 2019
0dca937
added upload image and fixed input styling
jamesxu0 Nov 5, 2019
8bfd6f6
Added image rotation and compression
jamesxu0 Nov 5, 2019
1ecd457
Added red color
jamesxu0 Nov 5, 2019
ddfd5a6
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 5, 2019
912f1db
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 5, 2019
b533f74
fixed api requires for exifinterface
jamesxu0 Nov 6, 2019
0523f14
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 6, 2019
3591159
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 6, 2019
41a895f
Changed gradle dependency
jamesxu0 Nov 6, 2019
1363bd9
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 6, 2019
da426d3
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 6, 2019
1a59475
Added error handling ui support
jamesxu0 Nov 6, 2019
c48fdeb
Added new asset and changed colors
jamesxu0 Nov 6, 2019
a0c233d
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 6, 2019
e6e504b
hide keyboard on create
jamesxu0 Nov 6, 2019
d389fd0
changed selectedImage to private
jamesxu0 Nov 6, 2019
a24e181
Moved bindingadapter to companion object
jamesxu0 Nov 6, 2019
b9b3257
removed fragment checks
jamesxu0 Nov 6, 2019
505d4e3
Sorted alphabetically
jamesxu0 Nov 7, 2019
a466e74
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 7, 2019
d4c0e17
added local default to tolowercase
jamesxu0 Nov 7, 2019
7b965d5
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 7, 2019
7641603
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 7, 2019
0a3e1b8
updated comment
jamesxu0 Nov 7, 2019
99e18b3
Updated key
jamesxu0 Nov 7, 2019
00d7ae9
added info icon
jamesxu0 Nov 8, 2019
8101d7e
Merge branch 'develop' into Implement-profile-management-controller
jamesxu0 Nov 8, 2019
cb3771b
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 8, 2019
4040d34
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 8, 2019
af03d59
started profile test helper
jamesxu0 Nov 8, 2019
3e9630f
Removed broken test, couldn't get mockito to work
jamesxu0 Nov 8, 2019
c39a49d
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 8, 2019
be186d3
Added ProfileTestHelperTest
jamesxu0 Nov 8, 2019
7c57f11
added test case for profilechooserfragment
jamesxu0 Nov 8, 2019
43a5508
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 8, 2019
8c487fc
Added test for AdminAuthActivity
jamesxu0 Nov 9, 2019
91b6ab2
using string.xml values in tests
jamesxu0 Nov 9, 2019
d0de127
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 9, 2019
730049b
Started AddProfileActivityTest
jamesxu0 Nov 9, 2019
851b83e
Finished test cases
jamesxu0 Nov 10, 2019
221bdbe
Minor fixes and added default profile avatar
jamesxu0 Nov 11, 2019
b2c68fb
minor fixes
jamesxu0 Nov 11, 2019
16cf025
added endline
jamesxu0 Nov 11, 2019
16f911b
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 11, 2019
fd946b4
Minor fixes
jamesxu0 Nov 11, 2019
a5c7c57
removed resources
jamesxu0 Nov 11, 2019
be4415e
Minor fixes.
jamesxu0 Nov 12, 2019
3bb99f9
Started updating to DataProviders
jamesxu0 Nov 16, 2019
ab38cda
Fixed loginToProfile
jamesxu0 Nov 22, 2019
51e675a
Merge branch 'develop' into Implement-profile-management-controller
jamesxu0 Nov 25, 2019
835ad9f
Minor fixes
jamesxu0 Nov 25, 2019
53eaaea
Added comments and new test.
jamesxu0 Nov 25, 2019
ba6b3c8
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 25, 2019
3881966
minor fixes
jamesxu0 Nov 25, 2019
945e2b2
Fixed bug
jamesxu0 Nov 26, 2019
7ae7953
Added vector version of avatar
jamesxu0 Nov 26, 2019
992d780
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 26, 2019
7288409
Minor fixes.
jamesxu0 Nov 27, 2019
21420e4
Converted livedata to dataproviders
jamesxu0 Nov 27, 2019
aed08c8
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 27, 2019
416b998
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 27, 2019
6535831
Minor fixes
jamesxu0 Nov 27, 2019
0b8991b
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 27, 2019
d349940
Removed coroutines from test.
jamesxu0 Nov 27, 2019
49d2f47
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 27, 2019
4ad7773
Added helper methods
jamesxu0 Nov 27, 2019
ac44e90
Removed ExperimentalCoroutinesApi
jamesxu0 Nov 27, 2019
5603950
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Nov 27, 2019
fa2cf78
Removed import
jamesxu0 Nov 27, 2019
4d15d4b
Removed ExperimentalCouroutinesApi
jamesxu0 Nov 27, 2019
676c903
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Nov 27, 2019
b26bd3b
Addressed comments
jamesxu0 Nov 28, 2019
bd2b65d
Fixed failing test cases
jamesxu0 Dec 3, 2019
995404a
Merge branch 'Implement-profile-management-controller' into implement…
jamesxu0 Dec 3, 2019
fc0aef1
Updated xml to multiples of 4
jamesxu0 Dec 3, 2019
c68bdb2
Merge branch 'implement-profile-chooser-fragment' into implement-add-…
jamesxu0 Dec 3, 2019
45d42c3
Fixed dp values
jamesxu0 Dec 4, 2019
ce63ad4
Merge branch 'develop' into implement-add-profile-fragment
jamesxu0 Dec 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"/>
<activity android:name=".player.state.testing.StateFragmentTestActivity" />
<activity
android:name=".profile.AddProfileActivity"
android:screenOrientation="portrait" />
<activity
android:name=".profile.AdminAuthActivity"
android:screenOrientation="portrait" />
<activity
android:name=".profile.ProfileActivity"
android:theme="@style/OppiaThemeWithoutActionBar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import org.oppia.app.home.continueplaying.ContinuePlayingActivity
import org.oppia.app.player.audio.testing.AudioFragmentTestActivity
import org.oppia.app.player.exploration.ExplorationActivity
import org.oppia.app.player.state.testing.StateFragmentTestActivity
import org.oppia.app.profile.AddProfileActivity
import org.oppia.app.profile.AdminAuthActivity
import org.oppia.app.profile.ProfileActivity
import org.oppia.app.settings.profile.ProfileRenameActivity
import org.oppia.app.settings.profile.ProfileResetPinActivity
Expand Down Expand Up @@ -39,6 +41,8 @@ interface ActivityComponent {

fun getFragmentComponentBuilderProvider(): Provider<FragmentComponent.Builder>

fun inject(addProfileActivity: AddProfileActivity)
fun inject(adminAuthActivity: AdminAuthActivity)
fun inject(audioFragmentTestActivity: AudioFragmentTestActivity)
fun inject(bindableAdapterTestActivity: BindableAdapterTestActivity)
fun inject(conceptCardFragmentTestActivity: ConceptCardFragmentTestActivity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import org.oppia.app.player.state.StateFragment
import org.oppia.app.settings.profile.ProfileEditFragment
import org.oppia.app.settings.profile.ProfileListFragment
import org.oppia.app.player.state.itemviewmodel.InteractionViewModelModule
import org.oppia.app.profile.AddProfileFragment
import org.oppia.app.profile.AdminAuthFragment
import org.oppia.app.profile.ProfileChooserFragment
import org.oppia.app.story.StoryFragment
import org.oppia.app.testing.BindableAdapterTestFragment
Expand Down Expand Up @@ -57,6 +55,4 @@ interface FragmentComponent {
fun inject(profileListFragment: ProfileListFragment)
fun inject(profileEditFragment: ProfileEditFragment)
fun inject(profileChooserFragment: ProfileChooserFragment)
fun inject(adminAuthFragment: AdminAuthFragment)
fun inject(addProfileFragment: AddProfileFragment)
}
30 changes: 30 additions & 0 deletions app/src/main/java/org/oppia/app/profile/AddProfileActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.oppia.app.profile

import android.content.Intent
import android.os.Bundle
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.oppia.app.activity.InjectableAppCompatActivity
import javax.inject.Inject

/** Activity that allows users to create new profiles. */
class AddProfileActivity : InjectableAppCompatActivity() {
@Inject
lateinit var addProfileFragmentPresenter: AddProfileActivityPresenter

@ExperimentalCoroutinesApi
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
addProfileFragmentPresenter.handleOnCreate()
}

override fun onSupportNavigateUp(): Boolean {
finish()
return false
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
addProfileFragmentPresenter.handleOnActivityResult(requestCode, resultCode, data)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
package org.oppia.app.profile

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.provider.MediaStore
import android.text.Editable
import android.text.TextWatcher
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Observer
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.oppia.app.R
import org.oppia.app.activity.ActivityScope
import org.oppia.app.databinding.AddProfileActivityBinding
import org.oppia.app.viewmodel.ViewModelProvider
import org.oppia.domain.profile.ProfileManagementController
import org.oppia.util.data.AsyncResult
import javax.inject.Inject

const val GALLERY_INTENT_RESULT_CODE = 1

/** The presenter for [AddProfileActivity]. */
@ActivityScope
class AddProfileActivityPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val profileManagementController: ProfileManagementController,
private val viewModelProvider: ViewModelProvider<AddProfileViewModel>
) {
private lateinit var uploadImageView: ImageView
private val profileViewModel by lazy {
getAddProfileViewModel()
}
private var selectedImage: Uri? = null
private var allowDownloadAccess = false
private var inputtedPin = false
private var inputtedConfirmPin = false

@ExperimentalCoroutinesApi
fun handleOnCreate() {
activity.title = activity.getString(R.string.add_profile_title)
activity.supportActionBar?.setDisplayHomeAsUpEnabled(true)
activity.supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp)

val binding = DataBindingUtil.setContentView<AddProfileActivityBinding>(activity, R.layout.add_profile_activity)

binding.apply {
viewModel = profileViewModel
}

binding.allowDownloadSwitch.setOnCheckedChangeListener { _, isChecked ->
allowDownloadAccess = isChecked
}

binding.infoIcon.setOnClickListener {
showInfoDialog()
}

uploadImageView = binding.uploadImageButton

addTextChangedListeners(binding)
addButtonListeners(binding)
}

fun handleOnActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == GALLERY_INTENT_RESULT_CODE && resultCode == Activity.RESULT_OK) {
data?.let {
selectedImage = data.data
Glide.with(activity)
.load(selectedImage)
.centerCrop()
.apply(RequestOptions.circleCropTransform())
.into(uploadImageView)
}
}
}

private fun addButtonListeners(binding: AddProfileActivityBinding) {
binding.uploadImageButton.setOnClickListener {
val galleryIntent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
activity.startActivityForResult(galleryIntent, GALLERY_INTENT_RESULT_CODE)
}

binding.createButton.setOnClickListener {
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
profileViewModel.clearAllErrorMessages()

val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
imm?.hideSoftInputFromWindow(activity.currentFocus?.windowToken, 0)

val name = binding.inputName.getInput()
val pin = binding.inputPin.getInput()
val confirmPin = binding.inputConfirmPin.getInput()

if (checkInputsAreValid(name, pin, confirmPin)) {
binding.scroll.smoothScrollTo(0, 0)
return@setOnClickListener
}

profileManagementController.addProfile(name, pin, selectedImage, allowDownloadAccess, isAdmin = false)
.observe(activity, Observer {
handleAddProfileResult(it, binding)
})
}
}

private fun checkInputsAreValid(name: String, pin: String, confirmPin: String): Boolean {
var failed = false
if (name.isEmpty()) {
profileViewModel.nameErrorMsg.set(activity.resources.getString(R.string.add_profile_error_name_empty))
failed = true
}
if (pin.isNotEmpty() && pin.length < 3) {
profileViewModel.pinErrorMsg.set(activity.resources.getString(R.string.add_profile_error_pin_length))
failed = true
}
if (pin != confirmPin) {
profileViewModel.confirmPinErrorMsg.set(activity.resources.getString(R.string.add_profile_error_pin_confirm_wrong))
failed = true
}
return failed
}

private fun handleAddProfileResult(result: AsyncResult<Any?>, binding: AddProfileActivityBinding) {
if (result.isSuccess()) {
val intent = Intent(activity, ProfileActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
activity.startActivity(intent)
} else if (result.isFailure()) {
when (result.getErrorOrNull()) {
is ProfileManagementController.ProfileNameNotUniqueException -> profileViewModel.nameErrorMsg.set(
activity.resources.getString(
R.string.add_profile_error_name_not_unique
)
)
is ProfileManagementController.ProfileNameOnlyLettersException -> profileViewModel.nameErrorMsg.set(
activity.resources.getString(
R.string.add_profile_error_name_only_letters
)
)
}
binding.scroll.smoothScrollTo(0, 0)
}
}

private fun addTextChangedListeners(binding: AddProfileActivityBinding) {
fun setValidPin() {
if (inputtedPin && inputtedConfirmPin) {
profileViewModel.validPin.set(true)
} else {
binding.allowDownloadSwitch.isChecked = false
profileViewModel.validPin.set(false)
}
}

addTextChangedListener(binding.inputPin) { pin ->
pin?.let {
profileViewModel.pinErrorMsg.set("")
inputtedPin = pin.isNotEmpty()
setValidPin()
}
}

addTextChangedListener(binding.inputConfirmPin) { confirmPin ->
confirmPin?.let {
profileViewModel.confirmPinErrorMsg.set("")
inputtedConfirmPin = confirmPin.isNotEmpty()
setValidPin()
}
}

addTextChangedListener(binding.inputName) { name ->
name?.let {
profileViewModel.nameErrorMsg.set("")
}
}
}

private fun addTextChangedListener(profileInputView: ProfileInputView, onTextChanged: (CharSequence?) -> Unit) {
profileInputView.addTextChangedListener(object : TextWatcher {
override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
onTextChanged(p0)
}

override fun afterTextChanged(p0: Editable?) {}
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
})
}

private fun showInfoDialog() {
AlertDialog.Builder(activity as Context, R.style.AlertDialogTheme)
.setMessage(R.string.add_profile_pin_info)
.setPositiveButton(R.string.add_profile_close) { dialog, _ ->
dialog.dismiss()
}.create().show()
}

private fun getAddProfileViewModel(): AddProfileViewModel {
return viewModelProvider.getForActivity(activity, AddProfileViewModel::class.java)
}
}
23 changes: 0 additions & 23 deletions app/src/main/java/org/oppia/app/profile/AddProfileFragment.kt

This file was deleted.

This file was deleted.

21 changes: 21 additions & 0 deletions app/src/main/java/org/oppia/app/profile/AddProfileViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.oppia.app.profile

import androidx.databinding.ObservableField
import org.oppia.app.activity.ActivityScope
import org.oppia.app.viewmodel.ObservableViewModel
import javax.inject.Inject

/** The ViewModel for [AddProfileActivity]. */
@ActivityScope
class AddProfileViewModel @Inject constructor() : ObservableViewModel() {
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
val validPin = ObservableField(false)
val pinErrorMsg = ObservableField("")
val confirmPinErrorMsg = ObservableField("")
val nameErrorMsg = ObservableField("")

fun clearAllErrorMessages() {
pinErrorMsg.set("")
confirmPinErrorMsg.set("")
nameErrorMsg.set("")
}
}
35 changes: 35 additions & 0 deletions app/src/main/java/org/oppia/app/profile/AdminAuthActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.oppia.app.profile

import android.content.Context
import android.content.Intent
import android.os.Bundle
import org.oppia.app.activity.InjectableAppCompatActivity
import javax.inject.Inject

const val KEY_ADMIN_AUTH_ADMIN_PIN = "ADMIN_AUTH_ADMIN_PIN"

/** Activity that authenticates by checking for admin's PIN. */
class AdminAuthActivity : InjectableAppCompatActivity() {
@Inject
lateinit var adminAuthFragmentPresenter: AdminAuthActivityPresenter

companion object {
fun createAdminAuthActivityIntent(context: Context, adminPin: String): Intent {
val intent = Intent(context, AdminAuthActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
intent.putExtra(KEY_ADMIN_AUTH_ADMIN_PIN, adminPin)
return intent
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityComponent.inject(this)
adminAuthFragmentPresenter.handleOnCreate()
}

override fun onSupportNavigateUp(): Boolean {
finish()
return false
}
}
Loading