Commit 702833b4 authored by Sharaf Zaman's avatar Sharaf Zaman

Ask for write permission in android when app starts

parent 38389bcc
......@@ -264,6 +264,7 @@ if(ANDROID)
set (Qt5Qml_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Qml/)
set (Qt5Quick_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Quick/)
set (Qt5QuickWidgets_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5QuickWidgets/)
set (Qt5AndroidExtras_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5AndroidExtras/)
set (KF5_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/kf5/kde/install/lib)
set(ECM_DIR ${CMAKE_CURRENT_BINARY_DIR}/kf5/kde/install/share/ECM/cmake)
......@@ -334,6 +335,13 @@ find_package(Qt5 ${MIN_QT_VERSION}
Concurrent
)
if (ANDROID)
find_package(Qt5 ${MIN_QT_VERSION}
REQUIRED COMPONENTS
AndroidExtras
)
endif()
if (WIN32)
set(CMAKE_REQUIRED_INCLUDES ${Qt5Core_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${Qt5Core_LIBRARIES})
......
......@@ -10,8 +10,13 @@ add_subdirectory( data )
add_subdirectory( integration )
add_subdirectory( pics/app )
if (ANDROID)
include_directories (${Qt5AndroidExtras_INCLUDE_DIRS})
endif()
set(krita_SRCS main.cc)
if (NOT APPLE)
file(GLOB ICON_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pics/app/*-apps-calligrakrita.png")
else()
......@@ -66,6 +71,7 @@ qt5_add_resources(krita_SRCS ${krita_QRCS})
if (ANDROID)
add_library(krita SHARED ${krita_SRCS})
target_link_libraries(krita PRIVATE Qt5::AndroidExtras)
else()
add_executable(krita ${krita_SRCS})
endif()
......
......@@ -58,6 +58,10 @@
#include <KisUsageLogger.h>
#include <kis_image_config.h>
#ifdef Q_OS_ANDROID
#include <QtAndroid>
#endif
#if defined Q_OS_WIN
#include "config_use_qt_tablet_windows.h"
#include <windows.h>
......@@ -178,6 +182,21 @@ extern "C" int main(int argc, char **argv)
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor);
#endif
#ifdef Q_OS_ANDROID
const QString write_permission = "android.permission.WRITE_EXTERNAL_STORAGE";
const QStringList permissions = { write_permission };
const QtAndroid::PermissionResultMap resultHash =
QtAndroid::requestPermissionsSync(QStringList(permissions));
if (resultHash[write_permission] == QtAndroid::PermissionResult::Denied) {
// TODO: show a dialog and graciously exit
dbgKrita << "Permission denied by the user";
}
else {
dbgKrita << "Permission granted";
}
#endif
const QString configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
QSettings kritarc(configPath + QStringLiteral("/kritadisplayrc"), QSettings::IniFormat);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment