Show song durations in queue (by adding a TextView) (#761)
* Show song durations in queue (by adding a TextView) This partially addresses https://github.com/vanilla-music/vanilla/issues/647 * Make duration TextView gone by default * Show song durations in playlist
This commit is contained in:
parent
d2990af08f
commit
b847279578
@ -38,6 +38,7 @@ public class DraggableRow extends LinearLayout implements Checkable {
|
||||
private boolean mLayoutSet;
|
||||
|
||||
private TextView mTextView;
|
||||
private TextView mDurationView;
|
||||
private CheckedTextView mCheckBox;
|
||||
private View mPmark;
|
||||
private ImageView mDragger;
|
||||
@ -61,6 +62,7 @@ public class DraggableRow extends LinearLayout implements Checkable {
|
||||
public void onFinishInflate() {
|
||||
mCheckBox = (CheckedTextView)this.findViewById(R.id.checkbox);
|
||||
mTextView = (TextView)this.findViewById(R.id.text);
|
||||
mDurationView = findViewById(R.id.duration);
|
||||
mPmark = (View)this.findViewById(R.id.pmark);
|
||||
mDragger = (ImageView)this.findViewById(R.id.dragger);
|
||||
mCoverView = (LazyCoverView)this.findViewById(R.id.cover);
|
||||
@ -82,6 +84,7 @@ public class DraggableRow extends LinearLayout implements Checkable {
|
||||
case LAYOUT_DRAGGABLE:
|
||||
highlightRow(false); // make this visible
|
||||
mCoverView.setVisibility(View.VISIBLE);
|
||||
mDurationView.setVisibility(View.VISIBLE);
|
||||
showDragger(true);
|
||||
break;
|
||||
case LAYOUT_LISTVIEW:
|
||||
@ -159,6 +162,13 @@ public class DraggableRow extends LinearLayout implements Checkable {
|
||||
return mTextView;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a TextView intended to display duration
|
||||
*/
|
||||
public TextView getDurationView() {
|
||||
return mDurationView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of our coverview
|
||||
*/
|
||||
|
@ -25,13 +25,12 @@ package ch.blinkenlights.android.vanilla;
|
||||
|
||||
import ch.blinkenlights.android.medialibrary.MediaLibrary;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -50,6 +49,7 @@ public class PlaylistAdapter extends CursorAdapter implements Handler.Callback {
|
||||
MediaLibrary.PlaylistSongColumns.SONG_ID,
|
||||
MediaLibrary.SongColumns.ALBUM_ID,
|
||||
MediaLibrary.PlaylistSongColumns.POSITION,
|
||||
MediaLibrary.SongColumns.DURATION,
|
||||
};
|
||||
|
||||
private final Context mContext;
|
||||
@ -114,6 +114,9 @@ public class PlaylistAdapter extends CursorAdapter implements Handler.Callback {
|
||||
textView.setText(cursor.getString(1));
|
||||
textView.setTag(cursor.getLong(3));
|
||||
|
||||
String duration = DateUtils.formatElapsedTime(cursor.getLong(6) / 1000);
|
||||
dview.getDurationView().setText(duration);
|
||||
|
||||
LazyCoverView cover = dview.getCoverView();
|
||||
cover.setCover(MediaUtils.TYPE_ALBUM, cursor.getLong(4), null);
|
||||
}
|
||||
|
@ -23,13 +23,11 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.TextView;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
||||
public class ShowQueueAdapter extends BaseAdapter {
|
||||
/**
|
||||
@ -144,6 +142,7 @@ public class ShowQueueAdapter extends BaseAdapter {
|
||||
sb.setSpan(new ForegroundColorSpan(Color.GRAY), song.title.length() + 1, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
row.getTextView().setText(sb);
|
||||
row.getCoverView().setCover(MediaUtils.TYPE_ALBUM, song.albumId, null);
|
||||
row.getDurationView().setText(song.getFormattedDuration());
|
||||
}
|
||||
|
||||
row.highlightRow(position == mHighlightRow);
|
||||
|
@ -27,7 +27,8 @@ import ch.blinkenlights.android.medialibrary.MediaLibrary;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.format.DateUtils;
|
||||
|
||||
/**
|
||||
* Represents a Song backed by the MediaStore. Includes basic metadata and
|
||||
* utilities to retrieve songs from the MediaStore.
|
||||
@ -203,6 +204,13 @@ public class Song implements Comparable<Song> {
|
||||
return song.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return duration of this song in the form "MM:SS" or "H:MM:SS"
|
||||
*/
|
||||
public String getFormattedDuration() {
|
||||
return DateUtils.formatElapsedTime(duration / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the large album art for this song.
|
||||
*
|
||||
|
@ -45,6 +45,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:layout_height="@dimen/row_normal_height"
|
||||
android:layout_marginLeft="@dimen/text_padding"
|
||||
android:layout_weight="1" />
|
||||
<TextView
|
||||
android:id="@+id/duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/text_padding"
|
||||
android:visibility="gone"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:gravity="center_vertical" />
|
||||
<CheckedTextView
|
||||
android:id="@+id/checkbox"
|
||||
android:visibility="gone"
|
||||
|
Loading…
x
Reference in New Issue
Block a user