Skip to content

Commit

Permalink
Merge pull request #183 from endlessm/784-move-pack-selection
Browse files Browse the repository at this point in the history
Rename welcomeScreen to loadingScreen
  • Loading branch information
dbnicholson committed Sep 22, 2023
2 parents 8294cd0 + 7be6c07 commit 601a04d
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ README.md
_explore/
apps-bundle.zip
collections.zip
assets/welcomeScreen/
assets/loadingScreen/
src/apps-bundle/
src/collections/
src/kolibri/
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
_explore/
apps-bundle.zip
collections.zip
assets/welcomeScreen/
assets/loadingScreen/
src/apps-bundle/
src/collections/
src/kolibri/
Expand Down
4 changes: 2 additions & 2 deletions .p4a
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--private "src"
--local-recipes "p4a-recipes"
--orientation sensor
--requirements python3,android,pyjnius,genericndkbuild,sqlite3,cryptography,twisted,attrs,bcrypt,service_identity,pyasn1,pyasn1_modules,pyopenssl,openssl,six,liblzma,zstandard,beautifulsoup4==4.10.0,zimply_core,kolibri_explore_plugin~=6.0,kolibri_zim_plugin
--requirements python3,android,pyjnius,genericndkbuild,sqlite3,cryptography,twisted,attrs,bcrypt,service_identity,pyasn1,pyasn1_modules,pyopenssl,openssl,six,liblzma,zstandard,beautifulsoup4==4.10.0,zimply_core,kolibri_explore_plugin~=7.0,kolibri_zim_plugin
--android-api 33
--minsdk 24
--allow-minsdk-ndkapi-mismatch
Expand All @@ -19,7 +19,7 @@
--icon-bg assets/icon-bg.png
--fileprovider-paths src/fileprovider_paths.xml
--add-asset assets/_load.html:_load.html
--add-asset assets/welcomeScreen:welcomeScreen
--add-asset assets/loadingScreen:loadingScreen
--whitelist ./allowlist.txt
--blacklist ./blocklist.txt
--add-source src/java/
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CLEAN_DEPS = \
clean-apps-bundle \
clean-collections \
clean-local-kolibri-explore-plugin \
clean-welcomeScreen
clean-loadingScreen
CLEAN_FILES = \
dist \
tmpenv \
Expand Down Expand Up @@ -164,11 +164,11 @@ clean-local-kolibri-explore-plugin:
local-kolibri-explore-plugin: clean-local-kolibri-explore-plugin
pip install --target=${EXPLOREPLUGIN_TARGET} --no-deps ${EXPLOREPLUGIN_WHEEL}

clean-welcomeScreen:
- rm -rf assets/welcomeScreen
clean-loadingScreen:
- rm -rf assets/loadingScreen

assets/welcomeScreen: clean-welcomeScreen local-kolibri-explore-plugin
cp -r ${EXPLOREPLUGIN_TARGET}/kolibri_explore_plugin/welcomeScreen/ assets/
assets/loadingScreen: clean-loadingScreen local-kolibri-explore-plugin
cp -r ${EXPLOREPLUGIN_TARGET}/kolibri_explore_plugin/loadingScreen/ assets/

.PHONY: p4a_android_distro
p4a_android_distro: needs-android-dirs
Expand All @@ -193,7 +193,7 @@ DIST_DEPS = \
src/kolibri \
src/apps-bundle \
src/collections \
assets/welcomeScreen \
assets/loadingScreen \
needs-version \
dist/version.json

Expand Down
2 changes: 1 addition & 1 deletion assets/_load.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="refresh" content="0; URL=welcomeScreen/index.html" />
<meta http-equiv="refresh" content="0; URL=loadingScreen/index.html" />

<title>Endless Key is starting...</title>
</head>
Expand Down
21 changes: 3 additions & 18 deletions src/java/org/learningequality/KolibriAndroidHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import android.graphics.BitmapFactory;
import android.view.View;
import android.content.Context;
import android.content.SharedPreferences;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.ConsoleMessage;
import android.widget.FrameLayout;
import android.webkit.JavascriptInterface;
import org.kivy.android.PythonActivity;

