diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 97faf649..b2692466 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -20,8 +20,8 @@ android { applicationId = "ltd.grunt.brainwallet" minSdk = 29 targetSdk = 34 - versionCode = 202503031 - versionName = "v4.3.1" + versionCode = 202503221 + versionName = "v4.4.0" multiDexEnabled = true base.archivesName.set("${defaultConfig.versionName}(${defaultConfig.versionCode})") diff --git a/app/src/main/java/com/brainwallet/presenter/activities/BreadActivity.java b/app/src/main/java/com/brainwallet/presenter/activities/BreadActivity.java index ed2a01c2..a0f6e980 100644 --- a/app/src/main/java/com/brainwallet/presenter/activities/BreadActivity.java +++ b/app/src/main/java/com/brainwallet/presenter/activities/BreadActivity.java @@ -42,6 +42,7 @@ import com.brainwallet.presenter.activities.util.BRActivity; import com.brainwallet.presenter.customviews.BRNotificationBar; import com.brainwallet.presenter.fragments.BuyTabFragment; +import com.brainwallet.presenter.fragments.FragmentMoonpay; import com.brainwallet.presenter.history.HistoryFragment; import com.brainwallet.tools.animation.BRAnimator; import com.brainwallet.tools.animation.TextSizeTransition; @@ -240,6 +241,7 @@ private void setListeners() { public boolean handleNavigationItemSelected(int menuItemId) { if (mSelectedBottomNavItem == menuItemId) return true; mSelectedBottomNavItem = menuItemId; + //TODO: revisit // we are using compose, that's why commented, will remove it after fully migrated to compose if (menuItemId == R.id.nav_history) { @@ -254,8 +256,12 @@ public boolean handleNavigationItemSelected(int menuItemId) { BRAnimator.showReceiveFragment(BreadActivity.this, true); } mSelectedBottomNavItem = 0; - } else if (menuItemId == R.id.nav_buy) { - ExtensionKt.replaceFragment(BreadActivity.this, new BuyTabFragment(), false, R.id.fragment_container); + } + else if (menuItemId == R.id.nav_buy) { + if (BRAnimator.isClickAllowed()) { + BRAnimator.showMoonpayFragment(BreadActivity.this); + } + mSelectedBottomNavItem = 0; } return true; } diff --git a/app/src/main/java/com/brainwallet/presenter/entities/Partner.java b/app/src/main/java/com/brainwallet/presenter/entities/Partner.java deleted file mode 100644 index 984c7778..00000000 --- a/app/src/main/java/com/brainwallet/presenter/entities/Partner.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.brainwallet.presenter.entities; - -import com.brainwallet.presenter.fragments.FragmentBuy; - -public class Partner { - private int logo; - private int title; - private int details; - private FragmentBuy.Partner code; - - public Partner(int logo, int title, int details, FragmentBuy.Partner code) { - this.logo = logo; - this.title = title; - this.details = details; - this.code = code; - } - - public int getLogo() { - return logo; - } - - public void setLogo(int logo) { - this.logo = logo; - } - - public int getTitle() { - return title; - } - - public void setTitle(int title) { - this.title = title; - } - - public int getDetails() { - return details; - } - - public void setDetails(int details) { - this.details = details; - } - - public FragmentBuy.Partner getCode() { - return code; - } -} diff --git a/app/src/main/java/com/brainwallet/presenter/fragments/BuyPartnersAdapter.java b/app/src/main/java/com/brainwallet/presenter/fragments/BuyPartnersAdapter.java deleted file mode 100644 index 32a40f35..00000000 --- a/app/src/main/java/com/brainwallet/presenter/fragments/BuyPartnersAdapter.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.brainwallet.presenter.fragments; - -import android.content.Context; -import android.net.Uri; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.HorizontalScrollView; -import android.widget.ImageView; -import android.widget.RadioGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.StringRes; -import androidx.browser.customtabs.CustomTabColorSchemeParams; -import androidx.browser.customtabs.CustomTabsIntent; -import androidx.fragment.app.FragmentActivity; -import androidx.recyclerview.widget.RecyclerView; - -import com.brainwallet.R; -import com.brainwallet.presenter.entities.Partner; -import com.brainwallet.presenter.fragments.FragmentBuy; -import com.brainwallet.tools.animation.BRAnimator; -import com.brainwallet.tools.util.BRConstants; - -import java.util.List; - -class BuyPartnersAdapter extends RecyclerView.Adapter { - - private final LayoutInflater inflater; - private List partners; - - BuyPartnersAdapter(Context context, @NonNull List partners) { - inflater = LayoutInflater.from(context); - this.partners = partners; - } - - @NonNull - @Override - public PartnerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - return new PartnerViewHolder(inflater.inflate(R.layout.buy_partner_item, parent, false)); - } - - @Override - public void onBindViewHolder(@NonNull final PartnerViewHolder holder, int position) { - final Partner partner = partners.get(position); - holder.logo.setImageResource(partner.getLogo()); - holder.title.setText(partner.getTitle()); - holder.detail.setText(partner.getDetails()); - holder.fiatOptionHScrollView.post(() -> { - int checkId = holder.fiatOptions.getCheckedRadioButtonId(); - View option = holder.fiatOptions.findViewById(checkId); - holder.fiatOptionHScrollView.scrollTo((int) option.getX(), (int) option.getY()); - }); - - if (partner.getCode() == FragmentBuy.Partner.BITREFILL) { - holder.fiatOptionHScrollView.setVisibility(View.INVISIBLE); - holder.fiatOptions.setVisibility(View.INVISIBLE); - } - - holder.buyPartnerWrapper.setOnClickListener(v -> { - int currencyResId = getCurrencyResId(holder.fiatOptions.getCheckedRadioButtonId()); - final Context context = v.getContext(); - String currency = context.getString(currencyResId); - if (partner.getCode() == FragmentBuy.Partner.MOONPAY) { - CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder() - .setDefaultColorSchemeParams(new CustomTabColorSchemeParams.Builder().setToolbarColor(context.getColor(R.color.near_black)).build()) - .setUrlBarHidingEnabled(true); - CustomTabsIntent customTabsIntent = builder.build(); - String buyUrl = FragmentBuy.url(context, partner.getCode(), currency); - customTabsIntent.launchUrl(context, Uri.parse(buyUrl)); - } else { - BRAnimator.showBuyFragment((FragmentActivity) context, currency, partner.getCode()); - } - }); - } - - @StringRes - private int getCurrencyResId(int checkedOption) { - int currency; - if (checkedOption == R.id.cad_fiat) { - currency = R.string.cad_currency_code; - } else if (checkedOption == R.id.eur_fiat) { - currency = R.string.eur_currency_code; - } else if (checkedOption == R.id.jpy_fiat) { - currency = R.string.jpy_currency_code; - } else if (checkedOption == R.id.gbp_fiat) { - currency = R.string.gbp_currency_code; - } else if (checkedOption == R.id.hkd_fiat) { - currency = R.string.hkd_currency_code; - } else if (checkedOption == R.id.idr_fiat) { - currency = R.string.idr_currency_code; - } else if (checkedOption == R.id.rub_fiat) { - currency = R.string.rub_currency_code; - } else if (checkedOption == R.id.sgd_fiat) { - currency = R.string.sgd_currency_code; - } else { - currency = R.string.usd_currency_code; - } - return currency; - } - - @Override - public int getItemCount() { - return partners.size(); - } - - static class PartnerViewHolder extends RecyclerView.ViewHolder { - - final ImageView logo; - final TextView title; - final TextView detail; - final RadioGroup fiatOptions; - final View buyPartnerWrapper; - final HorizontalScrollView fiatOptionHScrollView; - - PartnerViewHolder(@NonNull View itemView) { - super(itemView); - - logo = itemView.findViewById(R.id.logo); - title = itemView.findViewById(R.id.titleLbl); - detail = itemView.findViewById(R.id.detailLbl); - fiatOptions = itemView.findViewById(R.id.fiat_option); - fiatOptionHScrollView = itemView.findViewById(R.id.fiat_option_h_scroll); - buyPartnerWrapper = itemView.findViewById(R.id.buyPartnerWrapper); - } - } -} diff --git a/app/src/main/java/com/brainwallet/presenter/fragments/BuyTabFragment.java b/app/src/main/java/com/brainwallet/presenter/fragments/BuyTabFragment.java index 2ff9abdc..feeabfd3 100644 --- a/app/src/main/java/com/brainwallet/presenter/fragments/BuyTabFragment.java +++ b/app/src/main/java/com/brainwallet/presenter/fragments/BuyTabFragment.java @@ -14,15 +14,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.brainwallet.R; -import com.brainwallet.presenter.entities.Partner; -import com.brainwallet.presenter.fragments.BuyPartnersAdapter; -import com.brainwallet.presenter.fragments.FragmentBuy; import com.brainwallet.tools.manager.AnalyticsManager; import com.brainwallet.tools.util.BRConstants; -import java.util.ArrayList; -import java.util.List; - public class BuyTabFragment extends Fragment { private RecyclerView mRecyclerView; @@ -30,7 +24,7 @@ public class BuyTabFragment extends Fragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - return inflater.inflate(R.layout.fragment_buy_tab, container, false); + return null; } @Override @@ -38,20 +32,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat super.onViewCreated(view, savedInstanceState); mRecyclerView = view.findViewById(R.id.recycler_view); - mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - DividerItemDecoration itemDecor = new DividerItemDecoration(mRecyclerView.getContext(), DividerItemDecoration.VERTICAL); itemDecor.setDrawable(ContextCompat.getDrawable(mRecyclerView.getContext(), R.drawable.divider_white_shape)); mRecyclerView.addItemDecoration(itemDecor); - - mRecyclerView.setAdapter(new com.brainwallet.presenter.fragments.BuyPartnersAdapter(getContext(), getPartners())); AnalyticsManager.logCustomEvent(BRConstants._20191105_DTBT); } - - private List getPartners() { - List partners = new ArrayList<>(); - partners.add(new Partner(R.drawable.ic_moonpay_logo, R.string.BuyCenter_moonpay_Title, R.string.BuyCenter_moonpay_FinancialDetails, FragmentBuy.Partner.MOONPAY)); - return partners; - } } diff --git a/app/src/main/java/com/brainwallet/presenter/fragments/FragmentBuy.java b/app/src/main/java/com/brainwallet/presenter/fragments/FragmentBuy.java deleted file mode 100644 index 730af0a7..00000000 --- a/app/src/main/java/com/brainwallet/presenter/fragments/FragmentBuy.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.brainwallet.presenter.fragments; - -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.ClipData; -import android.content.Context; -import android.content.Intent; -import android.graphics.Bitmap; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.provider.Settings; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.webkit.ValueCallback; -import android.webkit.WebChromeClient; -import android.webkit.WebResourceRequest; -import android.webkit.WebSettings; -import android.webkit.WebView; -import android.webkit.WebViewClient; - -import android.widget.LinearLayout; -import android.widget.ProgressBar; - -import androidx.activity.OnBackPressedCallback; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.Toolbar; -import androidx.fragment.app.Fragment; - -import com.brainwallet.BrainwalletApp; -import com.brainwallet.BuildConfig; -import com.brainwallet.R; -import com.brainwallet.tools.animation.BRAnimator; -import com.brainwallet.tools.manager.BRApiManager; -import com.brainwallet.tools.manager.BRSharedPrefs; -import com.brainwallet.tools.util.BRConstants; -import com.brainwallet.tools.util.Utils; - -import org.koin.core.component.KoinComponentKt; -import org.koin.java.KoinJavaComponent; - -import java.util.Date; - -import timber.log.Timber; - -public class FragmentBuy extends Fragment { - private static final int FILE_CHOOSER_REQUEST_CODE = 15423; - public LinearLayout backgroundLayout; - private ProgressBar progress; - private WebView webView; - private String onCloseUrl; - private static final String CURRENCY_KEY = "currency_code_key"; - private static final String PARTNER_KEY = "partner_key"; - private ValueCallback uploadMessage; - private ValueCallback uploadMessageAboveL; - - public static Fragment newInstance(String currency, Partner partner) { - Bundle bundle = new Bundle(); - bundle.putString(CURRENCY_KEY, currency); - bundle.putSerializable(PARTNER_KEY, partner); - Fragment fragment = new FragmentBuy(); - fragment.setArguments(bundle); - return fragment; - } - - @Override - public void onActivityCreated(@Nullable Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) { - @Override - public void handleOnBackPressed() { - if (webView.canGoBack()) { - webView.goBack(); - } else { - closePayment(); - } - } - }); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_buy, container, false); - Toolbar toolbar = rootView.findViewById(R.id.toolbar); - toolbar.setNavigationOnClickListener(v -> closePayment()); - backgroundLayout = rootView.findViewById(R.id.background_layout); - progress = rootView.findViewById(R.id.progress); - webView = rootView.findViewById(R.id.web_view); - webView.setWebChromeClient(mWebChromeClient); - webView.setWebViewClient(mWebViewClient); - - WebSettings webSettings = webView.getSettings(); - if (BuildConfig.DEBUG) { - WebView.setWebContentsDebuggingEnabled(true); - } - webSettings.setDomStorageEnabled(true); - webSettings.setJavaScriptEnabled(true); -// -// // App (in Java) -// WebMessageListener bitrefillListener = new WebMessageListener() { -// @Override -// public void onPostMessage(WebView view, WebMessageCompat message, Uri sourceOrigin, -// boolean isMainFrame, JavaScriptReplyProxy replyProxy) { -// // do something about view, message, sourceOrigin and isMainFrame. -// replyProxy.postMessage("Got it!"); -// } -// }; -// if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)) { -// WebViewCompat.addWebMessageListener(webView, "bitrefillPostObj", rules, bitrefillListener); -// } - -// // App (in Java) -// WebMessageListener bitrefillListener = new WebMessageListener() { -// @Override -// public void onPostMessage(WebView view, WebMessageCompat message, Uri sourceOrigin, -// boolean isMainFrame, JavaScriptReplyProxy replyProxy) { -// // do something about view, message, sourceOrigin and isMainFrame. -// replyProxy.postMessage("Got it!"); -// } -// }; -// -// if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)) { -// WebViewCompat.addWebMessageListener(webView, "bitrefillPostObj", rules, bitrefillListener); -// } - - String currency = getArguments().getString(CURRENCY_KEY); - Partner partner = (Partner) getArguments().getSerializable(PARTNER_KEY); - - String bitrefillRef = "bAshL935"; - String utmSource = "BrainwalletAndroid"; - String bitrefillUrl = String.format( BRConstants.BITREFILL_AFFILIATE_LINK + "/embed/?paymentMethod=litecoin&ref=%s&utm_source=%s", bitrefillRef,utmSource); - - String buyUrl = partner == Partner.BITREFILL ? bitrefillUrl : url(getContext(), partner, currency); - Timber.d("timber: URL %s", buyUrl); - webView.loadUrl(buyUrl); - - return rootView; - } - - public static String url(Context context, Partner partner, String currency) { - String walletAddress = BRSharedPrefs.getReceiveAddress(context); - Long timestamp = new Date().getTime(); - String uuid = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); - String prefix = partner == Partner.MOONPAY ? "/moonpay/buy" : ""; - String baseUrl = ((BRApiManager) KoinJavaComponent.get(BRApiManager.class)).getBaseUrlProd(); - String query = String.format(baseUrl + prefix + "?address=%s&code=%s&idate=%s&uid=%s", walletAddress, currency, timestamp, uuid); - return query; - } - - private void closePayment() { - requireActivity().getSupportFragmentManager().popBackStack(); - } - - @Override - public void onStop() { - super.onStop(); - BRAnimator.animateBackgroundDim(backgroundLayout, true); - } - - private WebChromeClient mWebChromeClient = new WebChromeClient() { - // For Android API < 11 (3.0 OS) - public void openFileChooser(ValueCallback valueCallback) { - uploadMessage = valueCallback; - openImageChooserActivity(); - } - - // For Android API >= 11 (3.0 OS) - public void openFileChooser(ValueCallback valueCallback, String acceptType, String capture) { - uploadMessage = valueCallback; - openImageChooserActivity(); - } - - // For Android API >= 21 (5.0 OS) - @Override - public boolean onShowFileChooser(WebView webView, ValueCallback filePathCallback, FileChooserParams fileChooserParams) { - uploadMessageAboveL = filePathCallback; - openImageChooserActivity(); - return true; - } - - @Override - public void onProgressChanged(WebView view, int newProgress) { - super.onProgressChanged(view, newProgress); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - progress.setProgress(newProgress, true); - } else progress.setProgress(newProgress); - } - }; - - private WebViewClient mWebViewClient = new WebViewClient() { - @Override - public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { - String url = request.getUrl().toString(); - Timber.d("timber: shouldOverrideUrlLoading: URL=%s\nMethod=%s", url, request.getMethod()); - if (url.equalsIgnoreCase(onCloseUrl)) { - closePayment(); - onCloseUrl = null; - } else if (url.contains("close")) { - closePayment(); - } else { - view.loadUrl(url); - } - - return true; - } - - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - Timber.d("timber: onPageStarted: %s", url); - super.onPageStarted(view, url, favicon); - progress.setVisibility(View.VISIBLE); - } - - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - Timber.d("timber: onPageFinished %s", url); - progress.setVisibility(View.GONE); - } - }; - - private void openImageChooserActivity() { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT); - intent.addCategory(Intent.CATEGORY_OPENABLE); - intent.setType("image/*"); - startActivityForResult(Intent.createChooser(intent, "Image Chooser"), FILE_CHOOSER_REQUEST_CODE); - } - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == FILE_CHOOSER_REQUEST_CODE) { - if (uploadMessageAboveL != null) { - Uri[] results = getResultAboveL(resultCode, data); - uploadMessageAboveL.onReceiveValue(results); - } else if (uploadMessage != null) { - Uri result = data != null && resultCode == Activity.RESULT_OK ? data.getData() : null; - uploadMessage.onReceiveValue(result); - } - uploadMessageAboveL = null; - uploadMessage = null; - } - } - - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private Uri[] getResultAboveL(int resultCode, Intent intent) { - Uri[] results = null; - if (intent != null && resultCode == Activity.RESULT_OK) { - String dataString = intent.getDataString(); - ClipData clipData = intent.getClipData(); - if (clipData != null) { - results = new Uri[clipData.getItemCount()]; - for (int i = 0; i < clipData.getItemCount(); i++) { - ClipData.Item item = clipData.getItemAt(i); - results[i] = item.getUri(); - } - } else if (dataString != null) { - results = new Uri[]{Uri.parse(dataString)}; - } - } - return results; - } - - @Override - public void onPause() { - super.onPause(); - Utils.hideKeyboard(getActivity()); - } - - public enum Partner { - MOONPAY, BITREFILL - } -} \ No newline at end of file diff --git a/app/src/main/java/com/brainwallet/presenter/fragments/FragmentMoonpay.kt b/app/src/main/java/com/brainwallet/presenter/fragments/FragmentMoonpay.kt new file mode 100644 index 00000000..ce0a4c20 --- /dev/null +++ b/app/src/main/java/com/brainwallet/presenter/fragments/FragmentMoonpay.kt @@ -0,0 +1,65 @@ +package com.brainwallet.presenter.fragments + +import android.content.res.ColorStateList +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.webkit.WebSettings +import android.webkit.WebView +import android.webkit.WebViewClient +import android.widget.ImageButton +import android.widget.TextView +import androidx.core.content.ContextCompat +import androidx.fragment.app.Fragment +import com.brainwallet.R +import com.brainwallet.tools.manager.BRClipboardManager +import com.brainwallet.tools.manager.BRSharedPrefs + +class FragmentMoonpay : Fragment() { + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.fragment_moonpay_temp, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val webView = view.findViewById(R.id.web_view) + val buttonClose = view.findViewById(R.id.close_button) + val copyAddressButton = view.findViewById(R.id.copy_button) + var receiveAddressLabel = view.findViewById(R.id.receive_address) + val addressText = BRSharedPrefs.getReceiveAddress(context) + + // buttonClose + receiveAddressLabel.setText(addressText) + receiveAddressLabel.setTextColor(receiveAddressLabel.getResources().getColor(R.color.midnight, null)); + webView.setInitialScale(80) + webView.settings.apply { + javaScriptEnabled = true + domStorageEnabled = true + cacheMode = WebSettings.LOAD_DEFAULT + setSupportZoom(true) + useWideViewPort = true + loadWithOverviewMode = true + } + + webView.webViewClient = WebViewClient() + webView.loadUrl("https://www.brainwallet.co/mobile-top-up.html") + + buttonClose.setOnClickListener { + parentFragmentManager.popBackStack() + } + + receiveAddressLabel.setOnClickListener { + BRClipboardManager.putClipboard(context, receiveAddressLabel.getText().toString()) + } + + copyAddressButton.setOnClickListener { + BRClipboardManager.putClipboard(context, receiveAddressLabel.getText().toString()) + } + } + } diff --git a/app/src/main/java/com/brainwallet/tools/animation/BRAnimator.java b/app/src/main/java/com/brainwallet/tools/animation/BRAnimator.java index 8c822c0b..78c5364f 100644 --- a/app/src/main/java/com/brainwallet/tools/animation/BRAnimator.java +++ b/app/src/main/java/com/brainwallet/tools/animation/BRAnimator.java @@ -28,16 +28,15 @@ import androidx.fragment.app.FragmentActivity; import com.brainwallet.navigation.LegacyNavigation; +import com.brainwallet.presenter.fragments.FragmentMoonpay; import com.brainwallet.tools.threads.BRExecutor; import com.brainwallet.tools.util.BRConstants; -import com.brainwallet.tools.util.Utils; import com.brainwallet.R; import com.brainwallet.presenter.activities.BreadActivity; import com.brainwallet.presenter.activities.camera.ScanQRActivity; import com.brainwallet.presenter.customviews.BRDialogView; import com.brainwallet.presenter.entities.TxItem; import com.brainwallet.presenter.fragments.FragmentBalanceSeedReminder; -import com.brainwallet.presenter.fragments.FragmentBuy; import com.brainwallet.presenter.fragments.FragmentMenu; import com.brainwallet.presenter.fragments.FragmentReceive; import com.brainwallet.presenter.fragments.FragmentSend; @@ -222,65 +221,27 @@ public static void showReceiveFragment(Activity app, boolean isReceive) { } - public static void showBuyFragment(FragmentActivity app, String currency, FragmentBuy.Partner partner) { + public static void showMoonpayFragment(FragmentActivity app) { + if (app == null) { - Timber.i("timber: showBuyFragment: app is null"); + Timber.i("timber: showSendFragment: app is null"); return; } - app.getSupportFragmentManager() - .beginTransaction() - .setCustomAnimations(0, 0, 0, R.animator.plain_300) - .add(android.R.id.content, FragmentBuy.newInstance(currency, partner), FragmentBuy.class.getName()) - .addToBackStack(FragmentBuy.class.getName()) - .commit(); - } - - public static void showMenuFragment(Activity app) { - if (app == null) { - Timber.i("timber: showReceiveFragment: app is null"); + androidx.fragment.app.FragmentManager fragmentManager = app.getSupportFragmentManager(); + FragmentMoonpay fragmentMoonpay = (FragmentMoonpay) fragmentManager.findFragmentByTag(FragmentMoonpay.class.getName()); + if (fragmentMoonpay != null && fragmentMoonpay.isAdded()) { return; } - FragmentTransaction transaction = app.getFragmentManager().beginTransaction(); - transaction.setCustomAnimations(0, 0, 0, R.animator.plain_300); - transaction.add(android.R.id.content, new FragmentMenu(), FragmentMenu.class.getName()); - transaction.addToBackStack(FragmentMenu.class.getName()); - transaction.commit(); - } - - public static void showSettingsScreen(Activity app) { - - // Create a ComposeView - ComposeView composeView = new ComposeView(app); - -// // Set the Composable function -// composeView.setContent(() -> { -// SettingsScreenKt.SettingsScreen(shouldShowSettingsComposable); -// return null; -// }); -// -// // Set the ComposeView as the content view -// setContentView(composeView); + try { + fragmentMoonpay = new FragmentMoonpay(); + fragmentManager.beginTransaction() + .setCustomAnimations(0, 0, 0, R.animator.plain_300) + .add(android.R.id.content, fragmentMoonpay, FragmentMoonpay.class.getName()) + .addToBackStack(FragmentMoonpay.class.getName()).commit(); + } finally { + } } -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// setContentView(R.layout.activity_main); -// ComposeView composeView = findViewById(R.id.compose_view); -// composeView.setViewCompositionStrategy(ViewCompositionStrategy.[Your choice here]); -// composeView.setContent{ -// HomeKt.Home( -// // other function arguments -// ); -// }); -// } - - - - - - - public static boolean isClickAllowed() { if (clickAllowed) { clickAllowed = false; diff --git a/app/src/main/res/drawable-hdpi/ic_nav_spend.png b/app/src/main/res/drawable-hdpi/ic_nav_spend.png deleted file mode 100644 index 8d0979c0..00000000 Binary files a/app/src/main/res/drawable-hdpi/ic_nav_spend.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/import_symbol.png b/app/src/main/res/drawable-hdpi/import_symbol.png deleted file mode 100644 index a3df0f90..00000000 Binary files a/app/src/main/res/drawable-hdpi/import_symbol.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/restore_image.png b/app/src/main/res/drawable-hdpi/restore_image.png deleted file mode 100644 index d2335bd7..00000000 Binary files a/app/src/main/res/drawable-hdpi/restore_image.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_nav_spend.png b/app/src/main/res/drawable-mdpi/ic_nav_spend.png deleted file mode 100644 index e84e69ba..00000000 Binary files a/app/src/main/res/drawable-mdpi/ic_nav_spend.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/import_symbol.png b/app/src/main/res/drawable-mdpi/import_symbol.png deleted file mode 100644 index 2f60e656..00000000 Binary files a/app/src/main/res/drawable-mdpi/import_symbol.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/restore_image.png b/app/src/main/res/drawable-mdpi/restore_image.png deleted file mode 100644 index a0e12fb9..00000000 Binary files a/app/src/main/res/drawable-mdpi/restore_image.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_nav_spend.png b/app/src/main/res/drawable-xhdpi/ic_nav_spend.png deleted file mode 100644 index 5a805981..00000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_nav_spend.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/import_symbol.png b/app/src/main/res/drawable-xhdpi/import_symbol.png deleted file mode 100644 index dd0a4935..00000000 Binary files a/app/src/main/res/drawable-xhdpi/import_symbol.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/restore_image.png b/app/src/main/res/drawable-xhdpi/restore_image.png deleted file mode 100644 index 3dfc1843..00000000 Binary files a/app/src/main/res/drawable-xhdpi/restore_image.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_nav_spend.png b/app/src/main/res/drawable-xxhdpi/ic_nav_spend.png deleted file mode 100644 index 4dfcdb19..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_nav_spend.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/import_symbol.png b/app/src/main/res/drawable-xxhdpi/import_symbol.png deleted file mode 100644 index f3bb9063..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/import_symbol.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/restore_image.png b/app/src/main/res/drawable-xxhdpi/restore_image.png deleted file mode 100644 index d3479ac3..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/restore_image.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_nav_spend.png b/app/src/main/res/drawable-xxxhdpi/ic_nav_spend.png deleted file mode 100644 index 0e4951a0..00000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_nav_spend.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/import_symbol.png b/app/src/main/res/drawable-xxxhdpi/import_symbol.png deleted file mode 100644 index d95e2e36..00000000 Binary files a/app/src/main/res/drawable-xxxhdpi/import_symbol.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/restore_image.png b/app/src/main/res/drawable-xxxhdpi/restore_image.png deleted file mode 100644 index 16a2ee4b..00000000 Binary files a/app/src/main/res/drawable-xxxhdpi/restore_image.png and /dev/null differ diff --git a/app/src/main/res/drawable/copy_icon.png b/app/src/main/res/drawable/copy_icon.png new file mode 100644 index 00000000..243729b1 Binary files /dev/null and b/app/src/main/res/drawable/copy_icon.png differ diff --git a/app/src/main/res/drawable/ic_bread_logo_white.xml b/app/src/main/res/drawable/ic_bread_logo_white.xml deleted file mode 100644 index 7ba8d331..00000000 --- a/app/src/main/res/drawable/ic_bread_logo_white.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/fragment_buy.xml b/app/src/main/res/layout/fragment_buy.xml deleted file mode 100644 index 95cbf514..00000000 --- a/app/src/main/res/layout/fragment_buy.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_buy_tab.xml b/app/src/main/res/layout/fragment_buy_tab.xml deleted file mode 100644 index 6701bb07..00000000 --- a/app/src/main/res/layout/fragment_buy_tab.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_moonpay_temp.xml b/app/src/main/res/layout/fragment_moonpay_temp.xml new file mode 100644 index 00000000..d9761667 --- /dev/null +++ b/app/src/main/res/layout/fragment_moonpay_temp.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +