enforce minimum spend / deposits
This commit is contained in:
parent
b36813ebe6
commit
4a3db5ae20
6 changed files with 36 additions and 12 deletions
|
@ -231,6 +231,11 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
|
|||
showError(getString(R.string.insufficient_balance));
|
||||
return;
|
||||
}
|
||||
if (bid.doubleValue() < Helper.MIN_DEPOSIT) {
|
||||
String message = getResources().getQuantityString(R.plurals.min_deposit_required, 2, String.valueOf(Helper.MIN_DEPOSIT));
|
||||
showError(message);
|
||||
return;
|
||||
}
|
||||
|
||||
Claim channel = (Claim) channelSpinner.getSelectedItem();
|
||||
if (channel == null) {
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.text.HtmlCompat;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
@ -21,7 +20,6 @@ import com.google.android.material.snackbar.Snackbar;
|
|||
import com.google.android.material.textfield.TextInputEditText;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import io.lbry.browser.MainActivity;
|
||||
import io.lbry.browser.R;
|
||||
|
@ -113,6 +111,10 @@ public class SendTipDialogFragment extends BottomSheetDialogFragment implements
|
|||
showError(getString(R.string.insufficient_balance));
|
||||
return;
|
||||
}
|
||||
if (amount.doubleValue() < Helper.MIN_SPEND) {
|
||||
showError(getString(R.string.min_spend_required));
|
||||
return;
|
||||
}
|
||||
|
||||
SupportCreateTask task = new SupportCreateTask(claim.getClaimId(), amount, true, sendProgress, new GenericTaskHandler() {
|
||||
@Override
|
||||
|
|
|
@ -140,7 +140,6 @@ public class ChannelFormFragment extends BaseFragment implements
|
|||
Context context = getContext();
|
||||
FlexboxLayoutManager flm1 = new FlexboxLayoutManager(context);
|
||||
FlexboxLayoutManager flm2 = new FlexboxLayoutManager(context);
|
||||
FlexboxLayoutManager flm3 = new FlexboxLayoutManager(context);
|
||||
addedTagsList = root.findViewById(R.id.form_added_tags);
|
||||
addedTagsList.setLayoutManager(flm1);
|
||||
suggestedTagsList = root.findViewById(R.id.form_suggested_tags);
|
||||
|
@ -326,7 +325,7 @@ public class ChannelFormFragment extends BaseFragment implements
|
|||
showError(getString(R.string.please_enter_valid_deposit));
|
||||
return;
|
||||
}
|
||||
if (depositAmount == 0) {
|
||||
if (depositAmount < Helper.MIN_DEPOSIT) {
|
||||
String error = getResources().getQuantityString(R.plurals.min_deposit_required, depositAmount == 1 ? 1 : 2, String.valueOf(Helper.MIN_DEPOSIT));
|
||||
showError(error);
|
||||
return;
|
||||
|
|
|
@ -407,6 +407,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
|||
|
||||
private void sendCredits() {
|
||||
// wallet_send task
|
||||
View view = getView();
|
||||
String recipientAddress = Helper.getValue(inputSendAddress.getText());
|
||||
String amountString = Helper.getValue(inputSendAmount.getText());
|
||||
String amount = null;
|
||||
|
@ -414,13 +415,24 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
|||
amount = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).
|
||||
format(new BigDecimal(amountString).doubleValue());
|
||||
} catch (NumberFormatException ex) {
|
||||
Snackbar.make(getView(), R.string.invalid_amount, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
if (view != null) {
|
||||
Snackbar.make(view, R.string.invalid_amount, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
double actualSendAmount = Double.valueOf(amount);
|
||||
if (actualSendAmount < Helper.MIN_SPEND) {
|
||||
if (view != null) {
|
||||
Snackbar.make(view, R.string.min_spend_required, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
disableSendControls();
|
||||
double actualSendAmount = Double.valueOf(amount);
|
||||
WalletSendTask task = new WalletSendTask(recipientAddress, amount, walletSendProgress, new WalletSendTask.WalletSendHandler() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
@ -428,16 +440,20 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
|||
String message = getResources().getQuantityString(
|
||||
R.plurals.you_sent_credits, sentAmount == 1.0 ? 1 : 2,
|
||||
new DecimalFormat("#,###.##").format(sentAmount));
|
||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).show();
|
||||
inputSendAddress.setText(null);
|
||||
inputSendAmount.setText(null);
|
||||
Helper.setViewText(inputSendAddress, null);
|
||||
Helper.setViewText(inputSendAmount, null);
|
||||
if (view != null) {
|
||||
Snackbar.make(view, message, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
enableSendControls();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
Snackbar.make(getView(), R.string.send_credit_error, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
if (view != null) {
|
||||
Snackbar.make(view, R.string.send_credit_error, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
enableSendControls();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -70,6 +70,7 @@ public final class Helper {
|
|||
public static final MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
|
||||
public static final int CONTENT_PAGE_SIZE = 25;
|
||||
public static final double MIN_DEPOSIT = 0.001;
|
||||
public static final double MIN_SPEND = 0.0001;
|
||||
public static final String PLAIN_CURRENCY_FORMAT_PATTERN = "####.##";
|
||||
public static final String LBC_CURRENCY_FORMAT_PATTERN = "#,###.##";
|
||||
public static final String FILE_SIZE_FORMAT_PATTERN = "#,###.#";
|
||||
|
|
|
@ -329,6 +329,7 @@
|
|||
<string name="unlock">Unlock</string>
|
||||
<string name="unlock_tips">Unlock tips?</string>
|
||||
<string name="confirm_unlock_tips">Are you sure you want to unlock all your tips?</string>
|
||||
<string name="min_spend_required">Please enter an amount more than 0.0001 credits.</string>
|
||||
|
||||
<plurals name="you_sent_credits">
|
||||
<item quantity="one">You sent %1$s credit</item>
|
||||
|
|
Loading…
Reference in a new issue