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 93 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
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ dependencies {
'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1',
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1',
'org.mockito:mockito-core:2.7.22',
'de.hdodenhof:circleimageview:3.0.1'
)
testImplementation(
'androidx.test:core:1.2.0',
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
<activity android:name=".testing.ContinuePlayingFragmentTestActivity" />
<activity android:name=".home.HomeActivity" />
<activity android:name=".player.audio.testing.AudioFragmentTestActivity" />
<activity android:name=".profile.AdminAuthActivity" />
<activity android:name=".profile.AddProfileActivity" />
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
<activity
android:name=".profile.ProfileActivity"
android:theme="@style/OppiaThemeWithoutActionBar"/>
<activity
android:name=".player.exploration.ExplorationActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity android:name=".player.state.testing.StateFragmentTestActivity" />
<activity android:name=".profile.ProfileActivity" />
<activity
android:name=".splash.SplashActivity"
android:theme="@style/SplashScreenTheme">
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.story.StoryActivity
import org.oppia.app.story.testing.StoryFragmentTestActivity
Expand All @@ -35,6 +37,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 @@ -48,3 +48,11 @@ fun setImageDrawable(imageView: ImageView, thumbnailGraphic: LessonThumbnailGrap
}
)
}

@BindingAdapter("profile:src")
fun setProfileImage(imageView: ImageView, imageUrl: String) {
Glide.with(imageView.context)
.load(imageUrl)
.placeholder(R.drawable.default_avatar)
.into(imageView)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.oppia.app.databinding

import android.text.format.DateUtils
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.BindingAdapter
import java.util.*

/** Converts time in ms to readable relative time string. */
@BindingAdapter("profile:date")
fun setTextWithDate(textView: TextView, timeMs: Long) {
val dateText = "Last used " + DateUtils.getRelativeTimeSpanString(timeMs, Date().time, DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)
textView.text = dateText
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import org.oppia.app.player.audio.AudioFragment
import org.oppia.app.player.exploration.ExplorationFragment
import org.oppia.app.player.state.StateFragment
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 @@ -38,8 +36,6 @@ interface FragmentComponent {

fun getViewComponentBuilderProvider(): Provider<ViewComponent.Builder>

fun inject(addProfileFragment: AddProfileFragment)
fun inject(adminAuthFragment: AdminAuthFragment)
fun inject(audioFragment: AudioFragment)
fun inject(bindableAdapterTestFragment: BindableAdapterTestFragment)
fun inject(conceptCardFragment: ConceptCardFragment)
Expand Down
32 changes: 32 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,32 @@
package org.oppia.app.profile

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

/** Fragment 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)
if (requestCode == GALLERY_INTENT_RESULT_CODE && resultCode == Activity.RESULT_OK) {
addProfileFragmentPresenter.handleOnActivityResult(data)
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
package org.oppia.app.profile

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.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 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>
) {
lateinit var uploadImageView: ImageView
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
private val addViewModel by lazy {
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
getAddProfileViewModel()
}
private var selectedImage: Uri? = null
var allowDownloadAccess = false
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
var inputtedPin = false
var inputtedConfirmPin = false

@ExperimentalCoroutinesApi
fun handleOnCreate() {
activity.title = "Add Profile"
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
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 = addViewModel
}

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

binding.infoIcon.setOnClickListener {
showInfoDialog()
}

addTextChangeListeners(binding)

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)
}
uploadImageView = binding.uploadImageButton

binding.createButton.setOnClickListener {
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
addViewModel.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()
var failed = false
if (name.isEmpty()) {
addViewModel.nameErrorMsg.set(activity.resources.getString(R.string.add_profile_error_name_empty))
failed = true
}
if (pin.isNotEmpty() && pin.length < 3) {
addViewModel.pinErrorMsg.set(activity.resources.getString(R.string.add_profile_error_pin_length))
failed = true
}
if (pin != confirmPin) {
addViewModel.confirmPinErrorMsg.set(activity.resources.getString(R.string.add_profile_error_pin_confirm_wrong))
failed = true
}
if (failed) {
binding.scroll.smoothScrollTo(0,0)
return@setOnClickListener
}
profileManagementController.addProfile(name, pin, selectedImage, allowDownloadAccess, isAdmin = false).observe(activity, Observer {
if (it.isSuccess()) {
val intent = Intent(activity, ProfileActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
activity.startActivity(intent)
} else if (it.isFailure()) {
when (it.getErrorOrNull()) {
is ProfileManagementController.ProfileNameNotUniqueException -> addViewModel.nameErrorMsg.set(activity.resources.getString(R.string.add_profile_error_name_not_unique))
is ProfileManagementController.ProfileNameOnlyLettersException -> addViewModel.nameErrorMsg.set(activity.resources.getString(R.string.add_profile_error_name_only_letters))
}
binding.scroll.smoothScrollTo(0,0)
}
})
}
}

fun handleOnActivityResult(data: Intent?) {
data?.let {
selectedImage = data.data
Glide.with(activity)
.load(selectedImage)
.centerCrop()
.apply(RequestOptions.circleCropTransform())
.into(uploadImageView)
}
}

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

binding.inputPin.addTextChangedListener(object: TextWatcher {
override fun onTextChanged(pin: CharSequence?, start: Int, before: Int, count: Int) {
pin?.let {
addViewModel.pinErrorMsg.set("")
inputtedPin = it.isNotEmpty()
setValidPin()
}
}
override fun afterTextChanged(confirmPin: Editable?) {}
override fun beforeTextChanged(p0: CharSequence?, start: Int, count: Int, after: Int) {}
})

binding.inputConfirmPin.addTextChangedListener(object: TextWatcher {
override fun onTextChanged(confirmPin: CharSequence?, start: Int, before: Int, count: Int) {
confirmPin?.let {
addViewModel.confirmPinErrorMsg.set("")
inputtedConfirmPin = confirmPin.isNotEmpty()
setValidPin()
}
}
override fun afterTextChanged(confirmPin: Editable?) {}
override fun beforeTextChanged(p0: CharSequence?, start: Int, count: Int, after: Int) {}
})

binding.inputName.addTextChangedListener(object: TextWatcher {
jamesxu0 marked this conversation as resolved.
Show resolved Hide resolved
override fun onTextChanged(confirmPin: CharSequence?, start: Int, before: Int, count: Int) {
confirmPin?.let {
addViewModel.nameErrorMsg.set("")
}
}
override fun afterTextChanged(confirmPin: Editable?) {}
override fun beforeTextChanged(p0: CharSequence?, start: Int, count: Int, after: 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.

20 changes: 20 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,20 @@
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

@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("")
}
}
Loading