Android notification and routing (#797)
Android notification and routing
This commit is contained in:
parent
ff348a348c
commit
abb3c918e3
40 changed files with 1108 additions and 543 deletions
|
@ -30,6 +30,9 @@ SettingsController::SettingsController(const QSharedPointer<ServersModel> &serve
|
|||
{
|
||||
m_appVersion = QString("%1 (%2, %3)").arg(QString(APP_VERSION), __DATE__, GIT_COMMIT_HASH);
|
||||
checkIfNeedDisableLogs();
|
||||
#ifdef Q_OS_ANDROID
|
||||
connect(AndroidController::instance(), &AndroidController::notificationStateChanged, this, &SettingsController::onNotificationStateChanged);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingsController::toggleAmneziaDns(bool enable)
|
||||
|
@ -233,3 +236,19 @@ void SettingsController::toggleKillSwitch(bool enable)
|
|||
{
|
||||
m_settings->setKillSwitchEnabled(enable);
|
||||
}
|
||||
|
||||
bool SettingsController::isNotificationPermissionGranted()
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
return AndroidController::instance()->isNotificationPermissionGranted();
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingsController::requestNotificationPermission()
|
||||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
AndroidController::instance()->requestNotificationPermission();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
Q_PROPERTY(QString primaryDns READ getPrimaryDns WRITE setPrimaryDns NOTIFY primaryDnsChanged)
|
||||
Q_PROPERTY(QString secondaryDns READ getSecondaryDns WRITE setSecondaryDns NOTIFY secondaryDnsChanged)
|
||||
Q_PROPERTY(bool isLoggingEnabled READ isLoggingEnabled WRITE toggleLogging NOTIFY loggingStateChanged)
|
||||
Q_PROPERTY(bool isNotificationPermissionGranted READ isNotificationPermissionGranted NOTIFY onNotificationStateChanged)
|
||||
|
||||
public slots:
|
||||
void toggleAmneziaDns(bool enable);
|
||||
|
@ -66,6 +67,9 @@ public slots:
|
|||
bool isKillSwitchEnabled();
|
||||
void toggleKillSwitch(bool enable);
|
||||
|
||||
bool isNotificationPermissionGranted();
|
||||
void requestNotificationPermission();
|
||||
|
||||
signals:
|
||||
void primaryDnsChanged();
|
||||
void secondaryDnsChanged();
|
||||
|
@ -83,6 +87,8 @@ signals:
|
|||
|
||||
void loggingDisableByWatcher();
|
||||
|
||||
void onNotificationStateChanged();
|
||||
|
||||
private:
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
QSharedPointer<ContainersModel> m_containersModel;
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
|
||||
#if defined(Q_OS_IOS)
|
||||
# include "platforms/ios/iosnotificationhandler.h"
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
# include "platforms/android/android_notificationhandler.h"
|
||||
#else
|
||||
|
||||
# include "systemtray_notificationhandler.h"
|
||||
#endif
|
||||
|
||||
|
@ -18,8 +15,6 @@
|
|||
NotificationHandler* NotificationHandler::create(QObject* parent) {
|
||||
#if defined(Q_OS_IOS)
|
||||
return new IOSNotificationHandler(parent);
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
return new AndroidNotificationHandler(parent);
|
||||
#else
|
||||
|
||||
# if defined(Q_OS_LINUX)
|
||||
|
|
|
@ -74,7 +74,8 @@ PageType {
|
|||
}
|
||||
}
|
||||
|
||||
KeyNavigation.tab: labelWithButtonLanguage.rightButton
|
||||
KeyNavigation.tab: Qt.platform.os === "android" && !SettingsController.isNotificationPermissionGranted ?
|
||||
labelWithButtonNotification.rightButton : labelWithButtonLanguage.rightButton
|
||||
parentFlickable: fl
|
||||
}
|
||||
|
||||
|
@ -82,6 +83,27 @@ PageType {
|
|||
visible: GC.isMobile()
|
||||
}
|
||||
|
||||
LabelWithButtonType {
|
||||
id: labelWithButtonNotification
|
||||
visible: Qt.platform.os === "android" && !SettingsController.isNotificationPermissionGranted
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTr("Enable notifications")
|
||||
descriptionText: qsTr("Enable notifications to show the VPN state in the status bar")
|
||||
rightImageSource: "qrc:/images/controls/chevron-right.svg"
|
||||
|
||||
KeyNavigation.tab: labelWithButtonLanguage.rightButton
|
||||
parentFlickable: fl
|
||||
|
||||
clickedFunction: function() {
|
||||
SettingsController.requestNotificationPermission()
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {
|
||||
visible: Qt.platform.os === "android" && !SettingsController.isNotificationPermissionGranted
|
||||
}
|
||||
|
||||
SwitcherType {
|
||||
id: switcherAutoStart
|
||||
visible: !GC.isMobile()
|
||||
|
@ -173,7 +195,6 @@ PageType {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
DividerType {}
|
||||
|
||||
LabelWithButtonType {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue