diff --git a/.github/ISSUE_TEMPLATE/rfc_template.md b/.github/ISSUE_TEMPLATE/rfc_template.md new file mode 100644 index 000000000..907fbb86b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/rfc_template.md @@ -0,0 +1,28 @@ +--- +name: "Request For Comments (RFC)" +about: "You have an idea on how to improve our processes. Propose your idea so that the team can provide feedback." +title: "RFC: " +labels: "type : rfc" +--- + +## Issue + +Describe the issue the team is currently facing. Provide as much content as possible. + +## Solution + +Describe the solution you are prescribing for the issue + +## Who Benefits? + +Describe who will be the beneficiaries e.g. everyone, specific chapters, clients... + +## What's Next? + +Provide an actionable list of things that must happen in order to implement the solution: + +- [ ] +- [ ] +- [ ] + +Using a poll is encouraged to gather feedback on the RFA 👉 Use this tool: https://gh-polls.com/ diff --git a/.github/workflows/verify_newproject_script.yml b/.github/workflows/verify_newproject_script.yml new file mode 100644 index 000000000..029a85114 --- /dev/null +++ b/.github/workflows/verify_newproject_script.yml @@ -0,0 +1,37 @@ +name: Verify newproject script + +on: + pull_request: + types: [ opened, reopened, synchronize ] + branches: [ develop ] + +jobs: + verify_newproject_script: + name: Verify newproject script + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Checkout source code + uses: actions/checkout@v2.3.2 + + - name: Cache Gradle + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches/modules-* + ~/.gradle/caches/jars-* + ~/.gradle/caches/build-cache-* + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Verify generating new project from RxTemplate + run: ./newproject.sh -t rx -p co.myproject.example -n "MyProjectExampleRx" + + - name: Verify generating new project from CoroutineTemplate + run: ./newproject.sh -t crt -p co.myproject.example -n "MyProjectExampleCoroutine" diff --git a/CoroutineTemplate/app/build.gradle.kts b/CoroutineTemplate/app/build.gradle.kts index 3bd4db617..eabe1fefa 100644 --- a/CoroutineTemplate/app/build.gradle.kts +++ b/CoroutineTemplate/app/build.gradle.kts @@ -123,6 +123,8 @@ dependencies { implementation("com.jakewharton.timber:timber:${Versions.TIMBER_LOG_VERSION}") + implementation("com.github.nimblehq:android-common-ktx:${Versions.ANDROID_COMMON_KTX_VERSION}") + implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN_VERSION}") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.KOTLINX_COROUTINES_VERSION}") diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ActivityExt.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ActivityExt.kt deleted file mode 100644 index 71aeaf34b..000000000 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ActivityExt.kt +++ /dev/null @@ -1,10 +0,0 @@ -package co.nimblehq.coroutine.extension - -import android.app.Activity -import android.content.Context -import android.view.inputmethod.InputMethodManager - -fun Activity.hideSoftKeyboard() { - val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager - inputMethodManager?.hideSoftInputFromWindow(currentFocus?.windowToken, 0) -} diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ContextExt.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ContextExt.kt deleted file mode 100644 index 3dc652e87..000000000 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ContextExt.kt +++ /dev/null @@ -1,7 +0,0 @@ -package co.nimblehq.coroutine.extension - -import android.content.Context -import androidx.annotation.IdRes - -fun Context.getResourceName(@IdRes resId: Int?): String? = - resId?.let(resources::getResourceName) diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ViewExt.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ViewExt.kt deleted file mode 100644 index 0ee0440db..000000000 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ViewExt.kt +++ /dev/null @@ -1,31 +0,0 @@ -package co.nimblehq.coroutine.extension - -import android.view.View - -fun View.visible() { - this.visibility = View.VISIBLE -} - -fun View.invisible() { - this.visibility = View.INVISIBLE -} - -fun View.gone() { - this.visibility = View.GONE -} - -fun View.visibleOrGone(visible: Boolean, delay: Long) { - if (delay <= 0L) { - visibleOrGone(visible) - } else { - postDelayed({ visibleOrGone(visible) }, delay) - } -} - -fun View.visibleOrGone(visible: Boolean) { - if (visible) visible() else gone() -} - -fun View.visibleOrInvisible(visible: Boolean) { - if (visible) visible() else invisible() -} diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseFragment.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseFragment.kt index e40db451a..d28bc846d 100644 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseFragment.kt +++ b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseFragment.kt @@ -10,7 +10,7 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle import androidx.viewbinding.ViewBinding -import co.nimblehq.coroutine.extension.hideSoftKeyboard +import co.nimblehq.common.extensions.hideSoftKeyboard import co.nimblehq.coroutine.ui.common.Toaster import co.nimblehq.coroutine.ui.userReadableMessage import kotlinx.coroutines.flow.Flow diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseNavigator.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseNavigator.kt index 3a6c52f47..588d8c567 100644 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseNavigator.kt +++ b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/base/BaseNavigator.kt @@ -6,7 +6,7 @@ import androidx.annotation.IdRes import androidx.fragment.app.Fragment import androidx.navigation.NavController import androidx.navigation.fragment.findNavController -import co.nimblehq.coroutine.extension.getResourceName +import co.nimblehq.common.extensions.getResourceName import timber.log.Timber interface BaseNavigator { diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/screens/home/HomeFragment.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/screens/home/HomeFragment.kt index 11ca47e17..5d78f933c 100644 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/screens/home/HomeFragment.kt +++ b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/ui/screens/home/HomeFragment.kt @@ -2,10 +2,10 @@ package co.nimblehq.coroutine.ui.screens.home import android.view.LayoutInflater import android.view.ViewGroup +import co.nimblehq.common.extensions.visibleOrGone import co.nimblehq.coroutine.databinding.FragmentHomeBinding import co.nimblehq.coroutine.databinding.ViewLoadingBinding import co.nimblehq.coroutine.extension.provideViewModels -import co.nimblehq.coroutine.extension.visibleOrGone import co.nimblehq.coroutine.lib.IsLoading import co.nimblehq.coroutine.model.UserUiModel import co.nimblehq.coroutine.ui.base.BaseFragment diff --git a/CoroutineTemplate/build.gradle.kts b/CoroutineTemplate/build.gradle.kts index d90d60718..45250dd0d 100644 --- a/CoroutineTemplate/build.gradle.kts +++ b/CoroutineTemplate/build.gradle.kts @@ -20,7 +20,7 @@ plugins { allprojects { repositories { google() - maven { url = uri("https://jitpack.io") } + maven(url = "https://jitpack.io") mavenCentral() } } diff --git a/CoroutineTemplate/buildSrc/src/main/java/Versions.kt b/CoroutineTemplate/buildSrc/src/main/java/Versions.kt index 24500ab03..3b326c69a 100644 --- a/CoroutineTemplate/buildSrc/src/main/java/Versions.kt +++ b/CoroutineTemplate/buildSrc/src/main/java/Versions.kt @@ -6,9 +6,10 @@ object Versions { const val ANDROID_TARGET_SDK_VERSION = 30 const val ANDROID_VERSION_CODE = 1 - const val ANDROID_VERSION_NAME = "3.3.0" + const val ANDROID_VERSION_NAME = "3.4.0" // Dependencies (Alphabet sorted) + const val ANDROID_COMMON_KTX_VERSION = "0.1.1" const val ANDROID_CRYPTO_VERSION = "1.0.0" const val ANDROIDX_ACTIVITY_KTX_VERSION = "1.2.1" const val ANDROIDX_CORE_KTX_VERSION = "1.3.0" diff --git a/RxJavaTemplate/app/build.gradle.kts b/RxJavaTemplate/app/build.gradle.kts index 9c6b3c005..091ff4a8d 100644 --- a/RxJavaTemplate/app/build.gradle.kts +++ b/RxJavaTemplate/app/build.gradle.kts @@ -160,6 +160,7 @@ dependencies { implementation("com.jakewharton.timber:timber:${Versions.TIMBER_LOG_VERSION}") implementation("com.github.bumptech.glide:glide:${Versions.GLIDE_VERSION}") implementation("com.github.tbruyelle:rxpermissions:${Versions.RXPERMISSION_VERSION}") + implementation("com.github.nimblehq:android-common-ktx:${Versions.ANDROID_COMMON_KTX_VERSION}") debugImplementation("androidx.fragment:fragment-testing:${Versions.ANDROID_FRAGMENT_VERSION}") debugImplementation("com.github.chuckerteam.chucker:library:${Versions.CHUCKER_INTERCEPTOR_VERSION}") diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ActivityExt.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ActivityExt.kt deleted file mode 100644 index e3f25ca57..000000000 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ActivityExt.kt +++ /dev/null @@ -1,10 +0,0 @@ -package co.nimblehq.rxjava.extension - -import android.app.Activity -import android.content.Context -import android.view.inputmethod.InputMethodManager - -fun Activity.hideSoftKeyboard() { - val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager - inputMethodManager?.hideSoftInputFromWindow(currentFocus?.windowToken, 0) -} diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ContextExt.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ContextExt.kt deleted file mode 100644 index 17221ebc6..000000000 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ContextExt.kt +++ /dev/null @@ -1,34 +0,0 @@ -package co.nimblehq.rxjava.extension - -import android.content.Context -import android.content.Context.INPUT_METHOD_SERVICE -import android.content.Intent -import android.content.pm.PackageManager -import android.view.View -import android.view.inputmethod.InputMethodManager -import android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT -import androidx.annotation.IdRes -import androidx.core.net.toUri - -fun Context.showSoftKeyboard(view: View) { - view.requestFocus() - val inputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as? InputMethodManager - inputMethodManager?.showSoftInput(view, SHOW_IMPLICIT) -} - -fun Context.getResourceName(@IdRes resId: Int?): String? = - resId?.let { resources.getResourceName(resId) } - -fun Context.openPlayStore(packageName: String) { - val intent = Intent(Intent.ACTION_VIEW, "market://details?id=$packageName".toUri()) - if (intent.resolveActivity(packageManager) == null) { - intent.data = "https://play.google.com/store/apps/details?id=$packageName".toUri() - } - startActivity(intent) -} - -fun Context.checkAppInstalled(packageName: String): Boolean { - return packageManager - .getInstalledApplications(PackageManager.GET_META_DATA) - .find { it.packageName == packageName } != null -} diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ToastExtension.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ToastExtension.kt deleted file mode 100644 index 9d54353dd..000000000 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ToastExtension.kt +++ /dev/null @@ -1,25 +0,0 @@ -package co.nimblehq.rxjava.extension - -import android.app.Activity -import android.widget.Toast -import androidx.fragment.app.Fragment - -/** - * Provide extension functions to Activity/Fragment to capable of showing Toast in a shorter call - */ - -fun Activity.toastShort(message: CharSequence, duration: Int = Toast.LENGTH_SHORT) { - Toast.makeText(this, message, duration).show() -} - -fun Fragment.toastShort(message: CharSequence, duration: Int = Toast.LENGTH_SHORT) { - Toast.makeText(context, message, duration).show() -} - -fun Activity.toastLong(message: CharSequence, duration: Int = Toast.LENGTH_LONG) { - Toast.makeText(this, message, duration).show() -} - -fun Fragment.toastLong(message: CharSequence, duration: Int = Toast.LENGTH_LONG) { - Toast.makeText(context, message, duration).show() -} diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ViewExt.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ViewExt.kt deleted file mode 100644 index b87226edd..000000000 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ViewExt.kt +++ /dev/null @@ -1,31 +0,0 @@ -package co.nimblehq.rxjava.extension - -import android.view.View - -fun View.visible() { - this.visibility = View.VISIBLE -} - -fun View.invisible() { - this.visibility = View.INVISIBLE -} - -fun View.gone() { - this.visibility = View.GONE -} - -fun View.visibleOrGone(visible: Boolean, delay: Long) { - if (delay <= 0L) { - visibleOrGone(visible) - } else { - postDelayed({ visibleOrGone(visible) }, delay) - } -} - -fun View.visibleOrGone(visible: Boolean) { - if (visible) visible() else gone() -} - -fun View.visibleOrInvisible(visible: Boolean) { - if (visible) visible() else invisible() -} diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseFragment.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseFragment.kt index d46fd5e84..fbc6c9ae9 100644 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseFragment.kt +++ b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseFragment.kt @@ -5,12 +5,10 @@ import android.os.Bundle import android.view.* import android.view.View.* import androidx.annotation.CallSuper -import androidx.annotation.VisibleForTesting import androidx.fragment.app.Fragment import androidx.viewbinding.ViewBinding +import co.nimblehq.common.extensions.hideSoftKeyboard import co.nimblehq.rxjava.domain.schedulers.BaseSchedulerProvider -import co.nimblehq.rxjava.domain.schedulers.SchedulerProvider -import co.nimblehq.rxjava.extension.hideSoftKeyboard import co.nimblehq.rxjava.extension.subscribeOnClick import co.nimblehq.rxjava.ui.common.Toaster import co.nimblehq.rxjava.ui.userReadableMessage diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseNavigator.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseNavigator.kt index 605ae3651..75348fcd6 100644 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseNavigator.kt +++ b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/base/BaseNavigator.kt @@ -6,7 +6,7 @@ import androidx.annotation.IdRes import androidx.fragment.app.Fragment import androidx.navigation.NavController import androidx.navigation.fragment.findNavController -import co.nimblehq.rxjava.extension.getResourceName +import co.nimblehq.common.extensions.getResourceName import timber.log.Timber interface BaseNavigator { @@ -49,7 +49,8 @@ abstract class BaseNavigatorImpl( protected fun unsupportedNavigation() { val navController = findNavController() val currentGraph = fragment.requireActivity().getResourceName(navController?.graph?.id) - val currentDestination = fragment.requireActivity().getResourceName(navController?.currentDestination?.id) + val currentDestination = + fragment.requireActivity().getResourceName(navController?.currentDestination?.id) handleError(NavigationError.UnsupportedNavigationError(currentGraph, currentDestination)) } diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/home/HomeFragment.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/home/HomeFragment.kt index e8a2fe655..8c1cf7e4c 100644 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/home/HomeFragment.kt +++ b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/home/HomeFragment.kt @@ -6,12 +6,12 @@ import androidx.fragment.app.viewModels import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import co.nimblehq.common.extensions.visibleOrGone import co.nimblehq.rxjava.databinding.FragmentHomeBinding import co.nimblehq.rxjava.databinding.ViewLoadingBinding import co.nimblehq.rxjava.domain.data.Data import co.nimblehq.rxjava.extension.subscribeOnClick import co.nimblehq.rxjava.extension.subscribeOnItemClick -import co.nimblehq.rxjava.extension.visibleOrGone import co.nimblehq.rxjava.lib.IsLoading import co.nimblehq.rxjava.ui.base.BaseFragment import co.nimblehq.rxjava.ui.helpers.handleVisualOverlaps diff --git a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/webview/WebViewFragment.kt b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/webview/WebViewFragment.kt index e8c24e7dd..dffb8929a 100644 --- a/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/webview/WebViewFragment.kt +++ b/RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/ui/screens/webview/WebViewFragment.kt @@ -5,10 +5,10 @@ import android.view.ViewGroup import android.webkit.WebViewClient import androidx.fragment.app.viewModels import androidx.navigation.fragment.navArgs +import co.nimblehq.common.extensions.visibleOrGone import co.nimblehq.rxjava.databinding.FragmentWebviewBinding import co.nimblehq.rxjava.databinding.ViewLoadingBinding import co.nimblehq.rxjava.extension.initialSetup -import co.nimblehq.rxjava.extension.visibleOrGone import co.nimblehq.rxjava.lib.IsLoading import co.nimblehq.rxjava.ui.base.BaseFragment import co.nimblehq.rxjava.ui.helpers.handleVisualOverlaps diff --git a/RxJavaTemplate/build.gradle.kts b/RxJavaTemplate/build.gradle.kts index c88aedcee..ee8fd3b7d 100644 --- a/RxJavaTemplate/build.gradle.kts +++ b/RxJavaTemplate/build.gradle.kts @@ -22,7 +22,7 @@ allprojects { repositories { google() jcenter() - maven { url = uri("https://jitpack.io") } + maven(url = "https://jitpack.io") mavenCentral() } } diff --git a/RxJavaTemplate/buildSrc/src/main/java/Versions.kt b/RxJavaTemplate/buildSrc/src/main/java/Versions.kt index e97e5ee81..aa926814d 100644 --- a/RxJavaTemplate/buildSrc/src/main/java/Versions.kt +++ b/RxJavaTemplate/buildSrc/src/main/java/Versions.kt @@ -2,12 +2,13 @@ object Versions { const val BUILD_GRADLE_VERSION = "4.2.2" const val ANDROID_VERSION_CODE = 9 - const val ANDROID_VERSION_NAME = "3.3.0" + const val ANDROID_VERSION_NAME = "3.4.0" const val ANDROID_MIN_SDK_VERSION = 23 const val ANDROID_TARGET_SDK_VERSION = 28 const val ANDROID_COMPILE_SDK_VERSION = 28 // Dependencies (Alphabet sorted) + const val ANDROID_COMMON_KTX_VERSION = "0.1.1" const val ANDROID_CORE_VERSION = "1.2.0" const val ANDROID_CRYPTO_VERSION = "1.0.0" const val ANDROID_FRAGMENT_VERSION = "1.3.3" diff --git a/newproject.sh b/newproject.sh index 144fb6831..3137b4b6f 100755 --- a/newproject.sh +++ b/newproject.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e # Script inspired by https://gist.github.com/szeidner/613fe4652fc86f083cefa21879d5522b @@ -96,7 +96,7 @@ fi # Enforce package name regex='^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$' -if ! [[ $packagename =~ $regex ]]; then +if ! [[ "$packagename" =~ $regex ]]; then die "Invalid Package Name: $packagename (needs to follow standard pattern {com.example.package})" fi @@ -108,15 +108,14 @@ NAME_NO_SPACES=$(echo "$appname" | sed "s/ //g") # Copy main folder cp -R $OLD_NAME $NAME_NO_SPACES -# get rid of idea settings +# Clean the old build +./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES clean +# Get rid of idea settings rm -rf $NAME_NO_SPACES/.idea -# get rid of gradle cache +# Get rid of gradle cache rm -rf $NAME_NO_SPACES/.gradle -# get rid of the git history +# Get rid of the git history rm -rf $NAME_NO_SPACES/.git -# get rid of the build -rm -rf $NAME_NO_SPACES/build -rm -rf $NAME_NO_SPACES/app/build # Rename folder structure renameFolderStructure() { @@ -146,21 +145,73 @@ renameFolderStructure() { echo "=> 🔎 Replacing files structure..." # Rename project folder structure -PACKAGE_DIR="app/src/main/java" -PACKAGE_DIR=$( renameFolderStructure $PACKAGE_DIR ) +APP_PACKAGE_DIR="app/src/main/java" +APP_PACKAGE_DIR=$( renameFolderStructure $APP_PACKAGE_DIR ) + +DATA_PACKAGE_DIR="data/src/main/java" +DATA_PACKAGE_DIR=$( renameFolderStructure $DATA_PACKAGE_DIR ) + +DOMAIN_PACKAGE_DIR="domain/src/main/java" +DOMAIN_PACKAGE_DIR=$( renameFolderStructure $DOMAIN_PACKAGE_DIR ) # Rename android test folder structure -ANDROIDTEST_DIR="app/src/androidTest/java" -if [ -d ANDROIDTEST_DIR ] +APP_ANDROIDTEST_DIR="app/src/androidTest/java" +if [ -d APP_ANDROIDTEST_DIR ] +then + APP_ANDROIDTEST_DIR=$( renameFolderStructure $APP_ANDROIDTEST_DIR ) +fi + +DATA_ANDROIDTEST_DIR="data/src/androidTest/java" +if [ -d DATA_ANDROIDTEST_DIR ] +then + DATA_ANDROIDTEST_DIR=$( renameFolderStructure $DATA_ANDROIDTEST_DIR ) +fi + +DOMAIN_ANDROIDTEST_DIR="domain/src/androidTest/java" +if [ -d DOMAIN_ANDROIDTEST_DIR ] then - ANDROIDTEST_DIR=$( renameFolderStructure $ANDROIDTEST_DIR ) + DOMAIN_ANDROIDTEST_DIR=$( renameFolderStructure $DOMAIN_ANDROIDTEST_DIR ) fi # Rename test folder structure -TEST_DIR="app/src/test/java" -if [ -d TEST_DIR ] +APP_TEST_DIR="app/src/test/java" +if [ -d APP_TEST_DIR ] +then + APP_TEST_DIR=$( renameFolderStructure $APP_TEST_DIR ) +fi + +DATA_TEST_DIR="data/src/test/java" +if [ -d DATA_TEST_DIR ] +then + DATA_TEST_DIR=$( renameFolderStructure $DATA_TEST_DIR ) +fi + +DOMAIN_TEST_DIR="domain/src/test/java" +if [ -d DOMAIN_TEST_DIR ] then - TEST_DIR=$( renameFolderStructure TEST_DIR ) + DOMAIN_TEST_DIR=$( renameFolderStructure $DOMAIN_TEST_DIR ) +fi + +# Rename common-rx module on RxTemplate +if [ $template = "rx" ] +then + # Rename package folder + COMMON_RX_PACKAGE_DIR="common-rx/src/main/java" + COMMON_RX_PACKAGE_DIR=$( renameFolderStructure $COMMON_RX_PACKAGE_DIR ) + + # Rename androidTest folder + COMMON_RX_ANDROIDTEST_DIR="common-rx/src/androidTest/java" + if [ -d COMMON_RX_ANDROIDTEST_DIR ] + then + COMMON_RX_ANDROIDTEST_DIR=$( renameFolderStructure $COMMON_RX_ANDROIDTEST_DIR ) + fi + + # Rename test folder + COMMON_RX_TEST_DIR="common-rx/src/test/java" + if [ -d COMMON_RX_TEST_DIR ] + then + COMMON_RX_TEST_DIR=$( renameFolderStructure $COMMON_RX_TEST_DIR ) + fi fi echo "✅ Completed" @@ -169,14 +220,26 @@ echo "✅ Completed" echo "=> 🔎 Replacing package and package name within files..." PACKAGE_NAME_ESCAPED="${packagename//./\.}" OLD_PACKAGE_NAME_ESCAPED="${OLD_PACKAGE//./\.}" -LC_ALL=C find $WORKING_DIR/$NAME_NO_SPACES -type f -exec sed -i "" "s/$OLD_PACKAGE_NAME_ESCAPED/$PACKAGE_NAME_ESCAPED/g" {} + -LC_ALL=C find $WORKING_DIR/$NAME_NO_SPACES -type f -exec sed -i "" "s/$OLD_NAME/$NAME_NO_SPACES/g" {} + +if [[ "$OSTYPE" == "darwin"* ]] # Mac OSX +then + LC_ALL=C find $WORKING_DIR/$NAME_NO_SPACES -type f -exec sed -i "" -e "s/$OLD_PACKAGE_NAME_ESCAPED/$PACKAGE_NAME_ESCAPED/g" {} + + LC_ALL=C find $WORKING_DIR/$NAME_NO_SPACES -type f -exec sed -i "" -e "s/$OLD_NAME/$NAME_NO_SPACES/g" {} + +else + LC_ALL=C find $WORKING_DIR/$NAME_NO_SPACES -type f -exec sed -i -e "s/$OLD_PACKAGE_NAME_ESCAPED/$PACKAGE_NAME_ESCAPED/g" {} + + LC_ALL=C find $WORKING_DIR/$NAME_NO_SPACES -type f -exec sed -i -e "s/$OLD_NAME/$NAME_NO_SPACES/g" {} + +fi echo "✅ Completed" # Search and replace files <...> echo "=> 🔎 Replacing app name in strings.xml..." -sed -i "" "s/$OLD_APPNAME/$appname/" "$WORKING_DIR/$NAME_NO_SPACES/app/src/main/res/values/strings.xml" -sed -i "" "s/$OLD_APPNAME/$appname/" "$WORKING_DIR/$NAME_NO_SPACES/app/src/staging/res/values/strings.xml" +if [[ "$OSTYPE" == "darwin"* ]] # Mac OSX +then + sed -i "" -e "s/$OLD_APPNAME/$appname/" "$WORKING_DIR/$NAME_NO_SPACES/app/src/main/res/values/strings.xml" + sed -i "" -e "s/$OLD_APPNAME/$appname/" "$WORKING_DIR/$NAME_NO_SPACES/app/src/staging/res/values/strings.xml" +else + sed -i -e "s/$OLD_APPNAME/$appname/" "$WORKING_DIR/$NAME_NO_SPACES/app/src/main/res/values/strings.xml" + sed -i -e "s/$OLD_APPNAME/$appname/" "$WORKING_DIR/$NAME_NO_SPACES/app/src/staging/res/values/strings.xml" +fi echo "✅ Completed" echo "=> 🔎 Replacing Application class..." @@ -185,5 +248,13 @@ APPLICATION_CLASS_PATH="${OLD_APPLICATION_CLASS_PATH/$OLD_NAME/$NAME_NO_SPACES}" mv $OLD_APPLICATION_CLASS_PATH $APPLICATION_CLASS_PATH echo "✅ Completed" +echo "=> 🛠️ Building generated project..." +./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES assembleDebug +echo "✅ Build success" + +echo "=> 🚓 Executing all unit tests..." +./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES testStagingDebugUnitTest +echo "✅ All unit tests passed" + # Done! -echo "=> 🚀 Done! App is ready to be tested 🙌" +echo "=> 🚀 Done! The project is ready for development 🙌"