Skip to content

Commit

Permalink
chore: Added build flavors to separate FULL and DEMO app releases.
Browse files Browse the repository at this point in the history
fix: Subtitle based on build flavor. Demo package name ignored in settings on purpose.
  • Loading branch information
baruckis committed Mar 1, 2019
1 parent dc5ac82 commit cca891a
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 11 deletions.
13 changes: 11 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ android {
dataBinding {
enabled = true
}

// Configure only for each module that uses Java 8 language features
// (either in its source code or through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "version"
productFlavors {
demo {
applicationIdSuffix ".demo"
// This new string resource item will be generated at build time.
resValue "string", "app_id_suffix", ".demo"
}
full {
resValue "string", "app_id_suffix", ""
}
}
}

// We use Parcelize which is an experimental feature at the moment so we need to add the following
Expand Down Expand Up @@ -207,5 +217,4 @@ dependencies {

// Dependencies for local unit tests. JUnit is a unit testing framework for Java.
testImplementation "junit:junit:$versions.junit"

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2018-2019 Andrius Baruckis www.baruckis.com | mycryptocoins.baruckis.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.baruckis.mycryptocoins.utilities

/**
* Constants used throughout the app for DEMO build.
*/

// This testing sandbox has free access to all endpoints and all subscription plans to test with a
// snapshot of CoinMarketCap market data. It is used for DEMO purpose.
const val API_SERVICE_BASE_URL = "https://sandbox-api.coinmarketcap.com/"

const val API_SERVICE_AUTHENTICATION_KEY = "" // TODO: Use your API Key provided by CoinMarketCap Professional API Developer Portal.

// This is dedicated test Ad Unit ID for Android rewarded video.
const val ADMOB_AD_UNIT_ID = "ca-app-pub-3940256099942544/5224354917"
27 changes: 27 additions & 0 deletions app/src/demo/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2018-2019 Andrius Baruckis www.baruckis.com | mycryptocoins.baruckis.com
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- Strings used throughout the app for DEMO build. -->

<resources>

<string name="app_version" translatable="false">@string/app_version_demo</string>
<string name="app_subtitle" translatable="false">@string/app_subtitle_demo</string>

<!-- App ID provided by Google AdMob is just for testing. -->
<string name="admob_app_id" translatable="false">"ca-app-pub-3940256099942544~3347511713"</string>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2018-2019 Andrius Baruckis www.baruckis.com | mycryptocoins.baruckis.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.baruckis.mycryptocoins.utilities

/**
* Constants used throughout the app for FULL build.
*/

// This is live production environment with the latest market data of CoinMarketCap.
// It is used for FULL release version to Google Play Store.
const val API_SERVICE_BASE_URL = "https://pro-api.coinmarketcap.com/"

const val API_SERVICE_AUTHENTICATION_KEY = "" // TODO: Use your API Key provided by CoinMarketCap Professional API Developer Portal.

// This is dedicated real Ad Unit ID for Android rewarded video.
const val ADMOB_AD_UNIT_ID = "" // TODO: Use your Ad Unit ID provided by Google AdMob.
27 changes: 27 additions & 0 deletions app/src/full/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright 2018-2019 Andrius Baruckis www.baruckis.com | mycryptocoins.baruckis.com
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- Strings used throughout the app for FULL build. -->

<resources>

<string name="app_version" translatable="false">@string/app_version_full</string>
<string name="app_subtitle" translatable="false">@string/app_subtitle_full</string>

<!-- TODO: Use your App ID provided by Google AdMob. -->
<string name="admob_app_id" translatable="false">""</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class MainActivity : BaseActivity(), HasSupportFragmentInjector {
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)

supportActionBar?.subtitle = getString(R.string.app_subtitle)

subscribeUi()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class SettingsFragment : PreferenceFragmentCompat(), Injectable, RewardedVideoAd
// Link in Google Play store app on the phone.
private fun openAppInPlayStore() {
val uri = Uri.parse("market://" + GOOGLE_PLAY_STORE_APP_DETAILS_PATH +
context?.packageName)
getPackageName())
val goToMarketIntent = Intent(Intent.ACTION_VIEW, uri)

var flags = Intent.FLAG_ACTIVITY_NO_HISTORY or
Expand All @@ -397,7 +397,7 @@ class SettingsFragment : PreferenceFragmentCompat(), Injectable, RewardedVideoAd
} catch (e: ActivityNotFoundException) {
val intent = Intent(Intent.ACTION_VIEW,
Uri.parse(GOOGLE_PLAY_STORE_APPS_URL +
GOOGLE_PLAY_STORE_APP_DETAILS_PATH + context?.packageName))
GOOGLE_PLAY_STORE_APP_DETAILS_PATH + getPackageName()))

