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:paddingTop="8dip" >
<include layout="@layout/download_buttons" />
</LinearLayout>
<LinearLayout

View File

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

View File

@ -6,7 +6,7 @@
a:paddingBottom="8dip"
a:paddingLeft="8dip"
a:paddingRight="8dip" >
<TextView
a:id="@+id/download_song_title"
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,62 +4,64 @@
a:layout_width="fill_parent"
a:layout_height="wrap_content"
a:paddingBottom="8dip"
a:paddingTop="8dip" >
<ImageView
a:id="@+id/download_shuffle"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_shuffle" />
a:paddingTop="8dip"
a:paddingLeft="4dip"
a:paddingRight="4dip">
<com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton
a:id="@+id/download_previous"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_previous" />
<ImageView
a:id="@+id/download_start"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_play" />
<ImageView
a:id="@+id/download_shuffle"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_shuffle"/>
<ImageView
a:id="@+id/download_pause"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_pause" />
<com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton
a:id="@+id/download_previous"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_previous"/>
<ImageView
a:id="@+id/download_stop"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_stop" />
<ImageView
a:id="@+id/download_start"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_play"/>
<com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton
a:id="@+id/download_next"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_next" />
<ImageView
a:id="@+id/download_pause"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_pause"/>
<ImageView
a:id="@+id/download_repeat"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_repeat_off" />
<ImageView
a:id="@+id/download_stop"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_stop"/>
<com.thejoshwa.ultrasonic.androidapp.view.AutoRepeatButton
a:id="@+id/download_next"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_next"/>
<ImageView
a:id="@+id/download_repeat"
a:layout_width="0dip"
a:layout_height="wrap_content"
a:layout_weight="1"
a:focusable="true"
a:src="?attr/media_repeat_off"/>
</LinearLayout>

View File

@ -7,14 +7,14 @@
a:padding="10dp">
<ProgressBar
a:layout_width="wrap_content"
a:layout_height="fill_parent"
a:layout_marginRight="10dp"/>
a:layout_width="wrap_content"
a:layout_height="fill_parent"
a:layout_marginRight="10dp"/>
<TextView
a:id="@+id/progress_message"
a:text="@string/progress.wait"
a:layout_width="wrap_content"
a:layout_height="fill_parent"/>
a:id="@+id/progress_message"
a:text="@string/progress.wait"
a:layout_width="wrap_content"
a:layout_height="fill_parent"/>
</LinearLayout>

View File

@ -1,25 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<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
a:id="@+id/menu_item_share"
a:icon="?attr/share"
a:showAsAction="ifRoom|withText"
a:title="Share"/>
a:title="@string/download.share"/>
<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:title="@string/download.menu_equalizer"/>
<item
a:id="@+id/download_visualizer"
a:id="@+id/menu_item_visualizer"
a:showAsAction="never"
a:title="@string/download.menu_visualizer"/>
<item
a:id="@+id/download_jukebox"
a:id="@+id/menu_item_jukebox"
a:showAsAction="never"
a:title="@string/download.menu_jukebox_on"/>
<item
a:id="@+id/menu_screen_on_off"
a:id="@+id/menu_item_screen_on_off"
a:showAsAction="never"
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_year">One Year</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">
<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_year">One Year</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">
<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_year">One Year</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">
<item quantity="zero">No songs</item>

View File

