From f2d6281d7fe949b1e40e714b4583519b7cc53b43 Mon Sep 17 00:00:00 2001 From: Antoine POPINEAU Date: Sun, 21 Jun 2020 16:14:22 +0200 Subject: [PATCH] Initial setup for flavors and Chromecast support. --- app/build.gradle.kts | 19 +++++++++++++++++++ .../com/github/apognu/otter/utils/Cast.kt | 11 +++++++++++ app/src/full/AndroidManifest.xml | 13 +++++++++++++ .../com/github/apognu/otter/utils/Cast.kt | 17 +++++++++++++++++ app/src/main/AndroidManifest.xml | 8 +++----- .../apognu/otter/activities/MainActivity.kt | 3 ++- .../github/apognu/otter/utils/AppContext.kt | 3 ++- .../java/com/github/apognu/otter/utils/Bus.kt | 1 + app/src/main/res/menu/toolbar.xml | 12 +++++------- 9 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 app/src/foss/java/com/github/apognu/otter/utils/Cast.kt create mode 100644 app/src/full/AndroidManifest.xml create mode 100644 app/src/full/java/com/github/apognu/otter/utils/Cast.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 88eda5f..5fae2ec 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -77,6 +77,22 @@ android { proguardFile("proguard-rules.pro") } } + + flavorDimensions("version") + + productFlavors { + create("full") { + setDimension("version") + + applicationId = "com.github.apognu.otter" + } + + create("foss") { + setDimension("version") + + applicationId = "com.github.apognu.otter.foss" + } + } } ktlint { @@ -122,4 +138,7 @@ dependencies { implementation("com.google.code.gson:gson:2.8.5") implementation("com.squareup.picasso:picasso:2.71828") implementation("jp.wasabeef:picasso-transformations:2.2.1") + + "fullImplementation"("com.google.android.gms:play-services-cast-framework:18.1.0") + "fullImplementation"("com.google.android.exoplayer:extension-cast:2.11.5") } diff --git a/app/src/foss/java/com/github/apognu/otter/utils/Cast.kt b/app/src/foss/java/com/github/apognu/otter/utils/Cast.kt new file mode 100644 index 0000000..eadcf46 --- /dev/null +++ b/app/src/foss/java/com/github/apognu/otter/utils/Cast.kt @@ -0,0 +1,11 @@ +package com.github.apognu.otter + +import android.content.Context +import android.view.Menu +import com.github.apognu.otter.utils.log + +object Cast { + fun init(context: Context) {} + fun setupButton(context: Context, menu: Menu?) {} +} + diff --git a/app/src/full/AndroidManifest.xml b/app/src/full/AndroidManifest.xml new file mode 100644 index 0000000..8d03908 --- /dev/null +++ b/app/src/full/AndroidManifest.xml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/full/java/com/github/apognu/otter/utils/Cast.kt b/app/src/full/java/com/github/apognu/otter/utils/Cast.kt new file mode 100644 index 0000000..94e2a70 --- /dev/null +++ b/app/src/full/java/com/github/apognu/otter/utils/Cast.kt @@ -0,0 +1,17 @@ +package com.github.apognu.otter + +import android.content.Context +import android.view.Menu +import com.google.android.gms.cast.framework.CastButtonFactory +import com.google.android.gms.cast.framework.CastContext + +object Cast { + fun init(context: Context) { + CastContext.getSharedInstance(context) + } + + fun setupButton(context: Context, menu: Menu?) { + CastButtonFactory.setUpMediaRouteButton(context, menu, R.id.cast) + } +} + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 12fe67b..c222b15 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,8 @@ + xmlns:tools="http://schemas.android.com/tools" + package="com.github.apognu.otter" + tools:node="merge"> @@ -17,10 +19,6 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true"> - - { request, response -> diff --git a/app/src/main/java/com/github/apognu/otter/utils/Bus.kt b/app/src/main/java/com/github/apognu/otter/utils/Bus.kt index 1c7d36d..6a8ad84 100644 --- a/app/src/main/java/com/github/apognu/otter/utils/Bus.kt +++ b/app/src/main/java/com/github/apognu/otter/utils/Bus.kt @@ -68,6 +68,7 @@ sealed class Response { object EventBus { fun send(event: Event) { GlobalScope.launch(IO) { + Otter.get().eventBus.log() Otter.get().eventBus.offer(event) } } diff --git a/app/src/main/res/menu/toolbar.xml b/app/src/main/res/menu/toolbar.xml index 8677eeb..31b606f 100644 --- a/app/src/main/res/menu/toolbar.xml +++ b/app/src/main/res/menu/toolbar.xml @@ -6,20 +6,19 @@ android:id="@+id/nav_queue" android:icon="@drawable/queue" android:title="@string/playback_queue" - app:showAsAction="ifRoom" /> + app:showAsAction="always" /> - + app:showAsAction="always" /> + app:showAsAction="always" />