Android qt 6.7 (#1024)
* Up Gradle to 8.10 * Update Android dependencies * Up Qt to 6.7.2 * Up qtkeychain to 0.14.3 * Move function of changing the color of the navigation bar to the android side * Fix splashscreen and recent apps thumbnail backgrounds * Android authentication refactoring * Fix GitHub action * Fix the extra circle around the connect button on Android * Fix keyboard popup * Increase the amount of requestNetwork attempts on Android 11
This commit is contained in:
parent
cd70b7e619
commit
175477d31f
33 changed files with 256 additions and 192 deletions
|
@ -10,9 +10,6 @@
|
|||
|
||||
#include "core/controllers/vpnConfigurationController.h"
|
||||
#include "systemController.h"
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "platforms/android/android_utils.h"
|
||||
#endif
|
||||
#include "qrcodegen.hpp"
|
||||
|
||||
ExportController::ExportController(const QSharedPointer<ServersModel> &serversModel, const QSharedPointer<ContainersModel> &containersModel,
|
||||
|
@ -24,12 +21,6 @@ ExportController::ExportController(const QSharedPointer<ServersModel> &serversMo
|
|||
m_clientManagementModel(clientManagementModel),
|
||||
m_settings(settings)
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
m_authResultNotifier.reset(new AuthResultNotifier);
|
||||
m_authResultReceiver.reset(new AuthResultReceiver(m_authResultNotifier));
|
||||
connect(m_authResultNotifier.get(), &AuthResultNotifier::authFailed, this, [this]() { emit exportErrorOccurred(tr("Access error!")); });
|
||||
connect(m_authResultNotifier.get(), &AuthResultNotifier::authSuccessful, this, &ExportController::generateFullAccessConfig);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExportController::generateFullAccessConfig()
|
||||
|
@ -63,26 +54,6 @@ void ExportController::generateFullAccessConfig()
|
|||
emit exportConfigChanged();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
void ExportController::generateFullAccessConfigAndroid()
|
||||
{
|
||||
/* We use builtin keyguard for ssh key export protection on Android */
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
auto appContext = activity.callObjectMethod("getApplicationContext", "()Landroid/content/Context;");
|
||||
if (appContext.isValid()) {
|
||||
auto intent = QJniObject::callStaticObjectMethod("org/amnezia/vpn/AuthHelper", "getAuthIntent",
|
||||
"(Landroid/content/Context;)Landroid/content/Intent;", appContext.object());
|
||||
if (intent.isValid()) {
|
||||
if (intent.object<jobject>() != nullptr) {
|
||||
QtAndroidPrivate::startActivity(intent.object<jobject>(), 1, m_authResultReceiver.get());
|
||||
}
|
||||
} else {
|
||||
generateFullAccessConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ExportController::generateConnectionConfig(const QString &clientName)
|
||||
{
|
||||
clearPreviousConfig();
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
#include "ui/models/clientManagementModel.h"
|
||||
#include "ui/models/containers_model.h"
|
||||
#include "ui/models/servers_model.h"
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "platforms/android/authResultReceiver.h"
|
||||
#endif
|
||||
|
||||
class ExportController : public QObject
|
||||
{
|
||||
|
@ -25,9 +22,6 @@ public:
|
|||
|
||||
public slots:
|
||||
void generateFullAccessConfig();
|
||||
#if defined(Q_OS_ANDROID)
|
||||
void generateFullAccessConfigAndroid();
|
||||
#endif
|
||||
void generateConnectionConfig(const QString &clientName);
|
||||
void generateOpenVpnConfig(const QString &clientName);
|
||||
void generateWireGuardConfig(const QString &clientName);
|
||||
|
@ -74,11 +68,6 @@ private:
|
|||
QString m_config;
|
||||
QString m_nativeConfigString;
|
||||
QList<QString> m_qrCodes;
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
QSharedPointer<AuthResultNotifier> m_authResultNotifier;
|
||||
QSharedPointer<QAndroidActivityResultReceiver> m_authResultReceiver;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // EXPORTCONTROLLER_H
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "platforms/android/android_controller.h"
|
||||
#include "platforms/android/android_utils.h"
|
||||
#include <QJniObject>
|
||||
#endif
|
||||
#if defined Q_OS_MAC
|
||||
#include "ui/macos_util.h"
|
||||
|
@ -22,18 +20,8 @@ PageController::PageController(const QSharedPointer<ServersModel> &serversModel,
|
|||
: QObject(parent), m_serversModel(serversModel), m_settings(settings)
|
||||
{
|
||||
#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);
|
||||
}
|
||||
});
|
||||
AndroidController::instance()->setNavigationBarColor(initialPageNavigationBarColor);
|
||||
#endif
|
||||
|
||||
#if defined Q_OS_MACX
|
||||
|
@ -115,14 +103,7 @@ unsigned int PageController::getInitialPageNavigationBarColor()
|
|||
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);
|
||||
}
|
||||
});
|
||||
AndroidController::instance()->setNavigationBarColor(color);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -285,3 +285,12 @@ QString SettingsController::getGatewayEndpoint()
|
|||
{
|
||||
return m_settings->getGatewayEndpoint();
|
||||
}
|
||||
|
||||
bool SettingsController::isOnTv()
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
return AndroidController::instance()->isOnTv();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
|
@ -82,6 +82,8 @@ public slots:
|
|||
void setGatewayEndpoint(const QString &endpoint);
|
||||
QString getGatewayEndpoint();
|
||||
|
||||
bool isOnTv();
|
||||
|
||||
signals:
|
||||
void primaryDnsChanged();
|
||||
void secondaryDnsChanged();
|
||||
|
|
|
@ -125,3 +125,12 @@ void SystemController::setQmlRoot(QObject *qmlRoot)
|
|||
{
|
||||
m_qmlRoot = qmlRoot;
|
||||
}
|
||||
|
||||
bool SystemController::isAuthenticated()
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
return AndroidController::instance()->requestAuthentication();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public slots:
|
|||
|
||||
void setQmlRoot(QObject *qmlRoot);
|
||||
|
||||
bool isAuthenticated();
|
||||
signals:
|
||||
void fileDialogClosed(const bool isAccepted);
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ Button {
|
|||
property string defaultButtonColor: AmneziaStyle.color.paleGray
|
||||
property string progressButtonColor: AmneziaStyle.color.paleGray
|
||||
property string connectedButtonColor: AmneziaStyle.color.goldenApricot
|
||||
property bool buttonActiveFocus: activeFocus && (Qt.platform.os !== "android" || SettingsController.isOnTv())
|
||||
|
||||
implicitWidth: 190
|
||||
implicitHeight: 190
|
||||
|
@ -50,14 +51,14 @@ Button {
|
|||
verticalOffset: 0
|
||||
radius: 10
|
||||
samples: 25
|
||||
color: root.activeFocus ? AmneziaStyle.color.paleGray : AmneziaStyle.color.goldenApricot
|
||||
color: root.buttonActiveFocus ? AmneziaStyle.color.paleGray : AmneziaStyle.color.goldenApricot
|
||||
source: backgroundCircle
|
||||
}
|
||||
|
||||
ShapePath {
|
||||
fillColor: AmneziaStyle.color.transparent
|
||||
strokeColor: AmneziaStyle.color.paleGray
|
||||
strokeWidth: root.activeFocus ? 1 : 0
|
||||
strokeWidth: root.buttonActiveFocus ? 1 : 0
|
||||
capStyle: ShapePath.RoundCap
|
||||
|
||||
PathAngleArc {
|
||||
|
@ -81,14 +82,14 @@ Button {
|
|||
return defaultButtonColor
|
||||
}
|
||||
}
|
||||
strokeWidth: root.activeFocus ? 2 : 3
|
||||
strokeWidth: root.buttonActiveFocus ? 2 : 3
|
||||
capStyle: ShapePath.RoundCap
|
||||
|
||||
PathAngleArc {
|
||||
centerX: backgroundCircle.width / 2
|
||||
centerY: backgroundCircle.height / 2
|
||||
radiusX: 93 - (root.activeFocus ? 2 : 0)
|
||||
radiusY: 93 - (root.activeFocus ? 2 : 0)
|
||||
radiusX: 93 - (root.buttonActiveFocus ? 2 : 0)
|
||||
radiusY: 93 - (root.buttonActiveFocus ? 2 : 0)
|
||||
startAngle: 0
|
||||
sweepAngle: 360
|
||||
}
|
||||
|
|
|
@ -140,22 +140,23 @@ PageType {
|
|||
Keys.onTabPressed: lastItemTabClicked(focusItem)
|
||||
|
||||
clickedFunc: function() {
|
||||
PageController.showBusyIndicator(true)
|
||||
|
||||
if (Qt.platform.os === "android" && !SystemController.isAuthenticated()) {
|
||||
PageController.showBusyIndicator(false)
|
||||
ExportController.exportErrorOccurred(qsTr("Access error!"))
|
||||
return
|
||||
} else {
|
||||
ExportController.generateFullAccessConfig()
|
||||
}
|
||||
|
||||
shareConnectionDrawer.headerText = qsTr("Connection to ") + serverSelector.text
|
||||
shareConnectionDrawer.configContentHeaderText = qsTr("File with connection settings to ") + serverSelector.text
|
||||
|
||||
shareConnectionDrawer.open()
|
||||
shareConnectionDrawer.contentVisible = false
|
||||
PageController.showBusyIndicator(true)
|
||||
|
||||
if (Qt.platform.os === "android") {
|
||||
ExportController.generateFullAccessConfigAndroid();
|
||||
} else {
|
||||
ExportController.generateFullAccessConfig();
|
||||
}
|
||||
shareConnectionDrawer.contentVisible = true
|
||||
|
||||
PageController.showBusyIndicator(false)
|
||||
|
||||
shareConnectionDrawer.contentVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue