From 7272dc7e88f6c0c2ea737a7c23659e1f66acff08 Mon Sep 17 00:00:00 2001 From: Vishwajith Shettigar <76042077+Vishwajith-Shettigar@users.noreply.github.com> Date: Tue, 31 Oct 2023 21:26:20 +0530 Subject: [PATCH 1/3] Fix #5032 Images in Arabic (RTL) lessons are right-aligned rather than center-aligned. (#5212) ## Explanation Fixes #5032, To make the image center-aligned, we are adding styling to the HTML content image and removing the left margin by setting drawableLeft bound to 0 in RTL. ## Essential Checklist - [x] 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](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only ### Before LTR Potrait ![beforeLTRpotrait](https://github.com/oppia/oppia-android/assets/76042077/298fc2c0-7512-40dc-8d56-444fe55f4998) LTR Landscape ![LTRlandscape](https://github.com/oppia/oppia-android/assets/76042077/94e16ccb-052c-4723-b26e-00fa0591270d) RTL Potrait ![beforeRTLpotrait](https://github.com/oppia/oppia-android/assets/76042077/59efc1c5-c695-442a-9549-8aa353d61aed) RTL Landscape ![RTLlandscape](https://github.com/oppia/oppia-android/assets/76042077/dae3c7b8-ce4e-4968-8dea-c4bc23eaf75f) ### After RTL Potrait ![Potrait_after](https://github.com/oppia/oppia-android/assets/76042077/d5115f63-f71c-44fa-bb60-639e8f8abcef) RTL Landscape ![landscapeafter](https://github.com/oppia/oppia-android/assets/76042077/9a37d6d1-dc80-489e-827c-8b208fa33d67) LTR Potrait ![LTRpotraitafter](https://github.com/oppia/oppia-android/assets/76042077/4d51cf7c-68eb-4924-aaaa-64cb44391081) LTR Landscape ![LTRLandscape](https://github.com/oppia/oppia-android/assets/76042077/802dcd37-5adb-4f5d-8a30-cfa110d76885) 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](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing --- .../org/oppia/android/util/parser/html/HtmlParser.kt | 12 +++++++++++- .../android/util/parser/image/UrlImageParser.kt | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt b/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt index ca7b8c0b661..cb37742ff19 100755 --- a/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt +++ b/utility/src/main/java/org/oppia/android/util/parser/html/HtmlParser.kt @@ -75,16 +75,26 @@ class HtmlParser private constructor( supportsLinks: Boolean = false, supportsConceptCards: Boolean = false ): Spannable { + + var htmlContent = rawString + // Canvas does not support RTL, it always starts from left to right in RTL due to which compound drawables are // not center aligned. To avoid this situation check if RTL is enabled and set the textDirection. if (isRtl) { htmlContentTextView.textDirection = View.TEXT_DIRECTION_RTL + + val regex = Regex("""]*>.*?""") + val modifiedHtmlContent = rawString.replace(regex) { + val oppiaImageTag = it.value + """
$oppiaImageTag
""" + } + htmlContent = modifiedHtmlContent } else { htmlContentTextView.textDirection = View.TEXT_DIRECTION_LTR } + htmlContentTextView.invalidate() - var htmlContent = rawString if ("\n\t" in htmlContent) { htmlContent = htmlContent.replace("\n\t", "") } diff --git a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt index b8dd69868a8..b18934a1897 100644 --- a/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt +++ b/utility/src/main/java/org/oppia/android/util/parser/image/UrlImageParser.kt @@ -15,6 +15,7 @@ import android.view.View import android.view.ViewGroup import android.view.ViewTreeObserver import android.widget.TextView +import androidx.core.view.ViewCompat import com.bumptech.glide.request.target.CustomTarget import com.bumptech.glide.request.transition.Transition import org.oppia.android.util.R @@ -234,6 +235,11 @@ class UrlImageParser private constructor( private val autoResizeImage: Boolean ) : AutoAdjustingImageTarget(targetConfiguration) { + private fun isRTLMode(): Boolean { + return ViewCompat.getLayoutDirection(htmlContentTextView) == ViewCompat + .LAYOUT_DIRECTION_RTL + } + override fun computeBounds( context: Context, drawable: D, @@ -304,11 +310,13 @@ class UrlImageParser private constructor( drawableWidth *= multipleFactor } } - val drawableLeft = if (imageCenterAlign) { + + val drawableLeft = if (imageCenterAlign && !isRTLMode()) { calculateInitialMargin(maxAvailableWidth, drawableWidth) } else { 0f } + val drawableTop = 0f val drawableRight = drawableLeft + drawableWidth val drawableBottom = drawableTop + drawableHeight From f496e0e8046066e1b395a5c3bbf8c8901a0406d4 Mon Sep 17 00:00:00 2001 From: Kenneth Murerwa Date: Tue, 31 Oct 2023 20:13:47 +0300 Subject: [PATCH 2/3] fix: Fix Translate Wiki Issues with Splash Activity Screen Strings (#5219) ## Explanation When merged, this PR will: - Remove white spaces and new lines that were added to Splash Activity Screen strings by the [App/OS Deprecation Milestone 3 PR](https://github.com/oppia/oppia-android/pull/5096). This will allow TranslateWiki to translate them. See related [comment on the PR](https://github.com/oppia/oppia-android/commit/d471d79e7bcce6de8351cf045458af23711fcdb2#r130759117). ## Essential Checklist - [x] 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: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## 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](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> --- app/src/main/res/values/strings.xml | 56 ++++++++--------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 97547bc1638..9b924f81a97 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -472,48 +472,20 @@ completed_story_list_recyclerview_tag Please select all correct choices. - - Unsupported app version - - - This version of the app is no longer supported. Please update it through the Play Store. - - - Close app - - - App update required - - - A new version of %s is now available. The new version is more secure, and improves your learning experience.\n\nThis version is no longer supported. To continue using the app, please update to the latest version. - - - Update - - - Close app - - - New update available - - - A new version of %s is now available. We recommend that you update the app for bug fixes and a better learning experience. - - - Dismiss - - - Update - - - Update your Android OS - - - We recommend updating your Android OS to take advantage of %s\'s new features and lessons.\n\nVisit your phone\'s Settings app to update your OS. - - - Dismiss - + Unsupported app version + This version of the app is no longer supported. Please update it through the Play Store. + Close app + App update required + A new version of %s is now available. The new version is more secure, and improves your learning experience.\n\nThis version is no longer supported. To continue using the app, please update to the latest version. + Update + Close app + New update available + A new version of %s is now available. We recommend that you update the app for bug fixes and a better learning experience. + Dismiss + Update + Update your Android OS + We recommend updating your Android OS to take advantage of %s\'s new features and lessons.\n\nVisit your phone\'s Settings app to update your OS. + Dismiss Developer Build Alpha Beta From 094d4a344a54a50413a506f99613787195d29c8d Mon Sep 17 00:00:00 2001 From: MOHIT GUPTA <76530270+MohitGupta121@users.noreply.github.com> Date: Wed, 1 Nov 2023 00:54:51 +0530 Subject: [PATCH 3/3] Fix #5214, Fix Part of #1723 : Fix onboarding issue faced by new contributors (#5210) ## Explanation Fix #5214 : Wiki link not redirect to correct destination ( good-first-issue link) Fix Part of #1723 : Fix onboarding issue faced by new contributors. 1. Tell contributors firmly to use "Android Studio Bumblebee | 2021.1.1 Patch 3." 2. In the wiki, make sure to mention that you need to have JDK 11 to use oppia-android. 3. Concentrate on using robolectric instead of espresso and provide clear instructions for setting up tests. ## Essential Checklist - [x] 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](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). --- wiki/Installing-Oppia-Android.md | 62 ++++++++++++++++++++++++-------- wiki/Oppia-Android-Testing.md | 27 ++++++++------ 2 files changed, 63 insertions(+), 26 deletions(-) diff --git a/wiki/Installing-Oppia-Android.md b/wiki/Installing-Oppia-Android.md index 309a9f3b274..8e37749c5f6 100644 --- a/wiki/Installing-Oppia-Android.md +++ b/wiki/Installing-Oppia-Android.md @@ -8,13 +8,15 @@ This wiki page explains how to install Oppia Android on your local machine. If y - [Install oppia-android](#install-oppia-android) - [Run the app from Android Studio](#run-the-app-from-android-studio) - [Run the tests](#set-up-and-run-tests) + - [Step-by-Step guidance for setting up and running app modules robolectric test](#step-by-step-guidance-for-setting-up-and-running-app-modules-robolectric-test) + - [For tests that are in non-app modules, such as **domain** or **utility**:](#for-tests-that-are-in-non-app-modules-such-as-domain-or-utility) ## Prepare developer environment -1. Download/Install [Android Studio](https://developer.android.com/studio/?gclid=EAIaIQobChMI8fX3n5Lb6AIVmH8rCh24JQsxEAAYASAAEgL4L_D_BwE&gclsrc=aw.ds#downloads). +1. Download/Install [Android Studio Bumblebee | Patch 3](https://developer.android.com/studio/archive). - **Note**: We recommend installing **Android Studio Bumblebee** because newer versions of Android Studio[ do not support running tests where shared source sets are used](https://issuetracker.google.com/issues/232007221#comment18), a configuration we use at Oppia. + **Note**: We recommend installing **Android Studio Bumblebee | 2021.1.1 Patch 3** because newer versions of Android Studio[ do not support running tests where shared source sets are used](https://issuetracker.google.com/issues/232007221#comment18), a configuration we use at Oppia. **Direct download Url**: [Windows](https://redirector.gvt1.com/edgedl/android/studio/install/2021.1.1.23/android-studio-2021.1.1.23-windows.exe) | [Linux](https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2021.1.1.23/android-studio-2021.1.1.23-linux.tar.gz) | [Intel Mac](https://redirector.gvt1.com/edgedl/android/studio/install/2021.1.1.23/android-studio-2021.1.1.23-mac.dmg) | [Apple Silicon Mac](https://redirector.gvt1.com/edgedl/android/studio/install/2021.1.1.23/android-studio-2021.1.1.23-mac_arm.dmg) @@ -22,10 +24,13 @@ This wiki page explains how to install Oppia Android on your local machine. If y 2. Configure your Android Studio - In Android Studio, open Tools > SDK Manager. - - In the "SDK Platforms" tab (which is the default), select `API Level 28` and also `API Level 31` (for Bazel support). + - In the "SDK Platforms" tab (which is the default), select `API Level 28` and also `API Level 30` (for Bazel support). - Also, navigate to the "SDK Tools" tab, click the "Show Package Details" checkbox at the bottom right, then click on "Android SDK Build-Tools 34-rc1" and select 29.0.2 (this is needed for Bazel support). - Then, click "Apply" to download and install these two SDKs/Tools. + + - Must have **JDK 11** selected: + - In Android Studio, open Settings > Build, Execution, Deployment > Build Tools > Gradle and edit the Gradle JDK field. ## Install oppia-android @@ -81,38 +86,65 @@ Please follow these steps to set up Oppia Android on your local machine. ## Set up and run tests Testing the app is an integral part of our development process. You will need to test all code changes to ensure that the app works correctly, therefore it is important to ensure that your test configuration works. -We run tests in either Espresso(`app` module tests) or Robolectric(non-app module tests), meaning tests will run in either the emulator or on Gradle/Bazel via the terminal. +We strongly recommend running tests on Robolectric which is faster because it does not require a physical device or emulator setup. + +### Configure Robolectric Tests + +#### Step-by-Step guidance for setting up and running app modules robolectric test: + +1. Go to **Edit Configuration** in Android Studio (Bumblebee | 2021.1.1 Patch 3) + ![](https://user-images.githubusercontent.com/9396084/79109714-83525980-7d96-11ea-99d7-f83ea81a8a50.png) + +2. Click on Add(+) -> **JUnit** + ![](https://github.com/oppia/oppia-android/assets/76530270/87caf3fc-37d9-472d-92fd-b8ec49fb6b49) + +3. Enter following information: + - a) Name of test. Example: In my case "SplashActivityTest" + - b) Make sure select "java 11" and oppia-android.app + - c) Class path of Test class. Example: In my case "org.oppia.android.app.splash. + SplashActivityTest" + - d) Press `OK` to select the test. + ![](https://github.com/oppia/oppia-android/assets/76530270/5901624a-df76-4b27-8f31-6077a68fcb89) + +4. Click on "Run" button to run robolectric test. (In my case "SplashActivityTest") + ![](https://github.com/oppia/oppia-android/assets/76530270/75a6b998-90c5-4f0a-8886-78f96970be90) + +#### For tests that are in non-app modules, such as **domain** or **utility**:: + +1. In Android Studio, open the desired test file, e.g., `AnalyticsControllerTest`. +2. In the test file, to the left of the class name, click on the orange and green arrow, and select **Run 'AnalyticsControllerTest'**. + - You will notice that the emulator is greyed out, but the run window will open to show the running tests: + ![](https://user-images.githubusercontent.com/59600948/272657015-158117e5-47d2-40fc-a38b-5dee6c347556.png) ### Configure Emulator Tests + +**Espresso is slower for running tests, so we recommend using Robolectric.** + 1. In Android Studio, open the desired test file, e.g., `HomeActivityTest`. 2. In the Android Studio toolbar, click on the `Available Devices` option. Select an emulator that has between API 28-30. **Note**: If you don't have any available devices in this list, please follow [these instructions](#run-the-app-from-android-studio) to create one. + 3. In the test file, to the left of the class name, click on the orange and green arrow, and select **Run 'HomeActivityTest'**. -![](https://user-images.githubusercontent.com/59600948/272657131-96e5354b-13a9-4709-969a-b9494a65c30f.png) + ![](https://user-images.githubusercontent.com/59600948/272657131-96e5354b-13a9-4709-969a-b9494a65c30f.png) + 4. An "**Edit Configuration**" dialog will show up, and you should add the following settings under the general tab: - For module, select **oppia-android.app** - For Test, select **Class** - For Instrumentation class, **org.oppia.android.testing.OppiaTestRunner**, will be selected by default. - For target, select the **Use the device/snapshot dropdown** option. - Verify that your setup looks like below: - -![](https://user-images.githubusercontent.com/59600948/272657260-2e654891-61be-467a-8ebd-c997aa2abda6.png) + + ![](https://user-images.githubusercontent.com/59600948/272657260-2e654891-61be-467a-8ebd-c997aa2abda6.png) - Finally, Click the "Apply" and "Okay" buttons. - You may need to repeat step (3) above to run the test with the new configuration. - Subsequent runs of any app module tests will not require editing the configuration. - This configuration will run all the tests in that class. 5. To run only a specific test in a file: - Search or scroll down to the desired test name, to the left of the test name, click on the run icon and select **Run '`test name`''**. - -### Configure Robolectric Tests -These are tests that are in non-app modules, such as **domain** or **utility**. -1. In Android Studio, open the desired test file, e.g., `AnalyticsControllerTest`. -2. In the test file, to the left of the class name, click on the orange and green arrow, and select **Run 'AnalyticsControllerTest'**. - - You will notice that the emulator is greyed out, but the run window will open to show the running tests: - - ![](https://user-images.githubusercontent.com/59600948/272657015-158117e5-47d2-40fc-a38b-5dee6c347556.png) - + ### Next Steps -- Congratulations, you are ready to work on your first issue! Take a look at our [good first issues](https://github.com/oppia/oppia-android/wiki/Oppia-Android-Testing) and leave a comment with your suggested fix. A maintainer will assign you the issue and provide any necessary guidance. +- Congratulations, you are ready to work on your first issue! Take a look at our [good first issues](https://github.com/oppia/oppia-android/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+no%3Aassignee) and leave a comment with your suggested fix. A maintainer will assign you the issue and provide any necessary guidance. - When you are ready to submit a PR, please follow [these instructions](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR) on submitting a PR. diff --git a/wiki/Oppia-Android-Testing.md b/wiki/Oppia-Android-Testing.md index de1519730a7..757d83975bf 100644 --- a/wiki/Oppia-Android-Testing.md +++ b/wiki/Oppia-Android-Testing.md @@ -112,17 +112,22 @@ public class MyActivityTest { ``` ### Running Robolectric tests -1. Go to **Edit Configuration** in Android Studio -Screenshot 2020-04-13 at 2 51 02 PM - -2. Add **Android JUnit** -Screenshot 2020-04-13 at 2 51 31 PM - -3. Enter following information - (a.) **Name** (Normally class name) (b.)**Use classpath of module** (c.) **Class** -Screenshot 2020-04-13 at 3 18 39 PM - - -4. Press `OK` to run the test cases in robolectric. +1. Go to **Edit Configuration** in Android Studio (Bumblebee | 2021.1.1 Patch 3) + ![](https://user-images.githubusercontent.com/9396084/79109714-83525980-7d96-11ea-99d7-f83ea81a8a50.png) + +2. Click on Add(+) -> **JUnit** + ![](https://github.com/oppia/oppia-android/assets/76530270/87caf3fc-37d9-472d-92fd-b8ec49fb6b49) + +3. Enter following information: + - a) Name of test. Example: In my case "SplashActivityTest" + - b) Make sure select "java 11" and oppia-android.app [**Note:** For "app module test" select `oppia-android.app` similarly for "utility tests" select `oppia-android.utility`, for "domain test" select `oppia-android.domain`, for "model test" select `oppia-android.model`, for "testing" select `oppia-android.testing`] + - c) Class path of Test class. Example: In my case "org.oppia.android.app.splash. + SplashActivityTest" + - d) Press `OK` to select the test. + ![](https://github.com/oppia/oppia-android/assets/76530270/5901624a-df76-4b27-8f31-6077a68fcb89) + +4. Click on "Run" button to run robolectric test. (In my case "SplashActivityTest") + ![](https://github.com/oppia/oppia-android/assets/76530270/75a6b998-90c5-4f0a-8886-78f96970be90) ## Espresso