From e29f04b48f552c04b8ea8fd620751d865f149dcd Mon Sep 17 00:00:00 2001 From: Dmitri Chernysh Date: Sat, 17 Feb 2024 22:14:06 +0200 Subject: [PATCH] Added a new module 'core:util' to store global constants, time util, etc --- core/util/.gitignore | 1 + core/util/build.gradle.kts | 43 +++++++++++++++++++ core/util/consumer-rules.pro | 0 core/util/proguard-rules.pro | 21 +++++++++ core/util/src/main/AndroidManifest.xml | 2 + .../kotlin/com/mobiledevpro/util/Constant.kt | 22 ++++++++++ .../kotlin/com/mobiledevpro/util/TimeUtil.kt | 13 ++++++ settings.gradle.kts | 1 + 8 files changed, 103 insertions(+) create mode 100644 core/util/.gitignore create mode 100644 core/util/build.gradle.kts create mode 100644 core/util/consumer-rules.pro create mode 100644 core/util/proguard-rules.pro create mode 100644 core/util/src/main/AndroidManifest.xml create mode 100644 core/util/src/main/kotlin/com/mobiledevpro/util/Constant.kt create mode 100644 core/util/src/main/kotlin/com/mobiledevpro/util/TimeUtil.kt diff --git a/core/util/.gitignore b/core/util/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/core/util/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/util/build.gradle.kts b/core/util/build.gradle.kts new file mode 100644 index 0000000..248926a --- /dev/null +++ b/core/util/build.gradle.kts @@ -0,0 +1,43 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) +} + +android { + namespace = "com.mobiledevpro.util" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + testImplementation(libs.test.junit) + androidTestImplementation(libs.junit) + androidTestImplementation(libs.espresso.core) +} \ No newline at end of file diff --git a/core/util/consumer-rules.pro b/core/util/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/core/util/proguard-rules.pro b/core/util/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/core/util/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/core/util/src/main/AndroidManifest.xml b/core/util/src/main/AndroidManifest.xml new file mode 100644 index 0000000..568741e --- /dev/null +++ b/core/util/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/core/util/src/main/kotlin/com/mobiledevpro/util/Constant.kt b/core/util/src/main/kotlin/com/mobiledevpro/util/Constant.kt new file mode 100644 index 0000000..b5358e9 --- /dev/null +++ b/core/util/src/main/kotlin/com/mobiledevpro/util/Constant.kt @@ -0,0 +1,22 @@ +package com.mobiledevpro.util/* + * Copyright 2023 | Dmitri Chernysh | https://mobile-dev.pro + * + * + * 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. + * + */ + + +object Constant { + const val LOG_TAG_DEBUG = "app.debug" +} \ No newline at end of file diff --git a/core/util/src/main/kotlin/com/mobiledevpro/util/TimeUtil.kt b/core/util/src/main/kotlin/com/mobiledevpro/util/TimeUtil.kt new file mode 100644 index 0000000..f45085e --- /dev/null +++ b/core/util/src/main/kotlin/com/mobiledevpro/util/TimeUtil.kt @@ -0,0 +1,13 @@ +package com.mobiledevpro.util + +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +object TimeUtil { + + fun currentTimeStamp(): String = DateTimeFormatter.ofPattern(TIMESTAMP_PATTERN).let { format -> + LocalDateTime.now().format(format) + } +} + +private const val TIMESTAMP_PATTERN = "yyyyMMdd_HHmmssSSS" \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 8e0c075..a00fe69 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -31,3 +31,4 @@ include(":feature:user_profile") include(":feature:people_profile") include(":feature:people") include(":core:di") +include(":core:util")