diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-10-02 19:17:22 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-10-02 19:17:22 -0700 |
commit | 7069ab8ab78a48e60fa4a95ccc325eb7e56fa1be (patch) | |
tree | 7b2ec25823373ad6b1473559a2d9d86d253645a8 /src/github | |
parent | e34688b0366f9ac17e8c9c55877d83d4acd7fb0d (diff) | |
parent | ad8e2fbbe3a096dbcea0f252ba0fa1bad6baffda (diff) | |
download | dsub-7069ab8ab78a48e60fa4a95ccc325eb7e56fa1be.tar.gz dsub-7069ab8ab78a48e60fa4a95ccc325eb7e56fa1be.tar.bz2 dsub-7069ab8ab78a48e60fa4a95ccc325eb7e56fa1be.zip |
Merge branch 'master' into Transition
Diffstat (limited to 'src/github')
5 files changed, 47 insertions, 23 deletions
diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index ac197161..1f5c7b88 100644 --- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -627,7 +627,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis menu.findItem(R.id.menu_show_artist).setVisible(false);
}
- hideMenuItems(menu);
+ hideMenuItems(menu, (AdapterView.AdapterContextMenuInfo) menuInfo);
}
}
diff --git a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java index f9ab0cc9..c26429ce 100644 --- a/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectBookmarkFragment.java @@ -19,6 +19,7 @@ package github.daneren2005.dsub.fragments; import android.content.DialogInterface; +import android.util.Log; import android.view.ContextMenu; import android.view.MenuInflater; import android.view.MenuItem; @@ -29,6 +30,7 @@ import github.daneren2005.dsub.R; import github.daneren2005.dsub.activity.DownloadActivity; import github.daneren2005.dsub.domain.Bookmark; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; @@ -39,6 +41,8 @@ import github.daneren2005.dsub.util.ProgressListener; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.BookmarkAdapter; +import github.daneren2005.dsub.view.SongView; + import java.text.Format; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -53,6 +57,8 @@ public class SelectBookmarkFragment extends SelectListFragment<MusicDirectory.En MenuInflater inflater = context.getMenuInflater(); inflater.inflate(R.menu.select_bookmark_context, menu); + + hideMenuItems(menu, (AdapterView.AdapterContextMenuInfo) menuInfo); } @Override diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index cc38ad69..4b845753 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -258,9 +258,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter case R.id.menu_shuffle:
playNow(true, false);
return true;
- case R.id.menu_select:
- selectAllOrNone();
- return true;
case R.id.menu_download:
downloadBackground(false);
selectAll(false, false);
@@ -777,18 +774,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
}
- private void selectAllOrNone() {
- boolean someUnselected = false;
- int count = entryList.getCount();
- for (int i = 0; i < count; i++) {
- if (!entryList.isItemChecked(i) && entryList.getItemAtPosition(i) instanceof Entry) {
- someUnselected = true;
- break;
- }
- }
- selectAll(someUnselected, true);
- }
-
private void selectAll(boolean selected, boolean toast) {
int count = entryList.getCount();
int selectedCount = 0;
@@ -1186,12 +1171,14 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter return;
}
- AlertDialog.Builder imageDialog = new AlertDialog.Builder(context);
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
ImageView fullScreenView = new ImageView(context);
imageLoader.loadImage(fullScreenView, albumRep, true, true);
- imageDialog.setView(fullScreenView);
- imageDialog.setCancelable(true);
- imageDialog.create();
+ builder.setCancelable(true);
+
+ AlertDialog imageDialog = builder.create();
+ // Set view here with unecessary 0's to remove top/bottom border
+ imageDialog.setView(fullScreenView, 0, 0, 0, 0);
imageDialog.show();
}
});
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index fe1153c0..66900b55 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -40,6 +40,7 @@ import android.view.MenuItem; import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
+import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
@@ -74,6 +75,7 @@ import github.daneren2005.dsub.util.LoadingTask; import github.daneren2005.dsub.util.UserUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.PlaylistSongView;
+import github.daneren2005.dsub.view.SongView;
import github.daneren2005.dsub.view.UpdateView;
import java.io.File;
@@ -168,7 +170,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo, Object selected) {
MenuInflater inflater = context.getMenuInflater();
-
+
if(selected instanceof Entry) {
Entry entry = (Entry) selected;
if(entry instanceof PodcastEpisode && !entry.isVideo()) {
@@ -227,10 +229,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
}
- hideMenuItems(menu);
+ hideMenuItems(menu, (AdapterView.AdapterContextMenuInfo) menuInfo);
}
- protected void hideMenuItems(ContextMenu menu) {
+ protected void hideMenuItems(ContextMenu menu, AdapterView.AdapterContextMenuInfo info) {
if(!ServerInfo.checkServerVersion(context, "1.8")) {
menu.setGroupVisible(R.id.server_1_8, false);
menu.setGroupVisible(R.id.hide_star, false);
@@ -258,6 +260,31 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR if(!prefs.getBoolean(Constants.PREFERENCES_KEY_MENU_RATING, true)) {
menu.setGroupVisible(R.id.hide_rating, false);
}
+
+ // If we are looking at a standard song view, get downloadFile to cache what options to show
+ if(info.targetView instanceof SongView) {
+ SongView songView = (SongView) info.targetView;
+ DownloadFile downloadFile = songView.getDownloadFile();
+
+ try {
+ if(downloadFile != null) {
+ if(downloadFile.isWorkDone()) {
+ // Remove permanent cache menu if already perma cached
+ if(downloadFile.isSaved()) {
+ menu.removeItem(R.id.song_menu_pin);
+ }
+
+ // Remove cache option no matter what if already downloaded
+ menu.removeItem(R.id.song_menu_download);
+ } else {
+ // Remove delete option if nothing to delete
+ menu.removeItem(R.id.song_menu_delete);
+ }
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to lookup downloadFile info", e);
+ }
+ }
}
protected void recreateContextMenu(ContextMenu menu) {
diff --git a/src/github/daneren2005/dsub/view/SongView.java b/src/github/daneren2005/dsub/view/SongView.java index f795cbce..0fe19944 100644 --- a/src/github/daneren2005/dsub/view/SongView.java +++ b/src/github/daneren2005/dsub/view/SongView.java @@ -161,6 +161,10 @@ public class SongView extends UpdateView implements Checkable { dontChangeDownloadFile = true; } + public DownloadFile getDownloadFile() { + return downloadFile; + } + @Override protected void updateBackground() { if (downloadService == null) { |