Skip to content

Commit

Permalink
Feature - add donation modal disclaimer
Browse files Browse the repository at this point in the history
 - #60
  • Loading branch information
vsima authored and kcw-grunt committed Jan 15, 2023
1 parent fc0b991 commit 8dd7d76
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 15 deletions.
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 @@ -103,17 +105,18 @@ 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);
BRDialogView dialog = new BRDialogView();
dialog.setTitle(getString(R.string.donate_dialog_title));
dialog.setMessage(getString(R.string.donate_dialog_message));
dialog.setPosButton(getString(R.string.donate_dialog_positive_text));
dialog.setNegButton(getString(R.string.donate_dialog_negative_text));
dialog.setPosListener(brDialogView -> {
dialog.dismiss();
sendDonation();
});
dialog.setNegListener(brDialogView -> dialog.dismiss());
dialog.show(((Activity) getActivity()).getFragmentManager(), dialog.getClass().getName());

Bundle params = new Bundle();
params.putString("DONATION_ACCOUNT", chosenAddress.first);
params.putLong("DONATION_AMOUNT", mDonationAmount);
params.putString("ADDRESS_SCHEME", "v2");

AnalyticsManager.logCustomEventWithParams(BRConstants._20200223_DD, params);

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

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

private void sendDonation() {
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");
AnalyticsManager.logCustomEventWithParams(BRConstants._20200223_DD, params);
BRSender.getInstance().sendTransaction(getContext(), request);
}

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

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
19 changes: 18 additions & 1 deletion app/src/main/res/layout/fragment_dynamic_donation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
app:buttonType="2"
android:fontFamily="@font/barlowsemicondensed_regular"
app:isBreadButton="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/donateBut"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="spread"
Expand All @@ -209,6 +208,24 @@
app:layout_constraintStart_toEndOf="@+id/cancelBut"
app:layout_constraintTop_toTopOf="@+id/cancelBut" />


<TextView
android:id="@+id/donate_disclaimer"
style="@style/BRTextStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:lineHeight="12sp"
android:text="@string/donation_disclaimer"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/donateBut"
app:layout_constraintStart_toStartOf="@+id/cancelBut"
app:layout_constraintTop_toBottomOf="@+id/cancelBut" />

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -802,4 +802,5 @@
<string name="Login.currentLtcPrice">Current LTC value in %1$s</string>
<string name="Settings.languages">Languages</string>
<string name="JailbreakWarnings.close">Close</string>
<string name="donation_disclaimer">**We appreciate your donation to the Litecoin Foundation. Donations are final and can not be refunded. Thanks for your continuing support.</string>
</resources>

0 comments on commit 8dd7d76

Please sign in to comment.