diff options
Diffstat (limited to 'app')
6 files changed, 23 insertions, 13 deletions
diff --git a/app/src/google/java/github/daneren2005/dsub/service/ChromeCastController.java b/app/src/google/java/github/daneren2005/dsub/service/ChromeCastController.java index b2405705..2bd4cb59 100644 --- a/app/src/google/java/github/daneren2005/dsub/service/ChromeCastController.java +++ b/app/src/google/java/github/daneren2005/dsub/service/ChromeCastController.java @@ -49,6 +49,8 @@ import github.daneren2005.serverproxy.FileProxy; import github.daneren2005.serverproxy.ServerProxy; import github.daneren2005.serverproxy.WebProxy; +import static github.daneren2005.dsub.util.compat.GoogleCompat.castApplicationId; + /** * Created by owner on 2/9/14. */ @@ -421,14 +423,14 @@ public class ChromeCastController extends RemoteController { void launchApplication() { try { - Cast.CastApi.launchApplication(apiClient, EnvironmentVariables.CAST_APPLICATION_ID, false).setResultCallback(resultCallback); + Cast.CastApi.launchApplication(apiClient, castApplicationId(), false).setResultCallback(resultCallback); } catch (Exception e) { Log.e(TAG, "Failed to launch application", e); } } void reconnectApplication() { try { - Cast.CastApi.joinApplication(apiClient, EnvironmentVariables.CAST_APPLICATION_ID, sessionId).setResultCallback(resultCallback); + Cast.CastApi.joinApplication(apiClient, castApplicationId(), sessionId).setResultCallback(resultCallback); } catch (Exception e) { Log.e(TAG, "Failed to reconnect application", e); } diff --git a/app/src/google/java/github/daneren2005/dsub/util/compat/GoogleCompat.java b/app/src/google/java/github/daneren2005/dsub/util/compat/GoogleCompat.java index 63992b0f..f8bd4ee7 100644 --- a/app/src/google/java/github/daneren2005/dsub/util/compat/GoogleCompat.java +++ b/app/src/google/java/github/daneren2005/dsub/util/compat/GoogleCompat.java @@ -9,6 +9,7 @@ import com.google.android.gms.cast.CastMediaControlIntent; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.security.ProviderInstaller; +import static com.google.android.gms.cast.CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID; import github.daneren2005.dsub.service.ChromeCastController; import github.daneren2005.dsub.service.DownloadService; @@ -32,10 +33,17 @@ public final class GoogleCompat { ProviderInstaller.installIfNeeded(context); } + public static String castApplicationId() { + if (EnvironmentVariables.CAST_APPLICATION_ID != null) { + return EnvironmentVariables.CAST_APPLICATION_ID; + } else { + return DEFAULT_MEDIA_RECEIVER_APPLICATION_ID; + } + } + public static boolean castAvailable() { - if (EnvironmentVariables.CAST_APPLICATION_ID == null) { - Log.w(TAG, "CAST_APPLICATION_ID not provided"); - return false; + if (castApplicationId() == DEFAULT_MEDIA_RECEIVER_APPLICATION_ID) { + Log.i(TAG, "Using DEFAULT_MEDIA_RECEIVER_APPLICATION_ID for casting"); } try { Class.forName("com.google.android.gms.cast.CastDevice"); @@ -56,6 +64,6 @@ public final class GoogleCompat { } public static String getCastControlCategory() { - return CastMediaControlIntent.categoryForCast(EnvironmentVariables.CAST_APPLICATION_ID); + return CastMediaControlIntent.categoryForCast(castApplicationId()); } } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java index 31559305..c5463f38 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SettingsFragment.java @@ -214,7 +214,7 @@ public class SettingsFragment extends PreferenceCompatFragment implements Shared if(downloadService != null) { MediaRouteManager mediaRouter = downloadService.getMediaRouter(); - Boolean enabled = sharedPreferences.getBoolean(key, true); + Boolean enabled = sharedPreferences.getBoolean(key, false); if (enabled) { mediaRouter.addDLNAProvider(); } else { diff --git a/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java b/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java index e1e2dc63..0e80295a 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java +++ b/app/src/main/java/github/daneren2005/dsub/util/DownloadFileItemHelperCallback.java @@ -4,9 +4,9 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.util.Log; -import org.eclipse.jetty.util.ArrayQueue; import java.util.Queue; +import java.util.ArrayDeque; import github.daneren2005.dsub.adapter.SectionAdapter; import github.daneren2005.dsub.fragments.SubsonicFragment; @@ -22,7 +22,7 @@ public class DownloadFileItemHelperCallback extends ItemTouchHelper.SimpleCallba private boolean mainList; private BackgroundTask pendingTask = null; - private Queue pendingOperations = new ArrayQueue(); + private Queue pendingOperations = new ArrayDeque(); public DownloadFileItemHelperCallback(SubsonicFragment fragment, boolean mainList) { super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT); diff --git a/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java b/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java index e19cc156..00e02dab 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java +++ b/app/src/main/java/github/daneren2005/dsub/util/MediaRouteManager.java @@ -141,7 +141,7 @@ public class MediaRouteManager extends MediaRouter.Callback { addOnlineProviders(); } - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Util.getPreferences(downloadService).getBoolean(Constants.PREFERENCES_KEY_DLNA_CASTING_ENABLED, true)) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Util.getPreferences(downloadService).getBoolean(Constants.PREFERENCES_KEY_DLNA_CASTING_ENABLED, false)) { addDLNAProvider(); } } diff --git a/app/src/main/res/xml/settings_cast.xml b/app/src/main/res/xml/settings_cast.xml index 78bafdd4..2170d7ed 100644 --- a/app/src/main/res/xml/settings_cast.xml +++ b/app/src/main/res/xml/settings_cast.xml @@ -33,9 +33,9 @@ android:title="@string/settings.other_title"> <CheckBoxPreference - android:title="@string/settings.casting.dlna_casting_enabled" - android:summary="@string/settings.casting.dlna_casting_enabled.summary" + android:defaultValue="false" android:key="dlnaCastingEnabled" - android:defaultValue="true"/> + android:summary="@string/settings.casting.dlna_casting_enabled.summary" + android:title="@string/settings.casting.dlna_casting_enabled" /> </PreferenceCategory> </PreferenceScreen>
\ No newline at end of file |