Add a function that minimizes the Android app (#692)
Add a function that minimizes the Android app
This commit is contained in:
parent
db8d966fac
commit
c6e6f2ae84
7 changed files with 25 additions and 0 deletions
|
|
@ -476,4 +476,12 @@ class AmneziaActivity : QtActivity() {
|
||||||
window.setFlags(flag, LayoutParams.FLAG_SECURE)
|
window.setFlags(flag, LayoutParams.FLAG_SECURE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
fun minimizeApp() {
|
||||||
|
Log.v(TAG, "Minimize application")
|
||||||
|
mainScope.launch {
|
||||||
|
moveTaskToBack(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,11 @@ void AndroidController::setScreenshotsEnabled(bool enabled)
|
||||||
callActivityMethod("setScreenshotsEnabled", "(Z)V", enabled);
|
callActivityMethod("setScreenshotsEnabled", "(Z)V", enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidController::minimizeApp()
|
||||||
|
{
|
||||||
|
callActivityMethod("minimizeApp", "()V");
|
||||||
|
}
|
||||||
|
|
||||||
// Moving log processing to the Android side
|
// Moving log processing to the Android side
|
||||||
jclass AndroidController::log;
|
jclass AndroidController::log;
|
||||||
jmethodID AndroidController::logDebug;
|
jmethodID AndroidController::logDebug;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ public:
|
||||||
void exportLogsFile(const QString &fileName);
|
void exportLogsFile(const QString &fileName);
|
||||||
void clearLogs();
|
void clearLogs();
|
||||||
void setScreenshotsEnabled(bool enabled);
|
void setScreenshotsEnabled(bool enabled);
|
||||||
|
void minimizeApp();
|
||||||
|
|
||||||
static bool initLogging();
|
static bool initLogging();
|
||||||
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
|
#include "platforms/android/android_controller.h"
|
||||||
#include "platforms/android/android_utils.h"
|
#include "platforms/android/android_utils.h"
|
||||||
#include <QJniObject>
|
#include <QJniObject>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -74,6 +75,13 @@ void PageController::closeWindow()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PageController::hideWindow()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_ANDROID
|
||||||
|
AndroidController::instance()->minimizeApp();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void PageController::keyPressEvent(Qt::Key key)
|
void PageController::keyPressEvent(Qt::Key key)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ public slots:
|
||||||
QString getPagePath(PageLoader::PageEnum page);
|
QString getPagePath(PageLoader::PageEnum page);
|
||||||
|
|
||||||
void closeWindow();
|
void closeWindow();
|
||||||
|
void hideWindow();
|
||||||
void keyPressEvent(Qt::Key key);
|
void keyPressEvent(Qt::Key key);
|
||||||
|
|
||||||
unsigned int getInitialPageNavigationBarColor();
|
unsigned int getInitialPageNavigationBarColor();
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ PageType {
|
||||||
|
|
||||||
function onClosePage() {
|
function onClosePage() {
|
||||||
if (stackView.depth <= 1) {
|
if (stackView.depth <= 1) {
|
||||||
|
PageController.hideWindow()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stackView.pop()
|
stackView.pop()
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ PageType {
|
||||||
|
|
||||||
function onClosePage() {
|
function onClosePage() {
|
||||||
if (tabBarStackView.depth <= 1) {
|
if (tabBarStackView.depth <= 1) {
|
||||||
|
PageController.hideWindow()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tabBarStackView.pop()
|
tabBarStackView.pop()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue