mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +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;
|
package org.thoughtcrime.securesms.payments.create;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
@@ -25,7 +28,11 @@ enum AmountKeyboardGlyph {
|
|||||||
this.glyphRes = glyphRes;
|
this.glyphRes = glyphRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGlyphRes() {
|
public String getGlyph(@NonNull Context context) {
|
||||||
return glyphRes;
|
if (this == DECIMAL) {
|
||||||
|
return ".";
|
||||||
|
} else {
|
||||||
|
return context.getString(glyphRes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ public class CreatePaymentViewModel extends ViewModel {
|
|||||||
if (!oldAmount.isEmpty()) {
|
if (!oldAmount.isEmpty()) {
|
||||||
String newAmount = oldAmount.substring(0, oldAmount.length() - 1);
|
String newAmount = oldAmount.substring(0, oldAmount.length() - 1);
|
||||||
if (newAmount.isEmpty()) {
|
if (newAmount.isEmpty()) {
|
||||||
return context.getString(AmountKeyboardGlyph.ZERO.getGlyphRes());
|
return AmountKeyboardGlyph.ZERO.getGlyph(context);
|
||||||
} else {
|
} else {
|
||||||
return newAmount;
|
return newAmount;
|
||||||
}
|
}
|
||||||
@@ -239,12 +239,12 @@ public class CreatePaymentViewModel extends ViewModel {
|
|||||||
return oldAmount;
|
return oldAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean oldAmountIsZero = context.getString(AmountKeyboardGlyph.ZERO.getGlyphRes()).equals(oldAmount);
|
boolean oldAmountIsZero = AmountKeyboardGlyph.ZERO.getGlyph(context).equals(oldAmount);
|
||||||
int decimalIndex = oldAmount.indexOf(context.getString(AmountKeyboardGlyph.DECIMAL.getGlyphRes()));
|
int decimalIndex = oldAmount.indexOf(AmountKeyboardGlyph.DECIMAL.getGlyph(context));
|
||||||
|
|
||||||
if (glyph == AmountKeyboardGlyph.DECIMAL) {
|
if (glyph == AmountKeyboardGlyph.DECIMAL) {
|
||||||
if (oldAmountIsZero) {
|
if (oldAmountIsZero) {
|
||||||
return context.getString(AmountKeyboardGlyph.ZERO.getGlyphRes()) + context.getString(glyph.getGlyphRes());
|
return AmountKeyboardGlyph.ZERO.getGlyph(context) + glyph.getGlyph(context);
|
||||||
} else if (decimalIndex > -1) {
|
} else if (decimalIndex > -1) {
|
||||||
return oldAmount;
|
return oldAmount;
|
||||||
}
|
}
|
||||||
@@ -255,9 +255,9 @@ public class CreatePaymentViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (oldAmountIsZero) {
|
if (oldAmountIsZero) {
|
||||||
return context.getString(glyph.getGlyphRes());
|
return glyph.getGlyph(context);
|
||||||
} else {
|
} else {
|
||||||
return oldAmount + context.getString(glyph.getGlyphRes());
|
return oldAmount + glyph.getGlyph(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user