Skip to content
This repository has been archived by the owner on Jul 4, 2020. It is now read-only.

Commit

Permalink
Added android manifest and launcher icons.
Browse files Browse the repository at this point in the history
Do not use pkg-config when cross-compiling to Android.
Added a helper class to send toasts and dialogs to the user.
Added android compatibility on some headers.
  • Loading branch information
codestation committed May 17, 2014
1 parent 9c7c2bc commit ce9353e
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 0 deletions.
40 changes: 40 additions & 0 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.2.5" android:installLocation="auto" package="com.github.codestation.qcma" android:versionCode="1">
<application android:label="qcma" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:icon="@drawable/icon">
<activity android:screenOrientation="unspecified" android:label="@string/app_name" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:value="qcma" android:name="android.app.lib_name"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:value="default" android:name="android.app.repository"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --" android:name="android.app.bundle_local_qt_libs"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:value="-- %%USE_LOCAL_QT_LIBS%% --" android:name="android.app.use_local_qt_libs"/>
<meta-data android:value="/data/local/tmp/qt/" android:name="android.app.libs_prefix"/>
<meta-data android:value="-- %%INSERT_LOCAL_LIBS%% --" android:name="android.app.load_local_libs"/>
<meta-data android:value="-- %%INSERT_LOCAL_JARS%% --" android:name="android.app.load_local_jars"/>
<meta-data android:value="-- %%INSERT_INIT_CLASSES%% --" android:name="android.app.static_init_classes"/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<meta-data android:name="android.app.splash_screen" android:resource="@layout/splash"/>
<!-- Splash screen -->
</activity>
</application>
<uses-sdk android:targetSdkVersion="19" android:minSdkVersion="10"/>
<supports-screens android:normalScreens="true" android:smallScreens="true" android:largeScreens="true" android:anyDensity="true"/>
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
Binary file added android/res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-ldpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-xhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/res/drawable-xxhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions android/src/com/github/codestation/qcma/QcmaNotification.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.codestation.qcma;

import android.content.Context;
import android.content.DialogInterface;
import android.widget.Toast;
import android.app.AlertDialog;

public class QcmaNotification extends org.qtproject.qt5.android.bindings.QtActivity
{
private static QcmaNotification m_instance;

public QcmaNotification()
{
m_instance = this;
}

public static void showToast(String message)
{
Context context = m_instance.getApplicationContext();
Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
toast.show();
}

public static void showDialog(String message)
{
AlertDialog.Builder builder = new AlertDialog.Builder(m_instance);
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
builder.setMessage(message).setTitle("QCMA message");
AlertDialog dialog = builder.create();
}
}
45 changes: 45 additions & 0 deletions src/androidmessage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* QCMA: Cross-platform content manager assistant for the PS Vita
*
* Copyright (C) 2013 Codestation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "androidmessage.h"

#include <QtAndroidExtras/QAndroidJniObject>

AndroidMessage::AndroidMessage(QObject *parent) :
QObject(parent)
{
}

void AndroidMessage::showToast(const QString &message)
{
QAndroidJniObject javaMessage = QAndroidJniObject::fromString(message);
QAndroidJniObject::callStaticMethod<void>("com/github/codestation/qcma/QcmaNotification",
"showToast",
"(Ljava/lang/String;)V",
javaMessage.object<jstring>());
}

void AndroidMessage::showDialog(const QString &message)
{
QAndroidJniObject javaMessage = QAndroidJniObject::fromString(message);
QAndroidJniObject::callStaticMethod<void>("com/github/codestation/qcma/QcmaNotification",
"showDialog",
"(Ljava/lang/String;)V",
javaMessage.object<jstring>());
}
36 changes: 36 additions & 0 deletions src/androidmessage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* QCMA: Cross-platform content manager assistant for the PS Vita
*
* Copyright (C) 2013 Codestation
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ANDROIDMESSAGE_H
#define ANDROIDMESSAGE_H

#include <QObject>

class AndroidMessage : public QObject
{
Q_OBJECT
public:
explicit AndroidMessage(QObject *parent = 0);

public slots:
void showToast(const QString &message);
void showDialog(const QString &message);
};

#endif // ANDROIDMESSAGE_H
6 changes: 6 additions & 0 deletions src/cmautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
#ifdef Q_OS_WIN32
#include <windows.h>
#else
#ifndef __ANDROID__
#include <sys/statvfs.h>
#else
#include <sys/vfs.h>
#define statvfs statfs
#define fstatvfs fstatfs
#endif
#endif

bool getDiskSpace(const QString &dir, quint64 *free, quint64 *total)
Expand Down

0 comments on commit ce9353e

Please sign in to comment.