|
26 | 26 | importandroid.content.res.Configuration;
|
27 | 27 | importandroid.content.res.Resources;
|
28 | 28 | importandroid.graphics.Color;
|
| 29 | +importandroid.graphics.Rect; |
29 | 30 | importandroid.graphics.drawable.Drawable;
|
| 31 | +importandroid.os.Build; |
30 | 32 | importandroid.text.InputType;
|
31 | 33 | importandroid.text.util.Linkify;
|
| 34 | +importandroid.view.DisplayCutout; |
32 | 35 | importandroid.view.View;
|
| 36 | +importandroid.view.Window; |
33 | 37 | importandroid.webkit.WebViewClient;
|
34 | 38 | importandroid.widget.Toast;
|
35 | 39 |
|
36 | 40 | importandroidx.annotation.NonNull;
|
37 | 41 | importandroidx.appcompat.app.AppCompatDelegate;
|
38 | 42 |
|
| 43 | +importjava.util.List; |
| 44 | + |
39 | 45 | @Kroll.module
|
40 | 46 | publicclassUIModuleextendsKrollModuleimplementsTiApplication.ConfigurationChangedListener
|
41 | 47 | {
|
@@ -571,6 +577,64 @@ public int getUserInterfaceStyle()
|
571 | 577 | returngetUserInterfaceStyle(TiApplication.getInstance().getResources().getConfiguration());
|
572 | 578 | }
|
573 | 579 |
|
| 580 | +@Kroll.getProperty |
| 581 | +publicintstatusBarHeight() |
| 582 | + { |
| 583 | +if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { |
| 584 | +Windoww = TiApplication.getAppCurrentActivity().getWindow(); |
| 585 | +if (w == null) return0; |
| 586 | +Viewdv = w.getDecorView(); |
| 587 | +if (dv == null) return0; |
| 588 | +if (dv.getRootWindowInsets() == null) return0; |
| 589 | +DisplayCutoutdpc = dv.getRootWindowInsets().getDisplayCutout(); |
| 590 | +if (dpc == null) return0; |
| 591 | +List<Rect> rects = dpc.getBoundingRects(); |
| 592 | +if (rects.size() > 0) { |
| 593 | +inth = dpc.getBoundingRects().get(0).height(); |
| 594 | +return (int) newTiDimension(h, TiDimension.TYPE_HEIGHT).getAsDefault(dv); |
| 595 | + } |
| 596 | + } |
| 597 | +return0; |
| 598 | + } |
| 599 | + |
| 600 | +@Kroll.getProperty |
| 601 | +publicKrollDictgetCutoutSize() |
| 602 | + { |
| 603 | +KrollDictreturnValue = newKrollDict(); |
| 604 | +returnValue.put("top", 0); |
| 605 | +returnValue.put("left", 0); |
| 606 | +returnValue.put("height", 0); |
| 607 | +returnValue.put("width", 0); |
| 608 | + |
| 609 | +if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { |
| 610 | +Windoww = TiApplication.getAppCurrentActivity().getWindow(); |
| 611 | +if (w == null) returnreturnValue; |
| 612 | +Viewdv = w.getDecorView(); |
| 613 | +if (dv == null) returnreturnValue; |
| 614 | +if (dv.getRootWindowInsets() == null) returnreturnValue; |
| 615 | +DisplayCutoutdpc = dv.getRootWindowInsets().getDisplayCutout(); |
| 616 | +if (dpc == null) returnreturnValue; |
| 617 | +List<Rect> rects = dpc.getBoundingRects(); |
| 618 | + |
| 619 | +intcutouts = rects.size(); |
| 620 | +int[] result = newint[cutouts * 4]; |
| 621 | +intindex = 0; |
| 622 | + |
| 623 | +if (rects.size() > 0) { |
| 624 | +intdh = dpc.getBoundingRects().get(0).height(); |
| 625 | +intdw = dpc.getBoundingRects().get(0).width(); |
| 626 | +intdt = dpc.getBoundingRects().get(0).top; |
| 627 | +intdl = dpc.getBoundingRects().get(0).left; |
| 628 | + |
| 629 | +returnValue.put("left", (int) newTiDimension(dl, TiDimension.TYPE_LEFT).getAsDefault(dv)); |
| 630 | +returnValue.put("top", (int) newTiDimension(dt, TiDimension.TYPE_TOP).getAsDefault(dv)); |
| 631 | +returnValue.put("width", (int) newTiDimension(dw, TiDimension.TYPE_WIDTH).getAsDefault(dv)); |
| 632 | +returnValue.put("height", (int) newTiDimension(dh, TiDimension.TYPE_HEIGHT).getAsDefault(dv)); |
| 633 | + } |
| 634 | + } |
| 635 | +returnreturnValue; |
| 636 | + } |
| 637 | + |
574 | 638 | @Override
|
575 | 639 | publicStringgetApiName()
|
576 | 640 | {
|
|
0 commit comments