Skip to content

Commit

Permalink
Merge branch 'develop' into input-keyboard-issues
Browse files Browse the repository at this point in the history
  • Loading branch information
theayushyadav11 authored Feb 26, 2025
2 parents 6e41f23 + 469fe9c commit 2816cf4
Show file tree
Hide file tree
Showing 77 changed files with 1,160 additions and 963 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ build:ignore_build_warnings --//tools/kotlin:warn_mode=warning

# Show all test output by default (for better debugging).
test --test_output=all

# Always start the app by default when using mobile-install.
mobile-install --start_app
3 changes: 0 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ WORKSPACE @oppia/android-app-infrastructure-reviewers
# Proguard configurations for Bazel builds.
/config/proguard/ @oppia/android-dev-workflow-reviewers

# Configuration for KitKat-specific curated builds.
/config/kitkat_main_dex_class_list.txt @oppia/android-dev-workflow-reviewers

# Specific manifest files specifically required for Bazel builds.
/app/src/main/AppAndroidManifest.xml @oppia/android-dev-workflow-reviewers
/app/src/main/DatabindingAdaptersManifest.xml @oppia/android-dev-workflow-reviewers
Expand Down
349 changes: 8 additions & 341 deletions .github/workflows/build_tests.yml

Large diffs are not rendered by default.

79 changes: 3 additions & 76 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ jobs:
max-parallel: 10
matrix: ${{ fromJson(needs.bazel_compute_affected_targets.outputs.matrix) }}
env:
ENABLE_CACHING: false
CACHE_DIRECTORY: ~/.bazel_cache
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -206,57 +205,7 @@ jobs:
echo "build --disk_cache=$EXPANDED_BAZEL_CACHE_PATH" >> $HOME/.bazelrc
shell: bash

# See explanation in bazel_build_app for how this is installed.
- name: Install git-secret (non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
shell: bash
run: |
cd $HOME
mkdir -p $HOME/gitsecret
git clone https://github.com/sobolevn/git-secret.git git-secret
cd git-secret && make build
PREFIX="$HOME/gitsecret" make install
echo "$HOME/gitsecret" >> $GITHUB_PATH
echo "$HOME/gitsecret/bin" >> $GITHUB_PATH
- name: Decrypt secrets (non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
env:
GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }}
run: |
cd $HOME
# NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout!
echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg
gpg --import ./git_secret_private_key.gpg
cd $GITHUB_WORKSPACE
git secret reveal
# See https://www.cyberciti.biz/faq/unix-for-loop-1-to-10/ for for-loop reference.
- name: Build Oppia Tests (with caching, non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
env:
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
# Attempt to build 5 times in case there are flaky builds.
# TODO(#3759): Remove this once there are no longer app test build failures.
i=0
# Disable exit-on-first-failure.
set +e
while [ $i -ne 5 ]; do
i=$(( $i+1 ))
echo "Attempt $i/5 to build test targets"
bazel build --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS
done
# Capture the error code of the final command run (which should be a success if there isn't a real build failure).
last_error_code=$?
# Reenable exit-on-first-failure.
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)
- name: Build Oppia Tests (without caching, or on a fork)
if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }}
- name: Build Oppia Tests
env:
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
Expand All @@ -276,30 +225,8 @@ jobs:
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)
- name: Run Oppia Tests (with caching, non-fork only)
if: ${{ env.ENABLE_CACHING == 'true' && ((github.ref == 'refs/heads/develop' && github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == 'oppia/oppia-android')) }}
env:
BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }}
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
# Attempt to build 5 times in case there are flaky builds.
# TODO(#3970): Remove this once there are no longer app test build failures.
i=0
# Disable exit-on-first-failure.
set +e
while [ $i -ne 5 ]; do
i=$(( $i+1 ))
echo "Attempt $i/5 to run test targets"
bazel test --keep_going --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- $BAZEL_TEST_TARGETS
done
# Capture the error code of the final command run (which should be a success if there isn't a real build failure).
last_error_code=$?
# Reenable exit-on-first-failure.
set -e
# Exit only if the most recent exit was a failure (by using a subshell).
(exit $last_error_code)
- name: Run Oppia Tests (without caching, or on a fork)
if: ${{ env.ENABLE_CACHING == 'false' || ((github.ref != 'refs/heads/develop' || github.event_name != 'push') && (github.event.pull_request.head.repo.full_name != 'oppia/oppia-android')) }}
- name: Run Oppia Tests
env:
BAZEL_TEST_TARGETS: ${{ env.BAZEL_TEST_TARGETS }}
run: |
Expand Down
69 changes: 4 additions & 65 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# TODO(#1532): Rename file to 'BUILD' post-Gradle.

