Added switcher "Allow app screenshots" for android
This commit is contained in:
parent
ed1afa7549
commit
4e3955b39d
5 changed files with 74 additions and 9 deletions
|
@ -178,6 +178,15 @@ public:
|
|||
m_settings.setValue("Conf/appLanguage", locale);
|
||||
};
|
||||
|
||||
bool isScreenshotsEnabled() const
|
||||
{
|
||||
return m_settings.value("Conf/screenshotsEnabled", false).toBool();
|
||||
}
|
||||
void setScreenshotsEnabled(bool enabled)
|
||||
{
|
||||
m_settings.setValue("Conf/screenshotsEnabled", enabled);
|
||||
}
|
||||
|
||||
void clearSettings();
|
||||
|
||||
signals:
|
||||
|
|
|
@ -61,15 +61,6 @@ ImportController::ImportController(const QSharedPointer<ServersModel> &serversMo
|
|||
{
|
||||
#ifdef Q_OS_ANDROID
|
||||
mInstance = this;
|
||||
// Set security screen for Android app
|
||||
AndroidUtils::runOnAndroidThreadSync([]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>("addFlags", "(I)V", FLAG_SECURE);
|
||||
}
|
||||
});
|
||||
|
||||
AndroidUtils::runOnAndroidThreadAsync([]() {
|
||||
JNINativeMethod methods[] {
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
#include "systemController.h"
|
||||
#include "ui/qautostart.h"
|
||||
#include "version.h"
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include "../../platforms/android/android_controller.h"
|
||||
#include "../../platforms/android/androidutils.h"
|
||||
#include <QJniObject>
|
||||
#endif
|
||||
|
||||
SettingsController::SettingsController(const QSharedPointer<ServersModel> &serversModel,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
|
@ -18,6 +23,20 @@ SettingsController::SettingsController(const QSharedPointer<ServersModel> &serve
|
|||
m_settings(settings)
|
||||
{
|
||||
m_appVersion = QString("%1: %2 (%3)").arg(tr("Software version"), QString(APP_MAJOR_VERSION), __DATE__);
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
if (!m_settings->isScreenshotsEnabled()) {
|
||||
// Set security screen for Android app
|
||||
AndroidUtils::runOnAndroidThreadSync([]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>("addFlags", "(I)V", FLAG_SECURE);
|
||||
}
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SettingsController::toggleAmneziaDns(bool enable)
|
||||
|
@ -152,3 +171,26 @@ void SettingsController::toggleStartMinimized(bool enable)
|
|||
{
|
||||
m_settings->setStartMinimized(enable);
|
||||
}
|
||||
|
||||
bool SettingsController::isScreenshotsEnabled()
|
||||
{
|
||||
return m_settings->isScreenshotsEnabled();
|
||||
}
|
||||
|
||||
void SettingsController::toggleScreenshotsEnabled(bool enable)
|
||||
{
|
||||
m_settings->setScreenshotsEnabled(enable);
|
||||
#ifdef Q_OS_ANDROID
|
||||
std::string command = enable ? "clearFlags" : "addFlags";
|
||||
|
||||
// Set security screen for Android app
|
||||
AndroidUtils::runOnAndroidThreadSync([&command]() {
|
||||
QJniObject activity = AndroidUtils::getActivity();
|
||||
QJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
|
||||
if (window.isValid()) {
|
||||
const int FLAG_SECURE = 8192;
|
||||
window.callMethod<void>(command.c_str(), "(I)V", FLAG_SECURE);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
|
@ -54,6 +54,9 @@ public slots:
|
|||
bool isStartMinimizedEnabled();
|
||||
void toggleStartMinimized(bool enable);
|
||||
|
||||
bool isScreenshotsEnabled();
|
||||
void toggleScreenshotsEnabled(bool enable);
|
||||
|
||||
signals:
|
||||
void primaryDnsChanged();
|
||||
void secondaryDnsChanged();
|
||||
|
|
|
@ -43,6 +43,26 @@ PageType {
|
|||
headerText: qsTr("Application")
|
||||
}
|
||||
|
||||
SwitcherType {
|
||||
visible: GC.isMobile()
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.margins: 16
|
||||
|
||||
text: qsTr("Allow application screenshots")
|
||||
|
||||
checked: SettingsController.isScreenshotsEnabled()
|
||||
onCheckedChanged: {
|
||||
if (checked !== SettingsController.isScreenshotsEnabled()) {
|
||||
SettingsController.toggleScreenshotsEnabled(checked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {
|
||||
visible: GC.isMobile()
|
||||
}
|
||||
|
||||
SwitcherType {
|
||||
visible: !GC.isMobile()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue