diff options
48 files changed, 384 insertions, 268 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 400357c9..0eb73517 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,7 +2,7 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="github.daneren2005.dsub"
android:installLocation="internalOnly"
- android:versionCode="113"
+ android:versionCode="114"
android:versionName="4.7.1">
<uses-permission android:name="android.permission.INTERNET"/>
@@ -32,7 +32,7 @@ <application android:label="@string/common.appname"
android:backupAgent="github.daneren2005.dsub.util.SettingsBackupAgent"
android:icon="@drawable/launch"
- android:theme="@style/Theme.DSub.Holo">
+ android:theme="@style/Theme.DSub.Light">
<activity android:name="github.daneren2005.dsub.activity.SubsonicFragmentActivity"
android:configChanges="orientation|keyboardHidden"
diff --git a/res/layout/song_list_item.xml b/res/layout/song_list_item.xml index 3bf7ab44..72ee298b 100644 --- a/res/layout/song_list_item.xml +++ b/res/layout/song_list_item.xml @@ -64,10 +64,12 @@ android:visibility="gone"/>
</LinearLayout>
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical">
+ <LinearLayout
+ android:id="@+id/song_bottom"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical">
<TextView
android:id="@+id/song_artist"
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index ab40df85..87c02c2d 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -237,8 +237,6 @@ \nZuletzt aktualisiert: %4$s
\nKommentar: %5$s</string>
- <string name="song_details.all">%1$s %2$s</string>
- <string name="song_details.kbps">%d kbps</string>
<string name="song_details.error">Fehler</string>
<string name="song_details.skipped">Überspringen</string>
<string name="song_details.downloading">Wird geladen</string>
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index ef025a6d..049728e9 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -226,8 +226,6 @@ \nComentario: %2$s \nPosición: %3$s</string> - <string name="song_details.all">%1$s %2$s</string> - <string name="song_details.kbps">%d kbps</string> <string name="song_details.error">Error</string> <string name="song_details.skipped">Saltados</string> <string name="song_details.downloading">Descargando</string> diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 43a21618..cc862c5b 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -7,10 +7,10 @@ <string name="common.cancel">Annuler</string>
<string name="common.play_now">Jouer</string>
<string name="common.play_shuffled">Jouer au hasard</string>
- <string name="common.play_next">Suivante</string>
+ <string name="common.play_next">Suivant</string>
<string name="common.play_last">Précédent</string>
- <string name="common.download">Cache</string>
- <string name="common.pin">Cache Permanent</string>
+ <string name="common.download">Mettre en cache</string>
+ <string name="common.pin">Mettre en cache Permanent</string>
<string name="common.delete">Supprimer</string>
<string name="common.star">Favori</string>
<string name="common.unstar">Supp. favori</string>
@@ -39,8 +39,8 @@ <string name="button_bar.downloading">Téléchargement</string>
<string name="main.welcome_title">Bienvenue !</string>
- <string name="main.welcome_text">Bienvenue dans DSub ! Cette appli est actuellement configurée pour se connecter au serveur de démo Subsonic. Vous pouvez configurer votre serveur dans les paramètres.<b>subsonic.org</b>), please go to <b>Settings</b> and change the configuration to connect to it.</string>
- <string name="main.about_title">A propos de DSub</string>
+ <string name="main.welcome_text">Bienvenue dans DSub ! L\'application est actuellement configurée pour se connecter au serveur de démo Subsonic (<b>demo.subsonic.org</b>). Vous pouvez configurer votre propre serveur dans les paramètres. Choisir <b>Paramètres</b> et mettre à jour la configuration pour vous y connecter.</string>
+ <string name="main.about_title">A propos de DSub</string>
<string name="main.about_text">Auteur : Scott Jackson
\nEmail : dsub.android@gmail.com
\nVersion : %1$s
@@ -50,10 +50,10 @@ <string name="main.faq_title">FAQ</string>
<string name="main.faq_text">
<![CDATA[
- <font color="red">Cache vs Permanent Cache</font>:
- <br/>When songs are downloaded by DSub, they can be deleted to make room for new downloads. Permanently cached music on the other hand will never be automatically deleted.
- <p/><font color="red">ChromeCast fails</font>:
- <br/>Make sure you are not using a self-signed certificate, because the Chromecast will automatically reject them.
+ <font color="red">Cache vs Cache permanent</font>:
+ <br/>Lorsque des titres sont téléchargés par DSub, ils peuvent être supprimés pour libérer de l\'espace pour de nouveaux téléchargements. Le cache permanent premet, lui, de ne jamais supprimer automatiquement la musique téléchargée.
+ <p/><font color="red">ChromeCast a échoué</font>:
+ <br/>Assurez-vous de ne pas utiliser un certificat auto-signé, Chromecast les rejette systématiquement.
]]>
</string>
<string name="main.select_server">Choisir un serveur</string>
@@ -65,7 +65,7 @@ <string name="main.albums_newest">Ajoutés récemments</string>
<string name="main.albums_recent">Joués récemment</string>
<string name="main.albums_frequent">Les plus joués</string>
- <string name="main.albums_highest">Mieux notés</string>
+ <string name="main.albums_highest">Les mieux notés</string>
<string name="main.albums_starred">Favoris</string>
<string name="main.albums_random">Au hazard</string>
<string name="main.albums_genres">Par genres</string>
@@ -78,7 +78,8 @@ <string name="menu.refresh">Recharger</string>
<string name="menu.select">Tout sélectionner</string>
<string name="menu.play">Jouer</string>
- <string name="menu.exit">Exit</string><string name="menu.play_last">Jouer dernier</string>
+ <string name="menu.exit">Quitter</string>
+ <string name="menu.play_last">Jouer dernier</string>
<string name="menu.settings">Paramètres</string>
<string name="menu.help">Aide</string>
@@ -96,13 +97,13 @@ <string name="menu.show_all">Afficher tous les media</string>
<string name="menu.show_artist">Afficher l\'artiste</string>
<string name="menu.share">Partager</string>
- <string name="menu.delete_cache">Supprimer le cache</string>
+ <string name="menu.delete_cache">Supprimer du cache</string>
<string name="menu.cast">Diffuser vers appareil</string>
<string name="menu.faq">FAQ</string>
<string name="menu.add_user">Ajouter utilisateur</string>
<string name="playlist.label">Playlists</string>
- <string name="playlist.update_info">Mise à jour information</string>
+ <string name="playlist.update_info">Mise à jour informations</string>
<string name="playlist.updated_info">Informations de la playlist %s mises à jour</string>
<string name="playlist.updated_info_error">Echec de la mise à jour des informations de la playlist %s</string>
<string name="playlist.overwrite">Remplacer la playlist existante</string>
@@ -131,7 +132,7 @@ <string name="select_album.offline">Déconnecté</string>
<string name="select_album.searching">Recherche en cours...</string>
<string name="select_album.no_sdcard">Erreur : Aucune carte SD card disponible.</string>
- <string name="select_album.no_network">Warning : Aucun réseau disponible.</string>
+ <string name="select_album.no_network">Problème : Aucun réseau disponible.</string>
<string name="select_album.not_licensed">Serveur sans licence valide. %d jours restant.</string>
<string name="select_album.donate_dialog_message">Téléchargement illimité en supportant Subsonic.</string>
<string name="select_album.donate_dialog_now">Maintenant</string>
@@ -236,8 +237,6 @@ \nMis à jour : %4$s
\nCommentaire : %5$s</string>
- <string name="song_details.all">%1$s %2$s</string>
- <string name="song_details.kbps">%d kbps</string>
<string name="song_details.error">Erreur</string>
<string name="song_details.skipped">Ignoré</string>
<string name="song_details.downloading">Chargement</string>
@@ -318,12 +317,12 @@ <string name="settings.wifi_required_title">Streaming en Wifi uniquement</string>
<string name="settings.wifi_required_summary">Ne lire les média qu\'avec une connexion Wifi</string>
<string name="settings.network_timeout_title">Délai d\'attente réseau (timeout)</string>
- <string name="settings.network_timeout_10000">10 seconds</string>
- <string name="settings.network_timeout_15000">15 seconds</string>
- <string name="settings.network_timeout_30000">30 seconds</string>
- <string name="settings.network_timeout_45000">45 seconds</string>
- <string name="settings.network_timeout_60000">60 seconds</string>
- <string name="settings.preload_0">0 titres</string>
+ <string name="settings.network_timeout_10000">10 secondes</string>
+ <string name="settings.network_timeout_15000">15 secondes</string>
+ <string name="settings.network_timeout_30000">30 secondes</string>
+ <string name="settings.network_timeout_45000">45 secondes</string>
+ <string name="settings.network_timeout_60000">60 secondes</string>
+ <string name="settings.preload_0">0 titre</string>
<string name="settings.preload_1">1 titre</string>
<string name="settings.preload_2">2 titres</string>
<string name="settings.preload_3">3 titres</string>
@@ -337,11 +336,11 @@ <string name="settings.scrobble_summary">Penser à paramétrer votre compte Last.fm sur le serveur Subsonic</string>
<string name="settings.hide_media_title">Invisible pour les autres</string>
<string name="settings.hide_media_summary">Rendre les fichiers de musique indisponibles pour les autres applications.</string>
- <string name="settings.hide_media_toast">Prendra effet à la prochaine recherce de musique d\'Android.</string>
+ <string name="settings.hide_media_toast">Prendra effet au prochain scan de musique d\'Android.</string>
<string name="settings.media_button_title">Boutons physique</string>
<string name="settings.media_button_summary">Répondre aux boutons du mobile, du casque filaire ou bluetooth</string>
<string name="settings.screen_lit_title">Garder l\'écran allumé</string>
- <string name="settings.screen_lit_summary">Garder l\'écran allumer augmente la vitesse de téléchargement.</string>
+ <string name="settings.screen_lit_summary">Garder l\'écran allumé augmente la vitesse de téléchargement.</string>
<string name="settings.playlist_title">Lecture</string>
<string name="settings.playlist_random_size_title">Random Size</string>
<string name="settings.sleep_timer_title">Temporisateur</string>
@@ -375,11 +374,11 @@ <string name="settings.hide_widget_title">Cacher le Widget</string>
<string name="settings.hide_widget_summary">Cacher le widget après avoir quitté l\'application</string>
<string name="settings.podcasts_enabled">Podcasts autorisés</string>
- <string name="settings.podcasts_enabled_summary">Afficher ou non la liste des podcasts</string>
+ <string name="settings.podcasts_enabled_summary">Afficher ou non l\'accès aux podcasts</string>
<string name="settings.bookmarks_enabled">Favoris autorisés</string>
- <string name="settings.bookmarks_enabled_summary">Afficher ou non la liste des favoris</string>
+ <string name="settings.bookmarks_enabled_summary">Afficher ou non l\'accès aux favoris</string>
<string name="settings.shares_enabled">Partages autorisés</string>
- <string name="settings.shares_enabled_summary">Afficher ou non la liste des partages</string>
+ <string name="settings.shares_enabled_summary">Afficher ou non l\'accès aux partages</string>
<string name="settings.sync_title">Sync</string>
<string name="settings.sync_enabled">Sync autorisée</string>
<string name="settings.sync_enabled_summary">Controler ou non périodiquement si les playlists et podcasts ont été mis à jour</string>
@@ -402,44 +401,44 @@ <string name="settings.sync_notification_summary">Afficher une notification dès qu\'un média a été synchronisé</string>
<string name="settings.menu_options.title">Options de menu optionnelles</string>
<string name="settings.menu_options.play_next_summary">Afficher Lire suivant dans les menus</string>
- <string name="settings.menu_options.play_last_summary">Afficher lire dernier dans les menus</string>
+ <string name="settings.menu_options.play_last_summary">Afficher Lire dernier dans les menus</string>
<string name="settings.menu_options.star_summary">Afficher Noter dans les menus</string>
<string name="settings.menu_options.shared_summary">Afficher Partager dans les menus</string>
<string name="settings.browse_by_tags">Naviguer via les tags</string>
- <string name="settings.browse_by_tags_summary">Naviguer via les tags plutôt que via l\'arborescence de fichier. Necessite Subsonic 4.7+</string>
+ <string name="settings.browse_by_tags_summary">Naviguer via les tags plutôt que via l\'arborescence de fichier. Nécessite Subsonic 4.7+</string>
<string name="settings.override_system_language">Ne pas utiliser la langue du système</string>
<string name="settings.override_system_language_summary">Afficher DSub en Anglais même si une traduction existe pour la langue système. Peut nécessiter un vidage du cache de l\'application.</string>
- <string name="settings.drawer_items_title">Drawer Items</string>
- <string name="settings.play_now_after">Play Now - After</string>
+ <string name="settings.drawer_items_title">Eléments du menu principal</string>
+ <string name="settings.play_now_after">Jouer maintenant - Plus tard</string>
<string name="settings.play_now_after_summary">Play Now context menu for a song plays everything after selected item (like the Subsonic web GUI)</string>
- <string name="settings.large_album_art">Large Album Art</string>
- <string name="settings.large_album_art_summary">Display albums with large album art instead of in a list</string>
- <string name="settings.admin_enabled">Admin Enabled</string>
- <string name="settings.admin_enabled_summary">Whether or not to display the admin listing in the pull out drawer</string>
+ <string name="settings.large_album_art">Pochettes larges</string>
+ <string name="settings.large_album_art_summary">Afficher les pochettes en grand plutôt qu\'en liste.</string>
+ <string name="settings.admin_enabled">Administration</string>
+ <string name="settings.admin_enabled_summary">Afficher ou non l\'accès aux outils d\'administration</string>
<string name="shuffle.title">Shuffle By</string>
- <string name="shuffle.startYear">Start Year:</string>
- <string name="shuffle.endYear">End Year:</string>
- <string name="shuffle.genre">Genre:</string>
- <string name="shuffle.pick_genre">Pick a genre</string>
+ <string name="shuffle.startYear">Année début :</string>
+ <string name="shuffle.endYear">Année fin :</string>
+ <string name="shuffle.genre">Genre :</string>
+ <string name="shuffle.pick_genre">Choisir un genre</string>
- <string name="share.info">Owner: %1$s
+ <string name="share.info">Propriétaire : %1$s
\nDescription: %2$s
\nURL: %3$s
- \nCreation: %4$s
- \nLast Visited: %5$s
- \nExpiration: %6$s
- \nVisit Count: %7$s
+ \nCréation : %4$s
+ \nDernière visite : %5$s
+ \nExpiration : %6$s
+ \nNombre de visites : %7$s
</string>
- <string name="share.expires">Expires: %s</string>
- <string name="share.expires_never">Never Expires</string>
- <string name="share.deleted">Deleted share %s</string>
- <string name="share.deleted_error">Failed to delete share %s</string>
- <string name="share.no_expiration">No expiration</string>
- <string name="share.expiration">Expires:</string>
- <string name="share.updated_info">Updated share information for %s</string>
- <string name="share.updated_info_error">Failed to update share information for %s</string>
+ <string name="share.expires">Expiration : %s</string>
+ <string name="share.expires_never">N\'expire jamais</string>
+ <string name="share.deleted">Supprimer le partage %s</string>
+ <string name="share.deleted_error">Echec de la suppression du partage %s</string>
+ <string name="share.no_expiration">Pas d\'expiration</string>
+ <string name="share.expiration">Expiration :</string>
+ <string name="share.updated_info">Informations de partage mises à jour pour %s</string>
+ <string name="share.updated_info_error">Echec de la mise à jour des informations de partage pour %s</string>
<string name="share.via">Partager via</string>
<string name="share.delete">Supprimer le partage</string>
@@ -531,21 +530,21 @@ <string name="changelog_version_format" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">Version <xliff:g id="version_name">%s</xliff:g></string>
<plurals name="select_album_n_songs">
- <item quantity="zero">No songs</item>
- <item quantity="one">One song</item>
- <item quantity="other">%d songs</item>
+ <item quantity="zero">Aucun titre</item>
+ <item quantity="one">Un titre</item>
+ <item quantity="other">%d titres</item>
</plurals>
<plurals name="select_album_n_songs_downloading">
- <item quantity="one">One song scheduled for download.</item>
- <item quantity="other">%d songs scheduled for download.</item>
+ <item quantity="one">Téléchargement programmé pour un titre.</item>
+ <item quantity="other">Téléchargement programmé pour %d titres.</item>
</plurals>
<plurals name="select_album_n_songs_added">
- <item quantity="one">One song added to play queue.</item>
- <item quantity="other">%d songs added to play queue.</item>
+ <item quantity="one">Un titre a été ajouté à la liste de lecture en cours.</item>
+ <item quantity="other">%d titres ont été ajoutés à la liste de lecture en cours.</item>
</plurals>
<plurals name="select_album_donate_dialog_n_trial_days_left">
- <item quantity="one">One day left of trial period</item>
- <item quantity="other">%d days left of trial period</item>
+ <item quantity="one">Dernier jour avant la fin de période d\'essai.</item>
+ <item quantity="other">%d jours avant la fin de période d\'essai.</item>
</plurals>
</resources>
diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 330ab8b7..a6365a84 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -238,8 +238,6 @@ \nUtolsó módosítás: %4$s
\nMegjegyzés: %5$s</string>
- <string name="song_details.all">%1$s %2$s</string>
- <string name="song_details.kbps">%d kbps</string>
<string name="song_details.error">Hiba</string>
<string name="song_details.skipped">Átlépve</string>
<string name="song_details.downloading">Letöltés</string>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 8e636328..1888bf5f 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -149,9 +149,6 @@ <string name="updated_playlist_error">Не удалось обновить \"%s\", пожалуйста, попробуйте позже.</string>
<string name="removed_playlist">Удалено %1$s из \"%2$s\" композиций</string>
- <string name="song_details.all">%1$s %2$s</string>
- <string name="song_details.kbps">%d kbps</string>
-
<string name="lyrics.nomatch">Текст не найден</string>
<string name="error.label">Ошибка</string>
diff --git a/res/values-v16/themes.xml b/res/values-v16/themes.xml index aabcfaa9..0161388b 100644 --- a/res/values-v16/themes.xml +++ b/res/values-v16/themes.xml @@ -4,6 +4,11 @@ <item name="android:fontFamily">sans-serif-light</item>
</style>
+ <style name="DSub.TextViewStyle.Bold" parent="android:Widget.TextView">
+ <item name="android:fontFamily">sans-serif</item>
+ <item name="android:textStyle">bold</item>
+ </style>
+
<style name="DSub.ButtonStyle" parent="android:Widget.Holo.Button">
<item name="android:fontFamily">sans-serif-light</item>
</style>
diff --git a/res/values/strings.xml b/res/values/strings.xml index c05d3d51..89492cd7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -237,8 +237,6 @@ \nLast Updated: %4$s
\nComment: %5$s</string>
- <string name="song_details.all">%1$s %2$s</string>
- <string name="song_details.kbps">%d kbps</string>
<string name="song_details.error">Error</string>
<string name="song_details.skipped">Skipped</string>
<string name="song_details.downloading">Downloading</string>
@@ -344,7 +342,7 @@ <string name="settings.screen_lit_title">Keep screen on</string>
<string name="settings.screen_lit_summary">Keeping the screen on while downloading improves download speed.</string>
<string name="settings.playlist_title">Play</string>
- <string name="settings.playlist_random_size_title">Random Size</string>
+ <string name="settings.playlist_random_size_title">Shuffle Playlist Size</string>
<string name="settings.sleep_timer_title">Sleep Timer</string>
<string name="settings.sleep_timer_duration_title">Sleep Timer Duration</string>
<string name="settings.sleep_timer_off">Off</string>
@@ -410,7 +408,7 @@ <string name="settings.browse_by_tags_summary">Browse by tags instead of by folder structure. Requires Subsonic 4.7+</string>
<string name="settings.override_system_language">Override System Language</string>
<string name="settings.override_system_language_summary">Display app in english even if the system language is something DSub has a translation for. May need to clear the app from memory for changes to take affect.</string>
- <string name="settings.drawer_items_title">Drawer Items</string>
+ <string name="settings.drawer_items_title">Drawer Tabs</string>
<string name="settings.play_now_after">Play Now - After</string>
<string name="settings.play_now_after_summary">Play Now context menu for a song plays everything after selected item (like the Subsonic web GUI)</string>
<string name="settings.large_album_art">Large Album Art</string>
diff --git a/res/values/themes.xml b/res/values/themes.xml index 6611cff7..1700aa88 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -120,6 +120,10 @@ <style name="DSub.TextViewStyle" parent="android:Widget.TextView"> </style> + <style name="DSub.TextViewStyle.Bold" parent="android:Widget.TextView"> + <item name="android:textStyle">bold</item> + </style> + <style name="DSub.ButtonStyle.Dark" parent="android:Widget.Holo.Button"> </style> <style name="DSub.ButtonStyle.Light" parent="android:Widget.Holo.Light.Button"> diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 6216cf47..42b74aa0 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -27,7 +27,7 @@ <ListPreference android:title="@string/settings.theme_title" android:key="theme" - android:defaultValue="holo" + android:defaultValue="light" android:entryValues="@array/themeValues" android:entries="@array/themeNames"/> @@ -102,22 +102,10 @@ android:defaultValue="true"/> </PreferenceCategory> + </PreferenceScreen> - <PreferenceCategory - android:title="@string/button_bar.chat"> - - <CheckBoxPreference - android:title="@string/settings.chat_enabled" - android:summary="@string/settings.chat_enabled_summary" - android:key="chatEnabled" - android:defaultValue="true"/> - - <EditTextPreference - android:title="@string/settings.chat_refresh" - android:key="chatRefreshRate" - android:defaultValue="30" - android:digits="0123456789"/> - </PreferenceCategory> + <PreferenceScreen + android:title="@string/settings.drawer_items_title"> <PreferenceCategory android:title="@string/settings.drawer_items_title"> @@ -141,6 +129,12 @@ android:defaultValue="true"/> <CheckBoxPreference + android:title="@string/settings.chat_enabled" + android:summary="@string/settings.chat_enabled_summary" + android:key="chatEnabled" + android:defaultValue="true"/> + + <CheckBoxPreference android:title="@string/settings.admin_enabled" android:summary="@string/settings.admin_enabled_summary" android:key="adminEnabled" @@ -148,13 +142,13 @@ </PreferenceCategory> <PreferenceCategory - android:title="@string/settings.other_title"> + android:title="@string/button_bar.chat"> - <CheckBoxPreference - android:title="@string/settings.play_now_after" - android:summary="@string/settings.play_now_after_summary" - android:key="playNowAfter" - android:defaultValue="false"/> + <EditTextPreference + android:title="@string/settings.chat_refresh" + android:key="chatRefreshRate" + android:defaultValue="30" + android:digits="0123456789"/> </PreferenceCategory> </PreferenceScreen> @@ -335,6 +329,12 @@ android:summary="@string/settings.persistent_summary" android:key="persistentNotification" android:defaultValue="false"/> + + <CheckBoxPreference + android:title="@string/settings.play_now_after" + android:summary="@string/settings.play_now_after_summary" + android:key="playNowAfter" + android:defaultValue="false"/> </PreferenceCategory> <PreferenceCategory diff --git a/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java b/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java index 4678bbc5..eefb9c56 100644 --- a/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java +++ b/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java @@ -24,6 +24,7 @@ import android.app.SearchManager; import android.content.Intent; import android.os.Bundle; import android.provider.SearchRecentSuggestions; +import android.util.Log; import github.daneren2005.dsub.fragments.SubsonicFragment; import github.daneren2005.dsub.util.Constants; @@ -37,7 +38,9 @@ import github.daneren2005.dsub.provider.DSubSearchProvider; */ public class QueryReceiverActivity extends Activity { - @Override + private static final String TAG = QueryReceiverActivity.class.getSimpleName(); + + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -68,6 +71,9 @@ public class QueryReceiverActivity extends Activity { if(albumId.indexOf("ar-") == 0) { intent.putExtra(Constants.INTENT_EXTRA_NAME_ARTIST, true); albumId = albumId.replace("ar-", ""); + } else if(albumId.indexOf("so-") == 0) { + intent.putExtra(Constants.INTENT_EXTRA_SEARCH_SONG, name); + albumId = albumId.replace("so-", ""); } intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, albumId); if (name != null) { diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java index 56c3e387..48f67dd5 100644 --- a/src/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java @@ -245,7 +245,11 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - Log.d(TAG, "Preference changed: " + key); + // Random error I have no idea how to reproduce + if(sharedPreferences == null) { + return; + } + update(); if (Constants.PREFERENCES_KEY_HIDE_MEDIA.equals(key)) { @@ -468,22 +472,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private void applyTheme() { String activeTheme = Util.getTheme(this); - if ("dark".equals(activeTheme)) { - setTheme(R.style.Theme_DSub_Dark); - } else if ("black".equals(activeTheme)) { - setTheme(R.style.Theme_DSub_Black); - } else if ("light".equals(activeTheme)) { - setTheme(R.style.Theme_DSub_Light); - } else { - setTheme(R.style.Theme_DSub_Holo); - } - - SharedPreferences prefs = Util.getPreferences(this); - if(prefs.getBoolean(Constants.PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE, false)) { - Configuration config = new Configuration(); - config.locale = Locale.ENGLISH; - getResources().updateConfiguration(config,getResources().getDisplayMetrics()); - } + Util.applyTheme(this, activeTheme); } private void setHideMedia(boolean hide) { diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 7aec30c4..395a347e 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -50,6 +50,7 @@ import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
+import android.widget.TextView;
import java.io.File;
import java.io.PrintWriter;
@@ -90,7 +91,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte ActionBarDrawerToggle drawerToggle;
DrawerAdapter drawerAdapter;
ListView drawerList;
- View lastSelectedView = null;
+ TextView lastSelectedView = null;
int lastSelectedPosition = 0;
boolean drawerOpen = false;
@@ -113,6 +114,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte getSupportActionBar().setCustomView(actionbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
+
+ if(getIntent().hasExtra(Constants.FRAGMENT_POSITION)) {
+ lastSelectedPosition = getIntent().getIntExtra(Constants.FRAGMENT_POSITION, 0);
+ }
}
@Override
@@ -156,6 +161,14 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte }
@Override
+ public void startActivity(Intent intent) {
+ if("github.daneren2005.dsub.activity.DownloadActivity".equals(intent.getComponent().getClassName())) {
+ intent.putExtra(Constants.FRAGMENT_POSITION, lastSelectedPosition);
+ }
+ super.startActivity(intent);
+ }
+
+ @Override
public void setContentView(int viewId) {
super.setContentView(R.layout.abstract_activity);
rootView = (ViewGroup) findViewById(R.id.content_frame);
@@ -177,10 +190,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(lastSelectedView != view) {
if(lastSelectedView != null) {
- lastSelectedView.setBackgroundResource(android.R.color.transparent);
+ lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle);
}
- view.setBackgroundResource(R.color.dividerColor);
- lastSelectedView = view;
+ lastSelectedView = (TextView) view.findViewById(R.id.drawer_name);
+ lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle_Bold);
lastSelectedPosition = position;
}
}
@@ -209,9 +222,9 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte }
if(lastSelectedView == null) {
- lastSelectedView = drawerList.getChildAt(lastSelectedPosition);
+ lastSelectedView = (TextView) drawerList.getChildAt(lastSelectedPosition).findViewById(R.id.drawer_name);
if(lastSelectedView != null) {
- lastSelectedView.setBackgroundResource(R.color.dividerColor);
+ lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle_Bold);
}
}
@@ -444,6 +457,15 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte }
}
}
+
+ if(drawerList.getChildAt(lastSelectedPosition) == null) {
+ drawerAdapter.setSelectedPosition(lastSelectedPosition);
+ } else {
+ lastSelectedView = (TextView) drawerList.getChildAt(lastSelectedPosition).findViewById(R.id.drawer_name);
+ if(lastSelectedView != null) {
+ lastSelectedView.setTextAppearance(SubsonicActivity.this, R.style.DSub_TextViewStyle_Bold);
+ }
+ }
}
}
@@ -629,22 +651,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte Util.setTheme(this, theme);
}
- if ("dark".equals(theme)) {
- setTheme(R.style.Theme_DSub_Dark);
- } else if ("black".equals(theme)) {
- setTheme(R.style.Theme_DSub_Black);
- } else if ("light".equals(theme)) {
- setTheme(R.style.Theme_DSub_Light);
- } else {
- setTheme(R.style.Theme_DSub_Holo);
- }
-
- SharedPreferences prefs = Util.getPreferences(this);
- if(prefs.getBoolean(Constants.PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE, false)) {
- Configuration config = new Configuration();
- config.locale = Locale.ENGLISH;
- getResources().updateConfiguration(config,getResources().getDisplayMetrics());
- }
+ Util.applyTheme(this, theme);
}
private void applyFullscreen() {
fullScreen = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false);
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index aa977c2c..9845411a 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -282,6 +282,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_ID, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID));
args.putString(Constants.INTENT_EXTRA_NAME_NAME, getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME));
+ args.putString(Constants.INTENT_EXTRA_SEARCH_SONG, getIntent().getStringExtra(Constants.INTENT_EXTRA_SEARCH_SONG));
if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_ARTIST)) {
args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true);
}
diff --git a/src/github/daneren2005/dsub/fragments/AdminFragment.java b/src/github/daneren2005/dsub/fragments/AdminFragment.java index 5e14aff5..08a78fd6 100644 --- a/src/github/daneren2005/dsub/fragments/AdminFragment.java +++ b/src/github/daneren2005/dsub/fragments/AdminFragment.java @@ -70,7 +70,7 @@ public class AdminFragment extends SelectListFragment<User> { MenuInflater inflater = context.getMenuInflater();
if(UserUtil.isCurrentAdmin()) {
inflater.inflate(R.menu.admin_context, menu);
- } else {
+ } else if(UserUtil.isCurrentRole(User.SETTINGS)) {
inflater.inflate(R.menu.admin_context_user, menu);
}
}
@@ -114,7 +114,9 @@ public class AdminFragment extends SelectListFragment<User> { try {
// Will only work if user is admin
List<User> users = musicService.getUsers(refresh, context, listener);
- UserUtil.refreshCurrentUser(context);
+ if(refresh) {
+ UserUtil.refreshCurrentUser(context, true);
+ }
return users;
} catch(SubsonicRESTException e) {
// Delete cached users if not allowed to get them
@@ -126,7 +128,7 @@ public class AdminFragment extends SelectListFragment<User> { List<User> users = new ArrayList<User>();
users.add(musicService.getUser(refresh, UserUtil.getCurrentUsername(context), context, listener));
- UserUtil.refreshCurrentUser(context);
+ UserUtil.refreshCurrentUser(context, false);
return users;
}
}
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java index c673fc12..fc86ad36 100644 --- a/src/github/daneren2005/dsub/fragments/MainFragment.java +++ b/src/github/daneren2005/dsub/fragments/MainFragment.java @@ -209,7 +209,7 @@ public class MainFragment extends SubsonicFragment { }
Util.setActiveServer(context, instance);
context.invalidate();
- UserUtil.refreshCurrentUser(context);
+ UserUtil.refreshCurrentUser(context, false);
}
}
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index e7c34d9a..3486f154 100644 --- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -69,6 +69,7 @@ import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.view.DownloadFileAdapter;
import github.daneren2005.dsub.view.FadeOutAnimation;
import github.daneren2005.dsub.view.SongView;
+import github.daneren2005.dsub.view.UpdateView;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.VisualizerView;
@@ -1008,6 +1009,8 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis playlistFlipper.setInAnimation(AnimationUtils.loadAnimation(context, R.anim.push_up_in));
playlistFlipper.setOutAnimation(AnimationUtils.loadAnimation(context, R.anim.push_up_out));
playlistFlipper.setDisplayedChild(1);
+
+ UpdateView.triggerUpdate();
}
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java index 08d9c13a..4817967f 100644 --- a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -64,6 +64,10 @@ public class SelectArtistFragment extends SelectListFragment<Artist> { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
folderButton = null;
super.onCreateView(inflater, container, bundle);
+
+ if("4.4.2".equals(Build.VERSION.RELEASE)) {
+ listView.setFastScrollAlwaysVisible(true);
+ }
if(objects != null) {
if (Util.isOffline(context) || Util.isTagBrowsing(context)) {
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index e372bf51..d40f8fad 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -80,6 +80,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter boolean restoredInstance = false;
boolean lookupParent = false;
boolean largeAlbums = false;
+ String lookupEntry;
public SelectDirectoryFragment() {
super();
@@ -121,6 +122,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
artist = args.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false);
+ lookupEntry = args.getString(Constants.INTENT_EXTRA_SEARCH_SONG);
String childId = args.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID);
if(childId != null) {
@@ -680,9 +682,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
listAdapter = new AlbumListAdapter(context, entryAdapter, albumListType, albumListExtra, albumListSize);
- } else if((albumListType == null || "starred".equals(albumListType)) && largeAlbums) {
+ } else if(albumListType == null || "starred".equals(albumListType)) {
// Only set standard album adapter if not album list and largeAlbums is true
- albumList.setAdapter(new AlbumGridAdapter(context, getImageLoader(), albums, !artist));
+ if(largeAlbums) {
+ albumList.setAdapter(new AlbumGridAdapter(context, getImageLoader(), albums, !artist));
+ }
} else {
// If album list, use infinite adapters for either depending on whether or not largeAlbums is true
if(largeAlbums) {
@@ -697,6 +701,16 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
context.supportInvalidateOptionsMenu();
+ if(lookupEntry != null) {
+ for(int i = 0; i < entries.size(); i++) {
+ if(lookupEntry.equals(entries.get(i).getTitle())) {
+ entryList.setSelection(i + entryList.getHeaderViewsCount());
+ lookupEntry = null;
+ break;
+ }
+ }
+ }
+
Bundle args = getArguments();
boolean playAll = args.getBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
if (playAll && !restoredInstance) {
@@ -1164,6 +1178,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
if(songCount == 0) {
showHeader = false;
+ hideButtons = true;
return null;
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index b07be642..7f6de2d8 100644 --- a/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -56,7 +56,7 @@ public class SelectPlaylistFragment extends SelectListFragment<Playlist> { if(!Util.checkServerVersion(context, "1.8")) {
menu.removeItem(R.id.playlist_update_info);
- } else if(playlist.getPublic() != null && playlist.getPublic() == true && !UserUtil.getCurrentUsername(context).equals(playlist.getOwner())) {
+ } else if(playlist.getPublic() != null && playlist.getPublic() == true && playlist.getId().indexOf(".m3u") == -1 && !UserUtil.getCurrentUsername(context).equals(playlist.getOwner())) {
menu.removeItem(R.id.playlist_update_info);
menu.removeItem(R.id.playlist_menu_delete);
}
@@ -155,7 +155,7 @@ public class SelectPlaylistFragment extends SelectListFragment<Playlist> { Bundle args = new Bundle();
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
- if(Util.checkServerVersion(context, "1.8") && UserUtil.getCurrentUsername(context).equals(playlist.getOwner())) {
+ if(Util.checkServerVersion(context, "1.8") && playlist.getOwner() != null && playlist.getOwner().equals(UserUtil.getCurrentUsername(context))) {
args.putBoolean(Constants.INTENT_EXTRA_NAME_PLAYLIST_OWNER, true);
}
fragment.setArguments(args);
diff --git a/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java index 616af757..73a415ba 100644 --- a/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java @@ -238,7 +238,7 @@ public class SelectPodcastsFragment extends SelectListFragment<PodcastChannel> { "\nURL: " + channel.getUrl() +
"\nStatus: " + channel.getStatus() +
((channel.getErrorMessage()) == null ? "" : "\nError Message: " + channel.getErrorMessage()) +
- ((channel.getDescription()) == null ? "" : "\nDescription: " + channel.getDescription());
+ ((channel.getDescription()) == null ? "" : "\n\nDescription: " + channel.getDescription());
Util.info(context, channel.getName(), message);
}
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 1e3f832d..54709ec0 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -67,6 +67,8 @@ import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.LoadingTask;
import github.daneren2005.dsub.util.UserUtil;
import github.daneren2005.dsub.util.Util;
+import github.daneren2005.dsub.view.UpdateView;
+
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -124,6 +126,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR @Override
public void onResume() {
super.onResume();
+ UpdateView.triggerUpdate();
}
@Override
@@ -729,11 +732,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR downloadRecursively(id, name, isDirectory, save, append, autoplay, shuffle, background, false);
}
protected void downloadRecursively(final String id, final String name, final boolean isDirectory, final boolean save, final boolean append, final boolean autoplay, final boolean shuffle, final boolean background, final boolean playNext) {
- LoadingTask<List<MusicDirectory.Entry>> task = new LoadingTask<List<MusicDirectory.Entry>>(context) {
+ LoadingTask<Boolean> task = new LoadingTask<Boolean>(context) {
private static final int MAX_SONGS = 500;
@Override
- protected List<MusicDirectory.Entry> doInBackground() throws Throwable {
+ protected Boolean doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
MusicDirectory root;
if(share != null) {
@@ -752,7 +755,26 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR List<MusicDirectory.Entry> songs = new LinkedList<MusicDirectory.Entry>();
getSongsRecursively(root, songs);
- return songs;
+
+ DownloadService downloadService = getDownloadService();
+ boolean transition = false;
+ if (!songs.isEmpty() && downloadService != null) {
+ if (!append) {
+ downloadService.clear();
+ }
+ if(!background) {
+ downloadService.download(songs, save, autoplay, playNext, false);
+ if(!append) {
+ transition = true;
+ }
+ }
+ else {
+ downloadService.downloadBackground(songs, save);
+ }
+ }
+ artistOverride = false;
+
+ return transition;
}
private void getSongsRecursively(MusicDirectory parent, List<MusicDirectory.Entry> songs) throws Exception {
@@ -779,24 +801,12 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
@Override
- protected void done(List<MusicDirectory.Entry> songs) {
- DownloadService downloadService = getDownloadService();
- if (!songs.isEmpty() && downloadService != null) {
- if (!append) {
- downloadService.clear();
- }
- warnIfNetworkOrStorageUnavailable();
- if(!background) {
- downloadService.download(songs, save, autoplay, playNext, false);
- if(!append) {
- Util.startActivityWithoutTransition(context, DownloadActivity.class);
- }
- }
- else {
- downloadService.downloadBackground(songs, save);
- }
+ protected void done(Boolean result) {
+ warnIfNetworkOrStorageUnavailable();
+
+ if(result) {
+ Util.startActivityWithoutTransition(context, DownloadActivity.class);
}
- artistOverride = false;
}
};
@@ -832,7 +842,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR Iterator<Playlist> it = playlists.iterator();
while(it.hasNext()) {
Playlist playlist = it.next();
- if(playlist.getPublic() == true && !UserUtil.getCurrentUsername(context).equals(playlist.getOwner())) {
+ if(playlist.getPublic() == true && playlist.getId().indexOf(".m3u") == -1 && !UserUtil.getCurrentUsername(context).equals(playlist.getOwner())) {
it.remove();
}
}
diff --git a/src/github/daneren2005/dsub/fragments/UserFragment.java b/src/github/daneren2005/dsub/fragments/UserFragment.java index 1ad62d87..9bf26baf 100644 --- a/src/github/daneren2005/dsub/fragments/UserFragment.java +++ b/src/github/daneren2005/dsub/fragments/UserFragment.java @@ -70,7 +70,7 @@ public class UserFragment extends SubsonicFragment{ @Override
public void onAttach(Activity activity) {
super.onAttach(activity);
- activity.invalidateOptionsMenu();
+ ((SubsonicActivity) activity).supportInvalidateOptionsMenu();
}
@Override
@@ -82,8 +82,10 @@ public class UserFragment extends SubsonicFragment{ if(UserUtil.isCurrentAdmin() && Util.checkServerVersion(context, "1.10")) {
menuInflater.inflate(R.menu.user, menu);
- } else {
+ } else if(UserUtil.isCurrentRole(User.SETTINGS)) {
menuInflater.inflate(R.menu.user_user, menu);
+ } else {
+ menuInflater.inflate(R.menu.empty, menu);
}
}
diff --git a/src/github/daneren2005/dsub/provider/DSubSearchProvider.java b/src/github/daneren2005/dsub/provider/DSubSearchProvider.java index 4fd4b218..6c23a5d0 100644 --- a/src/github/daneren2005/dsub/provider/DSubSearchProvider.java +++ b/src/github/daneren2005/dsub/provider/DSubSearchProvider.java @@ -83,7 +83,7 @@ public class DSubSearchProvider extends ContentProvider { } for (MusicDirectory.Entry song : searchResult.getSongs()) { String icon = RESOURCE_PREFIX + R.drawable.ic_action_song; - cursor.addRow(new Object[]{song.getId().hashCode(), song.getTitle(), song.getArtist(), song.getParent(), song.getTitle(), icon}); + cursor.addRow(new Object[]{song.getId().hashCode(), song.getTitle(), song.getArtist(), "so-" + song.getParent(), song.getTitle(), icon}); } return cursor; } diff --git a/src/github/daneren2005/dsub/receiver/AudioNoisyReceiver.java b/src/github/daneren2005/dsub/receiver/AudioNoisyReceiver.java index 058d04b4..b4ace297 100644 --- a/src/github/daneren2005/dsub/receiver/AudioNoisyReceiver.java +++ b/src/github/daneren2005/dsub/receiver/AudioNoisyReceiver.java @@ -39,7 +39,7 @@ public class AudioNoisyReceiver extends BroadcastReceiver { }
if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals (intent.getAction ())) {
- if(!downloadService.isRemoteEnabled() && downloadService.getPlayerState() == PlayerState.STARTED) {
+ if(!downloadService.isRemoteEnabled() && (downloadService.getPlayerState() == PlayerState.STARTED || downloadService.getPlayerState() == PlayerState.PAUSED_TEMP)) {
SharedPreferences prefs = Util.getPreferences(downloadService);
int pausePref = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_PAUSE_DISCONNECT, "0"));
if(pausePref == 0) {
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index bd43fbed..31280b19 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -511,13 +511,15 @@ public class CachedMusicService implements MusicService { public User getUser(boolean refresh, String username, Context context, ProgressListener progressListener) throws Exception { User result = null; - if(!refresh) { - result = FileUtil.deserialize(context, getCacheName(context, "user-" + username), User.class); - } - - if(result == null) { + try { result = musicService.getUser(refresh, username, context, progressListener); FileUtil.serialize(context, result, getCacheName(context, "user-" + username)); + } catch(Exception e) { + // Don't care + } + + if(result == null && !refresh) { + result = FileUtil.deserialize(context, getCacheName(context, "user-" + username), User.class); } return result; diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java index b1c78b24..908598f3 100644 --- a/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/src/github/daneren2005/dsub/service/DownloadFile.java @@ -237,7 +237,7 @@ public class DownloadFile implements BufferFile { @Override public synchronized void onResume() { - if(!isFailedMax() && !isDownloading()) { + if(!isWorkDone() && !isFailedMax() && !isDownloading() && !isDownloadCancelled()) { download(); } } @@ -503,8 +503,10 @@ public class DownloadFile implements BufferFile { } // Only run these if not interrupted, ie: cancelled - new CacheCleaner(context, DownloadService.getInstance()).cleanSpace(); - checkDownloads(); + if(!isCancelled()) { + new CacheCleaner(context, DownloadService.getInstance()).cleanSpace(); + checkDownloads(); + } return null; } diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 4c0c9151..f28c38dc 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -29,6 +29,7 @@ import static github.daneren2005.dsub.domain.PlayerState.PREPARING; import static github.daneren2005.dsub.domain.PlayerState.STARTED; import static github.daneren2005.dsub.domain.PlayerState.STOPPED; +import github.daneren2005.dsub.R; import github.daneren2005.dsub.audiofx.AudioEffectsController; import github.daneren2005.dsub.audiofx.EqualizerController; import github.daneren2005.dsub.audiofx.VisualizerController; @@ -45,6 +46,7 @@ import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.MediaRouteManager; import github.daneren2005.dsub.util.ShufflePlayBuffer; import github.daneren2005.dsub.util.SimpleServiceBinder; +import github.daneren2005.dsub.util.SyncUtil; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.util.compat.RemoteControlClientHelper; import github.daneren2005.serverproxy.BufferProxy; @@ -263,9 +265,11 @@ public class DownloadService extends Service { if(bufferTask != null) { bufferTask.cancel(); + bufferTask = null; } if(nextPlayingTask != null) { nextPlayingTask.cancel(); + nextPlayingTask = null; } if(remoteController != null) { remoteController.stop(); @@ -410,6 +414,7 @@ public class DownloadService extends Service { removePlayed = enabled; if(removePlayed) { checkDownloads(); + lifecycleSupport.serializeDownloadQueue(); } SharedPreferences.Editor editor = Util.getPreferences(this).edit(); editor.putBoolean(Constants.PREFERENCES_KEY_REMOVE_PLAYED, enabled); @@ -588,7 +593,7 @@ public class DownloadService extends Service { reset(); downloadList.clear(); revision++; - if (currentDownloading != null) { + if (currentDownloading != null && !backgroundDownloadList.contains(currentDownloading)) { currentDownloading.cancelDownload(); currentDownloading = null; } @@ -974,6 +979,7 @@ public class DownloadService extends Service { public synchronized void reset() { if (bufferTask != null) { bufferTask.cancel(); + bufferTask = null; } try { // Only set to idle if it's not being killed to start RemoteController @@ -1600,7 +1606,7 @@ public class DownloadService extends Service { checkShufflePlay(); } - if (remoteState != RemoteControlState.LOCAL || !Util.isNetworkConnected(this) || Util.isOffline(this)) { + if (remoteState != RemoteControlState.LOCAL || !Util.isNetworkConnected(this, true) || Util.isOffline(this)) { return; } diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index ed092328..76c9abeb 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -326,7 +326,7 @@ public class DownloadServiceLifecycleSupport { case TelephonyManager.CALL_STATE_OFFHOOK: if (downloadService.getPlayerState() == PlayerState.STARTED) { resumeAfterCall = true; - downloadService.pause(); + downloadService.pause(true); } break; case TelephonyManager.CALL_STATE_IDLE: diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 3299ec4b..43d443d2 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -92,6 +92,7 @@ import github.daneren2005.dsub.service.parser.UserParser; import github.daneren2005.dsub.service.parser.VersionParser; import github.daneren2005.dsub.service.ssl.SSLSocketFactory; import github.daneren2005.dsub.service.ssl.TrustSelfSignedStrategy; +import github.daneren2005.dsub.util.BackgroundTask; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; @@ -1526,7 +1527,7 @@ public class RESTMusicService implements MusicService { HttpConnectionParams.setSoTimeout(newParams, networkTimeout); httpClient.setParams(newParams); - final AtomicReference<Boolean> cancelled = new AtomicReference<Boolean>(false); + final AtomicReference<Boolean> isCancelled = new AtomicReference<Boolean>(false); int attempts = 0; while (true) { attempts++; @@ -1535,10 +1536,11 @@ public class RESTMusicService implements MusicService { if (task != null) { // Attempt to abort the HTTP request if the task is cancelled. - task.setOnCancelListener(new SilentBackgroundTask.OnCancelListener() { + task.setOnCancelListener(new BackgroundTask.OnCancelListener() { @Override public void onCancel() { try { + isCancelled.set(true); request.abort(); } catch(Exception e) { Log.e(TAG, "Failed to stop http task"); @@ -1579,14 +1581,14 @@ public class RESTMusicService implements MusicService { return response; } catch (IOException x) { request.abort(); - if (attempts >= HTTP_REQUEST_MAX_ATTEMPTS || cancelled.get()) { + if (attempts >= HTTP_REQUEST_MAX_ATTEMPTS || isCancelled.get()) { throw x; } if (progressListener != null) { String msg = context.getResources().getString(R.string.music_service_retry, attempts, HTTP_REQUEST_MAX_ATTEMPTS - 1); progressListener.updateProgress(msg); } - Log.w(TAG, "Got IOException (" + attempts + "), will retry", x); + Log.w(TAG, "Got IOException " + x + " (" + attempts + "), will retry"); increaseTimeouts(requestParams); Thread.sleep(2000L); } diff --git a/src/github/daneren2005/dsub/service/Scrobbler.java b/src/github/daneren2005/dsub/service/Scrobbler.java index 1f831a80..9958ff9e 100644 --- a/src/github/daneren2005/dsub/service/Scrobbler.java +++ b/src/github/daneren2005/dsub/service/Scrobbler.java @@ -24,6 +24,11 @@ public class Scrobbler { if (song == null || !Util.isScrobblingEnabled(context)) { return; } + + // Ignore if online with no network access + if(!Util.isOffline(context) && !Util.isNetworkConnected(context)) { + return; + } // Ignore podcasts if(song.getSong() instanceof PodcastEpisode) { diff --git a/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java index 0801bf7c..6dfbbbe4 100644 --- a/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/MostRecentSyncAdapter.java @@ -32,6 +32,7 @@ import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.Notifications;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.SyncUtil.SyncSet;
import github.daneren2005.dsub.util.Util;
@@ -89,7 +90,7 @@ public class MostRecentSyncAdapter extends SubsonicSyncAdapter { musicService.getIndexes(Util.getSelectedMusicFolderId(context), true, context, null);
}
- SyncUtil.showSyncNotification(context, R.string.sync_new_albums, SyncUtil.joinNames(updated));
+ Notifications.showSyncNotification(context, R.string.sync_new_albums, SyncUtil.joinNames(updated));
} else if(firstRun) {
FileUtil.serialize(context, syncedList, SyncUtil.getMostRecentSyncFile(context, instance));
}
diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java index f680becf..68bfdcb6 100644 --- a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java @@ -32,6 +32,7 @@ import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.parser.SubsonicRESTException;
import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.Notifications;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.SyncUtil.SyncSet;
import github.daneren2005.dsub.util.Util;
@@ -122,7 +123,7 @@ public class PlaylistSyncAdapter extends SubsonicSyncAdapter { }
if(updated.size() > 0) {
- SyncUtil.showSyncNotification(context, R.string.sync_new_playlists, SyncUtil.joinNames(updated));
+ Notifications.showSyncNotification(context, R.string.sync_new_playlists, SyncUtil.joinNames(updated));
}
}
}
diff --git a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java index bd9f26c7..a1878cad 100644 --- a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java @@ -32,6 +32,7 @@ import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.parser.SubsonicRESTException;
+import github.daneren2005.dsub.util.Notifications;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.SyncUtil.SyncSet;
import github.daneren2005.dsub.util.FileUtil;
@@ -104,7 +105,7 @@ public class PodcastSyncAdapter extends SubsonicSyncAdapter { // Make sure there are is at least one change before re-syncing
if(updated.size() > 0) {
FileUtil.serialize(context, podcastList, SyncUtil.getPodcastSyncFile(context, instance));
- SyncUtil.showSyncNotification(context, R.string.sync_new_podcasts, SyncUtil.joinNames(updated));
+ Notifications.showSyncNotification(context, R.string.sync_new_podcasts, SyncUtil.joinNames(updated));
}
} catch(Exception e) {
Log.w(TAG, "Failed to get podcasts for " + Util.getServerName(context, instance));
diff --git a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java index 54c10f41..b99c501d 100644 --- a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java @@ -20,6 +20,7 @@ package github.daneren2005.dsub.service.sync;
import android.annotation.TargetApi;
+import android.app.Notification;
import android.content.Context;
import android.util.Log;
@@ -29,6 +30,7 @@ import java.util.ArrayList; import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.Notifications;
import github.daneren2005.dsub.util.SyncUtil;
import github.daneren2005.dsub.util.Util;
@@ -69,7 +71,7 @@ public class StarredSyncAdapter extends SubsonicSyncAdapter { SyncUtil.setSyncedStarred(syncedList, context, instance);
if(updated) {
- SyncUtil.showSyncNotification(context, R.string.sync_new_starred, null);
+ Notifications.showSyncNotification(context, R.string.sync_new_starred, null);
}
} catch(Exception e) {
Log.e(TAG, "Failed to get starred list for " + Util.getServerName(context, instance));
diff --git a/src/github/daneren2005/dsub/util/BackgroundTask.java b/src/github/daneren2005/dsub/util/BackgroundTask.java index 63515f19..f64acbff 100644 --- a/src/github/daneren2005/dsub/util/BackgroundTask.java +++ b/src/github/daneren2005/dsub/util/BackgroundTask.java @@ -44,7 +44,7 @@ public abstract class BackgroundTask<T> implements ProgressListener { private static final String TAG = BackgroundTask.class.getSimpleName(); private final Context context; - protected boolean cancelled = false; + protected AtomicBoolean cancelled = new AtomicBoolean(false); protected OnCancelListener cancelListener; protected Task task; @@ -135,17 +135,20 @@ public abstract class BackgroundTask<T> implements ProgressListener { } public void cancel() { - cancelled = true; - if(task != null) { - task.cancel(); - } + if(cancelled.compareAndSet(false, true)) { + if(task != null && task.isRunning()) { + if(cancelListener != null) { + cancelListener.onCancel(); + } else { + task.cancel(); + } - if(cancelListener != null) { - cancelListener.onCancel(); + task = null; + } } } public boolean isCancelled() { - return cancelled; + return cancelled.get(); } public void setOnCancelListener(OnCancelListener listener) { cancelListener = listener; diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index 0c263d3a..f566c78c 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -61,6 +61,7 @@ public final class Constants { public static final String INTENT_EXTRA_NAME_SHARE = "subsonic.share"; public static final String INTENT_EXTRA_FRAGMENT_TYPE = "fragmentType"; public static final String INTENT_EXTRA_REFRESH_LISTINGS = "refreshListings"; + public static final String INTENT_EXTRA_SEARCH_SONG = "searchSong"; // Preferences keys. public static final String PREFERENCES_KEY_SERVER_KEY = "server"; @@ -73,6 +74,7 @@ public final class Constants { public static final String PREFERENCES_KEY_SERVER_INTERNAL_URL = "serverInternalUrl"; public static final String PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID = "serverLocalNetworkSSID"; public static final String PREFERENCES_KEY_SERVER_VERSION = "serverVersion"; + public static final String PREFERENCES_KEY_SERVER_TYPE = "serverType"; public static final String PREFERENCES_KEY_TEST_CONNECTION = "serverTestConnection"; public static final String PREFERENCES_KEY_OPEN_BROWSER = "openBrowser"; public static final String PREFERENCES_KEY_MUSIC_FOLDER_ID = "musicFolderId"; diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java index f9c5fed5..dc10ebba 100644 --- a/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/src/github/daneren2005/dsub/util/ImageLoader.java @@ -292,7 +292,7 @@ public class ImageLoader { mDrawable = Util.createDrawableFromBitmap(mContext, bitmap); } catch (Throwable x) { Log.e(TAG, "Failed to download album art.", x); - cancelled = true; + cancelled.set(true); } return null; @@ -358,7 +358,7 @@ public class ImageLoader { } } catch (Throwable x) { Log.e(TAG, "Failed to download album art.", x); - cancelled = true; + cancelled.set(true); } return null; diff --git a/src/github/daneren2005/dsub/util/LoadingTask.java b/src/github/daneren2005/dsub/util/LoadingTask.java index f774aa5b..6c3385d2 100644 --- a/src/github/daneren2005/dsub/util/LoadingTask.java +++ b/src/github/daneren2005/dsub/util/LoadingTask.java @@ -52,12 +52,12 @@ public abstract class LoadingTask<T> extends BackgroundTask<T> { @Override
public boolean isCancelled() {
- return (tabActivity instanceof SubsonicActivity && ((SubsonicActivity) tabActivity).isDestroyedCompat()) || cancelled;
+ return (tabActivity instanceof SubsonicActivity && ((SubsonicActivity) tabActivity).isDestroyedCompat()) || cancelled.get();
}
@Override
public void updateProgress(final String message) {
- if(!cancelled) {
+ if(!cancelled.get()) {
getHandler().post(new Runnable() {
@Override
public void run() {
diff --git a/src/github/daneren2005/dsub/util/Notifications.java b/src/github/daneren2005/dsub/util/Notifications.java index 3eec7517..de4129e9 100644 --- a/src/github/daneren2005/dsub/util/Notifications.java +++ b/src/github/daneren2005/dsub/util/Notifications.java @@ -48,6 +48,7 @@ public final class Notifications { // Notification IDs.
public static final int NOTIFICATION_ID_PLAYING = 100;
public static final int NOTIFICATION_ID_DOWNLOADING = 102;
+ public static final String NOTIFICATION_SYNC_GROUP = "github.daneren2005.dsub.sync";
private static boolean playShowing = false;
private static boolean downloadShowing = false;
@@ -66,6 +67,7 @@ public final class Notifications { RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded);
setupViews(expandedContentView,context,song, playing, remote);
notification.bigContentView = expandedContentView;
+ notification.priority = Notification.PRIORITY_HIGH;
}
RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification);
@@ -286,6 +288,29 @@ public final class Notifications { }
}
+ public static void showSyncNotification(final Context context, int stringId, String extra) {
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_SYNC_NOTIFICATION, true)) {
+ String content = (extra != null) ? context.getResources().getString(stringId, extra) : context.getResources().getString(stringId);
+
+ NotificationCompat.Builder builder;
+ builder = new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.stat_notify_sync)
+ .setContentTitle(context.getResources().getString(R.string.sync_title))
+ .setContentText(content)
+ .setStyle(new NotificationCompat.BigTextStyle().bigText(content.replace(", ", "\n")))
+ .setOngoing(false)
+ .setGroup(NOTIFICATION_SYNC_GROUP)
+ .setPriority(NotificationCompat.PRIORITY_LOW);
+
+ Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class);
+ notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ builder.setContentIntent(PendingIntent.getActivity(context, 2, notificationIntent, 0));
+
+ NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.notify(stringId, builder.build());
+ }
+ }
+
/**
* Resolves the default text color for notifications.
*
diff --git a/src/github/daneren2005/dsub/util/SyncUtil.java b/src/github/daneren2005/dsub/util/SyncUtil.java index 0c567681..15fa2d47 100644 --- a/src/github/daneren2005/dsub/util/SyncUtil.java +++ b/src/github/daneren2005/dsub/util/SyncUtil.java @@ -181,27 +181,6 @@ public final class SyncUtil { return "sync-most_recent-" + (Util.getRestUrl(context, null, instance, false)).hashCode() + ".ser";
}
- public static void showSyncNotification(final Context context, int stringId, String extra) {
- if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_SYNC_NOTIFICATION, true)) {
- String content = (extra != null) ? context.getResources().getString(stringId, extra) : context.getResources().getString(stringId);
-
- NotificationCompat.Builder builder;
- builder = new NotificationCompat.Builder(context)
- .setSmallIcon(R.drawable.stat_notify_sync)
- .setContentTitle(context.getResources().getString(R.string.sync_title))
- .setContentText(content)
- .setStyle(new NotificationCompat.BigTextStyle().bigText(content.replace(", ", "\n")))
- .setOngoing(false);
-
- Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class);
- notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- builder.setContentIntent(PendingIntent.getActivity(context, 2, notificationIntent, 0));
-
- NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(stringId, builder.build());
- }
- }
-
public static String joinNames(List<String> names) {
StringBuilder builder = new StringBuilder();
for (String val : names) {
diff --git a/src/github/daneren2005/dsub/util/TabBackgroundTask.java b/src/github/daneren2005/dsub/util/TabBackgroundTask.java index 022bcaa7..b0a24b28 100644 --- a/src/github/daneren2005/dsub/util/TabBackgroundTask.java +++ b/src/github/daneren2005/dsub/util/TabBackgroundTask.java @@ -36,7 +36,7 @@ public abstract class TabBackgroundTask<T> extends BackgroundTask<T> { @Override
public boolean isCancelled() {
- return !tabFragment.isAdded() || cancelled;
+ return !tabFragment.isAdded() || cancelled.get();
}
@Override
diff --git a/src/github/daneren2005/dsub/util/UserUtil.java b/src/github/daneren2005/dsub/util/UserUtil.java index baa56935..2d1b097a 100644 --- a/src/github/daneren2005/dsub/util/UserUtil.java +++ b/src/github/daneren2005/dsub/util/UserUtil.java @@ -46,11 +46,15 @@ public final class UserUtil { private static int instance = -1;
private static User currentUser;
- public static void refreshCurrentUser(Context context) {
+ public static void refreshCurrentUser(Context context, boolean forceRefresh) {
currentUser = null;
- seedCurrentUser(context);
+ seedCurrentUser(context, forceRefresh);
}
- public static void seedCurrentUser(final Context context) {
+
+ public static void seedCurrentUser(Context context) {
+ seedCurrentUser(context, false);
+ }
+ public static void seedCurrentUser(final Context context, final boolean refresh) {
// Only try to seed if online
if(Util.isOffline(context)) {
currentUser = null;
@@ -67,7 +71,7 @@ public final class UserUtil { new SilentBackgroundTask<Void>(context) {
@Override
protected Void doInBackground() throws Throwable {
- currentUser = MusicServiceFactory.getMusicService(context).getUser(false, getCurrentUsername(context, instance), context, null);
+ currentUser = MusicServiceFactory.getMusicService(context).getUser(refresh, getCurrentUsername(context, instance), context, null);
// If running, redo cast selector
DownloadService downloadService = DownloadService.getInstance();
@@ -107,17 +111,17 @@ public final class UserUtil { }
public static boolean isCurrentAdmin() {
- return isCurrentRole("adminRole");
+ return isCurrentRole(User.ADMIN);
}
public static boolean canPodcast() {
- return isCurrentRole("podcastRole");
+ return isCurrentRole(User.PODCAST);
}
public static boolean canShare() {
- return isCurrentRole("shareRole");
+ return isCurrentRole(User.SHARE);
}
public static boolean canJukebox() {
- return isCurrentRole("jukeboxRole");
+ return isCurrentRole(User.JUKEBOX);
}
public static boolean isCurrentRole(String role) {
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 72fc8511..cea5813e 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -8,7 +8,6 @@ Subsonic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License @@ -29,6 +28,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -62,6 +62,7 @@ import github.daneren2005.dsub.activity.SubsonicFragmentActivity; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.PlayerState; import github.daneren2005.dsub.domain.RepeatMode; +import github.daneren2005.dsub.domain.User; import github.daneren2005.dsub.domain.Version; import github.daneren2005.dsub.provider.DSubWidgetProvider; import github.daneren2005.dsub.receiver.MediaButtonIntentReceiver; @@ -84,6 +85,7 @@ import java.lang.reflect.Method; import java.security.MessageDigest; import java.text.DecimalFormat; import java.text.NumberFormat; +import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -154,7 +156,7 @@ public final class Util { public static boolean isScrobblingEnabled(Context context) { SharedPreferences prefs = getPreferences(context); - return prefs.getBoolean(Constants.PREFERENCES_KEY_SCROBBLE, true) && (isOffline(context) || UserUtil.isCurrentRole("scrobblingEnabled")); + return prefs.getBoolean(Constants.PREFERENCES_KEY_SCROBBLE, true) && (isOffline(context) || UserUtil.isCurrentRole(User.SCROBBLING)); } public static void setActiveServer(Context context, int instance) { @@ -274,6 +276,25 @@ public final class Util { editor.putString(Constants.PREFERENCES_KEY_THEME, theme); editor.commit(); } + + public static void applyTheme(Context context, String theme) { + if ("dark".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Dark); + } else if ("black".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Black); + } else if ("holo".equals(theme)) { + context.setTheme(R.style.Theme_DSub_Holo); + } else { + context.setTheme(R.style.Theme_DSub_Light); + } + + SharedPreferences prefs = Util.getPreferences(context); + if(prefs.getBoolean(Constants.PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE, false)) { + Configuration config = new Configuration(); + config.locale = Locale.ENGLISH; + context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics()); + } + } public static boolean getDisplayTrack(Context context) { SharedPreferences prefs = getPreferences(context); @@ -873,15 +894,22 @@ public final class Util { return Util.getScaledHeight((double) bitmap.getHeight(), (double) bitmap.getWidth(), width); } - public static boolean isNetworkConnected(Context context) { + public static boolean isNetworkConnected(Context context) { + return isNetworkConnected(context, false); + } + public static boolean isNetworkConnected(Context context, boolean streaming) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); boolean connected = networkInfo != null && networkInfo.isConnected(); - boolean wifiConnected = connected && networkInfo.getType() == ConnectivityManager.TYPE_WIFI; - boolean wifiRequired = isWifiRequiredForDownload(context); + if(streaming) { + boolean wifiConnected = connected && networkInfo.getType() == ConnectivityManager.TYPE_WIFI; + boolean wifiRequired = isWifiRequiredForDownload(context); - return connected && (!wifiRequired || wifiConnected); + return connected && (!wifiRequired || wifiConnected); + } else { + return connected; + } } public static boolean isWifiConnected(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); diff --git a/src/github/daneren2005/dsub/view/DrawerAdapter.java b/src/github/daneren2005/dsub/view/DrawerAdapter.java index 345ca34c..924df743 100644 --- a/src/github/daneren2005/dsub/view/DrawerAdapter.java +++ b/src/github/daneren2005/dsub/view/DrawerAdapter.java @@ -41,6 +41,7 @@ public class DrawerAdapter extends ArrayAdapter<String> { private List<String> items;
private List<Integer> icons;
private List<Boolean> visible;
+ private int selectedPosition = -1;
public DrawerAdapter(Context context, List<String> items, List<Integer> icons, List<Boolean> visible) {
super(context, R.layout.drawer_list_item, items);
@@ -63,6 +64,12 @@ public class DrawerAdapter extends ArrayAdapter<String> { TextView textView = (TextView) convertView.findViewById(R.id.drawer_name);
textView.setText(item);
+
+ if(selectedPosition == position) {
+ textView.setTextAppearance(context, R.style.DSub_TextViewStyle_Bold);
+ selectedPosition = -1;
+ }
+
ImageView iconView = (ImageView) convertView.findViewById(R.id.drawer_icon);
iconView.setImageResource(icon);
@@ -109,4 +116,8 @@ public class DrawerAdapter extends ArrayAdapter<String> { public void setDownloadVisible(boolean visible) {
setItemVisible(items.size() - 2, visible);
}
+
+ public void setSelectedPosition(int position) {
+ selectedPosition = position;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/SongView.java b/src/github/daneren2005/dsub/view/SongView.java index 2176b768..3e423877 100644 --- a/src/github/daneren2005/dsub/view/SongView.java +++ b/src/github/daneren2005/dsub/view/SongView.java @@ -88,18 +88,6 @@ public class SongView extends UpdateView implements Checkable { StringBuilder artist = new StringBuilder(40); - String bitRate = null; - if (song.getBitRate() != null) { - bitRate = String.format(getContext().getString(R.string.song_details_kbps), song.getBitRate()); - } - - String fileFormat = null; - if (song.getTranscodedSuffix() != null && !song.getTranscodedSuffix().equals(song.getSuffix())) { - fileFormat = String.format("%s > %s", song.getSuffix(), song.getTranscodedSuffix()); - } else { - fileFormat = song.getSuffix(); - } - if(!song.isVideo()) { if(song instanceof PodcastEpisode) { String date = ((PodcastEpisode)song).getDate(); @@ -112,20 +100,29 @@ public class SongView extends UpdateView implements Checkable { artist.append(song.getArtist()); } - String status = (song instanceof PodcastEpisode) ? ((PodcastEpisode)song).getStatus() : ""; - artist.append(" ("); - if("error".equals(status)) { - artist.append(getContext().getString(R.string.song_details_error)); - } else if("skipped".equals(status)) { - artist.append(getContext().getString(R.string.song_details_skipped)); - } else if("downloading".equals(status)) { - artist.append(getContext().getString(R.string.song_details_downloading)); - } else { - artist.append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)); + if(song instanceof PodcastEpisode) { + String status = ((PodcastEpisode) song).getStatus(); + int statusRes = -1; + + if("error".equals(status)) { + statusRes = R.string.song_details_error; + } else if("skipped".equals(status)) { + statusRes = R.string.song_details_skipped; + } else if("downloading".equals(status)) { + statusRes = R.string.song_details_downloading; + } + + if(statusRes != -1) { + artist.append(" ("); + artist.append(getContext().getString(statusRes)); + artist.append(")"); + } } - artist.append(")"); + + durationTextView.setText(Util.formatDuration(song.getDuration())); } else { - artist.append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)); + findViewById(R.id.song_bottom).setVisibility(View.GONE); + statusTextView.setText(Util.formatDuration(song.getDuration())); } String title = song.getTitle(); @@ -136,7 +133,6 @@ public class SongView extends UpdateView implements Checkable { titleTextView.setText(title); artistTextView.setText(artist); - durationTextView.setText(Util.formatDuration(song.getDuration())); checkedTextView.setVisibility(checkable && !song.isVideo() ? View.VISIBLE : View.GONE); revision = -1; diff --git a/src/github/daneren2005/dsub/view/UpdateView.java b/src/github/daneren2005/dsub/view/UpdateView.java index 66f34471..5278f83a 100644 --- a/src/github/daneren2005/dsub/view/UpdateView.java +++ b/src/github/daneren2005/dsub/view/UpdateView.java @@ -123,6 +123,14 @@ public class UpdateView extends LinearLayout { }, "UpdateView").start();
}
+ public static synchronized void triggerUpdate() {
+ if(backgroundHandler != null) {
+ uiHandler.removeCallbacksAndMessages(null);
+ backgroundHandler.removeCallbacksAndMessages(null);
+ uiHandler.post(updateRunnable);
+ }
+ }
+
private static void updateAll() {
try {
// If nothing can see this, stop updating
|