@ -42,7 +42,6 @@ import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
@ -105,8 +104,6 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
private View stopButton;
private View startButton;
private ImageView repeatButton;
private ImageButton starImageButton;
private ImageButton saveImageButton;
private ScheduledExecutorService executorService;
private DownloadFile currentPlaying;
private Entry currentSong;
@ -121,6 +118,9 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
private boolean jukeboxAvailable;
private SilentBackgroundTask<Void> onProgressChangedTask;
LinearLayout visualizerViewLayout;
private MenuItem starMenuItem;
private MenuItem bookmarkMenuItem;
private MenuItem bookmarkRemoveMenuItem;
/**
* Called when the activity is first created.
@ -161,13 +161,8 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
startButton = findViewById(R.id.download_start);
final View shuffleButton = findViewById(R.id.download_shuffle);
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()
{
@ -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()
{
@Override
@ -461,159 +447,22 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
if (Util.isOffline(this))
{
starImageButton.setVisibility(View.GONE);
bookmarkImageButton.setVisibility(View.GONE);
if (starMenuItem != null)
{
starMenuItem.setEnabled(false);
}
if (bookmarkMenuItem != null)
{
bookmarkMenuItem.setEnabled(false);
}
if (bookmarkRemoveMenuItem != null)
{
bookmarkRemoveMenuItem.setEnabled(false);
}
}
starImageButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(final View view)
{
if (currentSong == null)
{
return;
}
final boolean isStarred = currentSong.getStarred();
final String id = currentSong.getId();
if (isStarred)
{
starImageButton.setImageDrawable(Util.getDrawableFromAttribute(SubsonicTabActivity.getInstance(), R.attr.star_hollow));
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);
equalizerAvailable = (downloadService != null) && (downloadService.getEqualizerController() != null);
@ -714,10 +563,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
visualizerView.setActive(downloadService != null && downloadService.getShowVisualization());
}
if (Util.isOffline(this))
{
saveImageButton.setVisibility(View.GONE);
}
invalidateOptionsMenu();
}
// Scroll to current playing/downloading.
@ -844,11 +690,20 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
{
super.onPrepareOptionsMenu(menu);
final MenuItem screenOption = menu.findItem(R.id.menu_screen_on_off);
final MenuItem jukeboxOption = menu.findItem(R.id.download_jukebox);
final MenuItem equalizerMenuItem = menu.findItem(R.id.download_equalizer);
final MenuItem visualizerMenuItem = menu.findItem(R.id.download_visualizer);
final MenuItem screenOption = menu.findItem(R.id.menu_item_screen_on_off);
final MenuItem jukeboxOption = menu.findItem(R.id.menu_item_jukebox);
final MenuItem equalizerMenuItem = menu.findItem(R.id.menu_item_equalizer);
final MenuItem visualizerMenuItem = menu.findItem(R.id.menu_item_visualizer);
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)
{
@ -873,6 +728,33 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
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 (screenOption != null)
@ -995,7 +877,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
getDownloadService().remove(song);
onDownloadListChanged();
return true;
case R.id.menu_screen_on_off:
case R.id.menu_item_screen_on_off:
if (getDownloadService().getKeepScreenOn())
{
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -1011,10 +893,10 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
getDownloadService().shuffle();
Util.toast(this, R.string.download_menu_shuffle_notification);
return true;
case R.id.download_equalizer:
case R.id.menu_item_equalizer:
startActivity(new Intent(DownloadActivity.this, EqualizerActivity.class));
return true;
case R.id.download_visualizer:
case R.id.menu_item_visualizer:
final boolean active = !visualizerView.isActive();
visualizerView.setActive(active);
@ -1030,10 +912,136 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
getDownloadService().setShowVisualization(visualizerView.isActive());
Util.toast(DownloadActivity.this, active ? R.string.download_visualizer_on : R.string.download_visualizer_off);
return true;
case R.id.download_jukebox:
case R.id.menu_item_jukebox:
final boolean jukeboxEnabled = !getDownloadService().isJukeboxEnabled();
getDownloadService().setJukeboxEnabled(jukeboxEnabled);
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;
case R.id.menu_item_share:
if (entry == null)
@ -1083,6 +1091,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
}
onSliderProgressChanged();
invalidateOptionsMenu();
}
private void savePlaylistInBackground(final String playlistName)
@ -1259,8 +1268,6 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
if (currentPlaying != null)
{
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());
albumTextView.setText(currentSong.getAlbum());
artistTextView.setText(currentSong.getArtist());