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.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
@ -99,7 +100,11 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Resources resources = Resources.getSystem();
|
||||
float scale = 0;
|
||||
if (resources.getDisplayMetrics() != null) {
|
||||
scale = resources.getDisplayMetrics().density;
|
||||
}
|
||||
JSONBuilder envObject = new JSONBuilder()
|
||||
.put("platform", "Android")
|
||||
.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("screenWidth", DoricUtils.px2dp(DoricUtils.getScreenWidth()))
|
||||
.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("deviceBrand", Build.BRAND)
|
||||
.put("deviceModel", Build.MODEL);
|
||||
|
@ -43,7 +43,7 @@ public class StatusBarPlugin extends DoricJavaPlugin {
|
||||
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ((BaseDoricNavBar) getDoricContext().getDoricNavBar()).getLayoutParams();
|
||||
if (hidden) {
|
||||
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
|
||||
lp.topMargin = DoricUtils.getStatusBarHeight(activity);
|
||||
lp.topMargin = DoricUtils.getStatusBarHeight();
|
||||
} else {
|
||||
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
lp.topMargin = 0;
|
||||
|
@ -17,6 +17,7 @@ package pub.doric.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
@ -219,21 +220,13 @@ public class DoricUtils {
|
||||
}
|
||||
|
||||
|
||||
public static int getStatusBarHeight(Context context) {
|
||||
Class<?> c = null;
|
||||
Object obj = null;
|
||||
Field field = null;
|
||||
int x = 0, sbar = 0;
|
||||
try {
|
||||
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();
|
||||
public static int getStatusBarHeight() {
|
||||
int resourceId = Resources.getSystem().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
return Resources.getSystem().getDimensionPixelSize(resourceId);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return sbar;
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,6 +67,7 @@ - (instancetype)init {
|
||||
@"appVersion": infoDictionary[@"CFBundleShortVersionString"],
|
||||
@"screenWidth": @([[UIScreen mainScreen] bounds].size.width),
|
||||
@"screenHeight": @([[UIScreen mainScreen] bounds].size.height),
|
||||
@"screenScale": @([[UIScreen mainScreen] scale]),
|
||||
@"statusBarHeight": @([[UIApplication sharedApplication] statusBarFrame].size.height),
|
||||
@"hasNotch": @(hasNotch()),
|
||||
@"deviceBrand": @"Apple",
|
||||
|
@ -1890,8 +1890,7 @@ var List = /** @class */ (function (_super) {
|
||||
}
|
||||
};
|
||||
List.prototype.scrollToItem = function (context, index, config) {
|
||||
var _a;
|
||||
var animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
var animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index: index, animated: animated, });
|
||||
};
|
||||
List.prototype.reset = function () {
|
||||
|
@ -1396,8 +1396,7 @@ class List extends Superview {
|
||||
}
|
||||
}
|
||||
scrollToItem(context, index, config) {
|
||||
var _a;
|
||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||
}
|
||||
reset() {
|
||||
|
@ -1705,7 +1705,7 @@ var doric = (function (exports) {
|
||||
(module.exports = function (key, value) {
|
||||
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
||||
})('versions', []).push({
|
||||
version: '3.6.4',
|
||||
version: '3.6.5',
|
||||
mode: 'global',
|
||||
copyright: '© 2020 Denis Pushkarev (zloirock.ru)'
|
||||
});
|
||||
@ -6489,7 +6489,13 @@ var doric = (function (exports) {
|
||||
defer = functionBindContext(port.postMessage, port, 1);
|
||||
// Browsers with postMessage, skip WebWorkers
|
||||
// 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;
|
||||
global_1.addEventListener('message', listener, false);
|
||||
// IE8-
|
||||
@ -9861,7 +9867,7 @@ var doric = (function (exports) {
|
||||
var INVALID_PORT = 'Invalid port';
|
||||
|
||||
var ALPHA = /[A-Za-z]/;
|
||||
var ALPHANUMERIC = /[\d+\-.A-Za-z]/;
|
||||
var ALPHANUMERIC = /[\d+-.A-Za-z]/;
|
||||
var DIGIT = /\d/;
|
||||
var HEX_START = /^(0x|0X)/;
|
||||
var OCT = /^[0-7]+$/;
|
||||
|
@ -2855,8 +2855,7 @@ class List extends Superview {
|
||||
}
|
||||
}
|
||||
scrollToItem(context, index, config) {
|
||||
var _a;
|
||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||
}
|
||||
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;
|
||||
screenWidth: number;
|
||||
screenHeight: number;
|
||||
screenScale: number;
|
||||
statusBarHeight: number;
|
||||
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;
|
||||
screenWidth: number;
|
||||
screenHeight: number;
|
||||
screenScale: number;
|
||||
statusBarHeight: number;
|
||||
hasNotch: boolean;
|
||||
/**
|
||||
|
@ -48,8 +48,7 @@ export class List extends Superview {
|
||||
}
|
||||
}
|
||||
scrollToItem(context, index, config) {
|
||||
var _a;
|
||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||
}
|
||||
reset() {
|
||||
|
@ -60,6 +60,8 @@ declare global {
|
||||
|
||||
screenHeight: number,
|
||||
|
||||
screenScale: number,
|
||||
|
||||
statusBarHeight: number,
|
||||
|
||||
hasNotch: boolean,
|
||||
@ -72,7 +74,6 @@ declare global {
|
||||
* ex: iPhone12,5 or pixel 3
|
||||
*/
|
||||
deviceModel: string,
|
||||
|
||||
[index: string]: number | string | boolean | object | undefined
|
||||
}
|
||||
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) {
|
||||
var _a;
|
||||
const animated = (_a = config) === null || _a === void 0 ? void 0 : _a.animated;
|
||||
const animated = config === null || config === void 0 ? void 0 : config.animated;
|
||||
return this.nativeChannel(context, 'scrollToItem')({ index, animated, });
|
||||
}
|
||||
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