Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable code decompilation #61

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions app/src/main/java/com/apk/editor/activities/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mData.add(new sSerializableItems(sCommonUtils.getDrawable(R.drawable.ic_theme, this), getString(R.string.app_theme), sThemeUtils.getAppTheme(this), null));
mData.add(new sSerializableItems(sCommonUtils.getDrawable(R.drawable.ic_translate, this), getString(R.string.language), AppSettings.getLanguage(this), null));
mData.add(new sSerializableItems(null, getString(R.string.settings_general), null, null));
mData.add(new sSerializableItems(sCommonUtils.getDrawable(R.drawable.ic_explore, this), getString(R.string.decompile_setting), AppSettings.getDecompileSettingString(this), null));
mData.add(new sSerializableItems(sCommonUtils.getDrawable(R.drawable.ic_projects, this), getString(R.string.project_exist_action), AppSettings.getProjectExistAction(this), null));
mData.add(new sSerializableItems(sCommonUtils.getDrawable(R.drawable.ic_export, this), getString(R.string.export_path_apks), AppSettings.getExportAPKsPath(this), null));
mData.add(new sSerializableItems(sCommonUtils.getDrawable(R.drawable.ic_export, this), getString(R.string.export_path_resources), AppSettings.getExportPath(this), null));
Expand All @@ -72,6 +73,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
} else if (position == 2) {
AppSettings.setLanguage(this);
} else if (position == 4) {
sCommonUtils.saveBoolean("decompileSetting", !AppSettings.getDecompileSetting(this), this);
mData.set(position, new sSerializableItems(sCommonUtils.getDrawable(R.drawable.ic_explore, this), getString(R.string.decompile_setting), AppSettings.getDecompileSettingString(this), null));
mRecycleViewAdapter.notifyItemChanged(position);
} else if (position == 5) {
new sSingleChoiceDialog(R.drawable.ic_projects, getString(R.string.project_exist_action),
AppSettings.getProjectExitingMenu(this), AppSettings.getProjectExitingMenuPosition(this), this) {

Expand All @@ -92,7 +97,7 @@ public void onItemSelected(int itemPosition) {
}
}
}.show();
} else if (position == 5) {
} else if (position == 6) {
if (Build.VERSION.SDK_INT < 29 && sPermissionUtils.isPermissionDenied(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, this)) {
sPermissionUtils.requestPermission(
new String[] {
Expand Down Expand Up @@ -124,7 +129,7 @@ public void onItemSelected(int itemPosition) {
}.show();
}
}
} else if (position == 6) {
} else if (position == 7) {
if (Build.VERSION.SDK_INT < 29 && sPermissionUtils.isPermissionDenied(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, this)) {
sPermissionUtils.requestPermission(
new String[] {
Expand Down Expand Up @@ -160,7 +165,7 @@ public void onItemSelected(int itemPosition) {
}.show();
}
}
} else if (APKEditorUtils.isFullVersion(this) && position == 8) {
} else if (APKEditorUtils.isFullVersion(this) && position == 9) {
new sSingleChoiceDialog(R.drawable.ic_android, getString(R.string.export_options),
AppSettings.getExportingAPKMenu(this), AppSettings.getExportingAPKsPosition(this), this) {

Expand All @@ -187,7 +192,7 @@ public void onItemSelected(int itemPosition) {
}
}
}.show();
} else if (APKEditorUtils.isFullVersion(this) && position == 9) {
} else if (APKEditorUtils.isFullVersion(this) && position == 10) {
new sSingleChoiceDialog(R.drawable.ic_installer, getString(R.string.installer_action),
AppSettings.getInstallerMenu(this), AppSettings.getInstallerMenuPosition(this), this) {

Expand All @@ -214,7 +219,7 @@ public void onItemSelected(int itemPosition) {
}
}
}.show();
} else if (APKEditorUtils.isFullVersion(this) && position == 10) {
} else if (APKEditorUtils.isFullVersion(this) && position == 11) {
new sSingleChoiceDialog(R.drawable.ic_key, getString(R.string.sign_apk_with),
new String[] {
getString(R.string.sign_apk_default),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void onBindViewHolder(@NonNull SettingsAdapter.ViewHolder holder, int pos
holder.Title.setText(data.get(position).getTextOne());
if (data.get(position).getTextTwo() != null) {
holder.Description.setText(data.get(position).getTextTwo());
holder.Description.setVisibility(View.VISIBLE);
} else {
holder.Description.setVisibility(View.GONE);
}
Expand All @@ -54,6 +55,7 @@ public void onBindViewHolder(@NonNull SettingsAdapter.ViewHolder holder, int pos
holder.mIcon.setColorFilter(sThemeUtils.isDarkTheme(holder.Title.getContext()) ? Color.WHITE : Color.BLACK);
if (data.get(position).getIcon() != null) {
holder.mIcon.setImageDrawable(data.get(position).getIcon());
holder.Description.setVisibility(View.VISIBLE);
} else {
holder.mIcon.setVisibility(View.GONE);
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/apk/editor/utils/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ public static String getAPKs(Context context) {
}
}

public static String getDecompileSettingString(Context context) {
return context.getString(getDecompileSetting(context) ?
R.string.decompile_on : R.string.decompile_off);
}
public static Boolean getDecompileSetting(Context context) {
return sCommonUtils.getBoolean("decompileSetting", true, context);
}

public static String getProjectExistAction(Context context) {
if (sCommonUtils.getString("projectAction", null, context) != null) {
return sCommonUtils.getString("projectAction", null, context);
Expand Down
23 changes: 13 additions & 10 deletions app/src/main/java/com/apk/editor/utils/tasks/ExploreAPK.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.apk.editor.activities.APKTasksActivity;
import com.apk.editor.utils.APKEditorUtils;
import com.apk.editor.utils.APKExplorer;
import com.apk.editor.utils.AppSettings;
import com.apk.editor.utils.Common;
import com.apk.editor.utils.DexToSmali;

Expand Down Expand Up @@ -107,16 +108,18 @@ public void doInBackground() {
}
APKEditorUtils.unzip(mPackageName != null ? sPackageUtils.getSourceDir(mPackageName, mContext) : mAPKFile.getAbsolutePath(), mExplorePath.getAbsolutePath());
// Decompile dex file(s)
for (File files : Objects.requireNonNull(mExplorePath.listFiles())) {
if (files.getName().startsWith("classes") && files.getName().endsWith(".dex") && !Common.isCancelled()) {
sFileUtils.mkdir(mBackUpPath);
sFileUtils.copy(files, new File(mBackUpPath, files.getName()));
sFileUtils.delete(files);
File mDexExtractPath = new File(mExplorePath, files.getName());
sFileUtils.mkdir(mDexExtractPath);
Common.setStatus(mContext.getString(R.string.decompiling, files.getName()));
new DexToSmali(false, mPackageName != null ? new File(sPackageUtils.getSourceDir(mPackageName, mContext))
: mAPKFile, mDexExtractPath, 0, files.getName()).execute();
if (AppSettings.getDecompileSetting(mContext)) {
for (File files : Objects.requireNonNull(mExplorePath.listFiles())) {
if (files.getName().startsWith("classes") && files.getName().endsWith(".dex") && !Common.isCancelled()) {
sFileUtils.mkdir(mBackUpPath);
sFileUtils.copy(files, new File(mBackUpPath, files.getName()));
sFileUtils.delete(files);
File mDexExtractPath = new File(mExplorePath, files.getName());
sFileUtils.mkdir(mDexExtractPath);
Common.setStatus(mContext.getString(R.string.decompiling, files.getName()));
new DexToSmali(false, mPackageName != null ? new File(sPackageUtils.getSourceDir(mPackageName, mContext))
: mAPKFile, mDexExtractPath, 0, files.getName()).execute();
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<string name="clearing_cache_message">Clearing Cache…</string>
<string name="copying">Copying \'%s\'…</string>
<string name="decompiling">Decompiling \'%s\'…</string>
<string name="decompile_setting">Code Decompilation</string>
<string name="decompile_on">Decompile code to smali</string>
<string name="decompile_off">Don\'t decompile code (faster)</string>
<string name="delete">Delete</string>
<string name="delete_question">Delete %s?</string>
<string name="delete_folder">Delete folder</string>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0-beta03'
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

Expand Down
Loading