From 2c98ed2d8dbe1f76f3f0c94da97c3d52b89546af Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sun, 24 May 2020 18:37:05 +0100 Subject: [PATCH] Always display rewards driver on Invites page. Rewards drivers minimum display amounts. --- .../main/java/io/lbry/browser/ui/BaseFragment.java | 7 +++++-- .../lbry/browser/ui/channel/ChannelFormFragment.java | 2 +- .../browser/ui/findcontent/FileViewFragment.java | 12 ++++++++---- .../lbry/browser/ui/publish/PublishFormFragment.java | 2 +- .../io/lbry/browser/ui/wallet/InvitesFragment.java | 6 +++--- .../io/lbry/browser/ui/wallet/WalletFragment.java | 2 +- app/src/main/res/layout/fragment_invites.xml | 3 ++- app/src/main/res/values/strings.xml | 2 +- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/ui/BaseFragment.java b/app/src/main/java/io/lbry/browser/ui/BaseFragment.java index 6ea6f71a..014a6642 100644 --- a/app/src/main/java/io/lbry/browser/ui/BaseFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/BaseFragment.java @@ -12,6 +12,7 @@ import io.lbry.browser.MainActivity; import io.lbry.browser.R; import io.lbry.browser.model.WalletBalance; import io.lbry.browser.ui.wallet.RewardsFragment; +import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Lbry; import lombok.Getter; import lombok.Setter; @@ -65,7 +66,7 @@ public class BaseFragment extends Fragment { } } - public void checkRewardsDriverCard(String rewardDriverText) { + public void checkRewardsDriverCard(String rewardDriverText, double minCost) { View root = getView(); if (root != null) { View rewardDriverCard = root.findViewById(R.id.reward_driver_card); @@ -85,7 +86,9 @@ public class BaseFragment extends Fragment { // only apply to fragments that have the card present ((TextView) rewardDriverCard.findViewById(R.id.reward_driver_text)).setText(rewardDriverText); - boolean showRewardsDriver = Lbry.walletBalance == null || Lbry.walletBalance.getAvailable().doubleValue() <= 0; + boolean showRewardsDriver = Lbry.walletBalance == null || + minCost == 0 && Lbry.walletBalance.getAvailable().doubleValue() == 0 | + Lbry.walletBalance.getAvailable().doubleValue() < Math.max(minCost, Helper.MIN_DEPOSIT); rewardDriverCard.setVisibility(showRewardsDriver ? View.VISIBLE : View.GONE); } } diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFormFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFormFragment.java index 4c9b59f7..aa191c1c 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelFormFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelFormFragment.java @@ -697,7 +697,7 @@ public class ChannelFormFragment extends BaseFragment implements if (ctx != null) { String rewardsDriverText = String.format("%s\n%s", getString(R.string.channel_creation_requires_credits), getString(R.string.tap_here_to_get_some)); - checkRewardsDriverCard(rewardsDriverText); + checkRewardsDriverCard(rewardsDriverText, Helper.MIN_DEPOSIT); } } } diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java index ed0e9f6b..e0e65bb0 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java @@ -1428,6 +1428,7 @@ public class FileViewFragment extends BaseFragment implements if (metadata instanceof Claim.StreamMetadata) { Claim.StreamMetadata streamMetadata = (Claim.StreamMetadata) metadata; if (claim.getFile() == null && !claim.isFree()) { + // TODO: also check ownership from purchase_list // not free (and the user does not own the claim yet), perform a purchase confirmPurchaseUrl(); } else { @@ -1436,9 +1437,12 @@ public class FileViewFragment extends BaseFragment implements return; } - getView().findViewById(R.id.file_view_main_action_button).setVisibility(View.INVISIBLE); - getView().findViewById(R.id.file_view_main_action_loading).setVisibility(View.VISIBLE); - handleMainActionForClaim(); + View root = getView(); + if (root != null) { + root.findViewById(R.id.file_view_main_action_button).setVisibility(View.INVISIBLE); + root.findViewById(R.id.file_view_main_action_loading).setVisibility(View.VISIBLE); + handleMainActionForClaim(); + } } } else { showError(getString(R.string.cannot_view_claim)); @@ -2161,7 +2165,7 @@ public class FileViewFragment extends BaseFragment implements Context ctx = getContext(); if (ctx != null && claim != null && !claim.isFree() && claim.getFile() == null) { String rewardsDriverText = getString(R.string.earn_some_credits_to_access); - checkRewardsDriverCard(rewardsDriverText); + checkRewardsDriverCard(rewardsDriverText, claim.getActualCost(Lbryio.LBCUSDRate).doubleValue()); } } diff --git a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java index d7a48048..ca17b4ae 100644 --- a/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/publish/PublishFormFragment.java @@ -1430,7 +1430,7 @@ public class PublishFormFragment extends BaseFragment implements if (ctx != null) { String rewardsDriverText = String.format("%s\n%s", getString(R.string.publishing_requires_credits), getString(R.string.tap_here_to_get_some)); - checkRewardsDriverCard(rewardsDriverText); + checkRewardsDriverCard(rewardsDriverText, Helper.MIN_DEPOSIT); } } diff --git a/app/src/main/java/io/lbry/browser/ui/wallet/InvitesFragment.java b/app/src/main/java/io/lbry/browser/ui/wallet/InvitesFragment.java index 8daf886c..fd0ea501 100644 --- a/app/src/main/java/io/lbry/browser/ui/wallet/InvitesFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/wallet/InvitesFragment.java @@ -574,9 +574,9 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener, private void checkRewardsDriver() { Context ctx = getContext(); - if (ctx != null) { - String rewardsDriverText = getString(R.string.earn_credits_for_inviting); - checkRewardsDriverCard(rewardsDriverText); + View root = getView(); + if (ctx != null && root != null) { + Helper.setViewText(root.findViewById(R.id.reward_driver_text), R.string.earn_credits_for_inviting); } } } diff --git a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java index 95a84eb6..4da4ea99 100644 --- a/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java @@ -604,7 +604,7 @@ public class WalletFragment extends BaseFragment implements SdkStatusListener, W Lbryio.totalUnclaimedRewardAmount == 1 ? 1 : 2, Helper.shortCurrencyFormat(Lbryio.totalUnclaimedRewardAmount)); } - checkRewardsDriverCard(rewardsDriverText); + checkRewardsDriverCard(rewardsDriverText, 0); } } } diff --git a/app/src/main/res/layout/fragment_invites.xml b/app/src/main/res/layout/fragment_invites.xml index 443ef3a4..abda6d98 100644 --- a/app/src/main/res/layout/fragment_invites.xml +++ b/app/src/main/res/layout/fragment_invites.xml @@ -17,7 +17,8 @@ + android:layout_marginBottom="16dp" + android:visibility="visible" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8c160f5f..3774caca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -496,7 +496,7 @@ imaginary@friend.com Invite Invite History - Earn credits for invite a friend, an enemy, a frenemy, or an enefriend. Everyone needs content freedom. + Earn credits for inviting a friend, an enemy, a frenemy, or an enefriend. Everyone needs content freedom. Reward Claimed Claimable