From db3821488d9fde8f548ef4b92177bbce42b2089f Mon Sep 17 00:00:00 2001 From: Yueyu Date: Mon, 9 Nov 2020 21:25:27 +0800 Subject: [PATCH 1/7] disable drag & drop on images --- src/editor/engine/Sprite.js | 3 +++ src/editor/ui/Library.js | 3 +++ src/lobby/Home.js | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/editor/engine/Sprite.js b/src/editor/engine/Sprite.js index 7f03243..68198eb 100755 --- a/src/editor/engine/Sprite.js +++ b/src/editor/engine/Sprite.js @@ -107,6 +107,9 @@ export default class Sprite { setCostume (dataurl, fcn) { var img = document.createElement('img'); + img.ondragstart = function () { + return false; + } img.src = dataurl; this.img = img; // Make a copy that is not affected by zoom transformation diff --git a/src/editor/ui/Library.js b/src/editor/ui/Library.js index 76cde19..34ad766 100644 --- a/src/editor/ui/Library.js +++ b/src/editor/ui/Library.js @@ -198,6 +198,9 @@ export default class Library { img.style.top = (7 * scaleMultiplier) + 'px'; img.style.position = 'relative'; img.style.height = (data.height * scale) + 'px'; + img.ondragstart = function () { + return false; + } if (data.altmd5) { IO.getAsset(data.altmd5, drawMe); } diff --git a/src/lobby/Home.js b/src/lobby/Home.js index 6a78204..36b290e 100755 --- a/src/lobby/Home.js +++ b/src/lobby/Home.js @@ -300,6 +300,9 @@ export default class Home { if (md5) { IO.getAsset(md5, drawMe); } + img.ondragstart = function () { + return false; + } function drawMe (url) { img.src = url; } From 02d3035057a56f81db56155561fcd79302ce3595 Mon Sep 17 00:00:00 2001 From: Yueyu Date: Thu, 13 May 2021 07:08:01 +0800 Subject: [PATCH 2/7] hide gears on init options page --- src/entry/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/entry/index.js b/src/entry/index.js index 0b4ec84..06f0600 100644 --- a/src/entry/index.js +++ b/src/entry/index.js @@ -111,6 +111,7 @@ function indexSetAnalyticsPrefs () { function indexLoadStart () { indexHideSplash(); showLogo(); + showGear(); gn('gettings').className = 'gettings show'; gn('startcode').className = 'startcode show'; @@ -143,6 +144,14 @@ function showLogo () { gn('jrlogo').className = 'jrlogo show'; } +function hideGear () { + gn('gear').className = 'gear hide'; +} + +function showGear () { + gn('gear').className = 'gear show'; +} + function indexAskPlace () { gn('authors').className = 'credits show'; gn('authorsText').className = 'creditsText hide'; @@ -227,6 +236,7 @@ function optionTouched (elem) { function indexShowQuestion (key) { indexHideSplash(); hideLogo(); + hideGear(); var optionType = InitialOptions.optionTypeForKey(key); if (optionType === 'place_preference') { indexAskPlace(); From 3293e506ca92894632eba5fc8866c54253b41ecf Mon Sep 17 00:00:00 2001 From: Yueyu Date: Thu, 13 May 2021 18:38:49 +0800 Subject: [PATCH 3/7] set column-count by optionNum --- src/entry/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/entry/index.js b/src/entry/index.js index 0b4ec84..23aeeff 100644 --- a/src/entry/index.js +++ b/src/entry/index.js @@ -273,6 +273,15 @@ function indexShowQuestion (key) { } optionNum = optionNum + 1; }); + // iPad mini has the minimum screen size, it can show 13 items in one column + // and we use 3 columns as default + if (optionNum > 13 * 5) { + gn('optionsList').style['column-count'] = 8; + } else if (optionNum > 13 * 3) { + gn('optionsList').style['column-count'] = 5; + } else { + gn('optionsList').style['column-count'] = 3; + } gn('optionsList').className = 'optionsList show'; } } From ec18d1ff92d6e8825392903dfc6516918508d00c Mon Sep 17 00:00:00 2001 From: Yueyu Date: Thu, 13 May 2021 19:33:38 +0800 Subject: [PATCH 4/7] touch to click on init options page --- src/entry/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/entry/index.js b/src/entry/index.js index 0b4ec84..77286cc 100644 --- a/src/entry/index.js +++ b/src/entry/index.js @@ -203,7 +203,7 @@ function indexHidePlaceQuestion () { gn('usageNoanswer').className = 'usageNoanswer hide'; } -function optionTouched (elem) { +function optionSelected (elem) { var key = elem.target.getAttribute('data-key'); var value = elem.target.getAttribute('data-value'); // sometimes a touch is registered by a child of the relevant parent @@ -212,6 +212,7 @@ function optionTouched (elem) { key = parent.getAttribute('data-key'); value = parent.getAttribute('data-value'); } + console.log(key, value) // if we still don't have a key and value, something is wrong -- just go // to lobby if (!key && !value) { @@ -255,7 +256,7 @@ function indexShowQuestion (key) { optionElem.setAttribute('data-key', key); optionElem.setAttribute('data-value', option); optionElem.setAttribute('id', 'option-' + key + '-' + optionNum); - optionElem.ontouchend = optionTouched; + optionElem.onclick = optionSelected; optionsListElem.appendChild(optionElem); switch (optionType) { From 267d09bc879781885371ff0c3af9aa060f618454 Mon Sep 17 00:00:00 2001 From: Yueyu Date: Thu, 13 May 2021 19:39:03 +0800 Subject: [PATCH 5/7] clean up --- src/entry/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/entry/index.js b/src/entry/index.js index 77286cc..7921468 100644 --- a/src/entry/index.js +++ b/src/entry/index.js @@ -212,7 +212,6 @@ function optionSelected (elem) { key = parent.getAttribute('data-key'); value = parent.getAttribute('data-value'); } - console.log(key, value) // if we still don't have a key and value, something is wrong -- just go // to lobby if (!key && !value) { From eefc16b7b7801ab0dccd898cc8f26903c489a32a Mon Sep 17 00:00:00 2001 From: Yueyu Date: Fri, 28 May 2021 20:34:40 +0800 Subject: [PATCH 6/7] add md5 nil check --- ios/ScratchJr/src/IO.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ios/ScratchJr/src/IO.m b/ios/ScratchJr/src/IO.m index f5e1230..eb8c189 100644 --- a/ios/ScratchJr/src/IO.m +++ b/ios/ScratchJr/src/IO.m @@ -313,7 +313,10 @@ NSMutableDictionary *soundtimers; NSDictionary *page = [json valueForKey:name]; for (NSString *spriteName in [page valueForKey:@"sprites"]) { NSDictionary *sprite = [page valueForKey:spriteName]; - [sprites setValue:sprite forKey:[sprite valueForKey:@"md5"]]; + NSString *md5 = [sprite valueForKey:@"md5"]; + if (md5 != nil) { + [sprites setValue:sprite forKey:md5]; + } } } From 7908c8d75f0f888fd76b311f7972b4dd4c3ed8db Mon Sep 17 00:00:00 2001 From: Yueyu Date: Mon, 31 May 2021 06:34:35 +0800 Subject: [PATCH 7/7] update setAnalyticsPref signature --- .../android/JavaScriptDirectInterface.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java b/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java index c2a58b2..f1ec612 100644 --- a/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java +++ b/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java @@ -682,21 +682,13 @@ public class JavaScriptDirectInterface { /** * Record a user property - * @param prefObjStr single key-value JSON string, like "{\"school\": \"Central High\"}" + * @param key like "school" + * @param propertyString like "Central High" */ @JavascriptInterface - public void setAnalyticsPref(String prefObjStr) { - if (prefObjStr != null) { - try { - JSONObject jsonObject = new JSONObject(prefObjStr); - JSONArray jsonArray = jsonObject.names(); - String key = jsonArray.getString(0); - String value = jsonObject.getString(key); - _activity.setAnalyticsPref(key, value); - } catch (JSONException e) { - Log.e(LOG_TAG, "JSON error: " + e.getMessage(), e); - return; - } + public void setAnalyticsPref(String key, String propertyString) { + if (key != null) { + _activity.setAnalyticsPref(key, propertyString); } } }