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 #4446: Add placeholders for text based interactions #4503

Closed
wants to merge 4 commits into from

Conversation

JishnuGoyal
Copy link
Contributor

@JishnuGoyal JishnuGoyal commented Aug 16, 2022

Explanation

Additional note: At the time of PR creation it was observed that the placeholder texts are displayed everywhere and match with the ones on the website.

This PR fixes #4446 by adding a function that folds the placeholders texts (while also making sure that the lines are folded at a word break). These placeholder texts are "TextView hints" -- which can't fold the hint text as an out of the box feature in android.

In the function created called "foldPlaceholderText", there is an adjustable variable called numberOfLettersInOneLine. On tweaking this, the function can handle changing lines after the adjusted number of letters, or after few more letters depending on where is the immediate next word break.

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

For UI-specific PRs only

If your PR includes UI-related changes, then:

  • Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes
  • For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see RTL guide)
  • Add a video showing the full UX flow with a screen reader enabled (see accessibility guide)
  • Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing

Before:
Portrait
Screenshot from 2022-08-17 23-03-44

Landscape
Screenshot from 2022-08-17 23-02-29

After:
Portrait
Screenshot from 2022-08-17 00-20-37

Landscape
Screenshot from 2022-08-17 23-00-40

@JishnuGoyal JishnuGoyal marked this pull request as ready for review August 16, 2022 17:57
@JishnuGoyal
Copy link
Contributor Author

@BenHenning PTAL

@@ -179,6 +179,42 @@ class MathExpressionInteractionsViewModel private constructor(
}
}

private fun foldPlaceholderText(placeholder: CharSequence): String {
val numberOfLettersInOneLine = 50
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this depend on display properties, such as text scaling, display density, and portrait/landscape orientation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. My updated solution handles all this.

@BenHenning
Copy link
Member

@JishnuGoyal I'm wondering this is solving an unrelated issue. Wasn't the original issue leading to #4446 that the placeholders were not showing up for some lessons?

@BenHenning BenHenning assigned JishnuGoyal and unassigned BenHenning Aug 16, 2022
@JishnuGoyal JishnuGoyal requested a review from rt4914 as a code owner August 17, 2022 17:37
@JishnuGoyal
Copy link
Contributor Author

@BenHenning PTAL

@oppiabot oppiabot bot assigned BenHenning and unassigned JishnuGoyal Aug 17, 2022
@oppiabot
Copy link

oppiabot bot commented Aug 17, 2022

Unassigning @JishnuGoyal since a re-review was requested. @JishnuGoyal, please make sure you have addressed all review comments. Thanks!

@@ -24,7 +24,7 @@
android:id="@+id/math_expression_input_interaction_view"
style="@style/InputInteractionEditText"
app:placeholder="@{viewModel.hintText}"
android:inputType="text"
android:inputType="textMultiLine"
Copy link
Member

Choose a reason for hiding this comment

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

So I think the new issue is that this results in the default ime action in the keyboard now being to insert a line rather than submitting an answer, which I think is problematic. I'll look into what EditText does in textMultiLine mode to see if we can somehow get it to support multi-line hints without actually being a multi-line box.

@BenHenning
Copy link
Member

I believe this is obsolete now that #4506 was merged.

@BenHenning BenHenning closed this Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add placeholders for text based interactions
2 participants