Skip to content

Commit

Permalink
Added folder unrolling #19
Browse files Browse the repository at this point in the history
Added partial multilang support
  • Loading branch information
T0biasCZe committed Jan 22, 2024
1 parent 881a48f commit c659b71
Show file tree
Hide file tree
Showing 18 changed files with 1,402 additions and 471 deletions.
9 changes: 9 additions & 0 deletions AdbFileManager/AdbFileManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Update="strings.cs.Designer.cs">
<DependentUpon>strings.cs.resx</DependentUpon>
<DesignTime>True</DesignTime>
Expand Down Expand Up @@ -160,6 +165,10 @@
<None Update="icons\video2.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
Expand Down
27 changes: 27 additions & 0 deletions AdbFileManager/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="AdbFileManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<AdbFileManager.Properties.Settings>
<setting name="keep_modification_date" serializeAs="String">
<value>False</value>
</setting>
<setting name="smooth_progressbar" serializeAs="String">
<value>False</value>
</setting>
<setting name="lang" serializeAs="String">
<value>0</value>
</setting>
<setting name="preview_on_doubleclick" serializeAs="String">
<value>False</value>
</setting>
<setting name="compatibility" serializeAs="String">
<value>False</value>
</setting>
</AdbFileManager.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion AdbFileManager/CurrentCommit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7216362
881a48f
10 changes: 10 additions & 0 deletions AdbFileManager/Form1.Designer.cs

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

