Skip to content

Commit

Permalink
Turn on --use-aapt2 flag when recompiling; closed #160
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavpandeyvpz committed May 24, 2020
1 parent dfa6bb5 commit 194f3cf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
7 changes: 5 additions & 2 deletions sources/apkrecompileworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion sources/apkrecompileworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions sources/binarysettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 2 additions & 0 deletions sources/binarysettingswidget.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef BINARYSETTINGSWIDGET_H
#define BINARYSETTINGSWIDGET_H

#include <QCheckBox>
#include <QLineEdit>
#include <QSpinBox>
#include <QWidget>
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion sources/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 194f3cf

Please sign in to comment.