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));
|
showError(getString(R.string.insufficient_balance));
|
||||||
return;
|
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();
|
Claim channel = (Claim) channelSpinner.getSelectedItem();
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
|
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
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 com.google.android.material.textfield.TextInputEditText;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
import io.lbry.browser.MainActivity;
|
import io.lbry.browser.MainActivity;
|
||||||
import io.lbry.browser.R;
|
import io.lbry.browser.R;
|
||||||
|
@ -113,6 +111,10 @@ public class SendTipDialogFragment extends BottomSheetDialogFragment implements
|
||||||
showError(getString(R.string.insufficient_balance));
|
showError(getString(R.string.insufficient_balance));
|
||||||
return;
|
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() {
|
SupportCreateTask task = new SupportCreateTask(claim.getClaimId(), amount, true, sendProgress, new GenericTaskHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -140,7 +140,6 @@ public class ChannelFormFragment extends BaseFragment implements
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
FlexboxLayoutManager flm1 = new FlexboxLayoutManager(context);
|
FlexboxLayoutManager flm1 = new FlexboxLayoutManager(context);
|
||||||
FlexboxLayoutManager flm2 = new FlexboxLayoutManager(context);
|
FlexboxLayoutManager flm2 = new FlexboxLayoutManager(context);
|
||||||
FlexboxLayoutManager flm3 = new FlexboxLayoutManager(context);
|
|
||||||
addedTagsList = root.findViewById(R.id.form_added_tags);
|
addedTagsList = root.findViewById(R.id.form_added_tags);
|
||||||
addedTagsList.setLayoutManager(flm1);
|
addedTagsList.setLayoutManager(flm1);
|
||||||
suggestedTagsList = root.findViewById(R.id.form_suggested_tags);
|
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));
|
showError(getString(R.string.please_enter_valid_deposit));
|
||||||
return;
|
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));
|
String error = getResources().getQuantityString(R.plurals.min_deposit_required, depositAmount == 1 ? 1 : 2, String.valueOf(Helper.MIN_DEPOSIT));
|
||||||
showError(error);
|
showError(error);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -407,6 +407,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
||||||
|
|
||||||
private void sendCredits() {
|
private void sendCredits() {
|
||||||
// wallet_send task
|
// wallet_send task
|
||||||
|
View view = getView();
|
||||||
String recipientAddress = Helper.getValue(inputSendAddress.getText());
|
String recipientAddress = Helper.getValue(inputSendAddress.getText());
|
||||||
String amountString = Helper.getValue(inputSendAmount.getText());
|
String amountString = Helper.getValue(inputSendAmount.getText());
|
||||||
String amount = null;
|
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)).
|
amount = new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).
|
||||||
format(new BigDecimal(amountString).doubleValue());
|
format(new BigDecimal(amountString).doubleValue());
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
Snackbar.make(getView(), R.string.invalid_amount, Snackbar.LENGTH_LONG).
|
if (view != null) {
|
||||||
|
Snackbar.make(view, R.string.invalid_amount, Snackbar.LENGTH_LONG).
|
||||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
disableSendControls();
|
disableSendControls();
|
||||||
double actualSendAmount = Double.valueOf(amount);
|
|
||||||
WalletSendTask task = new WalletSendTask(recipientAddress, amount, walletSendProgress, new WalletSendTask.WalletSendHandler() {
|
WalletSendTask task = new WalletSendTask(recipientAddress, amount, walletSendProgress, new WalletSendTask.WalletSendHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
@ -428,16 +440,20 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W
|
||||||
String message = getResources().getQuantityString(
|
String message = getResources().getQuantityString(
|
||||||
R.plurals.you_sent_credits, sentAmount == 1.0 ? 1 : 2,
|
R.plurals.you_sent_credits, sentAmount == 1.0 ? 1 : 2,
|
||||||
new DecimalFormat("#,###.##").format(sentAmount));
|
new DecimalFormat("#,###.##").format(sentAmount));
|
||||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).show();
|
Helper.setViewText(inputSendAddress, null);
|
||||||
inputSendAddress.setText(null);
|
Helper.setViewText(inputSendAmount, null);
|
||||||
inputSendAmount.setText(null);
|
if (view != null) {
|
||||||
|
Snackbar.make(view, message, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
enableSendControls();
|
enableSendControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Exception error) {
|
public void onError(Exception error) {
|
||||||
Snackbar.make(getView(), R.string.send_credit_error, Snackbar.LENGTH_LONG).
|
if (view != null) {
|
||||||
|
Snackbar.make(view, R.string.send_credit_error, Snackbar.LENGTH_LONG).
|
||||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
|
}
|
||||||
enableSendControls();
|
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 MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
|
||||||
public static final int CONTENT_PAGE_SIZE = 25;
|
public static final int CONTENT_PAGE_SIZE = 25;
|
||||||
public static final double MIN_DEPOSIT = 0.001;
|
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 PLAIN_CURRENCY_FORMAT_PATTERN = "####.##";
|
||||||
public static final String LBC_CURRENCY_FORMAT_PATTERN = "#,###.##";
|
public static final String LBC_CURRENCY_FORMAT_PATTERN = "#,###.##";
|
||||||
public static final String FILE_SIZE_FORMAT_PATTERN = "#,###.#";
|
public static final String FILE_SIZE_FORMAT_PATTERN = "#,###.#";
|
||||||
|
|
|
@ -329,6 +329,7 @@
|
||||||
<string name="unlock">Unlock</string>
|
<string name="unlock">Unlock</string>
|
||||||
<string name="unlock_tips">Unlock tips?</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="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">
|
<plurals name="you_sent_credits">
|
||||||
<item quantity="one">You sent %1$s credit</item>
|
<item quantity="one">You sent %1$s credit</item>
|
||||||
|
|
Loading…
Reference in a new issue