Skip to content

Commit

Permalink
Move from Apktool default AAPT1 to AAPT2
Browse files Browse the repository at this point in the history
  • Loading branch information
kefir500 committed Jan 3, 2024
1 parent 59eb47d commit 454118d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/apk/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ Command *Package::createPackCommand(const QString &target)
{
const QString source = getContentsPath();
const QString frameworks = Apktool::getFrameworksPath();
const bool aapt2 = app->settings->getUseAapt2();
const bool aapt1 = app->settings->getUseAapt1();
const bool debuggable = app->settings->getMakeDebuggable();

auto apktoolBuild = new Apktool::Build(source, target, frameworks, aapt2, debuggable);
auto apktoolBuild = new Apktool::Build(source, target, frameworks, aapt1, debuggable);

connect(apktoolBuild, &Command::started, this, [=]() {
qDebug() << qPrintable(QString("Packing\n from: %1\n to: %2\n").arg(source, target));
Expand Down
8 changes: 4 additions & 4 deletions src/base/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ QString Settings::getApktoolVersion() const
return settings->value("Apktool/Version").toString();
}

bool Settings::getUseAapt2() const
bool Settings::getUseAapt1() const
{
return settings->value("Apktool/Aapt2", true).toBool();
return settings->value("Apktool/Aapt1", false).toBool();
}

bool Settings::getMakeDebuggable() const
Expand Down Expand Up @@ -417,9 +417,9 @@ void Settings::setApktoolVersion(const QString &version)
settings->setValue("Apktool/Version", version);
}

void Settings::setUseAapt2(bool aapt2)
void Settings::setUseAapt1(bool aapt1)
{
settings->setValue("Apktool/Aapt2", aapt2);
settings->setValue("Apktool/Aapt1", aapt1);
}

void Settings::setMakeDebuggable(bool debuggable)
Expand Down
4 changes: 2 additions & 2 deletions src/base/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Settings : public QObject
QString getKeyAlias() const;
QString getKeyPassword() const;
QString getApktoolVersion() const;
bool getUseAapt2() const;
bool getUseAapt1() const;
bool getMakeDebuggable() const;
bool getDecompileSources() const;
bool getDecompileNoDebugInfo() const;
Expand Down Expand Up @@ -88,7 +88,7 @@ class Settings : public QObject
void setKeyAlias(const QString &alias);
void setKeyPassword(const QString &password);
void setApktoolVersion(const QString &version);
void setUseAapt2(bool aapt2);
void setUseAapt1(bool aapt1);
void setMakeDebuggable(bool debuggable);
void setDecompileSources(bool smali);
void setDecompileNoDebugInfo(bool noDebugInfo);
Expand Down
4 changes: 2 additions & 2 deletions src/tools/apktool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ void Apktool::Build::run()
if (!frameworks.isEmpty()) {
arguments << "--frame-path" << frameworks;
}
if (aapt2) {
arguments << "--use-aapt2";
if (aapt1) {
arguments << "--use-aapt1";
}
if (debuggable) {
arguments << "--debug";
Expand Down
6 changes: 3 additions & 3 deletions src/tools/apktool.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ namespace Apktool
{
public:
Build(const QString &source, const QString &destination,
const QString &frameworks, bool aapt2, bool debuggable, QObject *parent = nullptr)
const QString &frameworks, bool aapt1, bool debuggable, QObject *parent = nullptr)
: Command(parent)
, source(source)
, destination(destination)
, frameworks(frameworks)
, aapt2(aapt2)
, aapt1(aapt1)
, debuggable(debuggable)
{}

Expand All @@ -56,7 +56,7 @@ namespace Apktool
const QString source;
const QString destination;
const QString frameworks;
const bool aapt2;
const bool aapt1;
const bool debuggable;
QString resultOutput;
};
Expand Down
10 changes: 5 additions & 5 deletions src/windows/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void OptionsDialog::load()
fileboxApktool->setCurrentPath(app->settings->getApktoolPath());
fileboxOutput->setCurrentPath(app->settings->getOutputDirectory());
fileboxFrameworks->setCurrentPath(app->settings->getFrameworksDirectory());
checkboxAapt2->setChecked(app->settings->getUseAapt2());
checkboxAapt1->setChecked(app->settings->getUseAapt1());
checkboxDebuggable->setChecked(app->settings->getMakeDebuggable());
checkboxSources->setChecked(app->settings->getDecompileSources());
checkboxOnlyMainClasses->setChecked(app->settings->getDecompileOnlyMainClasses());
Expand Down Expand Up @@ -162,7 +162,7 @@ void OptionsDialog::save()
app->settings->setApktoolPath(fileboxApktool->getCurrentPath());
app->settings->setOutputDirectory(fileboxOutput->getCurrentPath());
app->settings->setFrameworksDirectory(fileboxFrameworks->getCurrentPath());
app->settings->setUseAapt2(checkboxAapt2->isChecked());
app->settings->setUseAapt1(checkboxAapt1->isChecked());
app->settings->setMakeDebuggable(checkboxDebuggable->isChecked());
app->settings->setDecompileSources(checkboxSources->isChecked());
app->settings->setDecompileOnlyMainClasses(checkboxOnlyMainClasses->isChecked());
Expand Down Expand Up @@ -336,11 +336,11 @@ void OptionsDialog::initialize()
layoutUnpacking->addWidget(checkboxBrokenResources);

auto groupPacking = new QGroupBox(tr("Packing"), this);
//: "AAPT2" is the name of the tool, don't translate it.
checkboxAapt2 = new QCheckBox(tr("Use AAPT2"), this);
//: "AAPT1" is the name of the tool, don't translate it.
checkboxAapt1 = new QCheckBox(tr("Use AAPT1"), this);
checkboxDebuggable = new QCheckBox(tr("Pack for debugging"), this);
auto layoutPacking = new QVBoxLayout(groupPacking);
layoutPacking->addWidget(checkboxAapt2);
layoutPacking->addWidget(checkboxAapt1);
layoutPacking->addWidget(checkboxDebuggable);

pageApktool->addLayout(formApktool, 0, 0, 1, 2);
Expand Down
2 changes: 1 addition & 1 deletion src/windows/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class OptionsDialog : public QDialog
FileBox *fileboxApktool;
FileBox *fileboxOutput;
FileBox *fileboxFrameworks;
QCheckBox *checkboxAapt2;
QCheckBox *checkboxAapt1;
QCheckBox *checkboxDebuggable;
QCheckBox *checkboxSources;
QCheckBox *checkboxNoDebugInfo;
Expand Down

0 comments on commit 454118d

Please sign in to comment.