From cc2fda01661d693c3cf12e39227d7ceb5112e6a0 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 10 Dec 2013 20:28:40 +0100 Subject: [PATCH] Changed notification to always shouw route fragment. --- .../nutomic/controldlna/gui/MainActivity.java | 13 ++++++++++++- .../nutomic/controldlna/gui/RouteFragment.java | 1 - .../mediarouter/MediaRouterPlayService.java | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/github/nutomic/controldlna/gui/MainActivity.java b/src/com/github/nutomic/controldlna/gui/MainActivity.java index 249ae57..46785e2 100644 --- a/src/com/github/nutomic/controldlna/gui/MainActivity.java +++ b/src/com/github/nutomic/controldlna/gui/MainActivity.java @@ -32,6 +32,7 @@ import java.util.List; import org.teleal.cling.support.model.item.Item; import android.app.AlertDialog; +import android.content.Intent; import android.content.SharedPreferences; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -99,7 +100,8 @@ public class MainActivity extends ActionBarActivity { * shows a warning dialog. */ public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + super.onCreate(savedInstanceState); + onNewIntent(getIntent()); final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); @@ -194,6 +196,15 @@ public class MainActivity extends ActionBarActivity { mRouteFragment = new RouteFragment(); } } + + /** + * Displays the RouteFragment immediately (instead of ServerFragment). + */ + @Override + protected void onNewIntent(Intent intent) { + if (intent.getAction().equals("showRouteFragment")) + mViewPager.setCurrentItem(1); + } /** * Saves fragments. diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index a8f3264..b400977 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -485,7 +485,6 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements if (mListView.getAdapter() == mPlaylistAdapter) enableTrackHighlight(); - } } diff --git a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java index d53fff7..4485c5a 100644 --- a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java +++ b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java @@ -131,9 +131,11 @@ public class MediaRouterPlayService extends Service { artist = track.getArtists()[0].getName(); } } + Intent intent = new Intent(MediaRouterPlayService.this, MainActivity.class); + intent.setAction("showRouteFragment"); Notification notification = new NotificationCompat.Builder(MediaRouterPlayService.this) .setContentIntent(PendingIntent.getActivity(MediaRouterPlayService.this, 0, - new Intent(MediaRouterPlayService.this, MainActivity.class), 0)) + intent, 0)) .setContentTitle(title) .setContentText(artist) .setLargeIcon(result)