diff options
94 files changed, 857 insertions, 910 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c5048bc6..60ae8465 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="100"
+ android:versionCode="101"
android:versionName="4.5.8">
<uses-permission android:name="android.permission.INTERNET"/>
@@ -119,9 +119,7 @@ </service>
<receiver android:name="github.daneren2005.dsub.receiver.MediaButtonIntentReceiver">
- <intent-filter android:priority="999">
- <action android:name="android.intent.action.MEDIA_BUTTON" />
- </intent-filter>
+ <action android:name="android.intent.action.MEDIA_BUTTON" />
</receiver>
<receiver android:name="github.daneren2005.dsub.receiver.BluetoothIntentReceiver">
diff --git a/DragSortListView b/DragSortListView -Subproject 46fc56dc25549bf256798e159e9aba88a55f31e +Subproject 55d8788fef9580e2f18ac789b76d8191b1d1d50 diff --git a/res/layout/abstract_list_fragment.xml b/res/layout/abstract_list_fragment.xml index bfce4792..be3889ee 100644 --- a/res/layout/abstract_list_fragment.xml +++ b/res/layout/abstract_list_fragment.xml @@ -1,29 +1,35 @@ <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/fragment_list_layout"
+<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/refresh_layout"
android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
+ android:layout_height="fill_parent">
- <View
+ <LinearLayout
+ android:id="@+id/fragment_list_layout"
android:layout_width="fill_parent"
- android:layout_height="1px"
- android:background="@color/dividerColor"/>
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
- <include layout="@layout/tab_progress" />
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1px"
+ android:background="@color/dividerColor"/>
- <TextView
- android:id="@+id/fragment_list_empty"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="10dip"
- android:text="@string/common.empty"
- android:visibility="gone" />
+ <include layout="@layout/tab_progress" />
- <ListView
- android:id="@+id/fragment_list"
- android:layout_width="fill_parent"
- android:layout_height="0dip"
- android:layout_weight="1.0"
- android:fastScrollEnabled="true"/>
-</LinearLayout>
+ <TextView
+ android:id="@+id/fragment_list_empty"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="10dip"
+ android:text="@string/common.empty"
+ android:visibility="gone" />
+
+ <ListView
+ android:id="@+id/fragment_list"
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1.0"
+ android:fastScrollEnabled="true"/>
+ </LinearLayout>
+</android.support.v4.widget.SwipeRefreshLayout>
\ No newline at end of file diff --git a/res/layout/album_cell_item.xml b/res/layout/album_cell_item.xml new file mode 100644 index 00000000..9cc85c6e --- /dev/null +++ b/res/layout/album_cell_item.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <github.daneren2005.dsub.view.SquareImageView
+ android:id="@+id/album_coverart"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:src="@drawable/unknown_album"/>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="4dp"
+ android:paddingLeft="2dp">
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_vertical"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/album_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:text="@string/search.albums"/>
+
+ <TextView
+ android:id="@+id/album_artist"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true"
+ android:text="@string/search.artists"/>
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/album_more"
+ android:src="?attr/download_none"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|center_vertical"
+ android:paddingRight="2dp"
+ android:background="@drawable/menubar_button"/>
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file diff --git a/res/layout/album_list_item.xml b/res/layout/album_list_item.xml deleted file mode 100644 index 99a9ed88..00000000 --- a/res/layout/album_list_item.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@id/drag_handle"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
-
- <ImageView
- android:id="@+id/album_coverart"
- android:layout_width="@dimen/AlbumArt.Small"
- android:layout_height="@dimen/AlbumArt.Small"
- android:layout_gravity="left|center_vertical"/>
-
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_gravity="left|center_vertical"
- android:paddingLeft="10dip"
- android:paddingRight="3dip">
-
- <TextView
- android:id="@+id/album_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true"
- android:ellipsize="marquee"/>
-
- <TextView
- android:id="@+id/album_artist"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:singleLine="true"/>
-
- </LinearLayout>
-
- <ImageButton
- android:id="@+id/album_star"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="right|center_vertical"
- android:src="@drawable/ic_stat_star"
- android:background="@android:color/transparent"
- android:focusable="false"
- android:visibility="gone"/>
-
- <ImageView
- android:id="@+id/album_more"
- android:src="?attr/download_none"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_gravity="right|center_vertical"
- android:paddingRight="10dip"
- android:background="@drawable/menubar_button"/>
-</LinearLayout>
diff --git a/res/layout/chat.xml b/res/layout/chat.xml index 9b8f7d17..a62cfa65 100644 --- a/res/layout/chat.xml +++ b/res/layout/chat.xml @@ -1,47 +1,53 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/chat_layout" +<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/refresh_layout" android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" > + android:layout_height="fill_parent"> - <include layout="@layout/tab_progress" /> - - <ListView - android:id="@+id/chat_entries" + <LinearLayout + android:id="@+id/chat_layout" android:layout_width="fill_parent" - android:layout_height="0dip" - android:layout_weight="1.0" - android:textFilterEnabled="true" /> + android:layout_height="fill_parent" + android:orientation="vertical" > - <LinearLayout - android:layout_height="4dip" - android:layout_width="fill_parent" - android:layout_marginTop="4dip"/> + <include layout="@layout/tab_progress" /> - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:gravity="bottom" > - - <EditText - android:id="@+id/chat_edittext" - android:layout_width="0dip" - android:layout_height="40dip" - android:layout_weight="1" - android:autoLink="all" - android:hint="@string/chat.send_a_message" - android:inputType="textEmailAddress|textMultiLine" - android:linksClickable="true" - android:paddingBottom="10dip" - android:paddingTop="10dip" /> - - <ImageButton - android:id="@+id/chat_send" - android:layout_width="60dip" - android:layout_height="40dip" - android:src="?attr/chat_send" /> + <ListView + android:id="@+id/chat_entries" + android:layout_width="fill_parent" + android:layout_height="0dip" + android:layout_weight="1.0" + android:textFilterEnabled="true" /> + + <LinearLayout + android:layout_height="4dip" + android:layout_width="fill_parent" + android:layout_marginTop="4dip"/> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:gravity="bottom" > + + <EditText + android:id="@+id/chat_edittext" + android:layout_width="0dip" + android:layout_height="40dip" + android:layout_weight="1" + android:autoLink="all" + android:hint="@string/chat.send_a_message" + android:inputType="textEmailAddress|textMultiLine" + android:linksClickable="true" + android:paddingBottom="10dip" + android:paddingTop="10dip" /> + + <ImageButton + android:id="@+id/chat_send" + android:layout_width="60dip" + android:layout_height="40dip" + android:src="?attr/chat_send" /> + </LinearLayout> </LinearLayout> -</LinearLayout>
\ No newline at end of file +</android.support.v4.widget.SwipeRefreshLayout>
\ No newline at end of file diff --git a/res/layout/grid_view.xml b/res/layout/grid_view.xml new file mode 100644 index 00000000..17b2f8aa --- /dev/null +++ b/res/layout/grid_view.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?>
+<GridView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gridview"
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1.0"
+ android:numColumns="auto_fit"
+ android:horizontalSpacing="10dp"
+ android:verticalSpacing="10dp"
+ android:gravity="center"
+ android:stretchMode="columnWidth"/>
\ No newline at end of file diff --git a/res/layout/select_album.xml b/res/layout/select_album.xml index 01df495a..2189fdcc 100644 --- a/res/layout/select_album.xml +++ b/res/layout/select_album.xml @@ -1,31 +1,36 @@ <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/select_album_layout"
- android:orientation="vertical"
+<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/refresh_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
- <View
+ <LinearLayout
+ android:id="@+id/select_album_layout"
+ android:orientation="vertical"
android:layout_width="fill_parent"
- android:layout_height="1px"
- android:background="@color/dividerColor"/>
+ android:layout_height="fill_parent">
- <include layout="@layout/tab_progress"/>
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1px"
+ android:background="@color/dividerColor"/>
- <TextView
- android:id="@+id/select_album_empty"
- android:text="@string/select_album.empty"
- android:visibility="gone"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:padding="10dip"/>
+ <include layout="@layout/tab_progress"/>
- <com.mobeta.android.dslv.DragSortListView
- style="@style/DragDropListView"
- android:id="@+id/select_album_entries"
- android:textFilterEnabled="true"
- android:layout_width="fill_parent"
- android:layout_height="0dip"
- android:layout_weight="1.0"
- android:fastScrollEnabled="true"/>
-</LinearLayout>
\ No newline at end of file + <TextView
+ android:id="@+id/select_album_empty"
+ android:text="@string/select_album.empty"
+ android:visibility="gone"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="10dip"/>
+
+ <ListView
+ android:id="@+id/select_album_entries"
+ android:textFilterEnabled="true"
+ android:layout_width="fill_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1.0"
+ android:fastScrollEnabled="true"/>
+ </LinearLayout>
+</android.support.v4.widget.SwipeRefreshLayout>
\ No newline at end of file diff --git a/res/layout/unscrollable_grid_view.xml b/res/layout/unscrollable_grid_view.xml new file mode 100644 index 00000000..549f9ae5 --- /dev/null +++ b/res/layout/unscrollable_grid_view.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?>
+<github.daneren2005.dsub.view.UnscrollableGridView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gridview"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:numColumns="auto_fit"
+ android:horizontalSpacing="10dp"
+ android:verticalSpacing="10dp"
+ android:gravity="center"
+ android:stretchMode="columnWidth"/>
\ No newline at end of file diff --git a/res/menu/abstract_top_menu.xml b/res/menu/abstract_top_menu.xml index 46419d0f..67d18390 100644 --- a/res/menu/abstract_top_menu.xml +++ b/res/menu/abstract_top_menu.xml @@ -2,12 +2,6 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/menu_refresh"
- android:icon="?attr/refresh"
- android:title="@string/menu.refresh"
- compat:showAsAction="always|withText"/>
-
- <item
android:id="@+id/menu_search"
android:icon="?attr/search"
android:title="@string/menu.search"
diff --git a/res/menu/empty.xml b/res/menu/empty.xml index 9bb43bf7..cf7b82de 100644 --- a/res/menu/empty.xml +++ b/res/menu/empty.xml @@ -1,9 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto"> - <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> + </menu> diff --git a/res/menu/select_album.xml b/res/menu/select_album.xml index 8dc004f1..4b79d251 100644 --- a/res/menu/select_album.xml +++ b/res/menu/select_album.xml @@ -8,12 +8,6 @@ compat:showAsAction="always|withText"/> <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> - - <item android:id="@+id/menu_shuffle" android:icon="?attr/shuffle" android:title="@string/menu.shuffle" diff --git a/res/menu/select_album_list.xml b/res/menu/select_album_list.xml deleted file mode 100644 index 60b636e3..00000000 --- a/res/menu/select_album_list.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:compat="http://schemas.android.com/apk/res-auto"> - <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> -</menu> diff --git a/res/menu/select_artist.xml b/res/menu/select_artist.xml index d1e1f4e3..127736d6 100644 --- a/res/menu/select_artist.xml +++ b/res/menu/select_artist.xml @@ -2,12 +2,6 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto"> <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> - - <item android:id="@+id/menu_shuffle" android:icon="?attr/shuffle" android:title="@string/menu.shuffle" diff --git a/res/menu/select_podcast_episode.xml b/res/menu/select_podcast_episode.xml index 8a86b49b..dbb369e9 100644 --- a/res/menu/select_podcast_episode.xml +++ b/res/menu/select_podcast_episode.xml @@ -1,12 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto"> - <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> - <item android:id="@+id/menu_download_all" android:title="@string/select_podcasts.server_download"/> diff --git a/res/menu/select_podcast_episode_offline.xml b/res/menu/select_podcast_episode_offline.xml index 7080768a..3665d317 100644 --- a/res/menu/select_podcast_episode_offline.xml +++ b/res/menu/select_podcast_episode_offline.xml @@ -2,12 +2,6 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto"> <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> - - <item android:id="@+id/menu_delete" android:title="@string/menu.delete_cache"/> </menu> diff --git a/res/menu/select_podcasts.xml b/res/menu/select_podcasts.xml index 212feb04..2f0ab38a 100644 --- a/res/menu/select_podcasts.xml +++ b/res/menu/select_podcasts.xml @@ -1,12 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto"> - <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> - <item android:id="@+id/menu_search" android:icon="?attr/search" diff --git a/res/menu/select_song.xml b/res/menu/select_song.xml index d5bfc2b2..ec4af96a 100644 --- a/res/menu/select_song.xml +++ b/res/menu/select_song.xml @@ -8,12 +8,6 @@ compat:showAsAction="always|withText"/> <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> - - <item android:id="@+id/menu_shuffle" android:icon="?attr/shuffle" android:title="@string/menu.shuffle" diff --git a/res/menu/select_song_offline.xml b/res/menu/select_song_offline.xml index 0b482a5e..6915c873 100644 --- a/res/menu/select_song_offline.xml +++ b/res/menu/select_song_offline.xml @@ -8,12 +8,6 @@ compat:showAsAction="always|withText"/> <item - android:id="@+id/menu_refresh" - android:icon="?attr/refresh" - android:title="@string/menu.refresh" - compat:showAsAction="always|withText"/> - - <item android:id="@+id/menu_shuffle" android:icon="?attr/shuffle" android:title="@string/menu.shuffle" diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index b7ece050..ce9a68e5 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -52,7 +52,7 @@ <string name="main.online">Gehe Online</string>
<string name="main.settings">Einstellungen</string>
<string name="main.albums_title">Album Liste</string>
- <string name="main.albums_newest">Neu hinzugefügt</string>
+ <string name="main.albums_newest">Neue Alben</string>
<string name="main.albums_recent">Vor kurzem gespielt</string>
<string name="main.albums_frequent">Am meisten gespielt</string>
<string name="main.albums_highest">Top bewertet</string>
@@ -379,6 +379,9 @@ <string name="settings.browse_by_tags_summary">Tags statt Ordner verwenden. Benötigt Subsonic 4.7+</string>
<string name="settings.override_system_language">In Englisch anzeigen</string>
<string name="settings.override_system_language_summary">Verwende Englisch anstatt Deutsch für DSub. Benötigt einen Neustart der App.</string>
+ <string name="settings.drawer_items_title">Seitenmenü</string>
+ <string name="settings.play_now_after">Jetzt wiedergeben bis zum Listenende</string>
+ <string name="settings.play_now_after_summary">\"Jetzt wiedergeben\" im Kontextmenü spielt das ausgewählte Lied und alle in der Liste nachfolgenden Lieder ab (wie in der Web-Schnittstelle des Subsonic-Server)</string>
<string name="shuffle.title">Mischen von</string>
<string name="shuffle.startYear">Startjahr:</string>
@@ -417,8 +420,6 @@ <string name="service.connecting">Kontaktiere Server, bitte warten.</string>
- <string name="parser.reading">Lese vom Server.</string>
- <string name="parser.reading_done">Lese vom Server. Fertig!</string>
<string name="parser.upgrade_client">Inkompatible Versionen. Aktualisierung der DSub Android App erforderlich.</string>
<string name="parser.upgrade_server">Inkompatible Versionen. Aktualisierung des Subsonic Server erforderlich.</string>
<string name="parser.not_authenticated">Benutzername oder/und Passwort falsch.</string>
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index db557f19..e18e4b08 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -434,8 +434,6 @@ <string name="service.connecting">Conectando con el servidor, espere por favor.</string> - <string name="parser.reading">Leyendo desde el servidor.</string> - <string name="parser.reading_done">Leyendo desde el servidor. Hecho!</string> <string name="parser.upgrade_client">Versiones incompatibles. Por favor, actualice la aplicación DSub de Android.</string> <string name="parser.upgrade_server">Versiones incompatibles. Por favor, actualice su servidor Subsonic.</string> <string name="parser.not_authenticated">Usuario o contraseña inconrrectos.</string> diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 1625ab84..9a4e51ae 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -441,8 +441,6 @@ <string name="service.connecting">Csatlakozás a kiszolgálóhoz, kérem várjon!</string>
- <string name="parser.reading">Olvasás a kiszolgálóról...</string>
- <string name="parser.reading_done">Olvasás a kiszolgálóról. Kész!</string>
<string name="parser.upgrade_client">Nem kompatibilis verzió. Kérjük, frissítse a DSub Android alkalmazást!</string>
<string name="parser.upgrade_server">Nem kompatibilis verzió. Kérjük, frissítse a Subsonic kiszolgálót!</string>
<string name="parser.not_authenticated">Hibás felhasználónév vagy jelszó!</string>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index d4edbf46..7094fe7d 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -259,8 +259,6 @@ <string name="service.connecting">Подключение к серверу. Пожалуйста, подождите.</string>
- <string name="parser.reading">Чтение с сервера.</string>
- <string name="parser.reading_done">Чтение с сервера выполнено!</string>
<string name="parser.upgrade_client">Несовместимые версии. Пожалуйста, обновите приложение DSub для Android.</string>
<string name="parser.upgrade_server">Несовместимые версии. Пожалуйста, обновите сервер Subsonic.</string>
<string name="parser.not_authenticated">Неправильное имя пользователя или пароль.</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml index d0df0d24..0cbb9330 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -440,9 +440,7 @@ <string name="service.connecting">Contacting server, please wait.</string>
- <string name="parser.reading">Reading from server.</string>
- <string name="parser.reading_done">Reading from server. Done!</string>
- <string name="parser.upgrade_client">Incompatible versions. Please upgrade DSub Android app.</string>
+ <string name="parser.upgrade_client">Incompatible versions. Please upgrade DSub.</string>
<string name="parser.upgrade_server">Incompatible versions. Please upgrade Subsonic server.</string>
<string name="parser.not_authenticated">Wrong username or password.</string>
<string name="parser.not_authorized">Not authorized. Check user permissions in Subsonic server.</string>
diff --git a/res/xml/changelog.xml b/res/xml/changelog.xml index 4fb3b472..53b70127 100644 --- a/res/xml/changelog.xml +++ b/res/xml/changelog.xml @@ -73,247 +73,4 @@ <change>Fix offline scrobbling bug</change> <change>Fix some offline caching issues when sync is on with multiple servers</change> </release> - <release version="4.4" versioncode="86" releasedate="2/5/2014"> - <change>Browse by ID3 Tags instead of folder structure (off by default)</change> - <change>Probably a good idea to clear existing cache since there will be many songs that don't match up</change> - <change>Add unstar option to mass unstar songs in the Starred list</change> - <change>Convert the start timer to use a slider</change> - <change>Add years to albums display (requires Subsonic 4.9+)</change> - <change>Renamed all Delete's to Delete something to remove ambiguity</change> - <change>Fixed some places where rotating the screen caused a crash</change> - <change>Various minor bug fixes</change> - </release> - <release version="4.3.7" versioncode="84" releasedate="1/22/2014"> - <change>Add stats to genres for 4.9Beta3+ Servers</change> - <change>Fix stuck Last.FM notification if you use it to scrobble</change> - <change>Fix shuffle play issue</change> - <change>Fix pressing next from bluetooth controls not looping back to start with repeat set to all</change> - </release> - <release version="4.3.6" versioncode="81" releasedate="1/19/2014"> - <change>Added optional SSID to use for local network address (requires new permission: ACCESS_WIFI_STATE)</change> - <change>Fix not being able to clear local network address</change> - <change>Fix Galaxy S3 issues</change> - <change>Hide star button on now playing screen if hidden in settings</change> - <change>Fix podcasts not being clickable in offline mode</change> - <change>Bunch of minor improvements/bugfixes</change> - </release> - <release version="4.3.5" versioncode="80" releasedate="1/11/2014"> - <change>Fix downloads not limiting bitrate correctly</change> - </release> - <release version="4.3.4" versioncode="79" releasedate="1/9/2014"> - <change>New Share management tab (can disable in settings). Ability to share albums/songs (thanks archrival)</change> - <change>High quality album art cache (doesn't overwrite existing downloaded art) (thanks archrival)</change> - <change>Add ability to hide Play next/Play Last/Star/Share from menus</change> - <change>Add ability to define a separate IP used while browsing via WiFi</change> - <change>With unlimited bitrate, default to 320 kpbs if transcoding to mp3 (instead of server default of 128 kpbs)</change> - <change>Show artist as a option under album lists/search albums</change> - <change>GZip if tomcat/reverse proxy is set up to support it</change> - <change>Fix for using play next sometimes screwing up playback</change> - <change>Fix listened to podcasts not being deleted in certain circumstances</change> - </release> - <release version="4.3.3" versioncode="77" releasedate="12/25/2013"> - <change>Enable keep starred songs synced in settings</change> - <change>Enable sync newly added in settings</change> - <change>Sync notification when new stuff is downloaded (can be disabled)</change> - <change>Added albums by decade button to home screen on 4.9Beta3+</change> - <change>Browse genres by album (instead of by song) on 4.9Beta3+</change> - <change>Sort Podcasts by name</change> - <change>Sort albums by year on 4.9Beta3+</change> - <change>Fix clicking on notifications/widgets</change> - <change>Many sync fixes/improvements</change> - <change>Background optimizations to improve battery life</change> - <change>Fix genres not being sorted/weird characters in 4.9Beta3+</change> - <change>Fix crash turning screen back on in Android 4.3</change> - <change>Various minor bug fixes</change> - </release> - <release version="4.3.2" versioncode="76" releasedate="12/8/2013"> - <change>Click on album art to popup a larger version</change> - <change>Added Show all media button to replace albums with songs</change> - <change>Automatically delete podcasts that are > 95% listened to</change> - <change>Added Show Details button to albums (Year/Genre on Subsonic 4.9Beta3+)</change> - <change>Fix podcasts syncing trying to redownload ones you delete</change> - <change>Fix the context menus on the first pane on tablets not working</change> - <change>Bunch of random bug fixes and enhancements</change> - </release> - <release version="4.3.1" versioncode="75" releasedate="11/30/2013"> - <change>Fix search on MusicCabinet servers</change> - </release> - <release version="4.3.0" versioncode="74" releasedate="11/30/2013"> - <change>Manage new sync options in Settings -> Cache/Network</change> - <change>Mark playlists as Keep Synced to auto download whole playlist</change> - <change>Mark podcasts as Keep Synced to auto download new podcasts</change> - <change>New Search Provider that searches as you type (thanks Sindre)</change> - <change>When using "Listen To" search, autoplay artist or albums if they match the query</change> - <change>Full screen option in Settings. Immersive mode for Android 4.4+</change> - <change>Fix KitKat's lockscreen scrollbar for Android 4.4+</change> - <change>Fix crashes on KitKat</change> - <change>Added Play Next to artist/album context menus + song overflow menu</change> - <change>Hungarian translation (thanks Andrássy László)</change> - <change>Tons of bug fixes</change> - </release> - <release version="4.2.2" versioncode="71" releasedate="11/22/2013"> - <change>Added starring for artists for 4.9+ Servers</change> - <change>Add ability to place large widget on lockscreen for Android 4.2+</change> - <change>Option to use app's custom sorting (on by default)</change> - <change>Lots of tablet UI enhancements</change> - <change>Updated translations</change> - <change>Tons of bug fixes</change> - </release> - <release version="4.2.1" versioncode="70" releasedate="11/15/2013"> - <change>Fixed crash when going to download list with Screen On = true</change> - <change>Fixed crash when changing volume in RC mode</change> - </release> - <release version="4.2.0" versioncode="69" releasedate="11/14/2013"> - <change>Changed from tabs to Pull Out Drawer like newer Google docs specify</change> - <change>Major UI update with better scaling icons</change> - <change>Updated main app icon (thanks Ben Sumner)</change> - <change>Added tablet layout that better uses extra space</change> - <change>New Bookmarks tab</change> - <change>Persistent notification is like other music apps now (change in settings)</change> - <change>Ability to hide Podcasts/Bookmarks/Chat tabs</change> - <change>Pressing next with repeat all on loops back to beginning</change> - <change>Increase right padding so context buttons are easier to press</change> - </release> - <release version="4.1.8" versioncode="66" releasedate="10/26/2013"> - <change>Fix offline shuffle mode</change> - </release> - <release version="4.1.7" versioncode="65" releasedate="10/21/2013"> - <change>Settings screen now broken down by sections</change> - <change>Added option to choose whether or not to pause on headphone/bluetooth disconnect</change> - <change>Added confirm for clearing current queue</change> - <change>Added option to hide widget while nothing is playing</change> - <change>Fix not being able to change position in Jukebox mode</change> - <change>Fix position not being saved sometimes when pausing during a streamed song</change> - <change>Fix sometimes the letters not matching the position on the artist list</change> - <change>Various minor bug fixes</change> - </release> - <release version="4.1.6" versioncode="64" releasedate="10/3/2013"> - <change>Fix recent update sometimes messing up downloaded song</change> - <change>Fix changing position while streaming a song</change> - </release> - <release version="4.1.5" versioncode="63" releasedate="9/27/2013"> - <change>Notification while doing background downloads, clicking will show you the download list</change> - <change>Put songs in the root directory in a new folder called Root at the bottom of the list</change> - <change>Speedup of saving/loading current playing list (mostly matters for those using large playlists)</change> - <change>Cache most common folder listings for better experience while network is intermittent</change> - <change>Speedup of offline playlist loading</change> - <change>Fix app reloading data/losing position on orientation change</change> - <change>Fix Show Album from now playing list</change> - <change>Fix using shuffle in offline mode sometimes using online songs</change> - <change>Various optimizations and bug fixes</change> - </release> - <release version="4.1.4" versioncode="61" releasedate="8/25/2013"> - <change>Fix for freezes on 4.3</change> - <change>Fix for starred songs/albums not being clickable</change> - </release> - <release version="4.1.3" versioncode="60" releasedate="8/21/2013"> - <change>Updated icon</change> - <change>Moved from ActionBarSherlock to Google's new equivalent library</change> - <change>Fix podcasts not showing up if server less than 4.8</change> - <change>Add option to download all podcasts at once (useful for when first adding a new podcast)</change> - <change>Put back notification for position changing</change> - <change>Added AlbumArtist, Genre, Track metadata (Android 4.3+)</change> - <change>Added position updating for AVRCP 1.3 (Android 4.3+)</change> - <change>Jukebox volume looks nicer</change> - <change>Jukebox stays active the next time you start DSub</change> - <change>More optimizations and bug fixes</change> - </release> - <release version="4.1.2" versioncode="59" releasedate="7/24/2013"> - <change>Added option to clear cache from settings</change> - <change>Added cloud settings backup so when you reinstall on the same device your settings are still there</change> - <change>Fixed Android 4.3 crash</change> - <change>Performance enhancements</change> - </release> - <release version="4.1.1" versioncode="58" releasedate="7/18/2013"> - <change>Fix some podcasts causing errors</change> - </release> - <release version="4.1.0" versioncode="57" releasedate="7/17/2013"> - <change>Added Podcast Tab (4.5+)</change> - <change>Add/Delete Podcast Channels. Manage server status of Podcast Episodes (4.8+)</change> - <change>Double press pause on headset to skip to next song</change> - <change>Added HLS as a option under external video players (4.8+). Skipping doesn't seem to work for me.</change> - <change>Fix pressing play from widget from sometimes starting song over</change> - <change>Various minor UI tweaks to make things look nicer</change> - <change>Gapless Playback setting: if off now acts more like base Subsonic app to hopefully fix some issues</change> - </release> - <release version="4.0.7" versioncode="56" releasedate="7/2/2013"> - <change>Added offline starring to library view instead of just now playing</change> - <change>Remove * to show downloading, go off of whether arrow is blue or green for cached/perma cached</change> - <change>Go back to always showing bottom bar so downloading list is accessible </change> - <change>Fix offline mode matching first letters against ignore list (ie: the), instead of first word</change> - <change>Add prompt for removing a server</change> - <change>Fix some cases where list would incorrectly show up blank</change> - </release> - <release version="4.0.6" versioncode="55" releasedate="6/25/2013"> - <change>Scrobble and star songs and sync changes back when going online (has trouble when tags don't match folders)</change> - <change>Fix cases where operations didn't work in online mode when originally added in offline mode and vice versa</change> - <change>Added blank option to genre picker in the shuffle dialog</change> - <change>Added option to show track # in front of song (off by default)</change> - <change>Separate cached playlists from different servers in separate folders so they don't interfere with each other</change> - <change>Fix for some music files which throw errors at the end not proceeding to the next song</change> - <change>Fix flash preference not being obeyed for the Play External option</change> - <change>As songs are downloaded in background list, automatically remove them</change> - <change>Fix low quality album artwork in large widgets</change> - <change>Fix a rare case that can cause a song to be played twice</change> - <change>Fix for some who listen to untranscoded flac songs</change> - <change>Remove bottom bar if nothing is in the queue</change> - <change>Use .nomedia file instead of folder for more compatibility</change> - <change>Clean some sensitive info from the logs</change> - </release> - <release version="4.0.5" versioncode="54" releasedate="6/7/2013"> - <change>Fix album art on old Subsonic/MusicCabinet servers</change> - </release> - <release version="4.0.4" versioncode="53" releasedate="6/6/2013"> - <change>Added Genre parsing (thanks archrival)</change> - <change>Changed Genre to combo selection on 4.8+ servers</change> - <change>Added video choice similar to Subsonic (Raw is the same as MX but you can choose which player to use)</change> - <change>Added 4x2, 4x3, 4x4 widgets (thanks archrival)</change> - <change>Add option to create new playlist when adding song to playlists</change> - <change>Added option to overwrite existing playlist on 4.7+ servers</change> - <change>Fix when removing the current server</change> - <change>Fix edge case in new sort</change> - </release> - <release version="4.0.3" versioncode="52" releasedate="5/31/2013"> - <change>Sort by disc number if specified in tags</change> - <change>Show starred artists in starred list</change> - <change>Change folder.jpg to albumart.jpg which galleries shouldn't display</change> - <change>Fix Show Album</change> - <change>Added support for server Ignored Articles (future server version) + defaults to server's defaults</change> - <change>On network error return to front of the app instead of exiting all the way</change> - <change>Fix occasional crash when going back into app after running for a while</change> - <change>Various minor bugfixes</change> - </release> - <release version="4.0.2" versioncode="51" releasedate="5/24/2013"> - <change>Fix if you set chat refresh rate to 0, will just not refresh</change> - <change>Revert dark theme modification</change> - <change>New Theme called black which is the pure black background</change> - <change>Option to disable chat menu, need to exit app and reenter for now</change> - </release> - - <release version="4.0.1" versioncode="50" releasedate="5/23/2013"> - <change>New: Chat Tab (Set chat auto refresh rate from settings)</change> - <change>New: Dynamic servers, add as many, or remove all but the ones you are using</change> - <change>New: Added separate setting for songs to preload for Wifi/Mobile</change> - <change>Improvement: The infinite playlist while shuffling is now persistent between startups</change> - <change>Theme: White is now more white, got rid of blue text for white theme only</change> - <change>Theme: Black is now a flat black due to popular request</change> - <change>Theme: Apply the current theme to settings screen</change> - <change>Fix: Don't stretch album art on bottom of main tabs</change> - <change>Fix: Possible fix for some who were having crash on starting EQ</change> - </release> - - <release version="4.0.0" versioncode="48" releasedate="5/16/2013"> - <change>Converted everything to fragments!</change> - <change>Swipe to switch tabs</change> - <change>Breadcrumb trail when going down several levels</change> - <change>Require double tapping back to exit app</change> - <change>Change log dialog for new versions</change> - <change>Endless loading on album lists (ie: Random, Recently Added, etc...) instead of pressing more</change> - <change>Look at what is now playing from main tabs</change> - <change>Added Playing: Track/Total to Now Playing action bar</change> - <change>When clicking on a album in search, the parent is also added to the back stack</change> - <change>Added total time to playlist/album headers</change> - <change>Fixed a lot of the menu items not working when using search</change> - <change>Update to Light/Dark themes</change> - </release> </changelog>
\ No newline at end of file diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 7d971093..646fa295 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -209,7 +209,9 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte if(lastSelectedView == null) {
lastSelectedView = drawerList.getChildAt(lastSelectedPosition);
- lastSelectedView.setBackgroundResource(R.color.dividerColor);
+ if(lastSelectedView != null) {
+ lastSelectedView.setBackgroundResource(R.color.dividerColor);
+ }
}
getSupportActionBar().setTitle(R.string.common_appname);
@@ -321,7 +323,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte @Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
- if(drawerOpen == true) {
+ if(drawerOpen) {
menuInflater.inflate(R.menu.drawer_menu, menu);
} else if(currentFragment != null) {
currentFragment.onCreateOptionsMenu(menu, menuInflater);
@@ -348,7 +350,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte boolean isJukebox = getDownloadService() != null && getDownloadService().isRemoteEnabled();
if (isVolumeAdjust && isJukebox) {
- getDownloadService().setRemoteVolume(isVolumeUp);
+ getDownloadService().updateRemoteVolume(isVolumeUp);
return true;
}
return super.onKeyDown(keyCode, event);
@@ -428,7 +430,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte enabledItems[3] = chatEnabled;
String fragmentType = getIntent().getStringExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE);
- if(fragmentType != null) {
+ if(fragmentType != null && lastSelectedPosition == 0) {
for(int i = 0; i < drawerItemsDescriptions.length; i++) {
if(fragmentType.equals(drawerItemsDescriptions[i])) {
lastSelectedPosition = drawerAdapter.getAdapterPosition(i);
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index eee53d71..0bf770f3 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -320,11 +320,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity { @Override
public boolean onOptionsItemSelected(MenuItem item) {
- if(super.onOptionsItemSelected(item)) {
- return true;
- } else {
- return false;
- }
+ return super.onOptionsItemSelected(item);
}
@Override
diff --git a/src/github/daneren2005/dsub/domain/Bookmark.java b/src/github/daneren2005/dsub/domain/Bookmark.java index d1f470ce..4092cec4 100644 --- a/src/github/daneren2005/dsub/domain/Bookmark.java +++ b/src/github/daneren2005/dsub/domain/Bookmark.java @@ -22,7 +22,6 @@ import java.io.Serializable; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.List;
import java.util.Locale;
/**
diff --git a/src/github/daneren2005/dsub/fragments/ChatFragment.java b/src/github/daneren2005/dsub/fragments/ChatFragment.java index 7443c5d9..3e53f2ad 100644 --- a/src/github/daneren2005/dsub/fragments/ChatFragment.java +++ b/src/github/daneren2005/dsub/fragments/ChatFragment.java @@ -9,6 +9,7 @@ import java.util.Collections; import java.util.List;
import android.os.Bundle;
import android.os.Handler;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
@@ -22,6 +23,7 @@ import android.view.ViewGroup; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
+import android.widget.AbsListView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
@@ -127,6 +129,20 @@ public class ChatFragment extends SubsonicFragment { }
setTitle(R.string.button_bar_chat);
+ refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
+ refreshLayout.setOnRefreshListener(this);
+
+ chatListView.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (chatListView.getChildCount() == 0) ? 0 : chatListView.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ }
+ });
+
return rootView;
}
@@ -175,11 +191,8 @@ public class ChatFragment extends SubsonicFragment { @Override
public boolean onOptionsItemSelected(MenuItem item) {
- if(super.onOptionsItemSelected(item)) {
- return true;
- }
+ return super.onOptionsItemSelected(item);
- return false;
}
@Override
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java index d8fa11ac..3a9370a3 100644 --- a/src/github/daneren2005/dsub/fragments/MainFragment.java +++ b/src/github/daneren2005/dsub/fragments/MainFragment.java @@ -358,7 +358,7 @@ public class MainFragment extends SubsonicFragment { progs.add(logcat.getPath());
progs.add("*:I");
- logcatProc = Runtime.getRuntime().exec(progs.toArray(new String[0]));
+ logcatProc = Runtime.getRuntime().exec(progs.toArray(new String[progs.size()]));
logcatProc.waitFor();
} catch(Exception e) {
Util.toast(context, "Failed to gather logs");
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java index 5ef8c1dd..9fc35cd2 100644 --- a/src/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java @@ -6,12 +6,14 @@ import java.util.Arrays; import android.content.Intent;
import android.os.Bundle;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.MenuItem;
+import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
@@ -91,6 +93,9 @@ public class SearchFragment extends SubsonicFragment { moreAlbumsButton = buttons.findViewById(R.id.search_more_albums);
moreSongsButton = buttons.findViewById(R.id.search_more_songs);
+ refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
+ refreshLayout.setEnabled(false);
+
list = (ListView) rootView.findViewById(R.id.fragment_list);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@@ -121,6 +126,16 @@ public class SearchFragment extends SubsonicFragment { }
});
registerForContextMenu(list);
+ list.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (list.getChildCount() == 0) ? 0 : list.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ }
+ });
context.onNewIntent(context.getIntent());
if(searchResult != null) {
@@ -138,11 +153,8 @@ public class SearchFragment extends SubsonicFragment { @Override
public boolean onOptionsItemSelected(MenuItem item) {
- if(super.onOptionsItemSelected(item)) {
- return true;
- }
+ return super.onOptionsItemSelected(item);
- return false;
}
@Override
diff --git a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java index 5644c059..c38072cf 100644 --- a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -2,6 +2,7 @@ package github.daneren2005.dsub.fragments; import android.os.Build;
import android.os.Bundle;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -9,7 +10,9 @@ import android.view.MenuInflater; import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AbsListView;
import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
@@ -21,6 +24,7 @@ import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.ProgressListener;
import github.daneren2005.dsub.util.TabBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.ArtistAdapter;
@@ -29,24 +33,21 @@ import java.io.Serializable; import java.util.ArrayList;
import java.util.List;
-public class SelectArtistFragment extends SubsonicFragment implements AdapterView.OnItemClickListener {
+public class SelectArtistFragment extends SelectListFragment<Artist> {
private static final String TAG = SelectArtistFragment.class.getSimpleName();
private static final int MENU_GROUP_MUSIC_FOLDER = 10;
- private ListView artistList;
private View folderButtonParent;
private View folderButton;
private TextView folderName;
private List<MusicFolder> musicFolders = null;
private List<MusicDirectory.Entry> entries;
- private List<Artist> artists;
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if(bundle != null) {
- artists = (List<Artist>) bundle.getSerializable(Constants.FRAGMENT_LIST);
musicFolders = (List<MusicFolder>) bundle.getSerializable(Constants.FRAGMENT_LIST2);
}
artist = true;
@@ -55,37 +56,21 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie @Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) artists);
outState.putSerializable(Constants.FRAGMENT_LIST2, (Serializable) musicFolders);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- rootView = inflater.inflate(R.layout.abstract_list_fragment, container, false);
+ super.onCreateView(inflater, container, bundle);
- artistList = (ListView) rootView.findViewById(R.id.fragment_list);
- artistList.setOnItemClickListener(this);
if(Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
- artistList.setFastScrollAlwaysVisible(true);
+ listView.setFastScrollAlwaysVisible(true);
}
- folderButtonParent = inflater.inflate(R.layout.select_artist_header, artistList, false);
- folderName = (TextView) folderButtonParent.findViewById(R.id.select_artist_folder_2);
- artistList.addHeaderView(folderButtonParent);
- folderButton = folderButtonParent.findViewById(R.id.select_artist_folder);
-
- registerForContextMenu(artistList);
- if(artists == null) {
- if(!primaryFragment) {
- invalidated = true;
- } else {
- refresh(false);
- }
- } else {
+ if(objects != null) {
if (Util.isOffline(context) || Util.isTagBrowsing(context)) {
folderButton.setVisibility(View.GONE);
}
- artistList.setAdapter(new ArtistAdapter(context, artists));
setMusicFolders();
}
@@ -93,25 +78,11 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie }
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
- menuInflater.inflate(R.menu.select_artist, menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if(super.onOptionsItemSelected(item)) {
- return true;
- }
-
- return false;
- }
-
- @Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
- Object entry = artistList.getItemAtPosition(info.position);
+ Object entry = listView.getItemAtPosition(info.position);
if (entry instanceof Artist) {
onCreateContextMenu(menu, view, menuInfo, entry);
@@ -143,7 +114,7 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie }
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
- Artist artist = (Artist) artistList.getItemAtPosition(info.position);
+ Artist artist = (Artist) listView.getItemAtPosition(info.position);
if (artist != null) {
return onContextItemSelected(menuItem, artist);
@@ -181,19 +152,20 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie }
@Override
- protected void refresh(boolean refresh) {
- load(refresh);
- }
+ protected void refresh(final boolean refresh) {
+ if(folderButton == null) {
+ folderButtonParent = getLayoutInflater(null).inflate(R.layout.select_artist_header, listView, false);
+ folderName = (TextView) folderButtonParent.findViewById(R.id.select_artist_folder_2);
+ listView.addHeaderView(folderButtonParent);
+ folderButton = folderButtonParent.findViewById(R.id.select_artist_folder);
+ }
- private void load(final boolean refresh) {
- setTitle(R.string.button_bar_browse);
-
if (Util.isOffline(context) || Util.isTagBrowsing(context)) {
folderButton.setVisibility(View.GONE);
} else {
folderButton.setVisibility(View.VISIBLE);
}
- artistList.setVisibility(View.INVISIBLE);
+ listView.setVisibility(View.INVISIBLE);
BackgroundTask<Indexes> task = new TabBackgroundTask<Indexes>(this) {
@Override
@@ -208,20 +180,42 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie @Override
protected void done(Indexes result) {
- artists = new ArrayList<Artist>(result.getShortcuts().size() + result.getArtists().size());
- artists.addAll(result.getShortcuts());
- artists.addAll(result.getArtists());
- artistList.setFastScrollEnabled(false);
- artistList.setAdapter(new ArtistAdapter(context, artists));
- artistList.setFastScrollEnabled(true);
+ objects = new ArrayList<Artist>(result.getShortcuts().size() + result.getArtists().size());
+ objects.addAll(result.getShortcuts());
+ objects.addAll(result.getArtists());
+ listView.setFastScrollEnabled(false);
+ listView.setAdapter(adapter = getAdapter(objects));
+ listView.setFastScrollEnabled(true);
entries = result.getEntries();
setMusicFolders();
- artistList.setVisibility(View.VISIBLE);
+ listView.setVisibility(View.VISIBLE);
+ refreshLayout.setRefreshing(false);
}
};
task.execute();
}
+
+ @Override
+ public int getOptionsMenu() {
+ return R.menu.select_artist;
+ }
+
+ @Override
+ public ArrayAdapter getAdapter(List<Artist> objects) {
+ return new ArtistAdapter(context, objects);
+ }
+
+ @Override
+ public List<Artist> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception {
+ return null;
+ }
+
+ @Override
+ public int getTitleResource() {
+ return R.string.button_bar_browse;
+ }
+
private void setMusicFolders() {
// Display selected music folder
if (musicFolders != null) {
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index c91c005c..5ea432e5 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -19,7 +19,6 @@ package github.daneren2005.dsub.fragments; import android.content.DialogInterface; -import android.util.Log; import android.view.ContextMenu; import android.view.MenuInflater; import android.view.MenuItem; diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index c8937ea7..73a67592 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -6,6 +6,7 @@ import android.content.Intent; import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
@@ -14,21 +15,23 @@ import android.view.MenuInflater; import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AbsListView;
import android.widget.AdapterView;
+import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
-import github.daneren2005.dsub.domain.MusicFolder;
import github.daneren2005.dsub.domain.Share;
import github.daneren2005.dsub.util.ImageLoader;
+import github.daneren2005.dsub.view.AlbumGridAdapter;
import github.daneren2005.dsub.view.EntryAdapter;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
-import com.mobeta.android.dslv.*;
+
import github.daneren2005.dsub.activity.DownloadActivity;
import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.service.MusicService;
@@ -49,13 +52,16 @@ import java.util.Set; public class SelectDirectoryFragment extends SubsonicFragment implements AdapterView.OnItemClickListener {
private static final String TAG = SelectDirectoryFragment.class.getSimpleName();
- private DragSortListView entryList;
+ private GridView albumList;
+ private ListView entryList;
private View emptyView;
private boolean hideButtons = false;
private Boolean licenseValid;
private boolean showHeader = true;
private EntryAdapter entryAdapter;
+ private List<MusicDirectory.Entry> albums;
private List<MusicDirectory.Entry> entries;
+ private boolean albumContext = false;
String id;
String name;
@@ -93,30 +99,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- rootView = inflater.inflate(R.layout.select_album, container, false);
-
- entryList = (DragSortListView) rootView.findViewById(R.id.select_album_entries);
- entryList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
- entryList.setOnItemClickListener(this);
- entryList.setDropListener(new DragSortListView.DropListener() {
- @Override
- public void drop(int from, int to) {
- int max = entries.size();
- if(to >= max) {
- to = max - 1;
- }
- else if(to < 0) {
- to = 0;
- }
- entries.add(to, entries.remove(from));
- entryAdapter.notifyDataSetChanged();
- }
- });
-
- emptyView = rootView.findViewById(R.id.select_album_empty);
-
- registerForContextMenu(entryList);
-
Bundle args = getArguments();
if(args != null) {
id = args.getString(Constants.INTENT_EXTRA_NAME_ID);
@@ -144,6 +126,71 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
}
+ rootView = inflater.inflate(R.layout.select_album, container, false);
+
+ refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
+ refreshLayout.setOnRefreshListener(this);
+
+ entryList = (ListView) rootView.findViewById(R.id.select_album_entries);
+ entryList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
+ entryList.setOnItemClickListener(this);
+
+ entryList.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (entryList.getChildCount() == 0) ? 0 : entryList.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ }
+ });
+
+ if(albumListType == null || "starred".equals(albumListType)) {
+ albumList = (GridView) inflater.inflate(R.layout.unscrollable_grid_view, entryList, false);
+ entryList.addHeaderView(albumList);
+ } else {
+ ViewGroup rootGroup = (ViewGroup) rootView.findViewById(R.id.select_album_layout);
+ albumList = (GridView) inflater.inflate(R.layout.grid_view, rootGroup, false);
+ rootGroup.removeView(entryList);
+ rootGroup.addView(albumList);
+
+ albumList.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (albumList.getChildCount() == 0) ? 0 : albumList.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ }
+ });
+ }
+ albumList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ MusicDirectory.Entry entry = (MusicDirectory.Entry) parent.getItemAtPosition(position);
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle();
+ args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getId());
+ args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getTitle());
+ if ("newest".equals(albumListType)) {
+ args.putBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS, true);
+ }
+ if(entry.getArtist() == null && entry.getParent() == null) {
+ args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true);
+ }
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, true);
+ }
+ });
+
+ emptyView = rootView.findViewById(R.id.select_album_empty);
+
+ registerForContextMenu(entryList);
+ registerForContextMenu(albumList);
+
if(entries == null) {
if(primaryFragment || secondaryFragment) {
load(false);
@@ -169,7 +216,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
else if(hideButtons && !showAll) {
if(albumListType != null) {
- menuInflater.inflate(R.menu.select_album_list, menu);
+ menuInflater.inflate(R.menu.empty, menu);
} else {
menuInflater.inflate(R.menu.select_album, menu);
}
@@ -259,11 +306,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter return true;
}
- if(super.onOptionsItemSelected(item)) {
- return true;
- }
+ return super.onOptionsItemSelected(item);
- return false;
}
@Override
@@ -272,7 +316,18 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
- MusicDirectory.Entry entry = (MusicDirectory.Entry) entryList.getItemAtPosition(info.position);
+ MusicDirectory.Entry entry;
+ if(view.getId() == R.id.select_album_entries) {
+ if(info.position == 0) {
+ return;
+ }
+ entry = (MusicDirectory.Entry) entryList.getItemAtPosition(info.position);
+ albumContext = false;
+ } else {
+ entry = (MusicDirectory.Entry) albumList.getItemAtPosition(info.position);
+ albumContext = true;
+ }
+
onCreateContextMenu(menu, view, menuInfo, entry);
if(!entry.isVideo() && !Util.isOffline(context) && playlistId == null && (podcastId == null || Util.isOffline(context) && podcastId != null)) {
menu.removeItem(R.id.song_menu_remove_playlist);
@@ -298,7 +353,16 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
- Object selectedItem = entries.get(showHeader ? (info.position - 1) : info.position);
+ Object selectedItem;
+ if(albumContext) {
+ selectedItem = albums.get(showHeader ? (info.position - 1) : info.position);
+ } else {
+ if(info.position == 0) {
+ return false;
+ }
+ info.position--;
+ selectedItem = entries.get(showHeader ? (info.position - 1) : info.position);
+ }
if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, false) && menuItem.getItemId() == R.id.song_menu_play_now) {
List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>();
@@ -535,7 +599,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter SelectDirectoryFragment.this.albumListType = "genres-songs";
result = service.getSongsByGenre(albumListExtra, size, 0, context, this);
}
- } else if("genres".equals(albumListType)) {
+ } else if("genres".equals(albumListType) || "genres-songs".equals(albumListType)) {
result = service.getSongsByGenre(albumListExtra, size, 0, context, this);
} else {
result = service.getAlbumList(albumListType, size, 0, context, this);
@@ -563,7 +627,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter @Override
protected void done(Pair<MusicDirectory, Boolean> result) {
- entries = result.getFirst().getChildren();
+ albums = result.getFirst().getChildren(true, false);
+ entries = result.getFirst().getChildren(false, true);
licenseValid = result.getSecond();
finishLoading();
}
@@ -581,7 +646,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter if(showHeader) {
View header = createHeader(entries);
if(header != null) {
+ entryList.removeHeaderView(albumList);
entryList.addHeaderView(header, null, false);
+ entryList.addHeaderView(albumList);
}
}
} else {
@@ -591,13 +658,23 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
}
- emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE);
- entryAdapter = new EntryAdapter(context, getImageLoader(), entries, (podcastId == null) ? true : false);
- if(albumListType == null || "starred".equals(albumListType)) {
- entryList.setAdapter(entryAdapter);
- } else {
- entryList.setAdapter(new AlbumListAdapter(context, entryAdapter, albumListType, albumListExtra, albumListSize));
- }
+ emptyView.setVisibility((entries.isEmpty() && albums.isEmpty()) ? View.VISIBLE : View.GONE);
+ entryAdapter = new EntryAdapter(context, getImageLoader(), entries, (podcastId == null));
+ entryList.setAdapter(entryAdapter);
+ if("genres-songs".equals(albumListType)) {
+ ViewGroup rootGroup = (ViewGroup) rootView.findViewById(R.id.select_album_layout);
+ if(rootGroup.findViewById(R.id.gridview) != null) {
+ rootGroup.removeView(albumList);
+ rootGroup.addView(entryList);
+ }
+
+ entryList.setAdapter(new AlbumListAdapter(context, entryAdapter, albumListType, albumListExtra, albumListSize));
+ }
+ else if(albumListType == null || "starred".equals(albumListType)) {
+ albumList.setAdapter(new AlbumGridAdapter(context, getImageLoader(), albums));
+ } else {
+ albumList.setAdapter(new AlbumListAdapter(context, new AlbumGridAdapter(context, getImageLoader(), albums), albumListType, albumListExtra, albumListSize));
+ }
entryList.setVisibility(View.VISIBLE);
context.supportInvalidateOptionsMenu();
diff --git a/src/github/daneren2005/dsub/fragments/SelectListFragment.java b/src/github/daneren2005/dsub/fragments/SelectListFragment.java index d44422ce..35bf95c1 100644 --- a/src/github/daneren2005/dsub/fragments/SelectListFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectListFragment.java @@ -19,6 +19,7 @@ package github.daneren2005.dsub.fragments;
import android.os.Bundle;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -26,6 +27,7 @@ import android.view.MenuInflater; import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AbsListView;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
@@ -75,8 +77,21 @@ public abstract class SelectListFragment<T> extends SubsonicFragment implements public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
rootView = inflater.inflate(R.layout.abstract_list_fragment, container, false);
+ refreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_layout);
+ refreshLayout.setOnRefreshListener(this);
+
listView = (ListView)rootView.findViewById(R.id.fragment_list);
listView.setOnItemClickListener(this);
+ listView.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {}
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ int topRowVerticalPosition = (listView.getChildCount() == 0) ? 0 : listView.getChildAt(0).getTop();
+ refreshLayout.setEnabled(topRowVerticalPosition >= 0);
+ }
+ });
registerForContextMenu(listView);
emptyView = rootView.findViewById(R.id.fragment_list_empty);
@@ -100,11 +115,8 @@ public abstract class SelectListFragment<T> extends SubsonicFragment implements @Override
public boolean onOptionsItemSelected(MenuItem item) {
- if(super.onOptionsItemSelected(item)) {
- return true;
- }
+ return super.onOptionsItemSelected(item);
- return false;
}
@Override
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index bd0a3f45..45ab87e5 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -30,6 +30,7 @@ import android.media.MediaMetadataRetriever; import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.ContextMenu;
import android.view.GestureDetector;
@@ -75,7 +76,7 @@ import java.util.LinkedList; import java.util.List;
import java.util.Random;
-public class SubsonicFragment extends Fragment {
+public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private static final String TAG = SubsonicFragment.class.getSimpleName();
private static int TAG_INC = 10;
private int tag;
@@ -92,6 +93,7 @@ public class SubsonicFragment extends Fragment { protected Share share;
protected boolean artist = false;
protected boolean artistOverride = false;
+ protected SwipeRefreshLayout refreshLayout;
public SubsonicFragment() {
super();
@@ -135,9 +137,6 @@ public class SubsonicFragment extends Fragment { @Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.menu_refresh:
- refresh(true);
- return true;
case R.id.menu_shuffle:
onShuffleRequested();
return true;
@@ -406,6 +405,12 @@ public class SubsonicFragment extends Fragment { }
+ @Override
+ public void onRefresh() {
+ refreshLayout.setRefreshing(false);
+ refresh();
+ }
+
protected void exit() {
if(context.getClass() != SubsonicFragmentActivity.class) {
Intent intent = new Intent(context, SubsonicFragmentActivity.class);
diff --git a/src/github/daneren2005/dsub/provider/DSubWidget4x1.java b/src/github/daneren2005/dsub/provider/DSubWidget4x1.java index e00bf02d..9919eb22 100644 --- a/src/github/daneren2005/dsub/provider/DSubWidget4x1.java +++ b/src/github/daneren2005/dsub/provider/DSubWidget4x1.java @@ -18,7 +18,6 @@ */
package github.daneren2005.dsub.provider;
-import android.appwidget.AppWidgetManager;
import github.daneren2005.dsub.R;
public class DSubWidget4x1 extends DSubWidgetProvider {
diff --git a/src/github/daneren2005/dsub/provider/DSubWidget4x2.java b/src/github/daneren2005/dsub/provider/DSubWidget4x2.java index 4908f632..2aa6beae 100644 --- a/src/github/daneren2005/dsub/provider/DSubWidget4x2.java +++ b/src/github/daneren2005/dsub/provider/DSubWidget4x2.java @@ -18,7 +18,6 @@ */
package github.daneren2005.dsub.provider;
-import android.appwidget.AppWidgetManager;
import github.daneren2005.dsub.R;
public class DSubWidget4x2 extends DSubWidgetProvider {
diff --git a/src/github/daneren2005/dsub/provider/DSubWidget4x3.java b/src/github/daneren2005/dsub/provider/DSubWidget4x3.java index f1908d0d..dfe071c0 100644 --- a/src/github/daneren2005/dsub/provider/DSubWidget4x3.java +++ b/src/github/daneren2005/dsub/provider/DSubWidget4x3.java @@ -18,7 +18,6 @@ */
package github.daneren2005.dsub.provider;
-import android.appwidget.AppWidgetManager;
import github.daneren2005.dsub.R;
public class DSubWidget4x3 extends DSubWidgetProvider {
diff --git a/src/github/daneren2005/dsub/provider/DSubWidget4x4.java b/src/github/daneren2005/dsub/provider/DSubWidget4x4.java index 7fee2747..fa53918d 100644 --- a/src/github/daneren2005/dsub/provider/DSubWidget4x4.java +++ b/src/github/daneren2005/dsub/provider/DSubWidget4x4.java @@ -18,7 +18,6 @@ */
package github.daneren2005.dsub.provider;
-import android.appwidget.AppWidgetManager;
import github.daneren2005.dsub.R;
public class DSubWidget4x4 extends DSubWidgetProvider {
diff --git a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java index be7dedf6..d66bc0ec 100644 --- a/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java +++ b/src/github/daneren2005/dsub/provider/DSubWidgetProvider.java @@ -46,7 +46,6 @@ import github.daneren2005.dsub.activity.SubsonicFragmentActivity; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.util.Constants; -import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.ImageLoader; import github.daneren2005.dsub.util.Util; diff --git a/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java b/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java index da6e0c2c..0d2a5ff5 100644 --- a/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java +++ b/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java @@ -30,13 +30,15 @@ import android.support.v7.media.MediaRouteProviderDescriptor; import github.daneren2005.dsub.domain.RemoteControlState; import github.daneren2005.dsub.service.DownloadService; +import github.daneren2005.dsub.service.RemoteController; /** * Created by Scott on 11/28/13. */ public class JukeboxRouteProvider extends MediaRouteProvider { public static final String CATEGORY_JUKEBOX_ROUTE = "github.daneren2005.dsub.SERVER_JUKEBOX"; - private static int MAX_VOLUME = 10; + private RemoteController controller; + private static final int MAX_VOLUME = 10; private DownloadService downloadService; @@ -44,6 +46,10 @@ public class JukeboxRouteProvider extends MediaRouteProvider { super(context); this.downloadService = (DownloadService) context; + broadcastDescriptor(); + } + + private void broadcastDescriptor() { // Create intents IntentFilter routeIntentFilter = new IntentFilter(); routeIntentFilter.addCategory(CATEGORY_JUKEBOX_ROUTE); @@ -57,7 +63,7 @@ public class JukeboxRouteProvider extends MediaRouteProvider { .setPlaybackStream(AudioManager.STREAM_MUSIC) .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE) .setDescription("Subsonic Jukebox") - .setVolume(5) + .setVolume(controller == null ? 5 : (int) (controller.getVolume() * 10)) .setVolumeMax(MAX_VOLUME) .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE); @@ -72,7 +78,7 @@ public class JukeboxRouteProvider extends MediaRouteProvider { return new JukeboxRouteController(downloadService); } - private static class JukeboxRouteController extends RouteController { + private class JukeboxRouteController extends RouteController { private DownloadService downloadService; public JukeboxRouteController(DownloadService downloadService) { @@ -91,16 +97,35 @@ public class JukeboxRouteProvider extends MediaRouteProvider { @Override public void onRelease() { downloadService.setRemoteEnabled(RemoteControlState.LOCAL); + controller = null; } @Override public void onSelect() { downloadService.setRemoteEnabled(RemoteControlState.JUKEBOX_SERVER); + controller = downloadService.getRemoteController(); } @Override public void onUnselect() { downloadService.setRemoteEnabled(RemoteControlState.LOCAL); + controller = null; + } + + @Override + public void onUpdateVolume(int delta) { + if(controller != null) { + controller.updateVolume(delta > 0); + } + broadcastDescriptor(); + } + + @Override + public void onSetVolume(int volume) { + if(controller != null) { + controller.setVolume(volume); + } + broadcastDescriptor(); } } } diff --git a/src/github/daneren2005/dsub/provider/MostRecentStubProvider.java b/src/github/daneren2005/dsub/provider/MostRecentStubProvider.java index 33bc45c3..17447cda 100644 --- a/src/github/daneren2005/dsub/provider/MostRecentStubProvider.java +++ b/src/github/daneren2005/dsub/provider/MostRecentStubProvider.java @@ -41,7 +41,7 @@ public class MostRecentStubProvider extends ContentProvider { @Override
public String getType(Uri uri) {
- return new String();
+ return "";
}
@Override
diff --git a/src/github/daneren2005/dsub/provider/PlaylistStubProvider.java b/src/github/daneren2005/dsub/provider/PlaylistStubProvider.java index c778e762..e817c047 100644 --- a/src/github/daneren2005/dsub/provider/PlaylistStubProvider.java +++ b/src/github/daneren2005/dsub/provider/PlaylistStubProvider.java @@ -41,7 +41,7 @@ public class PlaylistStubProvider extends ContentProvider { @Override
public String getType(Uri uri) {
- return new String();
+ return "";
}
@Override
diff --git a/src/github/daneren2005/dsub/provider/PodcastStubProvider.java b/src/github/daneren2005/dsub/provider/PodcastStubProvider.java index 75def009..1c70e7f4 100644 --- a/src/github/daneren2005/dsub/provider/PodcastStubProvider.java +++ b/src/github/daneren2005/dsub/provider/PodcastStubProvider.java @@ -41,7 +41,7 @@ public class PodcastStubProvider extends ContentProvider { @Override
public String getType(Uri uri) {
- return new String();
+ return "";
}
@Override
diff --git a/src/github/daneren2005/dsub/provider/StarredStubProvider.java b/src/github/daneren2005/dsub/provider/StarredStubProvider.java index bb865096..27a84e3f 100644 --- a/src/github/daneren2005/dsub/provider/StarredStubProvider.java +++ b/src/github/daneren2005/dsub/provider/StarredStubProvider.java @@ -41,7 +41,7 @@ public class StarredStubProvider extends ContentProvider { @Override
public String getType(Uri uri) {
- return new String();
+ return "";
}
@Override
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index d98a67e1..d0740704 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -87,7 +87,7 @@ public class CachedMusicService implements MusicService { result = musicService.isLicenseValid(context, progressListener); // Only save a copy license is valid - if(result == true) { + if(result) { FileUtil.serialize(context, (Boolean) result, getCacheName(context, "license")); } } diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java index 639c7ebe..7568fe4d 100644 --- a/src/github/daneren2005/dsub/service/ChromeCastController.java +++ b/src/github/daneren2005/dsub/service/ChromeCastController.java @@ -54,9 +54,6 @@ public class ChromeCastController extends RemoteController { private CastDevice castDevice; private GoogleApiClient apiClient; - private ConnectionCallbacks connectionCallbacks; - private ConnectionFailedListener connectionFailedListener; - private Cast.Listener castClientListener; private boolean applicationStarted = false; private boolean waitingForReconnect = false; @@ -81,9 +78,9 @@ public class ChromeCastController extends RemoteController { public void create(boolean playing, int seconds) { downloadService.setPlayerState(PlayerState.PREPARING); - connectionCallbacks = new ConnectionCallbacks(playing, seconds); - connectionFailedListener = new ConnectionFailedListener(); - castClientListener = new Cast.Listener() { + ConnectionCallbacks connectionCallbacks = new ConnectionCallbacks(playing, seconds); + ConnectionFailedListener connectionFailedListener = new ConnectionFailedListener(); + Cast.Listener castClientListener = new Cast.Listener() { @Override public void onApplicationStatusChanged() { if (apiClient != null && apiClient.isConnected()) { @@ -96,7 +93,7 @@ public class ChromeCastController extends RemoteController { if (apiClient != null && applicationStarted) { try { gain = Cast.CastApi.getVolume(apiClient); - } catch(Exception e) { + } catch (Exception e) { Log.w(TAG, "Failed to get volume"); } } @@ -203,7 +200,18 @@ public class ChromeCastController extends RemoteController { } @Override - public void setVolume(boolean up) { + public void setVolume(int volume) { + gain = volume / 10.0; + + getVolumeToast().setVolume((float) gain); + try { + Cast.CastApi.setVolume(apiClient, gain); + } catch(Exception e) { + Log.e(TAG, "Failed to the volume"); + } + } + @Override + public void updateVolume(boolean up) { double delta = up ? 0.1 : -0.1; gain += delta; gain = Math.max(gain, 0.0); @@ -216,6 +224,10 @@ public class ChromeCastController extends RemoteController { Log.e(TAG, "Failed to the volume"); } } + @Override + public double getVolume() { + return Cast.CastApi.getVolume(apiClient); + } @Override public int getRemotePosition() { diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java index 9b7dd45d..dc1c7cbd 100644 --- a/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/src/github/daneren2005/dsub/service/DownloadFile.java @@ -31,7 +31,6 @@ import android.os.PowerManager; import android.util.DisplayMetrics; import android.util.Log; import github.daneren2005.dsub.domain.MusicDirectory; -import github.daneren2005.dsub.service.parser.SubsonicRESTException; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.Util; @@ -67,6 +66,7 @@ public class DownloadFile implements BufferFile { private boolean completeWhenDone = false; private Long contentLength = null; private long currentSpeed = 0; + private boolean rateLimit = false; public DownloadFile(Context context, MusicDirectory.Entry song, boolean save) { this.context = context; @@ -150,10 +150,12 @@ public class DownloadFile implements BufferFile { } public synchronized void download() { + rateLimit = false; preDownload(); downloadTask.execute(); } public synchronized void downloadNow(MusicService musicService) { + rateLimit = true; preDownload(); downloadTask.setMusicService(musicService); try { @@ -296,10 +298,10 @@ public class DownloadFile implements BufferFile { public void setPlaying(boolean isPlaying) { try { - if(saveWhenDone && isPlaying == false) { + if(saveWhenDone && !isPlaying) { Util.renameFile(completeFile, saveFile); saveWhenDone = false; - } else if(completeWhenDone && isPlaying == false) { + } else if(completeWhenDone && !isPlaying) { if(save) { Util.renameFile(partialFile, saveFile); mediaStoreService.saveInMediaStore(DownloadFile.this); @@ -523,6 +525,7 @@ public class DownloadFile implements BufferFile { long lastLog = System.currentTimeMillis(); long lastCount = 0; + boolean activeLimit = rateLimit; while (!isCancelled() && (n = in.read(buffer)) != -1) { out.write(buffer, 0, n); count += n; @@ -534,6 +537,21 @@ public class DownloadFile implements BufferFile { currentSpeed = lastCount / ((now - lastLog) / 1000L); lastLog = now; lastCount = 0; + + // Re-establish every few seconds whether screen is on or not + if(rateLimit) { + PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + if(pm.isScreenOn()) { + activeLimit = true; + } else { + activeLimit = false; + } + } + } + + // If screen is on and rateLimit is true, stop downloading from exhausting bandwidth + if(activeLimit) { + Thread.sleep(10L); } } return count; diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 3637f731..66295d5e 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -30,7 +30,6 @@ import static github.daneren2005.dsub.domain.PlayerState.STOPPED; import github.daneren2005.dsub.audiofx.AudioEffectsController; import github.daneren2005.dsub.audiofx.EqualizerController; -import github.daneren2005.dsub.audiofx.LoudnessEnhancerController; import github.daneren2005.dsub.audiofx.VisualizerController; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; @@ -70,9 +69,9 @@ import android.os.IBinder; import android.os.Looper; import android.os.PowerManager; import android.support.v7.media.MediaRouteSelector; +import android.support.v7.media.MediaRouter; import android.util.Log; import android.support.v4.util.LruCache; -import java.net.URLEncoder; /** * @author Sindre Mehus @@ -99,7 +98,6 @@ public class DownloadService extends Service { private MediaPlayer nextMediaPlayer; private int audioSessionId; private boolean nextSetup = false; - private boolean isPartial = true; private final List<DownloadFile> downloadList = new ArrayList<DownloadFile>(); private final List<DownloadFile> backgroundDownloadList = new ArrayList<DownloadFile>(); private final List<DownloadFile> toDelete = new ArrayList<DownloadFile>(); @@ -128,7 +126,6 @@ public class DownloadService extends Service { private PowerManager.WakeLock wakeLock; private boolean keepScreenOn; private int cachedPosition = 0; - private long downloadRevision; private boolean downloadOngoing = false; private AudioEffectsController effectsController; @@ -1115,6 +1112,10 @@ public class DownloadService extends Service { return remoteState != RemoteControlState.LOCAL; } + public RemoteController getRemoteController() { + return remoteController; + } + public void setRemoteEnabled(RemoteControlState newState) { if(instance != null) { setRemoteEnabled(newState, null); @@ -1229,8 +1230,19 @@ public class DownloadService extends Service { } } - public void setRemoteVolume(boolean up) { - remoteController.setVolume(up); + public void registerRoute(MediaRouter router) { + mRemoteControl.registerRoute(router); + } + public void unregisterRoute(MediaRouter router) { + mRemoteControl.unregisterRoute(router); + } + + public void updateRemoteVolume(boolean up) { + if(remoteState == RemoteControlState.JUKEBOX_SERVER) { + mediaRouter.getSelectedRoute().requestUpdateVolume(up ? 1 : -1); + } else { + remoteController.updateVolume(up); + } } public void startRemoteScan() { @@ -1262,7 +1274,7 @@ public class DownloadService extends Service { try { downloadFile.setPlaying(true); final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile(); - isPartial = file.equals(downloadFile.getPartialFile()); + boolean isPartial = file.equals(downloadFile.getPartialFile()); downloadFile.updateModificationDate(); mediaPlayer.setOnCompletionListener(null); @@ -1520,7 +1532,11 @@ public class DownloadService extends Service { private void handleError(Exception x) { Log.w(TAG, "Media player error: " + x, x); if(mediaPlayer != null) { - mediaPlayer.reset(); + try { + mediaPlayer.reset(); + } catch(Exception e) { + Log.e(TAG, "Failed to reset player in error handler"); + } } setPlayerState(IDLE); } @@ -1618,7 +1634,6 @@ public class DownloadService extends Service { if(!backgroundDownloadList.isEmpty()) { Util.showDownloadingNotification(this, currentDownloading, backgroundDownloadList.size()); - downloadRevision = revision; downloadOngoing = true; } else if(backgroundDownloadList.isEmpty() && downloadOngoing) { Util.hideDownloadingNotification(this); diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index c4a79ee0..5e8b0f8b 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -21,7 +21,6 @@ package github.daneren2005.dsub.service; import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/src/github/daneren2005/dsub/service/JukeboxController.java b/src/github/daneren2005/dsub/service/JukeboxController.java index ebebbaf8..da1538be 100644 --- a/src/github/daneren2005/dsub/service/JukeboxController.java +++ b/src/github/daneren2005/dsub/service/JukeboxController.java @@ -124,7 +124,15 @@ public class JukeboxController extends RemoteController { downloadService.setPlayerState(PlayerState.STARTED); } @Override - public void setVolume(boolean up) { + public void setVolume(int volume) { + gain = volume / 10.0f; + + getVolumeToast().setVolume(gain); + tasks.remove(SetGain.class); + tasks.add(new SetGain(gain)); + } + @Override + public void updateVolume(boolean up) { float delta = up ? 0.1f : -0.1f; gain += delta; gain = Math.max(gain, 0.0f); @@ -134,6 +142,10 @@ public class JukeboxController extends RemoteController { tasks.remove(SetGain.class); tasks.add(new SetGain(gain)); } + @Override + public double getVolume() { + return gain; + } @Override public int getRemotePosition() { diff --git a/src/github/daneren2005/dsub/service/RemoteController.java b/src/github/daneren2005/dsub/service/RemoteController.java index e41a37ad..d5a4d8df 100644 --- a/src/github/daneren2005/dsub/service/RemoteController.java +++ b/src/github/daneren2005/dsub/service/RemoteController.java @@ -46,7 +46,9 @@ public abstract class RemoteController { public abstract void updatePlaylist(); public abstract void changePosition(int seconds); public abstract void changeTrack(int index, DownloadFile song); - public abstract void setVolume(boolean up); + public abstract void setVolume(int volume); + public abstract void updateVolume(boolean up); + public abstract double getVolume(); public abstract int getRemotePosition(); public int getRemoteDuration() { diff --git a/src/github/daneren2005/dsub/service/parser/AlbumListParser.java b/src/github/daneren2005/dsub/service/parser/AlbumListParser.java index 9cf064e6..880a9a22 100644 --- a/src/github/daneren2005/dsub/service/parser/AlbumListParser.java +++ b/src/github/daneren2005/dsub/service/parser/AlbumListParser.java @@ -36,8 +36,6 @@ public class AlbumListParser extends MusicDirectoryEntryParser { } public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception { - - updateProgress(progressListener, R.string.parser_reading); init(reader); MusicDirectory dir = new MusicDirectory(); @@ -57,7 +55,6 @@ public class AlbumListParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return dir; } diff --git a/src/github/daneren2005/dsub/service/parser/BookmarkParser.java b/src/github/daneren2005/dsub/service/parser/BookmarkParser.java index a71e0e8b..23db3a07 100644 --- a/src/github/daneren2005/dsub/service/parser/BookmarkParser.java +++ b/src/github/daneren2005/dsub/service/parser/BookmarkParser.java @@ -37,7 +37,6 @@ public class BookmarkParser extends MusicDirectoryEntryParser { } public List<Bookmark> parse(Reader reader, ProgressListener progressListener) throws Exception { - updateProgress(progressListener, R.string.parser_reading); init(reader); List<Bookmark> bookmarks = new ArrayList<Bookmark>(); @@ -69,7 +68,6 @@ public class BookmarkParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return bookmarks; } diff --git a/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java b/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java index 1425a734..8e37de40 100644 --- a/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java +++ b/src/github/daneren2005/dsub/service/parser/ChatMessageParser.java @@ -38,7 +38,6 @@ public class ChatMessageParser extends AbstractParser { }
public List<ChatMessage> parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
init(reader);
List<ChatMessage> result = new ArrayList<ChatMessage>();
int eventType;
@@ -60,7 +59,6 @@ public class ChatMessageParser extends AbstractParser { } while (eventType != XmlPullParser.END_DOCUMENT);
validate();
- updateProgress(progressListener, R.string.parser_reading_done);
return result;
}
diff --git a/src/github/daneren2005/dsub/service/parser/GenreParser.java b/src/github/daneren2005/dsub/service/parser/GenreParser.java index 35913ba9..e963442c 100644 --- a/src/github/daneren2005/dsub/service/parser/GenreParser.java +++ b/src/github/daneren2005/dsub/service/parser/GenreParser.java @@ -45,8 +45,6 @@ public class GenreParser extends AbstractParser { }
public List<Genre> parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
-
List<Genre> result = new ArrayList<Genre>();
StringReader sr = null;
@@ -118,7 +116,6 @@ public class GenreParser extends AbstractParser { } while (eventType != XmlPullParser.END_DOCUMENT);
validate();
- updateProgress(progressListener, R.string.parser_reading_done);
return Genre.GenreComparator.sort(result);
}
diff --git a/src/github/daneren2005/dsub/service/parser/IndexesParser.java b/src/github/daneren2005/dsub/service/parser/IndexesParser.java index 30ea190b..3af76e1d 100644 --- a/src/github/daneren2005/dsub/service/parser/IndexesParser.java +++ b/src/github/daneren2005/dsub/service/parser/IndexesParser.java @@ -49,9 +49,7 @@ public class IndexesParser extends MusicDirectoryEntryParser { } public Indexes parse(Reader reader, ProgressListener progressListener) throws Exception { - long t0 = System.currentTimeMillis(); - updateProgress(progressListener, R.string.parser_reading); init(reader); List<Artist> artists = new ArrayList<Artist>(); diff --git a/src/github/daneren2005/dsub/service/parser/LyricsParser.java b/src/github/daneren2005/dsub/service/parser/LyricsParser.java index 98b0f6a0..b621d518 100644 --- a/src/github/daneren2005/dsub/service/parser/LyricsParser.java +++ b/src/github/daneren2005/dsub/service/parser/LyricsParser.java @@ -36,7 +36,6 @@ public class LyricsParser extends AbstractParser { } public Lyrics parse(Reader reader, ProgressListener progressListener) throws Exception { - updateProgress(progressListener, R.string.parser_reading); init(reader); Lyrics lyrics = null; diff --git a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java index 75f878be..e09aa33b 100644 --- a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java +++ b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java @@ -44,7 +44,6 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser { public MusicDirectory parse(String artist, Reader reader, ProgressListener progressListener) throws Exception { long t0 = System.currentTimeMillis(); - updateProgress(progressListener, R.string.parser_reading); init(reader); MusicDirectory dir = new MusicDirectory(); @@ -74,7 +73,6 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); // Only apply sorting on server version 4.7 and greater, where disc is supported if(Util.checkServerVersion(context, "1.8.0") && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_CUSTOM_SORT_ENABLED, true)) { diff --git a/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java b/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java index 5dfebf27..246c3415 100644 --- a/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java +++ b/src/github/daneren2005/dsub/service/parser/MusicFoldersParser.java @@ -27,7 +27,6 @@ import org.xmlpull.v1.XmlPullParser; import android.content.Context; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.MusicFolder; -import github.daneren2005.dsub.domain.Playlist; import github.daneren2005.dsub.util.ProgressListener; /** @@ -40,8 +39,6 @@ public class MusicFoldersParser extends AbstractParser { } public List<MusicFolder> parse(Reader reader, ProgressListener progressListener) throws Exception { - - updateProgress(progressListener, R.string.parser_reading); init(reader); List<MusicFolder> result = new ArrayList<MusicFolder>(); @@ -61,7 +58,6 @@ public class MusicFoldersParser extends AbstractParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return result; } diff --git a/src/github/daneren2005/dsub/service/parser/PlaylistParser.java b/src/github/daneren2005/dsub/service/parser/PlaylistParser.java index c630eb44..1eda1806 100644 --- a/src/github/daneren2005/dsub/service/parser/PlaylistParser.java +++ b/src/github/daneren2005/dsub/service/parser/PlaylistParser.java @@ -36,7 +36,6 @@ public class PlaylistParser extends MusicDirectoryEntryParser { } public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception { - updateProgress(progressListener, R.string.parser_reading); init(reader); MusicDirectory dir = new MusicDirectory(); @@ -57,7 +56,6 @@ public class PlaylistParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return dir; } diff --git a/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java b/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java index a5bf2497..c3b47f47 100644 --- a/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java +++ b/src/github/daneren2005/dsub/service/parser/PlaylistsParser.java @@ -39,8 +39,6 @@ public class PlaylistsParser extends AbstractParser { } public List<Playlist> parse(Reader reader, ProgressListener progressListener) throws Exception { - - updateProgress(progressListener, R.string.parser_reading); init(reader); List<Playlist> result = new ArrayList<Playlist>(); @@ -65,7 +63,6 @@ public class PlaylistsParser extends AbstractParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return PlaylistAdapter.PlaylistComparator.sort(result); } diff --git a/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java b/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java index bfdef7f2..6c83fad6 100644 --- a/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java +++ b/src/github/daneren2005/dsub/service/parser/PodcastChannelParser.java @@ -37,7 +37,6 @@ public class PodcastChannelParser extends AbstractParser { }
public List<PodcastChannel> parse(Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
init(reader);
List<PodcastChannel> channels = new ArrayList<PodcastChannel>();
diff --git a/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java b/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java index 58b1432b..c331f7e1 100644 --- a/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java +++ b/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java @@ -39,7 +39,6 @@ public class PodcastEntryParser extends AbstractParser { }
public MusicDirectory parse(String channel, Reader reader, ProgressListener progressListener) throws Exception {
- updateProgress(progressListener, R.string.parser_reading);
init(reader);
MusicDirectory episodes = new MusicDirectory();
diff --git a/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java b/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java index 3e62d3dc..88be3662 100644 --- a/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java +++ b/src/github/daneren2005/dsub/service/parser/RandomSongsParser.java @@ -36,7 +36,6 @@ public class RandomSongsParser extends MusicDirectoryEntryParser { } public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception { - updateProgress(progressListener, R.string.parser_reading); init(reader); MusicDirectory dir = new MusicDirectory(); @@ -54,7 +53,6 @@ public class RandomSongsParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return dir; } diff --git a/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java b/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java index abf96d7f..ce4a71c8 100644 --- a/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java +++ b/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java @@ -40,7 +40,6 @@ public class SearchResult2Parser extends MusicDirectoryEntryParser { } public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception { - updateProgress(progressListener, R.string.parser_reading); init(reader); List<Artist> artists = new ArrayList<Artist>(); @@ -69,7 +68,6 @@ public class SearchResult2Parser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return new SearchResult(artists, albums, songs); } diff --git a/src/github/daneren2005/dsub/service/parser/SearchResultParser.java b/src/github/daneren2005/dsub/service/parser/SearchResultParser.java index c8ef4031..952b95bc 100644 --- a/src/github/daneren2005/dsub/service/parser/SearchResultParser.java +++ b/src/github/daneren2005/dsub/service/parser/SearchResultParser.java @@ -41,7 +41,6 @@ public class SearchResultParser extends MusicDirectoryEntryParser { } public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception { - updateProgress(progressListener, R.string.parser_reading); init(reader); List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>(); @@ -59,7 +58,6 @@ public class SearchResultParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return new SearchResult(Collections.<Artist>emptyList(), Collections.<MusicDirectory.Entry>emptyList(), songs); } diff --git a/src/github/daneren2005/dsub/service/parser/ShareParser.java b/src/github/daneren2005/dsub/service/parser/ShareParser.java index 27a53d66..25feb5af 100644 --- a/src/github/daneren2005/dsub/service/parser/ShareParser.java +++ b/src/github/daneren2005/dsub/service/parser/ShareParser.java @@ -20,7 +20,6 @@ package github.daneren2005.dsub.service.parser; import android.content.Context;
import android.content.SharedPreferences;
-import android.util.Log;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.Share;
@@ -44,8 +43,6 @@ public class ShareParser extends MusicDirectoryEntryParser { }
public List<Share> parse(Reader reader, ProgressListener progressListener) throws Exception {
-
- updateProgress(progressListener, R.string.parser_reading);
init(reader);
List<Share> dir = new ArrayList<Share>();
@@ -88,7 +85,6 @@ public class ShareParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT);
validate();
- updateProgress(progressListener, R.string.parser_reading_done);
return dir;
}
diff --git a/src/github/daneren2005/dsub/service/parser/StarredListParser.java b/src/github/daneren2005/dsub/service/parser/StarredListParser.java index bd2a7888..89addecd 100644 --- a/src/github/daneren2005/dsub/service/parser/StarredListParser.java +++ b/src/github/daneren2005/dsub/service/parser/StarredListParser.java @@ -36,8 +36,6 @@ public class StarredListParser extends MusicDirectoryEntryParser { } public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception { - - updateProgress(progressListener, R.string.parser_reading); init(reader); MusicDirectory dir = new MusicDirectory(); @@ -63,7 +61,6 @@ public class StarredListParser extends MusicDirectoryEntryParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); - updateProgress(progressListener, R.string.parser_reading_done); return dir; } diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java index ba4f34c9..f680becf 100644 --- a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java @@ -82,18 +82,16 @@ public class PlaylistSyncAdapter extends SubsonicSyncAdapter { for(MusicDirectory.Entry entry: playlist.getChildren()) {
DownloadFile file = new DownloadFile(context, entry, true);
String path = file.getCompleteFile().getPath();
- if(!cachedPlaylist.synced.contains(path)) {
- while(!file.isSaved() && !file.isFailedMax()) {
- file.downloadNow(musicService);
- if(!updated.contains(playlist.getName())) {
- updated.add(playlist.getName());
- }
+ while(!file.isSaved() && !file.isFailedMax()) {
+ file.downloadNow(musicService);
+ if(file.isSaved() && !updated.contains(playlist.getName())) {
+ updated.add(playlist.getName());
}
+ }
- // Add to cached path set if saved
- if(file.isSaved()) {
- cachedPlaylist.synced.add(path);
- }
+ // Add to cached path set if saved
+ if(file.isSaved() && !cachedPlaylist.synced.contains(path)) {
+ cachedPlaylist.synced.add(path);
}
origPathList.remove(path);
@@ -118,12 +116,13 @@ public class PlaylistSyncAdapter extends SubsonicSyncAdapter { Log.e(TAG, "Failed to get playlist " + id + " for " + serverName, e);
}
- if(updated.size() > 0) {
- SyncUtil.showSyncNotification(context, R.string.sync_new_playlists, SyncUtil.joinNames(updated));
- }
if(updated.size() > 0 || removed) {
SyncUtil.setSyncedPlaylists(context, instance, playlistList);
}
}
+
+ if(updated.size() > 0) {
+ SyncUtil.showSyncNotification(context, R.string.sync_new_playlists, SyncUtil.joinNames(updated));
+ }
}
}
diff --git a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java index a23fa63f..54c10f41 100644 --- a/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/StarredSyncAdapter.java @@ -25,7 +25,6 @@ import android.util.Log; import java.io.File;
import java.util.ArrayList;
-import java.util.List;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
diff --git a/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java index 1f380e90..eccdaee2 100644 --- a/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java +++ b/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java @@ -149,10 +149,6 @@ public class SubsonicSyncAdapter extends AbstractThreadedSyncAdapter { private boolean isValidServer(Context context, int instance) { String url = Util.getRestUrl(context, "null", instance, false); - if(url.contains("demo.subsonic.org") || url.contains("yourhost")) { - return false; - } else { - return true; - } + return !(url.contains("demo.subsonic.org") || url.contains("yourhost")); } } diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java index c3008b3a..b1b00cc5 100644 --- a/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/src/github/daneren2005/dsub/util/ImageLoader.java @@ -215,7 +215,6 @@ public class ImageLoader { } } imageView.setImageDrawable(drawable); - return; } } diff --git a/src/github/daneren2005/dsub/util/MediaRouteManager.java b/src/github/daneren2005/dsub/util/MediaRouteManager.java index 9b4110f3..cad8afe3 100644 --- a/src/github/daneren2005/dsub/util/MediaRouteManager.java +++ b/src/github/daneren2005/dsub/util/MediaRouteManager.java @@ -15,7 +15,6 @@ package github.daneren2005.dsub.util; -import android.support.v7.media.MediaControlIntent; import android.support.v7.media.MediaRouteProvider; import android.support.v7.media.MediaRouteSelector; import android.support.v7.media.MediaRouter; @@ -86,9 +85,17 @@ public class MediaRouteManager extends MediaRouter.Callback { downloadService.setRemoteEnabled(RemoteControlState.CHROMECAST, controller); } } + + if(downloadService.isRemoteEnabled()) { + downloadService.registerRoute(router); + } } @Override public void onRouteUnselected(MediaRouter router, RouteInfo info) { + if(downloadService.isRemoteEnabled()) { + downloadService.unregisterRoute(router); + } + downloadService.setRemoteEnabled(RemoteControlState.LOCAL); } diff --git a/src/github/daneren2005/dsub/util/SyncUtil.java b/src/github/daneren2005/dsub/util/SyncUtil.java index 3a338543..0c567681 100644 --- a/src/github/daneren2005/dsub/util/SyncUtil.java +++ b/src/github/daneren2005/dsub/util/SyncUtil.java @@ -5,7 +5,6 @@ import android.app.PendingIntent; import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
-import android.util.Log;
import java.io.File;
import java.io.Serializable;
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 8488420e..10b0a429 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -39,7 +39,6 @@ import android.media.AudioManager.OnAudioFocusChangeListener; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiManager; -import android.opengl.Visibility; import android.os.Build; import android.os.Environment; import android.os.Handler; @@ -173,11 +172,7 @@ public final class Util { public static boolean checkServerVersion(Context context, String requiredVersion) { Version version = Util.getServerRestVersion(context); Version required = new Version(requiredVersion); - if(version != null && version.compareTo(required) >= 0) { - return true; - } else { - return false; - } + return version != null && version.compareTo(required) >= 0; } public static int getServerCount(Context context) { diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java index c3f3f70c..320092e9 100644 --- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java +++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientBase.java @@ -3,6 +3,7 @@ package github.daneren2005.dsub.util.compat; import github.daneren2005.dsub.domain.MusicDirectory.Entry; import android.content.ComponentName; import android.content.Context; +import android.support.v7.media.MediaRouter; import android.util.Log; public class RemoteControlClientBase extends RemoteControlClientHelper { @@ -11,22 +12,32 @@ public class RemoteControlClientBase extends RemoteControlClientHelper { @Override public void register(Context context, ComponentName mediaButtonReceiverComponent) { - Log.w(TAG, "RemoteControlClient requires Android API level 14 or higher."); + } @Override public void unregister(Context context) { - Log.w(TAG, "RemoteControlClient requires Android API level 14 or higher."); + } @Override public void setPlaybackState(int state) { - Log.w(TAG, "RemoteControlClient requires Android API level 14 or higher."); + } @Override public void updateMetadata(Context context, Entry currentSong) { - Log.w(TAG, "RemoteControlClient requires Android API level 14 or higher."); + + } + + @Override + public void registerRoute(MediaRouter router) { + + } + + @Override + public void unregisterRoute(MediaRouter router) { + } } diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientHelper.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientHelper.java index 9826851d..93075a28 100644 --- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientHelper.java +++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientHelper.java @@ -3,6 +3,7 @@ package github.daneren2005.dsub.util.compat; import github.daneren2005.dsub.domain.MusicDirectory; import android.content.ComponentName; import android.content.Context; +import android.support.v7.media.MediaRouter; import android.os.Build; public abstract class RemoteControlClientHelper { @@ -25,5 +26,7 @@ public abstract class RemoteControlClientHelper { public abstract void unregister(final Context context); public abstract void setPlaybackState(final int state); public abstract void updateMetadata(final Context context, final MusicDirectory.Entry currentSong); + public abstract void registerRoute(MediaRouter router); + public abstract void unregisterRoute(MediaRouter router); } diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java index 56378a25..50283da6 100644 --- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java +++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java @@ -11,6 +11,7 @@ import android.content.Intent; import android.media.AudioManager; import android.media.MediaMetadataRetriever; import android.media.RemoteControlClient; +import android.support.v7.media.MediaRouter; import github.daneren2005.dsub.activity.SubsonicActivity; @@ -68,6 +69,17 @@ public class RemoteControlClientICS extends RemoteControlClientHelper { imageLoader.loadImage(context, mRemoteControl, currentSong); } } + + @Override + public void registerRoute(MediaRouter router) { + router.addRemoteControlClient(mRemoteControl); + } + + @Override + public void unregisterRoute(MediaRouter router) { + router.removeRemoteControlClient(mRemoteControl); + } + protected void updateMetadata(final MusicDirectory.Entry currentSong, final RemoteControlClient.MetadataEditor editor) { editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, (currentSong == null) ? null : currentSong.getArtist()) .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, (currentSong == null) ? null : currentSong.getAlbum()) diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java deleted file mode 100644 index 532aec5b..00000000 --- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java +++ /dev/null @@ -1,82 +0,0 @@ -package github.daneren2005.dsub.util.compat; - -import github.daneren2005.dsub.domain.MusicDirectory; -import github.daneren2005.dsub.util.ImageLoader; -import android.annotation.TargetApi; -import android.app.PendingIntent; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.media.AudioManager; -import android.media.MediaMetadataEditor; -import android.media.MediaMetadataRetriever; -import android.media.Rating; -import android.media.RemoteControlClient; -import android.os.AsyncTask; -import android.util.Log; - -import github.daneren2005.dsub.activity.SubsonicActivity; -import github.daneren2005.dsub.service.DownloadService; -import github.daneren2005.dsub.service.MusicService; -import github.daneren2005.dsub.service.MusicServiceFactory; -import github.daneren2005.dsub.util.SilentBackgroundTask; -import github.daneren2005.dsub.util.Util; -import java.io.File; -import java.util.Arrays; - -@TargetApi(19) -public class RemoteControlClientKK extends RemoteControlClientJB { - private static String TAG = RemoteControlClientKK.class.getSimpleName(); - protected MusicDirectory.Entry currentSong; - - @Override - public void register(final Context context, final ComponentName mediaButtonReceiverComponent) { - super.register(context, mediaButtonReceiverComponent); - - mRemoteControl.setMetadataUpdateListener(new RemoteControlClient.OnMetadataUpdateListener() { - @Override - public void onMetadataUpdate(int key, Object newValue) { - if(key == MediaMetadataEditor.RATING_KEY_BY_USER) { - Rating rating = (Rating) newValue; - setStarred(currentSong, rating.hasHeart()); - } - } - }); - } - - @Override - protected void updateMetadata(final MusicDirectory.Entry currentSong, final RemoteControlClient.MetadataEditor editor) { - super.updateMetadata(currentSong, editor); - editor.putObject(MediaMetadataEditor.RATING_KEY_BY_USER, Rating.newHeartRating(currentSong.isStarred())); - editor.addEditableKey(MediaMetadataEditor.RATING_KEY_BY_USER); - this.currentSong = currentSong; - } - - @Override - protected int getTransportFlags() { - return super.getTransportFlags() | RemoteControlClient.FLAG_KEY_MEDIA_RATING; - } - - private void setStarred(final MusicDirectory.Entry entry, final boolean starred) { - entry.setStarred(starred); - - new AsyncTask<Void, Void, Void>() { - @Override - protected Void doInBackground(Void... params) { - try { - MusicService musicService = MusicServiceFactory.getMusicService(downloadService); - musicService.setStarred(Arrays.asList(entry.getId()), null, null, starred, downloadService, null); - - // Make sure to clear parent cache - String s = Util.getRestUrl(downloadService, null) + entry.getParent(); - String parentCache = "directory-" + s.hashCode() + ".ser"; - File file = new File(downloadService.getCacheDir(), parentCache); - file.delete(); - } catch(Exception e) { - Log.w(TAG, "Failed to set star for " + entry.getTitle()); - } - return null; - } - }.execute(); - } -} diff --git a/src/github/daneren2005/dsub/view/AlbumCell.java b/src/github/daneren2005/dsub/view/AlbumCell.java new file mode 100644 index 00000000..9cee0c41 --- /dev/null +++ b/src/github/daneren2005/dsub/view/AlbumCell.java @@ -0,0 +1,88 @@ +/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 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
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2014 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.view;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.io.File;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.ImageLoader;
+
+public class AlbumCell extends UpdateView {
+ private static final String TAG = AlbumCell.class.getSimpleName();
+
+ private Context context;
+ private MusicDirectory.Entry album;
+ private File file;
+
+ private View coverArtView;
+ private TextView titleView;
+ private TextView artistView;
+
+ public AlbumCell(Context context) {
+ super(context);
+ this.context = context;
+ LayoutInflater.from(context).inflate(R.layout.album_cell_item, this, true);
+
+ coverArtView = findViewById(R.id.album_coverart);
+ titleView = (TextView) findViewById(R.id.album_title);
+ artistView = (TextView) findViewById(R.id.album_artist);
+ moreButton = (ImageView) findViewById(R.id.album_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
+ }
+
+ protected void setObjectImpl(Object obj1, Object obj2) {
+ this.album = (MusicDirectory.Entry) obj1;
+ if(album.getAlbum() == null) {
+ titleView.setText(album.getTitle());
+ } else {
+ titleView.setText(album.getAlbum());
+ }
+ String artist = album.getArtist();
+ if(artist == null) {
+ artist = "";
+ }
+ if(album.getYear() != null) {
+ artist += " - " + album.getYear();
+ }
+ artistView.setText(artist);
+ artistView.setVisibility(album.getArtist() == null ? View.GONE : View.VISIBLE);
+ ((ImageLoader)obj2).loadImage(coverArtView, album, false, true);
+ file = null;
+ }
+
+ @Override
+ protected void updateBackground() {
+ if(file == null) {
+ file = FileUtil.getAlbumDirectory(context, album);
+ }
+
+ exists = file.exists();
+ isStarred = album.isStarred();
+ }
+}
diff --git a/src/github/daneren2005/dsub/view/AlbumGridAdapter.java b/src/github/daneren2005/dsub/view/AlbumGridAdapter.java new file mode 100644 index 00000000..3c81fa9a --- /dev/null +++ b/src/github/daneren2005/dsub/view/AlbumGridAdapter.java @@ -0,0 +1,55 @@ +/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 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
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2014 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.view;
+
+import android.content.Context;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+
+import java.util.List;
+
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.ImageLoader;
+
+public class AlbumGridAdapter extends ArrayAdapter<MusicDirectory.Entry> {
+ private final static String TAG = AlbumGridAdapter.class.getSimpleName();
+ private final Context activity;
+ private final ImageLoader imageLoader;
+ private List<MusicDirectory.Entry> entries;
+
+ public AlbumGridAdapter(Context activity, ImageLoader imageLoader, List<MusicDirectory.Entry> entries) {
+ super(activity, android.R.layout.simple_list_item_1, entries);
+ this.entries = entries;
+ this.activity = activity;
+ this.imageLoader = imageLoader;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ MusicDirectory.Entry entry = getItem(position);
+
+ AlbumCell view;
+ if(convertView instanceof AlbumCell) {
+ view = (AlbumCell) convertView;
+ } else {
+ view = new AlbumCell(activity);
+ }
+
+ view.setObject(entry, imageLoader);
+ return view;
+ }
+}
diff --git a/src/github/daneren2005/dsub/view/AlbumListAdapter.java b/src/github/daneren2005/dsub/view/AlbumListAdapter.java index f5f3e5fc..308eb7d7 100644 --- a/src/github/daneren2005/dsub/view/AlbumListAdapter.java +++ b/src/github/daneren2005/dsub/view/AlbumListAdapter.java @@ -63,11 +63,7 @@ public class AlbumListAdapter extends EndlessAdapter { result = service.getAlbumList(type, size, offset, context, null);
}
entries = result.getChildren();
- if(entries.size() > 0) {
- return true;
- } else {
- return false;
- }
+ return entries.size() > 0;
}
@Override
diff --git a/src/github/daneren2005/dsub/view/AlbumView.java b/src/github/daneren2005/dsub/view/AlbumView.java deleted file mode 100644 index be13aa5c..00000000 --- a/src/github/daneren2005/dsub/view/AlbumView.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - This file is part of Subsonic. - - Subsonic is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - 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 - along with Subsonic. If not, see <http://www.gnu.org/licenses/>. - - Copyright 2009 (C) Sindre Mehus - */ -package github.daneren2005.dsub.view; - -import android.content.Context; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.TextView; -import github.daneren2005.dsub.R; -import github.daneren2005.dsub.domain.MusicDirectory; -import github.daneren2005.dsub.util.FileUtil; -import github.daneren2005.dsub.util.ImageLoader; -import github.daneren2005.dsub.util.Util; -import java.io.File; -import java.util.List; - -/** - * Used to display albums in a {@code ListView}. - * - * @author Sindre Mehus - */ -public class AlbumView extends UpdateView { - private static final String TAG = AlbumView.class.getSimpleName(); - - private Context context; - private MusicDirectory.Entry album; - private File file; - - private TextView titleView; - private TextView artistView; - private View coverArtView; - - public AlbumView(Context context) { - super(context); - this.context = context; - LayoutInflater.from(context).inflate(R.layout.album_list_item, this, true); - - titleView = (TextView) findViewById(R.id.album_title); - artistView = (TextView) findViewById(R.id.album_artist); - coverArtView = findViewById(R.id.album_coverart); - starButton = (ImageButton) findViewById(R.id.album_star); - starButton.setFocusable(false); - - moreButton = (ImageView) findViewById(R.id.album_more); - moreButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - v.showContextMenu(); - } - }); - } - - protected void setObjectImpl(Object obj1, Object obj2) { - this.album = (MusicDirectory.Entry) obj1; - if(album.getAlbum() == null) { - titleView.setText(album.getTitle()); - } else { - titleView.setText(album.getAlbum()); - } - String artist = album.getArtist(); - if(artist == null) { - artist = ""; - } - if(album.getYear() != null) { - artist += " - " + album.getYear(); - } - artistView.setText(artist); - artistView.setVisibility(album.getArtist() == null ? View.GONE : View.VISIBLE); - ((ImageLoader)obj2).loadImage(coverArtView, album, false, true); - file = null; - } - - @Override - protected void updateBackground() { - if(file == null) { - file = FileUtil.getAlbumDirectory(context, album); - } - - exists = file.exists(); - isStarred = album.isStarred(); - } -} diff --git a/src/github/daneren2005/dsub/view/ArtistEntryView.java b/src/github/daneren2005/dsub/view/ArtistEntryView.java index 958b4b87..86fe7b1f 100644 --- a/src/github/daneren2005/dsub/view/ArtistEntryView.java +++ b/src/github/daneren2005/dsub/view/ArtistEntryView.java @@ -37,7 +37,7 @@ import java.io.File; * @author Sindre Mehus
*/
public class ArtistEntryView extends UpdateView {
- private static final String TAG = AlbumView.class.getSimpleName();
+ private static final String TAG = ArtistEntryView.class.getSimpleName();
private Context context;
private MusicDirectory.Entry artist;
diff --git a/src/github/daneren2005/dsub/view/ArtistView.java b/src/github/daneren2005/dsub/view/ArtistView.java index 6f54e800..23ce4f9d 100644 --- a/src/github/daneren2005/dsub/view/ArtistView.java +++ b/src/github/daneren2005/dsub/view/ArtistView.java @@ -27,7 +27,7 @@ import android.widget.TextView; import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.util.FileUtil;
-import github.daneren2005.dsub.util.Util;
+
import java.io.File;
/**
diff --git a/src/github/daneren2005/dsub/view/AutoRepeatButton.java b/src/github/daneren2005/dsub/view/AutoRepeatButton.java index 798c1649..cb2d2a51 100644 --- a/src/github/daneren2005/dsub/view/AutoRepeatButton.java +++ b/src/github/daneren2005/dsub/view/AutoRepeatButton.java @@ -8,8 +8,8 @@ import android.widget.ImageButton; public class AutoRepeatButton extends ImageButton {
- private long initialRepeatDelay = 1000;
- private long repeatIntervalInMilliseconds = 300;
+ private static final long initialRepeatDelay = 1000;
+ private static final long repeatIntervalInMilliseconds = 300;
private boolean doClick = true;
private Runnable repeatEvent = null;
diff --git a/src/github/daneren2005/dsub/view/BookmarkAdapter.java b/src/github/daneren2005/dsub/view/BookmarkAdapter.java index bcddc574..b0541397 100644 --- a/src/github/daneren2005/dsub/view/BookmarkAdapter.java +++ b/src/github/daneren2005/dsub/view/BookmarkAdapter.java @@ -20,7 +20,7 @@ package github.daneren2005.dsub.view; import android.content.Context; -import android.util.Log; + import java.util.List; import android.view.View; import android.view.ViewGroup; diff --git a/src/github/daneren2005/dsub/view/EntryAdapter.java b/src/github/daneren2005/dsub/view/EntryAdapter.java index 22ca384c..7da6e5a1 100644 --- a/src/github/daneren2005/dsub/view/EntryAdapter.java +++ b/src/github/daneren2005/dsub/view/EntryAdapter.java @@ -19,7 +19,7 @@ package github.daneren2005.dsub.view; import android.content.Context; -import android.util.Log; + import java.util.List; import android.view.View; @@ -54,26 +54,13 @@ public class EntryAdapter extends ArrayAdapter<MusicDirectory.Entry> { public View getView(int position, View convertView, ViewGroup parent) { MusicDirectory.Entry entry = getItem(position); - if (entry.isDirectory()) { - if(entry.getArtist() != null || entry.getParent() != null) { - AlbumView view; - view = new AlbumView(activity); - view.setObject(entry, imageLoader); - return view; - } else { - ArtistEntryView view = new ArtistEntryView(activity); - view.setObject(entry); - return view; - } - } else { - SongView view; - if (convertView != null && convertView instanceof SongView) { - view = (SongView) convertView; - } else { - view = new SongView(activity); - } - view.setObject(entry, checkable); - return view; - } + SongView view; + if (convertView != null && convertView instanceof SongView) { + view = (SongView) convertView; + } else { + view = new SongView(activity); + } + view.setObject(entry, checkable); + return view; } } diff --git a/src/github/daneren2005/dsub/view/ErrorDialog.java b/src/github/daneren2005/dsub/view/ErrorDialog.java index e72b1934..0b9d05a0 100644 --- a/src/github/daneren2005/dsub/view/ErrorDialog.java +++ b/src/github/daneren2005/dsub/view/ErrorDialog.java @@ -20,7 +20,6 @@ package github.daneren2005.dsub.view; import android.app.Activity; import android.app.AlertDialog; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; diff --git a/src/github/daneren2005/dsub/view/SquareImageView.java b/src/github/daneren2005/dsub/view/SquareImageView.java new file mode 100644 index 00000000..77ca50db --- /dev/null +++ b/src/github/daneren2005/dsub/view/SquareImageView.java @@ -0,0 +1,32 @@ +/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 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
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2014 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+public class SquareImageView extends ImageView {
+ public SquareImageView(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void onMeasure(final int widthSpec, final int heightSpec) {
+ super.onMeasure(widthSpec, heightSpec);
+ setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
+ }
+}
diff --git a/src/github/daneren2005/dsub/view/UnscrollableGridView.java b/src/github/daneren2005/dsub/view/UnscrollableGridView.java new file mode 100644 index 00000000..a36a7b79 --- /dev/null +++ b/src/github/daneren2005/dsub/view/UnscrollableGridView.java @@ -0,0 +1,81 @@ +package github.daneren2005.dsub.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.AbsListView;
+import android.widget.GridView;
+import android.widget.ListAdapter;
+
+/**
+ * Created by Scott on 4/26/2014.
+ */
+public class UnscrollableGridView extends GridView {
+ public UnscrollableGridView(Context context) {
+ super(context);
+ }
+
+ public UnscrollableGridView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public UnscrollableGridView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ public int getColumnWidth() {
+ // This method will be called from onMeasure() too.
+ // It's better to use getMeasuredWidth(), as it is safe in this case.
+ final int totalHorizontalSpacing = getNumColumns() > 0 ? (getNumColumns() - 1) * getHorizontalSpacing() : 0;
+ return (getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - totalHorizontalSpacing) / getNumColumns();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // Sets the padding for this view.
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ final int measuredWidth = getMeasuredWidth();
+ final int childWidth = getColumnWidth();
+ int childHeight = 0;
+
+ // If there's an adapter, use it to calculate the height of this view.
+ final ListAdapter adapter = getAdapter();
+ final int count;
+
+ // There shouldn't be any inherent size (due to padding) if there are no child views.
+ if (adapter == null || (count = adapter.getCount()) == 0) {
+ setMeasuredDimension(0, 0);
+ return;
+ }
+
+ // Get the first child from the adapter.
+ final View child = adapter.getView(0, null, this);
+ if (child != null) {
+ // Set a default LayoutParams on the child, if it doesn't have one on its own.
+ AbsListView.LayoutParams params = (AbsListView.LayoutParams) child.getLayoutParams();
+ if (params == null) {
+ params = new AbsListView.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT,
+ AbsListView.LayoutParams.WRAP_CONTENT);
+ child.setLayoutParams(params);
+ }
+
+ // Measure the exact width of the child, and the height based on the width.
+ // Note: the child takes care of calculating its height.
+ int childWidthSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
+ int childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ child.measure(childWidthSpec, childHeightSpec);
+ childHeight = child.getMeasuredHeight();
+ }
+
+ // Number of rows required to 'mTotal' items.
+ final int rows = (int) Math.ceil((double) getCount() / getNumColumns());
+ final int childrenHeight = childHeight * rows;
+ final int totalVerticalSpacing = rows > 0 ? (rows - 1) * getVerticalSpacing() : 0;
+
+ // Total height of this view.
+ final int measuredHeight = childrenHeight + getPaddingTop() + getPaddingBottom() + totalVerticalSpacing;
+ setMeasuredDimension(measuredWidth, measuredHeight);
+ }
+}
diff --git a/src/github/daneren2005/dsub/view/UpdateView.java b/src/github/daneren2005/dsub/view/UpdateView.java index f59cee3f..66f34471 100644 --- a/src/github/daneren2005/dsub/view/UpdateView.java +++ b/src/github/daneren2005/dsub/view/UpdateView.java @@ -131,7 +131,7 @@ public class UpdateView extends LinearLayout { return;
}
- List<UpdateView> views = new ArrayList<UpdateView>();;
+ List<UpdateView> views = new ArrayList<UpdateView>();
for (UpdateView view : INSTANCES.keySet()) {
if (view.isShown()) {
views.add(view);
|