Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ internal val Red20 = Color(0xFF690005)
internal val Red30 = Color(0xFF93000A)
internal val Red40 = Color(0xFFBA1A1A)
internal val Red90 = Color(0xFFFFDAD6)
internal val Teal10 = Color(0xFF014D40)
internal val Teal20 = Color(0xFF0C6B58)
internal val Teal30 = Color(0xFF147D64)
internal val Teal40 = Color(0xFF199473)
internal val Teal80 = Color(0xFF8EEDC7)
internal val Teal90 = Color(0xFFC6F7E2)

internal val Yellow10 = Color(0xFF8D2B0B)
internal val Yellow20 = Color(0xFFB44D12)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ import androidx.compose.ui.graphics.Color
data class CustomColorScheme(
val success: Color = Color.Unspecified,
val onSuccess: Color = Color.Unspecified,
val successContainer: Color = Color.Unspecified,
val onSuccessContainer: Color = Color.Unspecified,
)

val LightCustomColorScheme = CustomColorScheme(
success = Teal40,
onSuccess = Color.White,
successContainer = Teal90,
onSuccessContainer = Teal10,
)

val DarkCustomColorScheme = CustomColorScheme(
success = Teal80,
onSuccess = Teal20,
successContainer = Teal30,
onSuccessContainer = Teal90,
)

val LocalCustomColorScheme = staticCompositionLocalOf { CustomColorScheme() }
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ fun NatTheme(
tonalElevation = 2.dp,
)

val tintTheme = TintTheme()

val customColorsPalette =
if (darkTheme) {
DarkCustomColorScheme
Expand All @@ -90,7 +88,6 @@ fun NatTheme(
CompositionLocalProvider(
LocalCustomColorScheme provides customColorsPalette,
LocalBackgroundTheme provides backgroundTheme,
LocalTintTheme provides tintTheme,
) {
MaterialTheme(
colorScheme = colorScheme,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.nativeapptemplate.nativeapptemplatefree.utils

import android.text.format.DateUtils
import java.time.ZoneId
import java.time.ZonedDateTime

Expand Down Expand Up @@ -39,15 +38,4 @@ object DateUtility {
val date = ZonedDateTime.parse(this).withZoneSameInstant(zoneId)
return date.cardDateTimeString()
}

fun ZonedDateTime.cardTimeAgoInWordsDateString(): String {
return DateUtils.getRelativeTimeSpanString(this.toInstant().toEpochMilli(), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS).toString()
}

fun String.cardTimeAgoInWordsDateString(zoneId: ZoneId = ZoneId.systemDefault()): String {
if (this.isBlank()) return ""

val date = ZonedDateTime.parse(this).withZoneSameInstant(zoneId)
return date.cardTimeAgoInWordsDateString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ package com.nativeapptemplate.nativeapptemplatefree.utils
import android.content.Context
import android.content.ContextWrapper
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.os.Build
import androidx.activity.ComponentActivity
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.core.content.FileProvider
import com.nativeapptemplate.nativeapptemplatefree.BuildConfig
import com.nativeapptemplate.nativeapptemplatefree.NatConstants
import com.nativeapptemplate.nativeapptemplatefree.R
import java.io.File
import java.io.FileOutputStream
import java.util.Locale

object Utility {
Expand All @@ -28,12 +22,6 @@ object Utility {
else -> null
}

fun isAlphanumeric(text: String?): Boolean {
if (text.isNullOrBlank()) return false

return text.matches("^[a-zA-Z0-9]*$".toRegex())
}

fun marketUri(): Uri {
val appId = BuildConfig.APPLICATION_ID
return Uri.parse("market://details?id=$appId")
Expand All @@ -44,30 +32,6 @@ object Utility {
return Uri.parse("https://play.google.com/store/apps/details?id=$appId")
}

// https://stackoverflow.com/a/75714502/1160200
// https://qiita.com/irgaly/items/b942bd985a4647e372ea
fun Context.shareImage(title: String, image: ImageBitmap, filename: String) {
val file = File(cacheDir, "$filename.png").also { outputFile ->
FileOutputStream(outputFile).use { outputStream ->
image.asAndroidBitmap().compress(Bitmap.CompressFormat.PNG, 100, outputStream)
}
}

val uri = file.toUriCompat(this)

val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
type = "image/png"
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
putExtra(Intent.EXTRA_STREAM, uri)
}
startActivity(Intent.createChooser(shareIntent, title))
}

private fun File.toUriCompat(context: Context): Uri {
return FileProvider.getUriForFile(context, context.packageName + ".fileprovider", this)
}

// https://stackoverflow.com/a/78039163/1160200
fun Context.restartApp() {
val packageManager = packageManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,4 @@ class UtilityTest {
fun validateEmail_noDomain_returnsFalse() {
assertFalse("test@".validateEmail())
}

// isAlphanumeric tests

@Test
fun isAlphanumeric_alphanumericText_returnsTrue() {
assertTrue(Utility.isAlphanumeric("abc123"))
}

@Test
fun isAlphanumeric_lettersOnly_returnsTrue() {
assertTrue(Utility.isAlphanumeric("abcdef"))
}

@Test
fun isAlphanumeric_numbersOnly_returnsTrue() {
assertTrue(Utility.isAlphanumeric("123456"))
}

@Test
fun isAlphanumeric_specialChars_returnsFalse() {
assertFalse(Utility.isAlphanumeric("abc!@#"))
}

@Test
fun isAlphanumeric_null_returnsFalse() {
assertFalse(Utility.isAlphanumeric(null))
}

@Test
fun isAlphanumeric_blank_returnsFalse() {
assertFalse(Utility.isAlphanumeric(""))
}
}
Loading