From 817d6a1230cf9b4a4907f7829f2e5817df8a7887 Mon Sep 17 00:00:00 2001 From: Arman Kolahan Date: Sat, 8 May 2021 15:26:51 +0200 Subject: [PATCH] pro version --- app/build.gradle | 13 ++++ .../java/com/armanco/integral/MainActivity.kt | 9 ++- .../armanco/integral/extensions/extensions.kt | 11 ++++ .../navigation/image/ImageFragment.kt | 3 +- fastlane/Fastfile | 59 +++++++++++++++++-- fastlane/README.md | 10 ++++ fastlane/report.xml | 10 ++-- 7 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/com/armanco/integral/extensions/extensions.kt diff --git a/app/build.gradle b/app/build.gradle index 9395ec6..06bc842 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,19 @@ android { buildFeatures { viewBinding true } + + flavorDimensions 'default' + productFlavors { + free { + dimension 'default' + applicationId "com.armanco.integral" + } + pro { + dimension 'default' + applicationId "com.armanco.integral_pro" + } + } + } dependencies { diff --git a/app/src/main/java/com/armanco/integral/MainActivity.kt b/app/src/main/java/com/armanco/integral/MainActivity.kt index cf99c44..36d2b1f 100644 --- a/app/src/main/java/com/armanco/integral/MainActivity.kt +++ b/app/src/main/java/com/armanco/integral/MainActivity.kt @@ -1,11 +1,13 @@ package com.armanco.integral import android.os.Bundle +import android.view.View import androidx.appcompat.app.AppCompatActivity import androidx.navigation.findNavController import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupWithNavController +import com.armanco.integral.extensions.isPro import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.MobileAds import dagger.hilt.android.AndroidEntryPoint @@ -16,7 +18,8 @@ class MainActivity: AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - initAdMob() + if(!isPro) initAdMob() + else removeAdMob() initToolbar() } @@ -26,6 +29,10 @@ class MainActivity: AppCompatActivity() { adView?.loadAd(adRequest) } + private fun removeAdMob() { + adView?.visibility = View.GONE + } + private fun initToolbar() { val navHostFragment = supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as? NavHostFragment navHostFragment?.navController?.let { navController -> diff --git a/app/src/main/java/com/armanco/integral/extensions/extensions.kt b/app/src/main/java/com/armanco/integral/extensions/extensions.kt new file mode 100644 index 0000000..615f736 --- /dev/null +++ b/app/src/main/java/com/armanco/integral/extensions/extensions.kt @@ -0,0 +1,11 @@ +package com.armanco.integral.extensions + +import com.armanco.integral.BuildConfig + +val isPro: Boolean + get() { + return when (BuildConfig.FLAVOR) { + "pro" -> true + else -> false + } +} \ No newline at end of file diff --git a/app/src/main/java/com/armanco/integral/navigation/image/ImageFragment.kt b/app/src/main/java/com/armanco/integral/navigation/image/ImageFragment.kt index f9e70e4..dbb9359 100644 --- a/app/src/main/java/com/armanco/integral/navigation/image/ImageFragment.kt +++ b/app/src/main/java/com/armanco/integral/navigation/image/ImageFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import androidx.fragment.app.Fragment import com.armanco.integral.R +import com.armanco.integral.extensions.isPro import com.google.android.gms.ads.AdListener import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.InterstitialAd @@ -17,7 +18,7 @@ class ImageFragment: Fragment(R.layout.fragment_image) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - showInterstitialAd() + if(!isPro) showInterstitialAd() arguments?.getInt(IMAGE_KEY)?.let { photoView?.setImageResource(it) } } diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 969245c..ac4ecfc 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -28,7 +28,7 @@ platform :android do ) gradle(task: "test") gradle( - task: 'assembleRelease', + task: 'assembleFreeRelease', properties: { "android.injected.signing.store.file" => ENV['KEYSTORE_PATH'], "android.injected.signing.store.password" => ENV['STORE_PASSWORD'], @@ -37,8 +37,9 @@ platform :android do } ) upload_to_play_store( + package_name: 'com.armanco.integral', track: 'production', - apk: ENV['APK_PATH'], + apk: ENV['APK_PATH_FREE'], json_key: ENV['JSON_PATH'], skip_upload_aab: true ) @@ -51,7 +52,7 @@ platform :android do ) gradle(task: "test") gradle( - task: 'assembleRelease', + task: 'assembleFreeRelease', properties: { "android.injected.signing.store.file" => ENV['KEYSTORE_PATH'], "android.injected.signing.store.password" => ENV['STORE_PASSWORD'], @@ -60,8 +61,58 @@ platform :android do } ) upload_to_play_store( + package_name: 'com.armanco.integral', track: 'internal', - apk: ENV['APK_PATH'], + apk: ENV['APK_PATH_FREE'], + json_key: ENV['JSON_PATH'], + skip_upload_aab: true + ) + end + + + desc "Deploy a new version to the Google Play (PRO)" + lane :deploy_pro do + validate_play_store_json_key( + json_key: ENV['JSON_PATH'] + ) + gradle(task: "test") + gradle( + task: 'assembleProRelease', + properties: { + "android.injected.signing.store.file" => ENV['KEYSTORE_PATH'], + "android.injected.signing.store.password" => ENV['STORE_PASSWORD'], + "android.injected.signing.key.alias" => ENV['KEY_ALIAS'], + "android.injected.signing.key.password" => ENV['KEY_PASSWORD'], + } + ) + upload_to_play_store( + package_name: 'com.armanco.integral_pro', + track: 'production', + apk: ENV['APK_PATH_PRO'], + json_key: ENV['JSON_PATH'], + skip_upload_aab: true + ) + end + + desc "Submit a new Internal Test" + lane :internal_pro do + validate_play_store_json_key( + json_key: ENV['JSON_PATH'] + ) + gradle(task: "test") + gradle( + task: 'assembleProRelease', + properties: { + "android.injected.signing.store.file" => ENV['KEYSTORE_PATH'], + "android.injected.signing.store.password" => ENV['STORE_PASSWORD'], + "android.injected.signing.key.alias" => ENV['KEY_ALIAS'], + "android.injected.signing.key.password" => ENV['KEY_PASSWORD'], + } + ) + upload_to_play_store( + package_name: 'com.armanco.integral_pro', + track: 'internal', + apk: ENV['APK_PATH_PRO'], json_key: ENV['JSON_PATH'], skip_upload_aab: true ) diff --git a/fastlane/README.md b/fastlane/README.md index fc1d7b7..df341e6 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -31,6 +31,16 @@ Deploy a new version to the Google Play fastlane android internal ``` Submit a new Internal Test +### android deploy_pro +``` +fastlane android deploy_pro +``` +Deploy a new version to the Google Play (PRO) +### android internal_pro +``` +fastlane android internal_pro +``` +Submit a new Internal Test ### android screenshots ``` fastlane android screenshots diff --git a/fastlane/report.xml b/fastlane/report.xml index 3596ab3..9b478a3 100644 --- a/fastlane/report.xml +++ b/fastlane/report.xml @@ -5,27 +5,27 @@ - + - + - + - + - +