Add a function that minimizes the Android app (#692)

Add a function that minimizes the Android app
This commit is contained in:
albexk
2024-03-31 14:14:12 +03:00
committed by GitHub
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)
}
}
@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);
}
void AndroidController::minimizeApp()
{
callActivityMethod("minimizeApp", "()V");
}
// Moving log processing to the Android side
jclass AndroidController::log;
jmethodID AndroidController::logDebug;
@@ -40,6 +40,7 @@ public:
void exportLogsFile(const QString &fileName);
void clearLogs();
void setScreenshotsEnabled(bool enabled);
void minimizeApp();
static bool initLogging();
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message);
+8
View File
@@ -7,6 +7,7 @@
#endif
#ifdef Q_OS_ANDROID
#include "platforms/android/android_controller.h"
#include "platforms/android/android_utils.h"
#include <QJniObject>
#endif
@@ -74,6 +75,13 @@ void PageController::closeWindow()
#endif
}
void PageController::hideWindow()
{
#ifdef Q_OS_ANDROID
AndroidController::instance()->minimizeApp();
#endif
}
void PageController::keyPressEvent(Qt::Key key)
{
switch (key) {
+1
View File
@@ -76,6 +76,7 @@ public slots:
QString getPagePath(PageLoader::PageEnum page);
void closeWindow();
void hideWindow();
void keyPressEvent(Qt::Key key);
unsigned int getInitialPageNavigationBarColor();
@@ -24,6 +24,7 @@ PageType {
function onClosePage() {
if (stackView.depth <= 1) {
PageController.hideWindow()
return
}
stackView.pop()
+1
View File
@@ -40,6 +40,7 @@ PageType {
function onClosePage() {
if (tabBarStackView.depth <= 1) {
PageController.hideWindow()
return
}
tabBarStackView.pop()