Commit 096ca427 authored by Sharaf Zaman's avatar Sharaf Zaman

[Android]: Changes to access default resources and plugins

parent a2f4b6c2
......@@ -64,7 +64,11 @@ set(krita_QRCS
qt5_add_resources(krita_SRCS ${krita_QRCS})
add_executable(krita ${krita_SRCS})
if (ANDROID)
add_library(krita SHARED ${krita_SRCS})
else()
add_executable(krita ${krita_SRCS})
endif()
target_link_libraries(krita
PRIVATE
kritaui
......
......@@ -64,7 +64,6 @@
#include <kis_tablet_support_win8.h>
#include <QLibrary>
#endif
#if defined HAVE_KCRASH
#include <kcrash.h>
#elif defined USE_DRMINGW
......@@ -121,9 +120,12 @@ void resetRotation()
}
} // namespace
#endif
#ifdef Q_OS_ANDROID
__attribute__ ((visibility ("default")))
#endif
extern "C" int main(int argc, char **argv)
{
// The global initialization of the random generator
qsrand(time(0));
bool runningInKDE = !qgetenv("KDE_FULL_SESSION").isEmpty();
......
......@@ -51,6 +51,10 @@ KoJsonTrader::KoJsonTrader()
d.cd("../../../");
searchDirs << d;
#endif
#ifdef Q_OS_ANDROID
appDir.cdUp();
#endif
searchDirs << appDir;
// help plugin trader find installed plugins when run from uninstalled tests
#ifdef CMAKE_INSTALL_PREFIX
......@@ -75,6 +79,11 @@ KoJsonTrader::KoJsonTrader()
#endif
QDir libDir(info.absoluteFilePath());
#ifdef Q_OS_ANDROID
libDir.cd("arm");
m_pluginPath = libDir.absolutePath();
break;
#else
// on many systems this will be the actual lib dir (and krita subdir contains plugins)
if (libDir.cd("kritaplugins")) {
m_pluginPath = libDir.absolutePath();
......@@ -95,6 +104,7 @@ KoJsonTrader::KoJsonTrader()
if (!m_pluginPath.isEmpty()) {
break;
}
#endif
}
}
......@@ -121,7 +131,12 @@ QList<QPluginLoader *> KoJsonTrader::query(const QString &servicetype, const QSt
QDirIterator dirIter(m_pluginPath, QDirIterator::Subdirectories);
while (dirIter.hasNext()) {
dirIter.next();
#ifdef Q_OS_ANDROID
// files starting with lib_krita are plugins, it is needed because of the loading rules in NDK
if (dirIter.fileInfo().isFile() && dirIter.fileName().startsWith("lib_krita")) {
#else
if (dirIter.fileInfo().isFile() && dirIter.fileName().startsWith("krita") && !dirIter.fileName().endsWith(".debug")) {
#endif
debugPlugin << dirIter.fileName();
QPluginLoader *loader = new QPluginLoader(dirIter.filePath());
QJsonObject json = loader->metaData().value("MetaData").toObject();
......
......@@ -115,8 +115,7 @@ protected:
* can be observed with a KoResourceServerObserver
*
* The \p Policy template parameter defines the way how the lifetime
* of a resource is handled. There are to predefined policies:
* of a resource is handled. There are two predefined policies:
*
* o PointerStoragePolicy --- usual pointers with ownership over
......
......@@ -127,10 +127,16 @@ QString getInstallationPrefix() {
appdir.setPath(correctedPath);
appdir.cdUp();
return appdir.canonicalPath();
#else
#ifdef Q_OS_ANDROID
// qApp->applicationDirPath() isn't writable and android system won't allow
// any files other than libraries
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/";
#else
return qApp->applicationDirPath() + "/../";
#endif
#endif
#endif
}
class Q_DECL_HIDDEN KoResourcePaths::Private {
......
......@@ -38,7 +38,7 @@ sed -i -- 's/make-options -j8/make-options -j4 VERBOSE=1/g' kdesrc-conf-android/
if [ -e $qt_android_libs ]
then
sed -E -i "s|-DCMAKE_PREFIX_PATH=.*?\\ |-DCMAKE_PREFIX_PATH=$QT_ANDROID- -DCMAKE_ANDROID_NDK=$CMAKE_ANDROID_NDK -DECM_ADDITIONAL_FIND_ROOT_PATH=$QT_ANDROID\;$CURDIR/kf5/kde/install -DANDROID_STL=c++_static -DCMAKE_TOOLCHAIN_FILE=$CURDIR/kf5/kde/install/share/ECM/toolchain/Android.cmake -DKCONFIG_USE_DBUS=OFF -DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL |g" kdesrc-conf-android/kdesrc-buildrc
sed -E -i "s|-DCMAKE_PREFIX_PATH=.*?\\ |-DCMAKE_PREFIX_PATH=$QT_ANDROID- -DCMAKE_ANDROID_NDK=$CMAKE_ANDROID_NDK -DECM_ADDITIONAL_FIND_ROOT_PATH=$QT_ANDROID\;$CURDIR/kf5/kde/install -DANDROID_STL=c++_static -DCMAKE_TOOLCHAIN_FILE=$CURDIR/kf5/kde/install/share/ECM/toolchain/Android.cmake -DKCONFIG_USE_DBUS=OFF -DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL -DANDROID_API_LEVEL=$ANDROID_API_LEVEL |g" kdesrc-conf-android/kdesrc-buildrc
sed -i -- "s/cxxflags.*/& -D__ANDROID_API__=$ANDROID_API_LEVEL/" kdesrc-conf-android/kdesrc-buildrc
else
echo "Qt Android libraries path doesn't exist. Exiting."
......
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