Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB on ramp flow #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ android {

buildConfigField "long", "BUILD_TIMESTAMP", getLastCommitTimestamp() + "L"
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
buildConfigField "String", "MOBILECOIN_BUY_URL", "\"https://buy.mobilecoin.com/signal\""
buildConfigField "String", "SIGNAL_URL", "\"https://chat.signal.org\""
buildConfigField "String", "STORAGE_URL", "\"https://storage.signal.org\""
buildConfigField "String", "SIGNAL_CDN_URL", "\"https://cdn.signal.org\""
Expand Down Expand Up @@ -334,6 +335,7 @@ android {

applicationIdSuffix ".staging"

buildConfigField "String", "MOBILECOIN_BUY_URL", "\"https://staging.buy.mobilecoin.com/signal\""
buildConfigField "String", "SIGNAL_URL", "\"https://chat.staging.signal.org\""
buildConfigField "String", "STORAGE_URL", "\"https://storage-staging.signal.org\""
buildConfigField "String", "SIGNAL_CDN_URL", "\"https://cdn-staging.signal.org\""
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,18 @@

<activity android:name=".payments.preferences.PaymentsActivity"
android:theme="@style/TextSecure.LightRegistrationTheme"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:scheme="sgnl"
android:host="mobilecoinbuy" />
</intent-filter>
</activity>

<activity android:name=".lock.v2.CreateKbsPinActivity"
android:theme="@style/TextSecure.LightRegistrationTheme"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
refreshAnimation.setVisibility(View.GONE);
break;
case LOADING:
exchange.setText(R.string.PaymentsHomeFragment__loading_balance);
refresh.setVisibility(View.INVISIBLE);
refreshAnimation.playAnimation();
refreshAnimation.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
import androidx.lifecycle.ViewModelProviders;
import androidx.navigation.Navigation;

import com.google.android.material.button.MaterialButton;

import org.thoughtcrime.securesms.LoggingFragment;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.qr.QrView;
import org.thoughtcrime.securesms.util.CommunicationActions;
import org.thoughtcrime.securesms.util.views.LearnMoreTextView;

public final class PaymentsAddMoneyFragment extends LoggingFragment {
Expand All @@ -35,12 +38,16 @@ public PaymentsAddMoneyFragment() {
TextView walletAddressAbbreviated = view.findViewById(R.id.payments_add_money_abbreviated_wallet_address);
View copyAddress = view.findViewById(R.id.payments_add_money_copy_address_button);
LearnMoreTextView info = view.findViewById(R.id.payments_add_money_info);
TextView terms = view.findViewById(R.id.view_terms);
MaterialButton buyMob = view.findViewById(R.id.buy_mob);

info.setLinkColor(getResources().getColor(R.color.signal_text_primary));
info.setLearnMoreVisible(true);
info.setLink(getString(R.string.PaymentsAddMoneyFragment__learn_more__information));

toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());

terms.setOnClickListener(view1 -> openBrowserLink(getString(R.string.PaymentsAddMoneyFragment__view_terms_url)));
buyMob.setOnClickListener(view12 -> openBrowserLink(viewModel.getBuyMobUri()));
viewModel.getSelfAddressAbbreviated().observe(getViewLifecycleOwner(), walletAddressAbbreviated::setText);

viewModel.getSelfAddressB58().observe(getViewLifecycleOwner(), base58 -> copyAddress.setOnClickListener(v -> copyAddressToClipboard(base58)));
Expand All @@ -56,6 +63,10 @@ public PaymentsAddMoneyFragment() {
});
}

private void openBrowserLink(String url) {
CommunicationActions.openBrowserLink(requireContext(), url);
}

