Skip to content

Commit

Permalink
Update 1.6.7
Browse files Browse the repository at this point in the history
- UI update
- Some fixes and improvements under the hood!
  • Loading branch information
msartore committed May 30, 2021
1 parent 59b3969 commit 69657f4
Show file tree
Hide file tree
Showing 21 changed files with 5,319 additions and 3,539 deletions.
10 changes: 5 additions & 5 deletions ATA GUI/ATA GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@
<Compile Include="Forms\About.Designer.cs">
<DependentUpon>About.cs</DependentUpon>
</Compile>
<Compile Include="Forms\exeMissingForm.cs">
<Compile Include="Forms\ExeMissingForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\exeMissingForm.Designer.cs">
<DependentUpon>exeMissingForm.cs</DependentUpon>
<Compile Include="Forms\ExeMissingForm.Designer.cs">
<DependentUpon>ExeMissingForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\BootloaderMenu.cs">
<SubType>Form</SubType>
Expand Down Expand Up @@ -142,8 +142,8 @@
<EmbeddedResource Include="Forms\About.resx">
<DependentUpon>About.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\exeMissingForm.resx">
<DependentUpon>exeMissingForm.cs</DependentUpon>
<EmbeddedResource Include="Forms\ExeMissingForm.resx">
<DependentUpon>ExeMissingForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\BootloaderMenu.resx">
<DependentUpon>BootloaderMenu.cs</DependentUpon>
Expand Down
2 changes: 1 addition & 1 deletion ATA GUI/Forms/About.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

797 changes: 635 additions & 162 deletions ATA GUI/Forms/About.resx

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion ATA GUI/Forms/BloatwareDetecter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ public partial class BloatwareDetecter : Form
private readonly List<string> installedPackageList;
private readonly HashSet<string> foundPackageList = new HashSet<string>();
private readonly MainForm mainForm;
public string currentDevice;
private string currentDevice;

public string CurrentDevice
{
set { currentDevice = value; }
}

public BloatwareDetecter(List<string> listOfApps, MainForm main)
{
Expand Down
797 changes: 635 additions & 162 deletions ATA GUI/Forms/BloatwareDetecter.resx

Large diffs are not rendered by default.

797 changes: 635 additions & 162 deletions ATA GUI/Forms/BootloaderMenu.resx

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions ATA GUI/Forms/Disclaimer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

797 changes: 635 additions & 162 deletions ATA GUI/Forms/Disclaimer.resx

Large diffs are not rendered by default.

406 changes: 203 additions & 203 deletions ATA GUI/Forms/MainForm.Designer.cs

Large diffs are not rendered by default.

184 changes: 108 additions & 76 deletions ATA GUI/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Net.NetworkInformation;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;

namespace ATA_GUI
{
Expand All @@ -25,27 +26,24 @@ public partial class MainForm : Form
private readonly string FILEADB = "adb.exe";
private bool systemApp;
private readonly List<Device> devices = new List<Device>();
private string currentDeviceSelected = "";
private string currentDeviceSelected = string.Empty;
private bool deviceWireless;
private bool allApk;
private string stringApk;
private string stringApkS;
private bool connected = true;

[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private const string CURRENTVERSION = "v.1.6.7";
private static readonly Regex regex = new Regex(@"\s+");

public static string RemoveWhiteSpaces(string str)
{
return regex.Replace(str, String.Empty);
}

[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();

private const string CURRENTVERSION = "v.1.6.6";

public MainForm()
{
InitializeComponent();
Expand All @@ -60,24 +58,6 @@ private void panelTopBar_MouseMove(object sender, MouseEventArgs e)
}
}

private void buttonCloseWindows_Click(object sender, EventArgs e)
{
if (Process.GetProcessesByName("adb").Length != 0)
{
DialogResult dialogResult = MessageBox.Show("Do you want to kill ADB?", "Kill ADB", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
systemCommand("taskkill /f /im " + FILEADB);
}
}
Application.Exit();
}

private void button1_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}

private void buttonSyncApp_Click(object sender, EventArgs e)
{
if (tabControl1.SelectedTab.Name.Contains("System"))
Expand Down Expand Up @@ -242,6 +222,46 @@ public static void MessageShowBox(string message, int type)
}
}

private async void updateCheckAsync()
{
Release currentRelease = new Release();
Release latestRelease = new Release();
string json;
try
{
HttpClient _client = new HttpClient();
_client.Timeout = TimeSpan.FromSeconds(5);
_client.DefaultRequestHeaders.Add("User-Agent", "ATA");
json = await _client.GetStringAsync("https://api.github.com/repos/MassimilianoSartore/ATA-GUI/releases");
dynamic jsonReal = JsonConvert.DeserializeObject(json);
string latestReleaseName = jsonReal[0]["tag_name"];
latestRelease.Number = int.Parse(Regex.Replace(latestReleaseName, @"[^\d]+(\d*:abc$)|[^\d]+", ""));
if (latestReleaseName.Contains("Pre")) { latestRelease.Pre = true; }
currentRelease.Number = int.Parse(Regex.Replace(CURRENTVERSION, @"[^\d]+(\d*:abc$)|[^\d]+", ""));
if (CURRENTVERSION.Contains("Pre")) { currentRelease.Pre = true; }
string linkString = jsonReal[0]["assets"][0]["browser_download_url"];
string linkRepository = jsonReal[0]["html_url"];
if ((latestRelease.Number > currentRelease.Number) || ((latestRelease.Number == currentRelease.Number) && (currentRelease.Pre && !latestRelease.Pre)))
{
if (MessageBox.Show("Update found, do you want to update it?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Process.Start((string)jsonReal[0]["html_url"]);
UpdateForm update = new UpdateForm(linkString);
update.ShowDialog();
}
}
else
{
LogWriteLine("ATA is up to date!");
}
}
catch
{
LogWriteLine("Timeout Error occurred while connecting to the Server!");
LogWriteLine("Open settings to check if a new version is avaiable!");
}
}

private void backgroundWorkerSync_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
Object paramObj = e.Argument as Object;
Expand Down Expand Up @@ -638,13 +658,13 @@ private void DevicesListUpdate()
}
}

