mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-07-03 16:40:46 -04:00
Fix Android scaling
On some newer android devices the screen tranform matrix already includes the current scale. i.e. the matrix looks like: ``` { a: scaleX, b: 0, c: 0, d: scaleY, e: offsetX, f: offsetY } ``` where both `scaleX`, and `scaleY` are the current zoom. On other devices the scale is always `1`, and we need to apply our own scaling. I also added the code to automatically allow webview debgging if the buildType is debuggable. Also, note that you can switch which line is commented out in bundle-compile.sh to get unobfuscated javascript.
This commit is contained in:
parent
4347cac225
commit
f6dbdd4fe7
4 changed files with 15 additions and 6 deletions
android/ScratchJr/app
bin
src/painteditor
|
@ -13,6 +13,9 @@ android {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
debug {
|
||||||
|
debuggable true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flavorDimensions 'scratchjrversion'
|
flavorDimensions 'scratchjrversion'
|
||||||
|
|
|
@ -365,8 +365,9 @@ public class ScratchJrActivity
|
||||||
webSettings.setDisplayZoomControls(false);
|
webSettings.setDisplayZoomControls(false);
|
||||||
webSettings.setLoadWithOverviewMode(false);
|
webSettings.setLoadWithOverviewMode(false);
|
||||||
webSettings.setUseWideViewPort(false);
|
webSettings.setUseWideViewPort(false);
|
||||||
// Uncomment to enable remote Chrome debugging on a physical Android device
|
if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) {
|
||||||
// WebView.setWebContentsDebuggingEnabled(true);
|
WebView.setWebContentsDebuggingEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
// Enable cookie persistence
|
// Enable cookie persistence
|
||||||
CookieManager.setAcceptFileSchemeCookies(true);
|
CookieManager.setAcceptFileSchemeCookies(true);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd ..;
|
cd ..;
|
||||||
/usr/local/bin/node ./node_modules/webpack/bin/webpack.js --mode=production
|
/usr/local/bin/node ./node_modules/webpack/bin/webpack.js --mode=production
|
||||||
|
# /usr/local/bin/node ./node_modules/webpack/bin/webpack.js --mode=development
|
||||||
|
|
|
@ -13,7 +13,7 @@ import SVGImage from './SVGImage';
|
||||||
import Camera from './Camera';
|
import Camera from './Camera';
|
||||||
import Events from '../utils/Events';
|
import Events from '../utils/Events';
|
||||||
import Rectangle from '../geom/Rectangle';
|
import Rectangle from '../geom/Rectangle';
|
||||||
import {gn, isTablet, isiOS, getIdFor} from '../utils/lib';
|
import {gn, isTablet, getIdFor} from '../utils/lib';
|
||||||
/*
|
/*
|
||||||
Type of objects:
|
Type of objects:
|
||||||
- fixed: Only exists on Assets Backgrounds and can it only be fill (color or camera) or removed
|
- fixed: Only exists on Assets Backgrounds and can it only be fill (color or camera) or removed
|
||||||
|
@ -1130,9 +1130,13 @@ export default class PaintAction {
|
||||||
var pt2 = Paint.root.createSVGPoint();
|
var pt2 = Paint.root.createSVGPoint();
|
||||||
pt2.x = pt.x;
|
pt2.x = pt.x;
|
||||||
pt2.y = pt.y;
|
pt2.y = pt.y;
|
||||||
var globalPoint = pt2.matrixTransform(Paint.root.getScreenCTM().inverse());
|
var screenMatrix = Paint.root.getScreenCTM();
|
||||||
globalPoint.x = globalPoint.x / Paint.currentZoom;
|
var globalPoint = pt2.matrixTransform(screenMatrix.inverse());
|
||||||
globalPoint.y = globalPoint.y / Paint.currentZoom;
|
// screenMatrix should include the currentScale, if it doesn't match, apply scaling
|
||||||
|
if (screenMatrix.a != Paint.currentZoom) {
|
||||||
|
globalPoint.x = globalPoint.x / Paint.currentZoom;
|
||||||
|
globalPoint.y = globalPoint.y / Paint.currentZoom;
|
||||||
|
}
|
||||||
return globalPoint;
|
return globalPoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue