Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #336 from LLK/release/2020-10-05
Browse files Browse the repository at this point in the history
[MASTER] Release 2020-10-05
  • Loading branch information
chrisgarrity authored Oct 5, 2020
2 parents 72c8112 + c2d7be6 commit 1a5419f
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 48 deletions.
8 changes: 4 additions & 4 deletions android/ScratchJr/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ android {
free {
dimension = 'scratchjrversion'
applicationId "org.scratchjr.androidfree"
minSdkVersion 19
targetSdkVersion 28
versionCode 21
versionName "1.2.0"
minSdkVersion 21
targetSdkVersion 29
versionCode 22
versionName "1.2.11"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Vector;

/**
* Main activity for Scratch Jr., consisting of a full-screen landscape WebView.
Expand Down Expand Up @@ -103,6 +105,7 @@ public class ScratchJrActivity
private final int SCRATCHJR_CAMERA_MIC_PERMISSION = 1;
public int cameraPermissionResult = PackageManager.PERMISSION_DENIED;
public int micPermissionResult = PackageManager.PERMISSION_DENIED;
public int readExtPermissionResult = PackageManager.PERMISSION_DENIED;

/* Firebase analytics tracking */
private FirebaseAnalytics _FirebaseAnalytics;
Expand Down Expand Up @@ -172,34 +175,33 @@ public void run() {
requestPermissions();
}

private void requestExtStoragePermissions() {
int readExtPermissionResult = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
if (readExtPermissionResult != PackageManager.PERMISSION_GRANTED) {
int requestCode = 2;
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, requestCode);
}
}

/*
Ask for all permissions when ScratchJr is first launched so that we are not asking a 5-7 year old to give permission
*/
public void requestPermissions() {
requestExtStoragePermissions();
cameraPermissionResult = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
micPermissionResult = ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);
readExtPermissionResult = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);

String[] desiredPermissions;
if (cameraPermissionResult != PackageManager.PERMISSION_GRANTED
&& micPermissionResult != PackageManager.PERMISSION_GRANTED) {
desiredPermissions = new String[]{
Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO
};
} else if (cameraPermissionResult != PackageManager.PERMISSION_GRANTED) {
desiredPermissions = new String[]{Manifest.permission.CAMERA};
} else if (micPermissionResult != PackageManager.PERMISSION_GRANTED) {
desiredPermissions = new String[]{Manifest.permission.RECORD_AUDIO};
} else {
if (cameraPermissionResult == PackageManager.PERMISSION_GRANTED
&& micPermissionResult == PackageManager.PERMISSION_GRANTED
&& readExtPermissionResult == PackageManager.PERMISSION_GRANTED) {
return;
}

Vector<String> tmp = new Vector<String>(3);
if (cameraPermissionResult != PackageManager.PERMISSION_GRANTED) {
tmp.add(Manifest.permission.CAMERA);
}
if (micPermissionResult != PackageManager.PERMISSION_GRANTED) {
tmp.add(Manifest.permission.RECORD_AUDIO);
}
if (readExtPermissionResult != PackageManager.PERMISSION_GRANTED) {
tmp.add(Manifest.permission.READ_EXTERNAL_STORAGE);
}
Object[] tmpArray = tmp.toArray();
String[] desiredPermissions = Arrays.copyOf(tmpArray, tmpArray.length, String[].class);

ActivityCompat.requestPermissions(this,
desiredPermissions,
SCRATCHJR_CAMERA_MIC_PERMISSION);
Expand All @@ -217,6 +219,9 @@ public void onRequestPermissionsResult(int requestCode,
if (permission.equals(Manifest.permission.RECORD_AUDIO)) {
micPermissionResult = grantResults[permissionId];
}
if (permission.equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
readExtPermissionResult = grantResults[permissionId];
}
permissionId++;
}
}
Expand Down
66 changes: 44 additions & 22 deletions ios/ScratchJr/src/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,49 @@ - (void) showSplash {
[UIImage imageNamed:@"Default.png"],
nil];
[self.view addSubview:splashScreen];

// align splashScreen image to superview
splashScreen.translatesAutoresizingMaskIntoConstraints = NO;
// Trailing
NSLayoutConstraint *trailing = [NSLayoutConstraint
constraintWithItem:splashScreen
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTrailing
multiplier:1.0f
constant:0.f];
// Leading
NSLayoutConstraint *leading = [NSLayoutConstraint
constraintWithItem:splashScreen
attribute:NSLayoutAttributeLeading
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeLeading
multiplier:1.0f
constant:0.f];
// Top
NSLayoutConstraint *top = [NSLayoutConstraint
constraintWithItem:splashScreen
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:0.f];
// Bottom
NSLayoutConstraint *bottom = [NSLayoutConstraint
constraintWithItem:splashScreen
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeBottom
multiplier:1.0f
constant:0.f];
[self.view addConstraint:leading];
[self.view addConstraint:trailing];
[self.view addConstraint:top];
[self.view addConstraint:bottom];
}

- (void)didReceiveMemoryWarning
Expand Down Expand Up @@ -118,27 +161,6 @@ - (void)viewDidAppear:(BOOL)animated{
startDate = [NSDate date];
}

// Disables iOS 9 webview touch tooltip by disabling the long-press gesture recognizer in subviews
// Thanks to Rye:
// http://stackoverflow.com/questions/32687368/how-to-completely-disable-magnifying-glass-for-uiwebview-ios9
- (void) disableWebViewLongPressGestures:(WKWebView *)webview {
for(id subView in webview.subviews) {
if([subView isKindOfClass:[UIScrollView class]]) {
UIScrollView *scrollView = (UIScrollView *)subView;
for(id ssView in scrollView.subviews) {
if([NSStringFromClass([ssView class]) isEqualToString:@"UIWebBrowserView"]) {
for(UIGestureRecognizer *gs in [ssView gestureRecognizers]) {
if ([gs isKindOfClass:[UILongPressGestureRecognizer class]])
{
gs.enabled = NO;
}
}
}
}
}
}
}

- (void) receiveProject:(NSString *)project{
NSString *callback = [NSString stringWithFormat:@"OS.loadProjectFromSjr('%@');", project];
WKWebView *webview = [ViewController webview];
Expand Down Expand Up @@ -171,7 +193,7 @@ - (BOOL)prefersStatusBarHidden{

- (void) webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[webview evaluateJavaScript:@"window.tablet = window.webkit.messageHandlers.jsBridge" completionHandler:nil];
[self disableWebViewLongPressGestures:webView];
[webview evaluateJavaScript:@"document.body.style.webkitTouchCallout='none';" completionHandler:nil];

NSString *debugChoice =[[NSUserDefaults standardUserDefaults] stringForKey:@"debugstate"];

Expand Down
2 changes: 1 addition & 1 deletion src/editor/ui/Palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export default class Palette {
(sc.flowCaret.next != null) || (sc.flowCaret.inside != null))) {
return 'scripts';
}
if (box2.overlapElemBy(box, 0.66) && box2.hitRect({x: el.left / scale, y: el.top / scale})) {
if (box2.overlapElemBy(box, 0.4) && box2.hitRect({x: el.left / scale, y: el.top / scale})) {
return 'palette';
}
if (pt && box2.hitRect(pt)) {
Expand Down

0 comments on commit 1a5419f

Please sign in to comment.