feat:Environment add scale
This commit is contained in:
parent
d32f714050
commit
9e7c1f04ef
@ -18,6 +18,7 @@ package pub.doric.engine;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
@ -99,7 +100,11 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Resources resources = Resources.getSystem();
|
||||||
|
float scale = 0;
|
||||||
|
if (resources.getDisplayMetrics() != null) {
|
||||||
|
scale = resources.getDisplayMetrics().density;
|
||||||
|
}
|
||||||
JSONBuilder envObject = new JSONBuilder()
|
JSONBuilder envObject = new JSONBuilder()
|
||||||
.put("platform", "Android")
|
.put("platform", "Android")
|
||||||
.put("platformVersion", String.valueOf(android.os.Build.VERSION.SDK_INT))
|
.put("platformVersion", String.valueOf(android.os.Build.VERSION.SDK_INT))
|
||||||
@ -107,7 +112,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
|||||||
.put("appVersion", appVersion)
|
.put("appVersion", appVersion)
|
||||||
.put("screenWidth", DoricUtils.px2dp(DoricUtils.getScreenWidth()))
|
.put("screenWidth", DoricUtils.px2dp(DoricUtils.getScreenWidth()))
|
||||||
.put("screenHeight", DoricUtils.px2dp(DoricUtils.getScreenHeight()))
|
.put("screenHeight", DoricUtils.px2dp(DoricUtils.getScreenHeight()))
|
||||||
.put("statusBarHeight", DoricUtils.px2dp(DoricUtils.getStatusBarHeight(context)))
|
.put("screenScale", scale)
|
||||||
|
.put("statusBarHeight", DoricUtils.px2dp(DoricUtils.getStatusBarHeight()))
|
||||||
.put("hasNotch", false)
|
.put("hasNotch", false)
|
||||||
.put("deviceBrand", Build.BRAND)
|
.put("deviceBrand", Build.BRAND)
|
||||||
.put("deviceModel", Build.MODEL);
|
.put("deviceModel", Build.MODEL);
|
||||||
|
@ -43,7 +43,7 @@ public class StatusBarPlugin extends DoricJavaPlugin {
|
|||||||
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ((BaseDoricNavBar) getDoricContext().getDoricNavBar()).getLayoutParams();
|
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ((BaseDoricNavBar) getDoricContext().getDoricNavBar()).getLayoutParams();
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
|
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
|
||||||
lp.topMargin = DoricUtils.getStatusBarHeight(activity);
|
lp.topMargin = DoricUtils.getStatusBarHeight();
|
||||||
} else {
|
} else {
|
||||||
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||||
lp.topMargin = 0;
|
lp.topMargin = 0;
|
||||||
|
@ -17,6 +17,7 @@ package pub.doric.utils;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
@ -219,21 +220,13 @@ public class DoricUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int getStatusBarHeight(Context context) {
|
public static int getStatusBarHeight() {
|
||||||
Class<?> c = null;
|
int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android");
|
||||||
Object obj = null;
|
if (resourceId > 0) {
|
||||||
Field field = null;
|
return Resources.getSystem().getDimensionPixelSize(resourceId);
|
||||||
int x = 0, sbar = 0;
|
} else {
|
||||||
try {
|
return 0;
|
||||||
c = Class.forName("com.android.internal.R$dimen");
|
|
||||||
obj = c.newInstance();
|
|
||||||
field = c.getField("status_bar_height");
|
|
||||||
x = Integer.parseInt(field.get(obj).toString());
|
|
||||||
sbar = context.getResources().getDimensionPixelSize(x);
|
|
||||||
} catch (Exception E) {
|
|
||||||
E.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return sbar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ - (instancetype)init {
|
|||||||
@"appVersion": infoDictionary[@"CFBundleShortVersionString"],
|
@"appVersion": infoDictionary[@"CFBundleShortVersionString"],
|
||||||
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
|
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
|
||||||
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
|
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
|
||||||
|
@"screenScale": @([[UIScreen mainScreen] scale]),
|
||||||
@"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
|
@"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
|
||||||
@"hasNotch": @(hasNotch()),
|
@"hasNotch": @(hasNotch()),
|
||||||
@"deviceBrand": @"Apple",
|
@"deviceBrand": @"Apple",
|
||||||
|
@ -1890,8 +1890,7 @@ var List = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
List.prototype.scrollToItem = function (context, index, config) {
|
List.prototype.scrollToItem = function (context, index, config) {
|
||||||
var _a;
|
var animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||||
var animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
|
||||||
return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, });
|
return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, });
|
||||||
};
|
};
|
||||||
List.prototype.reset = function () {
|
List.prototype.reset = function () {
|
||||||
|
@ -1396,8 +1396,7 @@ class List extends Superview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scrollToItem(context, index, config) {
|
scrollToItem(context, index, config) {
|
||||||
var _a;
|
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
|
||||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
|
@ -1705,7 +1705,7 @@ var doric = (function (exports) {
|
|||||||
(module.exports = function (key, value) {
|
(module.exports = function (key, value) {
|
||||||
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
||||||
})('versions', []).push({
|
})('versions', []).push({
|
||||||
version: '3.6.4',
|
version: '3.6.5',
|
||||||
mode: 'global',
|
mode: 'global',
|
||||||
copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
|
copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
|
||||||
});
|
});
|
||||||
@ -6489,7 +6489,13 @@ var doric = (function (exports) {
|
|||||||
defer = functionBindContext(port.postMessage, port, 1);
|
defer = functionBindContext(port.postMessage, port, 1);
|
||||||
// Browsers with postMessage, skip WebWorkers
|
// Browsers with postMessage, skip WebWorkers
|
||||||
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
|
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
|
||||||
} else if (global_1.addEventListener && typeof postMessage == 'function' && !global_1.importScripts && !fails(post)) {
|
} else if (
|
||||||
|
global_1.addEventListener &&
|
||||||
|
typeof postMessage == 'function' &&
|
||||||
|
!global_1.importScripts &&
|
||||||
|
!fails(post) &&
|
||||||
|
location.protocol !== 'file:'
|
||||||
|
) {
|
||||||
defer = post;
|
defer = post;
|
||||||
global_1.addEventListener('message', listener, false);
|
global_1.addEventListener('message', listener, false);
|
||||||
// IE8-
|
// IE8-
|
||||||
@ -9861,7 +9867,7 @@ var doric = (function (exports) {
|
|||||||
var INVALID_PORT = 'Invalid port';
|
var INVALID_PORT = 'Invalid port';
|
||||||
|
|
||||||
var ALPHA = /[A-Za-z]/;
|
var ALPHA = /[A-Za-z]/;
|
||||||
var ALPHANUMERIC = /[\d+\-.A-Za-z]/;
|
var ALPHANUMERIC = /[\d+-.A-Za-z]/;
|
||||||
var DIGIT = /\d/;
|
var DIGIT = /\d/;
|
||||||
var HEX_START = /^(0x|0X)/;
|
var HEX_START = /^(0x|0X)/;
|
||||||
var OCT = /^[0-7]+$/;
|
var OCT = /^[0-7]+$/;
|
||||||
|
@ -2855,8 +2855,7 @@ class List extends Superview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scrollToItem(context, index, config) {
|
scrollToItem(context, index, config) {
|
||||||
var _a;
|
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
|
||||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
|
1
doric-js/index.d.ts
vendored
1
doric-js/index.d.ts
vendored
@ -50,6 +50,7 @@ declare module 'doric/lib/src/runtime/global' {
|
|||||||
libVersion: string;
|
libVersion: string;
|
||||||
screenWidth: number;
|
screenWidth: number;
|
||||||
screenHeight: number;
|
screenHeight: number;
|
||||||
|
screenScale: number;
|
||||||
statusBarHeight: number;
|
statusBarHeight: number;
|
||||||
hasNotch: boolean;
|
hasNotch: boolean;
|
||||||
/**
|
/**
|
||||||
|
1
doric-js/lib/src/runtime/global.d.ts
vendored
1
doric-js/lib/src/runtime/global.d.ts
vendored
@ -36,6 +36,7 @@ declare global {
|
|||||||
libVersion: string;
|
libVersion: string;
|
||||||
screenWidth: number;
|
screenWidth: number;
|
||||||
screenHeight: number;
|
screenHeight: number;
|
||||||
|
screenScale: number;
|
||||||
statusBarHeight: number;
|
statusBarHeight: number;
|
||||||
hasNotch: boolean;
|
hasNotch: boolean;
|
||||||
/**
|
/**
|
||||||
|
@ -48,8 +48,7 @@ export class List extends Superview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scrollToItem(context, index, config) {
|
scrollToItem(context, index, config) {
|
||||||
var _a;
|
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
|
||||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
|
@ -60,6 +60,8 @@ declare global {
|
|||||||
|
|
||||||
screenHeight: number,
|
screenHeight: number,
|
||||||
|
|
||||||
|
screenScale: number,
|
||||||
|
|
||||||
statusBarHeight: number,
|
statusBarHeight: number,
|
||||||
|
|
||||||
hasNotch: boolean,
|
hasNotch: boolean,
|
||||||
@ -72,7 +74,6 @@ declare global {
|
|||||||
* ex: iPhone12,5 or pixel 3
|
* ex: iPhone12,5 or pixel 3
|
||||||
*/
|
*/
|
||||||
deviceModel: string,
|
deviceModel: string,
|
||||||
|
|
||||||
[index: string]: number | string | boolean | object | undefined
|
[index: string]: number | string | boolean | object | undefined
|
||||||
}
|
}
|
||||||
function Entry(constructor: { new(...args: any[]): {} }): any
|
function Entry(constructor: { new(...args: any[]): {} }): any
|
||||||
|
3
doric-web/dist/index.js
vendored
3
doric-web/dist/index.js
vendored
@ -2913,8 +2913,7 @@ class List extends Superview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scrollToItem(context, index, config) {
|
scrollToItem(context, index, config) {
|
||||||
var _a;
|
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
|
||||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user