Repository navigation
feat: introduce notification reminder on filter apps #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
isaacsa51
merged 3 commits into
master
from
feat/notification/suggest_app_on_transaction
Oct 10, 2026
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| name: Sync Crowdin | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| paths: | ||
| - 'app/src/main/res/values/strings.xml' | ||
| - 'app/src/main/res/values-*/strings.xml' | ||
| - 'crowdin.yml' | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: crowdin-sync | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| upload: | ||
| name: Upload sources and translations | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | ||
|
|
||
| - name: Upload to Crowdin | ||
| uses: crowdin/github-action@8f01d54f70f1713ee3f09d82c2bbb2daeac28689 # v2.17.1 | ||
| with: | ||
| upload_sources: true | ||
| upload_translations: true | ||
| import_eq_suggestions: true | ||
| auto_approve_imported: false | ||
| download_translations: false | ||
| env: | ||
| CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
app/src/main/java/com/serranoie/app/minus/domain/notification/ExpenseNotificationParser.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| package com.serranoie.app.minus.domain.notification | ||
|
|
||
| import com.serranoie.app.minus.domain.model.SupportedCurrency | ||
| import java.math.BigDecimal | ||
|
|
||
| const val PENDING_QUICK_ADD_AMOUNT_KEY_NAME = "pending_quick_add_amount" | ||
|
|
||
| object ExpenseNotificationParser { | ||
|
|
||
| private const val EVIDENCE_WINDOW = 8 | ||
| private const val SIGN_WINDOW = 4 | ||
|
|
||
| private val AMOUNT = Regex( | ||
| """[+\-]?\d{1,3}(?:[.,\u00A0 ]\d{3})+(?:[.,]\d{1,2})?|[+\-]?\d+(?:[.,]\d{1,2})?""" | ||
| ) | ||
|
|
||
| /** | ||
| * Symbols that more than one supported currency uses, such as "$" for USD, MXN, ARS, COP and | ||
| * CLP. Seeing one of these says nothing about which currency the amount is in, so they are not | ||
| * accepted as evidence on their own. | ||
| */ | ||
| private val SHARED_SYMBOLS: Set<String> by lazy { | ||
| SupportedCurrency.ALL | ||
| .groupingBy { it.symbol.trim().lowercase() } | ||
| .eachCount() | ||
| .filterValues { it > 1 } | ||
| .keys | ||
| } | ||
|
|
||
| fun parse( | ||
| text: String, | ||
| currencyCode: String, | ||
| denyWords: List<String>, | ||
| ): BigDecimal? { | ||
| if (text.isBlank()) return null | ||
| val haystack = text.lowercase() | ||
|
|
||
| if (denyWords.any { it.isNotBlank() && haystack.contains(it.trim().lowercase()) }) return null | ||
|
|
||
| val evidence = evidenceRanges(haystack, currencyCode) | ||
| if (evidence.isEmpty()) return null | ||
|
|
||
| for (match in AMOUNT.findAll(haystack)) { | ||
| if (haystack.getOrNull(match.range.last + 1) == '%') continue | ||
| val leading = haystack.substring( | ||
| (match.range.first - SIGN_WINDOW).coerceAtLeast(0), | ||
| match.range.first, | ||
| ) | ||
| if (match.value.startsWith("+") || leading.contains('+')) continue | ||
|
|
||
| val from = (match.range.first - EVIDENCE_WINDOW).coerceAtLeast(0) | ||
| val to = (match.range.last + EVIDENCE_WINDOW).coerceAtMost(haystack.length - 1) | ||
| if (evidence.none { it.first >= from && it.last <= to }) continue | ||
|
|
||
| val amount = normalize(match.value) ?: continue | ||
| if (amount.compareTo(BigDecimal.ZERO) == 0) continue | ||
| return amount | ||
| } | ||
| return null | ||
| } | ||
|
|
||
| /** | ||
| * Where in [haystack] the configured currency is spelled out. The ISO code always counts, but | ||
| * only as a whole code, so "usdx" or "busd" is not evidence of USD. The symbol counts only when | ||
| * a single supported currency uses it. | ||
| */ | ||
| private fun evidenceRanges(haystack: String, currencyCode: String): List<IntRange> { | ||
| val code = currencyCode.trim().lowercase() | ||
| val ranges = mutableListOf<IntRange>() | ||
| if (code.isNotEmpty()) ranges += occurrencesOf(haystack, code) | ||
|
|
||
| val symbol = SupportedCurrency.findByCode(currencyCode)?.symbol?.trim()?.lowercase() | ||
| if (!symbol.isNullOrEmpty() && symbol != code && symbol !in SHARED_SYMBOLS) { | ||
| ranges += occurrencesOf(haystack, symbol) | ||
| } | ||
| return ranges | ||
| } | ||
|
|
||
| /** | ||
| * Every occurrence of [token] in [haystack] that is not glued to a letter on either end, so an | ||
| * alphabetic token is matched as a whole word while digits around it are still allowed | ||
| * ("12.00usd" counts, "usdx" does not). | ||
| */ | ||
| private fun occurrencesOf(haystack: String, token: String): List<IntRange> { | ||
| if (token.isEmpty()) return emptyList() | ||
| val ranges = mutableListOf<IntRange>() | ||
| var index = haystack.indexOf(token) | ||
| while (index >= 0) { | ||
| val endExclusive = index + token.length | ||
| val startIsBounded = !token.first().isLetter() || | ||
| haystack.getOrNull(index - 1)?.isLetter() != true | ||
| val endIsBounded = !token.last().isLetter() || | ||
| haystack.getOrNull(endExclusive)?.isLetter() != true | ||
| if (startIsBounded && endIsBounded) ranges += index until endExclusive | ||
| index = haystack.indexOf(token, index + 1) | ||
| } | ||
| return ranges | ||
| } | ||
|
|
||
| private fun normalize(token: String): BigDecimal? { | ||
| val cleaned = token.trimStart('+', '-').filterNot { it.isWhitespace() || it == '\u00A0' } | ||
| val lastSeparator = cleaned.indexOfLast { it == '.' || it == ',' } | ||
| return runCatching { | ||
| if (lastSeparator < 0) { | ||
| BigDecimal(cleaned) | ||
| } else { | ||
| val fraction = cleaned.substring(lastSeparator + 1) | ||
| if (fraction.length in 1..2) { | ||
| val whole = cleaned.take(lastSeparator).filter { it.isDigit() } | ||
| BigDecimal("${whole.ifEmpty { "0" }}.$fraction") | ||
| } else { | ||
| BigDecimal(cleaned.filter { it.isDigit() }) | ||
| } | ||
| } | ||
| }.getOrNull() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.