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 #3586: Merge topic_practice_subtopic.xml into a single xml file #3835

Merged

Conversation

kritigupta45
Copy link
Contributor

@kritigupta45 kritigupta45 commented Sep 24, 2021

Explanation

Fixes #3586: merges the 4 versions of the topic_practice_subtopic.xml file into a single XML file.

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).

  • Before ss of mobile-portrait mode

  • After ss of mobile-portrait mode

  • Before ss of mobile-landscape mode

  • After ss of mobile-landscape mode

  • Before ss of tablet-portrait mode

  • After ss of tablet-portrait mode

  • Before ss of tablet-landscape mode

  • After ss of tablet-landscape mode

@kritigupta45
Copy link
Contributor Author

kritigupta45 commented Sep 24, 2021

@Arjupta PTAL. Thanks.

@rt4914 rt4914 self-assigned this Sep 24, 2021
Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

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

The before/after screenshot does look different for mobile-landscape and therefore the code should be merged such that there is no difference in before/after UI.

Also once you remove tablet related files, make sure you remove the app from tablet device and then rebuild the entire project and then run the app on emulator.

@rt4914 rt4914 removed their assignment Sep 24, 2021
@oppiabot
Copy link

oppiabot bot commented Sep 24, 2021

Hi @kritigupta45, it looks like some changes were requested on this pull request by @rt4914. PTAL. Thanks!

@kritigupta45
Copy link
Contributor Author

Apologies for the discrepancy between the before and after changes (ss) in mob-landscape mode UI.
@rt4914 PTAL. Thanks.

@oppiabot oppiabot bot assigned rt4914 and unassigned kritigupta45 Sep 25, 2021
@oppiabot
Copy link

oppiabot bot commented Sep 25, 2021

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

Copy link
Contributor

@Arjupta Arjupta left a comment

Choose a reason for hiding this comment

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

@kritigupta45 you don't have to commit the file changes that are under .idea/ directory. You can revert these files in the next commit.

@Arjupta Arjupta assigned kritigupta45 and unassigned Arjupta Sep 25, 2021
@kritigupta45 kritigupta45 removed their assignment Sep 26, 2021
Copy link
Contributor Author

@kritigupta45 kritigupta45 left a comment

Choose a reason for hiding this comment

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

@rt4914 I am facing an issue with the tablet mode where the layout_width is set to 360dp and match_parent for the mobile UI.
Unable to get a proper dimension for the dimens.xml file which should work well with both mobile and tablet mode UI.
PTAL. Thanks.

Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

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

@kritigupta45 @Arjupta PTAL Thanks.

.idea/misc.xml Outdated Show resolved Hide resolved
.idea/runConfigurations.xml Outdated Show resolved Hide resolved
@@ -13,39 +13,44 @@
type="org.oppia.android.app.topic.practice.practiceitemviewmodel.TopicPracticeSubtopicViewModel" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
<FrameLayout
Copy link
Contributor

Choose a reason for hiding this comment

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

To merge all files correctly you can use ConstraintLayout (CL) inside ConstraintLayout such that the outer CL is match_parent and inner CL width can be either 0dp or 360dp. When its 0dp it will automatically be treated as match_parent.

Copy link
Contributor

@Arjupta Arjupta Sep 27, 2021

Choose a reason for hiding this comment

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

Nice Idea. But doesn't this looks like a patch work. I didn't knew that Android doesn't support match_parent as parameter in viewbinding. I thought just like while handling with importantForAccessibilty stuff we got to change it with the help of few dimens constants, that actually corresponded to the values of enums.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can use databinding too and it might be clear, I am just doubtful about the UI rendering performance. Can you check if this works without any UI glitch?

How is it related to accessibility?

Copy link
Contributor

@Arjupta Arjupta Sep 27, 2021

Choose a reason for hiding this comment

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

I have tried that databinding solution but no luck. Also the accessiblity issue I am talking about is implemented here also importantForAccessiblity. Normally the importantForAccessiblity will take yes or no as a parameter. But we know that there enums values corresponds to true and false hence we used that logic here. I was aksing can something similar be done

Copy link
Contributor

Choose a reason for hiding this comment

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

@Arjupta We cannot use databinding because for doing that we need some condition based on which we can identify if we want to keep match_parent or 360dp width. And here we don't have any such condition. Therefore using CL inside CL is the easiest working solution here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have tried the nested ConstraintLayout solution and it is working correctly. Below is the sample code.
Note that you will need to introduce the correct values for width, margin_start and margin_end dimens in all 4 dimens files and also make sure that the names are also correct.

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.constraintlayout.widget.ConstraintLayout
      android:layout_width="@dimen/width"
      android:layout_height="wrap_content"
      android:layout_marginStart="@dimen/margin_start"
      android:layout_marginEnd="@dimen/margin_end"
      app:barrierDirection="end"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent">

      <androidx.constraintlayout.widget.Barrier

Copy link
Contributor

Choose a reason for hiding this comment

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

@Arjupta We cannot use databinding because for doing that we need some condition based on which we can identify if we want to keep match_parent or 360dp width. And here we don't have any such condition. Therefore using CL inside CL is the easiest working solution here.

@rt4914 I agree with your findings and hence @kritigupta45 can go with making a CL under a Cl for this PR. Although I would like to know that, if we assume there is an observable boolean in the viewmodel which changes its value based on the device orientation (true for portrait & false for landscape). So can we use this boolean to change the constraint between match_parent and some other value (defined in dimens.xml). And if the answer is Yes, then please do share a code snippet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Arjupta Yes we can do that but that would make code more complex as compared to what we have done right now.

app/src/main/res/values/dimens.xml Outdated Show resolved Hide resolved
@rt4914 rt4914 assigned Arjupta and kritigupta45 and unassigned rt4914 Sep 27, 2021
@Arjupta Arjupta assigned rt4914 and unassigned Arjupta Sep 27, 2021
@kritigupta45 kritigupta45 removed their assignment Sep 27, 2021
@rt4914 rt4914 assigned Arjupta and kritigupta45 and unassigned rt4914 Sep 30, 2021
@kritigupta45 kritigupta45 removed their assignment Oct 1, 2021
Copy link
Contributor

@Arjupta Arjupta left a comment

Choose a reason for hiding this comment

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

The changes I suggested are done hence LGTM. @rt4914 PTAL

@Arjupta Arjupta assigned rt4914 and unassigned Arjupta Oct 2, 2021
@oppiabot
Copy link

oppiabot bot commented Oct 2, 2021

Assigning @BenHenning for code owner reviews. Thanks!

Copy link
Contributor

@rt4914 rt4914 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@rt4914 rt4914 merged commit 4171e0d into oppia:develop Oct 3, 2021
@kritigupta45 kritigupta45 deleted the merge-topic-practice-subtopic-xml branch November 11, 2021 12:41
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.

Merge topic_practice_subtopic.xml into single xml file
4 participants