load("@dagger//:workspace_defs.bzl", "dagger_rules")
load("//:build_flavors.bzl", "AVAILABLE_FLAVORS", "define_oppia_aab_binary_flavor", "transform_android_manifest")
load("//:version.bzl", "MAJOR_VERSION", "MINOR_VERSION", "OPPIA_DEV_KITKAT_VERSION_CODE", "OPPIA_DEV_VERSION_CODE")

# This is exported here since config/ isn't a Bazel package.
exports_files(["config/kitkat_main_dex_class_list.txt"])
load("//:build_flavors.bzl", "AVAILABLE_FLAVORS", "define_oppia_aab_binary_flavor")

# Corresponds to being accessible to all Oppia targets. This should be used for production APIs &
# modules that may be used both in production targets and in tests.
Expand Down Expand Up @@ -73,67 +69,10 @@ package_group(
)

# TODO(#1640): Move binary manifest to top-level package post-Gradle.
[
transform_android_manifest(
name = "oppia_apk_%s_transformed_manifest" % apk_flavor_metadata["flavor"],
application_relative_qualified_class = ".app.application.dev.DeveloperOppiaApplication",
build_flavor = apk_flavor_metadata["flavor"],
input_file = "//app:src/main/AndroidManifest.xml",
major_version = MAJOR_VERSION,
minor_version = MINOR_VERSION,
output_file = "AndroidManifest_transformed_%s.xml" % apk_flavor_metadata["flavor"],
version_code = apk_flavor_metadata["version_code"],
)
for apk_flavor_metadata in [
{
"flavor": "oppia",
"version_code": OPPIA_DEV_VERSION_CODE,
},
{
"flavor": "oppia_kitkat",
"version_code": OPPIA_DEV_KITKAT_VERSION_CODE,
},
]
]

[
android_binary(
name = apk_flavor_metadata["flavor"],
custom_package = "org.oppia.android",
enable_data_binding = True,
main_dex_list = apk_flavor_metadata.get("main_dex_list"),
manifest = "oppia_apk_%s_transformed_manifest" % apk_flavor_metadata["flavor"],
manifest_values = {
"applicationId": "org.oppia.android",
"minSdkVersion": "%d" % apk_flavor_metadata["min_sdk_version"],
"targetSdkVersion": "%d" % apk_flavor_metadata["target_sdk_version"],
},
multidex = apk_flavor_metadata["multidex"],
deps = [
"//app/src/main/java/org/oppia/android/app/application/dev:developer_application",
"//config/src/java/org/oppia/android/config:all_languages_config",
],
)
for apk_flavor_metadata in [
{
"flavor": "oppia",
"min_sdk_version": 21,
"multidex": "native",
"target_sdk_version": 34,
},
{
"flavor": "oppia_kitkat",
"main_dex_list": "//:config/kitkat_main_dex_class_list.txt",
"min_sdk_version": 21,
"multidex": "manual_main_dex",
"target_sdk_version": 34,
},
]
]

