Android: set displayManager listener after QtLayout is initialized
the QtDisplayManager listener uses m_layout but it can be called before m_layout is actually initialized, so set the listener after the layout has been initialized. Task-number: QTBUG-118077 Fixes: QTBUG-119007 Fixes: QTBUG-119134 Change-Id: Icebc350f09210c12dbd011f86ce88a90b6f27d12 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
This commit is contained in:
parent
2c96f51771
commit
d6861926a1
@ -63,8 +63,6 @@ public class QtActivityDelegate
|
|||||||
|
|
||||||
setActionBarVisibility(false);
|
setActionBarVisibility(false);
|
||||||
|
|
||||||
m_displayManager.registerDisplayListener(m_activity, m_layout);
|
|
||||||
|
|
||||||
QtInputDelegate.KeyboardVisibilityListener keyboardVisibilityListener =
|
QtInputDelegate.KeyboardVisibilityListener keyboardVisibilityListener =
|
||||||
new QtInputDelegate.KeyboardVisibilityListener() {
|
new QtInputDelegate.KeyboardVisibilityListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -197,6 +195,8 @@ public class QtActivityDelegate
|
|||||||
|
|
||||||
m_layout = new QtLayout(m_activity, startApplicationRunnable);
|
m_layout = new QtLayout(m_activity, startApplicationRunnable);
|
||||||
|
|
||||||
|
m_displayManager.registerDisplayListener(m_activity, m_layout);
|
||||||
|
|
||||||
int orientation = m_activity.getResources().getConfiguration().orientation;
|
int orientation = m_activity.getResources().getConfiguration().orientation;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -26,6 +26,8 @@ private slots:
|
|||||||
void testAndroidActivity();
|
void testAndroidActivity();
|
||||||
void testRunOnAndroidMainThread();
|
void testRunOnAndroidMainThread();
|
||||||
void testFullScreenDimensions();
|
void testFullScreenDimensions();
|
||||||
|
void orientationChange_data();
|
||||||
|
void orientationChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_Android::assetsRead()
|
void tst_Android::assetsRead()
|
||||||
@ -299,6 +301,25 @@ void tst_Android::testFullScreenDimensions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_Android::orientationChange_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<int>("nativeOrientation");
|
||||||
|
QTest::addColumn<Qt::ScreenOrientation>("expected");
|
||||||
|
|
||||||
|
QTest::newRow("Landscape") << 0 << Qt::LandscapeOrientation;
|
||||||
|
QTest::newRow("Portrait") << 1 << Qt::PortraitOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_Android::orientationChange()
|
||||||
|
{
|
||||||
|
QFETCH(int, nativeOrientation);
|
||||||
|
QFETCH(Qt::ScreenOrientation, expected);
|
||||||
|
|
||||||
|
auto context = QNativeInterface::QAndroidApplication::context();
|
||||||
|
context.callMethod<void>("setRequestedOrientation", nativeOrientation);
|
||||||
|
QTRY_COMPARE(qGuiApp->primaryScreen()->orientation(), expected);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_Android)
|
QTEST_MAIN(tst_Android)
|
||||||
#include "tst_android.moc"
|
#include "tst_android.moc"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user