Commit e7778d14 authored by Daniel Teske's avatar Daniel Teske

AndroidManifestEditor: Cope with non existing strings.xml

Instead of retrieving the app_name from the strings.xml simply show the
reference to the strings.xml file.

Task-number: QTCREATORBUG-10821
Change-Id: I99bf45df4864857992d03746cf8613b6f097352d
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent cef8ff29
......@@ -99,7 +99,8 @@ AndroidManifestEditorWidget::AndroidManifestEditorWidget(QWidget *parent, TextEd
: TextEditor::PlainTextEditorWidget(parent),
m_dirty(false),
m_stayClean(false),
m_setAppName(false)
m_setAppName(false),
m_appNameInStringsXml(false)
{
QSharedPointer<AndroidManifestDocument> doc(new AndroidManifestDocument(this));
doc->setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
......@@ -586,7 +587,7 @@ void AndroidManifestEditorWidget::preSave()
if (activePage() != Source)
syncToEditor();
if (m_setAppName) {
if (m_setAppName && m_appNameInStringsXml) {
QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->filePath()).absolutePath();
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
QFile f(fileName);
......@@ -773,6 +774,8 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
QString baseDir = QFileInfo(static_cast<AndroidManifestDocument *>(editor()->document())->filePath()).absolutePath();
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application"));
QFile f(fileName);
if (f.exists() && f.open(QIODevice::ReadOnly)) {
QDomDocument doc;
......@@ -786,9 +789,13 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
metadataElem = metadataElem.nextSiblingElement(QLatin1String("string"));
}
}
m_appNameInStringsXml = true;
} else {
m_appNameLineEdit->setText(applicationElement.attribute(QLatin1String("android:label")));
m_appNameInStringsXml = false;
}
QDomElement metadataElem = manifest.firstChildElement(QLatin1String("application")).firstChildElement(QLatin1String("activity")).firstChildElement(QLatin1String("meta-data"));
QDomElement metadataElem = applicationElement.firstChildElement(QLatin1String("activity")).firstChildElement(QLatin1String("meta-data"));
while (!metadataElem.isNull()) {
if (metadataElem.attribute(QLatin1String("android:name")) == QLatin1String("android.app.lib_name")) {
m_targetLineEdit->setEditText(metadataElem.attribute(QLatin1String("android:value")));
......@@ -893,6 +900,11 @@ void AndroidManifestEditorWidget::syncToEditor()
manifest.setAttribute(QLatin1String("android:versionCode"), m_versionCode->value());
manifest.setAttribute(QLatin1String("android:versionName"), m_versionNameLinedit->text());
if (!m_appNameInStringsXml) {
QDomElement application = manifest.firstChildElement(QLatin1String("application"));
application.setAttribute(QLatin1String("android:label"), m_appNameLineEdit->text());
}
setUsesSdk(doc, manifest, extractVersion(m_androidMinSdkVersion->currentText()),
extractVersion(m_androidTargetSdkVersion->currentText()));
......
......@@ -138,6 +138,7 @@ private:
bool m_dirty; // indicates that we need to call syncToEditor()
bool m_stayClean;
bool m_setAppName;
bool m_appNameInStringsXml;
int m_errorLine;
int m_errorColumn;
......
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