185 changes: 158 additions & 27 deletions AdbFileManager/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
using System.Reflection.Metadata;
using System.Text;
using System.Globalization;
using Microsoft.WindowsAPICodePack.ApplicationServices;
using System.Reflection;
using System.Resources;
using Microsoft.WindowsAPICodePack.Dialogs;
using TaskDialogButton = System.Windows.Forms.TaskDialogButton;
using TaskDialog = System.Windows.Forms.TaskDialog;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace AdbFileManager {
public partial class Form1 : Form {
Expand All @@ -23,9 +30,12 @@ public partial class Form1 : Form {
public bool temp_folder_created = false;
public Form1() {
_Form1 = this;
Functions.set_language();
InitializeComponent();
load_lang();

InitializeComponent();

load_lang_combobox();
load_settings();

this.Controls.Add(panel2);
panel1.Controls.Remove(panel2);
Expand Down Expand Up @@ -155,16 +165,7 @@ private int ParseProgress(string line) {
private void android2pc_Click(object sender, EventArgs e) {
string destinationFolder = ShellObject.FromParsingName(explorerBrowser1.NavigationLog.CurrentLocation.ParsingName).Properties.System.ItemPathDisplay.Value;
//MessageBox.Show(destinationFolder);
int filecount = dataGridView1.SelectedRows.Count;
int copied = 0;
Form2 progressbar = new Form2();
progressbar.Show();
//try to make the progressbar get shown
progressbar.BringToFront();
progressbar.Activate();
progressbar.Focus();

copying = true;
string date = checkBox_filedate.Checked ? " -a " : "";
List<File> files = new List<File>();
foreach(DataGridViewRow row in dataGridView1.SelectedRows) {
Expand All @@ -177,7 +178,65 @@ private void android2pc_Click(object sender, EventArgs e) {
files.Add(new File(name, size, datee, permissions, isDirectory));
}

progressbar.Close();
if(checkBox_unwrapfolders.Checked) {
ProgressBarMarquee pgm = new ProgressBarMarquee();
ResourceManager rm = new ResourceManager("AdbFileManager.strings", Assembly.GetExecutingAssembly());
pgm.set(rm.GetString("unwrap_wait"), rm.GetString("unwrap_wait_title"));
pgm.Show(); pgm.BringToFront(); pgm.Activate(); pgm.Focus();

//go through the list, and if there is folder, remove it and add it's contents to the list.
restart:;
for(int i = 0; i < files.Count; i++) {
File file = files[i];
if(Functions.isFolder(file)) {
Console.WriteLine("unwraping folder: " + file.name);
DataTable newfiles_table = Functions.getDir(directoryPath + file.name, checkBox_android6fix.Checked);
Console.WriteLine("removed folder status: " + files.Remove(file));
List<File> newfiles = new List<File>();
foreach(DataRow row in newfiles_table.Rows) {
//put each selected file into a list
string name = row.ItemArray[1].ToString();
string size = row.ItemArray[2].ToString();
string datee = row.ItemArray[3].ToString();
string permissions = row.ItemArray[4].ToString();
bool isDirectory = Functions.isFolder(permissions);
newfiles.Add(new File(file.name + "/" + name, size, datee, permissions, isDirectory));
Console.WriteLine("added file: " + name);
}
files.AddRange(newfiles);
if(pgm.cancel) {
pgm.delete();
copying = false;
}
goto restart;
}
}
}

int filecount = files.Count();
int copied = 0;
Form2 progressbar = new Form2();
progressbar.Show();
//try to make the progressbar get shown
progressbar.BringToFront();
progressbar.Activate();
progressbar.Focus();
copying = true;

foreach(File file in files) {
string sourcefile = directoryPath + file.name;
string destinationFile = $"\"{destinationFolder.Replace('\\', '/')}/{file.name}\"";
Console.WriteLine(destinationFile);
string command = $"adb pull {date} \"{sourcefile}\" {destinationFile}";
System.IO.Directory.CreateDirectory(Path.GetDirectoryName(destinationFile));
Console.WriteLine(command);
progressbar.update(copied, filecount, directoryPath, destinationFolder, file.name);
Console.WriteLine(adb(command));
copied++;
}


progressbar.delete();
copying = false;

//string sourceFileName = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
Expand Down Expand Up @@ -337,7 +396,77 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
if(Directory.Exists(tempPath)) {
Directory.Delete(tempPath, true);
}

save_settings();
}

enum Languages {
English,
Cestina,
Polski,
Deutsch,
Japanese,
Espanol
}
private void save_settings() {
Properties.Settings.Default.preview_on_doubleclick = checkBox_preview.Checked;
Properties.Settings.Default.smooth_progressbar = checkBox_unwrapfolders.Checked;
Properties.Settings.Default.keep_modification_date = checkBox_filedate.Checked;
Properties.Settings.Default.compatibility = checkBox_android6fix.Checked;

Properties.Settings.Default.lang = (ushort)comboBox_lang.SelectedIndex;
Properties.Settings.Default.Save();
}
private void load_settings() {
checkBox_preview.Checked = Properties.Settings.Default.preview_on_doubleclick;
checkBox_unwrapfolders.Checked = Properties.Settings.Default.smooth_progressbar;
checkBox_filedate.Checked = Properties.Settings.Default.keep_modification_date;
checkBox_android6fix.Checked = Properties.Settings.Default.compatibility;
comboBox_lang.SelectedIndex = Properties.Settings.Default.lang;
}
private void load_lang_combobox() {
comboBox_lang.Items.Clear();

comboBox_lang.Items.Add("English");
comboBox_lang.Items.Add("Čeština");
comboBox_lang.Items.Add("Polski");
comboBox_lang.Items.Add("Deutsch");
comboBox_lang.Items.Add("Japanese");
comboBox_lang.Items.Add("Espanol");

if(Properties.Settings.Default.lang != null) {
comboBox_lang.SelectedItem = Properties.Settings.Default.lang;
}
else {
comboBox_lang.SelectedItem = "English";
}

}
private void load_lang() {
ushort? loaded_lang = Properties.Settings.Default.lang;
if(loaded_lang == null) loaded_lang = (ushort)Languages.English;
switch((Languages)loaded_lang) {
case Languages.English:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
break;
case Languages.Cestina:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("cs");
break;
case Languages.Polski:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("pl");
break;
case Languages.Deutsch:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
break;
case Languages.Japanese:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("jp");
break;
case Languages.Espanol:
Thread.CurrentThread.CurrentUICulture = new CultureInfo("es");
break;
}

}
}

public static class Functions {
Expand All @@ -350,24 +479,18 @@ public static class Functions {
public static string[] executableExtensions = { ".exe", ".dll", ".bat", ".msi", ".jar", ".py", ".sh", ".apk" };

public static bool isFolder(string path) {
/*//i said do not look :(
//folders have these filesize values
if(path.Contains("3452")) return true;
if(path.Contains("4096")) return true;
else if(path.Contains("512000")) return true;
else if(path.Contains("24576")) return true;
else if(path.Contains("8192")) return true;
else if(path.Contains("53248")) return true;
else if(path.Contains("122880")) return true;
else if(path.Contains("20480")) return true;
else return false;*/
if(path[0] == 'd') return true; //the first character of the line is 'd' if it's a directory
if(path == null) return false;
if(path.ToLower().Trim()[0] == 'd') return true; //the first character of the line is 'd' if it's a directory
else return false;
}
public static bool isFolder(File file) {
if(file.permissions.ToLower().Trim()[0] == 'd') return true; //the first character of the line is 'd' if it's a directory
else return false;
}

public static DataTable getDir(string directoryPath, bool old_android) {
// Retrieve a list of files in the specified directory
string command = old_android ? $"adb shell ls -lL {directoryPath}" : $"adb shell ls -l {directoryPath}";
string command = old_android ? $"adb shell ls -lL \"'{directoryPath}'\"" : $"adb shell ls -l \"'{directoryPath}'\"";
Console.WriteLine(command);
string output = Form1.adb(command);
string[] lines = output.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
Expand Down Expand Up @@ -489,8 +612,16 @@ public static string[] CustomSplit(string text, char delimiter) {
return result;
}

public static void set_language() {
Thread.CurrentThread.CurrentUICulture = new CultureInfo("cs-CZ");
public static void set_language(string jazyk) {
if(jazyk == "Polski") {
Thread.CurrentThread.CurrentUICulture = new CultureInfo("pl");
}
else if(jazyk == "Čeština") {
Thread.CurrentThread.CurrentUICulture = new CultureInfo("cs");
}
else {
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
}
}
}
public static class Icons {
Expand Down
4 changes: 0 additions & 4 deletions AdbFileManager/Form1.cs.resx
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,4 @@ Při zavření programu se dočasné soubory smažou
AA/+AAAA/8AAH/4AAAA=
</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>Inherit</value>
</data>
</root>
Loading

0 comments on commit c659b71

Please sign in to comment.