Commit d7f96e32 authored by Daniel Teske's avatar Daniel Teske

Android Deploy Options: Clean up ui

Task-number: QTCREATORBUG-9208

Change-Id: I1b1864908a24af3cd7c576831656267a6390b583
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent e2591965
......@@ -83,10 +83,9 @@ void AndroidDeployStep::ctor()
setDefaultDisplayName(tr("Deploy to Android device"));
m_deployAction = NoDeploy;
m_useLocalQtLibs = false;
if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target()->kit()))
if (qt->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0))
m_useLocalQtLibs = true;
m_deployAction = BundleLibraries;
}
bool AndroidDeployStep::init()
......@@ -118,7 +117,6 @@ bool AndroidDeployStep::init()
m_apkPathDebug = AndroidManager::apkPath(target(), AndroidManager::DebugBuild).toString();
m_apkPathRelease = AndroidManager::apkPath(target(), AndroidManager::ReleaseBuildSigned).toString();
m_buildDirectory = static_cast<Qt4Project *>(target()->project())->rootQt4ProjectNode()->buildDir();
m_runQASIPackagePath = m_QASIPackagePath;
m_runDeployAction = m_deployAction;
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
if (!tc || tc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) {
......@@ -148,15 +146,15 @@ AndroidDeployStep::AndroidDeployAction AndroidDeployStep::deployAction()
return m_deployAction;
}
bool AndroidDeployStep::useLocalQtLibs()
{
return m_useLocalQtLibs;
}
bool AndroidDeployStep::fromMap(const QVariantMap &map)
{
m_useLocalQtLibs = map.value(QLatin1String(USE_LOCAL_QT_KEY), false).toBool();
m_deployAction = AndroidDeployAction(map.value(QLatin1String(DEPLOY_ACTION_KEY), NoDeploy).toInt());
QVariant useLocalQt = map.value(QLatin1String(USE_LOCAL_QT_KEY));
if (useLocalQt.isValid()) { // old settings
if (useLocalQt.toBool() && m_deployAction == NoDeploy)
m_deployAction = BundleLibraries;
}
if (m_deployAction == InstallQASI)
m_deployAction = NoDeploy;
return ProjectExplorer::BuildStep::fromMap(map);
......@@ -165,7 +163,6 @@ bool AndroidDeployStep::fromMap(const QVariantMap &map)
QVariantMap AndroidDeployStep::toMap() const
{
QVariantMap map = ProjectExplorer::BuildStep::toMap();
map.insert(QLatin1String(USE_LOCAL_QT_KEY), m_useLocalQtLibs);
map.insert(QLatin1String(DEPLOY_ACTION_KEY), m_deployAction);
return map;
}
......@@ -184,7 +181,7 @@ void AndroidDeployStep::cleanLibsOnDevice()
QProcess *process = new QProcess(this);
QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber);
arguments << QLatin1String("shell") << QLatin1String("rm") << QLatin1String("-r") << QLatin1String("/data/local/tmp/qt");
connect(process, SIGNAL(finished(int)), this, SLOT(cleanLibsFinished()));
connect(process, SIGNAL(finished(int)), this, SLOT(processFinished()));
const QString adb = AndroidConfigurations::instance().adbToolPath().toString();
Core::MessageManager::instance()->printToOutputPane(adb + QLatin1String(" ")
+ arguments.join(QLatin1String(" ")),
......@@ -194,7 +191,7 @@ void AndroidDeployStep::cleanLibsOnDevice()
delete process;
}
void AndroidDeployStep::cleanLibsFinished()
void AndroidDeployStep::processFinished()
{
QProcess *process = qobject_cast<QProcess *>(sender());
QTC_ASSERT(process, return);
......@@ -204,22 +201,35 @@ void AndroidDeployStep::cleanLibsFinished()
process->deleteLater();
}
void AndroidDeployStep::setDeployAction(AndroidDeployStep::AndroidDeployAction deploy)
void AndroidDeployStep::installQASIPackage(const QString &packagePath)
{
m_deployAction = deploy;
const QString targetArch = AndroidManager::targetArch(target());
const QString targetSDK = AndroidManager::targetSDK(target());
int deviceAPILevel = targetSDK.mid(targetSDK.indexOf(QLatin1Char('-')) + 1).toInt();
QString deviceSerialNumber = AndroidConfigurations::instance().getDeployDeviceSerialNumber(&deviceAPILevel, targetArch);
if (!deviceSerialNumber.length()) {
Core::MessageManager::instance()->printToOutputPane(tr("Could not run adb. No device found."), Core::MessageManager::NoModeSwitch);
return;
}
AndroidManager::updateDeploymentSettings(target());
}
QProcess *process = new QProcess(this);
QStringList arguments = AndroidDeviceInfo::adbSelector(deviceSerialNumber);
arguments << QLatin1String("install") << QLatin1String("-r ") << packagePath;
void AndroidDeployStep::setDeployQASIPackagePath(const QString &package)
{
m_QASIPackagePath = package;
setDeployAction(InstallQASI);
connect(process, SIGNAL(finished(int)), this, SLOT(processFinished()));
const QString adb = AndroidConfigurations::instance().adbToolPath().toString();
Core::MessageManager::instance()->printToOutputPane(adb + QLatin1String(" ")
+ arguments.join(QLatin1String(" ")),
Core::MessageManager::NoModeSwitch);
process->start(adb, arguments);
if (!process->waitForFinished(500))
delete process;
}
void AndroidDeployStep::setUseLocalQtLibs(bool useLocal)
void AndroidDeployStep::setDeployAction(AndroidDeployStep::AndroidDeployAction deploy)
{
m_useLocalQtLibs = useLocal;
m_deployAction = deploy;
AndroidManager::updateDeploymentSettings(target());
}
......@@ -453,17 +463,6 @@ bool AndroidDeployStep::deployPackage()
AndroidPackageCreationStep::removeDirectory(tempPath);
}
if (m_runDeployAction == InstallQASI) {
if (!runCommand(deployProc, AndroidConfigurations::instance().adbToolPath().toString(),
AndroidDeviceInfo::adbSelector(m_deviceSerialNumber)
<< QLatin1String("install") << QLatin1String("-r ") << m_runQASIPackagePath)) {
raiseError(tr("Qt Android smart installer installation failed"));
disconnect(deployProc, 0, this, 0);
deployProc->deleteLater();
return false;
}
emit resetDelopyAction();
}
deployProc->setWorkingDirectory(m_androidDirPath.toString());
writeOutput(tr("Installing package onto %1.").arg(m_deviceSerialNumber));
......
......@@ -75,9 +75,10 @@ class AndroidDeployStep : public ProjectExplorer::BuildStep
public:
enum AndroidDeployAction
{
NoDeploy,
NoDeploy, // use ministro
DeployLocal,
InstallQASI
InstallQASI, // unused old value
BundleLibraries
};
public:
......@@ -89,28 +90,25 @@ public:
int deviceAPILevel();
AndroidDeployAction deployAction();
bool useLocalQtLibs();
bool fromMap(const QVariantMap &map);
QVariantMap toMap() const;
void cleanLibsOnDevice();
void installQASIPackage(const QString &packagePath);
public slots:
void setDeployAction(AndroidDeployAction deploy);
void setDeployQASIPackagePath(const QString &package);
void setUseLocalQtLibs(bool useLocal);
signals:
void done();
void error();
void resetDelopyAction();
private slots:
bool deployPackage();
void handleBuildOutput();
void handleBuildError();
void cleanLibsFinished();
void processFinished();
private:
AndroidDeployStep(ProjectExplorer::BuildStepList *bc,
......@@ -140,7 +138,6 @@ private:
QString m_QASIPackagePath;
AndroidDeployAction m_deployAction;
bool m_useLocalQtLibs;
// members to transfer data from init() to run
QString m_packageName;
......
......@@ -47,21 +47,26 @@ AndroidDeployStepWidget::AndroidDeployStepWidget(AndroidDeployStep *step) :
{
ui->setupUi(this);
ui->useLocalQtLibs->setChecked(m_step->useLocalQtLibs());
switch (m_step->deployAction()) {
case AndroidDeployStep::NoDeploy:
ui->ministroOption->setChecked(true);
break;
case AndroidDeployStep::DeployLocal:
ui->deployQtLibs->setChecked(true);
ui->temporaryQtOption->setChecked(true);
break;
case AndroidDeployStep::BundleLibraries:
ui->bundleQtOption->setChecked(true);
break;
default:
ui->devicesQtLibs->setChecked(true);
ui->ministroOption->setChecked(true);
break;
}
connect(m_step, SIGNAL(resetDelopyAction()), SLOT(resetAction()));
connect(ui->devicesQtLibs, SIGNAL(clicked()), SLOT(resetAction()));
connect(ui->deployQtLibs, SIGNAL(clicked()), SLOT(setDeployLocalQtLibs()));
connect(ui->ministroOption, SIGNAL(clicked()), SLOT(setMinistro()));
connect(ui->temporaryQtOption, SIGNAL(clicked()), SLOT(setDeployLocalQtLibs()));
connect(ui->bundleQtOption, SIGNAL(clicked()), SLOT(setBundleQtLibs()));
connect(ui->chooseButton, SIGNAL(clicked()), SLOT(setQASIPackagePath()));
connect(ui->useLocalQtLibs, SIGNAL(stateChanged(int)), SLOT(useLocalQtLibsStateChanged(int)));
connect(ui->cleanLibsPushButton, SIGNAL(clicked()), SLOT(cleanLibsOnDevice()));
}
......@@ -80,9 +85,8 @@ QString AndroidDeployStepWidget::summaryText() const
return displayName();
}
void AndroidDeployStepWidget::resetAction()
void AndroidDeployStepWidget::setMinistro()
{
ui->devicesQtLibs->setChecked(true);
m_step->setDeployAction(AndroidDeployStep::NoDeploy);
}
......@@ -91,19 +95,20 @@ void AndroidDeployStepWidget::setDeployLocalQtLibs()
m_step->setDeployAction(AndroidDeployStep::DeployLocal);
}
void AndroidDeployStepWidget::setBundleQtLibs()
{
m_step->setDeployAction(AndroidDeployStep::BundleLibraries);
}
void AndroidDeployStepWidget::setQASIPackagePath()
{
QString packagePath =
QFileDialog::getOpenFileName(this, tr("Qt Android Smart Installer"),
QDir::homePath(), tr("Android package (*.apk)"));
if (packagePath.length())
m_step->setDeployQASIPackagePath(packagePath);
if (!packagePath.isEmpty())
m_step->installQASIPackage(packagePath);
}
void AndroidDeployStepWidget::useLocalQtLibsStateChanged(int state)
{
m_step->setUseLocalQtLibs(state == Qt::Checked);
}
void AndroidDeployStepWidget::cleanLibsOnDevice()
{
......
......@@ -49,10 +49,11 @@ public:
~AndroidDeployStepWidget();
private slots:
void resetAction();
void setMinistro();
void setDeployLocalQtLibs();
void setBundleQtLibs();
void setQASIPackagePath();
void useLocalQtLibsStateChanged(int);
void cleanLibsOnDevice();
private:
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>145</height>
<width>678</width>
<height>155</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -19,138 +19,88 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="devicesQtLibs">
<property name="toolTip">
<string>Use Qt libraries from device</string>
</property>
<property name="text">
<string>Use Qt libraries from device</string>
</property>
<property name="checked">
<bool>true</bool>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Qt Deployment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="ministroOption">
<property name="toolTip">
<string>Use the external Ministro application to download and maintain Qt libraries.</string>
</property>
<property name="text">
<string>Use Ministro service to install Qt</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="temporaryQtOption">
<property name="toolTip">
<string>Push local Qt libraries to device. You must have Qt libraries compiled for that platform.
The APK will not be usable on any other device.</string>
</property>
<property name="text">
<string>Deploy local Qt libraries to temporary directory</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bundleQtOption">
<property name="toolTip">
<string>Creates a standalone APK.</string>
</property>
<property name="text">
<string>Bundle Qt libraries in APK</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="deployQtLibs">
<property name="toolTip">
<string>Push local Qt libraries to device.
You must have Qt libraries compiled for that platform</string>
</property>
<property name="text">
<string>Deploy local Qt libraries</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useLocalQtLibs">
<property name="toolTip">
<string>Check this option to force the application to use local Qt libraries instead of system libraries.</string>
</property>
<property name="text">
<string>Use local Qt libraries</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cleanLibsPushButton">
<property name="text">
<string>Clean Libs on Device</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="installQASI">
<property name="toolTip">
<string>Choose and install Ministro system wide Qt shared libraries.
This option is useful when you want to try your application on devices which don't have Android Market (e.g. Android Emulator).</string>
</property>
<property name="text">
<string>Install Ministro, system-wide Qt shared libraries installer</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="chooseButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Choose APK</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>41</height>
</size>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Advanced Actions</string>
</property>
</spacer>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="cleanLibsPushButton">
<property name="text">
<string>Clean Temporary Libraries Directory on Device</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="chooseButton">
<property name="text">
<string>Install Ministro from APK</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>installQASI</sender>
<signal>toggled(bool)</signal>
<receiver>chooseButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>119</x>
<y>68</y>
</hint>
<hint type="destinationlabel">
<x>272</x>
<y>64</y>
</hint>
</hints>
</connection>
<connection>
<sender>deployQtLibs</sender>
<signal>clicked(bool)</signal>
<receiver>useLocalQtLibs</receiver>
<slot>setChecked(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>138</x>
<y>43</y>
</hint>
<hint type="destinationlabel">
<x>343</x>
<y>44</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>
......@@ -319,8 +319,7 @@ bool AndroidManager::bundleQt(ProjectExplorer::Target *target)
AndroidRunConfiguration *androidRunConfiguration = qobject_cast<AndroidRunConfiguration *>(runConfiguration);
if (androidRunConfiguration != 0) {
AndroidDeployStep *deployStep = androidRunConfiguration->deployStep();
return deployStep->deployAction() == AndroidDeployStep::NoDeploy
&& deployStep->useLocalQtLibs();
return deployStep->deployAction() == AndroidDeployStep::BundleLibraries;
}
return false;
......@@ -340,9 +339,10 @@ bool AndroidManager::updateDeploymentSettings(ProjectExplorer::Target *target)
return false;
AndroidDeployStep *deployStep = androidRunConfiguration->deployStep();
bool useLocalLibs = deployStep->useLocalQtLibs();
bool deployQtLibs = deployStep->deployAction() != AndroidDeployStep::NoDeploy;
bool bundleQtLibs = useLocalLibs && !deployQtLibs;
AndroidDeployStep::AndroidDeployAction deployAction = deployStep->deployAction();
bool useLocalLibs = deployAction == AndroidDeployStep::DeployLocal
|| deployAction == AndroidDeployStep::BundleLibraries;
bool bundleQtLibs = deployAction == AndroidDeployStep::BundleLibraries;
QDomDocument doc;
if (!openManifest(target, doc))
......
......@@ -234,7 +234,8 @@ void AndroidPackageCreationWidget::setQtLibs(QModelIndex, QModelIndex)
{
AndroidManager::setQtLibs(m_step->target(), m_qtLibsModel->checkedItems());
AndroidDeployStep * const deployStep = AndroidGlobal::buildStep<AndroidDeployStep>(m_step->target()->activeDeployConfiguration());
if (deployStep->useLocalQtLibs())
if (deployStep->deployAction() == AndroidDeployStep::DeployLocal
|| deployStep->deployAction() == AndroidDeployStep::BundleLibraries)
AndroidManager::updateDeploymentSettings(m_step->target());
}
......@@ -242,7 +243,8 @@ void AndroidPackageCreationWidget::setPrebundledLibs(QModelIndex, QModelIndex)
{
AndroidManager::setPrebundledLibs(m_step->target(), m_prebundledLibs->checkedItems());
AndroidDeployStep * const deployStep = AndroidGlobal::buildStep<AndroidDeployStep>(m_step->target()->activeDeployConfiguration());
if (deployStep->useLocalQtLibs())
if (deployStep->deployAction() == AndroidDeployStep::DeployLocal
|| deployStep->deployAction() == AndroidDeployStep::BundleLibraries)
AndroidManager::updateDeploymentSettings(m_step->target());
}
......
......@@ -74,7 +74,9 @@ AndroidRunner::AndroidRunner(QObject *parent,
}
ProjectExplorer::Target *target = runConfig->target();
AndroidDeployStep *ds = runConfig->deployStep();
if ((m_useLocalQtLibs = ds->useLocalQtLibs())) {
m_useLocalQtLibs = ds->deployAction() == AndroidDeployStep::DeployLocal
|| ds->deployAction() == AndroidDeployStep::BundleLibraries;
if (m_useLocalQtLibs) {
m_localLibs = AndroidManager::loadLocalLibs(target, ds->deviceAPILevel());
m_localJars = AndroidManager::loadLocalJars(target, ds->deviceAPILevel());
m_localJarsInitClasses = AndroidManager::loadLocalJarsInitClasses(target, ds->deviceAPILevel());
......
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