Commit 845271e9 authored by Jake Petroules's avatar Jake Petroules

Android: turn "use Ministro" into a checkbox

Ministro is an advanced deployment option which requires knowledge of
how to set up and maintain a Ministro repository. Place it with the
other advanced options instead of as a checkbox alongside the normal
deployent mechanism which is used by default and probably in the vast
majority of cases, in order to reduce cognitive load on the user and
clean up the UI a bit (since two options in a radio selection doesn't
make much sense).

Task-number: QTBUG-62995
Change-Id: If33b3c73db4fcc66717dd4ff0f7923f0250e8418
Reviewed-by: default avatarBogDan Vatra <bogdan@kdab.com>
parent 9bd0fcbe
......@@ -58,13 +58,6 @@
For more information about options that you have for running applications,
see \l {Specifying Run Settings for Android Devices}.
\section1 Creating Distributable APK Packages
To copy Qt libraries and files to the project directory and to bundle them
as part of the APK, select the \uicontrol {Bundle Qt libraries in APK} option.
\note Android 5 devices support only this option.
\section1 Using Ministro to Install Qt Libraries
To minimize the size of your APK, you can package the application with an
......
......@@ -61,10 +61,10 @@ namespace Android {
using namespace Internal;
const QVersionNumber gradleScriptRevokedSdkVersion(25, 3, 0);
const char DeployActionKey[] = "Qt4ProjectManager.AndroidDeployQtStep.DeployQtAction";
const char KeystoreLocationKey[] = "KeystoreLocation";
const char BuildTargetSdkKey[] = "BuildTargetSdk";
const char VerboseOutputKey[] = "VerboseOutput";
const char UseMinistroKey[] = "UseMinistro";
class PasswordInputDialog : public QDialog {
public:
......@@ -101,9 +101,9 @@ AndroidBuildApkStep::AndroidBuildApkStep(ProjectExplorer::BuildStepList *parent,
AndroidBuildApkStep::AndroidBuildApkStep(ProjectExplorer::BuildStepList *parent,
AndroidBuildApkStep *other)
: ProjectExplorer::AbstractProcessStep(parent, other),
m_deployAction(other->deployAction()),
m_signPackage(other->signPackage()),
m_verbose(other->m_verbose),
m_useMinistro(other->useMinistro()),
m_openPackageLocation(other->m_openPackageLocation),
// leave m_openPackageLocationForRun at false
m_buildTargetSdk(other->m_buildTargetSdk)
......@@ -230,25 +230,23 @@ bool AndroidBuildApkStep::verifyCertificatePassword()
bool AndroidBuildApkStep::fromMap(const QVariantMap &map)
{
m_deployAction = AndroidDeployAction(map.value(DeployActionKey, BundleLibrariesDeployment).toInt());
if (m_deployAction > BundleLibrariesDeployment)
m_deployAction = BundleLibrariesDeployment; // BundleLibrariesDeployment used to be 2
m_keystorePath = Utils::FileName::fromString(map.value(KeystoreLocationKey).toString());
m_signPackage = false; // don't restore this
m_buildTargetSdk = map.value(BuildTargetSdkKey).toString();
if (m_buildTargetSdk.isEmpty())
m_buildTargetSdk = AndroidConfig::apiLevelNameFor(AndroidConfigurations::currentConfig().highestAndroidSdk());
m_verbose = map.value(VerboseOutputKey).toBool();
m_useMinistro = map.value(UseMinistroKey).toBool();
return ProjectExplorer::BuildStep::fromMap(map);
}
QVariantMap AndroidBuildApkStep::toMap() const
{
QVariantMap map = ProjectExplorer::AbstractProcessStep::toMap();
map.insert(DeployActionKey, m_deployAction);
map.insert(KeystoreLocationKey, m_keystorePath.toString());
map.insert(BuildTargetSdkKey, m_buildTargetSdk);
map.insert(VerboseOutputKey, m_verbose);
map.insert(UseMinistroKey, m_useMinistro);
return map;
}
......@@ -268,16 +266,6 @@ void AndroidBuildApkStep::setBuildTargetSdk(const QString &sdk)
AndroidManager::updateGradleProperties(target());
}
AndroidBuildApkStep::AndroidDeployAction AndroidBuildApkStep::deployAction() const
{
return m_deployAction;
}
void AndroidBuildApkStep::setDeployAction(AndroidDeployAction deploy)
{
m_deployAction = deploy;
}
void AndroidBuildApkStep::setKeystorePath(const Utils::FileName &path)
{
m_keystorePath = path;
......@@ -325,6 +313,16 @@ void AndroidBuildApkStep::setVerboseOutput(bool verbose)
m_verbose = verbose;
}
bool AndroidBuildApkStep::useMinistro() const
{
return m_useMinistro;
}
void AndroidBuildApkStep::setUseMinistro(bool useMinistro)
{
m_useMinistro = useMinistro;
}
bool AndroidBuildApkStep::addDebugger() const
{
return m_addDebugger;
......
......@@ -41,17 +41,9 @@ class ANDROID_EXPORT AndroidBuildApkStep : public ProjectExplorer::AbstractProce
public:
AndroidBuildApkStep(ProjectExplorer::BuildStepList *bc, const Core::Id id);
enum AndroidDeployAction
{
MinistroDeployment, // use ministro
BundleLibrariesDeployment
};
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
AndroidDeployAction deployAction() const;
// signing
Utils::FileName keystorePath();
void setKeystorePath(const Utils::FileName &path);
......@@ -69,6 +61,9 @@ public:
bool verboseOutput() const;
void setVerboseOutput(bool verbose);
bool useMinistro() const;
void setUseMinistro(bool b);
bool addDebugger() const;
void setAddDebugger(bool debug);
......@@ -76,7 +71,6 @@ public:
void setBuildTargetSdk(const QString &sdk);
virtual Utils::FileName androidPackageSourceDir() const = 0;
void setDeployAction(AndroidDeployAction deploy);
protected:
Q_INVOKABLE void showInGraphicalShell();
......@@ -92,9 +86,9 @@ protected:
bool verifyCertificatePassword();
protected:
AndroidDeployAction m_deployAction = BundleLibrariesDeployment;
bool m_signPackage = false;
bool m_verbose = false;
bool m_useMinistro = false;
bool m_openPackageLocation = false;
bool m_openPackageLocationForRun = false;
bool m_addDebugger = true;
......
......@@ -62,18 +62,9 @@ AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step)
m_ui->targetSDKComboBox->addItems(targets);
m_ui->targetSDKComboBox->setCurrentIndex(targets.indexOf(AndroidManager::buildTargetSDK(step->target())));
// deployment option
switch (m_step->deployAction()) {
case AndroidBuildApkStep::MinistroDeployment:
// Ministro
if (m_step->useMinistro())
m_ui->ministroOption->setChecked(true);
break;
case AndroidBuildApkStep::BundleLibrariesDeployment:
m_ui->bundleQtOption->setChecked(true);
break;
default:
// can't happen
break;
}
// signing
m_ui->signPackageCheckBox->setChecked(m_step->signPackage());
......@@ -99,9 +90,7 @@ AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step)
// deployment options
connect(m_ui->ministroOption, &QAbstractButton::clicked,
this, &AndroidBuildApkWidget::setMinistro);
connect(m_ui->bundleQtOption, &QAbstractButton::clicked,
this, &AndroidBuildApkWidget::setBundleQtLibs);
m_step, &AndroidBuildApkStep::setUseMinistro);
connect(m_ui->openPackageLocationCheckBox, &QAbstractButton::toggled,
this, &AndroidBuildApkWidget::openPackageLocationCheckBoxToggled);
......@@ -150,16 +139,6 @@ void AndroidBuildApkWidget::setTargetSdk(const QString &sdk)
m_step->setBuildTargetSdk(sdk);
}
void AndroidBuildApkWidget::setMinistro()
{
m_step->setDeployAction(AndroidBuildApkStep::MinistroDeployment);
}
void AndroidBuildApkWidget::setBundleQtLibs()
{
m_step->setDeployAction(AndroidBuildApkStep::BundleLibrariesDeployment);
}
void AndroidBuildApkWidget::signPackageCheckBoxToggled(bool checked)
{
m_ui->certificatesAliasComboBox->setEnabled(checked);
......
......@@ -51,8 +51,6 @@ public:
private:
void setTargetSdk(const QString &sdk);
void setMinistro();
void setBundleQtLibs();
void createKeyStore();
void certificatesAliasComboBoxCurrentIndexChanged(const QString &alias);
void certificatesAliasComboBoxActivated(const QString &alias);
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>641</width>
<height>331</height>
<height>349</height>
</rect>
</property>
<property name="windowTitle">
......@@ -139,7 +139,7 @@
</layout>
</widget>
</item>
<item row="2" column="1">
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="advancedActions">
<property name="title">
<string>Advanced Actions</string>
......@@ -152,13 +152,6 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="verboseOutputCheckBox">
<property name="text">
<string>Verbose output</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="addDebuggerCheckBox">
<property name="enabled">
......@@ -172,35 +165,20 @@
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="qtDeployment">
<property name="title">
<string>Qt Deployment</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="ministroOption">
<property name="toolTip">
<string>Uses the external Ministro application to download and maintain Qt libraries.</string>
</property>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="verboseOutputCheckBox">
<property name="text">
<string>Use Ministro service to install Qt</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Verbose output</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bundleQtOption">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="ministroOption">
<property name="toolTip">
<string>Creates a standalone APK.</string>
<string>Uses the external Ministro application to download and maintain Qt libraries.</string>
</property>
<property name="text">
<string>Bundle Qt libraries in APK</string>
<string>Use Ministro service to install Qt</string>
</property>
</widget>
</item>
......
......@@ -223,15 +223,9 @@ bool AndroidDeployQtStep::init(QList<const BuildStep *> &earlierSteps)
return false;
}
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, tmp.toString());
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--deployment"));
switch (androidBuildApkStep->deployAction()) {
case AndroidBuildApkStep::MinistroDeployment:
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("ministro"));
break;
case AndroidBuildApkStep::BundleLibrariesDeployment:
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("bundled"));
break;
if (androidBuildApkStep->useMinistro()) {
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--deployment"));
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("ministro"));
}
Utils::QtcProcess::addArg(&m_androiddeployqtArgs, QLatin1String("--gradle"));
......
......@@ -224,7 +224,7 @@ bool AndroidManager::bundleQt(ProjectExplorer::Target *target)
AndroidBuildApkStep *androidBuildApkStep
= AndroidGlobal::buildStep<AndroidBuildApkStep>(target->activeBuildConfiguration());
if (androidBuildApkStep)
return androidBuildApkStep->deployAction() == AndroidBuildApkStep::BundleLibrariesDeployment;
return !androidBuildApkStep->useMinistro();
return false;
}
......
......@@ -135,12 +135,6 @@ bool QmakeAndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps)
if (Utils::HostOsInfo::isWindowsHost())
command += ".exe";
QString deploymentMethod;
if (m_deployAction == MinistroDeployment)
deploymentMethod = "ministro";
else if (m_deployAction == BundleLibrariesDeployment)
deploymentMethod = "bundled";
ProjectExplorer::BuildConfiguration *bc = buildConfiguration();
QString outputDir = bc->buildDirectory().appendPath(Constants::ANDROID_BUILDDIRECTORY).toString();
......@@ -165,7 +159,6 @@ bool QmakeAndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps)
QStringList arguments = {"--input", inputFile,
"--output", outputDir,
"--deployment", deploymentMethod,
"--android-platform", AndroidManager::buildTargetSDK(target()),
"--jdk", AndroidConfigurations::currentConfig().openJDKLocation().toString()};
......@@ -174,6 +167,9 @@ bool QmakeAndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps)
arguments << "--gradle";
if (m_useMinistro)
arguments << "--deployment" << "ministro";
QStringList argumentsPasswordConcealed = arguments;
if (m_signPackage) {
......
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