From dbe72737fbaf943bd75d8ca2a75532c2f6f0d45c Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Tue, 30 Nov 2021 14:32:41 +0700 Subject: [PATCH 01/12] [#146] Add RFC template --- .github/ISSUE_TEMPLATE/rfc_template.md | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/rfc_template.md 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/ From 2854db80897ebba3ccdc278468c3b71655db2761 Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Tue, 14 Dec 2021 17:47:04 +0700 Subject: [PATCH 02/12] [#133] Add gradle build and execute UnitTest on generated project --- newproject.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/newproject.sh b/newproject.sh index 144fb6831..221677ccf 100755 --- a/newproject.sh +++ b/newproject.sh @@ -146,21 +146,75 @@ 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 ) + +if [ $template = "rx" ] +then + COMMON_RX_PACKAGE_DIR="common-rx/src/main/java" + COMMON_RX_PACKAGE_DIR=$( renameFolderStructure $COMMON_RX_PACKAGE_DIR ) +fi # 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 + +if [ $template = "rx" ] +then + 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 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 + +if [ $template = "rx" ] +then + 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" @@ -185,5 +239,14 @@ 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..." +cd $appname +./gradlew assembleDebug +echo "✅ Build success" + +echo "=> 🚓 Executing all unittest..." +./gradlew testStagingDebugUnitTest +echo "✅ All test passed" + # Done! -echo "=> 🚀 Done! App is ready to be tested 🙌" +echo "=> 🚀 Done! The project is ready for development 🙌" From fb6f75923caafb9df3a906591e1b72a9fc74ac29 Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Tue, 14 Dec 2021 17:59:28 +0700 Subject: [PATCH 03/12] [#133] Add workflow to execute the script --- .../workflows/verify_newproject_script.yml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/verify_newproject_script.yml diff --git a/.github/workflows/verify_newproject_script.yml b/.github/workflows/verify_newproject_script.yml new file mode 100644 index 000000000..346658ed3 --- /dev/null +++ b/.github/workflows/verify_newproject_script.yml @@ -0,0 +1,40 @@ +name: Verify newproject script + +on: + pull_request: + types: [ opened, edited, reopened, synchronize ] + branches: + - 'feature/**' + - 'chore/**' + - 'bug/**' + +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" From 2fbfb8edfde17d097eff49d55b56c09be93a58cd Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Tue, 14 Dec 2021 21:29:05 +0700 Subject: [PATCH 04/12] [#133] Fix script execute fail on Github actions --- .../workflows/verify_newproject_script.yml | 5 +--- newproject.sh | 24 ++++++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/verify_newproject_script.yml b/.github/workflows/verify_newproject_script.yml index 346658ed3..bf7bf1753 100644 --- a/.github/workflows/verify_newproject_script.yml +++ b/.github/workflows/verify_newproject_script.yml @@ -3,10 +3,7 @@ name: Verify newproject script on: pull_request: types: [ opened, edited, reopened, synchronize ] - branches: - - 'feature/**' - - 'chore/**' - - 'bug/**' + branches: [ develop ] jobs: verify_newproject_script: diff --git a/newproject.sh b/newproject.sh index 221677ccf..452ee6f00 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 @@ -223,14 +223,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"* ]] #MacOS +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"* ]] #MacOS +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..." From 0bd9ad918d9bb85f9b6c80b9501439618ea1497a Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Tue, 30 Nov 2021 13:54:50 +0700 Subject: [PATCH 05/12] [#148] Add android-common-ktx library on RxJava template --- RxJavaTemplate/app/build.gradle.kts | 1 + .../nimblehq/rxjava/extension/ActivityExt.kt | 10 ------ .../nimblehq/rxjava/extension/ContextExt.kt | 34 ------------------- .../rxjava/extension/ToastExtension.kt | 25 -------------- .../co/nimblehq/rxjava/extension/ViewExt.kt | 31 ----------------- .../nimblehq/rxjava/ui/base/BaseFragment.kt | 4 +-- .../nimblehq/rxjava/ui/base/BaseNavigator.kt | 5 +-- .../rxjava/ui/screens/home/HomeFragment.kt | 2 +- .../ui/screens/webview/WebViewFragment.kt | 2 +- RxJavaTemplate/build.gradle.kts | 2 +- .../buildSrc/src/main/java/Versions.kt | 1 + 11 files changed, 9 insertions(+), 108 deletions(-) delete mode 100644 RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ActivityExt.kt delete mode 100644 RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ContextExt.kt delete mode 100644 RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ToastExtension.kt delete mode 100644 RxJavaTemplate/app/src/main/java/co/nimblehq/rxjava/extension/ViewExt.kt 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..814932b5c 100644 --- a/RxJavaTemplate/buildSrc/src/main/java/Versions.kt +++ b/RxJavaTemplate/buildSrc/src/main/java/Versions.kt @@ -8,6 +8,7 @@ object Versions { const val ANDROID_COMPILE_SDK_VERSION = 28 // Dependencies (Alphabet sorted) + const val ANDROID_COMMON_KTX_VERSION = "0.1.0" const val ANDROID_CORE_VERSION = "1.2.0" const val ANDROID_CRYPTO_VERSION = "1.0.0" const val ANDROID_FRAGMENT_VERSION = "1.3.3" From 73e83ded62fbc003553244ae1c0af23fb0b29959 Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Tue, 30 Nov 2021 14:16:01 +0700 Subject: [PATCH 06/12] [#148] Add android-common-ktx library on Coroutine template --- CoroutineTemplate/app/build.gradle.kts | 2 ++ .../coroutine/extension/ActivityExt.kt | 10 ------ .../coroutine/extension/ContextExt.kt | 7 ----- .../nimblehq/coroutine/extension/ViewExt.kt | 31 ------------------- .../coroutine/ui/base/BaseFragment.kt | 2 +- .../coroutine/ui/base/BaseNavigator.kt | 2 +- .../coroutine/ui/screens/home/HomeFragment.kt | 2 +- CoroutineTemplate/build.gradle.kts | 2 +- .../buildSrc/src/main/java/Versions.kt | 1 + 9 files changed, 7 insertions(+), 52 deletions(-) delete mode 100644 CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ActivityExt.kt delete mode 100644 CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ContextExt.kt delete mode 100644 CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/extension/ViewExt.kt 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..6383cbf30 100644 --- a/CoroutineTemplate/buildSrc/src/main/java/Versions.kt +++ b/CoroutineTemplate/buildSrc/src/main/java/Versions.kt @@ -9,6 +9,7 @@ object Versions { const val ANDROID_VERSION_NAME = "3.3.0" // Dependencies (Alphabet sorted) + const val ANDROID_COMMON_KTX_VERSION = "0.1.0" 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" From 82c6995055880cd5e93886488f621772c003b674 Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Mon, 20 Dec 2021 16:17:47 +0700 Subject: [PATCH 07/12] [#133] Apply PR review changes --- newproject.sh | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/newproject.sh b/newproject.sh index 452ee6f00..b1be0baad 100755 --- a/newproject.sh +++ b/newproject.sh @@ -108,15 +108,14 @@ NAME_NO_SPACES=$(echo "$appname" | sed "s/ //g") # Copy main folder cp -R $OLD_NAME $NAME_NO_SPACES +# 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 rm -rf $NAME_NO_SPACES/.gradle # 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() { @@ -155,12 +154,6 @@ DATA_PACKAGE_DIR=$( renameFolderStructure $DATA_PACKAGE_DIR ) DOMAIN_PACKAGE_DIR="domain/src/main/java" DOMAIN_PACKAGE_DIR=$( renameFolderStructure $DOMAIN_PACKAGE_DIR ) -if [ $template = "rx" ] -then - COMMON_RX_PACKAGE_DIR="common-rx/src/main/java" - COMMON_RX_PACKAGE_DIR=$( renameFolderStructure $COMMON_RX_PACKAGE_DIR ) -fi - # Rename android test folder structure APP_ANDROIDTEST_DIR="app/src/androidTest/java" if [ -d APP_ANDROIDTEST_DIR ] @@ -180,15 +173,6 @@ then DOMAIN_ANDROIDTEST_DIR=$( renameFolderStructure $DOMAIN_ANDROIDTEST_DIR ) fi -if [ $template = "rx" ] -then - 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 -fi - # Rename test folder structure APP_TEST_DIR="app/src/test/java" if [ -d APP_TEST_DIR ] @@ -208,8 +192,21 @@ then 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 @@ -223,7 +220,7 @@ echo "✅ Completed" echo "=> 🔎 Replacing package and package name within files..." PACKAGE_NAME_ESCAPED="${packagename//./\.}" OLD_PACKAGE_NAME_ESCAPED="${OLD_PACKAGE//./\.}" -if [[ "$OSTYPE" == "darwin"* ]] #MacOS +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" {} + @@ -235,7 +232,7 @@ echo "✅ Completed" # Search and replace files <...> echo "=> 🔎 Replacing app name in strings.xml..." -if [[ "$OSTYPE" == "darwin"* ]] #MacOS +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" @@ -252,12 +249,11 @@ mv $OLD_APPLICATION_CLASS_PATH $APPLICATION_CLASS_PATH echo "✅ Completed" echo "=> 🛠️ Building generated project..." -cd $appname -./gradlew assembleDebug +./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES assembleDebug echo "✅ Build success" echo "=> 🚓 Executing all unittest..." -./gradlew testStagingDebugUnitTest +./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES testStagingDebugUnitTest echo "✅ All test passed" # Done! From 7c3deddfd97dae5f5e572f7f739021be50ade339 Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Mon, 20 Dec 2021 16:18:41 +0700 Subject: [PATCH 08/12] [#133] Apply PR review changes --- newproject.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/newproject.sh b/newproject.sh index b1be0baad..1527e684b 100755 --- a/newproject.sh +++ b/newproject.sh @@ -108,13 +108,13 @@ NAME_NO_SPACES=$(echo "$appname" | sed "s/ //g") # Copy main folder cp -R $OLD_NAME $NAME_NO_SPACES -# clean the old build +# Clean the old build ./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES clean -# get rid of idea settings +# 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 # Rename folder structure From 2319da854fb5342e57fa23a30127b6d91136923a Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Thu, 30 Dec 2021 12:26:21 +0700 Subject: [PATCH 09/12] [#148] Update android-common-ktx version to 0.1.1 --- CoroutineTemplate/buildSrc/src/main/java/Versions.kt | 2 +- RxJavaTemplate/buildSrc/src/main/java/Versions.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CoroutineTemplate/buildSrc/src/main/java/Versions.kt b/CoroutineTemplate/buildSrc/src/main/java/Versions.kt index 6383cbf30..f5fd26bab 100644 --- a/CoroutineTemplate/buildSrc/src/main/java/Versions.kt +++ b/CoroutineTemplate/buildSrc/src/main/java/Versions.kt @@ -9,7 +9,7 @@ object Versions { const val ANDROID_VERSION_NAME = "3.3.0" // Dependencies (Alphabet sorted) - const val ANDROID_COMMON_KTX_VERSION = "0.1.0" + 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/buildSrc/src/main/java/Versions.kt b/RxJavaTemplate/buildSrc/src/main/java/Versions.kt index 814932b5c..e62a3976a 100644 --- a/RxJavaTemplate/buildSrc/src/main/java/Versions.kt +++ b/RxJavaTemplate/buildSrc/src/main/java/Versions.kt @@ -8,7 +8,7 @@ object Versions { const val ANDROID_COMPILE_SDK_VERSION = 28 // Dependencies (Alphabet sorted) - const val ANDROID_COMMON_KTX_VERSION = "0.1.0" + 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" From 8e754752e1a68063efb722f818a0868845d78c8a Mon Sep 17 00:00:00 2001 From: Suphawadee Santaweesook Date: Thu, 6 Jan 2022 13:27:30 +0700 Subject: [PATCH 10/12] [Chore] Bump version to 3.4.0 --- CoroutineTemplate/buildSrc/src/main/java/Versions.kt | 2 +- RxJavaTemplate/buildSrc/src/main/java/Versions.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CoroutineTemplate/buildSrc/src/main/java/Versions.kt b/CoroutineTemplate/buildSrc/src/main/java/Versions.kt index 24500ab03..9ed9670eb 100644 --- a/CoroutineTemplate/buildSrc/src/main/java/Versions.kt +++ b/CoroutineTemplate/buildSrc/src/main/java/Versions.kt @@ -6,7 +6,7 @@ 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_CRYPTO_VERSION = "1.0.0" diff --git a/RxJavaTemplate/buildSrc/src/main/java/Versions.kt b/RxJavaTemplate/buildSrc/src/main/java/Versions.kt index e97e5ee81..dde9e61f3 100644 --- a/RxJavaTemplate/buildSrc/src/main/java/Versions.kt +++ b/RxJavaTemplate/buildSrc/src/main/java/Versions.kt @@ -2,7 +2,7 @@ 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 From 93c5feb772698515b22f3430da6d0708c0a6e07d Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Thu, 27 Jan 2022 10:25:12 +0700 Subject: [PATCH 11/12] [#133] Remove triggering edited action on PR --- .github/workflows/verify_newproject_script.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_newproject_script.yml b/.github/workflows/verify_newproject_script.yml index bf7bf1753..029a85114 100644 --- a/.github/workflows/verify_newproject_script.yml +++ b/.github/workflows/verify_newproject_script.yml @@ -2,7 +2,7 @@ name: Verify newproject script on: pull_request: - types: [ opened, edited, reopened, synchronize ] + types: [ opened, reopened, synchronize ] branches: [ develop ] jobs: From d1edb47ee5ea67a3e95fd67ebd52ca005406aeac Mon Sep 17 00:00:00 2001 From: hoangnguyen92dn Date: Thu, 27 Jan 2022 10:30:52 +0700 Subject: [PATCH 12/12] [#133] Fix typos --- newproject.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/newproject.sh b/newproject.sh index 1527e684b..3137b4b6f 100755 --- a/newproject.sh +++ b/newproject.sh @@ -252,9 +252,9 @@ echo "=> 🛠️ Building generated project..." ./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES assembleDebug echo "✅ Build success" -echo "=> 🚓 Executing all unittest..." +echo "=> 🚓 Executing all unit tests..." ./$NAME_NO_SPACES/gradlew -p ./$NAME_NO_SPACES testStagingDebugUnitTest -echo "✅ All test passed" +echo "✅ All unit tests passed" # Done! echo "=> 🚀 Done! The project is ready for development 🙌"