private async void MainForm_Shown(object sender, EventArgs e)
private void MainForm_Shown(object sender, EventArgs e)
{
LogWriteLine("Checking connection...");
toolStripButtonRestoreApp.Enabled = false;
Ping myPing = new Ping();
String host = "google.com";
String host = "1.1.1.1";
byte[] buffer = new byte[32];
bool tempCheck = false;
int timeout = 1000;
PingOptions pingOptions = new PingOptions();
PingReply reply;
Expand All @@ -653,45 +673,19 @@ private async void MainForm_Shown(object sender, EventArgs e)
reply = myPing.Send(host, timeout, buffer, pingOptions);
if (reply.Status == IPStatus.Success)
{
tempCheck = true;
connected = true;
}
}
catch
{
LogWriteLine("You are offline");
}
if (tempCheck)
{
Release currentRelease = new Release();
Release latestRelease = new Release();
HttpClient _client = new HttpClient();
_client.DefaultRequestHeaders.Add("User-Agent", "C# App");
string json = await _client.GetStringAsync("https://api.github.com/repos/MassimilianoSartore/ATA-GUI/releases");
dynamic jsonReal = JsonConvert.DeserializeObject(json);
string latestReleaseName = jsonReal[0]["tag_name"];
latestRelease.Number = int.Parse(Regex.Replace(latestReleaseName, @"[^\d]+(\d*:abc$)|[^\d]+", ""));
if (latestReleaseName.Contains("Pre")) { latestRelease.Pre = true; }
currentRelease.Number = int.Parse(Regex.Replace(CURRENTVERSION, @"[^\d]+(\d*:abc$)|[^\d]+", ""));
if (CURRENTVERSION.Contains("Pre")) { currentRelease.Pre = true; }
string linkString = jsonReal[0]["assets"][0]["browser_download_url"];
string linkRepository = jsonReal[0]["html_url"];
if ((latestRelease.Number > currentRelease.Number) || ((latestRelease.Number == currentRelease.Number) && (currentRelease.Pre && !latestRelease.Pre)))
{
if (MessageBox.Show("Update found, do you want to update it?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Process.Start((string)jsonReal[0]["html_url"]);
UpdateForm update = new UpdateForm(linkString);
update.ShowDialog();
}
}
}
else
{
connected = false;
disableSystem(true);
}
LogWriteLine("Connection checked!");

DevicesListUpdate();
syncFun(3);
updateCheckAsync();
}

private void checkBoxSelectAll_CheckedChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -885,8 +879,9 @@ private void flash(int index)

private void backgroundWorkerFlashImg_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
string log = "";
string command = "";
string command = string.Empty;
string log;

