diff --git a/sources/apkrecompileworker.cpp b/sources/apkrecompileworker.cpp index ea25472..c0dec0a 100644 --- a/sources/apkrecompileworker.cpp +++ b/sources/apkrecompileworker.cpp @@ -2,8 +2,8 @@ #include "apkrecompileworker.h" #include "processutils.h" -ApkRecompileWorker::ApkRecompileWorker(const QString &folder, QObject *parent) - : QObject(parent), m_Folder(folder) +ApkRecompileWorker::ApkRecompileWorker(const QString &folder, bool aapt2, QObject *parent) + : QObject(parent), m_Aapt2(aapt2), m_Folder(folder) { } @@ -24,6 +24,9 @@ void ApkRecompileWorker::recompile() QStringList args; args << heap << "-jar" << apktool; args << "b" << m_Folder; + if (m_Aapt2) { + args << "--use-aapt2"; + } ProcessResult result = ProcessUtils::runCommand(java, args); #ifdef QT_DEBUG qDebug() << "Apktool returned code" << result.code; diff --git a/sources/apkrecompileworker.h b/sources/apkrecompileworker.h index ec61c50..9b9e7fc 100644 --- a/sources/apkrecompileworker.h +++ b/sources/apkrecompileworker.h @@ -7,9 +7,10 @@ class ApkRecompileWorker : public QObject { Q_OBJECT public: - explicit ApkRecompileWorker(const QString &folder, QObject *parent = nullptr); + explicit ApkRecompileWorker(const QString &folder, bool aapt2, QObject *parent = nullptr); void recompile(); private: + bool m_Aapt2; QString m_Folder; signals: void finished(); diff --git a/sources/binarysettingswidget.cpp b/sources/binarysettingswidget.cpp index 9b0879f..188dd10 100644 --- a/sources/binarysettingswidget.cpp +++ b/sources/binarysettingswidget.cpp @@ -41,6 +41,7 @@ QLayout *BinarySettingsWidget::buildForm() label->setTextInteractionFlags(Qt::TextBrowserInteraction); label->setTextFormat(Qt::RichText); layout->addRow("", child); + layout->addRow(tr("Use AAPT2?"), m_CheckAapt2 = new QCheckBox(this)); layout->addRow(tr("Jadx"), m_EditJadxExe = new QLineEdit(this)); child = new QHBoxLayout(); child->addWidget(button = new QPushButton(tr("Browse"), this)); @@ -76,6 +77,7 @@ QLayout *BinarySettingsWidget::buildForm() m_EditAdbExe->setText(adb); } m_EditApktoolJar->setText(settings.value("apktool_jar").toString()); + m_CheckAapt2->setChecked(settings.value("use_aapt2", true).toBool()); m_EditJadxExe->setText(settings.value("jadx_exe").toString()); auto java = settings.value("java_exe").toString(); if (adb.isEmpty()) { diff --git a/sources/binarysettingswidget.h b/sources/binarysettingswidget.h index f5c9b01..e4f5009 100644 --- a/sources/binarysettingswidget.h +++ b/sources/binarysettingswidget.h @@ -1,6 +1,7 @@ #ifndef BINARYSETTINGSWIDGET_H #define BINARYSETTINGSWIDGET_H +#include #include #include #include @@ -11,6 +12,7 @@ class BinarySettingsWidget : public QWidget public: explicit BinarySettingsWidget(QWidget *parent = nullptr); private: + QCheckBox *m_CheckAapt2; QLineEdit *m_EditAdbExe; QLineEdit *m_EditApktoolJar; QLineEdit *m_EditJadxExe; diff --git a/sources/mainwindow.cpp b/sources/mainwindow.cpp index 4a19025..60a5303 100644 --- a/sources/mainwindow.cpp +++ b/sources/mainwindow.cpp @@ -421,8 +421,10 @@ void MainWindow::handleActionBuild() while (active->data(0, Qt::UserRole + 1).toInt() != Project) { active = active->parent(); } + QSettings settings; + auto appt2 = settings.value("use_aapt2", true).toBool(); auto thread = new QThread(); - auto worker = new ApkRecompileWorker(active->data(0, Qt::UserRole + 2).toString()); + auto worker = new ApkRecompileWorker(active->data(0, Qt::UserRole + 2).toString(), appt2); worker->moveToThread(thread); connect(worker, &ApkRecompileWorker::recompileFailed, this, &MainWindow::handleRecompileFailed); connect(worker, &ApkRecompileWorker::recompileFinished, this, &MainWindow::handleRecompileFinished);