From e09c70e5d112bd6b7142892b25697212a745e963 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 23 Nov 2015 22:21:06 -0800 Subject: Prioritize closest title for autoplay so a query like All American Rejects plays the artist The All American Rejects --- .../daneren2005/dsub/activity/VoiceQueryReceiverActivity.java | 6 +++++- .../java/github/daneren2005/dsub/fragments/SearchFragment.java | 9 +++++---- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'app/src/main/java/github/daneren2005') diff --git a/app/src/main/java/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java index 7ae0ba77..c0effe27 100644 --- a/app/src/main/java/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java +++ b/app/src/main/java/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java @@ -23,7 +23,9 @@ import android.app.Activity; import android.app.SearchManager; import android.content.Intent; import android.os.Bundle; +import android.provider.MediaStore; import android.provider.SearchRecentSuggestions; +import android.util.Log; import github.daneren2005.dsub.fragments.SubsonicFragment; import github.daneren2005.dsub.util.Constants; @@ -38,7 +40,8 @@ import github.daneren2005.dsub.provider.DSubSearchProvider; * @author Sindre Mehus */ public class VoiceQueryReceiverActivity extends Activity { - private static String GMS_SEARCH_ACTION = "com.google.android.gms.actions.SEARCH_ACTION"; + private static final String TAG = VoiceQueryReceiverActivity.class.getSimpleName(); + private static final String GMS_SEARCH_ACTION = "com.google.android.gms.actions.SEARCH_ACTION"; @Override public void onCreate(Bundle savedInstanceState) { @@ -52,6 +55,7 @@ public class VoiceQueryReceiverActivity extends Activity { if(!GMS_SEARCH_ACTION.equals(getIntent().getAction())) { intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true); } + intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, getIntent().getStringExtra(MediaStore.EXTRA_MEDIA_FOCUS)); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); Util.startActivityWithoutTransition(VoiceQueryReceiverActivity.this, intent); } 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 ce36eea6..d21b82e0 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java @@ -284,14 +284,15 @@ public class SearchFragment extends SubsonicFragment implements SectionAdapter.O song.setCloseness(Util.getStringDistance(song.getTitle().toLowerCase(), query)); } - if(artist != null && artist.getCloseness() <= MIN_CLOSENESS) { + if(artist != null && (artist.getCloseness() <= MIN_CLOSENESS || + (album == null || artist.getCloseness() <= album.getCloseness()) && + (song == null || artist.getCloseness() <= song.getCloseness()))) { onArtistSelected(artist, true); - } else if(album != null && album.getCloseness() <= MIN_CLOSENESS) { + } else if(album != null && (album.getCloseness() <= MIN_CLOSENESS || + song == null || album.getCloseness() <= song.getCloseness())) { onAlbumSelected(album, true); } else if(song != null) { onSongSelected(song, false, false, true, false); - } else if(album != null) { - onAlbumSelected(album, true); } } } -- cgit v1.2.3