From 8f5c36b9178642ea10b77611b025afc49ee2e8c6 Mon Sep 17 00:00:00 2001 From: Felix Date: Thu, 11 Jun 2020 21:51:22 +0200 Subject: [PATCH] change touch and leanback into library modules. debug is working, release not yet --- app/build.gradle | 90 ++++++---- app/src/main/AndroidManifest.xml | 34 +++- common/build.gradle | 107 +++++------ common/src/main/res/xml/debug_settings.xml | 4 + flavors.gradle | 63 +++++++ leanback/build.gradle | 158 ++++++++-------- leanback/src/main/AndroidManifest.xml | 9 +- .../conferences/ConferencesBrowseFragment.kt | 2 +- .../leanback/detail/EventDetailsFragment.kt | 2 +- leanback/src/main/res/values/styles.xml | 2 +- touch/build.gradle | 170 +++++++++--------- touch/src/main/AndroidManifest.xml | 10 +- .../touch/settings/SettingsFragment.kt | 18 +- .../res/layout/fragment_event_details.xml | 4 +- 14 files changed, 418 insertions(+), 255 deletions(-) create mode 100644 flavors.gradle diff --git a/app/build.gradle b/app/build.gradle index 542cdefd..f7c9f726 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,8 +3,10 @@ plugins { id 'kotlin-android' id 'kotlin-kapt' id 'kotlin-android-extensions' -// id 'com.github.triplet.play' version '2.6.2' + id 'com.github.triplet.play' version '2.6.2' } +apply from: "${rootProject.projectDir}/flavors.gradle" + String appName = "Chaosflix" String versionString = new File("versionfile").text.trim() @@ -22,17 +24,16 @@ android { versionCode 1 versionName versionString - if(project.hasProperty("versionCode")){ + if (project.hasProperty("versionCode")) { versionCode = project.property("versionCode") as int println "Setting VersionCode from property: $versionCode" } - if(project.hasProperty("versionName")){ + if (project.hasProperty("versionName")) { versionName = project.property("versionName") as String println "Setting versionName from property: $versionName" } } - signingConfigs { //noinspection GroovyMissingReturnStatement, GroovyAssignabilityCheck release { @@ -65,40 +66,67 @@ android { } } - flavorDimensions "stage", "libs" + with flavorConfig +// flavorDimensions "stage", "libs" +// +// productFlavors { +// prod { +// dimension "stage" +// } +// dev { +// dimension "stage" +// applicationIdSuffix ".dev" +// manifestPlaceholders = [label: appName + "-Dev"] +// } +// mock { +// dimension "stage" +// applicationIdSuffix ".mock" +// manifestPlaceholders = [label: appName + "-Mock"] +// } +// free { +// dimension "libs" +// } +// noFree { +// dimension "libs" +// } +// } - productFlavors { - prod { - dimension "stage" - } - dev { - dimension "stage" - applicationIdSuffix ".dev" - manifestPlaceholders = [label: appName + "-Dev"] - } - mock { - dimension "stage" - applicationIdSuffix ".mock" - manifestPlaceholders = [label: appName + "-Mock"] - } - free { - dimension "libs" - } - noFree { - dimension "libs" + playConfigs { + prodNoFree { + enabled = true } } + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } + + dataBinding.enabled = true + viewBinding.enabled = true + } -configurations { - mockDebugCompile - prodDebugCompile - prodReleaseCompile -} +//configurations { +// devFreeDebugImplementation +// devNoFreeDebugImplementation +// devFreeReleaseImplementation +// devNoFreeReleaseImplementation +// mockDebugImplementation +// prodDebugImplementation +// prodReleaseImplementation +//} dependencies { -// implementation project(':touch') -// implementation project(':leanback') + implementation project(':touch') + implementation project(':leanback') implementation project(':common') } + +play { + serviceAccountCredentials = file("../chaosflix-d1d09f33cbb2.json") + track = "alpha" + releaseStatus = "draft" + enabled = false + artifactDir = file("build/outputs/apk/prodNoFree/release/app-prod-noFree-release.apk") +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 583b4f99..12e7c9e8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,10 +10,40 @@ android:label="${label}" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme" - tools:ignore="GoogleAppIndexingWarning"> + tools:ignore="GoogleAppIndexingWarning" + tools:replace="android:label"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index 199d4806..c6e67632 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,7 +1,11 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' -apply plugin: "de.mannodermaus.android-junit5" +plugins { + id 'com.android.library' + id 'kotlin-android' + id 'kotlin-kapt' + id "de.mannodermaus.android-junit5" +} +apply from: "${rootProject.projectDir}/flavors.gradle" + String versionString = new File("versionfile").text.trim() @@ -48,53 +52,54 @@ android { } } - flavorDimensions "stage", "libs" - - productFlavors { - prod { - dimension "stage" - } - - dev { - dimension "stage" - } - - mock { - dimension "stage" - buildConfigField "String", "STREAMING_API_BASE_URL", "\"https://gist.githubusercontent.com\"" - buildConfigField "String", "STREAMING_API_OFFERS_PATH", "\"/NiciDieNase/1ca017f180242f0ee683a1f592efc4ed/raw/0104592b57f4b29863fd0684a510462af276f30e/example_streams_v2.json\"" - } - - free { - dimension "libs" - - ext { - prod = null - dev = null - mock = null - } - } - noFree { - dimension "libs" - ext { - if (project.hasProperty("appcenterId")) { - prod = appcenterId - } else { - prod = null - println "AppcenterId not set" - } - if (project.hasProperty("appcenterDevId")) { - dev = appcenterDevId - mock = appcenterDevId - } else { - dev = null - mock = null - println "AppcenterId not set" - } - - } - } - } + with flavorConfig +// flavorDimensions "stage", "libs" +// +// productFlavors { +// prod { +// dimension "stage" +// } +// +// dev { +// dimension "stage" +// } +// +// mock { +// dimension "stage" +// buildConfigField "String", "STREAMING_API_BASE_URL", "\"https://gist.githubusercontent.com\"" +// buildConfigField "String", "STREAMING_API_OFFERS_PATH", "\"/NiciDieNase/1ca017f180242f0ee683a1f592efc4ed/raw/0104592b57f4b29863fd0684a510462af276f30e/example_streams_v2.json\"" +// } +// +// free { +// dimension "libs" +// +// ext { +// prod = null +// dev = null +// mock = null +// } +// } +// noFree { +// dimension "libs" +// ext { +// if (project.hasProperty("appcenterId")) { +// prod = appcenterId +// } else { +// prod = null +// println "AppcenterId not set" +// } +// if (project.hasProperty("appcenterDevId")) { +// dev = appcenterDevId +// mock = appcenterDevId +// } else { +// dev = null +// mock = null +// println "AppcenterId not set" +// } +// +// } +// } +// } libraryVariants.all { variant -> def flavors = variant.productFlavors diff --git a/common/src/main/res/xml/debug_settings.xml b/common/src/main/res/xml/debug_settings.xml index 6112cc49..c32a4fac 100644 --- a/common/src/main/res/xml/debug_settings.xml +++ b/common/src/main/res/xml/debug_settings.xml @@ -23,6 +23,10 @@ android:id="@+id/import_favorites" android:key="import_favorites" android:title="@string/import_favorites"/> + \ No newline at end of file diff --git a/flavors.gradle b/flavors.gradle new file mode 100644 index 00000000..6c456521 --- /dev/null +++ b/flavors.gradle @@ -0,0 +1,63 @@ +String appName = "Chaosflix" +//String versionString = new File("versionfile").text.trim() + +ext.flavorConfig = { + flavorDimensions "stage", "libs" + + productFlavors { + prod { + dimension "stage" + } + dev { + dimension "stage" +// applicationIdSuffix ".dev" + ext.myApplicationIdSuffix = ".dev" + manifestPlaceholders = [label: appName + "-Dev"] + } + mock { + dimension "stage" + ext.myApplicationIdSuffix = ".mock" + manifestPlaceholders = [label: appName + "-Mock"] + buildConfigField "String", "STREAMING_API_BASE_URL", "\"https://gist.githubusercontent.com\"" + buildConfigField "String", "STREAMING_API_OFFERS_PATH", "\"/NiciDieNase/1ca017f180242f0ee683a1f592efc4ed/raw/0104592b57f4b29863fd0684a510462af276f30e/example_streams_v2.json\"" + } + free { + dimension "libs" + ext { + prod = null + dev = null + mock = null + } + } + noFree { + dimension "libs" + ext { + if (project.hasProperty("appcenterId")) { + prod = appcenterId + } else { + prod = null + println "AppcenterId not set" + } + if (project.hasProperty("appcenterDevId")) { + dev = appcenterDevId + mock = appcenterDevId + } else { + dev = null + mock = null + println "AppcenterId not set" + } + + } + } + } + + productFlavors.all { flavor -> + if (flavor.hasProperty('myApplicationIdSuffix') && isApplicationProject()) { + flavor.applicationIdSuffix = flavor.myApplicationIdSuffix + } + } +} + +def isApplicationProject() { + return project.android.class.simpleName.startsWith('BaseAppModuleExtension') +} diff --git a/leanback/build.gradle b/leanback/build.gradle index 91130325..d9ed7900 100644 --- a/leanback/build.gradle +++ b/leanback/build.gradle @@ -1,90 +1,94 @@ plugins { - id 'com.android.application' + id 'com.android.library' +// id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' id 'kotlin-android-extensions' - id 'com.github.triplet.play' version '2.6.2' +// id 'com.github.triplet.play' version '2.6.2' } +apply from: "${rootProject.projectDir}/flavors.gradle" -String appName = "Chaosflix" -String versionString = new File("versionfile").text.trim() + +//String appName = "Chaosflix" +//String versionString = new File("versionfile").text.trim() android { buildToolsVersion '27.0.3' compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { - applicationId "de.nicidienase.chaosflix" - manifestPlaceholders = [label: appName] +// applicationId "de.nicidienase.chaosflix" +// manifestPlaceholders = [label: appName] minSdkVersion rootProject.ext.minSDK targetSdkVersion rootProject.ext.targetSDK // odd for touch, even for leanback versionCode 1 - versionName versionString - if(project.hasProperty("versionCode")){ - versionCode = project.property("versionCode") as int - println "Setting VersionCode from property: $versionCode" - } - } - signingConfigs { - //noinspection GroovyMissingReturnStatement, GroovyAssignabilityCheck - release { - if (project.hasProperty("chaosflixKeystore") && file(chaosflixKeystore).exists() && file(chaosflixKeystore).isFile()) { - println "Release app signing is configured: will sign APK" - storeFile file(chaosflixKeystore) - storePassword chaosflixStorePassword - keyAlias chaosflixKeyName - keyPassword chaosflixKeyPassword - } else { - println "App signing data not found. Will not sign." - } - } +// versionName versionString +// if(project.hasProperty("versionCode")){ +// versionCode = project.property("versionCode") as int +// println "Setting VersionCode from property: $versionCode" +// } } +// signingConfigs { +// //noinspection GroovyMissingReturnStatement, GroovyAssignabilityCheck +// release { +// if (project.hasProperty("chaosflixKeystore") && file(chaosflixKeystore).exists() && file(chaosflixKeystore).isFile()) { +// println "Release app signing is configured: will sign APK" +// storeFile file(chaosflixKeystore) +// storePassword chaosflixStorePassword +// keyAlias chaosflixKeyName +// keyPassword chaosflixKeyPassword +// } else { +// println "App signing data not found. Will not sign." +// } +// } +// } buildTypes { debug { - applicationIdSuffix ".debug" - manifestPlaceholders = [label: appName + "-debug"] +// applicationIdSuffix ".debug" +// manifestPlaceholders = [label: appName + "-debug"] minifyEnabled false } release { minifyEnabled true - shrinkResources true +// shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro' - if (project.hasProperty("chaosflixKeystore") && file(chaosflixKeystore).exists() && file(chaosflixKeystore).isFile()) { - signingConfig signingConfigs.release - } +// if (project.hasProperty("chaosflixKeystore") && file(chaosflixKeystore).exists() && file(chaosflixKeystore).isFile()) { +// signingConfig signingConfigs.release +// } } } - flavorDimensions "stage", "libs" - - productFlavors { - prod { - dimension "stage" - } - dev { - dimension "stage" - applicationIdSuffix ".dev" - manifestPlaceholders = [label: appName + "-Dev"] - } - mock { - dimension "stage" - applicationIdSuffix ".mock" - manifestPlaceholders = [label: appName + "-Mock"] - } - free { - dimension "libs" - } - noFree{ - dimension "libs" - } - } - variantFilter { variant -> - def names = variant.flavors*.name - if (name.contains("prod") && name.contains("Debug")){ - setIgnore(true) - } - } + with flavorConfig +// flavorDimensions "stage", "libs" +// +// productFlavors { +// prod { +// dimension "stage" +// } +// dev { +// dimension "stage" +//// applicationIdSuffix ".dev" +//// manifestPlaceholders = [label: appName + "-Dev"] +// } +// mock { +// dimension "stage" +//// applicationIdSuffix ".mock" +//// manifestPlaceholders = [label: appName + "-Mock"] +// } +// free { +// dimension "libs" +// } +// noFree{ +// dimension "libs" +// } +// } +// variantFilter { variant -> +// def names = variant.flavors*.name +// if (name.contains("prod") && name.contains("Debug")){ +// setIgnore(true) +// } +// } packagingOptions { @@ -104,18 +108,22 @@ android { lintOptions.abortOnError = false dataBinding.enabled = true buildToolsVersion rootProject.ext.buildToolsVersion - playConfigs { - prodNoFree { - enabled = true - } - } +// playConfigs { +// prodNoFree { +// enabled = true +// } +// } } -configurations { - mockDebugCompile - prodDebugCompile - prodReleaseCompile -} +//configurations { +// devFreeDebugCompile +// devNoFreeDebugCompile +// devFreeReleaseCompile +// devNoFreeReleaseCompile +// mockDebugCompile +// prodDebugCompile +// prodReleaseCompile +//} dependencies { @@ -142,9 +150,9 @@ dependencies { androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.6.0' } -play { - serviceAccountCredentials = file("../chaosflix-d1d09f33cbb2.json") - track = "Alpha" - enabled = false -} +//play { +// serviceAccountCredentials = file("../chaosflix-d1d09f33cbb2.json") +// track = "Alpha" +// enabled = false +//} diff --git a/leanback/src/main/AndroidManifest.xml b/leanback/src/main/AndroidManifest.xml index 26b051fc..2226a9ee 100644 --- a/leanback/src/main/AndroidManifest.xml +++ b/leanback/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:label="${label}" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@style/AppTheme" + android:theme="@style/LeanbackAppTheme" tools:replace="android:label" tools:ignore="GoogleAppIndexingWarning"> @@ -35,11 +36,13 @@ + android:parentActivityName=".conferences.ConferencesActivity" + android:theme="@style/LeanbackAppTheme"/> + android:parentActivityName=".conferences.ConferencesActivity" + android:theme="@style/LeanbackAppTheme"> diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesBrowseFragment.kt b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesBrowseFragment.kt index 6acfc618..44a85bb5 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesBrowseFragment.kt +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/conferences/ConferencesBrowseFragment.kt @@ -358,7 +358,7 @@ class ConferencesBrowseFragment : BrowseSupportFragment() { } companion object { - const val FRAGMENT = R.id.browse_fragment + private val FRAGMENT = R.id.browse_fragment private val TAG = ConferencesBrowseFragment::class.java.simpleName } } diff --git a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt index 50348e98..d3859057 100644 --- a/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt +++ b/leanback/src/main/java/de/nicidienase/chaosflix/leanback/detail/EventDetailsFragment.kt @@ -393,7 +393,7 @@ class EventDetailsFragment : DetailsSupportFragment() { private const val DETAIL_THUMB_WIDTH = 254 private const val DETAIL_THUMB_HEIGHT = 143 - const val DEFAULT_DRAWABLE = R.drawable.default_background + private val DEFAULT_DRAWABLE = R.drawable.default_background private const val ACTION_PLAY: Long = 0L private const val ACTION_ADD_WATCHLIST = 1L diff --git a/leanback/src/main/res/values/styles.xml b/leanback/src/main/res/values/styles.xml index ad9ba0a9..df0c1ebe 100644 --- a/leanback/src/main/res/values/styles.xml +++ b/leanback/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ -