aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorKurt Hardin <kurthardin.dev@gmail.com>2012-09-25 11:48:55 -0700
committerKurt Hardin <kurthardin.dev@gmail.com>2012-09-25 11:48:55 -0700
commit2be1e2632966490e9d1b0cde7bb51f1951710794 (patch)
tree85a7684f8d53435fd584c5c6e6e00d49f0e08907 /subsonic-android/src
parent4573e156e0026348e7cdaaa1747d633b5fef3ef7 (diff)
parentd2ef30d252b8af7dd955f1d6c21d2f8f7475ec0c (diff)
downloaddsub-2be1e2632966490e9d1b0cde7bb51f1951710794.tar.gz
dsub-2be1e2632966490e9d1b0cde7bb51f1951710794.tar.bz2
dsub-2be1e2632966490e9d1b0cde7bb51f1951710794.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java21
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java112
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java62
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java266
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java76
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java61
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java82
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java144
8 files changed, 385 insertions, 439 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
index a657b7eb..baee66fa 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/DownloadActivity.java
@@ -40,9 +40,6 @@ import android.view.Display;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -58,6 +55,9 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ViewFlipper;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.view.MenuInflater;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.PlayerState;
@@ -121,7 +121,10 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setTitle("Now Playing");
setContentView(R.layout.download);
+
+ getSupportActionBar().hide();
WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
@@ -487,7 +490,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
+ MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.nowplaying, menu);
return true;
}
@@ -508,13 +511,13 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
}
@Override
- public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
+ public void onCreateContextMenu(android.view.ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
if (view == playlistView) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
DownloadFile downloadFile = (DownloadFile) playlistView.getItemAtPosition(info.position);
- MenuInflater inflater = getMenuInflater();
+ android.view.MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.nowplaying_context, menu);
if (downloadFile.getSong().getParent() == null) {
@@ -528,7 +531,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
}
@Override
- public boolean onContextItemSelected(MenuItem menuItem) {
+ public boolean onContextItemSelected(android.view.MenuItem menuItem) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
DownloadFile downloadFile = (DownloadFile) playlistView.getItemAtPosition(info.position);
return menuItemSelected(menuItem.getItemId(), downloadFile) || super.onContextItemSelected(menuItem);
@@ -643,8 +646,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
buttonBarFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_down_in));
buttonBarFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_down_out));
buttonBarFlipper.setDisplayedChild(0);
-
-
+ getSupportActionBar().hide();
} else {
playlistFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_in));
playlistFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_out));
@@ -652,6 +654,7 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
buttonBarFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_in));
buttonBarFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.push_up_out));
buttonBarFlipper.setDisplayedChild(1);
+ getSupportActionBar().show();
}
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
index e5958e57..2fab77e7 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
@@ -28,6 +28,9 @@ import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.MergeAdapter;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.util.FileUtil;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.view.MenuInflater;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -35,7 +38,6 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.ContextMenu;
import android.view.LayoutInflater;
-import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageButton;
@@ -51,8 +53,6 @@ public class MainActivity extends SubsonicTabActivity {
private static final int MENU_ITEM_SERVER_3 = 103;
private static final int MENU_ITEM_OFFLINE = 104;
- private String theme;
-
private static boolean infoDialogDisplayed;
/**
@@ -115,63 +115,48 @@ public class MainActivity extends SubsonicTabActivity {
}
}
});
-
- // Title: Subsonic
+
+ // Title: Subsonic
setTitle(R.string.common_appname);
+ showInfoDialog();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.main, menu);
+ return true;
+ }
- // Button 1: shuffle
- ImageButton actionShuffleButton = (ImageButton)findViewById(R.id.action_button_1);
- actionShuffleButton.setImageResource(R.drawable.action_shuffle);
- actionShuffleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(MainActivity.this, DownloadActivity.class);
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ Intent intent;
+ switch (item.getItemId()) {
+ case R.id.menu_shuffle:
+ intent = new Intent(MainActivity.this, DownloadActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
Util.startActivityWithoutTransition(MainActivity.this, intent);
- }
- });
-
- // Button 2: search
- ImageButton actionSearchButton = (ImageButton)findViewById(R.id.action_button_2);
- actionSearchButton.setImageResource(R.drawable.action_search);
- actionSearchButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(MainActivity.this, SearchActivity.class);
+ return true;
+ case R.id.menu_search:
+ intent = new Intent(MainActivity.this, SearchActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_REQUEST_SEARCH, true);
Util.startActivityWithoutTransition(MainActivity.this, intent);
- }
- });
-
- // Button 3: Help
- ImageButton actionHelpButton = (ImageButton)findViewById(R.id.action_button_3);
- actionHelpButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(MainActivity.this, HelpActivity.class));
- }
- });
-
- // Button 4: Settings
- ImageButton actionSettingsButton = (ImageButton)findViewById(R.id.action_button_4);
- actionSettingsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(MainActivity.this, SettingsActivity.class));
-
- /*LayoutInflater inflater = (LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.overflow_menu, null, false), 100, 100, true);
- pw.showAsDropDown(findViewById(R.id.action_button_4));*/
-
- /*PopupWindow window = new PopupWindow(findViewById(R.layout.overflow_menu));
- window.showAsDropDown(findViewById(R.id.action_button_2));*/
- }
- });
-
- // Remember the current theme.
- theme = Util.getTheme(this);
+ return true;
+ case R.id.menu_exit:
+ intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
+ Util.startActivityWithoutTransition(this, intent);
+ return true;
+ case R.id.menu_settings:
+ startActivity(new Intent(this, SettingsActivity.class));
+ return true;
+ case R.id.menu_help:
+ startActivity(new Intent(this, HelpActivity.class));
+ return true;
+ }
- showInfoDialog();
+ return false;
}
private void loadSettings() {
@@ -187,21 +172,16 @@ public class MainActivity extends SubsonicTabActivity {
@Override
protected void onResume() {
super.onResume();
-
- // Restart activity if theme has changed.
- if (theme != null && !theme.equals(Util.getTheme(this))) {
- restart();
- }
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
- MenuItem menuItem1 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_1, MENU_ITEM_SERVER_1, Util.getServerName(this, 1));
- MenuItem menuItem2 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_2, MENU_ITEM_SERVER_2, Util.getServerName(this, 2));
- MenuItem menuItem3 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_3, MENU_ITEM_SERVER_3, Util.getServerName(this, 3));
- MenuItem menuItem4 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_OFFLINE, MENU_ITEM_OFFLINE, Util.getServerName(this, 0));
+ android.view.MenuItem menuItem1 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_1, MENU_ITEM_SERVER_1, Util.getServerName(this, 1));
+ android.view.MenuItem menuItem2 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_2, MENU_ITEM_SERVER_2, Util.getServerName(this, 2));
+ android.view.MenuItem menuItem3 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_SERVER_3, MENU_ITEM_SERVER_3, Util.getServerName(this, 3));
+ android.view.MenuItem menuItem4 = menu.add(MENU_GROUP_SERVER, MENU_ITEM_OFFLINE, MENU_ITEM_OFFLINE, Util.getServerName(this, 0));
menu.setGroupCheckable(MENU_GROUP_SERVER, true, true);
menu.setHeaderTitle(R.string.main_select_server);
@@ -222,7 +202,7 @@ public class MainActivity extends SubsonicTabActivity {
}
@Override
- public boolean onContextItemSelected(MenuItem menuItem) {
+ public boolean onContextItemSelected(android.view.MenuItem menuItem) {
switch (menuItem.getItemId()) {
case MENU_ITEM_OFFLINE:
setActiveServer(0);
@@ -255,12 +235,6 @@ public class MainActivity extends SubsonicTabActivity {
}
}
- private void restart() {
- Intent intent = new Intent(this, MainActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- Util.startActivityWithoutTransition(this, intent);
- }
-
private void exit() {
stopService(new Intent(this, DownloadServiceImpl.class));
finish();
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java
index 3ea0cabf..4b9d844f 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SearchActivity.java
@@ -36,6 +36,7 @@ import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.net.Uri;
+import com.actionbarsherlock.view.Menu;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.MusicDirectory;
@@ -134,39 +135,38 @@ public class SearchActivity extends SubsonicTabActivity {
}
});
registerForContextMenu(list);
+ onNewIntent(getIntent());
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.search, menu);
+ return true;
+ }
- // Button 1: gone
- findViewById(R.id.action_button_1).setVisibility(View.GONE);
-
- // Button 2: search
- final ImageButton actionSearchButton = (ImageButton)findViewById(R.id.action_button_2);
- actionSearchButton.setImageResource(R.drawable.action_search);
- actionSearchButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- onSearchRequested();
- }
- });
-
- // Button 3: Help
- ImageButton actionHelpButton = (ImageButton)findViewById(R.id.action_button_3);
- actionHelpButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SearchActivity.this, HelpActivity.class));
- }
- });
-
- // Button 4: Settings
- ImageButton actionSettingsButton = (ImageButton)findViewById(R.id.action_button_4);
- actionSettingsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SearchActivity.this, SettingsActivity.class));
- }
- });
+ @Override
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ Intent intent;
+ switch (item.getItemId()) {
+ case R.id.menu_search:
+ onSearchRequested();
+ return true;
+ case R.id.menu_exit:
+ intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
+ Util.startActivityWithoutTransition(this, intent);
+ return true;
+ case R.id.menu_settings:
+ startActivity(new Intent(this, SettingsActivity.class));
+ return true;
+ case R.id.menu_help:
+ startActivity(new Intent(this, HelpActivity.class));
+ return true;
+ }
- onNewIntent(getIntent());
+ return false;
}
@Override
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
index 108dcf9c..b0c47a5e 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
@@ -34,6 +34,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
+import com.actionbarsherlock.view.Menu;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.DownloadFile;
@@ -55,17 +56,13 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
private ListView entryList;
private View footer;
private View emptyView;
- private Button selectButton;
- private Button playNowButton;
- private Button playShuffledButton;
- private Button playLastButton;
- private Button pinButton;
- private Button unpinButton;
- private Button deleteButton;
+ private boolean hideButtons = false;
+ private com.actionbarsherlock.view.MenuItem selectAll;
+ private com.actionbarsherlock.view.MenuItem cache;
+ private com.actionbarsherlock.view.MenuItem delete;
+ private com.actionbarsherlock.view.MenuItem playLast;
private Button moreButton;
- private ImageView coverArtView;
private boolean licenseValid;
- private ImageButton playAllButton;
/**
* Called when the activity is first created.
@@ -91,77 +88,16 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
Util.startActivityWithoutTransition(SelectAlbumActivity.this, intent);
} else if (entry.isVideo()) {
playVideo(entry);
- } else {
- enableButtons();
}
}
}
});
-
- coverArtView = (ImageView) findViewById(R.id.actionbar_home_icon);
- selectButton = (Button) findViewById(R.id.select_album_select);
- playNowButton = (Button) findViewById(R.id.select_album_play_now);
- playShuffledButton = (Button) findViewById(R.id.select_album_play_shuffled);
- playLastButton = (Button) findViewById(R.id.select_album_play_last);
- pinButton = (Button) findViewById(R.id.select_album_pin);
- unpinButton = (Button) findViewById(R.id.select_album_unpin);
- deleteButton = (Button) findViewById(R.id.select_album_delete);
+
moreButton = (Button) footer.findViewById(R.id.select_album_more);
emptyView = findViewById(R.id.select_album_empty);
- selectButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- selectAllOrNone();
- }
- });
- playNowButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- download(false, false, true, false, false);
- selectAll(false, false);
- }
- });
- playShuffledButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- download(false, false, true, false, true);
- selectAll(false, false);
- }
- });
- playLastButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- download(true, false, false, false, false);
- selectAll(false, false);
- }
- });
- pinButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- download(true, true, false, false, false);
- selectAll(false, false);
- }
- });
- unpinButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- unpin();
- selectAll(false, false);
- }
- });
- deleteButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- delete();
- selectAll(false, false);
- }
- });
-
registerForContextMenu(entryList);
- enableButtons();
-
String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID);
String name = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME);
String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID);
@@ -177,47 +113,80 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
} else {
getMusicDirectory(id, name);
}
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.select_album, menu);
+ selectAll = menu.findItem(R.id.menu_select);
+ cache = menu.findItem(R.id.menu_cache);
+ delete = menu.findItem(R.id.menu_delete);
+ playLast = menu.findItem(R.id.menu_play_last);
+ if(hideButtons) {
+ selectAll.setVisible(false);
+ cache.setVisible(false);
+ delete.setVisible(false);
+ playLast.setVisible(false);
+ hideButtons = false;
+ }
+ return true;
+ }
- // Button 1: play all
- playAllButton = (ImageButton) findViewById(R.id.action_button_1);
- playAllButton.setImageResource(R.drawable.action_play_all);
- playAllButton.setVisibility(View.GONE);
- playAllButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- playAll(false);
- }
- });
+ @Override
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ Intent intent;
+ switch (item.getItemId()) {
+ case R.id.menu_play_now:
+ playNow(false);
+ return true;
+ case R.id.menu_play_last:
+ download(true, false, false, false, false);
+ selectAll(false, false);
+ return true;
+ case R.id.menu_shuffle:
+ playNow(true);
+ return true;
+ case R.id.menu_select:
+ selectAllOrNone();
+ return true;
+ case R.id.menu_refresh:
+ refresh();
+ return true;
+ case R.id.menu_cache:
+ download(true, true, false, false, false);
+ selectAll(false, false);
+ return true;
+ case R.id.menu_delete:
+ delete();
+ selectAll(false, false);
+ return true;
+ case R.id.menu_exit:
+ intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
+ Util.startActivityWithoutTransition(this, intent);
+ return true;
+ case R.id.menu_settings:
+ startActivity(new Intent(this, SettingsActivity.class));
+ return true;
+ case R.id.menu_help:
+ startActivity(new Intent(this, HelpActivity.class));
+ return true;
+ }
- // Button 2: refresh
- ImageButton refreshButton = (ImageButton) findViewById(R.id.action_button_2);
- refreshButton.setImageResource(R.drawable.action_refresh);
- refreshButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- refresh();
- }
- });
-
- // Button 3: Help
- ImageButton actionHelpButton = (ImageButton)findViewById(R.id.action_button_3);
- actionHelpButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SelectAlbumActivity.this, HelpActivity.class));
- }
- });
-
- // Button 4: Settings
- ImageButton actionSettingsButton = (ImageButton)findViewById(R.id.action_button_4);
- actionSettingsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SelectAlbumActivity.this, SettingsActivity.class));
- }
- });
+ return false;
}
+ private void playNow(final boolean shuffle) {
+ if(getSelectedSongs().size() > 0) {
+ download(false, false, true, false, shuffle);
+ selectAll(false, false);
+ }
+ else {
+ playAll(shuffle);
+ }
+ }
private void playAll(final boolean shuffle) {
boolean hasSubFolders = false;
for (int i = 0; i < entryList.getCount(); i++) {
@@ -394,36 +363,6 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
: R.string.select_album_n_unselected;
Util.toast(this, getString(toastResId, selectedCount));
}
-
- enableButtons();
- }
-
- private void enableButtons() {
- if (getDownloadService() == null) {
- return;
- }
-
- List<MusicDirectory.Entry> selection = getSelectedSongs();
- boolean enabled = !selection.isEmpty();
- boolean unpinEnabled = false;
- boolean deleteEnabled = false;
-
- for (MusicDirectory.Entry song : selection) {
- DownloadFile downloadFile = getDownloadService().forSong(song);
- if (downloadFile.isCompleteFileAvailable()) {
- deleteEnabled = true;
- }
- if (downloadFile.isSaved()) {
- unpinEnabled = true;
- }
- }
-
- playNowButton.setEnabled(enabled);
- playShuffledButton.setEnabled(enabled);
- playLastButton.setEnabled(enabled);
- pinButton.setEnabled(enabled && !Util.isOffline(this));
- unpinButton.setEnabled(unpinEnabled);
- deleteButton.setEnabled(deleteEnabled);
}
private List<MusicDirectory.Entry> getSelectedSongs() {
@@ -523,23 +462,23 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
builder.setMessage(R.string.select_album_donate_dialog_message);
builder.setPositiveButton(R.string.select_album_donate_dialog_now,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.DONATION_URL)));
- }
- });
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.DONATION_URL)));
+ }
+ });
builder.setNegativeButton(R.string.select_album_donate_dialog_later,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- dialogInterface.dismiss();
- if (onValid != null) {
- onValid.run();
- }
- }
- });
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ dialogInterface.dismiss();
+ if (onValid != null) {
+ onValid.run();
+ }
+ }
+ });
builder.create().show();
}
@@ -572,21 +511,18 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
}
if (songCount > 0) {
- getImageLoader().loadImage(coverArtView, entries.get(0), false, true);
+ getImageLoader().loadImage(getSupportActionBar(), entries.get(0));
entryList.addFooterView(footer);
- selectButton.setVisibility(View.VISIBLE);
- playNowButton.setVisibility(View.VISIBLE);
- playShuffledButton.setVisibility(View.VISIBLE);
- playLastButton.setVisibility(View.VISIBLE);
- pinButton.setVisibility(View.VISIBLE);
- unpinButton.setVisibility(View.VISIBLE);
- deleteButton.setVisibility(View.VISIBLE);
- }
-
- boolean isAlbumList = getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE);
+ } else if(selectAll != null) {
+ selectAll.setVisible(false);
+ cache.setVisible(false);
+ delete.setVisible(false);
+ playLast.setVisible(false);
+ } else {
+ hideButtons = true;
+ }
emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE);
- playAllButton.setVisibility(isAlbumList || entries.isEmpty() ? View.GONE : View.VISIBLE);
entryList.setAdapter(new EntryAdapter(SelectAlbumActivity.this, getImageLoader(), entries, true));
licenseValid = result.getSecond();
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
index 8b32ff3a..bee76641 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectArtistActivity.java
@@ -30,6 +30,7 @@ import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
+import com.actionbarsherlock.view.Menu;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.Artist;
import github.daneren2005.dsub.domain.Indexes;
@@ -73,51 +74,46 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
}
registerForContextMenu(artistList);
+ setTitle(Util.isOffline(this) ? R.string.music_library_label_offline : R.string.music_library_label);
- setTitle(Util.isOffline(this) ? R.string.music_library_label_offline : R.string.music_library_label);
+ musicFolders = null;
+ load();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.select_artist, menu);
+ return true;
+ }
- // Button 1: shuffle
- ImageButton shuffleButton = (ImageButton) findViewById(R.id.action_button_1);
- shuffleButton.setImageResource(R.drawable.action_shuffle);
- shuffleButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(SelectArtistActivity.this, DownloadActivity.class);
+ @Override
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ Intent intent;
+ switch (item.getItemId()) {
+ case R.id.menu_refresh:
+ refresh();
+ return true;
+ case R.id.menu_shuffle:
+ intent = new Intent(SelectArtistActivity.this, DownloadActivity.class);
intent.putExtra(Constants.INTENT_EXTRA_NAME_SHUFFLE, true);
Util.startActivityWithoutTransition(SelectArtistActivity.this, intent);
- }
- });
-
- // Button 2: refresh
- ImageButton refreshButton = (ImageButton) findViewById(R.id.action_button_2);
- refreshButton.setImageResource(R.drawable.action_refresh);
- refreshButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- refresh();
- }
- });
-
- // Button 3: Help
- ImageButton actionHelpButton = (ImageButton)findViewById(R.id.action_button_3);
- actionHelpButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SelectArtistActivity.this, HelpActivity.class));
- }
- });
-
- // Button 4: Settings
- ImageButton actionSettingsButton = (ImageButton)findViewById(R.id.action_button_4);
- actionSettingsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SelectArtistActivity.this, SettingsActivity.class));
- }
- });
+ return true;
+ case R.id.menu_exit:
+ intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
+ Util.startActivityWithoutTransition(this, intent);
+ return true;
+ case R.id.menu_settings:
+ startActivity(new Intent(this, SettingsActivity.class));
+ return true;
+ case R.id.menu_help:
+ startActivity(new Intent(this, HelpActivity.class));
+ return true;
+ }
- musicFolders = null;
- load();
+ return false;
}
private void refresh() {
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
index a299b84b..f515d5be 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
@@ -61,39 +61,38 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
// Title: Playlists
setTitle(R.string.playlist_label);
- // Button 1: gone
- ImageButton searchButton = (ImageButton)findViewById(R.id.action_button_1);
- searchButton.setVisibility(View.GONE);
-
- // Button 2: refresh
- ImageButton refreshButton = (ImageButton) findViewById(R.id.action_button_2);
- refreshButton.setImageResource(R.drawable.action_refresh);
- refreshButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
+ load();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
+ com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
+ inflater.inflate(R.menu.select_playlist, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ Intent intent;
+ switch (item.getItemId()) {
+ case R.id.menu_refresh:
refresh();
- }
- });
-
- // Button 3: Help
- ImageButton actionHelpButton = (ImageButton)findViewById(R.id.action_button_3);
- actionHelpButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SelectPlaylistActivity.this, HelpActivity.class));
- }
- });
-
- // Button 4: Settings
- ImageButton actionSettingsButton = (ImageButton)findViewById(R.id.action_button_4);
- actionSettingsButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- startActivity(new Intent(SelectPlaylistActivity.this, SettingsActivity.class));
- }
- });
+ return true;
+ case R.id.menu_exit:
+ intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
+ Util.startActivityWithoutTransition(this, intent);
+ return true;
+ case R.id.menu_settings:
+ startActivity(new Intent(this, SettingsActivity.class));
+ return true;
+ case R.id.menu_help:
+ startActivity(new Intent(this, HelpActivity.class));
+ return true;
+ }
- load();
+ return false;
}
private void refresh() {
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
index 6afe842b..9b1ab55e 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java
@@ -34,13 +34,12 @@ import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.KeyEvent;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import github.daneren2005.dsub.R;
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockActivity;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadServiceImpl;
@@ -54,10 +53,11 @@ import github.daneren2005.dsub.util.Util;
/**
* @author Sindre Mehus
*/
-public class SubsonicTabActivity extends Activity {
+public class SubsonicTabActivity extends SherlockActivity {
private static final String TAG = SubsonicTabActivity.class.getSimpleName();
private static ImageLoader IMAGE_LOADER;
+ private String theme;
private boolean destroyed;
private View homeButton;
@@ -70,7 +70,6 @@ public class SubsonicTabActivity extends Activity {
setUncaughtExceptionHandler();
applyTheme();
super.onCreate(bundle);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
startService(new Intent(this, DownloadServiceImpl.class));
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
@@ -133,37 +132,12 @@ public class SubsonicTabActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
- Util.registerMediaButtonEventReceiver(this);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.main, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
-
- case R.id.menu_exit:
- Intent intent = new Intent(this, MainActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
- Util.startActivityWithoutTransition(this, intent);
- return true;
-
- case R.id.menu_settings:
- startActivity(new Intent(this, SettingsActivity.class));
- return true;
-
- case R.id.menu_help:
- startActivity(new Intent(this, HelpActivity.class));
- return true;
+ Util.registerMediaButtonEventReceiver(this);
+
+ // Make sure to update theme
+ if (theme != null && !theme.equals(Util.getTheme(this))) {
+ restart();
}
-
- return false;
}
@Override
@@ -187,6 +161,13 @@ public class SubsonicTabActivity extends Activity {
}
return super.onKeyDown(keyCode, event);
}
+
+ protected void restart() {
+ Intent intent = new Intent(this, this.getClass());
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtras(getIntent());
+ Util.startActivityWithoutTransition(this, intent);
+ }
@Override
public void finish() {
@@ -194,30 +175,19 @@ public class SubsonicTabActivity extends Activity {
Util.disablePendingTransition(this);
}
- @Override
- public void setTitle(CharSequence title) {
- super.setTitle(title);
-
- // Set the font of title in the action bar.
- TextView text = (TextView) findViewById(R.id.actionbar_title_text);
- Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Storopia.ttf");
- text.setTypeface(typeface);
-
- text.setText(title);
- }
-
- @Override
- public void setTitle(int titleId) {
- setTitle(getString(titleId));
- }
-
private void applyTheme() {
- String theme = Util.getTheme(this);
+ theme = Util.getTheme(this);
if ("dark".equals(theme)) {
- setTheme(android.R.style.Theme);
+ setTheme(R.style.Theme_DSub_Dark);
} else if ("light".equals(theme)) {
- setTheme(android.R.style.Theme_Light);
- }
+ setTheme(R.style.Theme_DSub_Light);
+ } else if ("dark_fullscreen".equals(theme)) {
+ setTheme(R.style.Theme_DSub_Dark_Fullscreen);
+ } else if ("light_fullscreen".equals(theme)) {
+ setTheme(R.style.Theme_DSub_Light_Fullscreen);
+ }else {
+ setTheme(R.style.Theme_DSub_Light);
+ }
}
public boolean isDestroyed() {
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java
index 0c4bc215..e1a9d86a 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java
@@ -44,6 +44,8 @@ import github.daneren2005.dsub.service.MusicServiceFactory;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
+import com.actionbarsherlock.app.ActionBar;
+
/**
* Asynchronous loading of images, with caching.
* <p/>
@@ -101,7 +103,7 @@ public class ImageLoader implements Runnable {
if (!large) {
setUnknownImage(view, large);
}
- queue.offer(new Task(view.getContext(), view, null, entry, size, large, large, crossfade));
+ queue.offer(new Task(view.getContext(), entry, size, large, large, new ViewTaskHandler(view, crossfade)));
}
public void loadImage(Context context, RemoteControlClient remoteControl, MusicDirectory.Entry entry) {
@@ -117,7 +119,23 @@ public class ImageLoader implements Runnable {
}
setUnknownImage(remoteControl);
- queue.offer(new Task(context, null, remoteControl, entry, imageSizeDefault, false, false, false));
+ queue.offer(new Task(context, entry, imageSizeDefault, false, false, new RemoteControlClientTaskHandler(remoteControl)));
+ }
+
+ public void loadImage(ActionBar actionBar, MusicDirectory.Entry entry) {
+ if (entry == null || entry.getCoverArt() == null) {
+ setUnknownImage(actionBar);
+ return;
+ }
+
+ Drawable drawable = cache.get(getKey(entry.getCoverArt(), imageSizeDefault));
+ if (drawable != null) {
+ setImage(actionBar, drawable);
+ return;
+ }
+
+ setUnknownImage(actionBar);
+ queue.offer(new Task(actionBar.getThemedContext(), entry, imageSizeDefault, false, false, new ActionBarTaskHandler(actionBar)));
}
private String getKey(String coverArtId, int size) {
@@ -158,6 +176,10 @@ public class ImageLoader implements Runnable {
origBitmap.copy(origBitmap.getConfig(), true))
.apply();
}
+
+ private void setImage(ActionBar actionBar, Drawable drawable) {
+ actionBar.setIcon(drawable);
+ }
private void setUnknownImage(View view, boolean large) {
if (large) {
@@ -174,6 +196,10 @@ public class ImageLoader implements Runnable {
private void setUnknownImage(RemoteControlClient remoteControl) {
setImage(remoteControl, largeUnknownImage);
}
+
+ private void setUnknownImage(ActionBar actionBar) {
+ setImage(actionBar, largeUnknownImage);
+ }
public void clear() {
queue.clear();
@@ -240,53 +266,95 @@ public class ImageLoader implements Runnable {
}
private class Task {
- private final Context context;
- private final View view;
- private final RemoteControlClient remoteControl;
- private final MusicDirectory.Entry entry;
- private final Handler handler;
- private final int size;
- private final boolean reflection;
- private final boolean saveToFile;
- private final boolean crossfade;
-
- public Task(Context context, View view, RemoteControlClient remoteControl, MusicDirectory.Entry entry, int size, boolean reflection, boolean saveToFile, boolean crossfade) {
- this.context = context;
- this.view = view;
- this.remoteControl = remoteControl;
- this.entry = entry;
- this.size = size;
- this.reflection = reflection;
- this.saveToFile = saveToFile;
- this.crossfade = crossfade;
- handler = new Handler();
+ private final Context mContext;
+ private final MusicDirectory.Entry mEntry;
+ private final Handler mHandler;
+ private final int mSize;
+ private final boolean mReflection;
+ private final boolean mSaveToFile;
+ private ImageLoaderTaskHandler mTaskHandler;
+
+ public Task(Context context, MusicDirectory.Entry entry, int size, boolean reflection, boolean saveToFile, ImageLoaderTaskHandler taskHandler) {
+ mContext = context;
+ mEntry = entry;
+ mSize = size;
+ mReflection = reflection;
+ mSaveToFile = saveToFile;
+ mTaskHandler = taskHandler;
+ mHandler = new Handler();
}
public void execute() {
try {
- MusicService musicService = MusicServiceFactory.getMusicService(context);
- Bitmap bitmap = musicService.getCoverArt(context, entry, size, saveToFile, null);
+ MusicService musicService = MusicServiceFactory.getMusicService(mContext);
+ Bitmap bitmap = musicService.getCoverArt(mContext, mEntry, mSize, mSaveToFile, null);
- if (reflection) {
+ if (mReflection) {
bitmap = createReflection(bitmap);
}
- final Drawable drawable = Util.createDrawableFromBitmap(context, bitmap);
- cache.put(getKey(entry.getCoverArt(), size), drawable);
-
- handler.post(new Runnable() {
- @Override
- public void run() {
- if (view != null) {
- setImage(view, drawable, crossfade);
- } else if (remoteControl != null) {
- setImage(remoteControl, drawable);
- }
- }
- });
+ final Drawable drawable = Util.createDrawableFromBitmap(mContext, bitmap);
+ cache.put(getKey(mEntry.getCoverArt(), mSize), drawable);
+
+ mTaskHandler.setDrawable(drawable);
+ mHandler.post(mTaskHandler);
} catch (Throwable x) {
Log.e(TAG, "Failed to download album art.", x);
}
}
}
+
+ private abstract class ImageLoaderTaskHandler implements Runnable {
+
+ protected Drawable mDrawable;
+
+ public void setDrawable(Drawable drawable) {
+ mDrawable = drawable;
+ }
+
+ }
+
+ private class ViewTaskHandler extends ImageLoaderTaskHandler {
+
+ protected boolean mCrossfade;
+ private View mView;
+
+ public ViewTaskHandler(View view, boolean crossfade) {
+ mCrossfade = crossfade;
+ mView = view;
+ }
+
+ @Override
+ public void run() {
+ setImage(mView, mDrawable, mCrossfade);
+ }
+ }
+
+ private class RemoteControlClientTaskHandler extends ImageLoaderTaskHandler {
+
+ private RemoteControlClient mRemoteControl;
+
+ public RemoteControlClientTaskHandler(RemoteControlClient remoteControl) {
+ mRemoteControl = remoteControl;
+ }
+
+ @Override
+ public void run() {
+ setImage(mRemoteControl, mDrawable);
+ }
+ }
+
+ private class ActionBarTaskHandler extends ImageLoaderTaskHandler {
+
+ private ActionBar mActionBar;
+
+ public ActionBarTaskHandler(ActionBar actionBar) {
+ mActionBar = actionBar;
+ }
+
+ @Override
+ public void run() {
+ setImage(mActionBar, mDrawable);
+ }
+ }
}