From 259f20cf200dee9d7bb30c0b7f71971d0cc4c019 Mon Sep 17 00:00:00 2001 From: Tristan Roux Date: Fri, 3 May 2019 21:00:12 +0200 Subject: [PATCH] Finishing the rework of the downloader. --- Opus/Code/Api/Services/Downloader.cs | 15 +- Opus/Code/UI/Fragments/DownloadQueue.cs | 3 - Opus/Resources/Resource.Designer.cs | 299 ++++++++++++------------ Opus/Resources/layout/DownloadQueue.xml | 5 +- Opus/Resources/values-fr/strings.xml | 1 + Opus/Resources/values/strings.xml | 1 + 6 files changed, 168 insertions(+), 156 deletions(-) diff --git a/Opus/Code/Api/Services/Downloader.cs b/Opus/Code/Api/Services/Downloader.cs index 00f92c8..0a8c23b 100644 --- a/Opus/Code/Api/Services/Downloader.cs +++ b/Opus/Code/Api/Services/Downloader.cs @@ -286,7 +286,6 @@ namespace Opus.Api.Services MediaScannerConnection.ScanFile(this, new string[] { filePath }, null, this); queue[position].State = DownloadState.Completed; - UpdateList(position); if (!queue.Exists(x => x.State == DownloadState.None || x.State == DownloadState.Downloading || x.State == DownloadState.Initialization || x.State == DownloadState.MetaData)) { @@ -294,6 +293,8 @@ namespace Opus.Api.Services DownloadQueue.instance?.Finish(); queue.Clear(); } + else + UpdateList(position); } public void OnScanCompleted(string path, Uri uri) @@ -340,8 +341,16 @@ namespace Opus.Api.Services } } - queue.AddRange(files); - StartDownload(); + queue.RemoveAll(x => x.State == DownloadState.Completed || x.State == DownloadState.UpToDate || x.State == DownloadState.Canceled); + if(files.Count(x => x.State == DownloadState.None) > 0) + { + queue.AddRange(files); + StartDownload(); + } + else + { + Toast.MakeText(MainActivity.instance, Resource.String.playlist_uptodate, ToastLength.Long).Show(); + } await Task.Run(() => { diff --git a/Opus/Code/UI/Fragments/DownloadQueue.cs b/Opus/Code/UI/Fragments/DownloadQueue.cs index c803215..cb58950 100644 --- a/Opus/Code/UI/Fragments/DownloadQueue.cs +++ b/Opus/Code/UI/Fragments/DownloadQueue.cs @@ -33,8 +33,6 @@ namespace Opus.Fragments SupportActionBar.Title = GetString(Resource.String.download_queue); SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.Close); SupportActionBar.SetDisplayHomeAsUpEnabled(true); - Window.SetStatusBarColor(Color.Argb(255, 33, 33, 33)); - ListView = FindViewById(Resource.Id.list); ListView.SetLayoutManager(new FixedLinearLayoutManager(this)); @@ -50,7 +48,6 @@ namespace Opus.Fragments protected override void OnStop() { instance = null; - Window.SetStatusBarColor(Color.Transparent); base.OnStop(); } diff --git a/Opus/Resources/Resource.Designer.cs b/Opus/Resources/Resource.Designer.cs index 6106a47..58b4dbc 100644 --- a/Opus/Resources/Resource.Designer.cs +++ b/Opus/Resources/Resource.Designer.cs @@ -7186,8 +7186,8 @@ namespace Opus // aapt resource value: 0x7f0d0072 public const int abc_toolbar_collapse_description = 2131558514; - // aapt resource value: 0x7f0d0132 - public const int add = 2131558706; + // aapt resource value: 0x7f0d0133 + public const int add = 2131558707; // aapt resource value: 0x7f0d00fc public const int add_playlist = 2131558652; @@ -7204,8 +7204,8 @@ namespace Opus // aapt resource value: 0x7f0d00da public const int add_to_queue = 2131558618; - // aapt resource value: 0x7f0d011b - public const int album = 2131558683; + // aapt resource value: 0x7f0d011c + public const int album = 2131558684; // aapt resource value: 0x7f0d00ea public const int all = 2131558634; @@ -7213,14 +7213,14 @@ namespace Opus // aapt resource value: 0x7f0d0080 public const int appbar_scrolling_view_behavior = 2131558528; - // aapt resource value: 0x7f0d013c - public const int appearances = 2131558716; + // aapt resource value: 0x7f0d013d + public const int appearances = 2131558717; - // aapt resource value: 0x7f0d012f - public const int apply = 2131558703; + // aapt resource value: 0x7f0d0130 + public const int apply = 2131558704; - // aapt resource value: 0x7f0d011a - public const int artist = 2131558682; + // aapt resource value: 0x7f0d011b + public const int artist = 2131558683; // aapt resource value: 0x7f0d00cb public const int autoplay = 2131558603; @@ -7231,11 +7231,11 @@ namespace Opus // aapt resource value: 0x7f0d0111 public const int badplaylisturl = 2131558673; - // aapt resource value: 0x7f0d0136 - public const int behavior = 2131558710; + // aapt resource value: 0x7f0d0137 + public const int behavior = 2131558711; - // aapt resource value: 0x7f0d0155 - public const int beta_available = 2131558741; + // aapt resource value: 0x7f0d0156 + public const int beta_available = 2131558742; // aapt resource value: 0x7f0d0081 public const int bottom_sheet_behavior = 2131558529; @@ -7243,17 +7243,17 @@ namespace Opus // aapt resource value: 0x7f0d00b4 public const int browse = 2131558580; - // aapt resource value: 0x7f0d0130 - public const int cancel = 2131558704; + // aapt resource value: 0x7f0d0131 + public const int cancel = 2131558705; - // aapt resource value: 0x7f0d015b - public const int cancelling = 2131558747; + // aapt resource value: 0x7f0d015c + public const int cancelling = 2131558748; // aapt resource value: 0x7f0d00f2 public const int cant_delete = 2131558642; - // aapt resource value: 0x7f0d0158 - public const int cant_play_non_youtube = 2131558744; + // aapt resource value: 0x7f0d0159 + public const int cant_play_non_youtube = 2131558745; // aapt resource value: 0x7f0d00b9 public const int cast = 2131558585; @@ -7336,11 +7336,11 @@ namespace Opus // aapt resource value: 0x7f0d0015 public const int cast_play = 2131558421; - // aapt resource value: 0x7f0d012d - public const int cast_queue_push = 2131558701; - // aapt resource value: 0x7f0d012e - public const int cast_queue_pushed = 2131558702; + public const int cast_queue_push = 2131558702; + + // aapt resource value: 0x7f0d012f + public const int cast_queue_pushed = 2131558703; // aapt resource value: 0x7f0d0016 public const int cast_rewind = 2131558422; @@ -7390,11 +7390,11 @@ namespace Opus // aapt resource value: 0x7f0d0025 public const int cast_unmute = 2131558437; - // aapt resource value: 0x7f0d011d - public const int change_albumart = 2131558685; + // aapt resource value: 0x7f0d011e + public const int change_albumart = 2131558686; - // aapt resource value: 0x7f0d0122 - public const int changes_saved = 2131558690; + // aapt resource value: 0x7f0d0123 + public const int changes_saved = 2131558691; // aapt resource value: 0x7f0d00ec public const int channels = 2131558636; @@ -7405,8 +7405,8 @@ namespace Opus // aapt resource value: 0x7f0d0083 public const int character_counter_pattern = 2131558531; - // aapt resource value: 0x7f0d0142 - public const int check_updates = 2131558722; + // aapt resource value: 0x7f0d0143 + public const int check_updates = 2131558723; // aapt resource value: 0x7f0d00b0 public const int clientID = 2131558576; @@ -7468,14 +7468,14 @@ namespace Opus // aapt resource value: 0x7f0d003b public const int common_signin_button_text_long = 2131558459; - // aapt resource value: 0x7f0d012c - public const int completed = 2131558700; + // aapt resource value: 0x7f0d012d + public const int completed = 2131558701; - // aapt resource value: 0x7f0d014f - public const int country_blocked = 2131558735; + // aapt resource value: 0x7f0d0150 + public const int country_blocked = 2131558736; - // aapt resource value: 0x7f0d0116 - public const int create_local = 2131558678; + // aapt resource value: 0x7f0d0117 + public const int create_local = 2131558679; // aapt resource value: 0x7f0d00cd public const int create_mix = 2131558605; @@ -7483,17 +7483,17 @@ namespace Opus // aapt resource value: 0x7f0d00d1 public const int create_mix_from_song = 2131558609; - // aapt resource value: 0x7f0d0112 - public const int create_playlist = 2131558674; + // aapt resource value: 0x7f0d0113 + public const int create_playlist = 2131558675; + + // aapt resource value: 0x7f0d0119 + public const int create_synced = 2131558681; // aapt resource value: 0x7f0d0118 - public const int create_synced = 2131558680; + public const int create_youtube = 2131558680; - // aapt resource value: 0x7f0d0117 - public const int create_youtube = 2131558679; - - // aapt resource value: 0x7f0d0140 - public const int dark_theme = 2131558720; + // aapt resource value: 0x7f0d0141 + public const int dark_theme = 2131558721; // aapt resource value: 0x7f0d00dc public const int delete = 2131558620; @@ -7501,20 +7501,20 @@ namespace Opus // aapt resource value: 0x7f0d010b public const int delete_playlist = 2131558667; - // aapt resource value: 0x7f0d0127 - public const int deleted_file = 2131558695; + // aapt resource value: 0x7f0d0128 + public const int deleted_file = 2131558696; // aapt resource value: 0x7f0d00d4 public const int download = 2131558612; - // aapt resource value: 0x7f0d011f - public const int download_albumart = 2131558687; - - // aapt resource value: 0x7f0d0138 - public const int download_directory = 2131558712; - // aapt resource value: 0x7f0d0120 - public const int download_meta = 2131558688; + public const int download_albumart = 2131558688; + + // aapt resource value: 0x7f0d0139 + public const int download_directory = 2131558713; + + // aapt resource value: 0x7f0d0121 + public const int download_meta = 2131558689; // aapt resource value: 0x7f0d00ee public const int download_path_error = 2131558638; @@ -7522,20 +7522,20 @@ namespace Opus // aapt resource value: 0x7f0d00ed public const int download_path_not_set = 2131558637; - // aapt resource value: 0x7f0d0126 - public const int download_queue = 2131558694; + // aapt resource value: 0x7f0d0127 + public const int download_queue = 2131558695; // aapt resource value: 0x7f0d00f0 public const int downloading = 2131558640; - // aapt resource value: 0x7f0d0159 - public const int downloading_notification = 2131558745; + // aapt resource value: 0x7f0d015a + public const int downloading_notification = 2131558746; - // aapt resource value: 0x7f0d012a - public const int downloading_status = 2131558698; + // aapt resource value: 0x7f0d012b + public const int downloading_status = 2131558699; - // aapt resource value: 0x7f0d0156 - public const int downloading_update = 2131558742; + // aapt resource value: 0x7f0d0157 + public const int downloading_update = 2131558743; // aapt resource value: 0x7f0d00d3 public const int edit_metadata = 2131558611; @@ -7672,11 +7672,11 @@ namespace Opus // aapt resource value: 0x7f0d00c4 public const int hours = 2131558596; - // aapt resource value: 0x7f0d0128 - public const int initialization = 2131558696; + // aapt resource value: 0x7f0d0129 + public const int initialization = 2131558697; - // aapt resource value: 0x7f0d0133 - public const int later = 2131558707; + // aapt resource value: 0x7f0d0134 + public const int later = 2131558708; // aapt resource value: 0x7f0d00d7 public const int list_songs = 2131558615; @@ -7693,29 +7693,29 @@ namespace Opus // aapt resource value: 0x7f0d0100 public const int localpl_noperm = 2131558656; - // aapt resource value: 0x7f0d0146 - public const int log_in = 2131558726; - // aapt resource value: 0x7f0d0147 - public const int log_out = 2131558727; - - // aapt resource value: 0x7f0d0145 - public const int logged_in = 2131558725; + public const int log_in = 2131558727; // aapt resource value: 0x7f0d0148 - public const int login_disabled = 2131558728; + public const int log_out = 2131558728; - // aapt resource value: 0x7f0d0139 - public const int max_download = 2131558713; + // aapt resource value: 0x7f0d0146 + public const int logged_in = 2131558726; + + // aapt resource value: 0x7f0d0149 + public const int login_disabled = 2131558729; // aapt resource value: 0x7f0d013a - public const int max_download_dialog = 2131558714; + public const int max_download = 2131558714; - // aapt resource value: 0x7f0d0129 - public const int metadata = 2131558697; + // aapt resource value: 0x7f0d013b + public const int max_download_dialog = 2131558715; - // aapt resource value: 0x7f0d0123 - public const int metdata_error_noid = 2131558691; + // aapt resource value: 0x7f0d012a + public const int metadata = 2131558698; + + // aapt resource value: 0x7f0d0124 + public const int metdata_error_noid = 2131558692; // aapt resource value: 0x7f0d00c1 public const int minute = 2131558593; @@ -7726,11 +7726,11 @@ namespace Opus // aapt resource value: 0x7f0d00e4 public const int more = 2131558628; - // aapt resource value: 0x7f0d0124 - public const int mount_error = 2131558692; - // aapt resource value: 0x7f0d0125 - public const int mount_error_action = 2131558693; + public const int mount_error = 2131558693; + + // aapt resource value: 0x7f0d0126 + public const int mount_error_action = 2131558694; // aapt resource value: 0x7f0d0040 public const int mr_button_content_description = 2131558464; @@ -7807,14 +7807,14 @@ namespace Opus // aapt resource value: 0x7f0d0087 public const int mtrl_chip_close_icon_content_description = 2131558535; - // aapt resource value: 0x7f0d0115 - public const int new_playlist = 2131558677; + // aapt resource value: 0x7f0d0116 + public const int new_playlist = 2131558678; // aapt resource value: 0x7f0d00be public const int next_loading = 2131558590; - // aapt resource value: 0x7f0d0135 - public const int no = 2131558709; + // aapt resource value: 0x7f0d0136 + public const int no = 2131558710; // aapt resource value: 0x7f0d00f7 public const int no_channel = 2131558647; @@ -7822,8 +7822,8 @@ namespace Opus // aapt resource value: 0x7f0d00f6 public const int no_lives = 2131558646; - // aapt resource value: 0x7f0d014a - public const int no_permission = 2131558730; + // aapt resource value: 0x7f0d014b + public const int no_permission = 2131558731; // aapt resource value: 0x7f0d00f5 public const int no_playlist = 2131558645; @@ -7834,17 +7834,17 @@ namespace Opus // aapt resource value: 0x7f0d00e9 public const int no_song = 2131558633; - // aapt resource value: 0x7f0d014b - public const int no_song_mix = 2131558731; + // aapt resource value: 0x7f0d014c + public const int no_song_mix = 2131558732; // aapt resource value: 0x7f0d00f4 public const int no_track = 2131558644; - // aapt resource value: 0x7f0d0144 - public const int not_log = 2131558724; + // aapt resource value: 0x7f0d0145 + public const int not_log = 2131558725; - // aapt resource value: 0x7f0d0150 - public const int not_streamable = 2131558736; + // aapt resource value: 0x7f0d0151 + public const int not_streamable = 2131558737; // aapt resource value: 0x7f0d00bd public const int nothing = 2131558589; @@ -7852,14 +7852,14 @@ namespace Opus // aapt resource value: 0x7f0d00c0 public const int off = 2131558592; - // aapt resource value: 0x7f0d0131 - public const int ok = 2131558705; + // aapt resource value: 0x7f0d0132 + public const int ok = 2131558706; // aapt resource value: 0x7f0d00c6 public const int open_youtube = 2131558598; - // aapt resource value: 0x7f0d0141 - public const int others = 2131558721; + // aapt resource value: 0x7f0d0142 + public const int others = 2131558722; // aapt resource value: 0x7f0d0088 public const int password_toggle_content_description = 2131558536; @@ -7879,8 +7879,8 @@ namespace Opus // aapt resource value: 0x7f0d00c8 public const int paused = 2131558600; - // aapt resource value: 0x7f0d011e - public const int pick_album_local = 2131558686; + // aapt resource value: 0x7f0d011f + public const int pick_album_local = 2131558687; // aapt resource value: 0x7f0d00ce public const int play = 2131558606; @@ -7918,6 +7918,9 @@ namespace Opus // aapt resource value: 0x7f0d0108 public const int playlist_unsaved = 2131558664; + // aapt resource value: 0x7f0d0112 + public const int playlist_uptodate = 2131558674; + // aapt resource value: 0x7f0d00b5 public const int playlists = 2131558581; @@ -7960,11 +7963,11 @@ namespace Opus // aapt resource value: 0x7f0d00ca public const int save_as_playlist = 2131558602; - // aapt resource value: 0x7f0d0114 - public const int save_folder_playlist = 2131558676; + // aapt resource value: 0x7f0d0115 + public const int save_folder_playlist = 2131558677; - // aapt resource value: 0x7f0d0113 - public const int save_playlist = 2131558675; + // aapt resource value: 0x7f0d0114 + public const int save_playlist = 2131558676; // aapt resource value: 0x7f0d0073 public const int search_menu_title = 2131558515; @@ -8008,35 +8011,35 @@ namespace Opus // aapt resource value: 0x7f0d00de public const int sync_now = 2131558622; - // aapt resource value: 0x7f0d013b - public const int sync_remove = 2131558715; + // aapt resource value: 0x7f0d013c + public const int sync_remove = 2131558716; // aapt resource value: 0x7f0d00f1 public const int syncing = 2131558641; - // aapt resource value: 0x7f0d015a - public const int tap_details = 2131558746; - - // aapt resource value: 0x7f0d013d - public const int theme = 2131558717; + // aapt resource value: 0x7f0d015b + public const int tap_details = 2131558747; // aapt resource value: 0x7f0d013e - public const int theme_dialog = 2131558718; + public const int theme = 2131558718; + + // aapt resource value: 0x7f0d013f + public const int theme_dialog = 2131558719; // aapt resource value: 0x7f0d00c5 public const int timer = 2131558597; - // aapt resource value: 0x7f0d014d - public const int timout = 2131558733; + // aapt resource value: 0x7f0d014e + public const int timout = 2131558734; - // aapt resource value: 0x7f0d0119 - public const int title = 2131558681; + // aapt resource value: 0x7f0d011a + public const int title = 2131558682; - // aapt resource value: 0x7f0d0149 - public const int undo = 2131558729; + // aapt resource value: 0x7f0d014a + public const int undo = 2131558730; - // aapt resource value: 0x7f0d0121 - public const int undo_change = 2131558689; + // aapt resource value: 0x7f0d0122 + public const int undo_change = 2131558690; // aapt resource value: 0x7f0d00e1 public const int unfork = 2131558625; @@ -8044,29 +8047,29 @@ namespace Opus // aapt resource value: 0x7f0d010e public const int unfork_playlist = 2131558670; - // aapt resource value: 0x7f0d014e - public const int unknow = 2131558734; + // aapt resource value: 0x7f0d014f + public const int unknow = 2131558735; // aapt resource value: 0x7f0d00bc public const int up_next = 2131558588; - // aapt resource value: 0x7f0d0154 - public const int up_to_date = 2131558740; + // aapt resource value: 0x7f0d0155 + public const int up_to_date = 2131558741; - // aapt resource value: 0x7f0d012b - public const int up_to_date_status = 2131558699; - - // aapt resource value: 0x7f0d0152 - public const int update = 2131558738; + // aapt resource value: 0x7f0d012c + public const int up_to_date_status = 2131558700; // aapt resource value: 0x7f0d0153 - public const int update_message = 2131558739; + public const int update = 2131558739; - // aapt resource value: 0x7f0d0151 - public const int update_no_internet = 2131558737; + // aapt resource value: 0x7f0d0154 + public const int update_message = 2131558740; - // aapt resource value: 0x7f0d0157 - public const int updating = 2131558743; + // aapt resource value: 0x7f0d0152 + public const int update_no_internet = 2131558738; + + // aapt resource value: 0x7f0d0158 + public const int updating = 2131558744; // aapt resource value: 0x7f0d003e public const int v7_preference_off = 2131558462; @@ -8074,20 +8077,20 @@ namespace Opus // aapt resource value: 0x7f0d003f public const int v7_preference_on = 2131558463; - // aapt resource value: 0x7f0d0143 - public const int version = 2131558723; + // aapt resource value: 0x7f0d0144 + public const int version = 2131558724; - // aapt resource value: 0x7f0d0137 - public const int volume = 2131558711; + // aapt resource value: 0x7f0d0138 + public const int volume = 2131558712; - // aapt resource value: 0x7f0d013f - public const int white_theme = 2131558719; + // aapt resource value: 0x7f0d0140 + public const int white_theme = 2131558720; - // aapt resource value: 0x7f0d0134 - public const int yes = 2131558708; + // aapt resource value: 0x7f0d0135 + public const int yes = 2131558709; - // aapt resource value: 0x7f0d014c - public const int youtube_endpoint = 2131558732; + // aapt resource value: 0x7f0d014d + public const int youtube_endpoint = 2131558733; // aapt resource value: 0x7f0d00fd public const int youtube_loading_error = 2131558653; @@ -8101,8 +8104,8 @@ namespace Opus // aapt resource value: 0x7f0d00b7 public const int youtube_search = 2131558583; - // aapt resource value: 0x7f0d011c - public const int youtubeid = 2131558684; + // aapt resource value: 0x7f0d011d + public const int youtubeid = 2131558685; // aapt resource value: 0x7f0d00b2 public const int yt_api_key = 2131558578; diff --git a/Opus/Resources/layout/DownloadQueue.xml b/Opus/Resources/layout/DownloadQueue.xml index 9e4d152..edf2348 100644 --- a/Opus/Resources/layout/DownloadQueue.xml +++ b/Opus/Resources/layout/DownloadQueue.xml @@ -5,11 +5,12 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:fitsSystemWindows="true"> + android:orientation="vertical" > Entrer l\'url ou l\'id de la playlist que vous voulez ajouter Ajoutez une playlist a votre bibliothèque en utilisant son URL. Impossible de trouver une playlist correspondant a cette URL. + Cette playlist est déjà a jour. Créer une nouvelle playlist diff --git a/Opus/Resources/values/strings.xml b/Opus/Resources/values/strings.xml index b4121ac..d123759 100644 --- a/Opus/Resources/values/strings.xml +++ b/Opus/Resources/values/strings.xml @@ -116,6 +116,7 @@ Enter the url or the id of the playlist you want to add Add a youtube playlist to your library by using it\'s url. Can\'t find a playlist with this URL. + This playlist is up to date. Create a new playlist