-
Notifications
You must be signed in to change notification settings - Fork 539
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 a part of #2133: Prevent vanishing of input on configuration change. #5617
base: develop
Are you sure you want to change the base?
Changes from all commits
2e51a58
6560e75
86da8f9
b774f2f
69760d9
1860e1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.oppia.android.app.profile | ||
|
||
import android.os.Bundle | ||
import android.text.method.PasswordTransformationMethod | ||
import android.view.animation.AnimationUtils | ||
import androidx.appcompat.app.AlertDialog | ||
|
@@ -43,6 +44,7 @@ class PinPasswordActivityPresenter @Inject constructor( | |
private var profileId = ProfileId.getDefaultInstance() | ||
private lateinit var alertDialog: AlertDialog | ||
private var confirmedDeletion = false | ||
private lateinit var binding: PinPasswordActivityBinding | ||
|
||
fun handleOnCreate() { | ||
val args = activity.intent.getProtoExtra( | ||
|
@@ -54,7 +56,7 @@ class PinPasswordActivityPresenter @Inject constructor( | |
internalProfileId = args?.internalProfileId ?: -1 | ||
profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() | ||
|
||
val binding = DataBindingUtil.setContentView<PinPasswordActivityBinding>( | ||
binding = DataBindingUtil.setContentView<PinPasswordActivityBinding>( | ||
activity, | ||
R.layout.pin_password_activity | ||
) | ||
|
@@ -247,6 +249,14 @@ class PinPasswordActivityPresenter @Inject constructor( | |
exitProcess(0) | ||
} | ||
} | ||
fun handleSaveInstanceState(outState: Bundle) { | ||
val enteredPin = binding.pinPasswordInputPinEditText.text.toString() | ||
outState.putString("enteredPin", enteredPin) | ||
} | ||
Comment on lines
+252
to
+255
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a couple of changes needed here in order to conform with Oppia Android coding patterns:
To retrieve the state, use: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @adhiamboperes , I'll implement the changes. |
||
fun handleRestoreInstanceState(restoreInstanceState: Bundle) { | ||
val restoredPin = restoreInstanceState.getString("enteredPin") | ||
binding.pinPasswordInputPinEditText.setText(restoredPin) | ||
} | ||
|
||
private fun showSuccessDialog() { | ||
AlertDialog.Builder(activity, R.style.OppiaAlertDialogTheme) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this manifest change is required. Could you please explain the need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @adhiamboperes , I have tested without changing the manifest file but on configuration change changes does not persist as mentioned in the issue. I have tested many approaches like LiveData with the ViewModel but only this method could solve the issue.
Can you please suggest me any better approach so I can implement the same.