aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-31 10:04:46 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-31 10:04:46 -0700
commit5ae23c33d575eefeaefac934b8f575a83bf2f9de (patch)
tree873a053006ca86216ef0f77292770f7a4f7342bd
parentd74b188f3cf3a5e76905716497e0a6a9482f95f3 (diff)
downloaddsub-5ae23c33d575eefeaefac934b8f575a83bf2f9de.tar.gz
dsub-5ae23c33d575eefeaefac934b8f575a83bf2f9de.tar.bz2
dsub-5ae23c33d575eefeaefac934b8f575a83bf2f9de.zip
Add rating/bookmark selected logic
-rw-r--r--res/drawable-hdpi/ic_action_rating_good_selected.pngbin0 -> 921 bytes
-rw-r--r--res/drawable-mdpi/ic_action_rating_good_selected.pngbin0 -> 581 bytes
-rw-r--r--res/drawable-xhdpi/ic_action_rating_good_selected.pngbin0 -> 1176 bytes
-rw-r--r--res/drawable-xxhdpi/ic_action_rating_good_selected.pngbin0 -> 1915 bytes
-rw-r--r--src/github/daneren2005/dsub/domain/MusicDirectory.java4
-rw-r--r--src/github/daneren2005/dsub/fragments/NowPlayingFragment.java47
-rw-r--r--src/github/daneren2005/dsub/util/Util.java10
7 files changed, 59 insertions, 2 deletions
diff --git a/res/drawable-hdpi/ic_action_rating_good_selected.png b/res/drawable-hdpi/ic_action_rating_good_selected.png
new file mode 100644
index 00000000..34d53153
--- /dev/null
+++ b/res/drawable-hdpi/ic_action_rating_good_selected.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_action_rating_good_selected.png b/res/drawable-mdpi/ic_action_rating_good_selected.png
new file mode 100644
index 00000000..97d279be
--- /dev/null
+++ b/res/drawable-mdpi/ic_action_rating_good_selected.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_action_rating_good_selected.png b/res/drawable-xhdpi/ic_action_rating_good_selected.png
new file mode 100644
index 00000000..c6770221
--- /dev/null
+++ b/res/drawable-xhdpi/ic_action_rating_good_selected.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_action_rating_good_selected.png b/res/drawable-xxhdpi/ic_action_rating_good_selected.png
new file mode 100644
index 00000000..bb444806
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_action_rating_good_selected.png
Binary files differ
diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java
index 1caf77cf..a738f9bf 100644
--- a/src/github/daneren2005/dsub/domain/MusicDirectory.java
+++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java
@@ -400,8 +400,8 @@ public class MusicDirectory implements Serializable {
this.starred = starred;
}
- public Integer getRating() {
- return rating;
+ public int getRating() {
+ return rating == null ? 0 : rating;
}
public void setRating(Integer rating) {
this.rating = rating;
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
index 868cdef1..b24fa7f2 100644
--- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
+++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java
@@ -24,6 +24,8 @@ import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.content.res.TypedArray;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
@@ -404,6 +406,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
@Override
public void onClick(View view) {
createBookmark();
+ bookmarkButton.setImageResource(R.drawable.ic_menu_bookmark_selected);
}
});
@@ -412,6 +415,14 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
public void onClick(View view) {
Entry entry = getDownloadService().getCurrentPlaying().getSong();
setRating(entry, 1);
+ rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_selected);
+
+ // Make sure good rating is blank
+ if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_dark);
+ } else {
+ rateGoodButton.setImageResource(Util.getAttribute(context, R.attr.rating_good));
+ }
}
});
rateGoodButton.setOnClickListener(new View.OnClickListener() {
@@ -419,6 +430,14 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
public void onClick(View view) {
Entry entry = getDownloadService().getCurrentPlaying().getSong();
setRating(entry, 5);
+ rateGoodButton.setImageResource(R.drawable.ic_action_rating_good_selected);
+
+ // Make sure bad rating is blank
+ if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ rateBadButton.setImageResource(R.drawable.ic_action_rating_bad_dark);
+ } else {
+ rateBadButton.setImageResource(Util.getAttribute(context, R.attr.rating_bad));
+ }
}
});
@@ -1155,6 +1174,34 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis
getImageLoader().loadImage(albumArtImageView, song, true, true);
starButton.setImageResource(song.isStarred() ? android.R.drawable.btn_star_big_on : android.R.drawable.btn_star_big_off);
setSubtitle(context.getResources().getString(R.string.download_playing_out_of, currentPlayingIndex, currentPlayingSize));
+
+ int badRating, goodRating, bookmark;
+ if(song.getRating() == 1) {
+ badRating = R.drawable.ic_action_rating_bad_selected;
+ } else if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ badRating = R.drawable.ic_action_rating_bad_dark;
+ } else {
+ badRating = Util.getAttribute(context, R.attr.rating_bad);
+ }
+ rateBadButton.setImageResource(badRating);
+
+ if(song.getRating() == 5) {
+ goodRating = R.drawable.ic_action_rating_good_selected;
+ } else if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ goodRating = R.drawable.ic_action_rating_good_dark;
+ } else {
+ goodRating = Util.getAttribute(context, R.attr.rating_good);
+ }
+ rateGoodButton.setImageResource(goodRating);
+
+ if(song.getBookmark() != null) {
+ bookmark = R.drawable.ic_menu_bookmark_selected;
+ } else if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ bookmark = R.drawable.ic_menu_bookmark_dark;
+ } else {
+ bookmark = Util.getAttribute(context, R.attr.bookmark);
+ }
+ bookmarkButton.setImageResource(bookmark);
} else {
songTitleTextView.setText(null);
getImageLoader().loadImage(albumArtImageView, null, true, false);
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index c1d026d4..24458eb3 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -30,6 +30,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
@@ -1089,6 +1090,15 @@ public final class Util {
}
}
+ public static int getAttribute(Context context, int attr) {
+ int res;
+ int[] attrs = new int[] {attr};
+ TypedArray typedArray = context.obtainStyledAttributes(attrs);
+ res = typedArray.getResourceId(0, 0);
+ typedArray.recycle();
+ return res;
+ }
+
public static void registerMediaButtonEventReceiver(Context context) {
// Only do it if enabled in the settings.