Skip to content

Commit

Permalink
Feature - donation disclaimer modal (#75)
Browse files Browse the repository at this point in the history
* Feature - add donation modal disclaimer
 - #60

* Add missing strings

* Upgraded AS

- Reduced donation amount
- Renamed id WIP

* updated stirings key format

- updated the donation  address

* code bump

Co-authored-by: kcw-grunt <[email protected]>
  • Loading branch information
vsima and kcw-grunt committed Jan 30, 2023
1 parent 20644d0 commit 2b66e3a
Show file tree
Hide file tree
Showing 23 changed files with 207 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class AboutActivity extends BRActivity {
private TextView policyText;
private TextView infoText;

private ImageView redditShare;
private ImageView instagramShare;
private ImageView twitterShare;
private ImageView blogShare;
private static AboutActivity app;
Expand Down Expand Up @@ -57,14 +57,14 @@ protected void onCreate(Bundle savedInstanceState) {
String verName = pInfo != null ? pInfo.versionName : " ";
infoText.setText(getString(R.string.About_footer, verName));

redditShare = (ImageView) findViewById(R.id.reddit_share_button);
instagramShare = (ImageView) findViewById(R.id.instagram_share_button);
twitterShare = (ImageView) findViewById(R.id.twitter_share_button);
blogShare = (ImageView) findViewById(R.id.blog_share_button);

redditShare.setOnClickListener(new View.OnClickListener() {
instagramShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(BRConstants.REDDIT_LINK));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(BRConstants.INSTAGRAM_LINK));
startActivity(browserIntent);
app.overridePendingTransition(R.anim.enter_from_bottom, R.anim.empty_300);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.breadwallet.presenter.fragments;

import android.app.Activity;
import android.os.Bundle;
import android.util.Pair;
import android.view.LayoutInflater;
Expand All @@ -17,6 +18,7 @@
import androidx.fragment.app.Fragment;

import com.breadwallet.R;
import com.breadwallet.presenter.customviews.BRDialogView;
import com.breadwallet.presenter.entities.PaymentItem;
import com.breadwallet.tools.manager.AnalyticsManager;
import com.breadwallet.tools.manager.BRSharedPrefs;
Expand Down Expand Up @@ -46,12 +48,14 @@ public class DynamicDonationFragment extends Fragment {
private TextView feeVal;
private TextView totalVal;

private TextView donationToTheLitewalletTeam;

private TextView amountSliderVal;

private SeekBar seekBar;
private String selectedIso;
private boolean isLTCSwap = true;
private Pair<String, String> chosenAddress;
private String chosenAddress = BRConstants.DONATION_ADDRESS;
private long mDonationAmount;


Expand All @@ -67,26 +71,10 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
isLTCSwap = BRSharedPrefs.getPreferredLTC(getContext());

addressVal = view.findViewById(R.id.addressVal);
addressVal.setText(chosenAddress);

chosenAddress = BRConstants.DONATION_ADDRESSES[0];
addressVal.setText(chosenAddress.second);

Spinner spinner = view.findViewById(R.id.spinnerAddresses);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
chosenAddress = BRConstants.DONATION_ADDRESSES[position];
addressVal.setText(chosenAddress.second);
}

@Override
public void onNothingSelected(AdapterView<?> parent) {
//NO-OP
}
});
ArrayAdapter adapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, addresses());
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
donationToTheLitewalletTeam = view.findViewById(R.id.donationAddressesPhrase);
donationToTheLitewalletTeam.setText(getString(R.string.Donate_toThe_LWTeam));

