Skip to content
Snippets Groups Projects
Commit 4fec788f authored by SeeLook's avatar SeeLook
Browse files

Hide SD card shortcut when API 19 (Kitkat) and above, return primary (internal) storage then

parent c0cbe783
No related branches found
No related tags found
No related merge requests found
/***************************************************************************
* Copyright (C) 2015 by Tomasz Bojczuk *
* Copyright (C) 2015-2016 by Tomasz Bojczuk *
* seelook@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -42,12 +42,23 @@ void Tandroid::setScreenLockDisabled() {
}
int Tandroid::getAPIlevelNr() {
return QtAndroid::androidSdkVersion();
}
QString Tandroid::getExternalPath() {
QString extPath = qgetenv("SECONDARY_STORAGE");
if (!extPath.isEmpty()) {
if (!QFileInfo(extPath).isWritable()) {
qDebug() << "[Tandroid] No write access to secondary storage!";
extPath.clear();
QString extPath;
if (getAPIlevelNr() < 19) { // look for SD card only before Kitkat, otherwise it is unaccessible
extPath = qgetenv("SECONDARY_STORAGE");
// QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment",
// "getExternalStorageDirectory", "()Ljava/io/File;");
// QString extPath = mediaDir.callObjectMethod("getAbsolutePath", "()Ljava/lang/String;").toString();
if (!extPath.isEmpty()) {
if (!QFileInfo(extPath).isWritable()) {
qDebug() << "[Tandroid] No write access to secondary storage!";
extPath.clear();
}
}
}
if (extPath.isEmpty())
......@@ -57,13 +68,6 @@ QString Tandroid::getExternalPath() {
extPath.clear();
}
return extPath;
// QAndroidJniObject extDirObject =
// QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
// QAndroidJniObject externalPath = extDirObject.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
// QAndroidJniEnvironment env;
// if (env->ExceptionCheck())
// env->ExceptionClear();
// return externalPath.toString();
}
......@@ -108,10 +112,11 @@ void Tandroid::restartNootka() {
alarmManager.callMethod<void>("set",
"(IJLandroid/app/PendingIntent;)V",
QAndroidJniObject::getStaticField<jint>("android/app/AlarmManager", "RTC"),
jlong(QDateTime::currentMSecsSinceEpoch() + 100), pendingIntent.object());
jlong(QDateTime::currentMSecsSinceEpoch() + 750), pendingIntent.object());
}
void Tandroid::sendExam(const QString& title, const QString &message, const QString& filePath) {
QAndroidJniObject jTitle = QAndroidJniObject::fromString(title);
QAndroidJniObject jMessage = QAndroidJniObject::fromString(message);
......
/***************************************************************************
* Copyright (C) 2015 by Tomasz Bojczuk *
* Copyright (C) 2015-2016 by Tomasz Bojczuk *
* seelook@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -30,6 +30,9 @@ namespace Tandroid {
/** Sets phone/tablet screen saving disabled. */
void setScreenLockDisabled();
/** Returns a number of Android API on a hosting device. */
int getAPIlevelNr();
/** Returns path to external storage (SD card). */
QString getExternalPath();
......
......@@ -154,7 +154,8 @@ QString TfileDialog::getSaveFileName(QWidget* parent, const QString& directory,
//#################################################################################################
TfileDialog::TfileDialog(QWidget *parent, const QString& directory, const QString& filter, EacceptMode mode) :
QDialog(parent),
m_acceptMode(mode)
m_acceptMode(mode),
m_newDirItem(nullptr)
{
showMaximized();
......@@ -198,9 +199,11 @@ TfileDialog::TfileDialog(QWidget *parent, const QString& directory, const QStrin
QString newLine = QLatin1String("\n");
m_dirUpItem = addMenuItem(QIcon(QLatin1String(":/mobile/dirUp.png")),
qTR("QFileDialog", "Parent Directory").replace(space, newLine));
m_newDirItem = addMenuItem(QIcon(QLatin1String(":/mobile/newDir.png")),
if (mode == e_acceptSave)
m_newDirItem = addMenuItem(QIcon(QLatin1String(":/mobile/newDir.png")),
qTR("QFileDialog", "&New Folder").replace(space, newLine).replace(QLatin1String("&"), QString()));
addMenuItem(QIcon(QLatin1String(":/mobile/card.png")), tr("Memory card").replace(space, newLine));
if (Tandroid::getAPIlevelNr() < 19) // display SD card shortcut only below Kitkat
addMenuItem(QIcon(QLatin1String(":/mobile/card.png")), tr("Memory card").replace(space, newLine));
m_cancelItem = addMenuItem(QIcon(QLatin1String(":/mobile/exit.png")), qTR("QShortcut", "Close"));
// upper location label, file name edit, extension combo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment