added qr-code decoder for android
- added color change for status and navigation bar for android
This commit is contained in:
parent
b9a13d3a32
commit
0411792ca5
13 changed files with 255 additions and 58 deletions
|
|
@ -1,10 +1,28 @@
|
|||
#include "pageController.h"
|
||||
|
||||
#include <QApplication>
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "../../platforms/android/androidutils.h"
|
||||
#include <QJniObject>
|
||||
#endif
|
||||
|
||||
PageController::PageController(const QSharedPointer<ServersModel> &serversModel, QObject *parent)
|
||||
: QObject(parent), m_serversModel(serversModel)
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
// Change color of navigation and status bar's
|
||||
auto initialPageNavigationBarColor = getInitialPageNavigationBarColor();
|
||||
AndroidUtils::runOnAndroidThreadSync([&initialPageNavigationBarColor]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
window.callMethod<void>("addFlags", "(I)V", 0x80000000);
|
||||
window.callMethod<void>("clearFlags", "(I)V", 0x04000000);
|
||||
window.callMethod<void>("setStatusBarColor", "(I)V", 0xFF0E0E11);
|
||||
window.callMethod<void>("setNavigationBarColor", "(I)V", initialPageNavigationBarColor);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
QString PageController::getInitialPage()
|
||||
|
|
@ -47,3 +65,26 @@ void PageController::keyPressEvent(Qt::Key key)
|
|||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int PageController::getInitialPageNavigationBarColor()
|
||||
{
|
||||
if (m_serversModel->getServersCount()) {
|
||||
return 0xFF1C1D21;
|
||||
} else {
|
||||
return 0xFF0E0E11;
|
||||
}
|
||||
}
|
||||
|
||||
void PageController::updateNavigationBarColor(const int color)
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
// Change color of navigation bar
|
||||
AndroidUtils::runOnAndroidThreadSync([&color]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
window.callMethod<void>("setNavigationBarColor", "(I)V", color);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue