Commit 578c564d authored by Martin Straka's avatar Martin Straka

Added test on system SDK version

parent f643cc46
...@@ -33,16 +33,21 @@ AndroidIO::AndroidIO(void) ...@@ -33,16 +33,21 @@ AndroidIO::AndroidIO(void)
{ {
} }
bool AndroidIO::openFile(const QString &filePath) bool AndroidIO::isSDKVersion24OrNewest(void)
{ {
jboolean ok = QAndroidJniObject::callStaticMethod<jboolean>(
"cz/nic/mobiledatovka/java/QFileProvider",
"isSDKVersion24OrNewest");
/* TOTO: ADD test: if (SDK >= 24) { use FileProvide } else { use QDesktopServices } */ return (ok);
}
#if 0 bool AndroidIO::openFile(const QString &filePath)
{
if (isSDKVersion24OrNewest()) {
return openWithFileProvider(filePath);
}
return openWithQDesktopServices(filePath); return openWithQDesktopServices(filePath);
#else
return openWithFileProvider(filePath);
#endif
} }
bool AndroidIO::openWithQDesktopServices(const QString &filePath) bool AndroidIO::openWithQDesktopServices(const QString &filePath)
......
...@@ -43,17 +43,39 @@ public: ...@@ -43,17 +43,39 @@ public:
explicit AndroidIO(void); explicit AndroidIO(void);
/*! /*!
* @brief Obtain intent arguments. * @brief Check if Android OS SDK Version is level 24 or newest.
* *
* @return List of files to be opened. * @return True if SDK Version is 24 or higher.
*/
static
bool isSDKVersion24OrNewest(void);
/*!
* @brief Open file.
*
* @param[in] filePath File path.
* @return True if success.
*/ */
static static
bool openFile(const QString &filePath); bool openFile(const QString &filePath);
private: private:
/*!
* @brief Open file with QDesktopService.
*
* @param[in] filePath File path.
* @return True if success.
*/
static static
bool openWithQDesktopServices(const QString &filePath); bool openWithQDesktopServices(const QString &filePath);
/*!
* @brief Open file with Java file provider.
*
* @param[in] filePath File path.
* @return True if success.
*/
static static
bool openWithFileProvider(const QString &filePath); bool openWithFileProvider(const QString &filePath);
}; };
...@@ -60,6 +60,11 @@ public class QFileProvider ...@@ -60,6 +60,11 @@ public class QFileProvider
protected QFileProvider() {} protected QFileProvider() {}
public static boolean isSDKVersion24OrNewest() {
// 24 and newest use fileprovider only
return (Build.VERSION.SDK_INT >= 24);
}
public static boolean startActivity(Intent theIntent, Uri uri) { public static boolean startActivity(Intent theIntent, Uri uri) {
final Context context = QtNative.activity(); final Context context = QtNative.activity();
......
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