Even more UI redesign

This commit is contained in:
Joshua Bahnsen 2013-04-27 02:52:25 -07:00
parent 625b015639
commit c2761389ab
31 changed files with 1638 additions and 1108 deletions

View File

@ -35,7 +35,6 @@
a:launchMode="standard" >
<intent-filter>
<action a:name="android.intent.action.MAIN" />
<category a:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
@ -45,7 +44,7 @@
a:launchMode="standard" />
<activity
a:name=".activity.SelectAlbumActivity"
a:configChanges="orientation|keyboardHidden" />
a:configChanges="orientation|keyboardHidden" />
<activity
a:name=".activity.SearchActivity"
a:configChanges="orientation|keyboardHidden"

File diff suppressed because it is too large Load Diff

View File

@ -8,19 +8,19 @@ package net.simonvt.menudrawer;
public final class R {
public static final class id {
public static final int md__menu = 0x7f070003;
public static final int mdContent = 0x7f070000;
public static final int mdActiveViewPosition = 0x7f070005;
public static final int mdMenu = 0x7f070001;
public static final int md__drawer = 0x7f070004;
public static final int md__content = 0x7f070002;
public static final int md__menu = 0x7f06000f;
public static final int mdContent = 0x7f06000c;
public static final int mdActiveViewPosition = 0x7f060011;
public static final int mdMenu = 0x7f06000d;
public static final int md__drawer = 0x7f060010;
public static final int md__content = 0x7f06000e;
}
public static final class style {
public static final int Widget_MenuDrawer = 0x7f080001;
public static final int Widget = 0x7f080000;
public static final int Widget_MenuDrawer = 0x7f0a0001;
public static final int Widget = 0x7f0a0000;
}
public static final class color {
public static final int md__defaultBackground = 0x7f060000;
public static final int md__defaultBackground = 0x7f090000;
}
public static final class styleable {
public static final int MenuDrawer_mdMenuBackground = 1;
@ -33,21 +33,21 @@ public final class R {
public static final int MenuDrawer_mdTouchBezelSize = 8;
public static final int MenuDrawer_mdMaxAnimationDuration = 10;
public static final int MenuDrawer_mdDropShadowSize = 5;
public static final int[] MenuDrawer = { 0x7f010001, 0x7f010002, 0x7f010003, 0x7f010004, 0x7f010005, 0x7f010006, 0x7f010007, 0x7f010008, 0x7f010009, 0x7f01000a, 0x7f01000b };
public static final int[] MenuDrawer = { 0x7f010014, 0x7f010015, 0x7f010016, 0x7f010017, 0x7f010018, 0x7f010019, 0x7f01001a, 0x7f01001b, 0x7f01001c, 0x7f01001d, 0x7f01001e };
public static final int MenuDrawer_mdContentBackground = 0;
}
public static final class attr {
public static final int mdMenuBackground = 0x7f010002;
public static final int mdMenuSize = 0x7f010003;
public static final int mdDropShadowSize = 0x7f010006;
public static final int mdDropShadowEnabled = 0x7f010005;
public static final int mdAllowIndicatorAnimation = 0x7f01000a;
public static final int mdDropShadowColor = 0x7f010007;
public static final int mdMaxAnimationDuration = 0x7f01000b;
public static final int mdDropShadow = 0x7f010008;
public static final int mdTouchBezelSize = 0x7f010009;
public static final int mdActiveIndicator = 0x7f010004;
public static final int mdContentBackground = 0x7f010001;
public static final int menuDrawerStyle = 0x7f010000;
public static final int mdMenuBackground = 0x7f010015;
public static final int mdMenuSize = 0x7f010016;
public static final int mdDropShadowSize = 0x7f010019;
public static final int mdDropShadowEnabled = 0x7f010018;
public static final int mdAllowIndicatorAnimation = 0x7f01001d;
public static final int mdDropShadowColor = 0x7f01001a;
public static final int mdMaxAnimationDuration = 0x7f01001e;
public static final int mdDropShadow = 0x7f01001b;
public static final int mdTouchBezelSize = 0x7f01001c;
public static final int mdActiveIndicator = 0x7f010017;
public static final int mdContentBackground = 0x7f010014;
public static final int menuDrawerStyle = 0x7f010013;
}
}

View File

@ -9,4 +9,5 @@
# Project target.
target=android-16
android.library.reference.1=android-menudrawer-master/library
android.library.reference.1=android-menudrawer-master\\library
android.library.reference.2=Android-PullToRefresh/library

View File

@ -1,13 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/md__transparent" />
</shape>
</item>
<item android:top="2dp" android:right="2dp" android:left="2dp">
<shape android:shape="rectangle">
<solid android:color="@color/md__transparent" />
</shape>
</item>
</layer-list>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/transparent"/>
<padding android:left="1dp" android:top="1dp"
android:right="1dp" android:bottom="1dp" />
<stroke android:color="#439CC8" android:width="1dp" />
</shape>

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/menu_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/menu_navigation"
style="@style/MenuDrawer.Widget.Category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/menu.navigation" />
<TextView
android:id="@+id/menu_home"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_home"
android:text="@string/button_bar.home" />
<TextView
android:id="@+id/menu_browse"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_browse"
android:text="@string/button_bar.browse" />
<TextView
android:id="@+id/menu_search"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_search"
android:text="@string/button_bar.search" />
<TextView
android:id="@+id/menu_playlists"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_playlists"
android:text="@string/button_bar.playlists" />
<TextView
android:id="@+id/menu_now_playing"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_play_all"
android:text="@string/button_bar.now_playing" />
<TextView
android:id="@+id/menu_common"
style="@style/MenuDrawer.Widget.Category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/menu.common" />
<TextView
android:id="@+id/menu_settings"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_settings"
android:text="@string/menu.settings" />
<TextView
android:id="@+id/menu_help"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_help"
android:text="@string/menu.help" />
<TextView
android:id="@+id/menu_exit"
style="@style/MenuDrawer.Widget.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_menu_exit"
android:text="@string/menu.exit" />
</LinearLayout>
</ScrollView>

View File

@ -67,10 +67,10 @@
<ImageButton
android:id="@+id/control_previous"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:layout_marginRight="5dip"
android:layout_marginRight="2dip"
android:layout_marginTop="2dip"
android:layout_weight="0.0"
android:background="@drawable/btn_bg"
@ -78,10 +78,10 @@
<ImageButton
android:id="@+id/control_play"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:layout_marginRight="5dip"
android:layout_marginRight="2dip"
android:layout_marginTop="2dip"
android:layout_weight="0.0"
android:background="@drawable/btn_bg"
@ -89,10 +89,10 @@
<ImageButton
android:id="@+id/control_stop"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:layout_marginRight="5dip"
android:layout_marginRight="2dip"
android:layout_marginTop="2dip"
android:layout_weight="0.0"
android:background="@drawable/btn_bg"
@ -100,10 +100,10 @@
<ImageButton
android:id="@+id/control_next"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:layout_marginRight="5dip"
android:layout_marginRight="2dip"
android:layout_marginTop="2dip"
android:layout_weight="0.0"
android:background="@drawable/btn_bg"

View File

@ -4,21 +4,18 @@
android:id="@+id/now_playing"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:background="@drawable/border"
android:layout_alignParentBottom="true"
android:visibility="gone" >
android:visibility="gone"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
<ImageView
android:id="@+id/now_playing_image"
android:layout_width="64.0dip"
android:layout_height="64.0dip"
android:layout_weight="0.0"
android:gravity="center" />
android:gravity="center"
android:focusable="true" />
<LinearLayout
android:layout_width="0.0dp"
@ -35,8 +32,8 @@
android:layout_height="wrap_content"
android:layout_gravity="left"
android:ellipsize="marquee"
android:focusable="true"
android:singleLine="true" />
android:singleLine="true"
android:textStyle="bold" />
<TextView
android:id="@+id/now_playing_artist"
@ -47,29 +44,17 @@
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true" />
<TextView
android:id="@+id/now_playing_album"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:ellipsize="end"
android:scrollHorizontally="true"
android:singleLine="true" />
</LinearLayout>
<ImageButton
<ImageView
android:id="@+id/now_playing_control_play"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:layout_marginRight="5dip"
android:layout_marginTop="2dip"
android:layout_weight="0.0"
android:background="@drawable/btn_bg"
android:focusable="false"
android:src="@drawable/media_pause_normal" />
</LinearLayout>
</LinearLayout>

View File

@ -19,49 +19,14 @@
a:layout_height="wrap_content"
a:padding="10dip"/>
<ListView a:id="@+id/select_album_entries"
<com.handmark.pulltorefresh.library.PullToRefreshListView
a:id="@+id/select_album_entries"
a:textFilterEnabled="true"
a:layout_width="fill_parent"
a:layout_height="0dip"
a:layout_weight="1.0"/>
<LinearLayout a:orientation="horizontal"
a:layout_marginTop="6dp"
a:layout_marginBottom="3dp"
a:layout_width="fill_parent"
a:layout_height="wrap_content" >
<Button a:id="@+id/select_album_select"
a:text="@string/select_album.select"
a:textAppearance="?android:attr/textAppearanceSmall"
a:visibility="gone"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="fill_parent"/>
<Button a:id="@+id/select_album_play_now"
a:text="@string/common.play_now"
a:textAppearance="?android:attr/textAppearanceSmall"
a:visibility="gone"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="fill_parent"/>
<Button a:id="@+id/select_album_play_last"
a:text="@string/common.play_last"
a:textAppearance="?android:attr/textAppearanceSmall"
a:visibility="gone"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="fill_parent"/>
</LinearLayout>
<include layout="@layout/album_buttons" />
<include layout="@layout/now_playing" />

View File

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="horizontal"
a:background="@android:color/transparent"
a:paddingTop="6dp"
a:paddingBottom="0dp"
a:layout_width="fill_parent"
a:layout_height="wrap_content">
<Button a:id="@+id/select_album_pin"
a:text="@string/common.pin"
a:textAppearance="?android:attr/textAppearanceSmall"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="fill_parent"/>
<Button a:id="@+id/select_album_unpin"
a:text="@string/common.unpin"
a:textAppearance="?android:attr/textAppearanceSmall"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="fill_parent"/>
<Button a:id="@+id/select_album_delete"
a:text="@string/common.delete"
a:textAppearance="?android:attr/textAppearanceSmall"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="fill_parent"/>
<Button a:id="@+id/select_album_more"
a:text="@string/select_album.more"
a:textAppearance="?android:attr/textAppearanceSmall"
a:visibility="gone"
a:layout_marginLeft="3dp"
a:layout_marginRight="3dp"
a:layout_weight="1"
a:layout_width="0dp"
a:layout_height="fill_parent"/>
</LinearLayout>

View File

@ -7,7 +7,8 @@
<include layout="@layout/tab_progress"/>
<ListView a:id="@+id/select_artist_list"
<com.handmark.pulltorefresh.library.PullToRefreshListView
a:id="@+id/select_artist_list"
a:textFilterEnabled="true"
a:fastScrollEnabled="true"
a:layout_width="fill_parent"

View File

@ -14,7 +14,8 @@
a:layout_height="wrap_content"
a:padding="10dip"/>
<ListView a:id="@+id/select_genre_list"
<com.handmark.pulltorefresh.library.PullToRefreshListView
a:id="@+id/select_genre_list"
a:textFilterEnabled="true"
a:fastScrollEnabled="true"
a:layout_width="fill_parent"

View File

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:orientation="vertical"
a:layout_width="fill_parent"
a:layout_height="fill_parent">
a:layout_width="fill_parent"
a:layout_height="fill_parent"
a:orientation="vertical" >
<include layout="@layout/tab_progress"/>
<include layout="@layout/tab_progress" />
<TextView
a:id="@+id/select_playlist_empty"
a:text="@string/select_playlist.empty"
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:padding="10dip"
a:visibility="gone"/>
a:id="@+id/select_playlist_empty"
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:padding="10dip"
a:text="@string/select_playlist.empty"
a:visibility="gone" />
<com.handmark.pulltorefresh.library.PullToRefreshListView
a:id="@+id/select_playlist_list"
a:layout_width="fill_parent"
a:layout_height="0dip"
a:layout_weight="1.0" />
<ListView a:id="@+id/select_playlist_list"
a:layout_width="fill_parent"
a:layout_height="0dip"
a:layout_weight="1.0"/>
<include layout="@layout/now_playing" />
</LinearLayout>
</LinearLayout>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:a="http://schemas.android.com/apk/res/android" >
<item
a:id="@+id/menu_refresh"
a:icon="@drawable/ic_menu_refresh"
a:showAsAction="ifRoom|withText"
a:title="@string/select_artist.refresh"/>
</menu>

View File

@ -44,6 +44,7 @@
<string name="menu.exit">Quitter</string>
<string name="menu.settings">Paramètres</string>
<string name="menu.help">Aide</string>
<string name="menu.about">Sur</string>
<string name="menu.search">Recherche</string>
<string name="menu.navigation">Navigation</string>
<string name="menu.common">Général</string>

View File

@ -44,6 +44,7 @@
<string name="menu.exit">Kilépés</string>
<string name="menu.settings">Beállítások</string>
<string name="menu.help">Súgó</string>
<string name="menu.about">Információ</string>
<string name="menu.search">Keresés</string>
<string name="menu.navigation">Navigáció</string>
<string name="menu.common">Közös</string>

View File

@ -44,6 +44,7 @@
<string name="menu.exit">Exit</string>
<string name="menu.settings">Settings</string>
<string name="menu.help">Help</string>
<string name="menu.about">About</string>
<string name="menu.search">Search</string>
<string name="menu.navigation">Navigation</string>
<string name="menu.common">Common</string>
@ -228,6 +229,8 @@
<string name="settings.show_lockscreen_controls_summary">Show playback controls on the lock screen</string>
<string name="settings.use_stream_proxy">Use Stream Proxy</string>
<string name="settings.use_stream_proxy_summary">Stream media playback through a proxy (may help stutter)</string>
<string name="settings.show_now_playing">Show Now Playing</string>
<string name="settings.show_now_playing_summary">Show currently playing track in all activities</string>
<string name="settings.max_albums">Max Albums</string>
<string name="settings.search_1">1</string>
<string name="settings.search_3">3</string>

View File

@ -37,27 +37,26 @@
<style name="customprogress" parent="android:style/Widget.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_holo_dark</item>
</style>
<style name="MenuDrawer" />
<style name="MenuDrawer.Widget" />
<style name="Widget.MenuDrawer">
<item name="mdMenuBackground">@color/md__transparent</item>
<item name="mdContentBackground">?android:attr/windowBackground</item>
<item name="mdActiveIndicator">@drawable/menu_arrow</item>
<item name="mdMenuSize">250dp</item>
<item name="mdAllowIndicatorAnimation">true</item>
</style>
<style name="MenuDrawer" />
<style name="MenuDrawer.Widget" />
<style name="MenuDrawer.Widget.Category">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/cyan</item>
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingLeft">16dp</item>
<item name="android:singleLine">true</item>
<item name="android:ellipsize">end</item>
</style>
@ -73,25 +72,4 @@
<item name="android:gravity">center_vertical</item>
</style>
<style name="MenuDrawerStyle" parent="Widget.MenuDrawer">
<item name="mdActiveIndicator">@drawable/menu_arrow</item>
<item name="mdMenuSize">250dp</item>
</style>
<style name="MenuDrawerStyle.Right" parent="Widget.MenuDrawer">
<item name="mdActiveIndicator">@drawable/menu_arrow_right</item>
<item name="mdMenuSize">150dp</item>
</style>
<style name="MenuDrawerStyle.Top" parent="Widget.MenuDrawer">
<item name="mdActiveIndicator">@drawable/menu_arrow_top</item>
<item name="mdMenuSize">64dp</item>
<item name="mdAllowIndicatorAnimation">true</item>
</style>
<style name="MenuDrawerStyle.Bottom" parent="Widget.MenuDrawer">
<item name="mdActiveIndicator">@drawable/menu_arrow_bottom</item>
<item name="mdMenuSize">64dp</item>
</style>
</resources>

View File

@ -103,7 +103,12 @@
a:defaultValue="true"
a:key="showTrackNumber"
a:summary="@string/settings.show_track_number_summary"
a:title="@string/settings.show_track_number" />
a:title="@string/settings.show_track_number" />
<CheckBoxPreference
a:defaultValue="true"
a:key="showNowPlaying"
a:summary="@string/settings.show_now_playing_summary"
a:title="@string/settings.show_now_playing" />
</PreferenceCategory>
<PreferenceCategory a:title="@string/settings.network_title" >
<ListPreference

View File

@ -340,6 +340,9 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
visualizerAvailable = downloadService != null && downloadService.getVisualizerController() != null;
equalizerAvailable = downloadService != null && downloadService.getEqualizerController() != null;
View nowPlayingMenuItem = findViewById(R.id.menu_now_playing);
menuDrawer.setActiveView(nowPlayingMenuItem);
if (visualizerAvailable) {
visualizerView = new VisualizerView(this);
visualizerViewLayout.addView(visualizerView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));

View File

@ -41,8 +41,10 @@ public final class LyricsActivity extends SubsonicTabActivity {
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.lyrics);
View view = findViewById(R.id.lyrics_scrollview);
//if (view != null) view.setOnTouchListener(gestureListener);
View nowPlayingMenuItem = findViewById(R.id.menu_now_playing);
menuDrawer.setActiveView(nowPlayingMenuItem);
load();
}

