diff --git a/docs/index.rst b/docs/index.rst index a601c93..2c67344 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -55,6 +55,7 @@ But there's a lot more to Tutor than that! For more advanced usage, please refer dev k8s webui + mobile troubleshooting tutor faq diff --git a/docs/mobile.rst b/docs/mobile.rst new file mode 100644 index 0000000..3a56a44 --- /dev/null +++ b/docs/mobile.rst @@ -0,0 +1,34 @@ +.. _mobile: + +Mobile Android application +========================== + +With Tutor, you can build an Android mobile application for your platform. First, generate the required environment:: + + tutor android env + +Then, build the app in debug mode:: + + tutor android build debug + +The ``.apk`` file will then be available in ``$TUTOR_ROOT/data/android``. Transfer it to an Android phone to install the application. You should be able to sign in and view available courses. + +Releasing an Android app +------------------------ + +**Note**: this is an untested feature. + +Releasing an Android app on the Play Store requires to build the app in release mode. To do so, edit the ``$TUTOR_ROOT/config.yml`` configuration file and define the following variables:: + + ANDROID_RELEASE_STORE_PASSWORD + ANDROID_RELEASE_KEY_PASSWORD + ANDROID_RELEASE_KEY_ALIAS + +Then, place your keystore file in ``$TUTOR_ROOT/env/android/app.keystore``. Finally, build the application with:: + + tutor android build release + +Customising the Android app +--------------------------- + +Customising the application, such as the logo or the background image, is currently not supported. If you are interested by this feature, please tell us about it in the Tutor `discussion forums `_. diff --git a/docs/options.rst b/docs/options.rst index 452d998..7bcff01 100644 --- a/docs/options.rst +++ b/docs/options.rst @@ -40,16 +40,3 @@ Xqueue ------ `Xqueue `_ is for grading problems with external services. If you don't know what it is, you probably don't need it. - -Android app (beta) ------------------- - -The Android app for your platform can be easily built in just one command:: - - tutor android build debug - -If all goes well, the debuggable APK for your platform should then be available in ./data/android. To obtain a release APK, you will need to obtain credentials from the app store and add them to ``config/android/gradle.properties``. Then run:: - - tutor android build release - -Building the Android app for an Open edX platform is currently labeled as a **beta feature** because it was not fully tested yet. In particular, there is no easy mechanism for overriding the edX assets in the mobile app. This is still a work-in-progress. diff --git a/tutor/android.py b/tutor/android.py index 93194ef..7ba1928 100644 --- a/tutor/android.py +++ b/tutor/android.py @@ -1,6 +1,6 @@ import click -from . import config +from . import config as tutor_config from . import env as tutor_env from . import fmt from . import opts @@ -20,7 +20,12 @@ def android(): ) @opts.root def env(root): - tutor_env.render_target(root, config.load(root), "android") + config = tutor_config.load(root) + # sub.domain.com -> com.domain.sub + config["LMS_HOST_REVERSE"] = ".".join(config["LMS_HOST"].split(".")[::-1]) + tutor_env.render_target(root, config, "build") + tutor_env.render_target(root, config, "android") + click.echo(fmt.info("Environment generated in {}".format(root))) @click.group( help="Build the application" @@ -33,10 +38,7 @@ def build(): ) @opts.root def debug(root): - docker_run( - root, "./gradlew", "assembleProdDebuggable", "&&", - "cp", "OpenEdXMobile/build/outputs/apk/prod/debuggable/*.apk", "/openedx/data/" - ) + docker_run(root) click.echo(fmt.info("The debuggable APK file is available in {}".format(tutor_env.data_path(root, "android")))) @click.command( @@ -56,8 +58,8 @@ def pullimage(): def docker_run(root, *command): utils.docker_run( - "--volume={}/:/openedx/config/".format(tutor_env.pathjoin(root, "android")), - "--volume={}:/openedx/data".format(tutor_env.data_path(root, "android")), + "--volume={}:/openedx/config/".format(tutor_env.pathjoin(root, "android")), + "--volume={}:/openedx/data/".format(tutor_env.data_path(root, "android")), DOCKER_IMAGE, *command ) diff --git a/tutor/scripts.py b/tutor/scripts.py index 453e203..c572ae6 100644 --- a/tutor/scripts.py +++ b/tutor/scripts.py @@ -19,12 +19,16 @@ migrate_forum = "bundle exec rake search:initialize && bundle exec rake search:r migrate_notes = "./manage.py migrate" migrate_xqueue = "./manage.py migrate" -oauth2 = """{% if ACTIVATE_NOTES %} +oauth2 = """ +./manage.py lms create_oauth2_client \ + "http://androidapp.com" "http://androidapp.com/redirect" public \ + --client_id android --client_secret {{ ANDROID_OAUTH2_SECRET }} \ + --trusted + +{% if ACTIVATE_NOTES %} ./manage.py lms manage_user notes notes@{{ LMS_HOST }} --staff --superuser ./manage.py lms create_oauth2_client \ - "http://notes.openedx:8000" \ - "http://notes.openedx:8000/complete/edx-oidc/" \ - confidential \ + "http://notes.openedx:8000" "http://notes.openedx:8000/complete/edx-oidc/" confidential \ --client_name edx-notes --client_id notes --client_secret {{ NOTES_OAUTH2_SECRET }} \ --trusted --logout_uri "http://notes.openedx:8000/logout/" --username notes {% endif %}""" diff --git a/tutor/templates/android/gradle.properties b/tutor/templates/android/gradle.properties index 28b46a6..5031d45 100644 --- a/tutor/templates/android/gradle.properties +++ b/tutor/templates/android/gradle.properties @@ -1,5 +1,5 @@ -APPLICATION_ID=com.example.yourapp -RELEASE_STORE_FILE=/openedx/config/your.keystore -RELEASE_STORE_PASSWORD=your store password here -RELEASE_KEY_PASSWORD=your key password here -RELEASE_KEY_ALIAS=your key alias here +APPLICATION_ID={{ LMS_HOST_REVERSE }} +RELEASE_STORE_FILE=/openedx/config/app.keystore +RELEASE_STORE_PASSWORD={{ ANDROID_STORE_PASSWORD }} +RELEASE_KEY_PASSWORD={{ ANDROID_KEY_PASSWORD }} +RELEASE_KEY_ALIAS={{ ANDROID_RELEASE_KEY_ALIAS }} diff --git a/tutor/templates/android/tutor.yaml b/tutor/templates/android/tutor.yaml index 43ea4e5..d89848b 100644 --- a/tutor/templates/android/tutor.yaml +++ b/tutor/templates/android/tutor.yaml @@ -3,3 +3,4 @@ ENVIRONMENT_DISPLAY_NAME: 'tutor' PLATFORM_NAME: '{{ PLATFORM_NAME }}' PLATFORM_DESTINATION_NAME: '{{ LMS_HOST }}' FEEDBACK_EMAIL_ADDRESS: 'support@{{ LMS_HOST }}' +OAUTH_CLIENT_ID: 'android' diff --git a/tutor/templates/apps/openedx/config/lms.env.json b/tutor/templates/apps/openedx/config/lms.env.json index 6efd3b5..d4a8b7b 100644 --- a/tutor/templates/apps/openedx/config/lms.env.json +++ b/tutor/templates/apps/openedx/config/lms.env.json @@ -7,10 +7,12 @@ "PLATFORM_NAME": "{{ PLATFORM_NAME }}", "FEATURES": { "PREVIEW_LMS_BASE": "preview.{{ LMS_HOST }}", - "ENABLE_OAUTH2_PROVIDER": true, "ENABLE_COURSE_DISCOVERY": true, "ENABLE_COURSEWARE_SEARCH": true, "ENABLE_DASHBOARD_SEARCH": true, + "ENABLE_COMBINED_LOGIN_REGISTRATION": true, + "ENABLE_MOBILE_REST_API": true, + "ENABLE_OAUTH2_PROVIDER": true, "ENABLE_EDXNOTES": {{ "true" if ACTIVATE_NOTES else "false" }} }, "LMS_ROOT_URL": "{{ "https" if ACTIVATE_HTTPS else "http" }}://{{ LMS_HOST }}", diff --git a/tutor/templates/build/android/Dockerfile b/tutor/templates/build/android/Dockerfile index 284a5b7..b58c286 100644 --- a/tutor/templates/build/android/Dockerfile +++ b/tutor/templates/build/android/Dockerfile @@ -23,7 +23,8 @@ RUN wget https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_ RUN yes | /openedx/android-sdk/tools/bin/sdkmanager "platforms;android-27" 1> /dev/null # Install android app repo -RUN git clone https://github.com/edx/edx-app-android /openedx/edx-app-android +# release/2.16.4 is the last know release to work with hawthorn +RUN git clone https://github.com/edx/edx-app-android --branch release/2.16.4 --depth 1 /openedx/edx-app-android WORKDIR /openedx/edx-app-android # Install gradle and all dependencies diff --git a/tutor/templates/config-defaults.yml b/tutor/templates/config-defaults.yml index 393630b..e764b85 100644 --- a/tutor/templates/config-defaults.yml +++ b/tutor/templates/config-defaults.yml @@ -10,3 +10,6 @@ XQUEUE_MYSQL_USERNAME: "xqueue" OPENEDX_DOCKER_IMAGE: "regis/openedx:hawthorn" NGINX_HTTP_PORT: 80 NGINX_HTTPS_PORT: 443 +ANDROID_RELEASE_STORE_PASSWORD: "android store password" +ANDROID_RELEASE_KEY_PASSWORD: "android release key password" +ANDROID_RELEASE_KEY_ALIAS: "android release key alias" diff --git a/tutor/templates/config.yml b/tutor/templates/config.yml index 02bd0b2..6b830a7 100644 --- a/tutor/templates/config.yml +++ b/tutor/templates/config.yml @@ -12,8 +12,8 @@ NOTES_OAUTH2_SECRET: "{{ RAND24 }}" XQUEUE_AUTH_PASSWORD: "{{ RAND8 }}" XQUEUE_MYSQL_PASSWORD: "{{ RAND8 }}" XQUEUE_SECRET_KEY: "{{ RAND24 }}" +ANDROID_OAUTH2_SECRET: "{{ RAND24 }}" ACTIVATE_HTTPS: false ACTIVATE_NOTES: false ACTIVATE_XQUEUE: false ID: "{{ RAND8 }}" -# pouac plonk