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)
{
}
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
return openWithQDesktopServices(filePath);
#else
bool AndroidIO::openFile(const QString &filePath)
{
if (isSDKVersion24OrNewest()) {
return openWithFileProvider(filePath);
#endif
}
return openWithQDesktopServices(filePath);
}
bool AndroidIO::openWithQDesktopServices(const QString &filePath)
......
......@@ -43,17 +43,39 @@ public:
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
bool openFile(const QString &filePath);
private:
/*!
* @brief Open file with QDesktopService.
*
* @param[in] filePath File path.
* @return True if success.
*/
static
bool openWithQDesktopServices(const QString &filePath);
/*!
* @brief Open file with Java file provider.
*
* @param[in] filePath File path.
* @return True if success.
*/
static
bool openWithFileProvider(const QString &filePath);
};
......@@ -60,6 +60,11 @@ public class 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) {
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