Auto upload in progress

This commit is contained in:
Harry Fn Potter
2021-08-18 10:05:18 -04:00
parent 85fad7d3ad
commit 04289885c2
8 changed files with 215 additions and 37 deletions

View File

@@ -265,6 +265,7 @@
<None Include="Resources\battery11.png" />
<None Include="Resources\battery.png" />
<None Include="Resources\battery1.png" />
<None Include="Resources\ajax-loader.gif" />
<Content Include="Resources\bluekey.png" />
<Content Include="Resources\redkey.png" />
<None Include="Resources\greenkey.png" />

33
MainForm.Designer.cs generated
View File

@@ -41,6 +41,8 @@
this.copyBulkObbButton = new System.Windows.Forms.Button();
this.downloadInstallGameButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.ULLabel = new System.Windows.Forms.Label();
this.ULGif = new System.Windows.Forms.PictureBox();
this.BatteryLbl = new System.Windows.Forms.Label();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.downloadingLabel = new System.Windows.Forms.Label();
@@ -92,6 +94,7 @@
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.gamesPictureBox = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ULGif)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
this.otherContainer.SuspendLayout();
this.backupContainer.SuspendLayout();
@@ -239,7 +242,7 @@
this.getApkButton.Padding = new System.Windows.Forms.Padding(23, 0, 0, 0);
this.getApkButton.Size = new System.Drawing.Size(218, 28);
this.getApkButton.TabIndex = 2;
this.getApkButton.Text = "Extract App to Desktop";
this.getApkButton.Text = "Upload Selected App";
this.getApkButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.getApkButton.UseVisualStyleBackColor = false;
this.getApkButton.Click += new System.EventHandler(this.getApkButton_Click);
@@ -343,6 +346,8 @@
//
this.panel1.AutoScroll = true;
this.panel1.BackColor = global::AndroidSideloader.Properties.Settings.Default.ButtonColor;
this.panel1.Controls.Add(this.ULLabel);
this.panel1.Controls.Add(this.ULGif);
this.panel1.Controls.Add(this.BatteryLbl);
this.panel1.Controls.Add(this.pictureBox5);
this.panel1.Controls.Add(this.downloadingLabel);
@@ -366,6 +371,29 @@
this.panel1.Size = new System.Drawing.Size(218, 721);
this.panel1.TabIndex = 73;
//
// ULLabel
//
this.ULLabel.AutoSize = true;
this.ULLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ULLabel.ForeColor = System.Drawing.Color.Snow;
this.ULLabel.Location = new System.Drawing.Point(154, 683);
this.ULLabel.Name = "ULLabel";
this.ULLabel.Size = new System.Drawing.Size(64, 13);
this.ULLabel.TabIndex = 87;
this.ULLabel.Text = "Uploading";
this.ULLabel.Visible = false;
//
// ULGif
//
this.ULGif.Enabled = false;
this.ULGif.Image = global::AndroidSideloader.Properties.Resources.ajax_loader;
this.ULGif.Location = new System.Drawing.Point(178, 699);
this.ULGif.Name = "ULGif";
this.ULGif.Size = new System.Drawing.Size(34, 17);
this.ULGif.TabIndex = 86;
this.ULGif.TabStop = false;
this.ULGif.Visible = false;
//
// BatteryLbl
//
this.BatteryLbl.AutoSize = true;
@@ -1260,6 +1288,7 @@
this.DragLeave += new System.EventHandler(this.Form1_DragLeave);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.ULGif)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
this.otherContainer.ResumeLayout(false);
this.backupContainer.ResumeLayout(false);
@@ -1338,6 +1367,8 @@
private System.Windows.Forms.Label BatteryLbl;
private System.Windows.Forms.PictureBox pictureBox5;
public System.Windows.Forms.ComboBox remotesList;
private System.Windows.Forms.PictureBox ULGif;
private System.Windows.Forms.Label ULLabel;
}
}

View File

