Skip to content
Snippets Groups Projects
Commit eac47010 authored by SeeLook's avatar SeeLook :musical_note:
Browse files

Remove AndroidExtras references, use new ones

parent e76fda1d
No related branches found
No related tags found
No related merge requests found
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
***************************************************************************/ ***************************************************************************/
#include "tandroid.h" #include "tandroid.h"
#include <QtAndroidExtras/qandroidfunctions.h>
#include <QtAndroidExtras/qandroidjnienvironment.h>
#include <QtCore/qdatetime.h> #include <QtCore/qdatetime.h>
#include <QtCore/qfileinfo.h> #include <QtCore/qfileinfo.h>
#include <QtCore/qstandardpaths.h> #include <QtCore/qstandardpaths.h>
...@@ -27,12 +25,14 @@ ...@@ -27,12 +25,14 @@
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
using namespace QNativeInterface;
void Tandroid::keepScreenOn(bool on) void Tandroid::keepScreenOn(bool on)
{ {
QtAndroid::runOnAndroidThread([on] { QAndroidApplication::runOnAndroidMainThread([on] {
QAndroidJniObject activity = QtAndroid::androidActivity(); auto activity = QJniObject(QAndroidApplication::context());
if (activity.isValid()) { if (activity.isValid()) {
QAndroidJniObject window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;"); auto window = activity.callObjectMethod("getWindow", "()Landroid/view/Window;");
if (window.isValid()) { if (window.isValid()) {
const int FLAG_KEEP_SCREEN_ON = 128; const int FLAG_KEEP_SCREEN_ON = 128;
...@@ -42,47 +42,45 @@ void Tandroid::keepScreenOn(bool on) ...@@ -42,47 +42,45 @@ void Tandroid::keepScreenOn(bool on)
window.callMethod<void>("clearFlags", "(I)V", FLAG_KEEP_SCREEN_ON); window.callMethod<void>("clearFlags", "(I)V", FLAG_KEEP_SCREEN_ON);
} }
} }
QAndroidJniEnvironment env; QJniEnvironment env;
if (env->ExceptionCheck()) env.checkAndClearExceptions();
env->ExceptionClear();
}); });
} }
void Tandroid::disableRotation(bool disRot) void Tandroid::disableRotation(bool disRot)
{ {
int orientation = disRot ? 0 : 10; // SCREEN_ORIENTATION_LANDSCAPE or SCREEN_ORIENTATION_FULL_SENSOR int orientation = disRot ? 0 : 10; // SCREEN_ORIENTATION_LANDSCAPE or SCREEN_ORIENTATION_FULL_SENSOR
QtAndroid::runOnAndroidThread([orientation] { QAndroidApplication::runOnAndroidMainThread([orientation] {
QAndroidJniObject activity = QtAndroid::androidActivity(); auto activity = QJniObject(QAndroidApplication::context());
if (activity.isValid()) if (activity.isValid())
activity.callMethod<void>("setRequestedOrientation", "(I)V", orientation); activity.callMethod<void>("setRequestedOrientation", "(I)V", orientation);
QAndroidJniEnvironment env; QJniEnvironment env;
if (env->ExceptionCheck()) env.checkAndClearExceptions();
env->ExceptionClear();
}); });
} }
int Tandroid::getAPIlevelNr() int Tandroid::getAPIlevelNr()
{ {
return QtAndroid::androidSdkVersion(); return QAndroidApplication::sdkVersion();
} }
bool Tandroid::hasWriteAccess() bool Tandroid::hasWriteAccess()
{ {
if (QtAndroid::androidSdkVersion() < 23) // if (QAndroidApplication::sdkVersion() < 23) // TODO
return true; return false; // true;
else // else
return QtAndroid::checkPermission(QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE")) == QtAndroid::PermissionResult::Granted; // return QtAndroid::checkPermission(QStringLiteral("android.permission.WRITE_EXTERNAL_STORAGE")) == QtAndroid::PermissionResult::Granted;
} }
void Tandroid::askForWriteAcces() void Tandroid::askForWriteAcces()
{ {
if (QtAndroid::androidSdkVersion() >= 23) { // if (QtAndroid::androidSdkVersion() >= 23) {
const QString writeID("android.permission.WRITE_EXTERNAL_STORAGE"); // const QString writeID("android.permission.WRITE_EXTERNAL_STORAGE");
if (QtAndroid::checkPermission(writeID) != QtAndroid::PermissionResult::Granted) { // if (QtAndroid::checkPermission(writeID) != QtAndroid::PermissionResult::Granted) {
auto perms = QtAndroid::requestPermissionsSync(QStringList() << writeID); // auto perms = QtAndroid::requestPermissionsSync(QStringList() << writeID);
qDebug() << writeID << (perms[writeID] == QtAndroid::PermissionResult::Granted); // qDebug() << writeID << (perms[writeID] == QtAndroid::PermissionResult::Granted);
} // }
} // }
} }
QString Tandroid::getExternalPath() QString Tandroid::getExternalPath()
...@@ -113,67 +111,66 @@ QString Tandroid::getExternalPath() ...@@ -113,67 +111,66 @@ QString Tandroid::getExternalPath()
QString Tandroid::getRunArgument() QString Tandroid::getRunArgument()
{ {
QString argument; QString argument;
QAndroidJniObject activity = QtAndroid::androidActivity(); auto activity = QJniObject(QAndroidApplication::context());
if (activity.isValid()) { if (activity.isValid()) {
QAndroidJniObject intent = activity.callObjectMethod("getIntent", "()Landroid/content/Intent;"); QJniObject intent = activity.callObjectMethod("getIntent", "()Landroid/content/Intent;");
if (intent.isValid()) { if (intent.isValid()) {
QAndroidJniObject data = intent.callObjectMethod("getData", "()Landroid/net/Uri;"); QJniObject data = intent.callObjectMethod("getData", "()Landroid/net/Uri;");
if (data.isValid()) { if (data.isValid()) {
QAndroidJniObject arg = data.callObjectMethod("getPath", "()Ljava/lang/String;"); QJniObject arg = data.callObjectMethod("getPath", "()Ljava/lang/String;");
if (arg.isValid()) if (arg.isValid())
argument = arg.toString(); argument = arg.toString();
} }
} }
} }
QAndroidJniEnvironment env; QJniEnvironment env;
if (env->ExceptionCheck()) env.checkAndClearExceptions();
env->ExceptionClear();
return argument; return argument;
} }
void Tandroid::restartNootka() void Tandroid::restartNootka()
{ {
auto activity = QtAndroid::androidActivity(); // auto activity = QtAndroid::androidActivity();
auto packageManager = activity.callObjectMethod("getPackageManager", "()Landroid/content/pm/PackageManager;"); // auto packageManager = activity.callObjectMethod("getPackageManager", "()Landroid/content/pm/PackageManager;");
auto activityIntent = packageManager.callObjectMethod("getLaunchIntentForPackage", // auto activityIntent = packageManager.callObjectMethod("getLaunchIntentForPackage",
"(Ljava/lang/String;)Landroid/content/Intent;", // "(Ljava/lang/String;)Landroid/content/Intent;",
activity.callObjectMethod("getPackageName", "()Ljava/lang/String;").object()); // activity.callObjectMethod("getPackageName", "()Ljava/lang/String;").object());
auto pendingIntent = // auto pendingIntent =
QAndroidJniObject::callStaticObjectMethod("android/app/PendingIntent", // QAndroidJniObject::callStaticObjectMethod("android/app/PendingIntent",
"getActivity", // "getActivity",
"(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;", // "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;",
activity.object(), // activity.object(),
jint(0), // jint(0),
activityIntent.object(), // activityIntent.object(),
QAndroidJniObject::getStaticField<jint>("android/content/Intent", "FLAG_ACTIVITY_CLEAR_TOP")); // QAndroidJniObject::getStaticField<jint>("android/content/Intent", "FLAG_ACTIVITY_CLEAR_TOP"));
auto alarmManager = // auto alarmManager =
activity.callObjectMethod("getSystemService", // activity.callObjectMethod("getSystemService",
"(Ljava/lang/String;)Ljava/lang/Object;", // "(Ljava/lang/String;)Ljava/lang/Object;",
QAndroidJniObject::getStaticObjectField("android/content/Context", "ALARM_SERVICE", "Ljava/lang/String;").object()); // QAndroidJniObject::getStaticObjectField("android/content/Context", "ALARM_SERVICE", "Ljava/lang/String;").object());
alarmManager.callMethod<void>("set", // alarmManager.callMethod<void>("set",
"(IJLandroid/app/PendingIntent;)V", // "(IJLandroid/app/PendingIntent;)V",
QAndroidJniObject::getStaticField<jint>("android/app/AlarmManager", "RTC"), // QAndroidJniObject::getStaticField<jint>("android/app/AlarmManager", "RTC"),
jlong(QDateTime::currentMSecsSinceEpoch() + 750), // jlong(QDateTime::currentMSecsSinceEpoch() + 750),
pendingIntent.object()); // pendingIntent.object());
QAndroidJniEnvironment env; // QAndroidJniEnvironment env;
if (env->ExceptionCheck()) // if (env->ExceptionCheck())
env->ExceptionClear(); // env->ExceptionClear();
} // }
void Tandroid::sendExam(const QString &title, const QString &message, const QString &filePath) // void Tandroid::sendExam(const QString &title, const QString &message, const QString &filePath)
{ // {
QAndroidJniObject jTitle = QAndroidJniObject::fromString(title); // QAndroidJniObject jTitle = QAndroidJniObject::fromString(title);
QAndroidJniObject jMessage = QAndroidJniObject::fromString(message); // QAndroidJniObject jMessage = QAndroidJniObject::fromString(message);
QAndroidJniObject jFile = QAndroidJniObject::fromString(filePath); // QAndroidJniObject jFile = QAndroidJniObject::fromString(filePath);
QAndroidJniObject::callStaticMethod<void>("net/sf/nootka/TshareExam", // QAndroidJniObject::callStaticMethod<void>("net/sf/nootka/TshareExam",
"send", // "send",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", // "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
jTitle.object<jstring>(), // jTitle.object<jstring>(),
jMessage.object<jstring>(), // jMessage.object<jstring>(),
jFile.object<jstring>()); // jFile.object<jstring>());
QAndroidJniEnvironment env; // QAndroidJniEnvironment env;
if (env->ExceptionCheck()) // if (env->ExceptionCheck())
env->ExceptionClear(); // env->ExceptionClear();
} }
QString Tandroid::accountName() QString Tandroid::accountName()
......
...@@ -26,11 +26,6 @@ ...@@ -26,11 +26,6 @@
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include <QtCore/qtimer.h> #include <QtCore/qtimer.h>
#if defined(Q_OS_ANDROID)
#include <QtAndroidExtras/qandroidfunctions.h>
#include <QtAndroidExtras/qandroidjnienvironment.h>
#endif
TtunerDialogItem::TtunerDialogItem(QQuickItem *parent) TtunerDialogItem::TtunerDialogItem(QQuickItem *parent)
: QQuickItem(parent) : QQuickItem(parent)
{ {
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
#include "tqtaudioin.h" #include "tqtaudioin.h"
#include "tqtaudioout.h" #include "tqtaudioout.h"
#include <QtAndroidExtras/qandroidfunctions.h>
#include <QtAndroidExtras/qandroidjnienvironment.h>
#else #else
// #include "tmidiout.h" // #include "tmidiout.h"
#include "tnotesbaritem.h" #include "tnotesbaritem.h"
...@@ -536,17 +534,17 @@ void Tsound::setTunerMode(bool isTuner) ...@@ -536,17 +534,17 @@ void Tsound::setTunerMode(bool isTuner)
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
int Tsound::maxVolRange() const int Tsound::maxVolRange() const
{ {
return QAndroidJniObject::callStaticMethod<jint>("net/sf/nootka/ToutVolume", "maxStreamVolume"); return QJniObject::callStaticMethod<jint>("net/sf/nootka/ToutVolume", "maxStreamVolume");
} }
int Tsound::currentVol() const int Tsound::currentVol() const
{ {
return QAndroidJniObject::callStaticMethod<jint>("net/sf/nootka/ToutVolume", "streamVolume"); return QJniObject::callStaticMethod<jint>("net/sf/nootka/ToutVolume", "streamVolume");
} }
void Tsound::setVol(int v) void Tsound::setVol(int v)
{ {
QAndroidJniObject::callStaticMethod<void>("net/sf/nootka/ToutVolume", "setStreamVolume", "(I)V", v); QJniObject::callStaticMethod<void>("net/sf/nootka/ToutVolume", "setStreamVolume", "(I)V", v);
} }
void Tsound::setTouchHandling(bool th) void Tsound::setTouchHandling(bool th)
...@@ -644,14 +642,14 @@ bool Tsound::eventFilter(QObject *watched, QEvent *event) ...@@ -644,14 +642,14 @@ bool Tsound::eventFilter(QObject *watched, QEvent *event)
if (m_volKeyTimer.elapsed() > 100) { if (m_volKeyTimer.elapsed() > 100) {
if (!m_tunerMode) { if (!m_tunerMode) {
if (playing()) { if (playing()) {
QAndroidJniObject::callStaticMethod<void>("net/sf/nootka/ToutVolume", "show"); QJniObject::callStaticMethod<void>("net/sf/nootka/ToutVolume", "show");
if (ke->key() == Qt::Key_VolumeDown) if (ke->key() == Qt::Key_VolumeDown)
m_currVol--; m_currVol--;
else else
m_currVol++; m_currVol++;
m_currVol = qBound(0, m_currVol, m_maxVol); m_currVol = qBound(0, m_currVol, m_maxVol);
setVol(m_currVol); setVol(m_currVol);
m_currVol = QAndroidJniObject::callStaticMethod<jint>("net/sf/nootka/ToutVolume", "streamVolume"); m_currVol = QJniObject::callStaticMethod<jint>("net/sf/nootka/ToutVolume", "streamVolume");
} else if (!GLOB->isExam()) } else if (!GLOB->isExam())
QTimer::singleShot(10, this, &Tsound::volumeKeyPressed); QTimer::singleShot(10, this, &Tsound::volumeKeyPressed);
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment