Move all download activity items to the menu, remove extra row of buttons

This commit is contained in:
Joshua Bahnsen 2013-12-21 14:06:58 -07:00
parent 2a061c0cc1
commit 8502125f80
11 changed files with 305 additions and 300 deletions

View File

@ -26,7 +26,6 @@
a:paddingBottom="8dip" a:paddingBottom="8dip"
a:paddingTop="8dip" > a:paddingTop="8dip" >
<include layout="@layout/download_buttons" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View File

@ -4,8 +4,6 @@
a:layout_height="fill_parent" a:layout_height="fill_parent"
a:orientation="vertical" > a:orientation="vertical" >
<include layout="@layout/download_buttons" />
<com.thejoshwa.ultrasonic.androidapp.util.MyViewFlipper <com.thejoshwa.ultrasonic.androidapp.util.MyViewFlipper
a:id="@+id/download_playlist_flipper" a:id="@+id/download_playlist_flipper"
a:layout_width="fill_parent" a:layout_width="fill_parent"

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:orientation="horizontal"
a:paddingBottom="8dip"
a:paddingTop="8dip" >
<ImageButton
a:id="@+id/download_toggle_list"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:background="@color/transparent"
a:src="?attr/media_toggle" />
<ImageButton
a:id="@+id/download_bookmark"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:background="@color/transparent"
a:src="?attr/bookmark" />
<ImageButton
a:id="@+id/download_remove_all"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:background="@color/transparent"
a:src="?attr/remove_all" />
<ImageButton
a:id="@+id/download_save_playlist"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:background="@color/transparent"
a:src="?attr/save" />
<ImageButton
a:id="@+id/download_star"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:background="@color/transparent"
a:src="?attr/star_hollow" />
</LinearLayout>

View File

@ -4,7 +4,9 @@
a:layout_width="fill_parent" a:layout_width="fill_parent"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:paddingBottom="8dip" a:paddingBottom="8dip"
a:paddingTop="8dip" > a:paddingTop="8dip"
a:paddingLeft="4dip"
a:paddingRight="4dip">
<ImageView <ImageView
a:id="@+id/download_shuffle" a:id="@+id/download_shuffle"
@ -12,7 +14,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:focusable="true" a:focusable="true"
a:src="?attr/media_shuffle" /> a:src="?attr/media_shuffle"/>
<com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton <com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton
a:id="@+id/download_previous" a:id="@+id/download_previous"
@ -20,7 +22,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:focusable="true" a:focusable="true"
a:src="?attr/media_previous" /> a:src="?attr/media_previous"/>
<ImageView <ImageView
a:id="@+id/download_start" a:id="@+id/download_start"
@ -28,7 +30,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:focusable="true" a:focusable="true"
a:src="?attr/media_play" /> a:src="?attr/media_play"/>
<ImageView <ImageView
a:id="@+id/download_pause" a:id="@+id/download_pause"
@ -36,7 +38,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:focusable="true" a:focusable="true"
a:src="?attr/media_pause" /> a:src="?attr/media_pause"/>
<ImageView <ImageView
a:id="@+id/download_stop" a:id="@+id/download_stop"
@ -44,7 +46,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:focusable="true" a:focusable="true"
a:src="?attr/media_stop" /> a:src="?attr/media_stop"/>
<com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton <com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton
a:id="@+id/download_next" a:id="@+id/download_next"
@ -52,7 +54,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:focusable="true" a:focusable="true"
a:src="?attr/media_next" /> a:src="?attr/media_next"/>
<ImageView <ImageView
a:id="@+id/download_repeat" a:id="@+id/download_repeat"
@ -60,6 +62,6 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" a:layout_weight="1"
a:focusable="true" a:focusable="true"
a:src="?attr/media_repeat_off" /> a:src="?attr/media_repeat_off"/>
</LinearLayout> </LinearLayout>

View File

@ -1,25 +1,55 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:a="http://schemas.android.com/apk/res/android" > <menu xmlns:a="http://schemas.android.com/apk/res/android" >
<item
a:id="@+id/menu_item_toggle_list"
a:icon="?attr/media_toggle"
a:showAsAction="always"
a:title="@string/download.toggle_playlist"/>
<item
a:id="@+id/menu_item_star"
a:icon="?attr/star_hollow"
a:showAsAction="ifRoom|withText"
a:title="@string/download.menu_star"/>
<item <item
a:id="@+id/menu_item_share" a:id="@+id/menu_item_share"
a:icon="?attr/share" a:icon="?attr/share"
a:showAsAction="ifRoom|withText" a:showAsAction="ifRoom|withText"
a:title="Share"/> a:title="@string/download.share"/>
<item <item
a:id="@+id/download_equalizer" a:id="@+id/menu_item_save_playlist"
a:icon="?attr/save"
a:showAsAction="ifRoom|withText"
a:title="@string/download.menu_save"/>
<item
a:id="@+id/menu_item_clear_playlist"
a:icon="?attr/remove_all"
a:showAsAction="ifRoom|withText"
a:title="@string/download.menu_clear_playlist"/>
<item
a:id="@+id/menu_item_bookmark_set"
a:icon="?attr/bookmark"
a:showAsAction="ifRoom|withText"
a:title="@string/download.bookmark_set"/>
<item
a:id="@+id/menu_item_bookmark_delete"
a:icon="?attr/bookmark"
a:showAsAction="ifRoom|withText"
a:title="@string/download.bookmark_delete"/>
<item
a:id="@+id/menu_item_equalizer"
a:showAsAction="never" a:showAsAction="never"
a:title="@string/download.menu_equalizer"/> a:title="@string/download.menu_equalizer"/>
<item <item
a:id="@+id/download_visualizer" a:id="@+id/menu_item_visualizer"
a:showAsAction="never" a:showAsAction="never"
a:title="@string/download.menu_visualizer"/> a:title="@string/download.menu_visualizer"/>
<item <item
a:id="@+id/download_jukebox" a:id="@+id/menu_item_jukebox"
a:showAsAction="never" a:showAsAction="never"
a:title="@string/download.menu_jukebox_on"/> a:title="@string/download.menu_jukebox_on"/>
<item <item
a:id="@+id/menu_screen_on_off" a:id="@+id/menu_item_screen_on_off"
a:showAsAction="never" a:showAsAction="never"
a:title="@string/download.menu_screen_on"/> a:title="@string/download.menu_screen_on"/>

View File

@ -372,6 +372,12 @@
<string name="settings.share_one_month">One Month</string> <string name="settings.share_one_month">One Month</string>
<string name="settings.share_one_year">One Year</string> <string name="settings.share_one_year">One Year</string>
<string name="no_expiration">No Expiration</string> <string name="no_expiration">No Expiration</string>
<string name="download.share">Share</string>
<string name="download.toggle_playlist">Toggle Playlist</string>
<string name="download.bookmark_set">Set Bookmark</string>
<string name="download.bookmark_delete">Delete Bookmark</string>
<string name="download.menu_star">Star</string>
<string name="download.menu_clear_playlist">Clear Playlist</string>
<plurals name="select_album_n_songs"> <plurals name="select_album_n_songs">
<item quantity="zero">Aucun titre</item> <item quantity="zero">Aucun titre</item>

View File

@ -372,6 +372,12 @@
<string name="settings.share_one_month">One Month</string> <string name="settings.share_one_month">One Month</string>
<string name="settings.share_one_year">One Year</string> <string name="settings.share_one_year">One Year</string>
<string name="no_expiration">No Expiration</string> <string name="no_expiration">No Expiration</string>
<string name="download.share">Share</string>
<string name="download.toggle_playlist">Toggle Playlist</string>
<string name="download.bookmark_set">Set Bookmark</string>
<string name="download.bookmark_delete">Delete Bookmark</string>
<string name="download.menu_star">Star</string>
<string name="download.menu_clear_playlist">Clear Playlist</string>
<plurals name="select_album_n_songs"> <plurals name="select_album_n_songs">
<item quantity="zero">Nincsenek dalok</item> <item quantity="zero">Nincsenek dalok</item>

