Skip to content

Commit de5ccaa

Browse files
committed
Resize app when keyboard appears on android and do not switch to horizontal mode when keyboard appears.
1 parent a444df5 commit de5ccaa

File tree

8 files changed

+31
-6
lines changed

8 files changed

+31
-6
lines changed

android/src/com/vedder/vesc/Utils.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ public static int topBarHeight(Context ctx) {
8787
public static int bottomBarHeight(Context ctx) {
8888
if (Build.VERSION.SDK_INT >= 35) {
8989
WindowInsets windowInsets = getActivity(ctx).getWindow().getDecorView().getRootWindowInsets();
90-
return windowInsets.getInsets(WindowInsets.Type.systemBars()).bottom;
90+
91+
int hKeyboard = windowInsets.getInsets(WindowInsets.Type.ime()).bottom;
92+
int hBars = windowInsets.getInsets(WindowInsets.Type.systemBars()).bottom;
93+
94+
if (hKeyboard > 0) {
95+
return hKeyboard;
96+
} else {
97+
return hBars;
98+
}
9199
} else {
92100
return 0;
93101
}

mobile/DetectBldc.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Item {
118118
anchors.fill: parent
119119
clip: true
120120
contentWidth: parent.width
121+
121122
ColumnLayout {
122123
anchors.fill: parent
123124
spacing: 0

mobile/DetectFocEncoder.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Item {
8484
anchors.fill: parent
8585
clip: true
8686
contentWidth: parent.width
87+
8788
ColumnLayout {
8889
anchors.fill: parent
8990
spacing: 0

mobile/DetectFocHall.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Item {
8989
anchors.fill: parent
9090
clip: true
9191
contentWidth: parent.width
92+
9293
ColumnLayout {
9394
anchors.fill: parent
9495
spacing: 0

mobile/DetectFocParam.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Item {
134134
anchors.fill: parent
135135
clip: true
136136
contentWidth: parent.width
137+
137138
ColumnLayout {
138139
anchors.fill: parent
139140
spacing: 0

mobile/SetupWizardFoc.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Item {
3434
property ConfigParams mMcConf: VescIf.mcConfig()
3535
property Commands mCommands: VescIf.commands()
3636
property var dialogParent: ApplicationWindow.overlay
37+
property bool isHorizontal: width > height
3738
property var canDevs: []
3839

3940
signal dialogClosed()
@@ -93,7 +94,7 @@ Item {
9394
id: dialog
9495
modal: true
9596
focus: true
96-
property bool isHorizontal: width > height
97+
property bool isHorizontal: topItem.isHorizontal
9798
width: parent.width - 10 - notchLeft - notchRight
9899
height: parent.height - 10
99100
closePolicy: Popup.NoAutoClose

mobile/StartPage.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,13 @@ Item {
389389
SetupWizardFoc {
390390
id: wizardFoc
391391
dialogParent: mainSwipeView
392+
isHorizontal: mainIsHorizontal
392393
}
393394

394395
SetupWizardInput {
395396
id: wizardInput
396397
dialogParent: mainSwipeView
398+
isHorizontal: mainIsHorizontal
397399
}
398400

399401
PairingDialog {
@@ -617,6 +619,7 @@ Item {
617619
pageIndicatorVisible: false
618620
swipeOrientation: Qt.Horizontal
619621
currentPage: tabBar.currentIndex
622+
isHorizontal: topItem.isHorizontal
620623
}
621624

622625
header: Rectangle {

mobile/main.qml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ ApplicationWindow {
4848
property int notchRight: 0
4949
property int notchBot: 0
5050
property int notchTop: 0
51+
property bool mainIsHorizontal: appWindow.width > appWindow.height
5152

5253
// https://github.com/ekke/c2gQtWS_x/blob/master/qml/main.qml
5354
flags: Qt.platform.os === "ios" ? (Qt.Window | Qt.MaximizeUsingFullscreenGeometryHint) : Qt.Window
@@ -66,16 +67,16 @@ ApplicationWindow {
6667

6768
Timer {
6869
id: oriTimer
69-
interval: 100; running: true; repeat: false
70+
interval: 100
71+
running: true
72+
repeat: true
73+
7074
onTriggered: {
7175
updateNotch()
7276
}
7377
}
7478

7579
Screen.orientationUpdateMask: Qt.LandscapeOrientation | Qt.PortraitOrientation
76-
Screen.onPrimaryOrientationChanged: {
77-
oriTimer.start()
78-
}
7980

8081
Component.onCompleted: {
8182
if (!VescIf.isIntroDone()) {
@@ -301,6 +302,7 @@ ApplicationWindow {
301302
anchors.fill: parent
302303
anchors.leftMargin: 10
303304
anchors.rightMargin: 10
305+
isHorizontal: mainIsHorizontal
304306

305307
onRequestOpenControls: {
306308
controls.openDialog()
@@ -366,6 +368,7 @@ ApplicationWindow {
366368
sourceComponent: RtData {
367369
anchors.fill: parent
368370
updateData: tabBar.currentIndex == (1 + indexOffset()) && rtSwipeView.currentIndex == 0
371+
isHorizontal: mainIsHorizontal
369372
}
370373
}
371374
}
@@ -379,6 +382,7 @@ ApplicationWindow {
379382
anchors.fill: parent
380383
dialogParent: mainSwipeView
381384
updateData: tabBar.currentIndex == (1 + indexOffset()) && rtSwipeView.currentIndex == 1
385+
isHorizontal: mainIsHorizontal
382386
}
383387
}
384388
}
@@ -431,6 +435,7 @@ ApplicationWindow {
431435

432436
sourceComponent: StatPage {
433437
anchors.fill: parent
438+
isHorizontal: mainIsHorizontal
434439
}
435440
}
436441
}
@@ -445,6 +450,7 @@ ApplicationWindow {
445450
visible: status == Loader.Ready
446451
sourceComponent: BMS {
447452
anchors.fill: parent
453+
isHorizontal: mainIsHorizontal
448454
}
449455
}
450456
}
@@ -607,6 +613,7 @@ ApplicationWindow {
607613
dialogParent: mainSwipeView
608614
anchors.leftMargin: 10
609615
anchors.rightMargin: 10
616+
isHorizontal: mainIsHorizontal
610617
}
611618
}
612619
}
@@ -624,6 +631,7 @@ ApplicationWindow {
624631
anchors.fill: parent
625632
anchors.leftMargin: 10
626633
anchors.rightMargin: 10
634+
isHorizontal: mainIsHorizontal
627635
}
628636
}
629637
}
@@ -640,6 +648,7 @@ ApplicationWindow {
640648
anchors.fill: parent
641649
anchors.leftMargin: 10
642650
anchors.rightMargin: 10
651+
isHorizontal: mainIsHorizontal
643652
}
644653
}
645654
}

0 commit comments

Comments
 (0)