diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-11-23 22:21:06 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-11-23 22:21:06 -0800 |
commit | e09c70e5d112bd6b7142892b25697212a745e963 (patch) | |
tree | 79138a66fe839adcf253a2ebe91442d865d74f44 /app | |
parent | e9fc1f04ed660a050896a43425a12fac5908f822 (diff) | |
download | dsub-e09c70e5d112bd6b7142892b25697212a745e963.tar.gz dsub-e09c70e5d112bd6b7142892b25697212a745e963.tar.bz2 dsub-e09c70e5d112bd6b7142892b25697212a745e963.zip |
Prioritize closest title for autoplay so a query like All American Rejects plays the artist The All American Rejects
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java | 6 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/fragments/SearchFragment.java | 9 |
2 files changed, 10 insertions, 5 deletions
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); } } } |