switch (sender.ToString())
{
case "0":
Expand Down Expand Up @@ -914,7 +909,7 @@ private void backgroundWorkerFlashImg_DoWork(object sender, System.ComponentMode
command = "flash vendor ";
break;
}
if ((log = adbFastbootCommandR(new [] { command + textBoxDirImg.Text }, 1))!=null)
if ((log = adbFastbootCommandR(new[] { command + textBoxDirImg.Text }, 1)) != null)
{
LogWriteLine(log);
}
Expand Down Expand Up @@ -1112,8 +1107,8 @@ private void toolStripButton5_Click(object sender, EventArgs e)
{
if (checkedListBoxApp.CheckedItems.Count > 0)
{
string command = "";
string commandName = "";
string command = string.Empty;
string commandName = string.Empty;
List<string> arrayApkSelect = new List<string>();
foreach (Object list in checkedListBoxApp.CheckedItems)
{
Expand Down Expand Up @@ -1316,18 +1311,16 @@ private void buttonReloadDevicesList_Click(object sender, EventArgs e)

private void tabControl1_Selected(object sender, TabControlEventArgs e)
{
if(tabControl1.SelectedTab.Text!="System")
comboBoxDevices.Enabled = true;
buttonReloadDevicesList.Enabled = true;

if (tabControl1.SelectedTab.Text!="System")
{
comboBoxDevices.Enabled = false;
buttonReloadDevicesList.Enabled = false;
buttonMobileScreenShare.Enabled = false;
disableEnableSystem(false);
}
else
{
comboBoxDevices.Enabled = true;
buttonReloadDevicesList.Enabled = true;
}
}

private void backgroundWorkerAdbDownloader_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
Expand All @@ -1342,7 +1335,7 @@ private void backgroundWorkerAdbDownloader_DoWork(object sender, System.Componen
disableEnableSystem(false);
buttonDisconnectIP.Enabled = false;
});
exeMissingForm adbError = new exeMissingForm("adb.exe not found\n\nDo you want to download sdk platform tool?\n\n[By pressing YES you agree sdk platform tool terms and conditions]\nfor more info press info button", "Error, ADB Missing!");
ExeMissingForm adbError = new ExeMissingForm("adb.exe not found\n\nDo you want to download sdk platform tool?\n\n[By pressing YES you agree sdk platform tool terms and conditions]\nfor more info press info button", "Error, ADB Missing!");
adbError.ShowDialog();
switch (adbError.DialogResult)
{
Expand Down Expand Up @@ -1375,9 +1368,10 @@ private void backgroundWorkerAdbDownloader_DoWork(object sender, System.Componen
systemCommand("rmdir /Q /S platform-tools");
LogWriteLine("ATA ready!");
}
catch (Exception ex)
catch
{
MessageShowBox(ex.ToString(), 0);
LogWriteLine("Error during sdk platform tool download!");
MessageShowBox("Error during sdk platform tool download!", 0);
disableSystem(true);
}
}
Expand Down Expand Up @@ -1415,7 +1409,7 @@ private void toolStripButtonBloatwareDetecter_Click(object sender, EventArgs e)
listOfApps.Add(list.ToString());
}
BloatwareDetecter bloatwareDetecter = new BloatwareDetecter(listOfApps, this);
bloatwareDetecter.currentDevice = currentDeviceSelected;
bloatwareDetecter.CurrentDevice = currentDeviceSelected;
bloatwareDetecter.ShowDialog();
}
else
Expand Down Expand Up @@ -1491,7 +1485,7 @@ private void backgroundWorkerExeDownloader_DoWork(object sender, System.Componen
MessageShowBox("You are offline, ATA can't download scrcpy", 0);
return;
}
exeMissingForm scrcpyError = new exeMissingForm("scrcpy.exe not found\n\nDo you want to download scrcpy?\n\n[By pressing YES you agree scrcpy terms and conditions]\nfor more info press info button", "Error, scrcpy Missing!");
ExeMissingForm scrcpyError = new ExeMissingForm("scrcpy.exe not found\n\nDo you want to download scrcpy?\n\n[By pressing YES you agree scrcpy terms and conditions]\nfor more info press info button", "Error, scrcpy Missing!");
scrcpyError.ShowDialog();
switch (scrcpyError.DialogResult)
{
Expand Down Expand Up @@ -1570,5 +1564,43 @@ private void videoTutorialToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/MassimilianoSartore/ATA-GUI/wiki#coming-soon");
}

private void pictureBoxMinimize_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}

private void pictureBoxClose_Click(object sender, EventArgs e)
{
if (Process.GetProcessesByName("adb").Length != 0)
{
DialogResult dialogResult = MessageBox.Show("Do you want to kill ADB?", "Kill ADB", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
systemCommand("taskkill /f /im " + FILEADB);
}
}
Application.Exit();
}

private void pictureBoxMinimize_MouseHover(object sender, EventArgs e)
{
pictureBoxMinimize.BackColor = System.Drawing.ColorTranslator.FromHtml("#1f2121");
}

private void pictureBoxMinimize_MouseLeave(object sender, EventArgs e)
{
pictureBoxMinimize.BackColor = Color.Black;
}

private void pictureBoxClose_MouseHover(object sender, EventArgs e)
{
pictureBoxClose.BackColor = Color.Red;
}

private void pictureBoxClose_MouseLeave(object sender, EventArgs e)
{
pictureBoxClose.BackColor = Color.Black;
}
}
}
Loading

0 comments on commit 69657f4

Please sign in to comment.