Giter Club home page Giter Club logo

currencyedittext's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

currencyedittext's Issues

Inability to set edittext to allow negative values

I have set the hint to an empty string but it still shows up with the pound sign as that is the region I am in.
I have used this code: editAmountexpense.setHint("");
Where editAmountExpense is the CurrencyEditText, and I still get the currency sign.
I am doing this because I want to turn the raw entered value to a float with 2 decimal places but without the hint in front.

Setting new currency does nothing

I noticed that when calling setCurrency, it'll set it back to the default currency. It's because setCurrency calls init, which calls initCurrency and sets the currency back to the default locale. Basically, trying to set a currency that is not the default currency is impossible because it would set itself back to the default currency. I can't set a locale because I only have a currency.

myCurrencyEditText.setCurrency(myCurrency); // calling this

public void setCurrency(Currency currency) {
  this.currency = currency;

  init(); // goes here
  updateHint();
}

private void init() {
  initCurrency(); // then here
  initCurrencyTextWatcher();
}

private void initCurrency() {
  try {
    currency = Currency.getInstance(locale); // effectively sets it back to the default currency
  } catch (IllegalArgumentException e) {
    currency = Currency.getInstance(defaultLocale);
  }
}

Ignore Decimal Values

Is there a way to disable the decimal value? I only care about whole dollar amounts.

Hint can't be changed

By default, the hint is displaying as £0.00 and despite changing android:hint, it will not budge.

I say it's displaying the hint, it seems to be the text value rather than the hint value (the EditText style for a hint is a dulled grey, this is black).

Symbol Visibility

Hi

Is there any feature in the api to set visibility of currency symbol?
Actually my app gives user choice of currency selection, and based on this selected currency the price is formatted following corresponding symbol.
This is not problem for US Dollar or Euro or even Yuan currencies to show symbol in CurrencyEditText, but for some locales this is not valid.
Consider for example user chooses Iranian's Rial, but on some devices this currency is not available, because there is no Persian locale by default in android. So my workaround is to not show currency symbol in edittext. But there is no option for that in CurrencyEditText!

Your library is great but I think that needs this feature.
Thanks

Suggestion regarding formatCurrency

I refer to the below class method formatCurrency. It would be better if the formatCurrency be inlined into the widget class itself e.g. mCurrencyEditText.getFormattedCurrency() or make the formatCurrency method a static method e.g. CurrencyEditText.formatCurrency(Long|String)

Reason being when inlined into the widget class it looks much cleaner and users will not be able to input the wrong arguments into the formatCurrency method, at least for its intended usage with the widget.

And i have one feature request. Often when I have a currency input field, I would usually like to get the value as a double for saving the value into a database or POJO(nosql db like realm or firebase). So could we have a convenience method like mCurrenctEditText.getDoubleValue() which returns a double?

Currently this is what i am doing mCurrenctEditText.getRawValue()/100.0

Anyway keep up the good work!

//rawVal contains "1000"
CurrencyEditText cet = new CurrencyEditText();
 
... user inputs "$10.00"
 
//rawVal is 1000
Long rawVal = cet.getRawValue();

//formattedVal accepts "1000" and returns "$10.00"
String formattedVal = cet.formatCurrency(Long.toString(rawVal));

//or

String formattedVal = cet.formatCurrency(rawVal);

Problem with Locale.

So, my Locale displays well on the Edittext,
i save the value as Raw, but when I try to display the formatted Value.
it uses US Locale. how can I overcome this constraint?

        CurrencyEditText cet = new CurrencyEditText(context,null);
        String currentText = cet.formatCurrency(Long.toString(produtoActual.getValor()));
        Locale locale = new Locale("pt", "MZ");
        cet.setLocale(locale);
        viewHolder.preco.setText(currentText);

CurrencyTextView

Is there a TextView exposed by this lib which handles all currency related functionalities just like the EditText does? I am looking to display currency stored in long in a TextView.

Long overflow parsing exception

When you mash numbers and you overflow the capacity of long, CurrencyTextWatcher line 49 parsing Long from string throws 'java.lang.NumberFormatException: Invalid long: "9658656685598570005"'

Set cursor to end of cents on focus

Started using your module a few days ago as it much better handles symbols at the end of the string. Is there a method to set the cursor to the end of the cents display ie

$1,000| or 1,000| kr

as the cursor moves there after the initial input

you have similar functionality already in the watcher class but would be nice to have that exposed as a main method

Can not download

Error:(46, 13) Failed to resolve: com.github.BlacKCaT27:CurrencyEditText:v2.0.1

Currency sign can't be removed in CurrencyEditText

