From 0f10e9dc1f131e4549894b6c08e3a59de5d6d876 Mon Sep 17 00:00:00 2001 From: Clayton Hickey Date: Sat, 12 Dec 2020 20:11:00 -0500 Subject: [PATCH] Removed comment tips --- .../java/io/lbry/browser/model/Comment.java | 1 - ...ithTipTask.java => CommentCreateTask.java} | 13 +- .../ui/channel/ChannelCommentsFragment.java | 35 +- .../ui/findcontent/FileViewFragment.java | 33 +- .../res/layout/container_comment_form.xml | 28 +- .../main/res/layout/fragment_file_view.xml | 403 ++++++++++-------- app/src/main/res/values/strings.xml | 15 +- 7 files changed, 272 insertions(+), 256 deletions(-) rename app/src/main/java/io/lbry/browser/tasks/{CommentCreateWithTipTask.java => CommentCreateTask.java} (83%) diff --git a/app/src/main/java/io/lbry/browser/model/Comment.java b/app/src/main/java/io/lbry/browser/model/Comment.java index 157a2174..2e9a9ae1 100644 --- a/app/src/main/java/io/lbry/browser/model/Comment.java +++ b/app/src/main/java/io/lbry/browser/model/Comment.java @@ -12,7 +12,6 @@ import lombok.Data; @Data public class Comment implements Comparable { - public static final double LBC_COST = 1; public static final int MAX_LENGTH = 2000; private Claim poster; diff --git a/app/src/main/java/io/lbry/browser/tasks/CommentCreateWithTipTask.java b/app/src/main/java/io/lbry/browser/tasks/CommentCreateTask.java similarity index 83% rename from app/src/main/java/io/lbry/browser/tasks/CommentCreateWithTipTask.java rename to app/src/main/java/io/lbry/browser/tasks/CommentCreateTask.java index 05e2fca1..54f810e6 100644 --- a/app/src/main/java/io/lbry/browser/tasks/CommentCreateWithTipTask.java +++ b/app/src/main/java/io/lbry/browser/tasks/CommentCreateTask.java @@ -24,18 +24,16 @@ import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -public class CommentCreateWithTipTask extends AsyncTask { +public class CommentCreateTask extends AsyncTask { private static final String STATUS_ENDPOINT = "https://comments.lbry.com"; private Comment comment; - private BigDecimal amount; private View progressView; private CommentCreateWithTipHandler handler; private Exception error; - public CommentCreateWithTipTask(Comment comment, BigDecimal amount, View progressView, CommentCreateWithTipHandler handler) { + public CommentCreateTask(Comment comment, View progressView, CommentCreateWithTipHandler handler) { this.comment = comment; - this.amount = amount; this.progressView = progressView; this.handler = handler; } @@ -62,13 +60,6 @@ public class CommentCreateWithTipTask extends AsyncTask { } Map options = new HashMap<>(); - options.put("blocking", true); - options.put("claim_id", comment.getClaimId()); - options.put("amount", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(amount.doubleValue())); - options.put("tip", true); - Lbry.genericApiCall(Lbry.METHOD_SUPPORT_CREATE, options); - - options = new HashMap<>(); options.put("comment", comment.getText()); options.put("claim_id", comment.getClaimId()); options.put("channel_id", comment.getChannelId()); diff --git a/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java b/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java index 3189cc5e..ce6dc6c3 100644 --- a/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/channel/ChannelCommentsFragment.java @@ -30,7 +30,6 @@ import com.google.android.material.snackbar.Snackbar; import com.google.android.material.textfield.TextInputEditText; import java.math.BigDecimal; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; @@ -45,7 +44,7 @@ import io.lbry.browser.listener.WalletBalanceListener; import io.lbry.browser.model.Claim; import io.lbry.browser.model.Comment; import io.lbry.browser.model.WalletBalance; -import io.lbry.browser.tasks.CommentCreateWithTipTask; +import io.lbry.browser.tasks.CommentCreateTask; import io.lbry.browser.tasks.CommentListHandler; import io.lbry.browser.tasks.CommentListTask; import io.lbry.browser.tasks.claim.ChannelCreateUpdateTask; @@ -58,7 +57,6 @@ import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.LbryAnalytics; import io.lbry.browser.utils.LbryUri; -import io.lbry.browser.utils.Lbryio; import lombok.Setter; public class ChannelCommentsFragment extends Fragment implements SdkStatusListener, WalletBalanceListener { @@ -367,9 +365,6 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen } private void initCommentForm(View root) { - double amount = Comment.LBC_COST; - String buttonText = getResources().getQuantityString(R.plurals.post_for_credits, amount == 1 ? 1 : 2, Helper.LBC_CURRENCY_FORMAT.format(amount)); - buttonPostComment.setText(buttonText); textCommentLimit.setText(String.format("%d / %d", Helper.getValue(inputComment.getText()).length(), Comment.MAX_LENGTH)); buttonClearReplyToComment.setOnClickListener(new View.OnClickListener() { @@ -387,7 +382,7 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen return; } - validateAndCheckPostComment(amount); + validateAndCheckPostComment(); } }); @@ -433,7 +428,7 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen }); } - private void validateAndCheckPostComment(double amount) { + private void validateAndCheckPostComment() { String comment = Helper.getValue(inputComment.getText()); Claim channel = (Claim) commentChannelSpinner.getSelectedItem(); @@ -445,29 +440,18 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen showError(getString(R.string.please_select_channel)); return; } - if (Lbry.walletBalance == null || amount > Lbry.walletBalance.getAvailable().doubleValue()) { - showError(getString(R.string.insufficient_balance)); - return; - } Context context = getContext(); if (context != null) { - String titleText = getResources().getQuantityString( - R.plurals.post_and_tip, - amount == 1 ? 1 : 2, - Helper.LBC_CURRENCY_FORMAT.format(amount)); - String confirmText = getResources().getQuantityString( - R.plurals.confirm_post_comment, - amount == 1 ? 1 : 2, - Helper.LBC_CURRENCY_FORMAT.format(amount), - claim.getTitleOrName()); + String titleText = getResources().getString(R.string.comment_confirm_post); + String confirmText = getResources().getString(R.string.confirm_post_comment); AlertDialog.Builder builder = new AlertDialog.Builder(context). setTitle(titleText). setMessage(confirmText) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - postComment(amount); + postComment(); } }).setNegativeButton(R.string.no, null); builder.show(); @@ -545,17 +529,15 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen replyToComment = null; } - private void postComment(double tipAmount) { + private void postComment() { if (postingComment) { return; } Comment comment = buildPostComment(); - // only use 2 decimal places - BigDecimal amount = new BigDecimal(String.valueOf(tipAmount)); beforePostComment(); - CommentCreateWithTipTask task = new CommentCreateWithTipTask(comment, amount, progressPostComment, new CommentCreateWithTipTask.CommentCreateWithTipHandler() { + CommentCreateTask task = new CommentCreateTask(comment, progressPostComment, new CommentCreateTask.CommentCreateWithTipHandler() { @Override public void onSuccess(Comment createdComment) { inputComment.setText(null); @@ -573,7 +555,6 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen checkNoComments(); Bundle bundle = new Bundle(); - bundle.putDouble("amount", amount.doubleValue()); bundle.putString("claim_id", claim != null ? claim.getClaimId() : null); bundle.putString("claim_name", claim != null ? claim.getName() : null); LbryAnalytics.logEvent(LbryAnalytics.EVENT_COMMENT_CREATE, bundle); 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 8f63d446..71547ae9 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 @@ -123,7 +123,7 @@ import io.lbry.browser.model.WalletBalance; import io.lbry.browser.model.lbryinc.Reward; import io.lbry.browser.model.lbryinc.Subscription; import io.lbry.browser.tasks.BufferEventTask; -import io.lbry.browser.tasks.CommentCreateWithTipTask; +import io.lbry.browser.tasks.CommentCreateTask; import io.lbry.browser.tasks.CommentListHandler; import io.lbry.browser.tasks.CommentListTask; import io.lbry.browser.tasks.GenericTaskHandler; @@ -2989,9 +2989,6 @@ public class FileViewFragment extends BaseFragment implements } private void initCommentForm(View root) { - double amount = Comment.LBC_COST; - String buttonText = getResources().getQuantityString(R.plurals.post_for_credits, amount == 1 ? 1 : 2, Helper.LBC_CURRENCY_FORMAT.format(amount)); - buttonPostComment.setText(buttonText); textCommentLimit.setText(String.format("%d / %d", Helper.getValue(inputComment.getText()).length(), Comment.MAX_LENGTH)); buttonClearReplyToComment.setOnClickListener(new View.OnClickListener() { @@ -3009,7 +3006,7 @@ public class FileViewFragment extends BaseFragment implements return; } - validateAndCheckPostComment(amount); + validateAndCheckPostComment(); } }); @@ -3055,7 +3052,7 @@ public class FileViewFragment extends BaseFragment implements }); } - private void validateAndCheckPostComment(double amount) { + private void validateAndCheckPostComment() { String comment = Helper.getValue(inputComment.getText()); Claim channel = (Claim) commentChannelSpinner.getSelectedItem(); @@ -3067,29 +3064,18 @@ public class FileViewFragment extends BaseFragment implements showError(getString(R.string.please_select_channel)); return; } - if (Lbry.walletBalance == null || amount > Lbry.walletBalance.getAvailable().doubleValue()) { - showError(getString(R.string.insufficient_balance)); - return; - } Context context = getContext(); if (context != null) { - String titleText = getResources().getQuantityString( - R.plurals.post_and_tip, - amount == 1 ? 1 : 2, - Helper.LBC_CURRENCY_FORMAT.format(amount)); - String confirmText = getResources().getQuantityString( - R.plurals.confirm_post_comment, - amount == 1 ? 1 : 2, - Helper.LBC_CURRENCY_FORMAT.format(amount), - claim.getTitleOrName()); + String titleText = getResources().getString(R.string.comment_confirm_post); + String confirmText = getResources().getString(R.string.confirm_post_comment); AlertDialog.Builder builder = new AlertDialog.Builder(context). setTitle(titleText). setMessage(confirmText) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - postComment(amount); + postComment(); } }).setNegativeButton(R.string.no, null); builder.show(); @@ -3167,17 +3153,15 @@ public class FileViewFragment extends BaseFragment implements replyToComment = null; } - private void postComment(double tipAmount) { + private void postComment() { if (postingComment) { return; } Comment comment = buildPostComment(); - // only use 2 decimal places - BigDecimal amount = new BigDecimal(String.valueOf(tipAmount)); beforePostComment(); - CommentCreateWithTipTask task = new CommentCreateWithTipTask(comment, amount, progressPostComment, new CommentCreateWithTipTask.CommentCreateWithTipHandler() { + CommentCreateTask task = new CommentCreateTask(comment, progressPostComment, new CommentCreateTask.CommentCreateWithTipHandler() { @Override public void onSuccess(Comment createdComment) { inputComment.setText(null); @@ -3195,7 +3179,6 @@ public class FileViewFragment extends BaseFragment implements checkNoComments(); Bundle bundle = new Bundle(); - bundle.putDouble("amount", amount.doubleValue()); bundle.putString("claim_id", claim != null ? claim.getClaimId() : null); bundle.putString("claim_name", claim != null ? claim.getName() : null); LbryAnalytics.logEvent(LbryAnalytics.EVENT_COMMENT_CREATE, bundle); diff --git a/app/src/main/res/layout/container_comment_form.xml b/app/src/main/res/layout/container_comment_form.xml index d92f96af..cca903d3 100644 --- a/app/src/main/res/layout/container_comment_form.xml +++ b/app/src/main/res/layout/container_comment_form.xml @@ -47,22 +47,25 @@ android:layout_marginBottom="8dp" android:orientation="horizontal" android:visibility="gone"> + + android:background="@color/nextLbryGreen" + android:orientation="vertical" /> + + android:layout_marginEnd="40dp" + android:orientation="vertical"> + + android:layout_height="36dp" + android:layout_alignParentEnd="true" + android:background="?attr/selectableItemBackground" + android:clickable="true"> + + + android:layout_centerVertical="true" + android:fontFamily="@font/inter" + android:text="@string/comment_form_post" /> + + android:layout_height="246dp" + android:background="@color/mediaContainerBackground"> + + android:layout_height="match_parent" + android:clickable="true" + android:foreground="?attr/selectableItemBackground"> + + + + android:visibility="invisible" /> + + + + android:textFontWeight="300" + android:textSize="14sp" /> + + app:controller_layout_id="@layout/exo_playback_control_view" /> + + + android:src="@drawable/gerbil_happy" /> + + android:layout_toEndOf="@id/file_view_unsupported_gerbil" + android:orientation="vertical"> + + android:textSize="18sp" /> + + android:textSize="14sp" /> + + android:text="@string/open" + android:textSize="14sp" /> @@ -173,31 +188,37 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="false"> + - + + + android:layout_height="wrap_content" + android:visibility="gone" /> + + android:paddingTop="8dp" + android:paddingEnd="4dp" + android:paddingBottom="8dp"> + + android:layout_centerVertical="true" + android:layout_marginEnd="48dp" + android:orientation="vertical"> + + + android:layout_height="wrap_content" + android:layout_marginTop="4dp" + android:orientation="horizontal"> + + + android:textFontWeight="300" + android:textSize="12sp" /> @@ -246,280 +270,308 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="5"> + + + + android:src="@drawable/ic_share" + android:tint="@color/foreground" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/share" + android:textSize="12sp" /> + + + android:text="@string/fa_gift" + android:textColor="@color/foreground" + android:textSize="20dp" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/support" + android:textSize="12sp" /> + + + android:text="@string/fa_repost" + android:textColor="@color/foreground" + android:textSize="20dp" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/repost" + android:textSize="12sp" /> + + + android:src="@drawable/ic_edit" + android:tint="@color/foreground" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/edit" + android:textSize="12sp" /> + + + + android:src="@drawable/ic_download" + android:tint="@color/foreground" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/download" + android:textSize="12sp" /> + + + android:src="@drawable/ic_delete" + android:tint="@color/foreground" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/delete" + android:textSize="12sp" /> + + + android:src="@drawable/ic_unpublish" + android:tint="@color/foreground" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/unpublish" + android:textSize="12sp" /> + + + android:src="@drawable/ic_report" + android:tint="@color/foreground" /> + + android:layout_gravity="center_horizontal" + android:fontFamily="@font/inter" + android:text="@string/report" + android:textSize="12sp" /> + android:background="@color/divider" /> + + android:paddingTop="12dp" + android:paddingBottom="12dp"> + + + android:layout_height="50dp" + android:layout_centerHorizontal="true" + android:background="@drawable/bg_channel_icon"> + + android:textFontWeight="300" + android:textSize="24sp" /> + + android:layout_height="50dp" + android:layout_centerHorizontal="true" /> + + + android:orientation="horizontal"> + + android:paddingTop="8dp" + android:paddingBottom="8dp"> + + android:textStyle="bold" /> + android:visibility="gone" /> + android:background="@color/divider" /> + android:layout_marginBottom="8dp" + android:orientation="vertical"> + + + android:text="@string/related_content" + android:textSize="16sp" /> + + + + android:layout_height="wrap_content" + android:overScrollMode="never" /> + android:orientation="vertical" + android:paddingBottom="16dp"> + Comment as Please enter a comment to post. Please select a channel to post your comment as. + Post + Confirm your comment + This will post your comment Your comment was successfully posted. Please select a channel to repost on. Reply Replying to %1$s Choose app - - Post and tip %1$s credit? - Post and tip %1$s credits? - - - Post for %1$s credit - Post for %1$s credits - - - This will post your comment with a tip of %1$s credit for %2$s - This will post your comment with a tip of %1$s credits for %2$s - %1$s view %1$s views -- 2.45.2