View File

@ -372,6 +372,12 @@
<string name="settings.share_one_month">One Month</string> <string name="settings.share_one_month">One Month</string>
<string name="settings.share_one_year">One Year</string> <string name="settings.share_one_year">One Year</string>
<string name="no_expiration">No Expiration</string> <string name="no_expiration">No Expiration</string>
<string name="download.share">Share</string>
<string name="download.toggle_playlist">Toggle Playlist</string>
<string name="download.bookmark_set">Set Bookmark</string>
<string name="download.bookmark_delete">Delete Bookmark</string>
<string name="download.menu_star">Star</string>
<string name="download.menu_clear_playlist">Clear Playlist</string>
<plurals name="select_album_n_songs"> <plurals name="select_album_n_songs">
<item quantity="zero">No songs</item> <item quantity="zero">No songs</item>

View File

@ -42,7 +42,6 @@ import android.view.WindowManager;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListAdapter; import android.widget.ListAdapter;
@ -105,8 +104,6 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
private View stopButton; private View stopButton;
private View startButton; private View startButton;
private ImageView repeatButton; private ImageView repeatButton;
private ImageButton starImageButton;
private ImageButton saveImageButton;
private ScheduledExecutorService executorService; private ScheduledExecutorService executorService;
private DownloadFile currentPlaying; private DownloadFile currentPlaying;
private Entry currentSong; private Entry currentSong;
@ -121,6 +118,9 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
private boolean jukeboxAvailable; private boolean jukeboxAvailable;
private SilentBackgroundTask<Void> onProgressChangedTask; private SilentBackgroundTask<Void> onProgressChangedTask;
LinearLayout visualizerViewLayout; LinearLayout visualizerViewLayout;
private MenuItem starMenuItem;
private MenuItem bookmarkMenuItem;
private MenuItem bookmarkRemoveMenuItem;
/** /**
* Called when the activity is first created. * Called when the activity is first created.
@ -161,13 +161,8 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
startButton = findViewById(R.id.download_start); startButton = findViewById(R.id.download_start);
final View shuffleButton = findViewById(R.id.download_shuffle); final View shuffleButton = findViewById(R.id.download_shuffle);
repeatButton = (ImageView) findViewById(R.id.download_repeat); repeatButton = (ImageView) findViewById(R.id.download_repeat);
starImageButton = (ImageButton) findViewById(R.id.download_star);
ImageButton bookmarkImageButton = (ImageButton) findViewById(R.id.download_bookmark);
ImageButton removeAllImageButton = (ImageButton) findViewById(R.id.download_remove_all);
saveImageButton = (ImageButton) findViewById(R.id.download_save_playlist);
visualizerViewLayout = (LinearLayout) findViewById(R.id.download_visualizer_view_layout);
final ImageButton toggleListButton = (ImageButton) findViewById(R.id.download_toggle_list); visualizerViewLayout = (LinearLayout) findViewById(R.id.download_visualizer_view_layout);
View.OnTouchListener touchListener = new View.OnTouchListener() View.OnTouchListener touchListener = new View.OnTouchListener()
{ {
@ -382,15 +377,6 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
} }
}); });
toggleListButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View view)
{
toggleFullScreenAlbumArt();
}
});
progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
{ {
@Override @Override
@ -461,158 +447,21 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
if (Util.isOffline(this)) if (Util.isOffline(this))
{ {
starImageButton.setVisibility(View.GONE); if (starMenuItem != null)
bookmarkImageButton.setVisibility(View.GONE); {
starMenuItem.setEnabled(false);
} }
starImageButton.setOnClickListener(new View.OnClickListener() if (bookmarkMenuItem != null)
{ {
@Override bookmarkMenuItem.setEnabled(false);
public void onClick(final View view)
{
if (currentSong == null)
{
return;
} }
final boolean isStarred = currentSong.getStarred(); if (bookmarkRemoveMenuItem != null)
final String id = currentSong.getId();
if (isStarred)
{ {
starImageButton.setImageDrawable(Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_hollow)); bookmarkRemoveMenuItem.setEnabled(false);
currentSong.setStarred(false);
}
else
{
starImageButton.setImageDrawable(Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_full));
currentSong.setStarred(true);
}
new Thread(new Runnable()
{
@Override
public void run()
{
final MusicService musicService = MusicServiceFactory.getMusicService(DownloadActivity.this);
try
{
if (isStarred)
{
musicService.unstar(id, null, null, DownloadActivity.this, null);
}
else
{
musicService.star(id, null, null, DownloadActivity.this, null);
} }
} }
catch (Exception e)
{
Log.e(TAG, e.getMessage(), e);
}
}
}).start();
}
});
bookmarkImageButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View view)
{
if (currentSong == null)
{
return;
}
final String id = currentSong.getId();
final int playerPosition = getDownloadService().getPlayerPosition();
currentSong.setBookmarkPosition(playerPosition);
String bookmarkTime = Util.formatTotalDuration(playerPosition, true);
new Thread(new Runnable()
{
@Override
public void run()
{
final MusicService musicService = MusicServiceFactory.getMusicService(DownloadActivity.this);
try
{
musicService.createBookmark(id, playerPosition, DownloadActivity.this, null);
}
catch (Exception e)
{
Log.e(TAG, e.getMessage(), e);
}
}
}).start();
String msg = getResources().getString(R.string.download_bookmark_set_at_position, bookmarkTime);
Util.toast(DownloadActivity.this, msg);
}
});
bookmarkImageButton.setOnLongClickListener(new View.OnLongClickListener()
{
@Override
public boolean onLongClick(final View view)
{
if (currentSong == null)
{
return true;
}
final String id = currentSong.getId();
currentSong.setBookmarkPosition(0);
new Thread(new Runnable()
{
@Override
public void run()
{
final MusicService musicService = MusicServiceFactory.getMusicService(DownloadActivity.this);
try
{
musicService.deleteBookmark(id, DownloadActivity.this, null);
}
catch (Exception e)
{
Log.e(TAG, e.getMessage(), e);
}
}
}).start();
Util.toast(DownloadActivity.this, R.string.download_bookmark_removed);
return true;
}
});
removeAllImageButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View view)
{
getDownloadService().setShufflePlayEnabled(false);
getDownloadService().clear();
onDownloadListChanged();
}
});
saveImageButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View view)
{
showDialog(DIALOG_SAVE_PLAYLIST);
}
});
visualizerAvailable = (downloadService != null) && (downloadService.getVisualizerController() != null); visualizerAvailable = (downloadService != null) && (downloadService.getVisualizerController() != null);
equalizerAvailable = (downloadService != null) && (downloadService.getEqualizerController() != null); equalizerAvailable = (downloadService != null) && (downloadService.getEqualizerController() != null);
@ -714,10 +563,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
visualizerView.setActive(downloadService != null && downloadService.getShowVisualization()); visualizerView.setActive(downloadService != null && downloadService.getShowVisualization());
} }
if (Util.isOffline(this)) invalidateOptionsMenu();
{
saveImageButton.setVisibility(View.GONE);
}
} }
// Scroll to current playing/downloading. // Scroll to current playing/downloading.
@ -844,11 +690,20 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
{ {
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
final MenuItem screenOption = menu.findItem(R.id.menu_screen_on_off); final MenuItem screenOption = menu.findItem(R.id.menu_item_screen_on_off);
final MenuItem jukeboxOption = menu.findItem(R.id.download_jukebox); final MenuItem jukeboxOption = menu.findItem(R.id.menu_item_jukebox);
final MenuItem equalizerMenuItem = menu.findItem(R.id.download_equalizer); final MenuItem equalizerMenuItem = menu.findItem(R.id.menu_item_equalizer);
final MenuItem visualizerMenuItem = menu.findItem(R.id.download_visualizer); final MenuItem visualizerMenuItem = menu.findItem(R.id.menu_item_visualizer);
final MenuItem shareMenuItem = menu.findItem(R.id.menu_item_share); final MenuItem shareMenuItem = menu.findItem(R.id.menu_item_share);
final MenuItem savePlaylistMenuItem = menu.findItem(R.id.menu_item_save_playlist);
starMenuItem = menu.findItem(R.id.menu_item_star);
bookmarkMenuItem = menu.findItem(R.id.menu_item_bookmark_set);
bookmarkRemoveMenuItem = menu.findItem(R.id.menu_item_bookmark_delete);
if (Util.isOffline(this))
{
savePlaylistMenuItem.setEnabled(false);
}
if (equalizerMenuItem != null) if (equalizerMenuItem != null)
{ {
@ -873,6 +728,33 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
if (downloadService != null) if (downloadService != null)
{ {
DownloadFile downloadFile = downloadService.getCurrentPlaying();
if (downloadFile != null)
{
currentSong = downloadFile.getSong();
}
if (currentSong != null)
{
final Drawable starDrawable = currentSong.getStarred() ? Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_full) : Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_hollow);
if (starMenuItem != null)
{
starMenuItem.setIcon(starDrawable);
}
}
else
{
final Drawable starDrawable = Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_hollow);
if (starMenuItem != null)
{
starMenuItem.setIcon(starDrawable);
}
}
if (downloadService.getKeepScreenOn()) if (downloadService.getKeepScreenOn())
{ {
if (screenOption != null) if (screenOption != null)
@ -995,7 +877,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
getDownloadService().remove(song); getDownloadService().remove(song);
onDownloadListChanged(); onDownloadListChanged();
return true; return true;
case R.id.menu_screen_on_off: case R.id.menu_item_screen_on_off:
if (getDownloadService().getKeepScreenOn()) if (getDownloadService().getKeepScreenOn())
{ {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -1011,10 +893,10 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
getDownloadService().shuffle(); getDownloadService().shuffle();
Util.toast(this, R.string.download_menu_shuffle_notification); Util.toast(this, R.string.download_menu_shuffle_notification);
return true; return true;
case R.id.download_equalizer: case R.id.menu_item_equalizer:
startActivity(new Intent(DownloadActivity.this, EqualizerActivity.class)); startActivity(new Intent(DownloadActivity.this, EqualizerActivity.class));
return true; return true;
case R.id.download_visualizer: case R.id.menu_item_visualizer:
final boolean active = !visualizerView.isActive(); final boolean active = !visualizerView.isActive();
visualizerView.setActive(active); visualizerView.setActive(active);
@ -1030,10 +912,136 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
getDownloadService().setShowVisualization(visualizerView.isActive()); getDownloadService().setShowVisualization(visualizerView.isActive());
Util.toast(DownloadActivity.this, active ? R.string.download_visualizer_on : R.string.download_visualizer_off); Util.toast(DownloadActivity.this, active ? R.string.download_visualizer_on : R.string.download_visualizer_off);
return true; return true;
case R.id.download_jukebox: case R.id.menu_item_jukebox:
final boolean jukeboxEnabled = !getDownloadService().isJukeboxEnabled(); final boolean jukeboxEnabled = !getDownloadService().isJukeboxEnabled();
getDownloadService().setJukeboxEnabled(jukeboxEnabled); getDownloadService().setJukeboxEnabled(jukeboxEnabled);
Util.toast(DownloadActivity.this, jukeboxEnabled ? R.string.download_jukebox_on : R.string.download_jukebox_off, false); Util.toast(DownloadActivity.this, jukeboxEnabled ? R.string.download_jukebox_on : R.string.download_jukebox_off, false);
return true;
case R.id.menu_item_toggle_list:
toggleFullScreenAlbumArt();
return true;
case R.id.menu_item_clear_playlist:
getDownloadService().setShufflePlayEnabled(false);
getDownloadService().clear();
onDownloadListChanged();
return true;
case R.id.menu_item_save_playlist:
if (getDownloadService().getSongs().size() > 0)
{
showDialog(DIALOG_SAVE_PLAYLIST);
}
return true;
case R.id.menu_item_star:
if (currentSong == null)
{
return true;
}
final boolean isStarred = currentSong.getStarred();
final String id = currentSong.getId();
if (isStarred)
{
starMenuItem.setIcon(Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_hollow));
currentSong.setStarred(false);
}
else
{
starMenuItem.setIcon(Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_full));
currentSong.setStarred(true);
}
new Thread(new Runnable()
{
@Override
public void run()
{
final MusicService musicService = MusicServiceFactory.getMusicService(DownloadActivity.this);
try
{
if (isStarred)
{
musicService.unstar(id, null, null, DownloadActivity.this, null);
}
else
{
musicService.star(id, null, null, DownloadActivity.this, null);
}
}
catch (Exception e)
{
Log.e(TAG, e.getMessage(), e);
}
}
}).start();
return true;
case R.id.menu_item_bookmark_set:
if (currentSong == null)
{
return true;
}
final String songId = currentSong.getId();
final int playerPosition = getDownloadService().getPlayerPosition();
currentSong.setBookmarkPosition(playerPosition);
String bookmarkTime = Util.formatTotalDuration(playerPosition, true);
new Thread(new Runnable()
{
@Override
public void run()
{
final MusicService musicService = MusicServiceFactory.getMusicService(DownloadActivity.this);
try
{
musicService.createBookmark(songId, playerPosition, DownloadActivity.this, null);
}
catch (Exception e)
{
Log.e(TAG, e.getMessage(), e);
}
}
}).start();
String msg = getResources().getString(R.string.download_bookmark_set_at_position, bookmarkTime);
Util.toast(DownloadActivity.this, msg);
return true;
case R.id.menu_item_bookmark_delete:
if (currentSong == null)
{
return true;
}
final String bookmarkSongId = currentSong.getId();
currentSong.setBookmarkPosition(0);
new Thread(new Runnable()
{
@Override
public void run()
{
final MusicService musicService = MusicServiceFactory.getMusicService(DownloadActivity.this);
try
{
musicService.deleteBookmark(bookmarkSongId, DownloadActivity.this, null);
}
catch (Exception e)
{
Log.e(TAG, e.getMessage(), e);
}
}
}).start();
Util.toast(DownloadActivity.this, R.string.download_bookmark_removed);
return true; return true;
case R.id.menu_item_share: case R.id.menu_item_share:
if (entry == null) if (entry == null)
@ -1083,6 +1091,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
} }
onSliderProgressChanged(); onSliderProgressChanged();
invalidateOptionsMenu();
} }
private void savePlaylistInBackground(final String playlistName) private void savePlaylistInBackground(final String playlistName)
@ -1259,8 +1268,6 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
if (currentPlaying != null) if (currentPlaying != null)
{ {
currentSong = currentPlaying.getSong(); currentSong = currentPlaying.getSong();
final Drawable starDrawable = currentSong.getStarred() ? Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_full) : Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_hollow);
starImageButton.setImageDrawable(starDrawable);
songTitleTextView.setText(currentSong.getTitle()); songTitleTextView.setText(currentSong.getTitle());
albumTextView.setText(currentSong.getAlbum()); albumTextView.setText(currentSong.getAlbum());
artistTextView.setText(currentSong.getArtist()); artistTextView.setText(currentSong.getArtist());