Skip to content
51 changes: 29 additions & 22 deletions adbGUI/Forms/BackupRestore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

namespace adbGUI.Forms
{
using Methods;
using System;
using System.Globalization;
using System.Windows.Forms;
using Methods;

public partial class BackupRestore : Form
{
Expand Down Expand Up @@ -40,10 +40,9 @@ private void Btn_BackupStart_Click(object sender, EventArgs e)
const string all = " -all";
var system = " -system";


if (cbo_BackupPackage.Checked == false)
if (!cbo_BackupPackage.Checked)
{
if (txt_BackupPathTo.Text == "")
if (txt_BackupPathTo.Text?.Length == 0)
{
MessageBox.Show(@"Please select a destination!", @"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
Expand All @@ -62,11 +61,35 @@ private void Btn_BackupStart_Click(object sender, EventArgs e)
{
var package = cbx_BackupPackage.SelectedItem.ToString();

if (txt_BackupPathTo.Text == "")
if (txt_BackupPathTo.Text?.Length == 0)
{
MessageBox.Show(@"Please select a destination!", @"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
_adb.StartProcessing("adb backup -apk " + package + name, _formMethods.SelectedDevice());
}
}
}

private void Btn_RestoreBrowse_Click(object sender, EventArgs e)
{
openFileDialog.FileName = "";
openFileDialog.Filter = @" .ab|*.ab";

if (openFileDialog.ShowDialog() == DialogResult.OK) txt_RestorePath.Text = openFileDialog.FileName;
}

private void Btn_RestoreStart_Click(object sender, EventArgs e)
{
if (txt_RestorePath.Text?.Length == 0)
{
MessageBox.Show(@"Please select a file!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
_adb.StartProcessing("adb restore \"" + txt_RestorePath.Text + "\"", _formMethods.SelectedDevice());
}
}

Expand All @@ -91,7 +114,7 @@ private void Cbo_BackupPackage_CheckedChanged(object sender, EventArgs e)

if (!string.IsNullOrEmpty(output))
{
foreach (var item in output.Split(new[] {"\n"}, StringSplitOptions.RemoveEmptyEntries))
foreach (var item in output.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
cbx_BackupPackage.Items.Add(item.Remove(0, 8));

cbx_BackupPackage.Sorted = true;
Expand All @@ -112,21 +135,5 @@ private void Cbo_BackupPackage_CheckedChanged(object sender, EventArgs e)
label8.Visible = false;
}
}

private void Btn_RestoreStart_Click(object sender, EventArgs e)
{
if (txt_RestorePath.Text == "")
MessageBox.Show(@"Please select a file!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
_adb.StartProcessing("adb restore \"" + txt_RestorePath.Text + "\"", _formMethods.SelectedDevice());
}

private void Btn_RestoreBrowse_Click(object sender, EventArgs e)
{
openFileDialog.FileName = "";
openFileDialog.Filter = @" .ab|*.ab";

if (openFileDialog.ShowDialog() == DialogResult.OK) txt_RestorePath.Text = openFileDialog.FileName;
}
}
}
2 changes: 1 addition & 1 deletion adbGUI/Forms/Credits.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ Elegant Themes: http://www.flaticon.com/authors/elegant-themes
Freepik: http://www.freepik.com
Dave Gandy: http://www.flaticon.com/authors/dave-gandy

Version at 06/04/2018</value>
Version at 29/05/2019</value>
</data>
</root>
17 changes: 4 additions & 13 deletions adbGUI/Forms/Density.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace adbGUI.Forms
{
using Methods;
using System;
using System.Windows.Forms;
using Methods;

public partial class Density : Form
{
Expand All @@ -26,20 +26,11 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
return true;
}

private void Btn_showDpi_Click(object sender, EventArgs e)
{
_adb.StartProcessing("adb shell wm density", _formMethods.SelectedDevice());
}
private void Btn_resetDpi_Click(object sender, EventArgs e) => _adb.StartProcessing("adb shell wm density reset", _formMethods.SelectedDevice());

private void Btn_setDpi_Click(object sender, EventArgs e)
{
_adb.StartProcessing("adb shell wm density " + txt_phoneDpi.Text, _formMethods.SelectedDevice());
}
private void Btn_setDpi_Click(object sender, EventArgs e) => _adb.StartProcessing("adb shell wm density " + txt_phoneDpi.Text, _formMethods.SelectedDevice());

private void Btn_resetDpi_Click(object sender, EventArgs e)
{
_adb.StartProcessing("adb shell wm density reset", _formMethods.SelectedDevice());
}
private void Btn_showDpi_Click(object sender, EventArgs e) => _adb.StartProcessing("adb shell wm density", _formMethods.SelectedDevice());

private void DpiChange_KeyDown(object sender, KeyEventArgs e)
{
Expand Down
64 changes: 34 additions & 30 deletions adbGUI/Forms/FileOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace adbGUI.Forms
{
using Methods;
using System;
using System.Windows.Forms;
using Methods;

public partial class FileOps : Form
{
Expand All @@ -19,6 +19,34 @@ public FileOps(CmdProcess adbFrm, FormMethods formMethodsFrm)
_formMethods = formMethodsFrm;
}

private void Btn_FileOpsPullBrowse_Click(object sender, EventArgs e)
{
folderBrowserDialog.Description = @"Where should the file be saved?";

if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
txt_FileOpsPullTo.Text = folderBrowserDialog.SelectedPath;
}

private void Btn_FileOpsPullList_Click(object sender, EventArgs e)
{
var path = txt_FileOpsPullFrom.Text;
_adb.StartProcessing("adb shell ls -la " + path + " -F", _formMethods.SelectedDevice());
}

private void Btn_FileOpsPullPull_Click(object sender, EventArgs e)
{
if (txt_FileOpsPullTo.Text?.Length == 0 || txt_FileOpsPullFrom.Text?.Length == 0)
{
MessageBox.Show(@"Please select a file and chose destination!", @"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
var s = "adb pull \"" + txt_FileOpsPullFrom.Text + "\" \"" + txt_FileOpsPullTo.Text + "\"";
_adb.StartProcessing(s, _formMethods.SelectedDevice());
}
}

private void Btn_FileOpsPushBrowse_Click(object sender, EventArgs e)
{
openFileDialog.FileName = " "; //This is not a normal whitespace. ALT + 255
Expand All @@ -29,23 +57,13 @@ private void Btn_FileOpsPushBrowse_Click(object sender, EventArgs e)

if (openFileDialog.ShowDialog() != DialogResult.OK) return;
if (openFileDialog.SafeFileName == " ") //This is not a normal whitespace. ALT + 255
{
txt_FileOpsPushTo.Text =
openFileDialog.FileName.Remove(openFileDialog.FileName.Length - 2, 2);
else
txt_FileOpsPushFrom.Text = openFileDialog.FileName;
}

private void Btn_FileOpsPushPush_Click(object sender, EventArgs e)
{
if (txt_FileOpsPushTo.Text == "" || txt_FileOpsPushFrom.Text == "")
{
MessageBox.Show(@"Please select a file and chose destination!", @"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
var s = "adb push \"" + txt_FileOpsPushFrom.Text + "\"" + " \"" + txt_FileOpsPushTo.Text + "\"";
_adb.StartProcessing(s, _formMethods.SelectedDevice());
txt_FileOpsPushFrom.Text = openFileDialog.FileName;
}
}

Expand All @@ -55,32 +73,18 @@ private void Btn_FileOpsPushList_Click(object sender, EventArgs e)
_adb.StartProcessing("adb shell ls -la " + path + " -F", _formMethods.SelectedDevice());
}

private void Btn_FileOpsPullBrowse_Click(object sender, EventArgs e)
{
folderBrowserDialog.Description = @"Where should the file be saved?";

if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
txt_FileOpsPullTo.Text = folderBrowserDialog.SelectedPath;
}

private void Btn_FileOpsPullPull_Click(object sender, EventArgs e)
private void Btn_FileOpsPushPush_Click(object sender, EventArgs e)
{
if (txt_FileOpsPullTo.Text == "" || txt_FileOpsPullFrom.Text == "")
if (txt_FileOpsPushTo.Text?.Length == 0 || txt_FileOpsPushFrom.Text?.Length == 0)
{
MessageBox.Show(@"Please select a file and chose destination!", @"Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
var s = "adb pull \"" + txt_FileOpsPullFrom.Text + "\"" + " \"" + txt_FileOpsPullTo.Text + "\"";
var s = "adb push \"" + txt_FileOpsPushFrom.Text + "\" \"" + txt_FileOpsPushTo.Text + "\"";
_adb.StartProcessing(s, _formMethods.SelectedDevice());
}
}

private void Btn_FileOpsPullList_Click(object sender, EventArgs e)
{
var path = txt_FileOpsPullFrom.Text;
_adb.StartProcessing("adb shell ls -la " + path + " -F", _formMethods.SelectedDevice());
}
}
}
39 changes: 19 additions & 20 deletions adbGUI/Forms/InstallUninstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace adbGUI.Forms
{
using Methods;
using System;
using System.Windows.Forms;
using Methods;

public partial class InstallUninstall : Form
{
Expand All @@ -20,6 +20,17 @@ public InstallUninstall(CmdProcess adbFrm, FormMethods formMethodsFrm)
_formMethods = formMethodsFrm;
}

private void Btn_InstallUninstallBrowse_Click(object sender, EventArgs e)
{
openFileDialog.FileName = "";
openFileDialog.CheckFileExists = true;
openFileDialog.CheckPathExists = true;
openFileDialog.Filter = @" .apk|*.apk";

if (openFileDialog.ShowDialog() == DialogResult.OK)
txt_InstallUninstallPackageInstall.Text = openFileDialog.FileName;
}

private void Btn_InstallUninstallInstall_Click(object sender, EventArgs e)
{
var s = "\"" + txt_InstallUninstallPackageInstall.Text + "\"";
Expand All @@ -36,15 +47,13 @@ private void Btn_InstallUninstallInstall_Click(object sender, EventArgs e)
}
}

private void Btn_InstallUninstallBrowse_Click(object sender, EventArgs e)
private void Btn_InstallUninstallRefreshApps_Click(object sender, EventArgs e)
{
openFileDialog.FileName = "";
openFileDialog.CheckFileExists = true;
openFileDialog.CheckPathExists = true;
openFileDialog.Filter = @" .apk|*.apk";

if (openFileDialog.ShowDialog() == DialogResult.OK)
txt_InstallUninstallPackageInstall.Text = openFileDialog.FileName;
groupBox1.Enabled = false;
groupBox3.Enabled = false;
RefreshInstalledApps();
groupBox1.Enabled = true;
groupBox3.Enabled = true;
}

private void Btn_InstallUninstallUninstall_Click(object sender, EventArgs e)
Expand All @@ -56,15 +65,6 @@ private void Btn_InstallUninstallUninstall_Click(object sender, EventArgs e)
RefreshInstalledApps();
}

private void Btn_InstallUninstallRefreshApps_Click(object sender, EventArgs e)
{
groupBox1.Enabled = false;
groupBox3.Enabled = false;
RefreshInstalledApps();
groupBox1.Enabled = true;
groupBox3.Enabled = true;
}

private void RefreshInstalledApps()
{
cbx_InstallUninstallPackageUninstall.Items.Clear();
Expand All @@ -76,7 +76,7 @@ private void RefreshInstalledApps()

if (!string.IsNullOrEmpty(output))
{
foreach (var item in output.Split(new[] {"\n"}, StringSplitOptions.RemoveEmptyEntries))
foreach (var item in output.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
cbx_InstallUninstallPackageUninstall.Items.Add(item.Remove(0, 8));

cbx_InstallUninstallPackageUninstall.Sorted = true;
Expand All @@ -85,7 +85,6 @@ private void RefreshInstalledApps()
cbx_InstallUninstallPackageUninstall.SelectedIndex = 0;
}


cbx_InstallUninstallPackageUninstall.Enabled = true;
}
}
Expand Down
Loading