Fix and upgrade Android app to v2.21.1

Also, we introduce tons of cool features, including downloading videos
to SD card.
This commit is contained in:
Régis Behmo 2020-05-12 11:58:08 +02:00
parent 8b8e27a781
commit a92ff42348
5 changed files with 51 additions and 35 deletions

View File

@ -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

View File

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

View File

@ -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 }}

View File

@ -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

View File

@ -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"]