diff --git a/spotify-mini-player/src/functions.php b/spotify-mini-player/src/functions.php index 88871b2a..32e6f389 100644 --- a/spotify-mini-player/src/functions.php +++ b/spotify-mini-player/src/functions.php @@ -130,6 +130,12 @@ function invokeMopidyMethod($w, $method, $params, $displayError = true) */ function switchThemeColor($w,$theme_color) { + touch($w->data().'/change_theme_color_in_progress'); + $nb_images_downloaded = 0; + $nb_images_total = 222; + $w->write('Change Theme Color▹'. 0 .'▹'. $nb_images_total .'▹'.time().'▹'.'starting', 'change_theme_color_in_progress'); + $in_progress_data = $w->read('change_theme_color_in_progress'); + $words = explode('▹', $in_progress_data); // Read settings from JSON @@ -155,6 +161,11 @@ function switchThemeColor($w,$theme_color) ); $w->request("$icon_url", $options); + + ++$nb_images_downloaded; + if ($nb_images_downloaded % 10 === 0) { + $w->write('Change Theme Color▹'.$nb_images_downloaded.'▹'.$nb_images_total.'▹'.$words[3].'▹'.'Icons', 'change_theme_color_in_progress'); + } } // check icons from images directory @@ -267,6 +278,10 @@ function switchThemeColor($w,$theme_color) ); $w->request("$icon_url", $options); + ++$nb_images_downloaded; + if ($nb_images_downloaded % 10 === 0) { + $w->write('Change Theme Color▹'.$nb_images_downloaded.'▹'.$nb_images_total.'▹'.$words[3].'▹'.'Icons UUID', 'change_theme_color_in_progress'); + } } // check UUID images @@ -335,6 +350,11 @@ function switchThemeColor($w,$theme_color) ); $w->request("$icon_url", $options); + + ++$nb_images_downloaded; + if ($nb_images_downloaded % 10 === 0) { + $w->write('Change Theme Color▹'.$nb_images_downloaded.'▹'.$nb_images_total.'▹'.$words[3].'▹'.'Icons remote', 'change_theme_color_in_progress'); + } } // check UUID images @@ -363,6 +383,11 @@ function switchThemeColor($w,$theme_color) ); $w->request("$icon_url", $options); + + ++$nb_images_downloaded; + if ($nb_images_downloaded % 10 === 0) { + $w->write('Change Theme Color▹'.$nb_images_downloaded.'▹'.$nb_images_total.'▹'.$words[3].'▹'.'Icons UUID remote page', 'change_theme_color_in_progress'); + } } // check UUID images @@ -390,6 +415,7 @@ function switchThemeColor($w,$theme_color) logMsg('Error(switchThemeColor): (failed to load Spotify Mini Player.app for '.$theme_color.')'); } + deleteTheFile($w->data().'/change_theme_color_in_progress'); if (!$hasError) { displayNotificationWithArtwork($w, 'All existing icons have been replaced by ' . $theme_color . ' icons', './images/change_theme_color.png', 'Settings'); } else { diff --git a/spotify-mini-player/src/main.php b/spotify-mini-player/src/main.php index 9efea50a..518a1688 100644 --- a/spotify-mini-player/src/main.php +++ b/spotify-mini-player/src/main.php @@ -92,6 +92,20 @@ } } +// check for download artworks in progress +$change_theme_color_in_progress = false; +if (file_exists($w->data().'/change_theme_color_in_progress')) { + $in_progress_data = $w->read('change_theme_color_in_progress'); + $change_theme_color_in_progress_words = explode('▹', $in_progress_data); + $elapsed_time = time() - $change_theme_color_in_progress_words[3]; + $change_theme_color_in_progress = true; + if ($change_theme_color_in_progress_words[2] != 0) { + $w->result(null, $w->data().'/change_theme_color_in_progress', $change_theme_color_in_progress_words[0].' in progress since '.beautifyTime($elapsed_time, true).' : '.floatToSquares(intval($change_theme_color_in_progress_words[1]) / intval($change_theme_color_in_progress_words[2])), $change_theme_color_in_progress_words[1].'/'.$change_theme_color_in_progress_words[2].' icons processed so far (empty icons can be seen until full download is complete)', './images/update_in_progress.png', 'no', null, ''); + } else { + $w->result(null, $w->data().'/change_theme_color_in_progress', $change_theme_color_in_progress_words[0].' in progress since '.beautifyTime($elapsed_time, true).' : '.floatToSquares(0), 'No icons processed so far (empty icons can be seen until full download is complete)', './images/update_in_progress.png', 'no', null, ''); + } +} + // Read settings from JSON $settings = getSettings($w);