I am using this library to format edittext like currency input. Example. if user wants to enter 10, he will simply enter 1000 and we will automatically show the value as 10.00. After I used this library, everything was going well. But, the problem is currency sign (eg.$ sign if my device's locale is US) appears at the start of EditText. I am trying to drop that sign. I have tried
android.hint="" like mentioned in README. But, it is not working. I know it is because of Locale. So, I tried to drop locale like below.
edCurrency.setDefaultLocale(Locale.ROOT); edCurrency.setLocale(Locale.ROOT); But, it is not also working. Could you please let us know how can I drop currency sign in CurrencyEditText. Thanks and appreciating!
image

Removing the currency symbol like the dollar $

Tested with the android.hint="" to remove the $ sign (as is stated in the README), no effect.
And since you are using this code for the format:
currencyFormatter = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale);
regardless of the hints, I don't see how the currency symbol will be removed.

Is there any plan to fix this?

force curser to right, when currecyEditText is focused

Hi, nice library, thank's for sharing it.
Do you know if it's possible to force the curser to the furthest right when the currencyEditText first gets focus?

As it is at the moment when the user clicks in the editText the curser just appears wherever they clicked, which means the first number they enter will appear at that position, then subsequent numbers will appear on the right. It makes the user experience a little awkward.

Cheers,

CurrencyEditText setSelection problem

Hi, I am trying to place the cursor rightmost position at the first focus. I get the content length correctly and call setSelection method. But doesn't work for me.

binding.cet.setSelection(binding.cet.getText().length()); // I call it on focus

Crash when Entering decimal point in a blank field

Reproduction Steps:

In the sample app,

  1. Click in Reset button.
  2. Type a decimal point in the first field

Expected

  1. The string "$0." appears in the field

Actual

The app crashes.

09-23 20:08:43.367 14567-14567/com.blackcat.currencyedittexttester E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.blackcat.currencyedittexttester, PID: 14567
java.lang.IndexOutOfBoundsException: setSpan (1 ... 1) ends beyond length 0
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1265)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:677)
at android.text.Selection.setSelection(Selection.java:76)
at android.widget.TextView.semSetSelection(TextView.java:11458)
at android.widget.TextView.semSetSelection(TextView.java:11472)
at android.widget.EditText.setSelection(EditText.java:124)
at com.blackcat.currencyedittext.CurrencyTextWatcher.afterTextChanged(CurrencyTextWatcher.java:68)
at android.widget.TextView.sendAfterTextChanged(TextView.java:9443)

Negative numbers not working

Hi,
I'm trying to use your module but even though I'm including app:allow_negative_values="true" into my xml and the minus sign is shown on my keyboard, it won't allow me to insert negative numbers ( pressing it has no effect). Am I missing something?

PS: is it really necessary to include InputType.TYPE_NUMBER_FLAG_DECIMAL? Isn't the user supposed to insert only numbers?

SetText(CharSequence text) method passing empty string as parameter doesn't change mText

Hey! :)

I've had a problem: calling SetText("") to erase the displayed currency value and then bring the hint again doesn't work like default EditTexts.

I'm using CurrencyEditText inside my RecyclerView items. When I add a new item, I call SetText("") in my CurrencyEditText object to update it's value (for example, changing mText from "U$0,02" to "", so it would display back again the hint, like a default EditText), but it doesn't change the value.

Edit:
This situation happens inside the afterTextChanged(Editable editable) method of class CurrencyTextWatcher, when it tries to get a formatted text from an empty string:
image

I've converted initCurrencyTextWatcher() from private to public, and called it so It would be possible to reinitialize textWatcher field, and then lastGoodInput would be an empty string in this situation, but the app freezes in this situation.

Is there any way to force the hint to be displayed?

Poland currency issue

For Poland there is an issue because the currency simbol has 2 characters (for euro it is only 1). The code was coming from right to left 2 characters, the euro simbol and the space. I already fixed for my application and I'm going to do a pull request for this fix today.

Outdated version number in README

You should consider editing your README and replacing

compile 'com.github.BlacKCaT27:CurrencyEditText:v1.2.3'

with something more generic like

compile 'com.github.BlacKCaT27:CurrencyEditText:v<VERSION>'

if you not plan to keep README updated after each release as others do that so people may simply copy this w/o checking into their gradle files and get hit by outdated version instead of recent one.

NumberFormatException for number greater than Long max value

java.lang.NumberFormatException: For input string: "10000000000000000000"
    at java.lang.Long.parseLong(Long.java:593)
    at java.lang.Long.valueOf(Long.java:804)
    at com.blackcat.currencyedittext.CurrencyTextWatcher.afterTextChanged(CurrencyTextWatcher.java:49)```

Build problem

Hi,

I am new at gradle.
I tried to add dependency to my gradle file as " compile 'com.github.blackcat27:library:1.2.0-SNAPSHOT'" and got error

Error:(33, 13) Failed to resolve: com.blackcat.currencyedittext:library:1.2.0-SNAPSHOT

What is the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.