From 7c78e39c759532f4e162cfb99dae4a10f0740237 Mon Sep 17 00:00:00 2001
From: q3b5q3 <40742924+AndnixSH@users.noreply.github.com>
Date: Sun, 13 Nov 2022 12:22:12 +0100
Subject: [PATCH] Improve temp logic
---
APKToolGUI/Forms/FormMain.cs | 13 ++-
APKToolGUI/Forms/FormMain.resx | 18 +--
APKToolGUI/Forms/FormSettings.Designer.cs | 129 +++++++++++-----------
APKToolGUI/Forms/FormSettings.cs | 33 ++----
APKToolGUI/Forms/FormSettings.resx | 48 ++++----
APKToolGUI/Program.cs | 5 +-
6 files changed, 120 insertions(+), 126 deletions(-)
diff --git a/APKToolGUI/Forms/FormMain.cs b/APKToolGUI/Forms/FormMain.cs
index 8aa53ed..3f21bef 100644
--- a/APKToolGUI/Forms/FormMain.cs
+++ b/APKToolGUI/Forms/FormMain.cs
@@ -254,8 +254,8 @@ namespace APKToolGUI
if (aapt.AppIcon != null)
{
- ZipUtils.ExtractFile(file, aapt.AppIcon, Path.Combine(Program.TEMP_DIR, aapt.PackageName));
- string icon = Path.Combine(Program.TEMP_DIR, aapt.PackageName, Path.GetFileName(aapt.AppIcon));
+ ZipUtils.ExtractFile(file, aapt.AppIcon, Path.Combine(Program.TempDir(), aapt.PackageName));
+ string icon = Path.Combine(Program.TempDir(), aapt.PackageName, Path.GetFileName(aapt.AppIcon));
if (File.Exists(icon))
{
apkIconPicBox.Image = Image.FromFile(icon);
@@ -915,9 +915,12 @@ namespace APKToolGUI
private void Application_ApplicationExit(object sender, EventArgs e)
{
- apkIconPicBox.Image.Dispose();
- apkIconPicBox.Image = null;
- DirectoryUtils.Delete(Program.TEMP_DIR);
+ if (apkIconPicBox.Image != null)
+ {
+ apkIconPicBox.Image.Dispose();
+ apkIconPicBox.Image = null;
+ }
+ DirectoryUtils.Delete(Program.TempDir());
Save();
}
diff --git a/APKToolGUI/Forms/FormMain.resx b/APKToolGUI/Forms/FormMain.resx
index b7826c8..cac9f25 100644
--- a/APKToolGUI/Forms/FormMain.resx
+++ b/APKToolGUI/Forms/FormMain.resx
@@ -5713,19 +5713,19 @@ and change target SDK to 29
423, 13
- 151, 22
+ 180, 22
Save log to file
- 151, 22
+ 180, 22
Settings
- 151, 22
+ 180, 22
Exit
@@ -7606,18 +7606,18 @@ and change target SDK to 29
System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- aboutToolStripMenuItem
-
-
- System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
baksmaliIssuesToolStripMenuItem
System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ aboutToolStripMenuItem
+
+
+ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
FormMain
diff --git a/APKToolGUI/Forms/FormSettings.Designer.cs b/APKToolGUI/Forms/FormSettings.Designer.cs
index 1228865..1e7aac4 100644
--- a/APKToolGUI/Forms/FormSettings.Designer.cs
+++ b/APKToolGUI/Forms/FormSettings.Designer.cs
@@ -33,23 +33,23 @@
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
+ this.customTempLocationTxtBox = new System.Windows.Forms.TextBox();
+ this.textBoxCustomJavaLocation = new System.Windows.Forms.TextBox();
+ this.buttonCustomTempLocation = new System.Windows.Forms.Button();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.buttonCustomJavaLocation = new System.Windows.Forms.Button();
+ this.checkBox2 = new System.Windows.Forms.CheckBox();
+ this.checkBox1 = new System.Windows.Forms.CheckBox();
+ this.checkBoxCheckUpdateStartup = new System.Windows.Forms.CheckBox();
this.groupBoxLanguage = new System.Windows.Forms.GroupBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.groupBoxContextMenu = new System.Windows.Forms.GroupBox();
+ this.ignoreOutputContextMenuBox = new System.Windows.Forms.CheckBox();
this.labelAdminRights = new System.Windows.Forms.Label();
this.buttonAddContextMenu = new System.Windows.Forms.Button();
this.buttonRemoveContextMenu = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonОК = new System.Windows.Forms.Button();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBoxCustomJavaLocation = new System.Windows.Forms.TextBox();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.checkBoxCheckUpdateStartup = new System.Windows.Forms.CheckBox();
- this.ignoreOutputContextMenuBox = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -77,9 +77,9 @@
//
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.checkBox4);
- this.groupBox1.Controls.Add(this.textBox1);
+ this.groupBox1.Controls.Add(this.customTempLocationTxtBox);
this.groupBox1.Controls.Add(this.textBoxCustomJavaLocation);
- this.groupBox1.Controls.Add(this.button1);
+ this.groupBox1.Controls.Add(this.buttonCustomTempLocation);
this.groupBox1.Controls.Add(this.checkBox3);
this.groupBox1.Controls.Add(this.buttonCustomJavaLocation);
this.groupBox1.Controls.Add(this.checkBox2);
@@ -96,11 +96,28 @@
this.checkBox4.Name = "checkBox4";
this.checkBox4.UseVisualStyleBackColor = true;
//
- // button1
+ // customTempLocationTxtBox
//
- resources.ApplyResources(this.button1, "button1");
- this.button1.Name = "button1";
- this.button1.UseVisualStyleBackColor = true;
+ resources.ApplyResources(this.customTempLocationTxtBox, "customTempLocationTxtBox");
+ this.customTempLocationTxtBox.BackColor = System.Drawing.SystemColors.Window;
+ this.customTempLocationTxtBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::APKToolGUI.Properties.Settings.Default, "TempDir", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.customTempLocationTxtBox.Name = "customTempLocationTxtBox";
+ this.customTempLocationTxtBox.Text = global::APKToolGUI.Properties.Settings.Default.TempDir;
+ //
+ // textBoxCustomJavaLocation
+ //
+ resources.ApplyResources(this.textBoxCustomJavaLocation, "textBoxCustomJavaLocation");
+ this.textBoxCustomJavaLocation.BackColor = System.Drawing.SystemColors.Window;
+ this.textBoxCustomJavaLocation.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::APKToolGUI.Properties.Settings.Default, "JavaExe", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.textBoxCustomJavaLocation.Name = "textBoxCustomJavaLocation";
+ this.textBoxCustomJavaLocation.Text = global::APKToolGUI.Properties.Settings.Default.JavaExe;
+ //
+ // buttonCustomTempLocation
+ //
+ resources.ApplyResources(this.buttonCustomTempLocation, "buttonCustomTempLocation");
+ this.buttonCustomTempLocation.Name = "buttonCustomTempLocation";
+ this.buttonCustomTempLocation.UseVisualStyleBackColor = true;
+ this.buttonCustomTempLocation.Click += new System.EventHandler(this.buttonCustomTempLocation_Click);
//
// checkBox3
//
@@ -117,6 +134,31 @@
this.buttonCustomJavaLocation.UseVisualStyleBackColor = true;
this.buttonCustomJavaLocation.Click += new System.EventHandler(this.buttonCustomJavaLocation_Click);
//
+ // checkBox2
+ //
+ resources.ApplyResources(this.checkBox2, "checkBox2");
+ this.checkBox2.Checked = global::APKToolGUI.Properties.Settings.Default.PlaySoundWhenDone;
+ this.checkBox2.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "PlaySoundWhenDone", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.checkBox2.Name = "checkBox2";
+ this.checkBox2.UseVisualStyleBackColor = true;
+ //
+ // checkBox1
+ //
+ resources.ApplyResources(this.checkBox1, "checkBox1");
+ this.checkBox1.Checked = global::APKToolGUI.Properties.Settings.Default.ClearLogBeforeAction;
+ this.checkBox1.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "ClearLogBeforeAction", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.checkBox1.Name = "checkBox1";
+ this.checkBox1.UseVisualStyleBackColor = true;
+ //
+ // checkBoxCheckUpdateStartup
+ //
+ resources.ApplyResources(this.checkBoxCheckUpdateStartup, "checkBoxCheckUpdateStartup");
+ this.checkBoxCheckUpdateStartup.Checked = global::APKToolGUI.Properties.Settings.Default.CheckForUpdateAtStartup;
+ this.checkBoxCheckUpdateStartup.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.checkBoxCheckUpdateStartup.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "CheckForUpdateAtStartup", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.checkBoxCheckUpdateStartup.Name = "checkBoxCheckUpdateStartup";
+ this.checkBoxCheckUpdateStartup.UseVisualStyleBackColor = true;
+ //
// groupBoxLanguage
//
resources.ApplyResources(this.groupBoxLanguage, "groupBoxLanguage");
@@ -141,6 +183,14 @@
this.groupBoxContextMenu.Name = "groupBoxContextMenu";
this.groupBoxContextMenu.TabStop = false;
//
+ // ignoreOutputContextMenuBox
+ //
+ resources.ApplyResources(this.ignoreOutputContextMenuBox, "ignoreOutputContextMenuBox");
+ this.ignoreOutputContextMenuBox.Checked = global::APKToolGUI.Properties.Settings.Default.IgnoreOutputDirContextMenu;
+ this.ignoreOutputContextMenuBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "IgnoreOutputDirContextMenu", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
+ this.ignoreOutputContextMenuBox.Name = "ignoreOutputContextMenuBox";
+ this.ignoreOutputContextMenuBox.UseVisualStyleBackColor = true;
+ //
// labelAdminRights
//
resources.ApplyResources(this.labelAdminRights, "labelAdminRights");
@@ -174,55 +224,6 @@
this.buttonОК.UseVisualStyleBackColor = true;
this.buttonОК.Click += new System.EventHandler(this.buttonОК_Click);
//
- // textBox1
- //
- resources.ApplyResources(this.textBox1, "textBox1");
- this.textBox1.BackColor = System.Drawing.SystemColors.Window;
- this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::APKToolGUI.Properties.Settings.Default, "TempDir", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.textBox1.Name = "textBox1";
- this.textBox1.Text = global::APKToolGUI.Properties.Settings.Default.TempDir;
- //
- // textBoxCustomJavaLocation
- //
- resources.ApplyResources(this.textBoxCustomJavaLocation, "textBoxCustomJavaLocation");
- this.textBoxCustomJavaLocation.BackColor = System.Drawing.SystemColors.Window;
- this.textBoxCustomJavaLocation.DataBindings.Add(new System.Windows.Forms.Binding("Text", global::APKToolGUI.Properties.Settings.Default, "JavaExe", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.textBoxCustomJavaLocation.Name = "textBoxCustomJavaLocation";
- this.textBoxCustomJavaLocation.Text = global::APKToolGUI.Properties.Settings.Default.JavaExe;
- //
- // checkBox2
- //
- resources.ApplyResources(this.checkBox2, "checkBox2");
- this.checkBox2.Checked = global::APKToolGUI.Properties.Settings.Default.PlaySoundWhenDone;
- this.checkBox2.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "PlaySoundWhenDone", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.UseVisualStyleBackColor = true;
- //
- // checkBox1
- //
- resources.ApplyResources(this.checkBox1, "checkBox1");
- this.checkBox1.Checked = global::APKToolGUI.Properties.Settings.Default.ClearLogBeforeAction;
- this.checkBox1.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "ClearLogBeforeAction", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // checkBoxCheckUpdateStartup
- //
- resources.ApplyResources(this.checkBoxCheckUpdateStartup, "checkBoxCheckUpdateStartup");
- this.checkBoxCheckUpdateStartup.Checked = global::APKToolGUI.Properties.Settings.Default.CheckForUpdateAtStartup;
- this.checkBoxCheckUpdateStartup.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBoxCheckUpdateStartup.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "CheckForUpdateAtStartup", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.checkBoxCheckUpdateStartup.Name = "checkBoxCheckUpdateStartup";
- this.checkBoxCheckUpdateStartup.UseVisualStyleBackColor = true;
- //
- // ignoreOutputContextMenuBox
- //
- resources.ApplyResources(this.ignoreOutputContextMenuBox, "ignoreOutputContextMenuBox");
- this.ignoreOutputContextMenuBox.Checked = global::APKToolGUI.Properties.Settings.Default.IgnoreOutputDirContextMenu;
- this.ignoreOutputContextMenuBox.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::APKToolGUI.Properties.Settings.Default, "IgnoreOutputDirContextMenu", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
- this.ignoreOutputContextMenuBox.Name = "ignoreOutputContextMenuBox";
- this.ignoreOutputContextMenuBox.UseVisualStyleBackColor = true;
- //
// FormSettings
//
resources.ApplyResources(this, "$this");
@@ -266,8 +267,8 @@
private System.Windows.Forms.CheckBox ignoreOutputContextMenuBox;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.CheckBox checkBox4;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.TextBox customTempLocationTxtBox;
+ private System.Windows.Forms.Button buttonCustomTempLocation;
private System.Windows.Forms.CheckBox checkBox3;
}
}
\ No newline at end of file
diff --git a/APKToolGUI/Forms/FormSettings.cs b/APKToolGUI/Forms/FormSettings.cs
index c17978a..6c5a653 100644
--- a/APKToolGUI/Forms/FormSettings.cs
+++ b/APKToolGUI/Forms/FormSettings.cs
@@ -4,6 +4,7 @@ using System.Runtime.InteropServices;
using System.IO;
using APKToolGUI.Languages;
using APKToolGUI.Utils;
+using Ookii.Dialogs.WinForms;
namespace APKToolGUI
{
@@ -117,27 +118,6 @@ namespace APKToolGUI
}
}
- //private void button1_Click(object sender, EventArgs e)
- //{
- // FontDialog fontDialog1 = new FontDialog();
- // fontDialog1.Font = textBox1.Font;
- // if (fontDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- // {
- // textBox1.Text = fontDialog1.Font.Name + ", " + fontDialog1.Font.Size;
- // textBox1.Font = fontDialog1.Font;
- // }
- //}
-
- //private void button2_Click(object sender, EventArgs e)
- //{
- // FontDialog fontDialog1 = new FontDialog();
- // fontDialog1.Font = textBox2.Font;
- // if (fontDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- // {
- // textBox2.Text = fontDialog1.Font.Name + ", " + fontDialog1.Font.Size;
- // textBox2.Font = fontDialog1.Font;
- // }
- //}
private void buttonCustomJavaLocation_Click(object sender, EventArgs e)
{
@@ -158,5 +138,16 @@ namespace APKToolGUI
// textBoxCustomJavaLocation.Text = openJavaExe.FileName;
//}
}
+
+ private void buttonCustomTempLocation_Click(object sender, EventArgs e)
+ {
+ using (VistaFolderBrowserDialog fbd = new VistaFolderBrowserDialog())
+ {
+ if (!String.IsNullOrWhiteSpace(customTempLocationTxtBox.Text))
+ fbd.SelectedPath = customTempLocationTxtBox.Text;
+ if (fbd.ShowDialog() == DialogResult.OK)
+ customTempLocationTxtBox.Text = fbd.SelectedPath;
+ }
+ }
}
}
diff --git a/APKToolGUI/Forms/FormSettings.resx b/APKToolGUI/Forms/FormSettings.resx
index 28a7113..3e231ea 100644
--- a/APKToolGUI/Forms/FormSettings.resx
+++ b/APKToolGUI/Forms/FormSettings.resx
@@ -156,31 +156,31 @@
0
-
+
Top, Left, Right
-
+
203, 86
-
+
215, 22
-
+
7
-
+
False
-
- textBox1
+
+ customTempLocationTxtBox
-
+
System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
groupBox1
-
+
1
@@ -210,40 +210,40 @@
2
-
+
buttonCustomTempLocation
-
+
Top, Right
-
+
System
-
+
NoControl
-
+
422, 86
-
+
24, 23
-
+
6
-
+
...
-
- button1
+
+ buttonCustomTempLocation
-
+
System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
groupBox1
-
+
3
@@ -409,7 +409,7 @@
12
- 2
+ General
groupBox1
diff --git a/APKToolGUI/Program.cs b/APKToolGUI/Program.cs
index d01d40f..4345069 100644
--- a/APKToolGUI/Program.cs
+++ b/APKToolGUI/Program.cs
@@ -61,7 +61,7 @@ namespace APKToolGUI
}
if (FilesCheck() == true)
{
- Directory.CreateDirectory(TEMP_DIR);
+ Directory.CreateDirectory(Program.TempDir());
PortableSettingsProvider.SettingsFileName = "config.xml";
PortableSettingsProvider.ApplyProvider(Settings.Default);
Application.Run(new FormMain());
@@ -156,7 +156,7 @@ namespace APKToolGUI
return path;
}
- private static string GetTempDir()
+ public static string TempDir()
{
if (Settings.Default.UseCustomTempDir)
return Path.Combine(Settings.Default.TempDir, "APKToolGUI" + StringExt.RandStrWithCaps(4));
@@ -165,7 +165,6 @@ namespace APKToolGUI
}
public static string LOCAL_APPDATA_PATH = Environment.GetEnvironmentVariable("LocalAppData");
- public static string TEMP_DIR = GetTempDir();
public static string APP_PATH = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
public static string APKTOOL_PATH = APP_PATH + @"\Resources\apktool.jar";
public static string APKSIGNER_PATH = APP_PATH + @"\Resources\apksigner.jar";