import android.util.Log;
Expand Down Expand Up @@ -79,7 +77,7 @@ public void configure(final Runnable startWithNetwork, final Runnable loadingRea
mActivity.mOpenExternalLinksInBrowser = true;

mLoadingWebView.setWebViewClient(new WebViewClient() {
private boolean mInWelcome = false;
private boolean mInLoading = false;

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Expand All @@ -90,25 +88,12 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
public void onPageFinished(WebView view, String url) {
Log.v(TAG, "mLoadingWebView onPageFinished " + url);

mLoadingWebView.evaluateJavascript("WelcomeApp.setNeedsPermission(true)", null);

if (!mInWelcome && url.contains("welcomeScreen/index.html")) {
if (!mInLoading && url.contains("loadingScreen/index.html")) {
loadingReady.run();
mInWelcome = true;
mInLoading = true;
}
}
});
mLoadingWebView.addJavascriptInterface(new Object() {
@JavascriptInterface
public void startWithNetwork(String packId) {
SharedPreferences sharedPref = mActivity.getSharedPreferences(mActivity.getPackageName(), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("initial_content_pack_id", packId);
editor.commit();
Log.v(TAG, packId);
startWithNetwork.run();
}
} , "WelcomeWrapper");

mLoadingWebView.getSettings().setAllowFileAccess(true);

Expand Down
7 changes: 0 additions & 7 deletions src/kolibri_android/android_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ def get_log_root():
return os.path.join(get_home_folder(), "logs")


def get_initial_content_pack_id():
preferences = get_preferences()
pack_id = preferences.getString("initial_content_pack_id", None)
logger.debug("Initial content pack ID: %s", pack_id)
return pack_id


def show_toast(context, msg, duration):
"""Helper to create and show a Toast message"""

Expand Down
10 changes: 0 additions & 10 deletions src/kolibri_android/kolibri_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from .android_utils import get_android_node_id
from .android_utils import get_home_folder
from .android_utils import get_initial_content_pack_id
from .android_utils import get_logging_config
from .android_utils import get_signature_key_issuing_organization
from .android_utils import get_timezone_name
Expand Down Expand Up @@ -38,7 +37,6 @@ def init_kolibri(**kwargs):
logger.info("Initializing Kolibri and running any upgrade routines")

_init_kolibri_env()
_update_explore_plugin_options()

_monkeypatch_kolibri_logging()

Expand Down Expand Up @@ -98,14 +96,6 @@ def _init_kolibri_env():
os.environ["MORANGO_NODE_ID"] = node_id


def _update_explore_plugin_options():
pack_id = get_initial_content_pack_id()
if pack_id is not None:
os.environ["KOLIBRI_INITIAL_CONTENT_PACK"] = pack_id
else:
os.environ["KOLIBRI_USE_EK_IGUANA_PAGE"] = "1"


def _monkeypatch_kolibri_logging():
"""Monkeypatch kolibri.utils.logger.get_default_logging_config
Expand Down
12 changes: 3 additions & 9 deletions src/kolibri_android/main_activity/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
PythonActivity = autoclass("org.kivy.android.PythonActivity")
KolibriAndroidHelper = autoclass("org.learningequality.KolibriAndroidHelper")

INITIAL_LOADING_PAGE_URL = "file:///android_asset/welcomeScreen/index.html"
LOADING_PAGE_URL = "file:///android_asset/welcomeScreen/index.html#/loading/default"
INITIAL_LOADING_PAGE_URL = "file:///android_asset/loadingScreen/index.html"
LOADING_PAGE_URL = "file:///android_asset/loadingScreen/index.html#/loading/default"


@Runnable
Expand All @@ -35,11 +35,6 @@ def show_loading_page(url):
KolibriAndroidHelper.getInstance().showLoadingPage(url)


@Runnable
def evaluate_javascript_in_loading_webview(js_code):
KolibriAndroidHelper.getInstance().mLoadingWebView.evaluateJavascript(js_code, None)


@Runnable
def set_app_key_cookie(url, app_key):
KolibriAndroidHelper.getInstance().setAppKeyCookie(url, app_key)
Expand Down Expand Up @@ -178,7 +173,6 @@ def _on_loading_ready(self):
startup_state = StartupState.get_current_state()
if startup_state == StartupState.FIRST_TIME:
logging.info("First time")
evaluate_javascript_in_loading_webview("WelcomeApp.showWelcome()")
else:
logging.info("Starting network mode")
self.TO_RUN_IN_MAIN = self.start_kolibri
self.TO_RUN_IN_MAIN = self.start_kolibri

0 comments on commit 601a04d

Please sign in to comment.