mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Fix bug with currency localization.
This commit is contained in:
committed by
Greyson Parrelli
parent
e3b7fe7509
commit
c9ba0432a0
@@ -1,5 +1,8 @@
|
||||
package org.thoughtcrime.securesms.payments.create;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -25,7 +28,11 @@ enum AmountKeyboardGlyph {
|
||||
this.glyphRes = glyphRes;
|
||||
}
|
||||
|
||||
public int getGlyphRes() {
|
||||
return glyphRes;
|
||||
public String getGlyph(@NonNull Context context) {
|
||||
if (this == DECIMAL) {
|
||||
return ".";
|
||||
} else {
|
||||
return context.getString(glyphRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class CreatePaymentViewModel extends ViewModel {
|
||||
if (!oldAmount.isEmpty()) {
|
||||
String newAmount = oldAmount.substring(0, oldAmount.length() - 1);
|
||||
if (newAmount.isEmpty()) {
|
||||
return context.getString(AmountKeyboardGlyph.ZERO.getGlyphRes());
|
||||
return AmountKeyboardGlyph.ZERO.getGlyph(context);
|
||||
} else {
|
||||
return newAmount;
|
||||
}
|
||||
@@ -239,12 +239,12 @@ public class CreatePaymentViewModel extends ViewModel {
|
||||
return oldAmount;
|
||||
}
|
||||
|
||||
boolean oldAmountIsZero = context.getString(AmountKeyboardGlyph.ZERO.getGlyphRes()).equals(oldAmount);
|
||||
int decimalIndex = oldAmount.indexOf(context.getString(AmountKeyboardGlyph.DECIMAL.getGlyphRes()));
|
||||
boolean oldAmountIsZero = AmountKeyboardGlyph.ZERO.getGlyph(context).equals(oldAmount);
|
||||
int decimalIndex = oldAmount.indexOf(AmountKeyboardGlyph.DECIMAL.getGlyph(context));
|
||||
|
||||
if (glyph == AmountKeyboardGlyph.DECIMAL) {
|
||||
if (oldAmountIsZero) {
|
||||
return context.getString(AmountKeyboardGlyph.ZERO.getGlyphRes()) + context.getString(glyph.getGlyphRes());
|
||||
return AmountKeyboardGlyph.ZERO.getGlyph(context) + glyph.getGlyph(context);
|
||||
} else if (decimalIndex > -1) {
|
||||
return oldAmount;
|
||||
}
|
||||
@@ -255,9 +255,9 @@ public class CreatePaymentViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
if (oldAmountIsZero) {
|
||||
return context.getString(glyph.getGlyphRes());
|
||||
return glyph.getGlyph(context);
|
||||
} else {
|
||||
return oldAmount + context.getString(glyph.getGlyphRes());
|
||||
return oldAmount + glyph.getGlyph(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user