Bump and clear

This commit is contained in:
Sad Ellie 2022-11-20 20:03:08 +04:00
parent 7fc6cea761
commit 7c38a60788
12 changed files with 98 additions and 30 deletions

View File

@ -14,7 +14,7 @@ plugins {
id("com.google.firebase.crashlytics") id("com.google.firebase.crashlytics")
} }
val composeVersion = "1.4.0-alpha01" val composeVersion = "1.4.0-alpha02"
// Flavor names // Flavor names
val playStore = "playStore" val playStore = "playStore"
@ -127,7 +127,7 @@ android {
shaders = false shaders = false
} }
composeOptions { composeOptions {
kotlinCompilerExtensionVersion = "1.3.0-rc01" kotlinCompilerExtensionVersion = "1.4.0-alpha02"
} }
packagingOptions { packagingOptions {
jniLibs.excludes.add("META-INF/licenses/**") jniLibs.excludes.add("META-INF/licenses/**")
@ -164,9 +164,9 @@ dependencies {
// Hilt and navigation // Hilt and navigation
implementation("androidx.hilt:hilt-navigation-compose:1.0.0") implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
kapt("com.google.dagger:dagger-android-processor:2.44.1") kapt("com.google.dagger:dagger-android-processor:2.44.2")
implementation("com.google.dagger:hilt-android:2.44.1") implementation("com.google.dagger:hilt-android:2.44.2")
kapt("com.google.dagger:hilt-compiler:2.44.1") kapt("com.google.dagger:hilt-compiler:2.44.2")
// There are a lot of icons // There are a lot of icons
implementation("androidx.compose.material:material-icons-extended:$composeVersion") implementation("androidx.compose.material:material-icons-extended:$composeVersion")
@ -175,10 +175,10 @@ dependencies {
implementation("androidx.datastore:datastore-preferences:1.0.0") implementation("androidx.datastore:datastore-preferences:1.0.0")
// This is for system status bar color // This is for system status bar color
implementation("com.google.accompanist:accompanist-systemuicontroller:0.27.0") implementation("com.google.accompanist:accompanist-systemuicontroller:0.27.1")
// Firebase // Firebase
"playStoreImplementation"(platform("com.google.firebase:firebase-bom:31.0.2")) "playStoreImplementation"(platform("com.google.firebase:firebase-bom:31.1.0"))
"playStoreImplementation"("com.google.firebase:firebase-analytics-ktx") "playStoreImplementation"("com.google.firebase:firebase-analytics-ktx")
// Crashlytics and Analytics // Crashlytics and Analytics
"playStoreImplementation"("com.google.firebase:firebase-crashlytics-ktx") "playStoreImplementation"("com.google.firebase:firebase-crashlytics-ktx")

View File

@ -23,6 +23,7 @@ import android.content.Context
/** /**
* This class is NOT actually using firebase. Used for flavors WITHOUT Firebase dependency. * This class is NOT actually using firebase. Used for flavors WITHOUT Firebase dependency.
*/ */
@Suppress("EmptyMethod")
class FirebaseHelper { class FirebaseHelper {
/** /**

View File

@ -138,8 +138,7 @@ fun UnittoApp(
navigateUp = { navController.navigateUp() }, navigateUp = { navController.navigateUp() },
navigateToSettingsAction = { navController.navigate(UNIT_GROUPS_SCREEN) }, navigateToSettingsAction = { navController.navigate(UNIT_GROUPS_SCREEN) },
selectAction = { mainViewModel.changeUnitTo(it) }, selectAction = { mainViewModel.changeUnitTo(it) },
inputValue = (mainViewModel.mainFlow.value.calculatedValue inputValue = mainViewModel.inputValue(),
?: mainViewModel.mainFlow.value.inputValue).toBigDecimal(),
unitFrom = mainViewModel.unitFrom unitFrom = mainViewModel.unitFrom
) )
} }

View File

@ -37,7 +37,7 @@ data class CurrencyUnitResponse(
* Custom parser because API has a weird json structure (dynamic field names) * Custom parser because API has a weird json structure (dynamic field names)
*/ */
class CurrencyAdapter { class CurrencyAdapter {
@Suppress("UNUSED", "UNUSED_PARAMETER") @Suppress("UNUSED", "UNUSED_PARAMETER", "SameReturnValue")
@ToJson fun toJson(card: CurrencyUnitResponse): String? = null @ToJson fun toJson(card: CurrencyUnitResponse): String? = null
@Suppress("UNUSED", "UNCHECKED_CAST") @Suppress("UNUSED", "UNCHECKED_CAST")

View File

@ -21,7 +21,16 @@ package com.sadellie.unitto.screens
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import com.sadellie.unitto.data.* import com.sadellie.unitto.data.KEY_COMMA
import com.sadellie.unitto.data.KEY_DIVIDE
import com.sadellie.unitto.data.KEY_DIVIDE_DISPLAY
import com.sadellie.unitto.data.KEY_DOT
import com.sadellie.unitto.data.KEY_E
import com.sadellie.unitto.data.KEY_MINUS
import com.sadellie.unitto.data.KEY_MINUS_DISPLAY
import com.sadellie.unitto.data.KEY_MULTIPLY
import com.sadellie.unitto.data.KEY_MULTIPLY_DISPLAY
import com.sadellie.unitto.data.KEY_PLUS
import com.sadellie.unitto.data.preferences.OutputFormat import com.sadellie.unitto.data.preferences.OutputFormat
import com.sadellie.unitto.data.preferences.Separator import com.sadellie.unitto.data.preferences.Separator
import com.sadellie.unitto.data.units.AbstractUnit import com.sadellie.unitto.data.units.AbstractUnit
@ -80,10 +89,7 @@ object Formatter {
// We may receive expressions // We may receive expressions
// Find all numbers in that expression // Find all numbers in that expression
val allNumbers: List<String> = input.split( val allNumbers: List<String> = input.split(
KEY_MINUS, KEY_MINUS, KEY_DIVIDE, KEY_PLUS, KEY_MULTIPLY
KEY_DIVIDE,
KEY_PLUS,
KEY_MULTIPLY
) )
allNumbers.forEach { allNumbers.forEach {
@ -173,19 +179,18 @@ fun openLink(mContext: Context, url: String) {
} }
/** /**
* Compute Levenshtein Distance. Doesn't really matter which string goes first * Compute Levenshtein Distance between this string and [stringB]. Doesn't matter which string is
* first.
* *
* @param stringToCompare Second string
* @return The amount of changes that are needed to transform one string into another * @return The amount of changes that are needed to transform one string into another
*/ */
fun String.lev(stringToCompare: String): Int { fun String.lev(stringB: String): Int {
val stringA = this val stringA = this
val stringB = stringToCompare
// Skipping computation for this cases // Skipping computation for this cases
if (stringA == stringB) return 0 if (stringA == stringB) return 0
if (stringA.isEmpty()) return stringB.length if (stringA.isEmpty()) return stringB.length
// This case is basically unreal in this app, because stringToCompare is a unit name and they are never empty // This case is basically unreal in this app, because stringB is a unit name and they are never empty
if (stringB.isEmpty()) return stringA.length if (stringB.isEmpty()) return stringA.length
var cost = IntArray(stringA.length + 1) { it } var cost = IntArray(stringA.length + 1) { it }

View File

@ -27,7 +27,22 @@ import androidx.lifecycle.viewModelScope
import com.github.keelar.exprk.ExpressionException import com.github.keelar.exprk.ExpressionException
import com.github.keelar.exprk.Expressions import com.github.keelar.exprk.Expressions
import com.sadellie.unitto.FirebaseHelper import com.sadellie.unitto.FirebaseHelper
import com.sadellie.unitto.data.* import com.sadellie.unitto.data.KEY_0
import com.sadellie.unitto.data.KEY_1
import com.sadellie.unitto.data.KEY_2
import com.sadellie.unitto.data.KEY_3
import com.sadellie.unitto.data.KEY_4
import com.sadellie.unitto.data.KEY_5
import com.sadellie.unitto.data.KEY_6
import com.sadellie.unitto.data.KEY_7
import com.sadellie.unitto.data.KEY_8
import com.sadellie.unitto.data.KEY_9
import com.sadellie.unitto.data.KEY_DIVIDE
import com.sadellie.unitto.data.KEY_DOT
import com.sadellie.unitto.data.KEY_MINUS
import com.sadellie.unitto.data.KEY_MULTIPLY
import com.sadellie.unitto.data.KEY_PLUS
import com.sadellie.unitto.data.OPERATORS
import com.sadellie.unitto.data.preferences.UserPreferences import com.sadellie.unitto.data.preferences.UserPreferences
import com.sadellie.unitto.data.preferences.UserPreferencesRepository import com.sadellie.unitto.data.preferences.UserPreferencesRepository
import com.sadellie.unitto.data.units.AbstractUnit import com.sadellie.unitto.data.units.AbstractUnit
@ -40,7 +55,12 @@ import com.sadellie.unitto.data.units.remote.CurrencyApi
import com.sadellie.unitto.data.units.remote.CurrencyUnitResponse import com.sadellie.unitto.data.units.remote.CurrencyUnitResponse
import com.sadellie.unitto.screens.toStringWith import com.sadellie.unitto.screens.toStringWith
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.math.BigDecimal import java.math.BigDecimal
import java.math.RoundingMode import java.math.RoundingMode
@ -367,6 +387,11 @@ class MainViewModel @Inject constructor(
_inputValue.update { KEY_0 } _inputValue.update { KEY_0 }
} }
/**
* Returns value to be used when converting value on the right side screen (unit selection)
*/
fun inputValue() = (mainFlow.value.calculatedValue ?: mainFlow.value.inputValue).toBigDecimal()
/** /**
* Saves latest pair of units into datastore * Saves latest pair of units into datastore
*/ */

View File

@ -25,7 +25,25 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.sadellie.unitto.data.* import com.sadellie.unitto.data.KEY_0
import com.sadellie.unitto.data.KEY_1
import com.sadellie.unitto.data.KEY_2
import com.sadellie.unitto.data.KEY_3
import com.sadellie.unitto.data.KEY_4
import com.sadellie.unitto.data.KEY_5
import com.sadellie.unitto.data.KEY_6
import com.sadellie.unitto.data.KEY_7
import com.sadellie.unitto.data.KEY_8
import com.sadellie.unitto.data.KEY_9
import com.sadellie.unitto.data.KEY_CLEAR
import com.sadellie.unitto.data.KEY_DIVIDE
import com.sadellie.unitto.data.KEY_DIVIDE_DISPLAY
import com.sadellie.unitto.data.KEY_DOT
import com.sadellie.unitto.data.KEY_MINUS
import com.sadellie.unitto.data.KEY_MINUS_DISPLAY
import com.sadellie.unitto.data.KEY_MULTIPLY
import com.sadellie.unitto.data.KEY_MULTIPLY_DISPLAY
import com.sadellie.unitto.data.KEY_PLUS
import com.sadellie.unitto.screens.Formatter import com.sadellie.unitto.screens.Formatter
/** /**

View File

@ -19,10 +19,21 @@
package com.sadellie.unitto.screens.main.components package com.sadellie.unitto.screens.main.components
import android.widget.Toast import android.widget.Toast
import androidx.compose.animation.* import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.with
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.material.ripple.rememberRipple import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme

View File

@ -21,7 +21,11 @@ package com.sadellie.unitto.screens.main.components
import androidx.compose.animation.core.FastOutSlowInEasing import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.SwapHoriz import androidx.compose.material.icons.outlined.SwapHoriz
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
@ -31,7 +35,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate import androidx.compose.ui.draw.rotate

View File

@ -39,7 +39,12 @@ import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.FavoriteBorder import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.outlined.Clear import androidx.compose.material.icons.outlined.Clear
import androidx.compose.material3.* import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue

View File

@ -6,8 +6,8 @@ buildscript {
} }
dependencies { dependencies {
classpath("com.android.tools.build:gradle:7.3.1") classpath("com.android.tools.build:gradle:7.3.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21")
classpath("com.google.dagger:hilt-android-gradle-plugin:2.43") classpath("com.google.dagger:hilt-android-gradle-plugin:2.44.2")
// Google services // Google services
classpath("com.google.gms:google-services:4.3.14") classpath("com.google.gms:google-services:4.3.14")

View File

@ -1,3 +1,4 @@
@Suppress("UnstableApiUsage")
dependencyResolutionManagement { dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories { repositories {