aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-02-22 17:19:18 -0800
committerScott Jackson <daneren2005@gmail.com>2016-02-22 17:19:18 -0800
commit2a625f25ff7eef0f900ca3eacfe8935dcf8d8bde (patch)
treec22d98787fb390ff6e53fdadee70ebc1cdd4b769
parentb347afd7ba73219852d59c4f43d363f24449d8cd (diff)
downloaddsub-2a625f25ff7eef0f900ca3eacfe8935dcf8d8bde.tar.gz
dsub-2a625f25ff7eef0f900ca3eacfe8935dcf8d8bde.tar.bz2
dsub-2a625f25ff7eef0f900ca3eacfe8935dcf8d8bde.zip
#417 Add listened status indicator for Podcasts/Audio Books
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java8
-rw-r--r--app/src/main/java/github/daneren2005/dsub/view/SongView.java36
-rw-r--r--app/src/main/res/drawable-hdpi/ic_toggle_played.pngbin0 -> 1064 bytes
-rw-r--r--app/src/main/res/drawable-mdpi/ic_toggle_played.pngbin0 -> 579 bytes
-rw-r--r--app/src/main/res/drawable-xhdpi/ic_toggle_played.pngbin0 -> 1341 bytes
-rw-r--r--app/src/main/res/drawable-xxhdpi/ic_toggle_played.pngbin0 -> 2552 bytes
-rw-r--r--app/src/main/res/drawable-xxxhdpi/ic_toggle_played.pngbin0 -> 3715 bytes
-rw-r--r--app/src/main/res/layout/song_list_item.xml18
-rw-r--r--app/src/main/res/values/dimens.xml1
9 files changed, 53 insertions, 10 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java b/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java
index 8d91a251..859c32dd 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/SongDBHandler.java
@@ -150,6 +150,14 @@ public class SongDBHandler extends SQLiteOpenHelper {
db.close();
}
+ public boolean hasBeenPlayed(MusicDirectory.Entry entry) {
+ Long[] lastPlayed = getLastPlayed(entry);
+ return lastPlayed != null && lastPlayed[0] != null && lastPlayed[0] > 0;
+ }
+ public boolean hasBeenCompleted(MusicDirectory.Entry entry) {
+ Long[] lastPlayed = getLastPlayed(entry);
+ return lastPlayed != null && lastPlayed[1] != null && lastPlayed[1] > 0;
+ }
public synchronized Long[] getLastPlayed(MusicDirectory.Entry entry) {
return getLastPlayed(getOnlineSongId(entry));
}
diff --git a/app/src/main/java/github/daneren2005/dsub/view/SongView.java b/app/src/main/java/github/daneren2005/dsub/view/SongView.java
index 2c0580af..95f7479f 100644
--- a/app/src/main/java/github/daneren2005/dsub/view/SongView.java
+++ b/app/src/main/java/github/daneren2005/dsub/view/SongView.java
@@ -20,7 +20,6 @@ package github.daneren2005.dsub.view;
import android.content.Context;
import android.graphics.Color;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.*;
@@ -30,6 +29,7 @@ import github.daneren2005.dsub.domain.PodcastEpisode;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.util.DrawableTint;
+import github.daneren2005.dsub.util.SongDBHandler;
import github.daneren2005.dsub.util.Util;
import java.io.File;
@@ -50,6 +50,7 @@ public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> {
private TextView statusTextView;
private ImageView statusImageView;
private ImageView bookmarkButton;
+ private ImageView playedButton;
private View bottomRowView;
private DownloadService downloadService;
@@ -66,8 +67,10 @@ public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> {
private boolean partialFileExists = false;
private boolean loaded = false;
private boolean isBookmarked = false;
- private boolean bookmarked = false;
+ private boolean isBookmarkedShown = false;
private boolean showPodcast = false;
+ private boolean isPlayed = false;
+ private boolean isPlayedShown = false;
public SongView(Context context) {
super(context);
@@ -84,6 +87,7 @@ public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> {
starButton.setFocusable(false);
bookmarkButton = (ImageButton) findViewById(R.id.song_bookmark);
bookmarkButton.setFocusable(false);
+ playedButton = (ImageButton) findViewById(R.id.song_played);
moreButton = (ImageView) findViewById(R.id.item_more);
bottomRowView = findViewById(R.id.song_bottom);
}
@@ -209,6 +213,10 @@ public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> {
item.loadMetadata(downloadFile.getCompleteFile());
loaded = true;
}
+
+ if(item instanceof PodcastEpisode || item.isAudioBook() || item.isPodcast()) {
+ isPlayed = SongDBHandler.getHandler(context).hasBeenCompleted(item);
+ }
}
@Override
@@ -274,18 +282,34 @@ public class SongView extends UpdateView2<MusicDirectory.Entry, Boolean> {
}
if(isBookmarked) {
- if(!bookmarked) {
+ if(!isBookmarkedShown) {
if(bookmarkButton.getDrawable() == null) {
bookmarkButton.setImageDrawable(DrawableTint.getTintedDrawable(context, R.drawable.ic_menu_bookmark_selected));
}
bookmarkButton.setVisibility(View.VISIBLE);
- bookmarked = true;
+ isBookmarkedShown = true;
}
} else {
- if(bookmarked) {
+ if(isBookmarkedShown) {
bookmarkButton.setVisibility(View.GONE);
- bookmarked = false;
+ isBookmarkedShown = false;
+ }
+ }
+
+ if(isPlayed) {
+ if(!isPlayedShown) {
+ if(playedButton.getDrawable() == null) {
+ playedButton.setImageDrawable(DrawableTint.getTintedDrawable(context, R.drawable.ic_toggle_played));
+ }
+
+ playedButton.setVisibility(View.VISIBLE);
+ isPlayedShown = true;
+ }
+ } else {
+ if(isPlayedShown) {
+ playedButton.setVisibility(View.GONE);
+ isPlayedShown = false;
}
}
diff --git a/app/src/main/res/drawable-hdpi/ic_toggle_played.png b/app/src/main/res/drawable-hdpi/ic_toggle_played.png
new file mode 100644
index 00000000..944ff8be
--- /dev/null
+++ b/app/src/main/res/drawable-hdpi/ic_toggle_played.png
Binary files differ
diff --git a/app/src/main/res/drawable-mdpi/ic_toggle_played.png b/app/src/main/res/drawable-mdpi/ic_toggle_played.png
new file mode 100644
index 00000000..02524f4c
--- /dev/null
+++ b/app/src/main/res/drawable-mdpi/ic_toggle_played.png
Binary files differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_toggle_played.png b/app/src/main/res/drawable-xhdpi/ic_toggle_played.png
new file mode 100644
index 00000000..c681150c
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/ic_toggle_played.png
Binary files differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_toggle_played.png b/app/src/main/res/drawable-xxhdpi/ic_toggle_played.png
new file mode 100644
index 00000000..33f9d819
--- /dev/null
+++ b/app/src/main/res/drawable-xxhdpi/ic_toggle_played.png
Binary files differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_toggle_played.png b/app/src/main/res/drawable-xxxhdpi/ic_toggle_played.png
new file mode 100644
index 00000000..0907fd2c
--- /dev/null
+++ b/app/src/main/res/drawable-xxxhdpi/ic_toggle_played.png
Binary files differ
diff --git a/app/src/main/res/layout/song_list_item.xml b/app/src/main/res/layout/song_list_item.xml
index 6a474787..d7c8d312 100644
--- a/app/src/main/res/layout/song_list_item.xml
+++ b/app/src/main/res/layout/song_list_item.xml
@@ -44,8 +44,8 @@
<ImageButton
android:id="@+id/song_bookmark"
- android:layout_width="24dp"
- android:layout_height="24dp"
+ android:layout_width="@dimen/SongStatusIcon"
+ android:layout_height="@dimen/SongStatusIcon"
android:layout_gravity="right|top"
android:background="@null"
android:focusable="false"
@@ -62,6 +62,16 @@
android:focusable="false"
android:visibility="gone"/>
+ <ImageButton
+ android:id="@+id/song_played"
+ android:layout_width="@dimen/SongStatusIcon"
+ android:layout_height="@dimen/SongStatusIcon"
+ android:scaleType="fitCenter"
+ android:layout_gravity="right|top"
+ android:background="@null"
+ android:focusable="false"
+ android:visibility="gone"/>
+
<TextView
android:id="@+id/song_status"
android:layout_width="wrap_content"
@@ -72,8 +82,8 @@
<ImageView
android:id="@+id/song_status_icon"
- android:layout_width="24dip"
- android:layout_height="24dip"
+ android:layout_width="@dimen/SongStatusIcon"
+ android:layout_height="@dimen/SongStatusIcon"
android:layout_gravity="top"
android:src="?attr/downloading"
android:visibility="gone"/>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 73ae6bed..9c53f472 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -6,6 +6,7 @@
<dimen name="AlbumArt.Small">78dip</dimen>
<dimen name="AlbumArt.Header">120dip</dimen>
<dimen name="Star.Small">20dp</dimen>
+ <dimen name="SongStatusIcon">24dp</dimen>
<dimen name="Card.Radius">4dp</dimen>
<dimen name="Card.TextLeftPadding">8dp</dimen>
<dimen name="Card.MarginsForShadow">2dp</dimen>