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

fix: crash on sign up #1924

Merged
merged 1 commit into from
Jun 6, 2019
Merged

fix: crash on sign up #1924

merged 1 commit into from
Jun 6, 2019

Conversation

anhanh11001
Copy link
Contributor

@anhanh11001 anhanh11001 commented Jun 6, 2019

Details:

  • Move hint from TextInputEditText to TextInputLayout due to an Android bug that create a crash
  • Add check so that when clicking on Google Auth in LoginFragment, it doesn't redirect back to AuthFragment

Related issue:
https://stackoverflow.com/questions/45898228/android-attempt-to-invoke-virtual-method-void-android-view-view-getboundsonsc

Fixes: #1923
Fixes #1920

@auto-label auto-label bot added the fix label Jun 6, 2019
@liveHarshit liveHarshit added this to the v0.4.0 milestone Jun 6, 2019
liveHarshit
liveHarshit previously approved these changes Jun 6, 2019
@liveHarshit liveHarshit dismissed their stale review June 6, 2019 09:29

Need to solve #1920 with it. As both are due to text watcher.

.actionLoginToAuthPop(redirectedFrom = safeArgs.redirectedFrom, email = s.toString()))
if (s.toString() != safeArgs.email)
findNavController(rootView).navigate(LoginFragmentDirections
.actionLoginToAuthPop(redirectedFrom = safeArgs.redirectedFrom, email = s.toString()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 if (BuildConfig.FLAVOR == PLAY_STORE_BUILD_FLAVOR) {

            smartAuthViewModel.requestCredentials(SmartAuthUtil.getCredentialsClient(requireActivity()))

            smartAuthViewModel.id
                .nonNull()
                .observe(viewLifecycleOwner, Observer {
                    email.text = SpannableStringBuilder(it)
                })

            smartAuthViewModel.password
                .nonNull()
                .observe(viewLifecycleOwner, Observer {
                    password.text = SpannableStringBuilder(it)
                })

            smartAuthViewModel.apiExceptionCodePair.nonNull().observe(viewLifecycleOwner, Observer {
                SmartAuthUtil.handleResolvableApiException(
                    it.first, requireActivity(), it.second)
            })

            smartAuthViewModel.progress
                .nonNull()
                .observe(viewLifecycleOwner, Observer {
                    progressDialog.show(it)
                })
        }

Here it fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a workaround is to move this block of code

 rootView.email.addTextChangedListener(object : TextWatcher {
            override fun afterTextChanged(s: Editable) {
 if (s.toString() != safeArgs.email)
                    findNavController(rootView).navigate(LoginFragmentDirections
                        .actionLoginToAuthPop(redirectedFrom = safeArgs.redirectedFrom, email = s.toString()))
   override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) { /*Do Nothing*/ }
            override fun onTextChanged(email: CharSequence, start: Int, before: Int, count: Int) { /*Do Nothing*/ }
        })

into here

if (safeArgs.email.isNotEmpty()) {
            rootView.email.text = SpannableStringBuilder(safeArgs.email)
        // HERE <------------------------
} else if (BuildConfig.FLAVOR == PLAY_STORE_BUILD_FLAVOR) {

            smartAuthViewModel.requestCredentials(SmartAuthUtil.getCredentialsClient(requireActivity()))

            smartAuthViewModel.id
                .nonNull()
                .observe(viewLifecycleOwner, Observer {
                    email.text = SpannableStringBuilder(it)
                    Timber.d("DEBUGGING ${email.text.toString()}")
                })

            smartAuthViewModel.password
                .nonNull()
                .observe(viewLifecycleOwner, Observer {
                    password.text = SpannableStringBuilder(it)
                })

            smartAuthViewModel.apiExceptionCodePair.nonNull().observe(viewLifecycleOwner, Observer {
                SmartAuthUtil.handleResolvableApiException(
                    it.first, requireActivity(), it.second)
            })

            smartAuthViewModel.progress
                .nonNull()
                .observe(viewLifecycleOwner, Observer {
                    progressDialog.show(it)
                })
        }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Do the changes and will test if both bugs will fix.

Copy link
Contributor Author

@anhanh11001 anhanh11001 Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a new update, can you test it as I'm still struggling to set up the environment. Somehow, my device can't save credential with ApiException from Google API for saving credential

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Details:
- Move hint from TextInputEditText to TextInputLayout due to an Android bug that create a crash
- Add check so that when clicking on Google Auth in LoginFragment, it doesn't redirect back to AuthFragment

Fixes: #1922
@liveHarshit
Copy link
Member

Both solved. One little bug is there with smart auth, will solve that later. 👍

@iamareebjamal
Copy link
Member

Writing Fixes and multiple issues on same line does not work

@iamareebjamal iamareebjamal merged commit 530fbc9 into fossasia:development Jun 6, 2019
@iamareebjamal
Copy link
Member

@anhanh11001 Your commit closed #1922

@anhanh11001 anhanh11001 deleted the 1922_login branch June 20, 2019 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App crashes on SignUpFragment when changing email text App is freezing on auth fragment
3 participants