From fbfb5a7464bd29131cfa8f4ef9da28c7b92c404b Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 4 Nov 2013 20:54:48 -0800 Subject: #162 Remove use of SearchActivity --- .../dsub/activity/QueryReceiverActivity.java | 7 ++- .../daneren2005/dsub/activity/SearchActivity.java | 68 ---------------------- .../dsub/activity/SubsonicActivity.java | 26 +++++++++ .../dsub/activity/VoiceQueryReceiverActivity.java | 7 ++- .../daneren2005/dsub/fragments/SearchFragment.java | 6 +- .../dsub/fragments/SelectDirectoryFragment.java | 4 -- .../dsub/fragments/SubsonicFragment.java | 7 --- 7 files changed, 38 insertions(+), 87 deletions(-) delete mode 100644 src/github/daneren2005/dsub/activity/SearchActivity.java (limited to 'src/github') diff --git a/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java b/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java index 15d0c6a6..7a19fcb5 100644 --- a/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java +++ b/src/github/daneren2005/dsub/activity/QueryReceiverActivity.java @@ -24,12 +24,14 @@ import android.app.SearchManager; import android.content.Intent; import android.os.Bundle; import android.provider.SearchRecentSuggestions; + +import github.daneren2005.dsub.fragments.SubsonicFragment; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.provider.DSubSearchProvider; /** - * Receives search queries and forwards to the SelectAlbumActivity. + * Receives search queries and forwards to the SearchFragment. * * @author Sindre Mehus */ @@ -46,8 +48,9 @@ public class QueryReceiverActivity extends Activity { DSubSearchProvider.MODE); suggestions.saveRecentQuery(query, null); - Intent intent = new Intent(QueryReceiverActivity.this, SearchActivity.class); + Intent intent = new Intent(QueryReceiverActivity.this, SubsonicFragmentActivity.class); intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query); + intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); Util.startActivityWithoutTransition(QueryReceiverActivity.this, intent); } finish(); diff --git a/src/github/daneren2005/dsub/activity/SearchActivity.java b/src/github/daneren2005/dsub/activity/SearchActivity.java deleted file mode 100644 index 2f3a4a46..00000000 --- a/src/github/daneren2005/dsub/activity/SearchActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of Subsonic. - - Subsonic is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Subsonic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Subsonic. If not, see . - - Copyright 2009 (C) Sindre Mehus - */ - -package github.daneren2005.dsub.activity; - -import github.daneren2005.dsub.R; -import android.content.Intent; -import android.os.Bundle; -import android.view.MenuItem; - -import github.daneren2005.dsub.fragments.SearchFragment; -import github.daneren2005.dsub.util.Constants; - -public class SearchActivity extends SubsonicActivity { - private static final String TAG = SearchActivity.class.getSimpleName(); - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.download_activity); - - if (findViewById(R.id.download_container) != null && savedInstanceState == null) { - currentFragment = new SearchFragment(); - currentFragment.setPrimaryFragment(true); - getSupportFragmentManager().beginTransaction().add(R.id.download_container, currentFragment, currentFragment.getSupportTag() + "").commit(); - } - } - - @Override - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - - if(currentFragment != null && 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 { - ((SearchFragment)currentFragment).populateList(); - if (requestsearch) { - onSearchRequested(); - } - } - } - } - - public void onSupportNewIntent(Intent intent) { - onNewIntent(intent); - } -} \ No newline at end of file diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 22d2a62c..b99055de 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -51,6 +51,7 @@ import android.widget.ListView; import android.widget.Spinner; import github.daneren2005.dsub.R; +import github.daneren2005.dsub.fragments.SearchFragment; import github.daneren2005.dsub.fragments.SubsonicFragment; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.DownloadServiceImpl; @@ -331,6 +332,31 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte public void onNothingSelected(AdapterView parent) { } + + @Override + public void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + if(currentFragment != null && 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 { + ((SearchFragment)currentFragment).populateList(); + if (requestsearch) { + onSearchRequested(); + } + } + } else if(intent.getStringExtra(Constants.INTENT_EXTRA_NAME_QUERY) != null) { + setIntent(intent); + + SearchFragment fragment = new SearchFragment(); + replaceFragment(fragment, currentFragment.getRootId(), fragment.getSupportTag()); + } + } private void populateDrawer() { SharedPreferences prefs = Util.getPreferences(this); diff --git a/src/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java b/src/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java index 5cda9ee5..e37696d5 100644 --- a/src/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java +++ b/src/github/daneren2005/dsub/activity/VoiceQueryReceiverActivity.java @@ -24,12 +24,14 @@ import android.app.SearchManager; import android.content.Intent; import android.os.Bundle; import android.provider.SearchRecentSuggestions; + +import github.daneren2005.dsub.fragments.SubsonicFragment; import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.provider.DSubSearchProvider; /** - * Receives voice search queries and forwards to the SearchActivity. + * Receives voice search queries and forwards to the SearchFragment. * * http://android-developers.blogspot.com/2010/09/supporting-new-music-voice-action.html * @@ -48,9 +50,10 @@ public class VoiceQueryReceiverActivity extends Activity { DSubSearchProvider.MODE); suggestions.saveRecentQuery(query, null); - Intent intent = new Intent(VoiceQueryReceiverActivity.this, SearchActivity.class); + Intent intent = new Intent(VoiceQueryReceiverActivity.this, SubsonicFragmentActivity.class); intent.putExtra(Constants.INTENT_EXTRA_NAME_QUERY, query); intent.putExtra(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true); + intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); Util.startActivityWithoutTransition(VoiceQueryReceiverActivity.this, intent); } finish(); diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java index 566fbbe1..61516e28 100644 --- a/src/github/daneren2005/dsub/fragments/SearchFragment.java +++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java @@ -18,11 +18,9 @@ import android.view.MenuItem; import android.widget.AdapterView; import android.widget.ListAdapter; import android.widget.ListView; -import android.widget.TextView; import android.net.Uri; import android.view.ViewGroup; import github.daneren2005.dsub.R; -import github.daneren2005.dsub.activity.SearchActivity; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.SearchCritera; @@ -126,7 +124,7 @@ public class SearchFragment extends SubsonicFragment { } }); registerForContextMenu(list); - ((SearchActivity)context).onSupportNewIntent(context.getIntent()); + context.onNewIntent(context.getIntent()); if(searchResult != null) { skipSearch = true; @@ -182,7 +180,7 @@ public class SearchFragment extends SubsonicFragment { public void setPrimaryFragment(boolean primary) { super.setPrimaryFragment(primary); if(rootView != null && primary) { - ((SearchActivity)context).onSupportNewIntent(context.getIntent()); + context.onNewIntent(context.getIntent()); } } diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 8c99fe01..e17d2d7b 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -24,7 +24,6 @@ import java.io.Serializable; import java.util.List; import com.mobeta.android.dslv.*; import github.daneren2005.dsub.activity.DownloadActivity; -import github.daneren2005.dsub.activity.SearchActivity; import github.daneren2005.dsub.domain.PodcastEpisode; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; @@ -594,9 +593,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } if (autoplay) { Util.startActivityWithoutTransition(context, DownloadActivity.class); - if(context instanceof SearchActivity) { - context.finish(); - } } else if (save) { Util.toast(context, context.getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size())); diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 99e253f5..18c9476a 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -42,7 +42,6 @@ import android.widget.EditText; import android.widget.TextView; import github.daneren2005.dsub.R; import github.daneren2005.dsub.activity.DownloadActivity; -import github.daneren2005.dsub.activity.SearchActivity; import github.daneren2005.dsub.activity.SettingsActivity; import github.daneren2005.dsub.activity.SubsonicActivity; import github.daneren2005.dsub.activity.SubsonicFragmentActivity; @@ -250,9 +249,6 @@ public class SubsonicFragment extends Fragment { getDownloadService().clear(); getDownloadService().download(songs, false, true, true, false); Util.startActivityWithoutTransition(context, DownloadActivity.class); - if(context instanceof SearchActivity) { - context.finish(); - } break; case R.id.song_menu_play_next: getDownloadService().download(songs, false, false, true, false); @@ -649,9 +645,6 @@ public class SubsonicFragment extends Fragment { downloadService.download(songs, save, autoplay, false, shuffle); if(!append) { Util.startActivityWithoutTransition(context, DownloadActivity.class); - if(context instanceof SearchActivity) { - context.finish(); - } } } else { -- cgit v1.2.3