From eaca7e8c966cb085096486b7e1d27e349e7c7aa8 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 30 May 2016 16:51:09 -0500 Subject: Fixes #690: Modernize the action bar search with SearchView --- .../dsub/activity/SubsonicFragmentActivity.java | 5 --- .../daneren2005/dsub/fragments/MainFragment.java | 1 + .../daneren2005/dsub/fragments/SearchFragment.java | 22 ++++++------- .../dsub/fragments/SelectRecyclerFragment.java | 6 ++++ .../dsub/fragments/SubsonicFragment.java | 37 ++++++++++++++++++++-- 5 files changed, 51 insertions(+), 20 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 51de1f6c..17cfdb42 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -396,14 +396,9 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo if(currentFragment instanceof SearchFragment) { String query = intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY); boolean autoplay = intent.getBooleanExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, false); - boolean requestsearch = intent.getBooleanExtra(Constants.INTENT_EXTRA_REQUEST_SEARCH, false); if (query != null) { ((SearchFragment)currentFragment).search(query, autoplay); - } else { - if (requestsearch) { - onSearchRequested(); - } } getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_QUERY); } else { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java index f3d675f0..4f5f7e6b 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java @@ -63,6 +63,7 @@ public class MainFragment extends SelectRecyclerFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { menuInflater.inflate(R.menu.main, menu); + onFinishSetupOptionsMenu(menu); try { if (!ServerInfo.isMadsonic(context) || !UserUtil.isCurrentAdmin()) { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java index c891da34..eed714af 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java @@ -7,6 +7,7 @@ import java.util.List; import android.content.Intent; import android.os.Bundle; +import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; @@ -125,18 +126,7 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { menuInflater.inflate(R.menu.search, menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_global_search: - context.startSearch(currentQuery, false, null, false); - return true; - } - - return super.onOptionsItemSelected(item); - + onFinishSetupOptionsMenu(menu); } @Override @@ -218,6 +208,14 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O } }; task.execute(); + + if(searchItem != null) { + MenuItemCompat.collapseActionView(searchItem); + } + } + + protected String getCurrentQuery() { + return currentQuery; } private void onArtistSelected(Artist artist, boolean autoplay) { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java index 7ae7fff8..0d4506ac 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectRecyclerFragment.java @@ -15,10 +15,15 @@ package github.daneren2005.dsub.fragments; +import android.app.SearchManager; +import android.app.SearchableInfo; +import android.content.Context; import android.os.Bundle; +import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.SearchView; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -102,6 +107,7 @@ public abstract class SelectRecyclerFragment extends SubsonicFragment impleme } menuInflater.inflate(getOptionsMenu(), menu); + onFinishSetupOptionsMenu(menu); } @Override diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java index f733c977..9cc27128 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -20,6 +20,9 @@ package github.daneren2005.dsub.fragments; import android.annotation.TargetApi; import android.app.Activity; +import android.app.SearchManager; +import android.app.SearchableInfo; +import android.support.v4.view.MenuItemCompat; import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; @@ -37,6 +40,7 @@ import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.SearchView; import android.util.Log; import android.view.GestureDetector; import android.view.Menu; @@ -125,6 +129,8 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR protected boolean artistOverride = false; protected SwipeRefreshLayout refreshLayout; protected boolean firstRun; + protected MenuItem searchItem; + protected SearchView searchView; public SubsonicFragment() { super(); @@ -177,15 +183,36 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR this.context = context; } + protected void onFinishSetupOptionsMenu(final Menu menu) { + searchItem = menu.findItem(R.id.menu_global_search); + if(searchItem != null) { + searchView = (SearchView) MenuItemCompat.getActionView(searchItem); + SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); + SearchableInfo searchableInfo = searchManager.getSearchableInfo(context.getComponentName()); + if(searchableInfo == null) { + Log.w(TAG, "Failed to get SearchableInfo"); + } else { + searchView.setSearchableInfo(searchableInfo); + } + + String currentQuery = getCurrentQuery(); + if(currentQuery != null) { + searchView.setOnSearchClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + searchView.setQuery(getCurrentQuery(), false); + } + }); + } + } + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_global_shuffle: onShuffleRequested(); return true; - case R.id.menu_global_search: - context.onSearchRequested(); - return true; case R.id.menu_exit: exit(); return true; @@ -1927,6 +1954,10 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR return false; } + protected String getCurrentQuery() { + return null; + } + public abstract class RecursiveLoader extends LoadingTask { protected MusicService musicService; protected static final int MAX_SONGS = 500; -- cgit v1.2.3 From 2a2e6d5c57b45bba59dce6716fc01b1a1b0cc1a4 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 30 May 2016 17:41:21 -0500 Subject: Remove "Root" folder concept now that we can trivially display artists and songs side by side --- .../daneren2005/dsub/adapter/ArtistAdapter.java | 39 +++++-- .../github/daneren2005/dsub/domain/Artist.java | 6 -- .../github/daneren2005/dsub/domain/Indexes.java | 7 -- .../dsub/fragments/SelectArtistFragment.java | 116 ++++++++++++--------- .../dsub/fragments/SelectDirectoryFragment.java | 8 +- 5 files changed, 101 insertions(+), 75 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java index 207dc0b2..5ed79e82 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/ArtistAdapter.java @@ -23,27 +23,32 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import java.io.Serializable; import java.util.List; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.Artist; +import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.domain.MusicDirectory.Entry; import github.daneren2005.dsub.domain.MusicFolder; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.ArtistView; import github.daneren2005.dsub.view.FastScroller; +import github.daneren2005.dsub.view.SongView; import github.daneren2005.dsub.view.UpdateView; -public class ArtistAdapter extends SectionAdapter implements FastScroller.BubbleTextGetter { +public class ArtistAdapter extends SectionAdapter implements FastScroller.BubbleTextGetter { + public static int VIEW_TYPE_SONG = 3; public static int VIEW_TYPE_ARTIST = 4; private List musicFolders; private OnMusicFolderChanged onMusicFolderChanged; - public ArtistAdapter(Context context, List artists, OnItemClickedListener listener) { + public ArtistAdapter(Context context, List artists, OnItemClickedListener listener) { this(context, artists, null, listener, null); } - public ArtistAdapter(Context context, List artists, List musicFolders, OnItemClickedListener onItemClickedListener, OnMusicFolderChanged onMusicFolderChanged) { + public ArtistAdapter(Context context, List artists, List musicFolders, OnItemClickedListener onItemClickedListener, OnMusicFolderChanged onMusicFolderChanged) { super(context, artists); this.musicFolders = musicFolders; this.onItemClickedListener = onItemClickedListener; @@ -110,17 +115,35 @@ public class ArtistAdapter extends SectionAdapter implements FastScrolle @Override public UpdateView.UpdateViewHolder onCreateSectionViewHolder(ViewGroup parent, int viewType) { - return new UpdateView.UpdateViewHolder(new ArtistView(context)); + UpdateView updateView = null; + if(viewType == VIEW_TYPE_ARTIST) { + updateView = new ArtistView(context); + } else if(viewType == VIEW_TYPE_SONG) { + updateView = new SongView(context); + } + + return new UpdateView.UpdateViewHolder(updateView); } @Override - public void onBindViewHolder(UpdateView.UpdateViewHolder holder, Artist item, int viewType) { - holder.getUpdateView().setObject(item); + public void onBindViewHolder(UpdateView.UpdateViewHolder holder, Serializable item, int viewType) { + UpdateView view = holder.getUpdateView(); + if(viewType == VIEW_TYPE_ARTIST) { + view.setObject(item); + } else if(viewType == VIEW_TYPE_SONG) { + SongView songView = (SongView) view; + Entry entry = (Entry) item; + songView.setObject(entry, checkable && !entry.isVideo()); + } } @Override - public int getItemViewType(Artist item) { - return VIEW_TYPE_ARTIST; + public int getItemViewType(Serializable item) { + if(item instanceof Artist) { + return VIEW_TYPE_ARTIST; + } else { + return VIEW_TYPE_SONG; + } } @Override diff --git a/app/src/main/java/github/daneren2005/dsub/domain/Artist.java b/app/src/main/java/github/daneren2005/dsub/domain/Artist.java index 5809146d..ff4d86ce 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/Artist.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/Artist.java @@ -130,12 +130,6 @@ public class Artist implements Serializable { } public int compare(Artist lhsArtist, Artist rhsArtist) { - if("root".equals(lhsArtist.getId())) { - return 1; - } else if("root".equals(rhsArtist.getId())) { - return -1; - } - String lhs = lhsArtist.getName().toLowerCase(); String rhs = rhsArtist.getName().toLowerCase(); diff --git a/app/src/main/java/github/daneren2005/dsub/domain/Indexes.java b/app/src/main/java/github/daneren2005/dsub/domain/Indexes.java index e15ccf9f..05e686ca 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/Indexes.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/Indexes.java @@ -52,13 +52,6 @@ public class Indexes implements Serializable { this.shortcuts = shortcuts; this.artists = artists; this.entries = entries; - if(!entries.isEmpty()) { - Artist root = new Artist(); - root.setId("root"); - root.setName("Root"); - root.setIndex("#"); - artists.add(root); - } } public long getLastModified() { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java index 6890f572..be371dd3 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -17,6 +17,7 @@ import github.daneren2005.dsub.adapter.SectionAdapter; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.Indexes; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.domain.MusicDirectory.Entry; import github.daneren2005.dsub.domain.MusicFolder; import github.daneren2005.dsub.domain.ServerInfo; import github.daneren2005.dsub.service.MusicService; @@ -29,12 +30,11 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -public class SelectArtistFragment extends SelectRecyclerFragment implements ArtistAdapter.OnMusicFolderChanged { +public class SelectArtistFragment extends SelectRecyclerFragment implements ArtistAdapter.OnMusicFolderChanged { private static final String TAG = SelectArtistFragment.class.getSimpleName(); - private static final int MENU_GROUP_MUSIC_FOLDER = 10; private List musicFolders = null; - private List entries; + private List entries; private String groupId; private String groupName; @@ -80,48 +80,68 @@ public class SelectArtistFragment extends SelectRecyclerFragment impleme } @Override - public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView updateView, Artist item) { + public void onCreateContextMenu(Menu menu, MenuInflater menuInflater, UpdateView updateView, Serializable item) { onCreateContextMenuSupport(menu, menuInflater, updateView, item); recreateContextMenu(menu); } @Override - public boolean onContextItemSelected(MenuItem menuItem, UpdateView updateView, Artist item) { + public boolean onContextItemSelected(MenuItem menuItem, UpdateView updateView, Serializable item) { return onContextItemSelected(menuItem, item); } @Override - public void onItemClicked(UpdateView updateView, Artist artist) { + public void onItemClicked(UpdateView updateView, Serializable item) { SubsonicFragment fragment; - if((Util.isFirstLevelArtist(context) || Util.isOffline(context) || Util.isTagBrowsing(context)) || "root".equals(artist.getId()) || groupId != null) { - fragment = new SelectDirectoryFragment(); - Bundle args = new Bundle(); - args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId()); - args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName()); - - if ("root".equals(artist.getId())) { - args.putSerializable(Constants.FRAGMENT_LIST, (Serializable) entries); - } - if(ServerInfo.checkServerVersion(context, "1.13") && !Util.isOffline(context)) { - args.putSerializable(Constants.INTENT_EXTRA_NAME_DIRECTORY, new MusicDirectory.Entry(artist)); + if(item instanceof Artist) { + Artist artist = (Artist) item; + + if ((Util.isFirstLevelArtist(context) || Util.isOffline(context) || Util.isTagBrowsing(context)) || groupId != null) { + fragment = new SelectDirectoryFragment(); + Bundle args = new Bundle(); + args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId()); + args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName()); + + if (ServerInfo.checkServerVersion(context, "1.13") && !Util.isOffline(context)) { + args.putSerializable(Constants.INTENT_EXTRA_NAME_DIRECTORY, new Entry(artist)); + } + args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true); + + fragment.setArguments(args); + } else { + fragment = new SelectArtistFragment(); + Bundle args = new Bundle(); + args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId()); + args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName()); + args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true); + if (ServerInfo.checkServerVersion(context, "1.13") && !Util.isOffline(context)) { + args.putSerializable(Constants.INTENT_EXTRA_NAME_DIRECTORY, new Entry(artist)); + } + + fragment.setArguments(args); } - args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true); - fragment.setArguments(args); + replaceFragment(fragment); } else { - fragment = new SelectArtistFragment(); - Bundle args = new Bundle(); - args.putString(Constants.INTENT_EXTRA_NAME_ID, artist.getId()); - args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName()); - args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true); - if(ServerInfo.checkServerVersion(context, "1.13") && !Util.isOffline(context)) { - args.putSerializable(Constants.INTENT_EXTRA_NAME_DIRECTORY, new MusicDirectory.Entry(artist)); + Entry entry = (Entry) item; + if (entry.isVideo()) { + playVideo(entry); + } else { + List songs = new ArrayList(); + + if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PLAY_NOW_AFTER, true)) { + for (Entry song : entries) { + if (!song.isDirectory() && !song.isVideo()) { + songs.add(song); + } + } + playNow(songs, entry, 0); + } else { + songs.add(entry); + playNow(songs); + } } - - fragment.setArguments(args); } - - replaceFragment(fragment); } @Override @@ -158,13 +178,13 @@ public class SelectArtistFragment extends SelectRecyclerFragment impleme } @Override - public SectionAdapter getAdapter(List objects) { + public SectionAdapter getAdapter(List objects) { return new ArtistAdapter(context, objects, musicFolders, this, this); } @Override - public List getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { - List artists; + public List getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception { + List items; if(groupId == null) { if (!Util.isOffline(context) && (!Util.isTagBrowsing(context) || ServerInfo.checkServerVersion(context, "1.14"))) { musicFolders = musicService.getMusicFolders(refresh, context, listener); @@ -181,14 +201,16 @@ public class SelectArtistFragment extends SelectRecyclerFragment impleme Indexes indexes = musicService.getIndexes(musicFolderId, refresh, context, listener); indexes.sortChildren(context); - artists = new ArrayList<>(indexes.getShortcuts().size() + indexes.getArtists().size()); - artists.addAll(indexes.getShortcuts()); - artists.addAll(indexes.getArtists()); + items = new ArrayList<>(indexes.getShortcuts().size() + indexes.getArtists().size()); + items.addAll(indexes.getShortcuts()); + items.addAll(indexes.getArtists()); entries = indexes.getEntries(); + items.addAll(entries); } else { - artists = new ArrayList<>(); + List artists = new ArrayList<>(); + items = new ArrayList<>(); MusicDirectory dir = musicService.getMusicDirectory(groupId, groupName, refresh, context, listener); - for(MusicDirectory.Entry entry: dir.getChildren(true, false)) { + for(Entry entry: dir.getChildren(true, false)) { Artist artist = new Artist(); artist.setId(entry.getId()); artist.setName(entry.getTitle()); @@ -196,21 +218,17 @@ public class SelectArtistFragment extends SelectRecyclerFragment impleme artists.add(artist); } - entries = new ArrayList<>(); - entries.addAll(dir.getChildren(false, true)); - if(!entries.isEmpty()) { - Artist root = new Artist(); - root.setId("root"); - root.setName("Root"); - root.setIndex("#"); - artists.add(root); - } - Indexes indexes = new Indexes(0, artists, new ArrayList()); indexes.sortChildren(context); + items.addAll(indexes.getArtists()); + + entries = dir.getChildren(false, true); + for(Entry entry: entries) { + items.add(entry); + } } - return artists; + return items; } @Override diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 67dcc6a2..67bc2565 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -234,7 +234,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section if(!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); } - if(!ServerInfo.checkServerVersion(context, "1.11") || (id != null && "root".equals(id))) { + if(!ServerInfo.checkServerVersion(context, "1.11") || id != null) { menu.removeItem(R.id.menu_radio); menu.removeItem(R.id.menu_similar_artists); } else if(!ServerInfo.hasSimilarArtists(context)) { @@ -379,9 +379,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section @Override protected void refresh(boolean refresh) { - if(!"root".equals(id)) { - load(refresh); - } + load(refresh); } @Override @@ -751,7 +749,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section // Show header if not album list type and not root and not artist // For Subsonic 5.1+ display a header for artists with getArtistInfo data if it exists boolean addedHeader = false; - if(albumListType == null && !"root".equals(id) && (!artist || artistInfo != null || artistInfoDelayed != null) && (share == null || entries.size() != albums.size())) { + if(albumListType == null && (!artist || artistInfo != null || artistInfoDelayed != null) && (share == null || entries.size() != albums.size())) { View header = createHeader(); if(header != null) { -- cgit v1.2.3 From 5dd1537844ffd459adeefec1bda88d6c6234e068 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 30 May 2016 17:42:45 -0500 Subject: Get rid of Log.d --- .../java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java | 1 - app/src/main/java/github/daneren2005/dsub/view/CardView.java | 1 - 2 files changed, 2 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java index b1a692d5..6ebb34e3 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/ExpandableSectionAdapter.java @@ -78,7 +78,6 @@ public abstract class ExpandableSectionAdapter extends SectionAdapter { } else { visibleSection.addAll(fullSection.subList(0, defaultVisible)); this.sectionsExtras.add(fullSection.subList(defaultVisible, fullSection.size())); - Log.d(TAG, visibleSection.size() + " + " + this.sectionsExtras.get(i).size()); } this.sections.add(visibleSection); diff --git a/app/src/main/java/github/daneren2005/dsub/view/CardView.java b/app/src/main/java/github/daneren2005/dsub/view/CardView.java index b9e0bcce..d6bca330 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/CardView.java +++ b/app/src/main/java/github/daneren2005/dsub/view/CardView.java @@ -61,7 +61,6 @@ public class CardView extends FrameLayout{ // clipPath is not supported with Hardware Acceleration before API 18 // http://stackoverflow.com/questions/8895677/work-around-canvas-clippath-that-is-not-supported-in-android-any-more/8895894#8895894 if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 && isHardwareAccelerated()) { - Log.d(TAG, "Change to software"); setLayerType(View.LAYER_TYPE_SOFTWARE, null); } } -- cgit v1.2.3 From 9fac439fd85487a165132431f4af74507218332e Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 8 Jun 2016 17:36:45 -0700 Subject: Fix crash if formatting null date string --- app/src/main/java/github/daneren2005/dsub/util/Util.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index c3f1a086..417c3173 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -919,6 +919,10 @@ public final class Util { return formatDate(context, dateString, true); } public static String formatDate(Context context, String dateString, boolean includeTime) { + if(dateString == null) { + return ""; + } + try { dateString = dateString.replace(' ', 'T'); boolean isDateNormalized = ServerInfo.checkServerVersion(context, "1.11"); -- cgit v1.2.3 From 6ac63bba55d94a335889207adb5e0f9c806a0a92 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 8 Jun 2016 17:37:11 -0700 Subject: Fixes #704: Allow rewind/fast forward in Auto + Bluetooth controls --- .../dsub/fragments/NowPlayingFragment.java | 2 +- .../daneren2005/dsub/service/DownloadFile.java | 3 +++ .../daneren2005/dsub/service/DownloadService.java | 8 +++---- .../dsub/util/compat/RemoteControlClientLP.java | 27 +++++++++++++++------- 4 files changed, 27 insertions(+), 13 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java index c8e99f51..8a6df2ab 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -1189,7 +1189,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis this.currentPlaying = currentPlaying; setupSubtitle(currentPlayingIndex); - if(currentPlaying != null && currentPlaying.getSong() != null && (currentPlaying.getSong().isPodcast() || currentPlaying.getSong().isAudioBook())) { + if(currentPlaying != null && !currentPlaying.isSong()) { previousButton.setVisibility(View.GONE); nextButton.setVisibility(View.GONE); diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java index 20126f01..e4bab798 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java @@ -84,6 +84,9 @@ public class DownloadFile implements BufferFile { public MusicDirectory.Entry getSong() { return song; } + public boolean isSong() { + return song.isSong(); + } public Context getContext() { return context; diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index ff260931..eb55ba93 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -1163,8 +1163,8 @@ public class DownloadService extends Service { } // If only one song, just skip within song - if(size() == 1) { - seekTo(getPlayerPosition() - REWIND); + if(size() == 1 || (currentPlaying != null && !currentPlaying.isSong())) { + rewind(); return; } @@ -1189,8 +1189,8 @@ public class DownloadService extends Service { } public synchronized void next(boolean forceCutoff, boolean forceStart) { // If only one song, just skip within song - if(size() == 1) { - seekTo(getPlayerPosition() + FAST_FORWARD); + if(size() == 1 || (currentPlaying != null && !currentPlaying.isSong())) { + fastForward(); return; } else if(playerState == PREPARING || playerState == PREPARED) { return; diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java index d210fbb0..d97a859b 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java +++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java @@ -145,11 +145,17 @@ public class RemoteControlClientLP extends RemoteControlClientBase { position = downloadService.getPlayerPosition(); } builder.setState(newState, position, 1.0f); - builder.setActions(getPlaybackActions()); - DownloadFile downloadFile = downloadService.getCurrentPlaying(); + Entry entry = null; + boolean isSong = true; if(downloadFile != null) { - Entry entry = downloadFile.getSong(); + entry = downloadFile.getSong(); + isSong = entry.isSong(); + } + + builder.setActions(getPlaybackActions(isSong)); + + if(entry != null) { addCustomActions(entry, builder); builder.setActiveQueueItemId(entry.getId().hashCode()); } @@ -231,7 +237,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase { return mediaSession; } - protected long getPlaybackActions() { + protected long getPlaybackActions(boolean isSong) { long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_SEEK_TO | @@ -239,10 +245,15 @@ public class RemoteControlClientLP extends RemoteControlClientBase { int currentIndex = downloadService.getCurrentPlayingIndex(); int size = downloadService.size(); - if(currentIndex > 0) { + if(isSong) { + if (currentIndex > 0) { + actions |= PlaybackState.ACTION_SKIP_TO_PREVIOUS; + } + if (currentIndex < size - 1) { + actions |= PlaybackState.ACTION_SKIP_TO_NEXT; + } + } else { actions |= PlaybackState.ACTION_SKIP_TO_PREVIOUS; - } - if(currentIndex < size - 1) { actions |= PlaybackState.ACTION_SKIP_TO_NEXT; } @@ -311,7 +322,7 @@ public class RemoteControlClientLP extends RemoteControlClientBase { return null; } - + private void playFromParent(Entry parent) throws Exception { List songs = new ArrayList<>(); getSongsRecursively(parent, songs); -- cgit v1.2.3 From 20dfbfb4d85a9003ee26a2806c231c7cc46bf742 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 13 Jun 2016 08:13:04 -0700 Subject: Add build to logs --- .../main/java/github/daneren2005/dsub/fragments/MainFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java index 4f5f7e6b..8c2fa4bf 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java @@ -1,6 +1,7 @@ package github.daneren2005.dsub.fragments; import android.content.Intent; +import android.content.pm.PackageInfo; import android.content.res.Resources; import android.net.Uri; import android.os.Build; @@ -270,7 +271,7 @@ public class MainFragment extends SelectRecyclerFragment { private void getLogs() { try { - final String version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; + final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); new LoadingTask(context) { @Override protected String doInBackground() throws Throwable { @@ -373,10 +374,11 @@ public class MainFragment extends SelectRecyclerFragment { footer += "\nDevice Name: " + Build.MANUFACTURER + " " + Build.PRODUCT; footer += "\nROM: " + Build.DISPLAY; footer += "\nLogs: " + logcat; + footer += "\nBuild Number: " + packageInfo.versionCode; Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "dsub.android@gmail.com", null)); - email.putExtra(Intent.EXTRA_SUBJECT, "DSub " + version + " Error Logs"); + email.putExtra(Intent.EXTRA_SUBJECT, "DSub " + packageInfo.versionName + " Error Logs"); email.putExtra(Intent.EXTRA_TEXT, "Describe the problem here\n\n\n" + footer); startActivity(email); } -- cgit v1.2.3 From ded7668dff886dd59cf05e3edabaa2521b016797 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 13 Jun 2016 08:18:48 -0700 Subject: Fix Ampache not having some options --- app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java | 2 +- app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java index e4c9b17d..7f538484 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java @@ -203,7 +203,7 @@ public class ServerInfo implements Serializable { } public static boolean hasArtistInfo(Context context) { - if(isStockSubsonic(context) && ServerInfo.checkServerVersion(context, "1.11")) { + if(!isMadsonic(context) && ServerInfo.checkServerVersion(context, "1.11")) { return true; } else if(isMadsonic(context)) { return checkServerVersion(context, "2.0"); diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java index 4c3a121d..5fc4ac83 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java @@ -608,7 +608,7 @@ public class RESTMusicService implements MusicService { int decade = Integer.parseInt(extra); // Reverse chronological order only supported in 5.3+ - if(ServerInfo.checkServerVersion(context, "1.13", instance) && ServerInfo.isStockSubsonic(context, instance)) { + if(ServerInfo.checkServerVersion(context, "1.13", instance) && !ServerInfo.isMadsonic(context, instance)) { values.add(decade + 9); values.add(decade); } else { -- cgit v1.2.3 From 291bd4346cafd8ff6bdfe22104bcf6443478ffd5 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 13 Jun 2016 08:22:46 -0700 Subject: Fixes #708: Typo causing artist options not to show --- .../java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 67bc2565..df79d91f 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -234,7 +234,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section if(!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); } - if(!ServerInfo.checkServerVersion(context, "1.11") || id != null) { + if(!ServerInfo.checkServerVersion(context, "1.11")) { menu.removeItem(R.id.menu_radio); menu.removeItem(R.id.menu_similar_artists); } else if(!ServerInfo.hasSimilarArtists(context)) { -- cgit v1.2.3 From eb606e1a98f3b5896969d8b5fdf20cf12f430b5a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 13 Jun 2016 08:28:10 -0700 Subject: Fixes #707: Fix artists not showing up with First Level Artists --- .../java/github/daneren2005/dsub/fragments/SelectArtistFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java index be371dd3..c9b94c9a 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectArtistFragment.java @@ -218,7 +218,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment i artists.add(artist); } - Indexes indexes = new Indexes(0, artists, new ArrayList()); + Indexes indexes = new Indexes(0, new ArrayList(), artists); indexes.sortChildren(context); items.addAll(indexes.getArtists()); -- cgit v1.2.3 From 9655f0cfdef513793c11560632b0652679412d6a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 13 Jun 2016 17:11:42 -0700 Subject: Fixes #711: Don't encode ' at all --- app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java index 5fc4ac83..edc52c22 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java @@ -1942,7 +1942,7 @@ public class RESTMusicService implements MusicService { for (int i = 0; i < parameterNames.size(); i++) { builder.append("&").append(parameterNames.get(i)).append("="); String part = URLEncoder.encode(String.valueOf(parameterValues.get(i)), "UTF-8"); - part = part.replaceAll("\\%27", "'"); + part = part.replaceAll("\\%27", "'"); builder.append(part); } url = builder.toString(); -- cgit v1.2.3 From 229a45cbded29c975d29d60e3b879266c32e3fbe Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 14 Jun 2016 17:24:09 -0700 Subject: Fixes #710: Show album on Top Tracks --- .../github/daneren2005/dsub/adapter/EntryGridAdapter.java | 6 ++++++ .../daneren2005/dsub/fragments/SelectDirectoryFragment.java | 3 +++ app/src/main/java/github/daneren2005/dsub/view/SongView.java | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java index b07d4731..e75a5104 100644 --- a/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java +++ b/app/src/main/java/github/daneren2005/dsub/adapter/EntryGridAdapter.java @@ -44,6 +44,7 @@ public class EntryGridAdapter extends SectionAdapter { private ImageLoader imageLoader; private boolean largeAlbums; private boolean showArtist = false; + private boolean showAlbum = false; private boolean removeFromPlaylist = false; private View header; @@ -87,6 +88,7 @@ public class EntryGridAdapter extends SectionAdapter { albumView.setObject(entry, imageLoader); } else if(viewType == VIEW_TYPE_SONG) { SongView songView = (SongView) view; + songView.setShowAlbum(showAlbum); songView.setObject(entry, checkable && !entry.isVideo()); } } @@ -123,6 +125,10 @@ public class EntryGridAdapter extends SectionAdapter { this.showArtist = showArtist; } + public void setShowAlbum(boolean showAlbum) { + this.showAlbum = showAlbum; + } + public void removeAt(int index) { sections.get(0).remove(index); if(header != null) { diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index df79d91f..de74d0ed 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -745,6 +745,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section if(!artist) { entryGridAdapter.setShowArtist(true); } + if(topTracks) { + entryGridAdapter.setShowAlbum(true); + } // Show header if not album list type and not root and not artist // For Subsonic 5.1+ display a header for artists with getArtistInfo data if it exists diff --git a/app/src/main/java/github/daneren2005/dsub/view/SongView.java b/app/src/main/java/github/daneren2005/dsub/view/SongView.java index 84e04a0b..8cb0c21c 100644 --- a/app/src/main/java/github/daneren2005/dsub/view/SongView.java +++ b/app/src/main/java/github/daneren2005/dsub/view/SongView.java @@ -71,6 +71,7 @@ public class SongView extends UpdateView2 { private boolean showPodcast = false; private boolean isPlayed = false; private boolean isPlayedShown = false; + private boolean showAlbum = false; public SongView(Context context) { super(context); @@ -114,7 +115,11 @@ public class SongView extends UpdateView2 { } } else if(song.getArtist() != null) { - artist.append(song.getArtist()); + if(showAlbum) { + artist.append(song.getAlbum()); + } else { + artist.append(song.getArtist()); + } } if(isPodcast) { @@ -354,4 +359,8 @@ public class SongView extends UpdateView2 { public void setShowPodcast(boolean showPodcast) { this.showPodcast = showPodcast; } + + public void setShowAlbum(boolean showAlbum) { + this.showAlbum = showAlbum; + } } -- cgit v1.2.3 From 9bfe3e3950b43485b4557e54aae622d7e57faa26 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 14 Jun 2016 17:24:31 -0700 Subject: try/catch onDone results as well --- .../java/github/daneren2005/dsub/util/BackgroundTask.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/util/BackgroundTask.java b/app/src/main/java/github/daneren2005/dsub/util/BackgroundTask.java index fce855fe..31e83200 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/BackgroundTask.java +++ b/app/src/main/java/github/daneren2005/dsub/util/BackgroundTask.java @@ -208,8 +208,18 @@ public abstract class BackgroundTask implements ProgressListener { handler.post(new Runnable() { @Override public void run() { - if(!isCancelled()) { - onDone(result); + if (!isCancelled()) { + try { + onDone(result); + } catch (Throwable t) { + if(!isCancelled()) { + try { + onError(t); + } catch(Exception e) { + // Don't care + } + } + } } taskStart.set(false); -- cgit v1.2.3 From 8c29aa1f88041e4d90edecddd8dbb72254bfa79d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 16 Jun 2016 07:04:31 -0700 Subject: Madsonic 6 uses getSimilarSongs now --- .../java/github/daneren2005/dsub/service/RESTMusicService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java index edc52c22..1f9e5494 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java @@ -696,7 +696,13 @@ public class RESTMusicService implements MusicService { int instance = getInstance(context); String method; - if(ServerInfo.isMadsonic(context, instance)) { + if(ServerInfo.isMadsonic6(context, instance)) { + if (Util.isTagBrowsing(context, instance)) { + method = "getSimilarSongsID3"; + } else { + method = "getSimilarSongs"; + } + } else if(ServerInfo.isMadsonic(context, instance)) { method = "getPandoraSongs"; } else { if (Util.isTagBrowsing(context, instance)) { -- cgit v1.2.3 From 031417c0b9fec1e177ce8e8d2304a4c094e635f4 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 23 Jun 2016 17:43:15 -0700 Subject: Override MediaSession's handling of KeyEvents to get custom logic (ie: double press to skip) --- .../github/daneren2005/dsub/service/DownloadService.java | 5 +++++ .../dsub/service/DownloadServiceLifecycleSupport.java | 2 +- .../dsub/util/compat/RemoteControlClientLP.java | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index eb55ba93..3d3a23b8 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -87,6 +87,7 @@ import android.support.v7.media.MediaRouteSelector; import android.support.v7.media.MediaRouter; import android.util.Log; import android.support.v4.util.LruCache; +import android.view.KeyEvent; /** * @author Sindre Mehus @@ -2663,6 +2664,10 @@ public class DownloadService extends Service { wakeLock.acquire(ms); } + public void handleKeyEvent(KeyEvent keyEvent) { + lifecycleSupport.handleKeyEvent(keyEvent); + } + public void addOnSongChangedListener(OnSongChangedListener listener) { addOnSongChangedListener(listener, false); } diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 5e9e04fc..f8272356 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -386,7 +386,7 @@ public class DownloadServiceLifecycleSupport { return lastChange; } - private void handleKeyEvent(KeyEvent event) { + public void handleKeyEvent(KeyEvent event) { if(event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() > 0) { switch (event.getKeyCode()) { case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS: diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java index d97a859b..df468155 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java +++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java @@ -34,7 +34,10 @@ import android.media.session.PlaybackState; import android.os.Build; import android.os.Bundle; import android.provider.MediaStore; +import android.support.annotation.NonNull; import android.support.v7.media.MediaRouter; +import android.util.Log; +import android.view.KeyEvent; import java.io.Serializable; import java.util.ArrayList; @@ -580,5 +583,18 @@ public class RemoteControlClientLP extends RemoteControlClientBase { downloadService.toggleStarred(); } } + + @Override + public boolean onMediaButtonEvent(@NonNull Intent mediaButtonIntent) { + if (getMediaSession() != null && Intent.ACTION_MEDIA_BUTTON.equals(mediaButtonIntent.getAction())) { + KeyEvent keyEvent = mediaButtonIntent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); + if (keyEvent != null) { + downloadService.handleKeyEvent(keyEvent); + return true; + } + } + + return super.onMediaButtonEvent(mediaButtonIntent); + } } } -- cgit v1.2.3 From 49f80c4810e3388bbaba13d9382cd8c6971bdd75 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 23 Jun 2016 17:49:03 -0700 Subject: Require SSID entry before using local network address --- app/src/main/java/github/daneren2005/dsub/util/Util.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java index 417c3173..9f742ef0 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Util.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java @@ -412,13 +412,15 @@ public final class Util { String serverUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_URL + instance, null); if(allowAltAddress && Util.isWifiConnected(context)) { String SSID = prefs.getString(Constants.PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID + instance, ""); - String currentSSID = Util.getSSID(context); - - String[] ssidParts = SSID.split(","); - if("".equals(SSID) || SSID.equals(currentSSID) || Arrays.asList(ssidParts).contains(currentSSID)) { - String internalUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance, null); - if(internalUrl != null && !"".equals(internalUrl) && !"http://".equals(internalUrl)) { - serverUrl = internalUrl; + if(!SSID.isEmpty()) { + String currentSSID = Util.getSSID(context); + + String[] ssidParts = SSID.split(","); + if ("".equals(SSID) || SSID.equals(currentSSID) || Arrays.asList(ssidParts).contains(currentSSID)) { + String internalUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance, null); + if (internalUrl != null && !"".equals(internalUrl) && !"http://".equals(internalUrl)) { + serverUrl = internalUrl; + } } } } -- cgit v1.2.3 From 5aabf7b1a2e23e479427d8c47c9bbc9bc81ffcd4 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 5 Jul 2016 17:11:47 -0700 Subject: Fixes #718: fix rotation/sleep issues with EQ fragment --- .../dsub/activity/SubsonicFragmentActivity.java | 23 +++++++++++++++++++++- .../github/daneren2005/dsub/util/Constants.java | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/github') diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 17cfdb42..ca6dd168 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -225,7 +225,12 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo bottomBar.setVisibility(View.GONE); nowPlayingToolbar.setVisibility(View.VISIBLE); setSupportActionBar(nowPlayingToolbar); - nowPlayingFragment.setPrimaryFragment(true); + + if(secondaryFragment == null) { + nowPlayingFragment.setPrimaryFragment(true); + } else { + secondaryFragment.setPrimaryFragment(true); + } drawerToggle.setDrawerIndicatorEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(true); @@ -467,6 +472,9 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); savedInstanceState.putString(Constants.MAIN_NOW_PLAYING, nowPlayingFragment.getTag()); + if(secondaryFragment != null) { + savedInstanceState.putString(Constants.MAIN_NOW_PLAYING_SECONDARY, secondaryFragment.getTag()); + } savedInstanceState.putInt(Constants.MAIN_SLIDE_PANEL_STATE, slideUpPanel.getPanelState().hashCode()); } @Override @@ -476,6 +484,19 @@ public class SubsonicFragmentActivity extends SubsonicActivity implements Downlo String id = savedInstanceState.getString(Constants.MAIN_NOW_PLAYING); FragmentManager fm = getSupportFragmentManager(); nowPlayingFragment = (NowPlayingFragment) fm.findFragmentByTag(id); + + String secondaryId = savedInstanceState.getString(Constants.MAIN_NOW_PLAYING_SECONDARY); + if(secondaryId != null) { + secondaryFragment = (SubsonicFragment) fm.findFragmentByTag(secondaryId); + + nowPlayingFragment.setPrimaryFragment(false); + secondaryFragment.setPrimaryFragment(true); + + FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); + trans.hide(nowPlayingFragment); + trans.commit(); + } + if(drawerToggle != null && backStack.size() > 0) { drawerToggle.setDrawerIndicatorEnabled(false); } diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java index ec3489ab..216db54b 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java @@ -190,6 +190,7 @@ public final class Constants { public static final String MAIN_BACK_STACK = "backStackIds"; public static final String MAIN_BACK_STACK_SIZE = "backStackIdsSize"; public static final String MAIN_NOW_PLAYING = "nowPlayingId"; + public static final String MAIN_NOW_PLAYING_SECONDARY = "nowPlayingSecondaryId"; public static final String MAIN_SLIDE_PANEL_STATE = "slidePanelState"; public static final String FRAGMENT_LIST = "fragmentList"; public static final String FRAGMENT_LIST2 = "fragmentList2"; -- cgit v1.2.3