Commit 37edb06c authored by Daniel Teske's avatar Daniel Teske

Android Manifest Editor: Fix various issues around min/target sdk level

Change-Id: I9b9239055301296b572e0c36c40f179b0e98c67d
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
parent 0e4deaba
...@@ -504,6 +504,9 @@ void AndroidManifestEditorWidget::resizeEvent(QResizeEvent *event) ...@@ -504,6 +504,9 @@ void AndroidManifestEditorWidget::resizeEvent(QResizeEvent *event)
bool AndroidManifestEditorWidget::open(QString *errorString, const QString &fileName, const QString &realFileName) bool AndroidManifestEditorWidget::open(QString *errorString, const QString &fileName, const QString &realFileName)
{ {
bool result = PlainTextEditorWidget::open(errorString, fileName, realFileName); bool result = PlainTextEditorWidget::open(errorString, fileName, realFileName);
updateSdkVersions();
if (!result) if (!result)
return result; return result;
...@@ -521,7 +524,6 @@ bool AndroidManifestEditorWidget::open(QString *errorString, const QString &file ...@@ -521,7 +524,6 @@ bool AndroidManifestEditorWidget::open(QString *errorString, const QString &file
} }
// some error occured // some error occured
updateInfoBar(error, errorLine, errorColumn); updateInfoBar(error, errorLine, errorColumn);
updateSdkVersions();
setActivePage(Source); setActivePage(Source);
return true; return true;
...@@ -697,7 +699,8 @@ void AndroidManifestEditorWidget::updateInfoBar() ...@@ -697,7 +699,8 @@ void AndroidManifestEditorWidget::updateInfoBar()
void AndroidManifestEditorWidget::updateSdkVersions() void AndroidManifestEditorWidget::updateSdkVersions()
{ {
const QString docPath(static_cast<AndroidManifestDocument *>(editor()->document())->filePath()); const QString docPath(static_cast<AndroidManifestDocument *>(editor()->document())->filePath());
QPair<int, int> apiLevels = AndroidManager::apiLevelRange(androidProject(docPath)->activeTarget()); Project *project = androidProject(docPath);
QPair<int, int> apiLevels = AndroidManager::apiLevelRange(project ? project->activeTarget() : 0);
for (int i = apiLevels.first; i < apiLevels.second + 1; ++i) for (int i = apiLevels.first; i < apiLevels.second + 1; ++i)
m_androidMinSdkVersion->addItem(tr("API %1: %2") m_androidMinSdkVersion->addItem(tr("API %1: %2")
.arg(i) .arg(i)
...@@ -865,6 +868,16 @@ void setUsesSdk(QDomDocument &doc, QDomElement &manifest, int minimumSdk, int ta ...@@ -865,6 +868,16 @@ void setUsesSdk(QDomDocument &doc, QDomElement &manifest, int minimumSdk, int ta
} }
} }
int extractVersion(const QString &string)
{
if (!string.startsWith(QLatin1String("API")))
return 0;
int index = string.indexOf(QLatin1Char(':'));
if (index == -1)
return 0;
return string.midRef(4, index - 4).toInt();
}
void AndroidManifestEditorWidget::syncToEditor() void AndroidManifestEditorWidget::syncToEditor()
{ {
QDomDocument doc; QDomDocument doc;
...@@ -879,8 +892,8 @@ void AndroidManifestEditorWidget::syncToEditor() ...@@ -879,8 +892,8 @@ void AndroidManifestEditorWidget::syncToEditor()
manifest.setAttribute(QLatin1String("android:versionCode"), m_versionCode->value()); manifest.setAttribute(QLatin1String("android:versionCode"), m_versionCode->value());
manifest.setAttribute(QLatin1String("android:versionName"), m_versionNameLinedit->text()); manifest.setAttribute(QLatin1String("android:versionName"), m_versionNameLinedit->text());
setUsesSdk(doc, manifest, m_androidMinSdkVersion->currentText().toInt(), setUsesSdk(doc, manifest, extractVersion(m_androidMinSdkVersion->currentText()),
m_androidTargetSdkVersion->currentText().toInt()); extractVersion(m_androidTargetSdkVersion->currentText()));
setAndroidAppLibName(doc, manifest.firstChildElement(QLatin1String("application")) setAndroidAppLibName(doc, manifest.firstChildElement(QLatin1String("application"))
.firstChildElement(QLatin1String("activity")), .firstChildElement(QLatin1String("activity")),
......
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