cottacush / currencyedittext Goto Github PK
View Code? Open in Web Editor NEW💰 A library to dynamically format your EditTexts to take currency inputs
License: Apache License 2.0
💰 A library to dynamically format your EditTexts to take currency inputs
License: Apache License 2.0
eg: I cant input 10.01
The library has been stable for more than a year now. 0.X.X
suggests that it's not stable. We should bump to 1.0.0
Whoops wrong repo
Add documentation to the methods, to provide additional information to the parameters and return values.
Hi
Can I specify the largest Integer number, such as decimal number?
Currently it is hardcoded to 2
in CurrencyInputWatcher
companion object but in a project I'm working on this number needs to be 3
. Can this be made configurable?
First, focus in front of the currency selected symbol
Will be displayed blank in the EditText and the cursor is not displayed in front of the text. @codedentwickler
@codedentwickler Request to reduce minSdkVersion to 17, Thank you.
If we set value to Edit Text
etPrice.setText("123")
then currency symbol is not visible. But its set in xml file like app:currencySymbol="$"
When using it from a US locale, it works perfectly. You can choose when to use the decimal etc...
But when using for a locale like European where they use the "," instead of the ".", you can not choose the "," (or even the ".") to denote decimal place.
Similarly, when displaying the price, it does not seem correctly format it for the locale, using "." instead of ",".
When the user clicks on a field that has already been pre-populated with a 0 value, it'd be nice if it allowed typing the new value immediately. Right now, a user has to delete all of the zeros before they begin typing a new value.
As a workaround I'm leaving it empty currently, but this behavior diverges from how I have this implemented in the iOS version of my app, so not perfectly ideal.
Pressing the backspace key cannot delete characters continuously, only one character can be deleted.
An example:
val amount = "515.809"
currencyEditText.setText(amount)
A text visible in a field is expected to be 515.809
and yet it becomes 515.808
.
I get the same results when trying to enter 515.809
manually.
It would be interesting if it was delimited correctly depending on how the android device is configured and also if you want to show another type of currency.
I hope it helps
val nf: NumberFormat = NumberFormat.getCurrencyInstance(Locale.getDefault())
if (nf is DecimalFormat) {
val sym: DecimalFormatSymbols = nf.decimalFormatSymbols
Log.d(TAG, "currency: " + sym.currency)
Log.d(TAG, "currencySymbol: " + sym.currencySymbol)
Log.d(TAG, "decimalSeparator: " + sym.decimalSeparator)
Log.d(TAG, "digit: " + sym.digit)
Log.d(TAG, "exponentSeparator: " + sym.exponentSeparator)
Log.d(TAG, "groupingSeparator: " + sym.groupingSeparator)
Log.d(TAG, "infinity: " + sym.infinity)
Log.d(TAG, "internationalCurrencySymbol: " + sym.internationalCurrencySymbol)
Log.d(TAG, "minusSign: " + sym.minusSign)
Log.d(TAG, "monetaryDecimalSeparator: " + sym.monetaryDecimalSeparator)
Log.d(TAG, "naN: " + sym.naN)
Log.d(TAG, "patternSeparator: " + sym.patternSeparator)
Log.d(TAG, "perMill: " + sym.perMill)
Log.d(TAG, "percent: " + sym.percent)
Log.d(TAG, "zeroDigit: " + sym.zeroDigit)
}
Decimal Format detail
D/: currency: EUR
D/: currencySymbol: €
D/: decimalSeparator: ,
D/: digit: #
D/: exponentSeparator: E
D/: groupingSeparator: .
D/: infinity: ∞
D/: internationalCurrencySymbol: EUR
D/: minusSign: -
D/: monetaryDecimalSeparator: ,
D/: naN: NaN
D/: patternSeparator: ;
D/: perMill: ‰
D/: percent: %
D/: zeroDigit: 0
Print currency format
nf.format(2536) //2.536,00 €
nf.format(2536.3321F) //2.536,33 €
nf.format(999999999999999) //999.999.999.999.999,00 €
nf.format(0) //0,00 €
nf.format(-31) //-31,00 €
nf.format(-31.83F) //-31,83 €
Decimal Format detail
D/FirstFragment: currency: USD
D/FirstFragment: currencySymbol: $
D/FirstFragment: decimalSeparator: .
D/FirstFragment: digit: #
D/FirstFragment: exponentSeparator: E
D/FirstFragment: groupingSeparator: ,
D/FirstFragment: infinity: ∞
D/FirstFragment: internationalCurrencySymbol: USD
D/FirstFragment: minusSign: -
D/FirstFragment: monetaryDecimalSeparator: .
D/FirstFragment: naN: NaN
D/FirstFragment: patternSeparator: ;
D/FirstFragment: perMill: ‰
D/FirstFragment: percent: %
D/FirstFragment: zeroDigit: 0
Print currency format
nf.format(2536) //$2,536.00
nf.format(2536.3321F) //$2,536.33
nf.format(999999999999999) //$999,999,999,999,999.00
nf.format(0) //$0.00
nf.format(-31) //-$31.00
nf.format(-31.83F) //-$31.83
represent a currency different from that established by the system
nf.currency = Currency.getInstance("EUR")
result
view that the euro symbol is displayed at the beginning, as is the system set by the user
nf.format(2536) //€2,536.00
nf.format(2536.3321F) //€2,536.33
nf.format(999999999999999) //€999,999,999,999,999.00
nf.format(0) //€0.00
nf.format(-31) //-€31.00
nf.format(-31.83F) //-€31.83
Get available currencies
listCurrencies = Currency.getAvailableCurrencies()
.filter { !it.displayName.contains("(") }
.sortedBy { it.currencyCode }
.map { it.displayName }
it is not accepting decimal places. I click on the dot or comma and nothing happens, the number remains whole.
Very large amount resulted in rounding error in display.
Entered 1 followed by zeros...eventually saw $ 99,999,999,999,999,990,000,000 when value should have been
$ 100,000,000,000,000,000,000,000
Using
Android Studio 4.2 Beta 6
Build #AI-202.7660.26.42.7188722, built on March 5, 2021
Runtime version: 11.0.8+10-b944.6916264 x86_64
VM: OpenJDK 64-Bit Server VM by N/A
macOS 10.15.7
And AVD:
Name: Nexus_10_API_27
CPU/ABI: Google APIs Intel Atom (x86)
Path: /Users/michaelhampton/.android/avd/Nexus_10_API_27.avd
Target: google_apis [Google APIs] (API level 27)
Skin: nexus_10
SD Card: 100M
hw.dPad: no
hw.lcd.height: 1600
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: Nexus 10
vm.heapSize: 192
skin.dynamic: yes
hw.device.manufacturer: Google
hw.lcd.width: 2560
hw.gps: yes
hw.initialOrientation: Portrait
image.androidVersion.api: 27
hw.audioInput: yes
image.sysdir.1: system-images/android-27/google_apis/x86/
tag.id: google_apis
showDeviceFrame: yes
hw.camera.back: virtualscene
hw.mainKeys: no
AvdId: Nexus_10_API_27
hw.camera.front: emulated
hw.lcd.density: 320
avd.ini.displayname: Nexus 10 API 27
hw.arc: false
hw.gpu.mode: auto
hw.device.hash2: MD5:813203ac93d1d63cd91f729c376b1f3e
hw.ramSize: 1536
hw.trackBall: no
PlayStore.enabled: false
fastboot.forceColdBoot: no
hw.battery: yes
hw.cpu.ncore: 4
hw.sdCard: yes
tag.display: Google APIs
runtime.network.latency: none
hw.keyboard: yes
hw.sensors.proximity: no
disk.dataPartition.size: 800M
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes
Investigate how easy it is to support the TextField
in Jetpack compose. Check if the formatting logic can be properly extracted and used for both the View-based EditText and Compose's TextVField
.
Ideally, the composing support should be exposed as an additional artefact/dependency on top of the core-library logic. We might need to do some refactoring on the existing package structure.
I hope that the separator and the number of characters to be separated can be customized.
In this line:
hasDecimalPoint = s.toString().contains(decimalFormatSymbols.decimalSeparator.toString())
It will check Persian, Arabic or any language specific decimals, but if developer used numeric keyboard decimal char will be "," or ".". So have to add these two characters as well.
SO if we set locale to Persian or Arabic locale from phone
resources.configuration.locales[0]
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
gradle
, com.vanniktech.maven.publish
, com.diffplug.spotless
, org.jetbrains.kotlin.android
, com.android.library
, com.android.application
).github/workflows/ci.yml
actions/checkout v3
actions/setup-java v4
android-actions/setup-android v3
.github/workflows/publish.yml
actions/checkout v3
actions/setup-java v4
android-actions/setup-android v3
gradle.properties
dependencies.gradle
androidx.appcompat:appcompat 1.4.2
com.google.android.material:material 1.7.0
androidx.core:core-ktx 1.6.0
settings.gradle
spotless.gradle
build.gradle
com.android.application 8.0.1
com.android.library 8.0.1
org.jetbrains.kotlin.android 1.6.21
com.diffplug.spotless 6.12.0
com.vanniktech.maven.publish 0.25.3
library/build.gradle
junit:junit 4.13.2
org.mockito:mockito-core 5.3.1
org.mockito:mockito-inline 5.2.0
sample/build.gradle
signing/signing.gradle
gradle/wrapper/gradle-wrapper.properties
gradle 8.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.