summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlinus_lee <llee@cyngn.com>2014-09-03 22:46:09 -0700
committerlinus_lee <llee@cyngn.com>2014-11-20 12:01:45 -0800
commit129470989c36396fc5b9b76b6929a619c01c7765 (patch)
treef0c4e3b0b8c8cb87ba31bc41f3bb8aa2458e2d86
parentb423f726267635f6dfea55d9d612afa99ec8dc51 (diff)
downloadandroid_packages_apps_Eleven-129470989c36396fc5b9b76b6929a619c01c7765.tar.gz
android_packages_apps_Eleven-129470989c36396fc5b9b76b6929a619c01c7765.tar.bz2
android_packages_apps_Eleven-129470989c36396fc5b9b76b6929a619c01c7765.zip
Eleven: Update the bottom action bar to be latest, add update playlist view
Playlists: add images and show # of songs HomeACtivity: fix the jumping back behavior Change-Id: I6327de25c4a4286c575adb2bb86766ed947c14b1
-rw-r--r--Android.mk8
-rw-r--r--res/layout/bottom_action_bar.xml48
-rw-r--r--res/layout/edit_track_list_item.xml2
-rw-r--r--res/layout/list_item_normal.xml9
-rw-r--r--res/values/dimens.xml4
-rw-r--r--res/values/plurals.xml1
-rw-r--r--res/values/styles.xml16
-rw-r--r--src/com/cyngn/eleven/adapters/PlaylistAdapter.java20
-rw-r--r--src/com/cyngn/eleven/adapters/ProfileSongAdapter.java53
-rw-r--r--src/com/cyngn/eleven/loaders/PlaylistLoader.java28
-rw-r--r--src/com/cyngn/eleven/loaders/SongLoader.java6
-rw-r--r--src/com/cyngn/eleven/model/Playlist.java14
-rw-r--r--src/com/cyngn/eleven/ui/activities/BaseActivity.java46
-rw-r--r--src/com/cyngn/eleven/ui/activities/HomeActivity.java19
-rw-r--r--src/com/cyngn/eleven/ui/fragments/profile/LastAddedFragment.java19
-rw-r--r--src/com/cyngn/eleven/ui/fragments/profile/PlaylistSongFragment.java17
-rw-r--r--src/com/cyngn/eleven/utils/MusicUtils.java3
17 files changed, 193 insertions, 120 deletions
diff --git a/Android.mk b/Android.mk
index de7e0d9..d84b532 100644
--- a/Android.mk
+++ b/Android.mk
@@ -10,8 +10,8 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-v4 \
android-support-v8-renderscript \
android-common \
- nineoldandroids \
- palette
+ eleven_nineoldandroids \
+ eleven_palette
LOCAL_PACKAGE_NAME := Eleven
LOCAL_OVERRIDES_PACKAGES := Music
@@ -25,6 +25,6 @@ include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
- nineoldandroids:libs/nineoldandroids-2.4.0.jar \
- palette:libs/android-support-v7-palette.jar
+ eleven_nineoldandroids:libs/nineoldandroids-2.4.0.jar \
+ eleven_palette:libs/android-support-v7-palette.jar
include $(BUILD_MULTI_PREBUILT)
diff --git a/res/layout/bottom_action_bar.xml b/res/layout/bottom_action_bar.xml
index ee38db3..bcb2631 100644
--- a/res/layout/bottom_action_bar.xml
+++ b/res/layout/bottom_action_bar.xml
@@ -23,10 +23,6 @@
android:layout_gravity="bottom"
tools:ignore="ContentDescription" >
- <include
- android:id="@+id/colorstrip"
- layout="@layout/colorstrip" />
-
<LinearLayout
android:id="@+id/bottom_action_bar"
android:layout_width="match_parent"
@@ -60,37 +56,19 @@
android:layout_below="@+id/bottom_action_bar_line_one" />
</RelativeLayout>
- <HorizontalScrollView
- android:layout_width="@dimen/bottom_action_bar_button_container_width"
- android:layout_height="match_parent"
- android:scrollbars="none" >
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:orientation="horizontal" >
-
- <com.cyngn.eleven.widgets.RepeatingImageButton
- android:id="@+id/action_button_previous"
- style="@style/BottomActionBarItem.Previous" />
-
- <com.cyngn.eleven.widgets.PlayPauseButton
- android:id="@+id/action_button_play"
- style="@style/BottomActionBarItem.Play" />
-
- <com.cyngn.eleven.widgets.RepeatingImageButton
- android:id="@+id/action_button_next"
- style="@style/BottomActionBarItem.Next" />
-
- <com.cyngn.eleven.widgets.ShuffleButton
- android:id="@+id/action_button_shuffle"
- style="@style/BottomActionBarItem.Shuffle" />
-
- <com.cyngn.eleven.widgets.RepeatButton
- android:id="@+id/action_button_repeat"
- style="@style/BottomActionBarItem.Repeat" />
- </LinearLayout>
- </HorizontalScrollView>
+ <FrameLayout
+ android:id="@+id/play_pause_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:paddingLeft="@dimen/bab_progress_padding_left"
+ android:paddingRight="@dimen/bab_progress_padding_right">
+ <include
+ android:contentDescription="@string/accessibility_play"
+ android:layout_width="@dimen/bab_progress_size"
+ android:layout_height="@dimen/bab_progress_size"
+ layout="@layout/play_pause_progress_button" />
+ </FrameLayout>
</LinearLayout>
</com.cyngn.eleven.widgets.theme.BottomActionBar> \ No newline at end of file
diff --git a/res/layout/edit_track_list_item.xml b/res/layout/edit_track_list_item.xml
index daaf79c..74e0362 100644
--- a/res/layout/edit_track_list_item.xml
+++ b/res/layout/edit_track_list_item.xml
@@ -34,7 +34,7 @@
android:layout_toRightOf="@+id/edit_track_list_item_handle"
android:gravity="center_vertical" >
- <include layout="@layout/list_item_simple" />
+ <include layout="@layout/list_item_normal" />
</FrameLayout>
</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/list_item_normal.xml b/res/layout/list_item_normal.xml
index 775ec1f..a8acdff 100644
--- a/res/layout/list_item_normal.xml
+++ b/res/layout/list_item_normal.xml
@@ -36,6 +36,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_image_height"
android:layout_toRightOf="@+id/image"
+ android:layout_toLeftOf="@+id/line_one_right"
android:gravity="center_vertical"
android:minHeight="@dimen/item_normal_height"
android:paddingLeft="@dimen/list_preferred_item_padding" >
@@ -54,4 +55,12 @@
android:layout_below="@+id/line_one" />
</RelativeLayout>
+ <TextView
+ android:id="@+id/line_one_right"
+ style="@style/ListItemSecondaryText.Single"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true" />
+
</RelativeLayout> \ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 92aeb23..ad8a957 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -67,7 +67,9 @@
<dimen name="bottom_action_bar_album_art_width">30.0dip</dimen>
<dimen name="bottom_action_bar_album_art_height">30.0dip</dimen>
<dimen name="bottom_action_bar_info_padding_left">5.0dip</dimen>
- <dimen name="bottom_action_bar_button_container_width">165.0dip</dimen>
+ <dimen name="bab_progress_size">35.0dip</dimen>
+ <dimen name="bab_progress_padding_left">16.0dip</dimen>
+ <dimen name="bab_progress_padding_right">22.0dip</dimen>
<!-- Notification template -->
<dimen name="notification_big_icon_height">64.0dip</dimen>
diff --git a/res/values/plurals.xml b/res/values/plurals.xml
index 8a158d4..33a549f 100644
--- a/res/values/plurals.xml
+++ b/res/values/plurals.xml
@@ -30,6 +30,7 @@
<!-- Used to indicate the number of songs for an album -->
<plurals name="Nsongs">
+ <item quantity="zero"><xliff:g id="count">%d</xliff:g> songs</item>
<item quantity="one"><xliff:g id="count">%d</xliff:g> song</item>
<item quantity="other"><xliff:g id="count">%d</xliff:g> songs</item>
</plurals>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9aa37a0..c0df4c7 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -211,24 +211,8 @@
<item name="android:scaleType">centerInside</item>
</style>
- <style name="BottomActionBarItem.Previous" parent="@style/BottomActionBarItem">
- <item name="android:contentDescription">@string/accessibility_prev</item>
- </style>
-
- <style name="BottomActionBarItem.Next" parent="@style/BottomActionBarItem">
- <item name="android:contentDescription">@string/accessibility_next</item>
- </style>
-
<style name="BottomActionBarItem.Play" parent="@style/BottomActionBarItem">
- <item name="android:contentDescription">@string/accessibility_play</item>
- </style>
-
- <style name="BottomActionBarItem.Shuffle" parent="@style/BottomActionBarItem">
- <item name="android:contentDescription">@string/accessibility_shuffle</item>
- </style>
- <style name="BottomActionBarItem.Repeat" parent="@style/BottomActionBarItem">
- <item name="android:contentDescription">@string/accessibility_repeat</item>
</style>
</resources>
diff --git a/src/com/cyngn/eleven/adapters/PlaylistAdapter.java b/src/com/cyngn/eleven/adapters/PlaylistAdapter.java
index 1a3b498..c18c8c7 100644
--- a/src/com/cyngn/eleven/adapters/PlaylistAdapter.java
+++ b/src/com/cyngn/eleven/adapters/PlaylistAdapter.java
@@ -23,6 +23,7 @@ import com.cyngn.eleven.model.Playlist;
import com.cyngn.eleven.ui.MusicHolder;
import com.cyngn.eleven.ui.MusicHolder.DataHolder;
import com.cyngn.eleven.ui.fragments.PlaylistFragment;
+import com.cyngn.eleven.utils.MusicUtils;
/**
* This {@link ArrayAdapter} is used to display all of the playlists on a user's
@@ -69,12 +70,8 @@ public class PlaylistAdapter extends ArrayAdapter<Playlist> {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(mLayoutId, parent, false);
holder = new MusicHolder(convertView);
- // Hide the second and third lines of text
- holder.mLineTwo.get().setVisibility(View.GONE);
+ // hide the third line
holder.mLineThree.get().setVisibility(View.GONE);
- // Make line one slightly larger
- holder.mLineOne.get().setTextSize(TypedValue.COMPLEX_UNIT_PX,
- getContext().getResources().getDimension(R.dimen.text_size_large));
convertView.setTag(holder);
} else {
holder = (MusicHolder)convertView.getTag();
@@ -85,6 +82,14 @@ public class PlaylistAdapter extends ArrayAdapter<Playlist> {
// Set each playlist name (line one)
holder.mLineOne.get().setText(dataHolder.mLineOne);
+
+ if (dataHolder.mLineTwo == null) {
+ holder.mLineTwo.get().setVisibility(View.GONE);
+ } else {
+ holder.mLineTwo.get().setVisibility(View.VISIBLE);
+ holder.mLineTwo.get().setText(dataHolder.mLineTwo);
+ }
+
return convertView;
}
@@ -121,6 +126,11 @@ public class PlaylistAdapter extends ArrayAdapter<Playlist> {
mData[i].mItemId = playlist.mPlaylistId;
// Playlist names (line one)
mData[i].mLineOne = playlist.mPlaylistName;
+ // # of songs
+ if (playlist.mSongCount >= 0) {
+ mData[i].mLineTwo = MusicUtils.makeLabel(getContext(),
+ R.plurals.Nsongs, playlist.mSongCount);
+ }
}
}
diff --git a/src/com/cyngn/eleven/adapters/ProfileSongAdapter.java b/src/com/cyngn/eleven/adapters/ProfileSongAdapter.java
index 2995775..7d80133 100644
--- a/src/com/cyngn/eleven/adapters/ProfileSongAdapter.java
+++ b/src/com/cyngn/eleven/adapters/ProfileSongAdapter.java
@@ -11,6 +11,7 @@
package com.cyngn.eleven.adapters;
+import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@@ -18,6 +19,8 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import com.cyngn.eleven.R;
+import com.cyngn.eleven.cache.ImageFetcher;
+import com.cyngn.eleven.model.Artist;
import com.cyngn.eleven.model.Song;
import com.cyngn.eleven.ui.MusicHolder;
import com.cyngn.eleven.ui.fragments.profile.AlbumSongFragment;
@@ -25,6 +28,7 @@ import com.cyngn.eleven.ui.fragments.profile.ArtistSongFragment;
import com.cyngn.eleven.ui.fragments.profile.GenreSongFragment;
import com.cyngn.eleven.ui.fragments.profile.LastAddedFragment;
import com.cyngn.eleven.ui.fragments.profile.PlaylistSongFragment;
+import com.cyngn.eleven.utils.ApolloUtils;
import com.cyngn.eleven.utils.Lists;
import com.cyngn.eleven.utils.MusicUtils;
@@ -86,6 +90,11 @@ public class ProfileSongAdapter extends ArrayAdapter<Song> {
private final int mLayoutId;
/**
+ * Image cache and image fetcher
+ */
+ private final ImageFetcher mImageFetcher;
+
+ /**
* Display setting for the second line in a song fragment
*/
private final int mDisplaySetting;
@@ -103,30 +112,32 @@ public class ProfileSongAdapter extends ArrayAdapter<Song> {
/**
* Constructor of <code>ProfileSongAdapter</code>
*
- * @param context The {@link Context} to use
+ * @param activity The {@link Activity} to use
* @param layoutId The resource Id of the view to inflate.
* @param setting defines the content of the second line
*/
- public ProfileSongAdapter(final Context context, final int layoutId, final int setting) {
- super(context, 0);
+ public ProfileSongAdapter(final Activity activity, final int layoutId, final int setting) {
+ super(activity, 0);
// Used to create the custom layout
- mInflater = LayoutInflater.from(context);
+ mInflater = LayoutInflater.from(activity);
// Cache the header
mHeader = mInflater.inflate(R.layout.faux_carousel, null);
// Get the layout Id
mLayoutId = layoutId;
// Know what to put in line two
mDisplaySetting = setting;
+ // Initialize the cache & image fetcher
+ mImageFetcher = ApolloUtils.getImageFetcher(activity);
}
/**
* Constructor of <code>ProfileSongAdapter</code>
*
- * @param context The {@link Context} to use
+ * @param activity The {@link Activity} to use
* @param layoutId The resource Id of the view to inflate.
*/
- public ProfileSongAdapter(final Context context, final int layoutId) {
- this(context, layoutId, DISPLAY_DEFAULT_SETTING);
+ public ProfileSongAdapter(final Activity activity, final int layoutId) {
+ this(activity, layoutId, DISPLAY_DEFAULT_SETTING);
}
/**
@@ -146,7 +157,9 @@ public class ProfileSongAdapter extends ArrayAdapter<Song> {
convertView = LayoutInflater.from(getContext()).inflate(mLayoutId, parent, false);
holder = new MusicHolder(convertView);
// Hide the third line of text
- holder.mLineThree.get().setVisibility(View.GONE);
+ if (holder.mLineThree.get() != null) {
+ holder.mLineThree.get().setVisibility(View.GONE);
+ }
convertView.setTag(holder);
} else {
holder = (MusicHolder)convertView.getTag();
@@ -179,6 +192,12 @@ public class ProfileSongAdapter extends ArrayAdapter<Song> {
sb.append(SEPARATOR_STRING);
sb.append(song.mAlbumName);
holder.mLineTwo.get().setText(sb.toString());
+
+ // Asynchronously load the album image
+ if (song.mAlbumId >= 0) {
+ mImageFetcher.loadAlbumImage(song.mArtistName, song.mAlbumName, song.mAlbumId,
+ holder.mImage.get());
+ }
break;
case DISPLAY_DEFAULT_SETTING:
default:
@@ -240,6 +259,24 @@ public class ProfileSongAdapter extends ArrayAdapter<Song> {
}
/**
+ * @param pause True to temporarily pause the disk cache, false otherwise.
+ */
+ public void setPauseDiskCache(final boolean pause) {
+ if (mImageFetcher != null) {
+ mImageFetcher.setPauseDiskCache(pause);
+ }
+ }
+
+ /**
+ * @param artist The key used to find the cached artist to remove
+ */
+ public void removeFromCache(final Artist artist) {
+ if (mImageFetcher != null) {
+ mImageFetcher.removeFromCache(artist.mArtistName);
+ }
+ }
+
+ /**
* Method that unloads and clears the items in the adapter
*/
public void unload() {
diff --git a/src/com/cyngn/eleven/loaders/PlaylistLoader.java b/src/com/cyngn/eleven/loaders/PlaylistLoader.java
index 485520f..938b12d 100644
--- a/src/com/cyngn/eleven/loaders/PlaylistLoader.java
+++ b/src/com/cyngn/eleven/loaders/PlaylistLoader.java
@@ -21,6 +21,7 @@ import android.provider.MediaStore.Audio.PlaylistsColumns;
import com.cyngn.eleven.R;
import com.cyngn.eleven.model.Playlist;
import com.cyngn.eleven.utils.Lists;
+import com.cyngn.eleven.utils.MusicUtils;
import java.util.ArrayList;
import java.util.List;
@@ -71,8 +72,10 @@ public class PlaylistLoader extends WrappedAsyncTaskLoader<List<Playlist>> {
// Copy the playlist name
final String name = mCursor.getString(1);
+ final int songCount = getSongCount(getContext(), id);
+
// Create a new playlist
- final Playlist playlist = new Playlist(id, name);
+ final Playlist playlist = new Playlist(id, name, songCount);
// Add everything up
mPlaylistList.add(playlist);
@@ -92,7 +95,7 @@ public class PlaylistLoader extends WrappedAsyncTaskLoader<List<Playlist>> {
/* Last added list */
final Playlist lastAdded = new Playlist(-2,
- resources.getString(R.string.playlist_last_added));
+ resources.getString(R.string.playlist_last_added), -1);
mPlaylistList.add(lastAdded);
}
@@ -111,4 +114,25 @@ public class PlaylistLoader extends WrappedAsyncTaskLoader<List<Playlist>> {
PlaylistsColumns.NAME
}, null, null, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
}
+
+ /**
+ * Gets the number of songs for a playlist
+ * @param context The {@link Context} to use.
+ * @param playlistId the id of the playlist
+ * @return the # of songs in the playlist or -1 if not found
+ */
+ public static final int getSongCount(final Context context, final long playlistId) {
+ Cursor c = context.getContentResolver().query(
+ MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
+ new String[]{ BaseColumns._ID }, MusicUtils.MUSIC_ONLY_SELECTION, null, null);
+
+ if (c != null && c.moveToFirst()) {
+ int count = c.getCount();
+ c.close();
+ c = null;
+ return count;
+ }
+
+ return -1;
+ }
}
diff --git a/src/com/cyngn/eleven/loaders/SongLoader.java b/src/com/cyngn/eleven/loaders/SongLoader.java
index c9bca72..1850755 100644
--- a/src/com/cyngn/eleven/loaders/SongLoader.java
+++ b/src/com/cyngn/eleven/loaders/SongLoader.java
@@ -20,6 +20,7 @@ import android.provider.MediaStore.Audio.AudioColumns;
import com.cyngn.eleven.model.Song;
import com.cyngn.eleven.sectionadapter.SectionCreator;
import com.cyngn.eleven.utils.Lists;
+import com.cyngn.eleven.utils.MusicUtils;
import com.cyngn.eleven.utils.PreferenceUtils;
import java.util.ArrayList;
@@ -108,9 +109,6 @@ public class SongLoader extends SectionCreator.SimpleListLoader<Song> {
* @return The {@link Cursor} used to run the song query.
*/
public static final Cursor makeSongCursor(final Context context) {
- final StringBuilder mSelection = new StringBuilder();
- mSelection.append(AudioColumns.IS_MUSIC + "=1");
- mSelection.append(" AND " + AudioColumns.TITLE + " != ''"); //$NON-NLS-2$
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
new String[] {
/* 0 */
@@ -127,7 +125,7 @@ public class SongLoader extends SectionCreator.SimpleListLoader<Song> {
AudioColumns.DURATION,
/* 6 */
AudioColumns.YEAR,
- }, mSelection.toString(), null,
+ }, MusicUtils.MUSIC_ONLY_SELECTION, null,
PreferenceUtils.getInstance(context).getSongSortOrder());
}
}
diff --git a/src/com/cyngn/eleven/model/Playlist.java b/src/com/cyngn/eleven/model/Playlist.java
index bb40a7b..a043f8b 100644
--- a/src/com/cyngn/eleven/model/Playlist.java
+++ b/src/com/cyngn/eleven/model/Playlist.java
@@ -31,15 +31,21 @@ public class Playlist {
public String mPlaylistName;
/**
+ * The number of songs in this playlist
+ */
+ public int mSongCount;
+
+ /**
* Constructor of <code>Genre</code>
*
* @param playlistId The Id of the playlist
* @param playlistName The playlist name
*/
- public Playlist(final long playlistId, final String playlistName) {
+ public Playlist(final long playlistId, final String playlistName, final int songCount) {
super();
mPlaylistId = playlistId;
mPlaylistName = playlistName;
+ mSongCount = songCount;
}
/**
@@ -51,6 +57,7 @@ public class Playlist {
int result = 1;
result = prime * result + (int) mPlaylistId;
result = prime * result + (mPlaylistName == null ? 0 : mPlaylistName.hashCode());
+ result = prime * result + mSongCount;
return result;
}
@@ -72,6 +79,11 @@ public class Playlist {
if (mPlaylistId != other.mPlaylistId) {
return false;
}
+
+ if (mSongCount != other.mSongCount) {
+ return false;
+ }
+
return TextUtils.equals(mPlaylistName, other.mPlaylistName);
}
diff --git a/src/com/cyngn/eleven/ui/activities/BaseActivity.java b/src/com/cyngn/eleven/ui/activities/BaseActivity.java
index 0ab779a..5ed2511 100644
--- a/src/com/cyngn/eleven/ui/activities/BaseActivity.java
+++ b/src/com/cyngn/eleven/ui/activities/BaseActivity.java
@@ -44,6 +44,7 @@ import com.cyngn.eleven.utils.MusicUtils;
import com.cyngn.eleven.utils.MusicUtils.ServiceToken;
import com.cyngn.eleven.utils.NavUtils;
import com.cyngn.eleven.widgets.PlayPauseButton;
+import com.cyngn.eleven.widgets.PlayPauseProgressButton;
import com.cyngn.eleven.widgets.RepeatButton;
import com.cyngn.eleven.widgets.ShuffleButton;
@@ -71,19 +72,9 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
private ServiceToken mToken;
/**
- * Play and pause button (BAB)
+ * Play pause progress button
*/
- private PlayPauseButton mPlayPauseButton;
-
- /**
- * Repeat button (BAB)
- */
- private RepeatButton mRepeatButton;
-
- /**
- * Shuffle button (BAB)
- */
- private ShuffleButton mShuffleButton;
+ private PlayPauseProgressButton mPlayPauseProgressButton;
/**
* Track name (BAB)
@@ -234,14 +225,14 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
final IntentFilter filter = new IntentFilter();
// Play and pause changes
filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED);
- // Shuffle and repeat changes
- filter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED);
- filter.addAction(MusicPlaybackService.REPEATMODE_CHANGED);
// Track changes
filter.addAction(MusicPlaybackService.META_CHANGED);
// Update a list, probably the playlist fragment's
filter.addAction(MusicPlaybackService.REFRESH);
registerReceiver(mPlaybackStatus, filter);
+
+ mPlayPauseProgressButton.resume();
+
MusicUtils.notifyForegroundStateChanged(this, true);
}
@@ -251,6 +242,9 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
@Override
protected void onStop() {
super.onStop();
+
+ mPlayPauseProgressButton.pause();
+
MusicUtils.notifyForegroundStateChanged(this, false);
}
@@ -291,11 +285,9 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
*/
private void initBottomActionBar() {
// Play and pause button
- mPlayPauseButton = (PlayPauseButton)findViewById(R.id.action_button_play);
- // Shuffle button
- mShuffleButton = (ShuffleButton)findViewById(R.id.action_button_shuffle);
- // Repeat button
- mRepeatButton = (RepeatButton)findViewById(R.id.action_button_repeat);
+ mPlayPauseProgressButton = (PlayPauseProgressButton)findViewById(R.id.playPauseProgressButton);
+ mPlayPauseProgressButton.enableAndShow();
+
// Track name
mTrackName = (TextView)findViewById(R.id.bottom_action_bar_line_one);
// Artist name
@@ -335,11 +327,7 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
*/
private void updatePlaybackControls() {
// Set the play and pause image
- mPlayPauseButton.updateState();
- // Set the shuffle image
- mShuffleButton.updateShuffleState();
- // Set the repeat image
- mRepeatButton.updateRepeatState();
+ mPlayPauseProgressButton.getPlayPauseButton().updateState();
}
/**
@@ -413,13 +401,7 @@ public abstract class BaseActivity extends FragmentActivity implements ServiceCo
}
} else if (action.equals(MusicPlaybackService.PLAYSTATE_CHANGED)) {
// Set the play and pause image
- mReference.get().mPlayPauseButton.updateState();
- } else if (action.equals(MusicPlaybackService.REPEATMODE_CHANGED)
- || action.equals(MusicPlaybackService.SHUFFLEMODE_CHANGED)) {
- // Set the repeat image
- mReference.get().mRepeatButton.updateRepeatState();
- // Set the shuffle image
- mReference.get().mShuffleButton.updateShuffleState();
+ mReference.get().mPlayPauseProgressButton.getPlayPauseButton().updateState();
} else if (action.equals(MusicPlaybackService.REFRESH)) {
// Let the listener know to update a list
for (final MusicStateListener listener : mReference.get().mMusicStateListener) {
diff --git a/src/com/cyngn/eleven/ui/activities/HomeActivity.java b/src/com/cyngn/eleven/ui/activities/HomeActivity.java
index 05288c5..8111669 100644
--- a/src/com/cyngn/eleven/ui/activities/HomeActivity.java
+++ b/src/com/cyngn/eleven/ui/activities/HomeActivity.java
@@ -123,7 +123,11 @@ public class HomeActivity extends BaseActivity {
mSecondPanel.setPanelSlideListener(new SimplePanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
- mFirstPanel.setSlidingEnabled(false);
+ // if we are not going to a specific panel, then disable sliding to prevent
+ // the two sliding panels from fighting for touch input
+ if (mTargetNavigatePanel == Panel.None) {
+ mFirstPanel.setSlidingEnabled(false);
+ }
}
@Override
@@ -133,6 +137,7 @@ public class HomeActivity extends BaseActivity {
@Override
public void onPanelCollapsed(View panel) {
+ // re-enable sliding when the second panel is collapsed
mFirstPanel.setSlidingEnabled(true);
checkTargetNavigation();
}
@@ -218,6 +223,8 @@ public class HomeActivity extends BaseActivity {
// if we are two panels over, we need special logic to jump twice
mTargetNavigatePanel = panel;
mSecondPanel.collapsePanel();
+ // re-enable sliding on first panel so we can collapse it
+ mFirstPanel.setSlidingEnabled(true);
mFirstPanel.collapsePanel();
break;
case MusicPlayer:
@@ -234,15 +241,11 @@ public class HomeActivity extends BaseActivity {
}
/**
- * This checks if we are at our target panel, and if not, continues the motion
+ * This checks if we are at our target panel and resets our flag if we are there
*/
protected void checkTargetNavigation() {
- if (mTargetNavigatePanel != Panel.None) {
- if (mTargetNavigatePanel == getCurrentPanel()) {
- mTargetNavigatePanel = Panel.None;
- } else {
- showPanel(mTargetNavigatePanel);
- }
+ if (mTargetNavigatePanel == getCurrentPanel()) {
+ mTargetNavigatePanel = Panel.None;
}
}
diff --git a/src/com/cyngn/eleven/ui/fragments/profile/LastAddedFragment.java b/src/com/cyngn/eleven/ui/fragments/profile/LastAddedFragment.java
index af7dbcd..ffbf4b6 100644
--- a/src/com/cyngn/eleven/ui/fragments/profile/LastAddedFragment.java
+++ b/src/com/cyngn/eleven/ui/fragments/profile/LastAddedFragment.java
@@ -25,6 +25,7 @@ import android.view.Menu;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
@@ -130,7 +131,7 @@ public class LastAddedFragment extends Fragment implements LoaderCallbacks<List<
// Create the adpater
mAdapter = new ProfileSongAdapter(
getActivity(),
- R.layout.list_item_simple,
+ R.layout.list_item_normal,
ProfileSongAdapter.DISPLAY_PLAYLIST_SETTING
);
}
@@ -154,7 +155,21 @@ public class LastAddedFragment extends Fragment implements LoaderCallbacks<List<
// Play the selected song
mListView.setOnItemClickListener(this);
// To help make scrolling smooth
- mListView.setOnScrollListener(new VerticalScrollListener(null, mProfileTabCarousel, 0));
+ mListView.setOnScrollListener(new VerticalScrollListener(null, mProfileTabCarousel, 0) {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ super.onScrollStateChanged(view, scrollState);
+
+ // Pause disk cache access to ensure smoother scrolling
+ if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING
+ || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
+ mAdapter.setPauseDiskCache(true);
+ } else {
+ mAdapter.setPauseDiskCache(false);
+ mAdapter.notifyDataSetChanged();
+ }
+ }
+ });
// Remove the scrollbars and padding for the fast scroll
mListView.setVerticalScrollBarEnabled(false);
mListView.setFastScrollEnabled(false);
diff --git a/src/com/cyngn/eleven/ui/fragments/profile/PlaylistSongFragment.java b/src/com/cyngn/eleven/ui/fragments/profile/PlaylistSongFragment.java
index 492de25..eb38197 100644
--- a/src/com/cyngn/eleven/ui/fragments/profile/PlaylistSongFragment.java
+++ b/src/com/cyngn/eleven/ui/fragments/profile/PlaylistSongFragment.java
@@ -27,6 +27,7 @@ import android.view.Menu;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
@@ -164,7 +165,21 @@ public class PlaylistSongFragment extends Fragment implements LoaderCallbacks<Li
// Quick scroll while dragging
mListView.setDragScrollProfile(this);
// To help make scrolling smooth
- mListView.setOnScrollListener(new VerticalScrollListener(null, mProfileTabCarousel, 0));
+ mListView.setOnScrollListener(new VerticalScrollListener(null, mProfileTabCarousel, 0) {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ super.onScrollStateChanged(view, scrollState);
+
+ // Pause disk cache access to ensure smoother scrolling
+ if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING
+ || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
+ mAdapter.setPauseDiskCache(true);
+ } else {
+ mAdapter.setPauseDiskCache(false);
+ mAdapter.notifyDataSetChanged();
+ }
+ }
+ });
// Remove the scrollbars and padding for the fast scroll
mListView.setVerticalScrollBarEnabled(false);
mListView.setFastScrollEnabled(false);
diff --git a/src/com/cyngn/eleven/utils/MusicUtils.java b/src/com/cyngn/eleven/utils/MusicUtils.java
index 698a9b4..5a0e6a4 100644
--- a/src/com/cyngn/eleven/utils/MusicUtils.java
+++ b/src/com/cyngn/eleven/utils/MusicUtils.java
@@ -73,6 +73,9 @@ public final class MusicUtils {
private static final int MIN_VALID_YEAR = 1900; // used to remove invalid years from metadata
+ public static final String MUSIC_ONLY_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1"
+ + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"; //$NON-NLS-2$
+
static {
mConnectionMap = new WeakHashMap<Context, ServiceBinder>();
sEmptyList = new long[0];