From 1b9e2f0e49c021f5db1df42f218941f2da65e0f7 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 10 May 2014 14:41:13 +0200 Subject: [PATCH] In debug builds, append "(Debug)" to provided route names. --- .../controldlna/localroute/Provider.java | 11 +++-- .../controldlna/upnp/RemotePlayService.java | 44 +++++++++++-------- src/main/res/values/strings.xml | 3 ++ 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/github/nutomic/controldlna/localroute/Provider.java b/src/main/java/com/github/nutomic/controldlna/localroute/Provider.java index db25e51..448848e 100644 --- a/src/main/java/com/github/nutomic/controldlna/localroute/Provider.java +++ b/src/main/java/com/github/nutomic/controldlna/localroute/Provider.java @@ -27,12 +27,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.github.nutomic.controldlna.localroute; -import java.util.ArrayList; - import android.content.Context; import android.content.IntentFilter; import android.content.IntentFilter.MalformedMimeTypeException; -import android.content.res.Resources; import android.media.AudioManager; import android.support.v7.media.MediaControlIntent; import android.support.v7.media.MediaRouteDescriptor; @@ -42,6 +39,8 @@ import android.support.v7.media.MediaRouter; import com.github.nutomic.controldlna.R; +import java.util.ArrayList; + /** * MediaRouteProvider that details the local audio route with its * controls to the system. @@ -83,8 +82,12 @@ final class Provider extends MediaRouteProvider { public Provider(Context context) { super(context); + String routeName = context.getString(R.string.local_device); + if (context.getPackageName().endsWith(".debug")) { + routeName = routeName + " (" + context.getString(R.string.debug) + ")"; + } MediaRouteDescriptor routeDescriptor = new MediaRouteDescriptor.Builder( - ROUTE_ID, context.getResources().getString(R.string.local_device)) + ROUTE_ID, routeName) .addControlFilters(CONTROL_FILTERS) .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE) .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE) diff --git a/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java b/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java index 6a64065..1108f33 100644 --- a/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java +++ b/src/main/java/com/github/nutomic/controldlna/upnp/RemotePlayService.java @@ -27,24 +27,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package com.github.nutomic.controldlna.upnp; -import java.util.Map.Entry; -import java.util.WeakHashMap; -import java.util.concurrent.ConcurrentHashMap; - -import org.teleal.cling.android.AndroidUpnpService; -import org.teleal.cling.android.AndroidUpnpServiceImpl; -import org.teleal.cling.model.action.ActionInvocation; -import org.teleal.cling.model.message.UpnpResponse; -import org.teleal.cling.model.meta.Device; -import org.teleal.cling.model.meta.LocalDevice; -import org.teleal.cling.model.meta.RemoteDevice; -import org.teleal.cling.model.meta.StateVariableAllowedValueRange; -import org.teleal.cling.model.types.ServiceType; -import org.teleal.cling.model.types.UDN; -import org.teleal.cling.registry.Registry; -import org.teleal.cling.registry.RegistryListener; -import org.teleal.cling.support.renderingcontrol.callback.GetVolume; - import android.app.Service; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -61,6 +43,26 @@ import android.os.Messenger; import android.os.RemoteException; import android.util.Log; +import com.github.nutomic.controldlna.R; + +import org.teleal.cling.android.AndroidUpnpService; +import org.teleal.cling.android.AndroidUpnpServiceImpl; +import org.teleal.cling.model.action.ActionInvocation; +import org.teleal.cling.model.message.UpnpResponse; +import org.teleal.cling.model.meta.Device; +import org.teleal.cling.model.meta.LocalDevice; +import org.teleal.cling.model.meta.RemoteDevice; +import org.teleal.cling.model.meta.StateVariableAllowedValueRange; +import org.teleal.cling.model.types.ServiceType; +import org.teleal.cling.model.types.UDN; +import org.teleal.cling.registry.Registry; +import org.teleal.cling.registry.RegistryListener; +import org.teleal.cling.support.renderingcontrol.callback.GetVolume; + +import java.util.Map.Entry; +import java.util.WeakHashMap; +import java.util.concurrent.ConcurrentHashMap; + /** * Allows UPNP playback from different apps by providing a proxy interface. * You can communicate to this service via RemotePlayServiceBinder. @@ -246,9 +248,13 @@ public class RemotePlayService extends Service implements RegistryListener { Message msg = Message.obtain(null, Provider.MSG_RENDERER_ADDED, 0, 0); + String routeName = device.getDetails().getFriendlyName(); + if (getPackageName().endsWith(".debug")) { + routeName = routeName + " (" + getString(R.string.debug) + ")"; + } msg.getData().putParcelable("device", new Provider.Device( device.getIdentity().getUdn().toString(), - device.getDetails().getFriendlyName(), + routeName, device.getDisplayString(), currentVolume, maxVolume)); diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 2ffd8c7..72aea52 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -60,5 +60,8 @@ Contact Developer + + + Debug