Commit 50e8f7bb authored by BogDan Vatra's avatar BogDan Vatra Committed by Daniel Teske

Android plugin

Change-Id: Iad58914f067a6ef6d3412ccd42f757d821e39e45
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@nokia.com>
parent cf4ecad4
......@@ -61,7 +61,7 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
if (!QDir::isAbsolutePath(path))
return QString::fromLatin1("%1/../Resources/%2")
.arg(QCoreApplication::applicationDirPath(), path);
#else
#elif !defined(Q_OS_ANDROID)
const QString pathInInstallDir =
QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists())
......@@ -77,6 +77,10 @@ QmlApplicationViewer::QmlApplicationViewer(QWidget *parent)
{
connect(engine(), SIGNAL(quit()), SLOT(close()));
setResizeMode(QDeclarativeView::SizeRootObjectToView);
#ifdef Q_OS_ANDROID
engine()->setBaseUrl(QUrl::fromLocalFile(QLatin1String("/")));
#endif
// Qt versions prior to 4.8.0 don't have QML/JS debugging services built in
#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800
#if !defined(NO_JSDEBUGGER)
......
......@@ -21,6 +21,28 @@ MAINPROFILEPWD = $$PWD
symbian {
isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg
isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
} else:android {
for(deploymentfolder, DEPLOYMENTFOLDERS) {
item = item$${deploymentfolder}
itemfiles = $${item}.files
$$itemfiles = $$eval($${deploymentfolder}.source)
itempath = $${item}.path
$$itempath = /assets/$$eval($${deploymentfolder}.target)
export($$itemfiles)
export($$itempath)
INSTALLS += $$item
}
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:win32 {
copyCommand =
for(deploymentfolder, DEPLOYMENTFOLDERS) {
......
<plugin name=\"Android\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\">
<vendor>KDE Necessitas</vendor>
<copyright>(C) 2010-2012 BogDan Vatra</copyright>
<license>
Commercial Usage
Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
GNU Lesser General Public License Usage
Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
</license>
<description>Support for deployment to and execution on Android Devices</description>
<category>Device Support</category>
<url>http://community.kde.org/Necessitas</url>
<dependencyList>
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"Debugger\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"Qt4ProjectManager\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddNewAVDDialog</class>
<widget class="QDialog" name="AddNewAVDDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>250</width>
<height>149</height>
</rect>
</property>
<property name="windowTitle">
<string>Create new AVD</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Target:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="targetComboBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>SD card size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="sizeSpinBox">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> MiB</string>
</property>
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>9999999</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddNewAVDDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>222</x>
<y>134</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>148</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddNewAVDDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>245</x>
<y>140</y>
</hint>
<hint type="destinationlabel">
<x>249</x>
<y>148</y>
</hint>
</hints>
</connection>
</connections>
</ui>
include(android_dependencies.pri)
LIBS *= -l$$qtLibraryName(Android)
TEMPLATE = lib
TARGET = Android
include(../../qtcreatorplugin.pri)
include(android_dependencies.pri)
QT += xml network
HEADERS += \
androidconstants.h \
androidconfigurations.h \
androidrunconfiguration.h \
androidruncontrol.h \
androidrunfactories.h \
androidsettingspage.h \
androidsettingswidget.h \
androidtoolchain.h \
androidpackageinstallationstep.h \
androidpackageinstallationfactory.h \
androidpackagecreationstep.h \
androidpackagecreationfactory.h \
androidpackagecreationwidget.h \
androiddeploystep.h \
androiddeploystepwidget.h \
androiddeploystepfactory.h \
androidglobal.h \
androidrunner.h \
androiddebugsupport.h \
androidqtversionfactory.h \
androidqtversion.h \
androiddeployconfiguration.h \
androidtarget.h \
androidtargetfactory.h \
androidcreatekeystorecertificate.h \
javaparser.h \
androidplugin.h
SOURCES += \
androidconfigurations.cpp \
androidrunconfiguration.cpp \
androidruncontrol.cpp \
androidrunfactories.cpp \
androidsettingspage.cpp \
androidsettingswidget.cpp \
androidtoolchain.cpp \
androidpackageinstallationstep.cpp \
androidpackageinstallationfactory.cpp \
androidpackagecreationstep.cpp \
androidpackagecreationfactory.cpp \
androidpackagecreationwidget.cpp \
androiddeploystep.cpp \
androiddeploystepwidget.cpp \
androiddeploystepfactory.cpp \
androidrunner.cpp \
androiddebugsupport.cpp \
androidqtversionfactory.cpp \
androidqtversion.cpp \
androiddeployconfiguration.cpp \
androidtarget.cpp \
androidtargetfactory.cpp \
androidcreatekeystorecertificate.cpp \
javaparser.cpp \
androidplugin.cpp
FORMS += \
androidsettingswidget.ui \
androidpackagecreationwidget.ui \
androiddeploystepwidget.ui \
addnewavddialog.ui \
androidcreatekeystorecertificate.ui
RESOURCES = android.qrc
DEFINES += QT_NO_CAST_TO_ASCII
DEFINES += ANDROID_LIBRARY
<RCC>
<qresource prefix="/android">
<file>images/QtAndroid.png</file>
</qresource>
</RCC>
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/debugger/debugger.pri)
include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../plugins/qt4projectmanager/qt4projectmanager.pri)
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 BogDan Vatra <bog_dan_ro@yahoo.com>
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANDROIDCONFIGURATIONS_H
#define ANDROIDCONFIGURATIONS_H
#include <QObject>
#include <QString>
#include <QVector>
#include <projectexplorer/abi.h>
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
namespace Android {
namespace Internal {
#ifdef Q_OS_LINUX
const QLatin1String ToolchainHost("linux-x86");
#else
# ifdef Q_OS_DARWIN
const QLatin1String ToolchainHost("darwin-x86");
# else
# ifdef Q_OS_WIN32
const QLatin1String ToolchainHost("windows");
# else
# warning No Android supported OSs found
const QLatin1String ToolchainHost("linux-x86");
# endif
# endif
#endif
class AndroidConfig
{
public:
AndroidConfig();
AndroidConfig(const QSettings &settings);
void save(QSettings &settings) const;
QString sdkLocation;
QString ndkLocation;
QString ndkToolchainVersion;
QString antLocation;
QString armGdbLocation;
QString armGdbserverLocation;
QString x86GdbLocation;
QString x86GdbserverLocation;
QString openJDKLocation;
QString keystoreLocation;
unsigned partitionSize;
};
struct AndroidDevice {
QString serialNumber;
QString cpuABI;
int sdk;
};
class AndroidConfigurations : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(AndroidConfigurations)
public:
static AndroidConfigurations &instance(QObject *parent = 0);
AndroidConfig config() const { return m_config; }
void setConfig(const AndroidConfig &config);
QStringList sdkTargets(int minApiLevel = 0) const;
QStringList ndkToolchainVersions() const;
QString adbToolPath() const;
QString androidToolPath() const;
QString antToolPath() const;
QString emulatorToolPath() const;
QString gccPath(ProjectExplorer::Abi::Architecture architecture) const;
QString gdbServerPath(ProjectExplorer::Abi::Architecture architecture) const;
QString gdbPath(ProjectExplorer::Abi::Architecture architecture) const;
QString openJDKPath() const;
QString keytoolPath() const;
QString jarsignerPath() const;
QString stripPath(ProjectExplorer::Abi::Architecture architecture) const;
QString readelfPath(ProjectExplorer::Abi::Architecture architecture) const;
QString getDeployDeviceSerialNumber(int *apiLevel) const;
bool createAVD(const QString &target, const QString &name, int sdcardSize) const;
bool removeAVD(const QString &name) const;
QVector<AndroidDevice> connectedDevices(int apiLevel = -1) const;
QVector<AndroidDevice> androidVirtualDevices() const;
QString startAVD(int *apiLevel, const QString &name = QString()) const;
QString bestMatch(const QString &targetAPI) const;
static QLatin1String toolchainPrefix(ProjectExplorer::Abi::Architecture architecture);
static QLatin1String toolsPrefix(ProjectExplorer::Abi::Architecture architecture);
signals:
void updated();
public slots:
bool createAVD(int minApiLevel = 0) const;
private:
QString toolPath(ProjectExplorer::Abi::Architecture architecture) const;
QString openJDKBinPath() const;
AndroidConfigurations(QObject *parent);
void load();
void save();
int getSDKVersion(const QString &device) const;
void updateAvailablePlatforms();
static AndroidConfigurations *m_instance;
AndroidConfig m_config;
QVector<int> m_availablePlatforms;
};
} // namespace Internal
} // namespace Android
#endif // ANDROIDCONFIGURATIONS_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 BogDan Vatra <bog_dan_ro@yahoo.com>
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANDROIDCONSTANTS_H
#define ANDROIDCONSTANTS_H
#include <QLatin1String>
namespace Android {
namespace Internal {
enum AndroidQemuStatus {
AndroidQemuStarting,
AndroidQemuFailedToStart,
AndroidQemuFinished,
AndroidQemuCrashed,
AndroidQemuUserReason
};
#define ANDROID_PREFIX "Qt4ProjectManager.AndroidRunConfiguration"
#ifdef Q_OS_WIN32
#define ANDROID_EXE_SUFFIX ".exe"
#define ANDROID_BAT_SUFFIX ".bat"
#else
#define ANDROID_EXE_SUFFIX ""
#define ANDROID_BAT_SUFFIX ""
#endif
static const QLatin1String ANDROID_RC_ID(ANDROID_PREFIX);
static const QLatin1String ANDROID_RC_ID_PREFIX(ANDROID_PREFIX ".");
static const QLatin1String AndroidArgumentsKey(ANDROID_PREFIX ".Arguments");
static const QLatin1String AndroidSimulatorPathKey(ANDROID_PREFIX ".Simulator");
static const QLatin1String AndroidDeviceIdKey(ANDROID_PREFIX ".DeviceId");
static const QLatin1String AndroidProFileKey(ANDROID_PREFIX ".ProFile");
static const QLatin1String AndroidExportedLocalDirsKey(ANDROID_PREFIX ".ExportedLocalDirs");
static const QLatin1String AndroidBaseEnvironmentBaseKey(ANDROID_PREFIX ".BaseEnvironmentBase");
static const QLatin1String AndroidUserEnvironmentChangesKey(ANDROID_PREFIX ".UserEnvironmentChanges");
static const QLatin1String AndroidUseRemoteGdbKey(ANDROID_PREFIX ".UseRemoteGdb");
} // namespace Internal
namespace Constants {
const char ANDROID_SETTINGS_ID[] = "ZZ.Android Configurations";
const char ANDROID_SETTINGS_CATEGORY[] = "X.Android";
const char ANDROID_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("Android", "Android");
const char ANDROID_SETTINGS_CATEGORY_ICON[] = ":/android/images/QtAndroid.png";
const char ANDROID_TOOLCHAIN_ID[] = "Qt4ProjectManager.ToolChain.Android";
const char ANDROIDQT[] = "Qt4ProjectManager.QtVersion.Android";
const char ANDROID_PLATFORM[] = "Android";
const char ANDROID_PLATFORM_TR[] = QT_TRANSLATE_NOOP("QtSupport", "Android");
}
} // namespace Android
#endif // ANDROIDCONSTANTS_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 BogDan Vatra <bog_dan_ro@yahoo.com>
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "androidcreatekeystorecertificate.h"
#include "androidconfigurations.h"
#include "ui_androidcreatekeystorecertificate.h"
#include <QFileDialog>
#include <QProcess>
#include <QMessageBox>
using namespace Android::Internal;
AndroidCreateKeystoreCertificate::AndroidCreateKeystoreCertificate(QWidget *parent) :
QDialog(parent),
ui(new Ui::AndroidCreateKeystoreCertificate)
{
ui->setupUi(this);
connect(ui->keystorePassLineEdit, SIGNAL(textChanged(QString)), this, SLOT(checkKeystorePassword()));
connect(ui->keystoreRetypePassLineEdit, SIGNAL(textChanged(QString)), this, SLOT(checkKeystorePassword()));
connect(ui->certificatePassLineEdit, SIGNAL(textChanged(QString)), this, SLOT(checkCertificatePassword()));
connect(ui->certificateRetypePassLineEdit, SIGNAL(textChanged(QString)), this, SLOT(checkCertificatePassword()));
}
AndroidCreateKeystoreCertificate::~AndroidCreateKeystoreCertificate()
{
delete ui;
}
QString AndroidCreateKeystoreCertificate::keystoreFilePath()
{
return m_keystoreFilePath;
}
QString AndroidCreateKeystoreCertificate::keystorePassword()
{
return ui->keystorePassLineEdit->text();
}
QString AndroidCreateKeystoreCertificate::certificateAlias()
{
return ui->aliasNameLineEdit->text();
}
QString AndroidCreateKeystoreCertificate::certificatePassword()
{
return ui->certificatePassLineEdit->text();
}
AndroidCreateKeystoreCertificate::PasswordStatus AndroidCreateKeystoreCertificate::checkKeystorePassword()
{
if (ui->keystorePassLineEdit->text().length() < 6) {
ui->keystorePassInfoLabel->setText(tr("<span style=\" color:#ff0000;\">Password is too short</span>"));
return Invalid;
}
if (ui->keystorePassLineEdit->text() != ui->keystoreRetypePassLineEdit->text()) {
ui->keystorePassInfoLabel->setText(tr("<span style=\" color:#ff0000;\">Passwords don't match</span>"));
return NoMatch;
}
ui->keystorePassInfoLabel->setText(tr("<span style=\" color:#00ff00;\">Password is ok</span>"));
return Match;
}
AndroidCreateKeystoreCertificate::PasswordStatus AndroidCreateKeystoreCertificate::checkCertificatePassword()
{
if (ui->certificatePassLineEdit->text().length() < 6) {
ui->certificatePassInfoLabel->setText(tr("<span style=\" color:#ff0000;\">Password is too short</span>"));
return Invalid;
}
if (ui->certificatePassLineEdit->text() != ui->certificateRetypePassLineEdit->text()) {
ui->certificatePassInfoLabel->setText(tr("<span style=\" color:#ff0000;\">Passwords don't match</span>"));
return NoMatch;
}
ui->certificatePassInfoLabel->setText(tr("<span style=\" color:#00ff00;\">Password is ok</span>"));
return Match;
}