diff --git a/CHANGELOG.md b/CHANGELOG.md index 76a6767..aa116d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Note: Breaking changes between versions are indicated by "💥". +## Unreleased + +- [Improvement] Upgrade Android app to v2.21.1 and enable many features, such as downloading videos to SD card. Thanks for the help @ejklock! +- [Bugfix] Fix Android app crash when accessing course + ## v3.12.4 (2020-05-18) - [Improvement] Add ability to rescore SCORM units diff --git a/tutor/commands/android.py b/tutor/commands/android.py index 97b4adf..2a866db 100644 --- a/tutor/commands/android.py +++ b/tutor/commands/android.py @@ -11,29 +11,15 @@ def android(): pass -@click.group(help="Build the application") -def build(): - pass - - -@click.command(help="Build the application in debug mode") +@click.command(help="Build the application") +@click.argument("mode", type=click.Choice(["debug", "release"])) @click.pass_obj -def debug(context): - docker_run(context.root) +def build(context, mode): + config = tutor_config.load(context.root) + docker_run(context.root, build_command(config, mode)) fmt.echo_info( - "The debuggable APK file is available in {}".format( - tutor_env.data_path(context.root, "android") - ) - ) - - -@click.command(help="Build the application in release mode") -@click.pass_obj -def release(context): - docker_run(context.root, "./gradlew", "assembleProdRelease") - fmt.echo_info( - "The production APK file is available in {}".format( - tutor_env.data_path(context.root, "android") + "The {} APK file is available in {}".format( + mode, tutor_env.data_path(context.root, "android") ) ) @@ -45,17 +31,31 @@ def pullimage(context): utils.execute("docker", "pull", config["DOCKER_IMAGE_ANDROID"]) -def docker_run(root, *command): +def build_command(config, target): + gradle_target = { + "debug": "assembleProdDebuggable", + "release": "assembleProdRelease", + }[target] + apk_folder = {"debug": "debuggable", "release": "release"}[target] + + command = """ +sed -i "s/APPLICATION_ID = .*/APPLICATION_ID = \\"{{ LMS_HOST|reverse_host|replace("-", "_") }}\\"/g" constants.gradle +./gradlew {gradle_target} +cp OpenEdXMobile/build/outputs/apk/prod/{apk_folder}/*.apk /openedx/data/""" + command = tutor_env.render_str(config, command) + command = command.format(gradle_target=gradle_target, apk_folder=apk_folder) + return command + + +def docker_run(root, command): config = tutor_config.load(root) utils.docker_run( "--volume={}:/openedx/config/".format(tutor_env.pathjoin(root, "android")), "--volume={}:/openedx/data/".format(tutor_env.data_path(root, "android")), config["DOCKER_IMAGE_ANDROID"], - *command + command, ) -build.add_command(debug) -build.add_command(release) android.add_command(build) android.add_command(pullimage) diff --git a/tutor/templates/android/gradle.properties b/tutor/templates/android/gradle.properties index 77f1afb..486a13a 100644 --- a/tutor/templates/android/gradle.properties +++ b/tutor/templates/android/gradle.properties @@ -1,4 +1,3 @@ -APPLICATION_ID={{ LMS_HOST|reverse_host|replace("-", "_") }} RELEASE_STORE_FILE=/openedx/config/app.keystore RELEASE_STORE_PASSWORD={{ ANDROID_RELEASE_STORE_PASSWORD }} RELEASE_KEY_PASSWORD={{ ANDROID_RELEASE_KEY_PASSWORD }} diff --git a/tutor/templates/android/tutor.yaml b/tutor/templates/android/tutor.yaml index d89848b..0f0340c 100644 --- a/tutor/templates/android/tutor.yaml +++ b/tutor/templates/android/tutor.yaml @@ -1,6 +1,18 @@ +# See docs: https://openedx.atlassian.net/wiki/spaces/LEARNER/pages/48792067/App+Configuration+Flags API_HOST_URL: '{{ "https" if ACTIVATE_HTTPS else "http" }}://{{ LMS_HOST }}' ENVIRONMENT_DISPLAY_NAME: 'tutor' PLATFORM_NAME: '{{ PLATFORM_NAME }}' PLATFORM_DESTINATION_NAME: '{{ LMS_HOST }}' FEEDBACK_EMAIL_ADDRESS: 'support@{{ LMS_HOST }}' OAUTH_CLIENT_ID: 'android' + +COURSE_VIDEOS_ENABLED: true +CERTIFICATES_ENABLED: true +DISCUSSIONS_ENABLED: true +DISCOVERY: + COURSE: + TYPE: native +DOWNLOAD_TO_SD_CARD_ENABLED: true +NEW_LOGISTRATION_ENABLED: true +USER_PROFILES_ENABLED : true +VIDEO_TRANSCRIPT_ENABLED: true \ No newline at end of file diff --git a/tutor/templates/build/android/Dockerfile b/tutor/templates/build/android/Dockerfile index 016aea4..fc77f18 100644 --- a/tutor/templates/build/android/Dockerfile +++ b/tutor/templates/build/android/Dockerfile @@ -9,22 +9,23 @@ RUN mkdir /openedx # Install Android SDK # Inspired from https://github.com/LiveXP/docker-android-sdk/blob/master/Dockerfile -ENV ANDROID_SDK_VERSION 4333796 +ENV ANDROID_SDK_VERSION 6200805 ENV ANDROID_SDK_PATH /openedx/android-sdk ENV ANDROID_HOME /openedx/android-sdk -RUN mkdir /openedx/android-sdk +RUN mkdir ${ANDROID_HOME} WORKDIR /openedx/android-sdk -RUN wget https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_VERSION}.zip && \ - unzip sdk-tools-linux-${ANDROID_SDK_VERSION}.zip && \ - rm sdk-tools-linux-${ANDROID_SDK_VERSION}.zip +RUN wget https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \ + unzip commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \ + rm commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip # Accept licenses # https://developer.android.com/studio/command-line/sdkmanager -RUN yes | /openedx/android-sdk/tools/bin/sdkmanager "platforms;android-27" 1> /dev/null +ARG ANDROID_API_LEVEL=28 +RUN yes | /openedx/android-sdk/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --install "platforms;android-$ANDROID_API_LEVEL" 1> /dev/null # Install android app repo ARG ANDROID_APP_REPOSITORY=https://github.com/edx/edx-app-android -ARG ANDROID_APP_VERSION=release/2.20.2 +ARG ANDROID_APP_VERSION=release/2.21.1 RUN git clone $ANDROID_APP_REPOSITORY --branch $ANDROID_APP_VERSION /openedx/edx-app-android WORKDIR /openedx/edx-app-android @@ -37,5 +38,4 @@ COPY ./edx.properties ./OpenEdXMobile/edx.properties RUN mkdir /openedx/config RUN ln -s /openedx/config/gradle.properties ./OpenEdXMobile/gradle.properties -CMD ./gradlew assembleProdDebuggable && \ - cp OpenEdXMobile/build/outputs/apk/prod/debuggable/*.apk /openedx/data/ +ENTRYPOINT ["sh", "-e", "-c"] \ No newline at end of file