Skip to content

Commit

Permalink
Apply changes from 2.0.2 release (#134)
Browse files Browse the repository at this point in the history
* Portfolio grammar fixes

* Use portfolio dialog instead of group dialog

* EditAsset: show keyboard on screen open

* Place cursor at end on focus

* Merge multiple instances of same asset in one portfolio

* Fix release app name and icon

* fix: AddAssetViewModel onAssetValueChange bug

* Replace downloadable fonts with font files

* Add AD_ID permission

* 2.0.2

* Fixing release workflow

* Fix portfolio asset add snackbar
  • Loading branch information
mdrlzy authored Dec 15, 2024
1 parent b167cc6 commit d370d54
Show file tree
Hide file tree
Showing 37 changed files with 505 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
distribution: 'adopt'

- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@3
uses: gradle/actions/wrapper-validation@v3

- name: Decrypt the keystore for signing
run: |
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId = "dev.arkbuilders.rate"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.compileSdk.get().toInt()
versionCode = 3
versionName = "1.2.0"
versionCode = 6
versionName = "2.0.2"
setProperty("archivesBaseName", "ark-rate")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -61,8 +61,8 @@ android {

addManifestPlaceholders(
mapOf(
"appIcon" to "@mipmap/ic_launcher_debug",
"appLabel" to "@string/app_name_debug",
"appIcon" to "@mipmap/ic_launcher",
"appLabel" to "@string/app_name",
),
)
}
Expand Down
6 changes: 2 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<application
android:name=".presentation.App"
Expand Down Expand Up @@ -53,9 +54,6 @@
tools:node="remove" />
</provider>

<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Upsert
import dev.arkbuilders.rate.core.db.entity.RoomAsset
import dev.arkbuilders.rate.core.domain.model.CurrencyCode
import kotlinx.coroutines.flow.Flow

@Dao
Expand All @@ -22,6 +23,9 @@ interface PortfolioDao {
@Query("SELECT * FROM RoomAsset WHERE id = :id")
suspend fun getById(id: Long): RoomAsset?

@Query("SELECT * FROM RoomAsset WHERE code = :code")
suspend fun getAllByCode(code: CurrencyCode): List<RoomAsset>

@Query("SELECT * FROM RoomAsset")
fun allFlow(): Flow<List<RoomAsset>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.LocalTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import dev.arkbuilders.rate.core.presentation.theme.ArkColor
Expand Down Expand Up @@ -39,3 +43,41 @@ fun ArkLargeTextField(
singleLine = true,
)
}

// Place cursor at end on focus
@Composable
fun ArkCursorLargeTextField(
modifier: Modifier,
value: String,
onValueChange: (String) -> Unit,
) {
var currentTextFieldValue =
remember {
mutableStateOf<TextFieldValue?>(null)
}
BasicTextField(
modifier =
modifier
.width(IntrinsicSize.Min)
.defaultMinSize(minWidth = 10.dp),
value =
TextFieldValue(
text = value,
selection = currentTextFieldValue.value?.selection ?: TextRange(value.length),
),
onValueChange = {
currentTextFieldValue.value = it
onValueChange(it.text)
},
textStyle =
LocalTextStyle.current.copy(
fontSize = 36.sp,
color = ArkColor.TextPrimary,
fontWeight = FontWeight.SemiBold,
),
keyboardOptions =
KeyboardOptions.Default
.copy(keyboardType = KeyboardType.Number),
singleLine = true,
)
}
Binary file added core/presentation/src/main/res/font/inter.ttf
Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_black.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_bold.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_extrabold.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_extralight.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_light.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_medium.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_semibold.xml

This file was deleted.

Binary file not shown.
7 changes: 0 additions & 7 deletions core/presentation/src/main/res/font/inter_thin.xml

This file was deleted.

17 changes: 0 additions & 17 deletions core/presentation/src/main/res/values/font_certs.xml

This file was deleted.

14 changes: 0 additions & 14 deletions core/presentation/src/main/res/values/preloaded_fonts.xml

This file was deleted.

19 changes: 13 additions & 6 deletions core/presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@


<string name="asset_detail">Asset detail</string>
<string name="portfolio_empty_title">Your Portfolio is Empty</string>
<string name="portfolio_empty_title">Your portfolio is empty</string>
<string name="portfolio_empty_desc">Add currencies manually to track and compare. Your portfolio helps you monitor and manage your favorite or frequently used currencies.</string>
<string name="portfolio_total_assets">Total Assets</string>
<string name="portfolio_snackbar_new_title">New Asset has been added</string>
<string name="portfolio_empty_new_assets">New assets</string>
<string name="portfolio_default_portfolio">Default portfolio</string>
<string name="portfolio_total_assets">Total assets</string>
<string name="portfolio_add_new_assets">Add new assets</string>
<string name="portfolio_new_asset">New asset</string>
<string name="portfolio_new_portfolio">New portfolio</string>
<string name="portfolio_name_dialog_title">Create portfolio</string>
<string name="portfolio_name_dialog_desc">Please enter a name for this group.</string>
<string name="portfolio_name_dialog_portfolio_name">Portfolio name</string>
<string name="portfolio_name_dialog_placeholder">e.g. Portfolio 1</string>
<string name="portfolio_snackbar_new_title">New asset has been added</string>
<string name="portfolio_snackbar_new_desc">You added %1$s to your portfolio</string>
<string name="portfolio_snackbar_removed_title">The asset has been deleted</string>
<string name="portfolio_snackbar_removed_desc">You deleted %1$s from you portfolio</string>
Expand Down Expand Up @@ -76,8 +85,7 @@
<string name="save">Save</string>
<string name="input_value">Input value</string>
<string name="result">Result</string>
<string name="new_currency">New Currency</string>
<string name="add_new_asset">Add new asset</string>
<string name="new_currency">New currency</string>
<string name="change_base_currency">Change base currency</string>
<string name="market_capitalization">Market Capitalization</string>
<string name="n_a">N/A</string>
Expand Down Expand Up @@ -129,7 +137,6 @@
<string name="alert_notification_desc">%1$s is now %2$s %3$s %4$s</string>
<string name="collect_analytics">Collect analytics</string>
<string name="search_currency">Search a currency</string>
<string name="new_asset">New Asset</string>
<string name="undo">Undo</string>
<string name="frequent_currencies">Frequent currencies</string>
<string name="top_results">Top results</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dev.arkbuilders.rate.feature.portfolio.data.repo

import dev.arkbuilders.rate.core.db.dao.PortfolioDao
import dev.arkbuilders.rate.core.db.entity.RoomAsset
import dev.arkbuilders.rate.core.domain.model.CurrencyCode
import dev.arkbuilders.rate.feature.portfolio.domain.model.Asset
import dev.arkbuilders.rate.feature.portfolio.domain.repo.PortfolioRepo
import kotlinx.coroutines.flow.Flow
Expand All @@ -23,6 +24,9 @@ class PortfolioRepoImpl @Inject constructor(

override suspend fun getById(id: Long) = dao.getById(id)?.toAsset()

override suspend fun getAllByCode(code: CurrencyCode) =
dao.getAllByCode(code).map { it.toAsset() }

override suspend fun setAsset(asset: Asset) = dao.insert(asset.toRoom())

override suspend fun setAssetsList(list: List<Asset>) = dao.insertList(list.map { it.toRoom() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import dagger.Provides
import dev.arkbuilders.rate.core.db.dao.PortfolioDao
import dev.arkbuilders.rate.feature.portfolio.data.repo.PortfolioRepoImpl
import dev.arkbuilders.rate.feature.portfolio.domain.repo.PortfolioRepo
import dev.arkbuilders.rate.feature.portfolio.domain.usecase.AddNewAssetsUseCase

@Module
class PortfolioModule {
@PortfolioScope
@Provides
fun portfolioRepo(portfolioDao: PortfolioDao): PortfolioRepo = PortfolioRepoImpl(portfolioDao)

@PortfolioScope
@Provides
fun addNewAssetsUseCase(portfolioRepo: PortfolioRepo): AddNewAssetsUseCase =
AddNewAssetsUseCase(portfolioRepo)
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package dev.arkbuilders.rate.feature.portfolio.domain.repo

import dev.arkbuilders.rate.core.domain.model.CurrencyCode
import dev.arkbuilders.rate.feature.portfolio.domain.model.Asset
import kotlinx.coroutines.flow.Flow

interface PortfolioRepo {
suspend fun allAssets(): List<dev.arkbuilders.rate.feature.portfolio.domain.model.Asset>
suspend fun allAssets(): List<Asset>

fun allAssetsFlow(): Flow<List<dev.arkbuilders.rate.feature.portfolio.domain.model.Asset>>
fun allAssetsFlow(): Flow<List<Asset>>

suspend fun getById(id: Long): dev.arkbuilders.rate.feature.portfolio.domain.model.Asset?
suspend fun getById(id: Long): Asset?

suspend fun setAsset(asset: dev.arkbuilders.rate.feature.portfolio.domain.model.Asset)
suspend fun getAllByCode(code: CurrencyCode): List<Asset>

suspend fun setAssetsList(list: List<dev.arkbuilders.rate.feature.portfolio.domain.model.Asset>)
suspend fun setAsset(asset: Asset)

suspend fun setAssetsList(list: List<Asset>)

suspend fun removeAsset(id: Long): Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.arkbuilders.rate.feature.portfolio.domain.usecase

import dev.arkbuilders.rate.feature.portfolio.domain.model.Asset
import dev.arkbuilders.rate.feature.portfolio.domain.repo.PortfolioRepo

class AddNewAssetsUseCase(
private val portfolioRepo: PortfolioRepo,
) {
suspend operator fun invoke(assets: List<Asset>) {
val mergedAssets =
assets.map { asset ->
val roomAsset =
portfolioRepo.getAllByCode(asset.code).find {
it.group == asset.group
}
val mergedAsset =
roomAsset?.let {
roomAsset.copy(value = asset.value + roomAsset.value)
} ?: asset
mergedAsset
}
portfolioRepo.setAssetsList(mergedAssets)
}
}
Loading

0 comments on commit d370d54

Please sign in to comment.