View File

@ -151,7 +151,11 @@ public class MainActivity extends SubsonicTabActivity {
}
}
});
View homeMenuItem = findViewById(R.id.menu_home);
menuDrawer.setActiveView(homeMenuItem);
getActionBar().setTitle(R.string.common_appname);
setTitle(R.string.common_appname);
// Remember the current theme.

View File

@ -86,7 +86,11 @@ public class SearchActivity extends SubsonicTabActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
setTitle(R.string.search_title);
getActionBar().setTitle(R.string.common_appname);
getActionBar().setSubtitle(R.string.search_title);
View searchMenuItem = findViewById(R.id.menu_search);
menuDrawer.setActiveView(searchMenuItem);
DEFAULT_ARTISTS = Util.getDefaultArtists(this);
DEFAULT_ALBUMS = Util.getDefaultAlbums(this);
@ -139,13 +143,6 @@ public class SearchActivity extends SubsonicTabActivity {
onNewIntent(getIntent());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
return true;
}
@Override
protected void onNewIntent(Intent intent) {

View File

@ -22,6 +22,7 @@ import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
@ -31,7 +32,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@ -53,21 +54,26 @@ import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
public class SelectAlbumActivity extends SubsonicTabActivity {
private static final String TAG = SelectAlbumActivity.class.getSimpleName();
private ListView entryList;
private PullToRefreshListView refreshAlbumListView;
private ListView albumListView;
private View header;
private View footer;
private View albumButtons;
private View emptyView;
private Button selectButton;
private Button playNowButton;
private Button playLastButton;
private Button pinButton;
private Button unpinButton;
private Button deleteButton;
private Button moreButton;
private ImageView selectButton;
private ImageView playNowButton;
private ImageView playLastButton;
private ImageView pinButton;
private ImageView unpinButton;
private ImageView deleteButton;
private ImageView moreButton;
private boolean licenseValid;
private boolean playAllButtonVisible;
private MenuItem playAllButton;
@ -81,14 +87,23 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select_album);
albumButtons = findViewById(R.id.menu_album);
refreshAlbumListView = (PullToRefreshListView) findViewById(R.id.select_album_entries);
albumListView = refreshAlbumListView.getRefreshableView();
refreshAlbumListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
new GetDataTask().execute();
}
});
entryList = (ListView) findViewById(R.id.select_album_entries);
header = LayoutInflater.from(this).inflate(R.layout.select_album_header, albumListView, false);
header = LayoutInflater.from(this).inflate(R.layout.select_album_header, entryList, false);
footer = LayoutInflater.from(this).inflate(R.layout.select_album_footer, entryList, false);
entryList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
entryList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
albumListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
albumListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position >= 0) {
@ -107,13 +122,13 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
});
selectButton = (Button) findViewById(R.id.select_album_select);
playNowButton = (Button) findViewById(R.id.select_album_play_now);
playLastButton = (Button) findViewById(R.id.select_album_play_last);
pinButton = (Button) footer.findViewById(R.id.select_album_pin);
unpinButton = (Button) footer.findViewById(R.id.select_album_unpin);
deleteButton = (Button) footer.findViewById(R.id.select_album_delete);
moreButton = (Button) footer.findViewById(R.id.select_album_more);
selectButton = (ImageView) findViewById(R.id.select_album_select);
playNowButton = (ImageView) findViewById(R.id.select_album_play_now);
playLastButton = (ImageView) findViewById(R.id.select_album_play_last);
pinButton = (ImageView) findViewById(R.id.select_album_pin);
unpinButton = (ImageView) findViewById(R.id.select_album_unpin);
deleteButton = (ImageView) findViewById(R.id.select_album_delete);
moreButton = (ImageView) findViewById(R.id.select_album_more);
emptyView = findViewById(R.id.select_album_empty);
selectButton.setOnClickListener(new View.OnClickListener() {
@ -158,7 +173,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
});
registerForContextMenu(entryList);
registerForContextMenu(albumListView);
enableButtons();
@ -174,6 +189,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
int albumListSize = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
int albumListOffset = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0);
View browseMenuItem = findViewById(R.id.menu_browse);
menuDrawer.setActiveView(browseMenuItem);
if (playlistId != null) {
getPlaylist(playlistId, playlistName);
} else if (albumListType != null) {
@ -202,7 +220,6 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.select_album, menu);
inflater.inflate(R.menu.select_common, menu);
super.onCreateOptionsMenu(menu);
return true;
@ -210,8 +227,8 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
private void playAll() {
boolean hasSubFolders = false;
for (int i = 0; i < entryList.getCount(); i++) {
MusicDirectory.Entry entry = (MusicDirectory.Entry) entryList.getItemAtPosition(i);
for (int i = 0; i < albumListView.getCount(); i++) {
MusicDirectory.Entry entry = (MusicDirectory.Entry) albumListView.getItemAtPosition(i);
if (entry != null && entry.isDirectory()) {
hasSubFolders = true;
break;
@ -240,7 +257,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
super.onCreateContextMenu(menu, view, menuInfo);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
MusicDirectory.Entry entry = (MusicDirectory.Entry) entryList.getItemAtPosition(info.position);
MusicDirectory.Entry entry = (MusicDirectory.Entry) albumListView.getItemAtPosition(info.position);
if (entry.isDirectory()) {
MenuInflater inflater = getMenuInflater();
@ -254,9 +271,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
MusicDirectory.Entry entry = (MusicDirectory.Entry) entryList.getItemAtPosition(info.position);
MusicDirectory.Entry entry = (MusicDirectory.Entry) albumListView.getItemAtPosition(info.position);
List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>(10);
songs.add((MusicDirectory.Entry) entryList.getItemAtPosition(info.position));
songs.add((MusicDirectory.Entry) albumListView.getItemAtPosition(info.position));
switch (menuItem.getItemId()) {
case R.id.album_menu_play_now:
downloadRecursively(entry.getId(), false, false, true);
@ -296,9 +313,6 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
intent1.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
Util.startActivityWithoutTransition(this, intent1);
return true;
case R.id.menu_refresh:
refresh();
return true;
case R.id.select_album_play_all:
playAll();
return true;
@ -308,7 +322,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
private void getMusicDirectory(final String id, String name) {
setTitle(name);
getActionBar().setSubtitle(name);
new LoadTask() {
@Override
@ -320,7 +334,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
private void getSongsForGenre(final String genre, final int count, final int offset) {
setTitle(genre);
getActionBar().setSubtitle(genre);
new LoadTask() {
@Override
@ -358,7 +372,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
private void getStarred() {
setTitle(R.string.main_songs_starred);
getActionBar().setSubtitle(R.string.main_songs_starred);
new LoadTask() {
@Override
@ -369,7 +383,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
private void getRandom(final int size) {
setTitle(R.string.main_songs_random);
getActionBar().setSubtitle(R.string.main_songs_random);
new LoadTask() {
@Override
@ -380,7 +394,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
private void getPlaylist(final String playlistId, String playlistName) {
setTitle(playlistName);
getActionBar().setSubtitle(playlistName);
new LoadTask() {
@Override
@ -393,7 +407,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
private void getAlbumList(final String albumListType, final int albumListTitle, final int size, final int offset) {
showHeader = false;
setTitle(albumListTitle);
getActionBar().setSubtitle(albumListTitle);
new LoadTask() {
@Override
@ -412,7 +426,6 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
if (result.getFirst().getChildren().size() < getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0)) {
moreButton.setVisibility(View.GONE);
} else {
entryList.addFooterView(footer);
moreButton.setVisibility(View.VISIBLE);
}
@ -432,6 +445,8 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
Util.startActivityWithoutTransition(SelectAlbumActivity.this, intent);
}
});
} else {
moreButton.setVisibility(View.GONE);
}
super.done(result);
@ -441,9 +456,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
private void selectAllOrNone() {
boolean someUnselected = false;
int count = entryList.getCount();
int count = albumListView.getCount();
for (int i = 0; i < count; i++) {
if (!entryList.isItemChecked(i) && entryList.getItemAtPosition(i) instanceof MusicDirectory.Entry) {
if (!albumListView.isItemChecked(i) && albumListView.getItemAtPosition(i) instanceof MusicDirectory.Entry) {
someUnselected = true;
break;
}
@ -452,20 +467,19 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
private void selectAll(boolean selected, boolean toast) {
int count = entryList.getCount();
int count = albumListView.getCount();
int selectedCount = 0;
for (int i = 0; i < count; i++) {
MusicDirectory.Entry entry = (MusicDirectory.Entry) entryList.getItemAtPosition(i);
MusicDirectory.Entry entry = (MusicDirectory.Entry) albumListView.getItemAtPosition(i);
if (entry != null && !entry.isDirectory() && !entry.isVideo()) {
entryList.setItemChecked(i, selected);
albumListView.setItemChecked(i, selected);
selectedCount++;
}
}
// Display toast: N tracks selected / N tracks unselected
if (toast) {
int toastResId = selected ? R.string.select_album_n_selected
: R.string.select_album_n_unselected;
int toastResId = selected ? R.string.select_album_n_selected : R.string.select_album_n_unselected;
Util.toast(this, getString(toastResId, selectedCount));
}
@ -501,10 +515,10 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
private List<MusicDirectory.Entry> getSelectedSongs() {
List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>(10);
int count = entryList.getCount();
int count = albumListView.getCount();
for (int i = 0; i < count; i++) {
if (entryList.isItemChecked(i)) {
songs.add((MusicDirectory.Entry) entryList.getItemAtPosition(i));
if (albumListView.isItemChecked(i)) {
songs.add((MusicDirectory.Entry) albumListView.getItemAtPosition(i));
}
}
return songs;
@ -526,9 +540,11 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
warnIfNetworkOrStorageUnavailable();
getDownloadService().download(songs, save, autoplay, playNext);
String playlistName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME);
if (playlistName != null) {
getDownloadService().setSuggestedPlaylistName(playlistName);
}
if (autoplay) {
Util.startActivityWithoutTransition(SelectAlbumActivity.this, DownloadActivity.class);
} else if (save) {
@ -646,15 +662,38 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
}
int listSize = getIntent().getIntExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
if (songCount > 0) {
if(showHeader) {
entryList.addHeaderView(createHeader(entries, directoryName, songCount), null, false);
albumListView.addHeaderView(createHeader(entries, directoryName, songCount), null, false);
}
entryList.addFooterView(footer);
pinButton.setVisibility(View.VISIBLE);
unpinButton.setVisibility(View.VISIBLE);
deleteButton.setVisibility(View.VISIBLE);
selectButton.setVisibility(View.VISIBLE);
playNowButton.setVisibility(View.VISIBLE);
playLastButton.setVisibility(View.VISIBLE);
if (listSize == 0 || songCount < listSize) {
moreButton.setVisibility(View.GONE);
} else {
moreButton.setVisibility(View.VISIBLE);
}
} else {
pinButton.setVisibility(View.GONE);
unpinButton.setVisibility(View.GONE);
deleteButton.setVisibility(View.GONE);
selectButton.setVisibility(View.GONE);
playNowButton.setVisibility(View.GONE);
playLastButton.setVisibility(View.GONE);
if (listSize == 0 || result.getFirst().getChildren().size() < listSize) {
albumButtons.setVisibility(View.GONE);
} else {
moreButton.setVisibility(View.VISIBLE);
}
}
boolean isAlbumList = getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
@ -666,7 +705,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
playAllButton.setVisible(playAllButtonVisible);
}
entryList.setAdapter(new EntryAdapter(SelectAlbumActivity.this, getImageLoader(), entries, true));
albumListView.setAdapter(new EntryAdapter(SelectAlbumActivity.this, getImageLoader(), entries, true));
licenseValid = result.getSecond();
boolean playAll = getIntent().getBooleanExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false);
@ -681,7 +720,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
getImageLoader().loadImage(coverArtView, entries.get(artworkSelection), true, true);
TextView titleView = (TextView) header.findViewById(R.id.select_album_title);
titleView.setText(name != null ? name : getTitle());
titleView.setText(name != null ? name : getActionBar().getSubtitle());
Set<String> artists = new HashSet<String>();
Set<String> grandParents = new HashSet<String>();
@ -756,4 +795,18 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
return header;
}
}
private class GetDataTask extends AsyncTask<Void, Void, String[]> {
@Override
protected void onPostExecute(String[] result) {
refreshAlbumListView.onRefreshComplete();
super.onPostExecute(result);
}
@Override
protected String[] doInBackground(Void... params) {
refresh();
return null;
}
}
}

View File

@ -20,6 +20,7 @@
package com.thejoshwa.ultrasonic.androidapp.activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.LayoutInflater;
@ -30,6 +31,10 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.thejoshwa.ultrasonic.androidapp.R;
import com.thejoshwa.ultrasonic.androidapp.domain.Artist;
import com.thejoshwa.ultrasonic.androidapp.domain.Indexes;
@ -49,7 +54,8 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
private static final int MENU_GROUP_MUSIC_FOLDER = 10;
private ListView artistList;
private PullToRefreshListView refreshArtistListView;
private ListView artistListView;
private View folderButton;
private TextView folderName;
private List<MusicFolder> musicFolders;
@ -62,25 +68,36 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
super.onCreate(savedInstanceState);
setContentView(R.layout.select_artist);
artistList = (ListView) findViewById(R.id.select_artist_list);
artistList.setOnItemClickListener(this);
//artistList.setOnTouchListener(gestureListener);
refreshArtistListView = (PullToRefreshListView) findViewById(R.id.select_artist_list);
artistListView = refreshArtistListView.getRefreshableView();
refreshArtistListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
new GetDataTask().execute();
}
});
artistListView.setOnItemClickListener(this);
folderButton = LayoutInflater.from(this).inflate(R.layout.select_artist_header, artistList, false);
folderButton = LayoutInflater.from(this).inflate(R.layout.select_artist_header, artistListView, false);
folderName = (TextView) folderButton.findViewById(R.id.select_artist_folder_2);
if (!Util.isOffline(this)) {
artistList.addHeaderView(folderButton);
artistListView.addHeaderView(folderButton);
}
registerForContextMenu(artistList);
registerForContextMenu(artistListView);
String title = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TITLE);
if (title == null) {
setTitle(Util.isOffline(this) ? R.string.music_library_label_offline : R.string.music_library_label);
getActionBar().setSubtitle(Util.isOffline(this) ? R.string.music_library_label_offline : R.string.music_library_label);
} else {
setTitle(title);
getActionBar().setSubtitle(title);
}
View browseMenuItem = findViewById(R.id.menu_browse);
menuDrawer.setActiveView(browseMenuItem);
musicFolders = null;
load();
@ -88,11 +105,7 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
inflater.inflate(R.menu.select_common, menu);
super.onCreateOptionsMenu(menu);
return true;
}
@ -128,7 +141,7 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
List<Artist> artists = new ArrayList<Artist>(result.getShortcuts().size() + result.getArtists().size());
artists.addAll(result.getShortcuts());
artists.addAll(result.getArtists());
artistList.setAdapter(new ArtistAdapter(SelectArtistActivity.this, artists));
artistListView.setAdapter(new ArtistAdapter(SelectArtistActivity.this, artists));
}
// Display selected music folder
@ -169,7 +182,7 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
if (artistList.getItemAtPosition(info.position) instanceof Artist) {
if (artistListView.getItemAtPosition(info.position) instanceof Artist) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.select_artist_context, menu);
} else if (info.position == 0) {
@ -196,7 +209,7 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
public boolean onContextItemSelected(MenuItem menuItem) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
Artist artist = (Artist) artistList.getItemAtPosition(info.position);
Artist artist = (Artist) artistListView.getItemAtPosition(info.position);
if (artist != null) {
switch (menuItem.getItemId()) {
@ -231,9 +244,6 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
case android.R.id.home:
menuDrawer.toggleMenu();
return true;
case R.id.menu_refresh:
refresh();
return true;
case R.id.main_shuffle:
Intent intent = new Intent(this, DownloadActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
@ -243,4 +253,18 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
return false;
}
private class GetDataTask extends AsyncTask<Void, Void, String[]> {
@Override
protected void onPostExecute(String[] result) {
refreshArtistListView.onRefreshComplete();
super.onPostExecute(result);
}
@Override
protected String[] doInBackground(Void... params) {
refresh();
return null;
}
}
}

View File

@ -20,14 +20,18 @@
package com.thejoshwa.ultrasonic.androidapp.activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.thejoshwa.ultrasonic.androidapp.R;
import com.thejoshwa.ultrasonic.androidapp.domain.Genre;
import com.thejoshwa.ultrasonic.androidapp.service.MusicService;
@ -45,7 +49,8 @@ public class SelectGenreActivity extends SubsonicTabActivity implements AdapterV
private static final String TAG = SelectGenreActivity.class.getSimpleName();
private ListView genreList;
private PullToRefreshListView refreshGenreListView;
private ListView genreListView;
private View emptyView;
/**
@ -56,24 +61,32 @@ public class SelectGenreActivity extends SubsonicTabActivity implements AdapterV
super.onCreate(savedInstanceState);
setContentView(R.layout.select_genre);
genreList = (ListView) findViewById(R.id.select_genre_list);
genreList.setOnItemClickListener(this);
//genreList.setOnTouchListener(gestureListener);
refreshGenreListView = (PullToRefreshListView) findViewById(R.id.select_genre_list);
genreListView = refreshGenreListView.getRefreshableView();
refreshGenreListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
new GetDataTask().execute();
}
});
genreListView.setOnItemClickListener(this);
emptyView = findViewById(R.id.select_genre_empty);
registerForContextMenu(genreList);
registerForContextMenu(genreListView);
View browseMenuItem = findViewById(R.id.menu_browse);
menuDrawer.setActiveView(browseMenuItem);
setTitle(R.string.main_genres_title);
getActionBar().setSubtitle(R.string.main_genres_title);
load();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
inflater.inflate(R.menu.select_common, menu);
super.onCreateOptionsMenu(menu);
return true;
@ -108,7 +121,7 @@ public class SelectGenreActivity extends SubsonicTabActivity implements AdapterV
emptyView.setVisibility(result == null || result.isEmpty() ? View.VISIBLE : View.GONE);
if (result != null) {
genreList.setAdapter(new GenreAdapter(SelectGenreActivity.this, result));
genreListView.setAdapter(new GenreAdapter(SelectGenreActivity.this, result));
}
}
@ -132,9 +145,6 @@ public class SelectGenreActivity extends SubsonicTabActivity implements AdapterV
case android.R.id.home:
menuDrawer.toggleMenu();
return true;
case R.id.menu_refresh:
refresh();
return true;
case R.id.main_shuffle:
Intent intent = new Intent(this, DownloadActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
@ -144,4 +154,18 @@ public class SelectGenreActivity extends SubsonicTabActivity implements AdapterV
return false;
}
private class GetDataTask extends AsyncTask<Void, Void, String[]> {
@Override
protected void onPostExecute(String[] result) {
refreshGenreListView.onRefreshComplete();
super.onPostExecute(result);
}
@Override
protected String[] doInBackground(Void... params) {
refresh();
return null;
}
}
}

View File

@ -20,16 +20,19 @@
package com.thejoshwa.ultrasonic.androidapp.activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.thejoshwa.ultrasonic.androidapp.R;
import com.thejoshwa.ultrasonic.androidapp.domain.Playlist;
import com.thejoshwa.ultrasonic.androidapp.service.MusicServiceFactory;
@ -45,7 +48,8 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
private static final int MENU_ITEM_PLAY_ALL = 1;
private ListView list;
private PullToRefreshListView refreshPlaylistsListView;
private ListView playlistsListView;
private View emptyTextView;
@Override
@ -53,24 +57,32 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
super.onCreate(savedInstanceState);
setContentView(R.layout.select_playlist);
list = (ListView) findViewById(R.id.select_playlist_list);
refreshPlaylistsListView = (PullToRefreshListView) findViewById(R.id.select_playlist_list);
playlistsListView = refreshPlaylistsListView.getRefreshableView();
refreshPlaylistsListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
new GetDataTask().execute();
}
});
emptyTextView = findViewById(R.id.select_playlist_empty);
list.setOnItemClickListener(this);
//list.setOnTouchListener(gestureListener);
registerForContextMenu(list);
playlistsListView.setOnItemClickListener(this);
registerForContextMenu(playlistsListView);
// Title: Playlists
setTitle(R.string.playlist_label);
View playlistsMenuItem = findViewById(R.id.menu_playlists);
menuDrawer.setActiveView(playlistsMenuItem);
getActionBar().setTitle(R.string.common_appname);
getActionBar().setSubtitle(R.string.playlist_label);
load();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.select_common, menu);
super.onCreateOptionsMenu(menu);
return true;
}
@ -92,7 +104,7 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
@Override
protected void done(List<Playlist> result) {
list.setAdapter(new PlaylistAdapter(result));
playlistsListView.setAdapter(new PlaylistAdapter(result));
emptyTextView.setVisibility(result.isEmpty() ? View.VISIBLE : View.GONE);
}
};
@ -108,7 +120,7 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
Playlist playlist = (Playlist) list.getItemAtPosition(info.position);
Playlist playlist = (Playlist) playlistsListView.getItemAtPosition(info.position);
switch (menuItem.getItemId()) {
case MENU_ITEM_PLAY_ALL:
@ -130,9 +142,6 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
case android.R.id.home:
menuDrawer.toggleMenu();
return true;
case R.id.menu_refresh:
refresh();
return true;
}
return false;
@ -154,4 +163,18 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
super(SelectPlaylistActivity.this, R.layout.playlist_list_item, playlists);
}
}
private class GetDataTask extends AsyncTask<Void, Void, String[]> {
@Override
protected void onPostExecute(String[] result) {
refreshPlaylistsListView.onRefreshComplete();
super.onPostExecute(result);
}
@Override
protected String[] doInBackground(Void... params) {
refresh();
return null;
}
}
}

View File

@ -28,6 +28,8 @@ import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.provider.SearchRecentSuggestions;
import android.util.Log;
import android.view.View;
import com.thejoshwa.ultrasonic.androidapp.R;
import com.thejoshwa.ultrasonic.androidapp.provider.SearchSuggestionProvider;
import com.thejoshwa.ultrasonic.androidapp.service.DownloadService;

View File

@ -34,11 +34,12 @@ import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.thejoshwa.ultrasonic.androidapp.R;
@ -57,6 +58,7 @@ import com.thejoshwa.ultrasonic.androidapp.util.ModalBackgroundTask;
import com.thejoshwa.ultrasonic.androidapp.util.Util;
import net.simonvt.menudrawer.MenuDrawer;
import net.simonvt.menudrawer.Position;
/**
* @author Sindre Mehus
@ -70,14 +72,16 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
private static final String STATE_MENUDRAWER = "com.thejoshwa.ultrasonic.androidapp.menuDrawer";
private static final String STATE_ACTIVE_VIEW_ID = "com.thejoshwa.ultrasonic.androidapp.activeViewId";
private static boolean hasPeeked = false;
private static final String STATE_ACTIVE_POSITION = "com.thejoshwa.ultrasonic.androidapp.activePosition";
protected MenuDrawer menuDrawer;
protected MenuDrawer menuDrawer;
private int activePosition = 1;
private int menuActiveViewId;
private View nowPlaying = null;
View searchMenuItem = null;
View playlistsMenuItem = null;
View menuMain = null;
public static boolean nowPlayingHidden = false;
@Override
protected void onCreate(Bundle bundle) {
@ -89,15 +93,12 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
setVolumeControlStream(AudioManager.STREAM_MUSIC);
if (bundle != null) {
activePosition = bundle.getInt(STATE_ACTIVE_POSITION);
menuActiveViewId = bundle.getInt(STATE_ACTIVE_VIEW_ID);
}
menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_WINDOW);
menuDrawer.setMenuView(R.layout.menu);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
menuDrawer = MenuDrawer.attach(this, MenuDrawer.MENU_DRAG_WINDOW, Position.LEFT);
menuDrawer.setMenuView(R.layout.menu_main);
searchMenuItem = findViewById(R.id.menu_search);
playlistsMenuItem = findViewById(R.id.menu_playlists);
@ -108,28 +109,31 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
playlistsMenuItem.setOnClickListener(this);
findViewById(R.id.menu_now_playing).setOnClickListener(this);
findViewById(R.id.menu_settings).setOnClickListener(this);
findViewById(R.id.menu_help).setOnClickListener(this);
findViewById(R.id.menu_about).setOnClickListener(this);
findViewById(R.id.menu_exit).setOnClickListener(this);
TextView activeView = (TextView) findViewById(menuActiveViewId);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
TextView activeView = (TextView)findViewById(menuActiveViewId);
if (activeView != null) {
menuDrawer.setActiveView(activeView);
}
if (!hasPeeked) {
menuDrawer.peekDrawer();
hasPeeked = true;
}
instance = this;
}
}
@Override
protected void onPostCreate(Bundle bundle) {
super.onPostCreate(bundle);
showNowPlaying();
if (!nowPlayingHidden) {
showNowPlaying();
} else {
hideNowPlaying();
}
int visibility = Util.isOffline(this) ? View.GONE : View.VISIBLE;
searchMenuItem.setVisibility(visibility);
@ -140,10 +144,16 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
protected void onResume() {
super.onResume();
instance = this;
showNowPlaying();
if (!nowPlayingHidden) {
showNowPlaying();
} else {
hideNowPlaying();
}
Util.registerMediaButtonEventReceiver(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@ -187,6 +197,13 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
private void showNowPlaying()
{
nowPlaying = findViewById(R.id.now_playing);
if (!Util.getShowNowPlayingPreference(this)) {
if (nowPlaying != null) {
nowPlaying.setVisibility(View.GONE);
}
return;
}
if (nowPlaying != null) {
final DownloadService downloadService = DownloadServiceImpl.getInstance();
@ -196,30 +213,33 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
if (playerState.equals(PlayerState.PAUSED) || playerState.equals(PlayerState.STARTED)) {
DownloadFile file = downloadService.getCurrentPlaying();
if (file != null) {
Entry song = file.getSong();
final Entry song = file.getSong();
showNowPlaying(this, (DownloadServiceImpl)downloadService, song, playerState);
}
} else {
hideNowPlaying();
}
ImageView nowPlayingControlPlay = (ImageView) nowPlaying.findViewById(R.id.now_playing_control_play);
SwipeDetector swipeDetector = SwipeDetector.Create(SubsonicTabActivity.this, downloadService);
nowPlaying.setOnTouchListener(swipeDetector);
nowPlaying.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
nowPlayingControlPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
downloadService.togglePlayPause();
}
});
}
ImageButton nowPlayingControlPlay = (ImageButton) nowPlaying.findViewById(R.id.now_playing_control_play);
nowPlaying.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Util.startActivityWithoutTransition(SubsonicTabActivity.this, DownloadActivity.class);
}
});
nowPlayingControlPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
downloadService.togglePlayPause();
}
});
}
}
@ -236,21 +256,27 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
}
}
public void showNowPlaying(final Context context, final DownloadServiceImpl downloadService, MusicDirectory.Entry song, PlayerState playerState) {
public void showNowPlaying(final Context context, final DownloadServiceImpl downloadService, final MusicDirectory.Entry song, PlayerState playerState) {
nowPlaying = findViewById(R.id.now_playing);
if (!Util.getShowNowPlayingPreference(this)) {
if (nowPlaying != null) {
nowPlaying.setVisibility(View.GONE);
}
return;
}
if (nowPlaying != null) {
nowPlaying.setVisibility(View.VISIBLE);
nowPlayingHidden = false;
String title = song.getTitle();
String artist = song.getArtist();
String album = song.getAlbum();
try {
ImageView nowPlayingImage = (ImageView) nowPlaying.findViewById(R.id.now_playing_image);
TextView nowPlayingTrack = (TextView) nowPlaying.findViewById(R.id.now_playing_trackname);
TextView nowPlayingArtist = (TextView) nowPlaying.findViewById(R.id.now_playing_artist);
TextView nowPlayingAlbum = (TextView) nowPlaying.findViewById(R.id.now_playing_album);
int size = context.getResources().getDrawable(R.drawable.unknown_album).getIntrinsicHeight();
@ -262,22 +288,31 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
} else {
nowPlayingImage.setImageBitmap(bitmap);
}
nowPlayingImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(SubsonicTabActivity.this, SelectAlbumActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_ID, song.getParent());
intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, song.getAlbum());
Util.startActivityWithoutTransition(SubsonicTabActivity.this, intent);
}
});
nowPlayingTrack.setText(title);
nowPlayingArtist.setText(artist);
nowPlayingAlbum.setText(album);
} catch (Exception x) {
Log.w(TAG, "Failed to get notification cover art", x);
}
ImageButton playButton = (ImageButton) nowPlaying.findViewById(R.id.now_playing_control_play);
ImageView playButton = (ImageView) nowPlaying.findViewById(R.id.now_playing_control_play);
if (playerState == PlayerState.PAUSED) {
playButton.setImageResource(R.drawable.ic_appwidget_music_play);
} else if (playerState == PlayerState.STARTED) {
playButton.setImageResource(R.drawable.ic_appwidget_music_pause);
}
}
}
}
@ -436,7 +471,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
@Override
public void onClick(View v) {
menuDrawer.setActiveView(v);
//menuDrawer.setActiveView(v);
menuActiveViewId = v.getId();
Intent intent;
@ -468,7 +503,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
case R.id.menu_settings:
Util.startActivityWithoutTransition(SubsonicTabActivity.this, SettingsActivity.class);
break;
case R.id.menu_help:
case R.id.menu_about:
Util.startActivityWithoutTransition(SubsonicTabActivity.this, HelpActivity.class);
break;
case R.id.menu_exit:
@ -493,6 +528,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
super.onSaveInstanceState(outState);
outState.putParcelable(STATE_MENUDRAWER, menuDrawer.saveState());
outState.putInt(STATE_ACTIVE_VIEW_ID, menuActiveViewId);
outState.putInt(STATE_ACTIVE_POSITION, activePosition);
}
@Override
@ -506,5 +542,75 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
super.onBackPressed();
}
static class SwipeDetector implements OnTouchListener {
public static enum Action {
LR, // Left to Right
RL, // Right to Left
TB, // Top to bottom
BT, // Bottom to Top
None, // when no action was detected
Click
}
public static SwipeDetector Create(SubsonicTabActivity activity, final DownloadService downloadService) {
SwipeDetector swipeDetector = new SwipeDetector();
swipeDetector.downloadService = downloadService;
swipeDetector.activity = activity;
return swipeDetector;
}
private static final int MIN_DISTANCE = 100;
private float downX, downY, upX, upY;
private Action mSwipeDetected = Action.None;
private DownloadService downloadService;
private SubsonicTabActivity activity;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
downX = event.getX();
downY = event.getY();
mSwipeDetected = Action.None;
return false; // allow other events like Click to be processed
} case MotionEvent.ACTION_UP: {
upX = event.getX();
upY = event.getY();
float deltaX = downX - upX;
float deltaY = downY - upY;
if (Math.abs(deltaX) > MIN_DISTANCE) {
// left or right
if (deltaX < 0) {
downloadService.previous();
return false;
}
if (deltaX > 0) {
downloadService.next();
return false;
}
} else if (Math.abs(deltaY) > MIN_DISTANCE) {
if (deltaY < 0) {
activity.nowPlayingHidden = true;
activity.hideNowPlaying();
return false;
}
if (deltaY > 0) {
mSwipeDetected = Action.BT;
return false;
}
}
Util.startActivityWithoutTransition(activity, DownloadActivity.class);
return false;
}
}
return false;
}
}
}

View File

@ -94,6 +94,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_DEFAULT_SONGS = "defaultSongs";
public static final String PREFERENCES_KEY_DEFAULT_ARTISTS = "defaultArtists";
public static final String PREFERENCES_KEY_USE_STREAM_PROXY = "useStreamProxy";
public static final String PREFERENCES_KEY_SHOW_NOW_PLAYING = "showNowPlaying";
// Name of the preferences file.
public static final String PREFERENCES_FILE_NAME = "com.thejoshwa.ultrasonic.androidapp_preferences";

View File

@ -1014,4 +1014,9 @@ public class Util extends DownloadActivity {
SharedPreferences prefs = getPreferences(context);
return prefs.getBoolean(Constants.PREFERENCES_KEY_MEDIA_BUTTONS, true);
}
public static boolean getShowNowPlayingPreference(Context context) {
SharedPreferences prefs = getPreferences(context);
return prefs.getBoolean(Constants.PREFERENCES_KEY_SHOW_NOW_PLAYING, true);
}
}