startActivity(intent, null)
}
Expand All @@ -412,9 +412,15 @@ class SettingsFragment : PreferenceFragmentCompat(), Injectable, RewardedVideoAd
intent.putExtra(Intent.EXTRA_TEXT,
viewModel.stringsLocalization.getString(R.string.share_app_message) +
GOOGLE_PLAY_STORE_APPS_URL + GOOGLE_PLAY_STORE_APP_DETAILS_PATH +
context?.packageName)
getPackageName())
startActivity(Intent.createChooser(intent,
viewModel.stringsLocalization.getString(R.string.share_app_chooser)))
}

private fun getPackageName(): String? {
// Get a string resource item generated at build time by Gradle.
val suffix = getString(R.string.app_id_suffix)
return context?.packageName?.removeSuffix(suffix)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ const val PERCENT_FORMAT_PATTERN = "##0.00"
const val ADD_TASK_REQUEST = 1
const val SERVER_CALL_DELAY_MILLISECONDS: Long = 1000
const val FLIPVIEW_CHARACTER_LIMIT = 3
const val API_SERVICE_BASE_URL = "https://sandbox-api.coinmarketcap.com/"

const val API_SERVICE_AUTHENTICATION_NAME = "X-CMC_PRO_API_KEY"
const val API_SERVICE_AUTHENTICATION_KEY = "" // TODO: Use your API Key provided by CoinMarketCap Professional API Developer Portal.

const val API_SERVICE_RESULTS_LIMIT = 5000 // This is max number from CoinMarketCap API.
const val TIME_12h_FORMAT_PATTERN = "hh:mm:ss"
const val TIME_24h_FORMAT_PATTERN = "HH:mm:ss"
const val CRYPTOCURRENCY_IMAGE_URL = "https://s2.coinmarketcap.com/static/img/coins"
const val CRYPTOCURRENCY_IMAGE_SIZE_PX = "128x128"
const val CRYPTOCURRENCY_IMAGE_FILE = ".png"
const val SEARCH_TYPING_DELAY_MILLISECONDS: Long = 500
const val ADMOB_AD_UNIT_ID = "ca-app-pub-3940256099942544/5224354917" // TODO: Use your Ad Unit ID provided by Google AdMob. This is dedicated test Ad Unit ID for Android rewarded video.

const val GOOGLE_PLAY_STORE_APPS_URL = "https://play.google.com/store/apps/"
const val GOOGLE_PLAY_STORE_APP_DETAILS_PATH = "details?id="
8 changes: 5 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

<string name="app_name">"My Crypto Coins"</string>

<string name="app_version" translatable="false">"v1.0.0"</string>
<!-- major . minor . patch -->
<string name="app_version_full" translatable="false">"v1.0.0"</string>
<string name="app_version_demo" translatable="false">"v1.0.0 DEMO"</string>

<!-- TODO: Use your App ID provided by Google AdMob. This one is just for testing. -->
<string name="admob_app_id" translatable="false">"ca-app-pub-3940256099942544~3347511713"</string>
<string name="app_subtitle_full" translatable="false">""</string>
<string name="app_subtitle_demo" translatable="false">"DEMO"</string>


<string name="action_settings">"Settings"</string>
Expand Down

0 comments on commit cca891a

Please sign in to comment.