@@ -758,6 +758,7 @@ namespace AndroidSideloader
m_combo.Invoke(() => { m_combo.MatchingMethod = StringMatchingMethod.NoWildcards; });
}
public static bool isuploading = false;
public static bool isworking = false;
private async void getApkButton_Click(object sender, EventArgs e)
{
@@ -811,23 +812,46 @@ namespace AndroidSideloader
while (t2.IsAlive)
await Task.Delay(100);
ChangeTitle("Zipping extracted application...");
string cmd = $"7z a {packageName}v{VersionInt}.zip .\\{packageName}\\*";
string cmd = $"7z a \"{GameName} v{VersionInt}.zip\" .\\{packageName}\\*";
string path = $"{Properties.Settings.Default.MainDir}\\7z.exe";
Thread t3 = new Thread(() =>
progressBar.Style = ProgressBarStyle.Continuous;
Thread t4 = new Thread(() =>
{
ADB.RunCommandToString(cmd, path);
});
t4.IsBackground = true;
t4.Start();
while (t4.IsAlive)
await Task.Delay(100);
ChangeTitle("Uploading to shared drive, you can continue to use Rookie while it uploads in the background.");
ULGif.Visible = true;
ULLabel.Visible = true;
ULGif.Enabled = true;
isworking = false;
isuploading = true;
Thread t3 = new Thread(() =>
{
string currentlyuploading = GameName;
ChangeTitle("Uploading to shared drive, you can continue to use Rookie while it uploads in the background.");
string Uploadoutput = RCLONE.runRcloneCommand($"copy \"{Properties.Settings.Default.MainDir}\\{GameName} v{VersionInt}.zip\" RSL-debuglogs:CleanGames").Output;
File.Delete($"{Properties.Settings.Default.MainDir}\\{GameName} v{VersionInt}.zip");
FlexibleMessageBox.Show($"Upload of {currentlyuploading} is complete! Thank you for your contribution!");
Directory.Delete($"{Properties.Settings.Default.MainDir}\\{packageName}", true);
});
t3.IsBackground = true;
t3.Start();
while (t3.IsAlive)
{
isuploading = true;
await Task.Delay(100);
File.Move($"{Properties.Settings.Default.MainDir}\\{packageName}v{VersionInt}.zip", $"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\{GameName} v{VersionInt}.zip");
FlexibleMessageBox.Show($"The app has been zipped and placed on your desktop as\n\n{GameName} v{VersionInt}.zip\n\nPlease upload this file to a free file hosting service like\n https://1fichier.com or https://mega.nz and share the link with a moderator.");
Directory.Delete($"{Properties.Settings.Default.MainDir}\\{packageName}", true);
progressBar.Style = ProgressBarStyle.Continuous;
}
ChangeTitle("");
isworking = false;
isuploading = false;
ULGif.Visible = false;
ULLabel.Visible = false;
ULGif.Enabled = false;
}
else MessageBox.Show("You must wait until each app is finished extracting to start another.");
}
@@ -1118,6 +1142,15 @@ namespace AndroidSideloader
DragDropLbl.Text = "";
ChangeTitle("");
}
public static string uploadcommand;
public static string uploadgamename;
public static ulong uploadversion;
public static string uploadcommand2;
public static string uploadgamename2;
public static ulong uploadversion2;
public static bool uploadyes;
public static bool secondpass = false;
private async void initListView()
{
gamesListView.Items.Clear();
@@ -1196,11 +1229,13 @@ namespace AndroidSideloader
}
}
}
if (!GameName.Contains("Beat Saber") && !dontget && !updatesnotified && cloudVersionInt > 0)
if (!GameName.Contains("Beat Saber") && !dontget && !updatesnotified && !isworking && cloudVersionInt > 0)
{
DialogResult dialogResult = FlexibleMessageBox.Show($"It seems you have a newer version of:\n\n{GameName}\n\nAll apps on Rookie are from donors, please share the updated files with us.\nThis is the only way to keep the apps up to date for everyone.\n\nNOTE: Rookie will only extract the APK/OBB which contain NO personal information whatsoever.", "Share clean files?", MessageBoxButtons.YesNo);
DialogResult dialogResult = FlexibleMessageBox.Show($"You have a newer version of:\n\n{GameName}\n\nRSL can AUTOMATICALLY UPLOAD the clean files to a shared drive in the background,\nthis is the only way to keep the apps up to date for everyone.\n\nNOTE: Rookie will only extract the APK/OBB which contain NO personal information whatsoever.", "CONTRIBUTE CLEAN FILES?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
uploadyes = true;
progressBar.Style = ProgressBarStyle.Marquee;
Thread t1 = new Thread(() =>
{
Sideloader.getApk(GameName);
@@ -1221,27 +1256,37 @@ namespace AndroidSideloader
while (t2.IsAlive)
await Task.Delay(1000);
ChangeTitle("Zipping extracted application...");
string cmd = $"7z a {packagename}v{installedVersionInt}.zip .\\{packagename}\\*";
string HWID = SideloaderUtilities.UUID();
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\{packagename}\\HWID.txt", HWID);
string cmd = $"7z a \"{GameName} v{installedVersionInt}.zip\" .\\{packagename}\\*";
string path = $"{Properties.Settings.Default.MainDir}\\7z.exe";
Thread t3 = new Thread(() =>
{
string HWID = SideloaderUtilities.UUID();
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\{packagename}\\HWID.txt", HWID);
ADB.RunCommandToString(cmd, path);
if (File.Exists($"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\{GameName} v{installedVersionInt}.zip"))
File.Delete($"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\{GameName} v{installedVersionInt}.zip");
File.Move($"{Properties.Settings.Default.MainDir}\\{packagename}v{installedVersionInt}.zip", $"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\{GameName} v{installedVersionInt}.zip");
FlexibleMessageBox.Show($"The app has been zipped and placed on your desktop as\n\n{GameName} v{installedVersionInt}.zip\n\nPlease upload this file to a free file hosting service like\n https://1fichier.com or https://mega.nz \nThen share the link to the moderators listed in the\npinned message on Telegram.");
Directory.Delete($"{Properties.Settings.Default.MainDir}\\{packagename}", true);
});
t3.IsBackground = true;
t3.Start();
while (t3.IsAlive)
await Task.Delay(100);
progressBar.Style = ProgressBarStyle.Continuous;
isworking = true;
if (File.Exists($"{Properties.Settings.Default.MainDir}\\{GameName} v{installedVersionInt}.zip"))
File.Delete($"{Properties.Settings.Default.MainDir}\\{GameName} v{installedVersionInt}.zip");
Thread t4 = new Thread(() =>
{
ADB.RunCommandToString(cmd, path);
});
t4.IsBackground = true;
t4.Start();
while (t4.IsAlive)
await Task.Delay(100);
isworking = false;
Directory.Delete($"{Properties.Settings.Default.MainDir}\\{packagename}", true);
if (!secondpass)
{
uploadcommand = $"copy \"{Properties.Settings.Default.MainDir}\\{GameName} v{installedVersionInt}.zip\" RSL-debuglogs:CleanGames";
uploadversion = installedVersionInt;
uploadgamename = GameName;
secondpass = true;
}
else if (secondpass)
{
uploadcommand2 = $"copy \"{Properties.Settings.Default.MainDir}\\{GameName} v{installedVersionInt}.zip\" RSL-debuglogs:CleanGames";
uploadversion2 = installedVersionInt;
uploadgamename2 = GameName;
}
ChangeTitle("");
}
}
@@ -1265,7 +1310,56 @@ namespace AndroidSideloader
gamesListView.EndUpdate();
updatesnotified = true;
if (uploadyes)
{
ChangeTitle("Uploading to shared drive, you can continue to use Rookie while it uploads in the background.");
ULGif.Visible = true;
ULLabel.Visible = true;
ULGif.Enabled = true;
if (uploadyes)
{
Thread t3 = new Thread(() =>
{
RCLONE.runRcloneCommand(uploadcommand);
FlexibleMessageBox.Show($"Upload of {uploadgamename} is complete! Thank you for your contribution!");
File.Delete($"{Properties.Settings.Default.MainDir}\\{uploadgamename} v{uploadversion}.zip");
});
t3.IsBackground = true;
t3.Start();
while (t3.IsAlive)
{
isuploading = true;
await Task.Delay(100);
}
}
if (secondpass)
{
Thread t3 = new Thread(() =>
{
RCLONE.runRcloneCommand(uploadcommand2);
FlexibleMessageBox.Show($"Upload of {uploadgamename2} is complete! Thank you for your contribution!");
File.Delete($"{Properties.Settings.Default.MainDir}\\{uploadgamename2} v{uploadversion2}.zip");
});
t3.IsBackground = true;
t3.Start();
while (t3.IsAlive)
{
isuploading = true;
await Task.Delay(100);
}
}
isuploading = false;
ULGif.Visible = false;
ULLabel.Visible = false;
ULGif.Enabled = false;
ChangeTitle("");
}
}
private void initMirrors(bool random)
@@ -1454,11 +1548,12 @@ without him none of this would be possible
if (remotesList.Items.Count > remotesList.SelectedIndex && !reset)
{
remotesList.SelectedIndex++;
SideloaderRCLONE.initGames(currentRemote);
steps++;
}
});
}
public bool isinstalling = false;
private async void downloadInstallGameButton_Click(object sender, EventArgs e)
{
{
@@ -1520,6 +1615,7 @@ without him none of this would be possible
ChangeTitle("");
return;
}
isinstalling = true;
//Add games to the queue
for (int i = 0; i < gamesToDownload.Length; i++)
gamesQueueList.Add(gamesToDownload[i]);
@@ -1648,7 +1744,7 @@ without him none of this would be possible
progressBar.Style = ProgressBarStyle.Continuous;
ChangeTitle("Installing game apk " + gameName, false);
etaLabel.Text = "ETA: Wait for install...";
speedLabel.Text = "DLS: Done downloading";
speedLabel.Text = "DLS: Finished";
if (File.Exists(Environment.CurrentDirectory + "\\" + gameName + "\\install.txt"))
isinstalltxt = true;
if (File.Exists(Environment.CurrentDirectory + "\\" + gameName + "\\Install.txt"))
@@ -1692,6 +1788,7 @@ without him none of this would be possible
Program.form.ChangeTitle($"Sideloading apk...");
output += ADB.Sideload(file, packagename);
});
apkThread.IsBackground = true;
apkThread.Start();
while (apkThread.IsAlive)
await Task.Delay(100);
@@ -1714,7 +1811,9 @@ without him none of this would be possible
while (obbThread.IsAlive)
await Task.Delay(100);
}
}
ChangeTitle($"Installation of {gameName} completed....");
}
if (Properties.Settings.Default.deleteAllAfterInstall)
{
@@ -1738,6 +1837,7 @@ without him none of this would be possible
ChangeTitlebarToDevice();
gamesAreDownloading = false;
ShowPrcOutput(output);
isinstalling = false;
listappsbtn();
initListView();
}
@@ -1801,8 +1901,36 @@ without him none of this would be possible
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
RCLONE.killRclone();
ADB.RunAdbCommandToString("kill-server");
if (isinstalling)
{
var res1 = FlexibleMessageBox.Show(this, "There are downloads and/or installations in progress,\nif you exit now you'll have to start the entire process over again.\nAre you sure you want to exit?", "Still downloading/installing.",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
if (res1 != DialogResult.Yes)
{
e.Cancel = true;
return;
}
}
else if (isuploading)
{
var res = FlexibleMessageBox.Show(this, "There is an upload still in progress, if you exit now\nyou'll have to start the entire process over again.\nAre you sure you want to exit?", "Still uploading.",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
if (res != DialogResult.Yes)
{
e.Cancel = true;
return;
}
else
{
RCLONE.killRclone();
ADB.RunAdbCommandToString("kill-server");
}
}
else
{
RCLONE.killRclone();
ADB.RunAdbCommandToString("kill-server");
}
}
private void ADBWirelessDisable_Click(object sender, EventArgs e)

View File

@@ -60,6 +60,16 @@ namespace AndroidSideloader.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap ajax_loader {
get {
object obj = ResourceManager.GetObject("ajax-loader", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -130,6 +130,9 @@
<data name="battery" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\battery.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="battery11" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\battery1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SearchGlass" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SearchGlass.PNG;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@@ -139,7 +142,7 @@
<data name="redkey" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\redkey.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="battery11" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\battery1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="ajax-loader" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ajax-loader.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -90,7 +90,7 @@ namespace AndroidSideloader
rclone.WaitForExit();
//if there is one of these errors, we switch the mirrors
if (error.Contains("cannot fetch token") || error.Contains("authError") || (error.Contains("quota") || error.Contains("exceeded") || error.Contains("directory not found")))
if (error.Contains("cannot fetch token") || error.Contains("authError") || (error.Contains("quota") || error.Contains("exceeded") || error.Contains("directory not found") || error.Contains("couldn't list")))
{
string oldRemote = MainForm.currentRemote;
try

BIN
Resources/ajax-loader.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

View File

@@ -94,12 +94,17 @@ namespace AndroidSideloader
{
gameProperties.Add(gameProperty);
}
gameProperties.Add("Upload Date");
gameProperties.Add("Last Updated");
tempGameList = Utilities.StringUtilities.RemoveEverythingBeforeFirst(tempGameList, "\n");
List<rcloneFolder> gameFolders = JsonConvert.DeserializeObject<List<rcloneFolder>>(RCLONE.runRcloneCommand($"lsjson \"{remote}:{RcloneGamesFolder}\"").Output);
if (gameFolders.Count < 1)
{
Program.form.SwitchMirrors();
gameFolders = JsonConvert.DeserializeObject<List<rcloneFolder>>(RCLONE.runRcloneCommand($"lsjson \"{remote}:{RcloneGamesFolder}\"").Output);
}
foreach (string game in tempGameList.Split('\n'))