TextView processingTimeLbl = view.findViewById(R.id.processingTimeLbl);
processingTimeLbl.setText(getString(R.string.Confirmation_processingAndDonationTime, "2.5-5"));
Expand All @@ -103,17 +91,19 @@ public void onNothingSelected(AdapterView<?> parent) {

Button donateBut = view.findViewById(R.id.donateBut);
donateBut.setOnClickListener(v -> {
String memo = getString(R.string.Donate_toThe) + chosenAddress.first;
PaymentItem request = new PaymentItem(new String[]{chosenAddress.second}, null, mDonationAmount, null, false, memo);

Bundle params = new Bundle();
params.putString("DONATION_ACCOUNT", chosenAddress.first);
params.putLong("DONATION_AMOUNT", mDonationAmount);
params.putString("ADDRESS_SCHEME", "v2");
BRDialogView dialog = new BRDialogView();
dialog.setTitle(getString(R.string.Donate_Dialog_title));

dialog.setMessage(getString(R.string.Donate_Dialog_message));
dialog.setNegButton(getString(R.string.Donate_Dialog_Negative_text));
dialog.setPosButton(getString(R.string.Donate_Dialog_Positive_text));
dialog.setPosListener(brDialogView -> {
dialog.dismiss();
sendDonation();
});
dialog.setNegListener(brDialogView -> dialog.dismiss());
dialog.show(((Activity) getActivity()).getFragmentManager(), dialog.getClass().getName());

AnalyticsManager.logCustomEventWithParams(BRConstants._20200223_DD, params);

BRSender.getInstance().sendTransaction(getContext(), request);
});

amountSliderVal = view.findViewById(R.id.amountSliderVal);
Expand Down Expand Up @@ -161,6 +151,17 @@ public void onStopTrackingTouch(SeekBar seekBar) {
updateDonationValues(BRConstants.DONATION_AMOUNT);
}

private void sendDonation() {
String memo = getString(R.string.Donate_toThe_LWTeam) + chosenAddress;
PaymentItem request = new PaymentItem(new String[]{chosenAddress}, null, mDonationAmount, null, false, memo);
Bundle params = new Bundle();
params.putString("DONATION_ACCOUNT", chosenAddress);
params.putLong("DONATION_AMOUNT", mDonationAmount);
params.putString("ADDRESS_SCHEME", "v2");
AnalyticsManager.logCustomEventWithParams(BRConstants._20200223_DD, params);
BRSender.getInstance().sendTransaction(getContext(), request);
}

private void setFeeToRegular() {
FeeManager feeManager = FeeManager.getInstance();

Expand All @@ -183,14 +184,6 @@ private long newAmount(int progress) {
return adjustedAmount + BRConstants.DONATION_AMOUNT;
}

private String[] addresses() {
String[] addresses = new String[BRConstants.DONATION_ADDRESSES.length];
for (int i = 0; i < BRConstants.DONATION_ADDRESSES.length; i++) {
addresses[i] = getString(R.string.Donate_toThe) + BRConstants.DONATION_ADDRESSES[i].first;
}
return addresses;
}

private void updateDonationValues(long donationAmount) {
mDonationAmount = donationAmount;
final BigDecimal donation = new BigDecimal(donationAmount);
Expand Down
14 changes: 6 additions & 8 deletions app/src/main/java/com/breadwallet/tools/util/BRConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,19 @@ public class BRConstants {
/**
* Donation
*/
public static final Pair[] DONATION_ADDRESSES = new Pair[]
{
Pair.create("Litewallet Hardware Fundraiser", "MJ4W7NZya4SzE7R6xpEVdamGCimaQYPiWu"),
Pair.create("Litecoin Foundation", "MVZj7gBRwcVpa9AAWdJm8A3HqTst112eJe")
};
public static final long DONATION_AMOUNT = 1_800_000;
public static final String DONATION_ADDRESS = "MJ4W7NZya4SzE7R6xpEVdamGCimaQYPiWu";
public static final long DONATION_AMOUNT = 1_400_000;

/**
* Support Center article ids.
*/
public static final String loopBug = "android-loop-bug";

public static final String TWITTER_LINK = "https://twitter.com/Litewallet_App";
public static final String REDDIT_LINK = "https://www.reddit.com/r/Litewallet";
public static final String WEB_LINK = "https://litewalle.io";

public static final String INSTAGRAM_LINK = "https://www.instagram.com/litewallet.app";

public static final String WEB_LINK = "https://litewallet.io";
public static final String TOS_LINK = "https://litewallet.io/privacy/policy.html";
public static String CUSTOMER_SUPPORT_LINK = "https://support.litewallet.io";
public static String BITREFILL_AFFILIATE_LINK = "https://www.bitrefill.com/";
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:text="@string/About.reddit"
android:text="@string/About.instagram"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/divider1"
app:layout_constraintLeft_toLeftOf="@+id/divider1" />

<ImageView
android:id="@+id/reddit_share_button"
android:id="@+id/instagram_share_button"
android:layout_width="16dp"
android:layout_height="16dp"
app:layout_constraintBottom_toBottomOf="@+id/textView21"
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/res/layout/bread_alert_dialog.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -22,7 +23,8 @@
android:textSize="22sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:text="Title"/>


<TextView
Expand All @@ -37,7 +39,8 @@
android:textSize="18sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dialog_title" />
app:layout_constraintTop_toBottomOf="@+id/dialog_title"
tools:text="Message"/>


<LinearLayout
Expand Down Expand Up @@ -66,7 +69,8 @@
android:layout_marginStart="16dp"
android:layout_weight="1.0"
android:background="@android:color/transparent"
android:textColor="@color/dark_blue" />
android:textColor="@color/dark_blue"
tools:text="Positive"/>

<com.breadwallet.presenter.customviews.BRButton
style="@style/BRButtonStyle"
Expand All @@ -77,7 +81,8 @@
android:layout_marginStart="16dp"
android:layout_weight="1.0"
android:background="@android:color/transparent"
android:textColor="@color/dark_blue" />
android:textColor="@color/dark_blue"
tools:text="Negative"/>

</LinearLayout>

Expand Down
Loading

0 comments on commit 2b66e3a

Please sign in to comment.