# Define all binary flavors that can be built. Note that these are AABs, not APKs, and can be
# be installed on a local device or emulator using a 'bazel run' command like so:
# bazel run //:install_oppia_dev
# Define all binary flavors that can be built. Note that these are AABs and thus cannot be installed
# directly. However, their binaries can be installed using mobile-install like so:
# bazel mobile-install //:oppia_dev_binary
[
define_oppia_aab_binary_flavor(flavor = flavor)
for flavor in AVAILABLE_FLAVORS
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AppAndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.ui">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.databinding.adapters">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingResourcesManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.databinding">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/RecyclerviewAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.recyclerview.adapters">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!-- TODO(#1632): Remove manifest post-Gradle -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.vm">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!-- TODO(#1632): Remove manifest post-Gradle -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.view.models">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<!-- TODO(#1632): Remove manifest post-Gradle -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.views">
<uses-sdk android:minSdkVersion="19"
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="34" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.app.Application
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.multidex.MultiDexApplication
import androidx.work.Configuration
import androidx.work.WorkManager
Expand Down Expand Up @@ -39,14 +38,6 @@ abstract class AbstractOppiaApplication(
@SuppressLint("ObsoleteSdkInt") // Incorrect warning.
override fun onCreate() {
super.onCreate()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// Ensure vector drawables can be properly loaded on KitKat devices. Note that this can
// introduce memory issues, but it's an easier-to-maintain solution that replacing all image
// binding with custom hook-ins (especially when it comes to databinding which isn't
// configurable in how it loads drawables), or building a custom vector drawable->PNG pipeline
// in Bazel.
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
}
// The current WorkManager version doesn't work in SDK 31+, so disable it.
// TODO(#4751): Re-enable WorkManager for S+.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void setProfileLastVisitedText(@NonNull TextView textView, long ti
}

// TODO(#4345): Add test for this method.
/** Binds an AndroidX KitKat-compatible drawable top to the specified text view. */
/** Binds an AndroidX drawable top to the specified text view. */
@BindingAdapter("drawableTopCompat")
public static void setDrawableTopCompat(
@NonNull TextView imageView,
Expand All @@ -56,7 +56,7 @@ public static void setDrawableTopCompat(
);
}

/** Binds an AndroidX KitKat-compatible drawable end to the specified text view. */
/** Binds an AndroidX drawable end to the specified text view. */
@BindingAdapter("drawableEndCompat")
public static void setDrawableEndCompat(
@NonNull TextView imageView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.fragment.app.FragmentManager
import org.oppia.android.app.model.ImageWithRegions
import org.oppia.android.app.model.UserAnswerState
import org.oppia.android.app.shim.ViewBindingShim
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.utility.ClickableAreasImage
import org.oppia.android.app.utility.OnClickableAreaClickedListener
import org.oppia.android.app.view.ViewComponentFactory
Expand Down Expand Up @@ -46,6 +47,7 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
@Inject lateinit var machineLocale: OppiaLocale.MachineLocale
@Inject lateinit var accessibilityService: AccessibilityService
@Inject lateinit var imageLoader: ImageLoader
@Inject lateinit var resourceHandler: AppLanguageResourceHandler

private lateinit var entityId: String
private lateinit var overlayView: FrameLayout
Expand All @@ -64,8 +66,8 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
maybeInitializeClickableAreas()
}

fun setUserAnswerState(userAnswerrState: UserAnswerState) {
this.userAnswerState = userAnswerrState
fun setUserAnswerState(userAnswerState: UserAnswerState) {
this.userAnswerState = userAnswerState
}

fun setEntityId(entityId: String) {
Expand Down Expand Up @@ -118,7 +120,8 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
::entityId.isInitialized &&
::imageUrl.isInitialized &&
::onRegionClicked.isInitialized &&
::overlayView.isInitialized
::overlayView.isInitialized &&
::resourceHandler.isInitialized
) {
loadImage()

Expand All @@ -129,7 +132,8 @@ class ImageRegionSelectionInteractionView @JvmOverloads constructor(
bindingInterface,
isAccessibilityEnabled = accessibilityService.isScreenReaderEnabled(),
clickableAreas,
userAnswerState
userAnswerState,
resourceHandler
)
areasImage.addRegionViews()
performAttachment(areasImage)
Expand Down
Loading

0 comments on commit 2816cf4

Please sign in to comment.