Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 891c332

Browse files
committed
Merge branch 'master' of github.com:UnityTech/UIWidgets into dev
2 parents 50d9665 + cd9e1d2 commit 891c332

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Runtime/Plugins/platform/android/view/UIWidgetsViewController.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,29 @@ public static UIWidgetsViewController getInstance() {
3434
private UIWidgetsViewMetrics viewMetrics;
3535
private boolean keyboardOpen;
3636

37+
private float statusHeight;
38+
private float navigationBarHeight;
39+
3740
private void setup() {
3841
//Log.i("tag", "On Setup 2");
3942

4043
keyboardOpen = false;
4144
viewMetrics = new UIWidgetsViewMetrics();
42-
45+
setupHeights();
4346
updateViewMetrics();
4447

4548
setupViewMetricsChangedListener();
4649
}
4750

51+
private void setupHeights() {
52+
final View unityView = ((ViewGroup)UnityPlayer.currentActivity.findViewById(android.R.id.content)).getChildAt(0);
53+
Rect rect = new Rect();
54+
unityView.getWindowVisibleDisplayFrame(rect);
55+
56+
statusHeight = rect.top;
57+
navigationBarHeight = unityView.getRootView().getHeight() - rect.bottom;
58+
}
59+
4860
public static UIWidgetsViewMetrics getMetrics() {
4961
UIWidgetsViewController controller = getInstance();
5062
return controller.viewMetrics;
@@ -143,6 +155,10 @@ public void updateViewMetrics() {
143155
viewMetrics.insets_bottom = navigationBarHidden? calculateBottomKeyboardInset(rect) : rect.bottom;
144156
viewMetrics.insets_left = 0;
145157

158+
//adjust
159+
viewMetrics.insets_bottom -= navigationBarHeight;
160+
viewMetrics.padding_top -= statusHeight;
161+
146162
//Log.i("UIWidgetsDebug", "checks: " + navigationBarHidden + " " + rect.bottom);
147163
//Log.i("UIWidgetsDebug", " padding: " + viewMetrics.padding_top + " " + viewMetrics.padding_right + " " + viewMetrics.padding_bottom + " " + viewMetrics.padding_left);
148164
//Log.i("UIWidgetsDebug", " insets: " + viewMetrics.insets_top + " " + viewMetrics.insets_right + " " + viewMetrics.insets_bottom + " " + viewMetrics.insets_left);

Runtime/ui/txt/paragraph.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ public void setParagraphStyle(ParagraphStyle style) {
661661

662662
public List<TextBox> getRectsForRange(int start, int end) {
663663
var lineBoxes = new SplayTree<int, List<TextBox>>();
664-
foreach (var run in this._codeUnitRuns) {
664+
for (int runIndex = 0; runIndex < this._codeUnitRunsCount; runIndex++) {
665+
var run = this._codeUnitRuns[runIndex];
665666
if (run.codeUnits.start >= end) {
666667
break;
667668
}
@@ -784,7 +785,8 @@ internal PositionWithAffinity getGlyphPositionAtCoordinate(float dx, float dy) {
784785
}
785786

786787
TextDirection direction = TextDirection.ltr;
787-
foreach (var run in this._codeUnitRuns) {
788+
for (int runIndex = 0; runIndex < this._codeUnitRunsCount; runIndex++) {
789+
var run = this._codeUnitRuns[runIndex];
788790
if (gp.codeUnit >= run.codeUnits.start && gp.codeUnit + 1 <= run.codeUnits.end) {
789791
direction = run.direction;
790792
break;

0 commit comments

Comments
 (0)