private void copyAddressToClipboard(@NonNull String base58) {
Context context = requireContext();
ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.util.AsynchronousCallback;
import org.signal.core.util.StringUtil;

final class PaymentsAddMoneyViewModel extends ViewModel {
private static final String REDIRECT_URL = "sgnl://mobilecoinbuy";

private final MutableLiveData<AddressAndUri> selfAddressAndUri = new MutableLiveData<>();
private final MutableLiveData<PaymentsAddMoneyRepository.Error> errors = new MutableLiveData<>();
Expand Down Expand Up @@ -55,6 +57,17 @@ LiveData<Uri> getSelfAddressUriForQr() {
return selfAddressUri;
}

String getBuyMobUri() {
return Uri.parse(BuildConfig.MOBILECOIN_BUY_URL)
.buildUpon()
.appendQueryParameter("walletAddress", selfAddressB58.getValue())
.appendQueryParameter("redirectURL", REDIRECT_URL)
.appendQueryParameter("language", SignalStore.settings().getLanguage())
.appendQueryParameter("currencyCode", SignalStore.paymentsValues().currentCurrency().getCurrencyCode())
.build().toString();
}


public static final class Factory implements ViewModelProvider.Factory {
@Override
public @NonNull <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,5 @@ private CharSequence describeSentBy(PaymentsDetailsViewModel.ViewState state) {
}

private @NonNull CharSequence getStatusFromPayment(@NonNull Payment payment) {
return getResources().getString(R.string.PaymentsDeatilsFragment__payment_completed_s, DateUtils.getTimeString(requireContext(), Locale.getDefault(), payment.getDisplayTimestamp()));
}
return getResources().getString(R.string.PaymentsDetailsFragment__payment_completed_s, DateUtils.getTimeString(requireContext(), Locale.getDefault(), payment.getDisplayTimestamp())); }
}
32 changes: 30 additions & 2 deletions app/src/main/res/layout/payments_add_money_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
android:id="@+id/payments_add_money_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="64dp"
android:layout_marginStart="24dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="64dp"
android:lineSpacingExtra="6sp"
android:text="@string/PaymentsAddMoneyFragment__to_add_funds"
android:text="@string/PaymentsAddMoneyFragment__buy_mob_from_partner"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.Signal.Body2"
android:textColor="@color/signal_text_secondary"
Expand All @@ -88,5 +88,33 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/payments_add_money_qr_border" />

<com.google.android.material.button.MaterialButton
android:id="@+id/buy_mob"
style="@style/Signal.Widget.Button.Large.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="38dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="38dp"
android:layout_marginBottom="24dp"
android:text="@string/PaymentsAddMoneyFragment__buy_mob"
app:cornerRadius="6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/payments_add_money_info" />

<TextView
android:id="@+id/view_terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/PaymentsAddMoneyFragment__view_terms"
android:textAppearance="@style/TextAppearance.Signal.Body2"
android:textColor="@color/signal_button_secondary_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/buy_mob" />

</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
4 changes: 2 additions & 2 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2645,7 +2645,7 @@
<string name="PaymentsAddMoneyFragment__your_wallet_address">عنوان محفظتك</string>
<string name="PaymentsAddMoneyFragment__copy">نسخ</string>
<string name="PaymentsAddMoneyFragment__copied_to_clipboard">تم النسخ إلى الحافظة</string>
<string name="PaymentsAddMoneyFragment__to_add_funds">لإضافة مبالغ، يٌرجى إرسال MobileCoin إلى عنوان محفظتك. يجب البدء بالمعاملة انطلاقا من حسابك في منصة تداول تدعم MobileCoin، بعدها يجب مسح الرمز المربع أو نسخ عنوان محفظتك.</string>
<string name="PaymentsAddMoneyFragment__buy_mob_from_partner">لإضافة مبالغ، يٌرجى إرسال MobileCoin إلى عنوان محفظتك. يجب البدء بالمعاملة انطلاقا من حسابك في منصة تداول تدعم MobileCoin، بعدها يجب مسح الرمز المربع أو نسخ عنوان محفظتك.</string>
<!--PaymentsDetailsFragment-->
<string name="PaymentsDetailsFragment__details">التفاصيل</string>
<string name="PaymentsDetailsFragment__status">الحالة</string>
Expand All @@ -2666,7 +2666,7 @@
<string name="PaymentsDetailsFragment__no_details_available">لا وجود لأي تفاصيل أخرى متاحة حول هذه المعاملة</string>
<string name="PaymentsDetailsFragment__sent_payment">المبلغ المُرسَل</string>
<string name="PaymentsDetailsFragment__received_payment">المبلغ المُستلَم</string>
<string name="PaymentsDeatilsFragment__payment_completed_s">تمَّ الدفع %1$s</string>
<string name="PaymentsDetailsFragment__payment_completed_s">تمَّ الدفع %1$s</string>
<string name="PaymentsDetailsFragment__block_number">حظر الرقم</string>
<!--PaymentsTransferFragment-->
<string name="PaymentsTransferFragment__transfer">إرسال</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2316,7 +2316,7 @@
<string name="PaymentsAddMoneyFragment__your_wallet_address">Pulqabı ünvanınız</string>
<string name="PaymentsAddMoneyFragment__copy">Kopyala</string>
<string name="PaymentsAddMoneyFragment__copied_to_clipboard">Lövhəyə kopyalandı</string>
<string name="PaymentsAddMoneyFragment__to_add_funds">Pul əlavə etmək üçün pulqabı ünvanınıza MobileCoin göndərin. MobileCoin dəstəkləyən bir birjada hesabınızdan bir əməliyyat başladın, daha sonra QR kodu skan edin və ya pulqabı ünvanınızı kopyalayın.</string>
<string name="PaymentsAddMoneyFragment__buy_mob_from_partner">Pul əlavə etmək üçün pulqabı ünvanınıza MobileCoin göndərin. MobileCoin dəstəkləyən bir birjada hesabınızdan bir əməliyyat başladın, daha sonra QR kodu skan edin və ya pulqabı ünvanınızı kopyalayın.</string>
<!--PaymentsDetailsFragment-->
<string name="PaymentsDetailsFragment__details">Təfsilatlar</string>
<string name="PaymentsDetailsFragment__status">Status</string>
Expand All @@ -2337,7 +2337,7 @@
<string name="PaymentsDetailsFragment__no_details_available">Bu əməliyyatla bağlı əlavə məlumat yoxdur</string>
<string name="PaymentsDetailsFragment__sent_payment">Ödəniş göndərildi</string>
<string name="PaymentsDetailsFragment__received_payment">Ödəniş alındı</string>
<string name="PaymentsDeatilsFragment__payment_completed_s">Ödəniş tamamlandı %1$s</string>
<string name="PaymentsDetailsFragment__payment_completed_s">Ödəniş tamamlandı %1$s</string>
<string name="PaymentsDetailsFragment__block_number">Blok nömrəsi</string>
<!--PaymentsTransferFragment-->
<string name="PaymentsTransferFragment__transfer">Köçürmə</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-bn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@
<string name="PaymentsAddMoneyFragment__your_wallet_address">আপনার ওয়ালেট ঠিকানা</string>
<string name="PaymentsAddMoneyFragment__copy">অনুলিপি</string>
<string name="PaymentsAddMoneyFragment__copied_to_clipboard">ক্লিপবোর্ডে অনুলিপি করা হয়েছে</string>
<string name="PaymentsAddMoneyFragment__to_add_funds">ফান্ড যোগ করতে আপনার ওয়ালেটের ঠিকানায় MobileCoin পাঠান। আপনার অ্যাকাউন্ট থেকে এমন কোনও লেনদেন শুরু করুন যা MobileCoin-কে সাপোর্ট করে, তারপরে QR কোডটি স্ক্যান করুন বা আপনার ওয়ালেটের ঠিকানাটি কপি করুন।</string>
<string name="PaymentsAddMoneyFragment__buy_mob_from_partner">ফান্ড যোগ করতে আপনার ওয়ালেটের ঠিকানায় MobileCoin পাঠান। আপনার অ্যাকাউন্ট থেকে এমন কোনও লেনদেন শুরু করুন যা MobileCoin-কে সাপোর্ট করে, তারপরে QR কোডটি স্ক্যান করুন বা আপনার ওয়ালেটের ঠিকানাটি কপি করুন।</string>
<!--PaymentsDetailsFragment-->
<string name="PaymentsDetailsFragment__details">খুঁটিনাটি</string>
<string name="PaymentsDetailsFragment__status">অবস্থা</string>
Expand All @@ -2262,7 +2262,7 @@
<string name="PaymentsDetailsFragment__no_details_available">এই লেনদেনের জন্য আর কোন বিস্তারিত বিবরণ নেই</string>
<string name="PaymentsDetailsFragment__sent_payment">পেমেন্ট পাঠানো হয়েছে</string>
<string name="PaymentsDetailsFragment__received_payment">পেমেন্ট পেয়েছে</string>
<string name="PaymentsDeatilsFragment__payment_completed_s">%1$s পেমেন্ট সম্পন্ন হয়েছে</string>
<string name="PaymentsDetailsFragment__payment_completed_s">%1$s পেমেন্ট সম্পন্ন হয়েছে</string>
<string name="PaymentsDetailsFragment__block_number">নাম্বার ব্লক করুন</string>
<!--PaymentsTransferFragment-->
<string name="PaymentsTransferFragment__transfer">ট্রান্সফার করুন</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-bs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@
<string name="PaymentsAddMoneyFragment__your_wallet_address">Adresa Vašeg novčanika</string>
<string name="PaymentsAddMoneyFragment__copy">Kopiraj</string>
<string name="PaymentsAddMoneyFragment__copied_to_clipboard">Kopirano u međuspremnik</string>
<string name="PaymentsAddMoneyFragment__to_add_funds">Da dodate sredstva, pošaljite MobileCoin na adresu svoga novčanika. Započnite transakciju sa svoga računa na berzi koja podržava MobileCoin, potom skenirajte QR kōd ili kopirajte adresu svoga novčanika.</string>
<string name="PaymentsAddMoneyFragment__buy_mob_from_partner">Da dodate sredstva, pošaljite MobileCoin na adresu svoga novčanika. Započnite transakciju sa svoga računa na berzi koja podržava MobileCoin, potom skenirajte QR kōd ili kopirajte adresu svoga novčanika.</string>
<!--PaymentsDetailsFragment-->
<string name="PaymentsDetailsFragment__details">Detalji</string>
<string name="PaymentsDetailsFragment__status">Status</string>
Expand All @@ -2422,7 +2422,7 @@
<string name="PaymentsDetailsFragment__no_details_available">Nema dodatnih detalja o ovoj transakciji</string>
<string name="PaymentsDetailsFragment__sent_payment">Isplaćeno</string>
<string name="PaymentsDetailsFragment__received_payment">Uplaćeno</string>
<string name="PaymentsDeatilsFragment__payment_completed_s">Plaćanje izvršeno %1$s</string>
<string name="PaymentsDetailsFragment__payment_completed_s">Plaćanje izvršeno %1$s</string>
<string name="PaymentsDetailsFragment__block_number">Broj bloka</string>
<!--PaymentsTransferFragment-->
<string name="PaymentsTransferFragment__transfer">Prenos</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,7 @@ S\'ha rebut un missatge d\'intercanvi de claus per a una versió del protocol no
<string name="PaymentsAddMoneyFragment__your_wallet_address">La vostra adreça de cartera</string>
<string name="PaymentsAddMoneyFragment__copy">Copia</string>
<string name="PaymentsAddMoneyFragment__copied_to_clipboard">Copiat al porta-retalls</string>
<string name="PaymentsAddMoneyFragment__to_add_funds">Per afegir-hi fons, envieu MobileCoin a la vostra adreça de cartera. Inicieu una transacció des del compte amb un intercanvi que admeti MobileCoin i, a continuació, escaneu el codi QR o copieu la vostra adreça de cartera.</string>
<string name="PaymentsAddMoneyFragment__buy_mob_from_partner">Per afegir-hi fons, envieu MobileCoin a la vostra adreça de cartera. Inicieu una transacció des del compte amb un intercanvi que admeti MobileCoin i, a continuació, escaneu el codi QR o copieu la vostra adreça de cartera.</string>
<!--PaymentsDetailsFragment-->
<string name="PaymentsDetailsFragment__details">Detalls</string>
<string name="PaymentsDetailsFragment__status">Estat</string>
Expand All @@ -2331,7 +2331,7 @@ S\'ha rebut un missatge d\'intercanvi de claus per a una versió del protocol no
<string name="PaymentsDetailsFragment__no_details_available">No hi ha més detalls disponibles per a aquesta transacció.</string>
<string name="PaymentsDetailsFragment__sent_payment">Pagament enviat</string>
<string name="PaymentsDetailsFragment__received_payment">Pagament rebut</string>
<string name="PaymentsDeatilsFragment__payment_completed_s">Pagament fet: %1$s</string>
<string name="PaymentsDetailsFragment__payment_completed_s">Pagament fet: %1$s</string>
<string name="PaymentsDetailsFragment__block_number">Número de bloc</string>
<!--PaymentsTransferFragment-->
<string name="PaymentsTransferFragment__transfer">Transferència</string>
Expand Down
Loading