implement commenting with tips
This commit is contained in:
parent
dcc91f75cc
commit
a0c21c44cb
17 changed files with 998 additions and 317 deletions
|
@ -1,24 +1,46 @@
|
|||
package io.lbry.browser.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.ClaimCacheKey;
|
||||
import io.lbry.browser.model.Comment;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbry;
|
||||
import io.lbry.browser.utils.LbryUri;
|
||||
import lombok.Setter;
|
||||
|
||||
public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.ViewHolder> {
|
||||
private List<Comment> items;
|
||||
private Context context;
|
||||
@Setter
|
||||
private ClaimListAdapter.ClaimListItemListener listener;
|
||||
|
||||
public CommentListAdapter(List<Comment> items, Context context) {
|
||||
this.items = items;
|
||||
this.items = new ArrayList<>(items);
|
||||
this.context = context;
|
||||
for (Comment item : this.items) {
|
||||
ClaimCacheKey key = new ClaimCacheKey();
|
||||
key.setClaimId(item.getChannelId());
|
||||
if (Lbry.claimCache.containsKey(key)) {
|
||||
item.setPoster(Lbry.claimCache.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,14 +48,53 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
|
|||
return items != null ? items.size() : 0;
|
||||
}
|
||||
|
||||
public List<String> getClaimUrlsToResolve() {
|
||||
List<String> urls = new ArrayList<>();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Comment item = items.get(i);
|
||||
if (item.getPoster() == null) {
|
||||
LbryUri url = LbryUri.tryParse(String.format("%s#%s", item.getChannelName(), item.getChannelId()));
|
||||
if (url != null) {
|
||||
urls.add(url.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
protected TextView channelName;
|
||||
protected TextView commentText;
|
||||
protected ImageView thumbnailView;
|
||||
protected View noThumbnailView;
|
||||
protected TextView alphaView;
|
||||
protected TextView commentTimeView;
|
||||
|
||||
public ViewHolder (View v) {
|
||||
super(v);
|
||||
channelName = v.findViewById(R.id.comment_channel_name);
|
||||
commentTimeView = v.findViewById(R.id.comment_time);
|
||||
commentText = v.findViewById(R.id.comment_text);
|
||||
thumbnailView = v.findViewById(R.id.comment_thumbnail);
|
||||
noThumbnailView = v.findViewById(R.id.comment_no_thumbnail);
|
||||
alphaView = v.findViewById(R.id.comment_thumbnail_alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public void insert(int index, Comment comment) {
|
||||
if (!items.contains(comment)) {
|
||||
items.add(index, comment);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePosterForComment(String channelId, Claim channel) {
|
||||
for (int i = 0 ; i < items.size(); i++) {
|
||||
Comment item = items.get(i);
|
||||
if (channelId.equalsIgnoreCase(item.getChannelId())) {
|
||||
item.setPoster(channel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +108,28 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
|
|||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
Comment comment = items.get(position);
|
||||
holder.channelName.setText(comment.getChannelName());
|
||||
holder.commentTimeView.setText(DateUtils.getRelativeTimeSpanString(
|
||||
(comment.getTimestamp() * 1000), System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
|
||||
holder.commentText.setText(comment.getText());
|
||||
|
||||
boolean hasThumbnail = comment.getPoster() != null && !Helper.isNullOrEmpty(comment.getPoster().getThumbnailUrl());
|
||||
holder.thumbnailView.setVisibility(hasThumbnail ? View.VISIBLE : View.INVISIBLE);
|
||||
holder.noThumbnailView.setVisibility(!hasThumbnail ? View.VISIBLE : View.INVISIBLE);
|
||||
int bgColor = Helper.generateRandomColorForValue(comment.getChannelId());
|
||||
Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context);
|
||||
if (hasThumbnail) {
|
||||
Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl()).
|
||||
apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView);
|
||||
}
|
||||
holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null);
|
||||
|
||||
holder.channelName.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null && comment.getPoster() != null) {
|
||||
listener.onClaimClicked(comment.getPoster());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,21 +1,48 @@
|
|||
package io.lbry.browser.model;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Comment {
|
||||
private final String channelName, text, id, parentId;
|
||||
public static final double COST = 0.25;
|
||||
public static final int MAX_LENGTH = 2000;
|
||||
|
||||
public Comment(String channelName, String text, String id, String parentId) {
|
||||
private Claim poster;
|
||||
private String claimId;
|
||||
private List<Comment> replies;
|
||||
private long timestamp;
|
||||
private String channelId;
|
||||
private String channelName, text, id, parentId;
|
||||
|
||||
public Comment(String channelId, String channelName, String text, String id, String parentId) {
|
||||
this.channelId = channelId;
|
||||
this.channelName = channelName;
|
||||
this.text = text;
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
|
||||
this.replies = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Comment() {
|
||||
replies = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addReply(Comment reply) {
|
||||
if (replies == null) {
|
||||
replies = new ArrayList<>();
|
||||
}
|
||||
if (!replies.contains(reply)) {
|
||||
replies.add(reply);
|
||||
}
|
||||
}
|
||||
|
||||
public static Comment fromJSONObject(JSONObject jsonObject) {
|
||||
|
@ -25,15 +52,17 @@ public class Comment {
|
|||
parentId = jsonObject.getString("parent_id");
|
||||
}
|
||||
|
||||
return new Comment(
|
||||
Comment comment = new Comment(
|
||||
Helper.getJSONString("channel_id", null, jsonObject),
|
||||
jsonObject.getString("channel_name"),
|
||||
jsonObject.getString("comment"),
|
||||
jsonObject.getString("comment_id"),
|
||||
parentId
|
||||
);
|
||||
comment.setClaimId(Helper.getJSONString("claim_id", null, jsonObject));
|
||||
comment.setTimestamp(Helper.getJSONLong("timestamp", 0, jsonObject));
|
||||
return comment;
|
||||
} catch (JSONException ex) {
|
||||
// TODO: Throw exception
|
||||
Log.e("Comments", ex.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
package io.lbry.browser.tasks;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.lbry.browser.exceptions.ApiCallException;
|
||||
import io.lbry.browser.model.Comment;
|
||||
import io.lbry.browser.utils.Helper;
|
||||
import io.lbry.browser.utils.Lbry;
|
||||
import io.lbry.browser.utils.Lbryio;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class CommentCreateWithTipTask extends AsyncTask<Void, Void, Comment> {
|
||||
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) {
|
||||
this.comment = comment;
|
||||
this.amount = amount;
|
||||
this.progressView = progressView;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
protected void onPreExecute() {
|
||||
Helper.setViewVisibility(progressView, View.VISIBLE);
|
||||
}
|
||||
|
||||
public Comment doInBackground(Void... params) {
|
||||
Comment createdComment = null;
|
||||
try {
|
||||
// check comments status endpoint
|
||||
Request request = new Request.Builder().url(STATUS_ENDPOINT).build();
|
||||
OkHttpClient client = new OkHttpClient.Builder().
|
||||
writeTimeout(30, TimeUnit.SECONDS).
|
||||
readTimeout(30, TimeUnit.SECONDS).
|
||||
build();
|
||||
Response response = client.newCall(request).execute();
|
||||
JSONObject status = new JSONObject(response.body().string());
|
||||
String statusText = Helper.getJSONString("text", null, status);
|
||||
boolean isRunning = Helper.getJSONBoolean("is_running", false, status);
|
||||
if (!"ok".equalsIgnoreCase(statusText) || !isRunning) {
|
||||
throw new ApiCallException("The comment server is not available at this time. Please try again later.");
|
||||
}
|
||||
|
||||
Map<String, Object> 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());
|
||||
options.put("channel_name", comment.getChannelName());
|
||||
if (!Helper.isNullOrEmpty(comment.getParentId())) {
|
||||
options.put("parent_id", comment.getParentId());
|
||||
}
|
||||
JSONObject jsonObject = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_COMMENT_CREATE, options);
|
||||
createdComment = Comment.fromJSONObject(jsonObject);
|
||||
} catch (ApiCallException | ClassCastException | IOException | JSONException ex) {
|
||||
error = ex;
|
||||
}
|
||||
|
||||
return createdComment;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Comment createdComment) {
|
||||
Helper.setViewVisibility(progressView, View.GONE);
|
||||
if (handler != null) {
|
||||
if (createdComment != null) {
|
||||
handler.onSuccess(createdComment);
|
||||
} else {
|
||||
handler.onError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface CommentCreateWithTipHandler {
|
||||
void onSuccess(Comment createdComment);
|
||||
void onError(Exception error);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,6 @@ import java.util.List;
|
|||
import io.lbry.browser.model.Comment;
|
||||
|
||||
public interface CommentListHandler {
|
||||
void onSuccess(List<Comment> comments);
|
||||
void onSuccess(List<Comment> comments, boolean hasReachedEnd);
|
||||
void onError(Exception error);
|
||||
}
|
||||
|
|
|
@ -52,9 +52,27 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
|
|||
|
||||
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_COMMENT_LIST, options);
|
||||
JSONArray items = result.getJSONArray("items");
|
||||
|
||||
List<Comment> children = new ArrayList<>();
|
||||
comments = new ArrayList<>();
|
||||
for (int i = 0; i < items.length(); i++) {
|
||||
comments.add(Comment.fromJSONObject(items.getJSONObject(i)));
|
||||
Comment comment = Comment.fromJSONObject(items.getJSONObject(i));
|
||||
if (comment != null) {
|
||||
if (!Helper.isNullOrEmpty(comment.getParentId())) {
|
||||
children.add(comment);
|
||||
} else {
|
||||
comments.add(comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Comment child : children) {
|
||||
for (Comment parent : comments) {
|
||||
if (parent.getId().equalsIgnoreCase(child.getParentId())) {
|
||||
parent.addReply(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
|
@ -65,12 +83,10 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
|
|||
protected void onPostExecute(List<Comment> comments) {
|
||||
Helper.setViewVisibility(progressBar, View.GONE);
|
||||
if (handler != null) {
|
||||
if (comments != null && error == null) {
|
||||
handler.onSuccess(comments);
|
||||
if (comments != null) {
|
||||
handler.onSuccess(comments, comments.size() < pageSize);
|
||||
} else {
|
||||
handler.onError(error);
|
||||
if (error != null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public class SupportCreateTask extends AsyncTask<Void, Void, Boolean> {
|
|||
protected Boolean doInBackground(Void... params) {
|
||||
try {
|
||||
Map<String, Object> options = new HashMap<>();
|
||||
options.put("blocking", true);
|
||||
options.put("claim_id", claimId);
|
||||
options.put("amount", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(amount.doubleValue()));
|
||||
options.put("tip", tip);
|
||||
|
|
|
@ -1,19 +1,36 @@
|
|||
package io.lbry.browser.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
import io.lbry.browser.BuildConfig;
|
||||
import io.lbry.browser.MainActivity;
|
||||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.adapter.InlineChannelSpinnerAdapter;
|
||||
import io.lbry.browser.model.Claim;
|
||||
import io.lbry.browser.model.WalletBalance;
|
||||
import io.lbry.browser.tasks.claim.ChannelCreateUpdateTask;
|
||||
import io.lbry.browser.tasks.claim.ClaimResultHandler;
|
||||
import io.lbry.browser.tasks.lbryinc.LogPublishTask;
|
||||
import io.lbry.browser.ui.wallet.RewardsFragment;
|
||||
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 lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -94,4 +111,132 @@ public class BaseFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showError(String message) {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void setupInlineChannelCreator(
|
||||
View container,
|
||||
TextInputEditText inputChannelName,
|
||||
TextInputEditText inputDeposit,
|
||||
View inlineBalanceView,
|
||||
TextView inlineBalanceValue,
|
||||
View linkCancel,
|
||||
MaterialButton buttonCreate,
|
||||
View progressView,
|
||||
AppCompatSpinner channelSpinner,
|
||||
InlineChannelSpinnerAdapter channelSpinnerAdapter) {
|
||||
inputDeposit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
Helper.setViewVisibility(inlineBalanceView, hasFocus ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
linkCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Helper.setViewText(inputChannelName, null);
|
||||
Helper.setViewText(inputDeposit, null);
|
||||
Helper.setViewVisibility(container, View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
buttonCreate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// validate deposit and channel name
|
||||
String channelNameString = Helper.normalizeChannelName(Helper.getValue(inputChannelName.getText()));
|
||||
Claim claimToSave = new Claim();
|
||||
claimToSave.setName(channelNameString);
|
||||
String channelName = claimToSave.getName().startsWith("@") ? claimToSave.getName().substring(1) : claimToSave.getName();
|
||||
String depositString = Helper.getValue(inputDeposit.getText());
|
||||
if ("@".equals(channelName) || Helper.isNullOrEmpty(channelName)) {
|
||||
showError(getString(R.string.please_enter_channel_name));
|
||||
return;
|
||||
}
|
||||
if (!LbryUri.isNameValid(channelName)) {
|
||||
showError(getString(R.string.channel_name_invalid_characters));
|
||||
return;
|
||||
}
|
||||
if (Helper.channelExists(channelName)) {
|
||||
showError(getString(R.string.channel_name_already_created));
|
||||
return;
|
||||
}
|
||||
|
||||
double depositAmount = 0;
|
||||
try {
|
||||
depositAmount = Double.valueOf(depositString);
|
||||
} catch (NumberFormatException ex) {
|
||||
// pass
|
||||
showError(getString(R.string.please_enter_valid_deposit));
|
||||
return;
|
||||
}
|
||||
if (depositAmount == 0) {
|
||||
String error = getResources().getQuantityString(R.plurals.min_deposit_required, depositAmount == 1 ? 1 : 2, String.valueOf(Helper.MIN_DEPOSIT));
|
||||
showError(error);
|
||||
return;
|
||||
}
|
||||
if (Lbry.walletBalance == null || Lbry.walletBalance.getAvailable().doubleValue() < depositAmount) {
|
||||
showError(getString(R.string.deposit_more_than_balance));
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelCreateUpdateTask task = new ChannelCreateUpdateTask(
|
||||
claimToSave, new BigDecimal(depositString), false, progressView, new ClaimResultHandler() {
|
||||
@Override
|
||||
public void beforeStart() {
|
||||
Helper.setViewEnabled(inputChannelName, false);
|
||||
Helper.setViewEnabled(inputDeposit, false);
|
||||
Helper.setViewEnabled(buttonCreate, false);
|
||||
Helper.setViewEnabled(linkCancel, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Claim claimResult) {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
LogPublishTask logPublishTask = new LogPublishTask(claimResult);
|
||||
logPublishTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
// channel created
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("claim_id", claimResult.getClaimId());
|
||||
bundle.putString("claim_name", claimResult.getName());
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_CHANNEL_CREATE, bundle);
|
||||
|
||||
// add the claim to the channel list and set it as the selected item
|
||||
if (channelSpinnerAdapter != null) {
|
||||
channelSpinnerAdapter.add(claimResult);
|
||||
}
|
||||
if (channelSpinner != null && channelSpinnerAdapter != null) {
|
||||
channelSpinner.setSelection(channelSpinnerAdapter.getCount() - 1);
|
||||
}
|
||||
|
||||
Helper.setViewEnabled(inputChannelName, true);
|
||||
Helper.setViewEnabled(inputDeposit, true);
|
||||
Helper.setViewEnabled(buttonCreate, true);
|
||||
Helper.setViewEnabled(linkCancel, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
Helper.setViewEnabled(inputChannelName, true);
|
||||
Helper.setViewEnabled(inputDeposit, true);
|
||||
Helper.setViewEnabled(buttonCreate, true);
|
||||
Helper.setViewEnabled(linkCancel, true);
|
||||
showError(error.getMessage());
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
});
|
||||
|
||||
Helper.setViewText(inlineBalanceValue, Helper.shortCurrencyFormat(Lbry.walletBalance.getAvailable().doubleValue()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,13 +371,6 @@ public class ChannelFormFragment extends BaseFragment implements
|
|||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void showError(String message) {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkPermissionsAndLaunchFilePicker(boolean isCover) {
|
||||
Context context = getContext();
|
||||
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||
|
|
|
@ -13,6 +13,8 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -24,6 +26,7 @@ import android.webkit.WebResourceRequest;
|
|||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
|
@ -31,6 +34,7 @@ import android.widget.TextView;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatSpinner;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
@ -40,6 +44,7 @@ import androidx.webkit.WebSettingsCompat;
|
|||
import androidx.webkit.WebViewFeature;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.github.chrisbanes.photoview.PhotoView;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.DefaultControlDispatcher;
|
||||
|
@ -64,6 +69,7 @@ import com.google.android.exoplayer2.util.Util;
|
|||
import com.google.android.flexbox.FlexboxLayoutManager;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
|
||||
import org.commonmark.node.Node;
|
||||
import org.commonmark.parser.Parser;
|
||||
|
@ -90,6 +96,7 @@ import io.lbry.browser.MainActivity;
|
|||
import io.lbry.browser.R;
|
||||
import io.lbry.browser.adapter.ClaimListAdapter;
|
||||
import io.lbry.browser.adapter.CommentListAdapter;
|
||||
import io.lbry.browser.adapter.InlineChannelSpinnerAdapter;
|
||||
import io.lbry.browser.adapter.TagListAdapter;
|
||||
import io.lbry.browser.dialog.RepostClaimDialogFragment;
|
||||
import io.lbry.browser.dialog.SendTipDialogFragment;
|
||||
|
@ -112,6 +119,7 @@ import io.lbry.browser.model.UrlSuggestion;
|
|||
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.CommentCreateWithTipTask;
|
||||
import io.lbry.browser.tasks.CommentListHandler;
|
||||
import io.lbry.browser.tasks.CommentListTask;
|
||||
import io.lbry.browser.tasks.GenericTaskHandler;
|
||||
|
@ -121,6 +129,7 @@ import io.lbry.browser.tasks.SetSdkSettingTask;
|
|||
import io.lbry.browser.tasks.claim.AbandonHandler;
|
||||
import io.lbry.browser.tasks.claim.AbandonStreamTask;
|
||||
import io.lbry.browser.tasks.claim.ClaimListResultHandler;
|
||||
import io.lbry.browser.tasks.claim.ClaimListTask;
|
||||
import io.lbry.browser.tasks.claim.ClaimSearchResultHandler;
|
||||
import io.lbry.browser.tasks.claim.ResolveTask;
|
||||
import io.lbry.browser.tasks.file.DeleteFileTask;
|
||||
|
@ -191,6 +200,28 @@ public class FileViewFragment extends BaseFragment implements
|
|||
private WebView webView;
|
||||
private boolean webViewAdded;
|
||||
|
||||
private boolean postingComment;
|
||||
private boolean fetchingChannels;
|
||||
private View progressLoadingChannels;
|
||||
private View progressPostComment;
|
||||
private InlineChannelSpinnerAdapter commentChannelSpinnerAdapter;
|
||||
private AppCompatSpinner commentChannelSpinner;
|
||||
private TextInputEditText inputComment;
|
||||
private TextView textCommentLimit;
|
||||
private MaterialButton buttonPostComment;
|
||||
private ImageView commentPostAsThumbnail;
|
||||
private View commentPostAsNoThumbnail;
|
||||
private TextView commentPostAsAlpha;
|
||||
|
||||
private View inlineChannelCreator;
|
||||
private TextInputEditText inlineChannelCreatorInputName;
|
||||
private TextInputEditText inlineChannelCreatorInputDeposit;
|
||||
private View inlineChannelCreatorInlineBalance;
|
||||
private TextView inlineChannelCreatorInlineBalanceValue;
|
||||
private View inlineChannelCreatorCancelLink;
|
||||
private View inlineChannelCreatorProgress;
|
||||
private MaterialButton inlineChannelCreatorCreateButton;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
View root = inflater.inflate(R.layout.fragment_file_view, container, false);
|
||||
|
@ -201,6 +232,25 @@ public class FileViewFragment extends BaseFragment implements
|
|||
layoutDisplayArea = root.findViewById(R.id.file_view_claim_display_area);
|
||||
buttonPublishSomething = root.findViewById(R.id.nothing_at_location_publish_button);
|
||||
|
||||
commentChannelSpinner = root.findViewById(R.id.comment_form_channel_spinner);
|
||||
progressLoadingChannels = root.findViewById(R.id.comment_form_channels_loading);
|
||||
progressPostComment = root.findViewById(R.id.comment_form_post_progress);
|
||||
inputComment = root.findViewById(R.id.comment_form_body);
|
||||
textCommentLimit = root.findViewById(R.id.comment_form_text_limit);
|
||||
buttonPostComment = root.findViewById(R.id.comment_form_post);
|
||||
commentPostAsThumbnail = root.findViewById(R.id.comment_form_thumbnail);
|
||||
commentPostAsNoThumbnail = root.findViewById(R.id.comment_form_no_thumbnail);
|
||||
commentPostAsAlpha = root.findViewById(R.id.comment_form_thumbnail_alpha);
|
||||
|
||||
inlineChannelCreator = root.findViewById(R.id.container_inline_channel_form_create);
|
||||
inlineChannelCreatorInputName = root.findViewById(R.id.inline_channel_form_input_name);
|
||||
inlineChannelCreatorInputDeposit = root.findViewById(R.id.inline_channel_form_input_deposit);
|
||||
inlineChannelCreatorInlineBalance = root.findViewById(R.id.inline_channel_form_inline_balance_container);
|
||||
inlineChannelCreatorInlineBalanceValue = root.findViewById(R.id.inline_channel_form_inline_balance_value);
|
||||
inlineChannelCreatorProgress = root.findViewById(R.id.inline_channel_form_create_progress);
|
||||
inlineChannelCreatorCancelLink = root.findViewById(R.id.inline_channel_form_cancel_link);
|
||||
inlineChannelCreatorCreateButton = root.findViewById(R.id.inline_channel_form_create_button);
|
||||
|
||||
initUi(root);
|
||||
|
||||
fileViewPlayerListener = new Player.EventListener() {
|
||||
|
@ -457,6 +507,7 @@ public class FileViewFragment extends BaseFragment implements
|
|||
loadFile();
|
||||
}
|
||||
checkOwnClaim();
|
||||
fetchChannels();
|
||||
checkAndLoadComments();
|
||||
}
|
||||
|
||||
|
@ -500,6 +551,10 @@ public class FileViewFragment extends BaseFragment implements
|
|||
if (!claim.isPlayable() && !claim.isViewable()) {
|
||||
showUnsupportedView();
|
||||
}
|
||||
} else {
|
||||
if (!claim.isPlayable() && !claim.isViewable()) {
|
||||
restoreMainActionButton();
|
||||
}
|
||||
}
|
||||
|
||||
initialFileLoadDone = true;
|
||||
|
@ -997,6 +1052,23 @@ public class FileViewFragment extends BaseFragment implements
|
|||
}
|
||||
});
|
||||
|
||||
commentChannelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
|
||||
commentChannelSpinnerAdapter.addPlaceholder(false);
|
||||
|
||||
initCommentForm(root);
|
||||
setupInlineChannelCreator(
|
||||
inlineChannelCreator,
|
||||
inlineChannelCreatorInputName,
|
||||
inlineChannelCreatorInputDeposit,
|
||||
inlineChannelCreatorInlineBalance,
|
||||
inlineChannelCreatorInlineBalanceValue,
|
||||
inlineChannelCreatorCancelLink,
|
||||
inlineChannelCreatorCreateButton,
|
||||
inlineChannelCreatorProgress,
|
||||
commentChannelSpinner,
|
||||
commentChannelSpinnerAdapter
|
||||
);
|
||||
|
||||
RecyclerView relatedContentList = root.findViewById(R.id.file_view_related_content_list);
|
||||
RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
|
||||
relatedContentList.setNestedScrollingEnabled(false);
|
||||
|
@ -1237,15 +1309,7 @@ public class FileViewFragment extends BaseFragment implements
|
|||
Claim.GenericMetadata metadata = claim.getValue();
|
||||
if (!Helper.isNullOrEmpty(claim.getThumbnailUrl())) {
|
||||
ImageView thumbnailView = root.findViewById(R.id.file_view_thumbnail);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (claim != null && context != null && thumbnailView != null) {
|
||||
Glide.with(context.getApplicationContext()).asBitmap().load(claim.getThumbnailUrl()).centerCrop().into(thumbnailView);
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
|
||||
} else {
|
||||
// display first x letters of claim name, with random background
|
||||
}
|
||||
|
@ -1891,33 +1955,75 @@ public class FileViewFragment extends BaseFragment implements
|
|||
if (claim != null && root != null) {
|
||||
CommentListTask relatedTask = new CommentListTask(1, 999, claim.getClaimId(), relatedLoading, new CommentListHandler() {
|
||||
@Override
|
||||
public void onSuccess(List<Comment> comments) {
|
||||
public void onSuccess(List<Comment> comments, boolean hasReachedEnd) {
|
||||
Context ctx = getContext();
|
||||
if (ctx != null) {
|
||||
View root = getView();
|
||||
if (ctx != null && root != null) {
|
||||
commentListAdapter = new CommentListAdapter(comments, ctx);
|
||||
commentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {
|
||||
@Override
|
||||
public void onClaimClicked(Claim claim) {
|
||||
if (!Helper.isNullOrEmpty(claim.getName()) &&
|
||||
claim.getName().startsWith("@") &&
|
||||
ctx instanceof MainActivity) {
|
||||
((MainActivity) ctx).openChannelClaim(claim);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
View v = getView();
|
||||
if (v != null) {
|
||||
RecyclerView relatedContentList = root.findViewById(R.id.file_view_comments_list);
|
||||
relatedContentList.setAdapter(commentListAdapter);
|
||||
commentListAdapter.notifyDataSetChanged();
|
||||
|
||||
Helper.setViewVisibility(
|
||||
v.findViewById(R.id.file_view_no_comments),
|
||||
commentListAdapter == null || commentListAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
checkNoComments();
|
||||
resolveCommentPosters();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
|
||||
// pass
|
||||
}
|
||||
});
|
||||
relatedTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNoComments() {
|
||||
View root = getView();
|
||||
if (root != null) {
|
||||
Helper.setViewVisibility(root.findViewById(R.id.file_view_no_comments),
|
||||
commentListAdapter == null || commentListAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveCommentPosters() {
|
||||
if (commentListAdapter != null) {
|
||||
List<String> urlsToResolve = new ArrayList<>(commentListAdapter.getClaimUrlsToResolve());
|
||||
if (urlsToResolve.size() > 0) {
|
||||
ResolveTask task = new ResolveTask(urlsToResolve, Lbry.SDK_CONNECTION_STRING, null, new ClaimListResultHandler() {
|
||||
@Override
|
||||
public void onSuccess(List<Claim> claims) {
|
||||
if (commentListAdapter != null) {
|
||||
for (Claim claim : claims) {
|
||||
if (claim.getClaimId() != null) {
|
||||
commentListAdapter.updatePosterForComment(claim.getClaimId(), claim);
|
||||
}
|
||||
}
|
||||
commentListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
// pass
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if (isInFullscreenMode()) {
|
||||
disableFullScreenMode();
|
||||
|
@ -2333,6 +2439,9 @@ public class FileViewFragment extends BaseFragment implements
|
|||
|
||||
@Override
|
||||
public void onWalletBalanceUpdated(WalletBalance walletBalance) {
|
||||
if (walletBalance != null && inlineChannelCreatorInlineBalanceValue != null) {
|
||||
inlineChannelCreatorInlineBalanceValue.setText(Helper.shortCurrencyFormat(walletBalance.getAvailable().doubleValue()));
|
||||
}
|
||||
checkRewardsDriver();
|
||||
}
|
||||
|
||||
|
@ -2454,4 +2563,257 @@ public class FileViewFragment extends BaseFragment implements
|
|||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchChannels() {
|
||||
if (Lbry.ownChannels != null && Lbry.ownChannels.size() > 0) {
|
||||
updateChannelList(Lbry.ownChannels);
|
||||
return;
|
||||
}
|
||||
|
||||
fetchingChannels = true;
|
||||
disableChannelSpinner();
|
||||
ClaimListTask task = new ClaimListTask(Claim.TYPE_CHANNEL, progressLoadingChannels, new ClaimListResultHandler() {
|
||||
@Override
|
||||
public void onSuccess(List<Claim> claims) {
|
||||
Lbry.ownChannels = new ArrayList<>(claims);
|
||||
updateChannelList(Lbry.ownChannels);
|
||||
enableChannelSpinner();
|
||||
fetchingChannels = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
enableChannelSpinner();
|
||||
fetchingChannels = false;
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
private void disableChannelSpinner() {
|
||||
Helper.setViewEnabled(commentChannelSpinner, false);
|
||||
hideInlineChannelCreator();
|
||||
}
|
||||
private void enableChannelSpinner() {
|
||||
Helper.setViewEnabled(commentChannelSpinner, true);
|
||||
if (commentChannelSpinner != null) {
|
||||
Claim selectedClaim = (Claim) commentChannelSpinner.getSelectedItem();
|
||||
if (selectedClaim != null) {
|
||||
if (selectedClaim.isPlaceholder()) {
|
||||
showInlineChannelCreator();
|
||||
} else {
|
||||
hideInlineChannelCreator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void showInlineChannelCreator() {
|
||||
Helper.setViewVisibility(inlineChannelCreator, View.VISIBLE);
|
||||
}
|
||||
private void hideInlineChannelCreator() {
|
||||
Helper.setViewVisibility(inlineChannelCreator, View.GONE);
|
||||
}
|
||||
|
||||
private void updateChannelList(List<Claim> channels) {
|
||||
if (commentChannelSpinnerAdapter == null) {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
commentChannelSpinnerAdapter = new InlineChannelSpinnerAdapter(context, R.layout.spinner_item_channel, new ArrayList<>(channels));
|
||||
commentChannelSpinnerAdapter.addPlaceholder(false);
|
||||
commentChannelSpinnerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
} else {
|
||||
commentChannelSpinnerAdapter.clear();
|
||||
commentChannelSpinnerAdapter.addAll(channels);
|
||||
commentChannelSpinnerAdapter.addPlaceholder(false);
|
||||
commentChannelSpinnerAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
if (commentChannelSpinner != null) {
|
||||
commentChannelSpinner.setAdapter(commentChannelSpinnerAdapter);
|
||||
}
|
||||
|
||||
if (commentChannelSpinnerAdapter != null && commentChannelSpinner != null) {
|
||||
if (commentChannelSpinnerAdapter.getCount() > 1) {
|
||||
commentChannelSpinner.setSelection(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initCommentForm(View root) {
|
||||
double amount = Comment.COST / Lbryio.LBCUSDRate;
|
||||
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));
|
||||
|
||||
buttonPostComment.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (!Lbry.SDK_READY) {
|
||||
Snackbar.make(root.findViewById(R.id.file_view_claim_display_area), R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
validateAndCheckPostComment(amount);
|
||||
}
|
||||
});
|
||||
|
||||
inputComment.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
int len = charSequence.length();
|
||||
textCommentLimit.setText(String.format("%d / %d", len, Comment.MAX_LENGTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
commentChannelSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
|
||||
Object item = adapterView.getItemAtPosition(position);
|
||||
if (item instanceof Claim) {
|
||||
Claim claim = (Claim) item;
|
||||
if (claim.isPlaceholder()) {
|
||||
if (!fetchingChannels) {
|
||||
showInlineChannelCreator();
|
||||
}
|
||||
} else {
|
||||
hideInlineChannelCreator();
|
||||
updatePostAsChannel(claim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> adapterView) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void validateAndCheckPostComment(double amount) {
|
||||
String comment = Helper.getValue(inputComment.getText());
|
||||
Claim channel = (Claim) commentChannelSpinner.getSelectedItem();
|
||||
|
||||
if (Helper.isNullOrEmpty(comment)) {
|
||||
showError(getString(R.string.please_enter_comment));
|
||||
return;
|
||||
}
|
||||
if (channel == null || Helper.isNullOrEmpty(channel.getClaimId())) {
|
||||
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 confirmText = getResources().getQuantityString(
|
||||
R.plurals.confirm_post_comment,
|
||||
amount == 1 ? 1 : 2,
|
||||
Helper.LBC_CURRENCY_FORMAT.format(amount),
|
||||
claim.getTitleOrName());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context).
|
||||
setTitle(R.string.post_comment).
|
||||
setMessage(confirmText)
|
||||
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
postComment(amount);
|
||||
}
|
||||
}).setNegativeButton(R.string.no, null);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePostAsChannel(Claim channel) {
|
||||
boolean hasThumbnail = !Helper.isNullOrEmpty(channel.getThumbnailUrl());
|
||||
Helper.setViewVisibility(commentPostAsThumbnail, hasThumbnail ? View.VISIBLE : View.INVISIBLE);
|
||||
Helper.setViewVisibility(commentPostAsNoThumbnail, !hasThumbnail ? View.VISIBLE : View.INVISIBLE);
|
||||
Helper.setViewText(commentPostAsAlpha, channel.getName() != null ? channel.getName().substring(1, 2).toUpperCase() : null);
|
||||
|
||||
Context context = getContext();
|
||||
int bgColor = Helper.generateRandomColorForValue(channel.getClaimId());
|
||||
Helper.setIconViewBackgroundColor(commentPostAsNoThumbnail, bgColor, false, context);
|
||||
|
||||
if (hasThumbnail && context != null) {
|
||||
Glide.with(context.getApplicationContext()).
|
||||
asBitmap().
|
||||
load(channel.getThumbnailUrl()).
|
||||
apply(RequestOptions.circleCropTransform()).
|
||||
into(commentPostAsThumbnail);
|
||||
}
|
||||
}
|
||||
|
||||
private void beforePostComment() {
|
||||
postingComment = true;
|
||||
Helper.setViewEnabled(commentChannelSpinner, false);
|
||||
Helper.setViewEnabled(inputComment, false);
|
||||
Helper.setViewEnabled(buttonPostComment, false);
|
||||
}
|
||||
|
||||
private void afterPostComment() {
|
||||
Helper.setViewEnabled(commentChannelSpinner, true);
|
||||
Helper.setViewEnabled(inputComment, true);
|
||||
Helper.setViewEnabled(buttonPostComment, true);
|
||||
postingComment = false;
|
||||
}
|
||||
|
||||
private Comment buildPostComment() {
|
||||
Comment comment = new Comment();
|
||||
Claim channel = (Claim) commentChannelSpinner.getSelectedItem();
|
||||
comment.setClaimId(claim.getClaimId());
|
||||
comment.setChannelId(channel.getClaimId());
|
||||
comment.setChannelName(channel.getName());
|
||||
comment.setText(Helper.getValue(inputComment.getText()));
|
||||
comment.setPoster(channel);
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
private void postComment(double tipAmount) {
|
||||
if (postingComment) {
|
||||
return;
|
||||
}
|
||||
|
||||
Comment comment = buildPostComment();
|
||||
// only use 2 decimal places
|
||||
BigDecimal amount = new BigDecimal(new DecimalFormat(Helper.PLAIN_CURRENCY_FORMAT_PATTERN).format(tipAmount));
|
||||
|
||||
beforePostComment();
|
||||
CommentCreateWithTipTask task = new CommentCreateWithTipTask(comment, amount, progressPostComment, new CommentCreateWithTipTask.CommentCreateWithTipHandler() {
|
||||
@Override
|
||||
public void onSuccess(Comment createdComment) {
|
||||
inputComment.setText(null);
|
||||
if (commentListAdapter != null) {
|
||||
createdComment.setPoster(comment.getPoster());
|
||||
commentListAdapter.insert(0, createdComment);
|
||||
}
|
||||
afterPostComment();
|
||||
checkNoComments();
|
||||
|
||||
Context context = getContext();
|
||||
if (context instanceof MainActivity) {
|
||||
((MainActivity) context).showMessage(R.string.comment_posted);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
showError(error.getMessage());
|
||||
afterPostComment();
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -475,6 +475,8 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
}
|
||||
});
|
||||
|
||||
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
|
||||
channelSpinnerAdapter.addPlaceholder(false);
|
||||
setupInlineChannelCreator(
|
||||
inlineChannelCreator,
|
||||
inlineChannelCreatorInputName,
|
||||
|
@ -483,7 +485,9 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
inlineChannelCreatorInlineBalanceValue,
|
||||
inlineChannelCreatorCancelLink,
|
||||
inlineChannelCreatorCreateButton,
|
||||
inlineChannelCreatorProgress
|
||||
inlineChannelCreatorProgress,
|
||||
channelSpinner,
|
||||
channelSpinnerAdapter
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1269,128 +1273,6 @@ public class PublishFormFragment extends BaseFragment implements
|
|||
checkRewardsDriver();
|
||||
}
|
||||
|
||||
private void setupInlineChannelCreator(
|
||||
View container,
|
||||
TextInputEditText inputChannelName,
|
||||
TextInputEditText inputDeposit,
|
||||
View inlineBalanceView,
|
||||
TextView inlineBalanceValue,
|
||||
View linkCancel,
|
||||
MaterialButton buttonCreate,
|
||||
View progressView) {
|
||||
inputDeposit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
Helper.setViewVisibility(inlineBalanceView, hasFocus ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
linkCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Helper.setViewText(inputChannelName, null);
|
||||
Helper.setViewText(inputDeposit, null);
|
||||
Helper.setViewVisibility(container, View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
buttonCreate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// validate deposit and channel name
|
||||
String channelNameString = Helper.normalizeChannelName(Helper.getValue(inputChannelName.getText()));
|
||||
Claim claimToSave = new Claim();
|
||||
claimToSave.setName(channelNameString);
|
||||
String channelName = claimToSave.getName().startsWith("@") ? claimToSave.getName().substring(1) : claimToSave.getName();
|
||||
String depositString = Helper.getValue(inputDeposit.getText());
|
||||
if ("@".equals(channelName) || Helper.isNullOrEmpty(channelName)) {
|
||||
showError(getString(R.string.please_enter_channel_name));
|
||||
return;
|
||||
}
|
||||
if (!LbryUri.isNameValid(channelName)) {
|
||||
showError(getString(R.string.channel_name_invalid_characters));
|
||||
return;
|
||||
}
|
||||
if (Helper.channelExists(channelName)) {
|
||||
showError(getString(R.string.channel_name_already_created));
|
||||
return;
|
||||
}
|
||||
|
||||
double depositAmount = 0;
|
||||
try {
|
||||
depositAmount = Double.valueOf(depositString);
|
||||
} catch (NumberFormatException ex) {
|
||||
// pass
|
||||
showError(getString(R.string.please_enter_valid_deposit));
|
||||
return;
|
||||
}
|
||||
if (depositAmount == 0) {
|
||||
String error = getResources().getQuantityString(R.plurals.min_deposit_required, depositAmount == 1 ? 1 : 2, String.valueOf(Helper.MIN_DEPOSIT));
|
||||
showError(error);
|
||||
return;
|
||||
}
|
||||
if (Lbry.walletBalance == null || Lbry.walletBalance.getAvailable().doubleValue() < depositAmount) {
|
||||
showError(getString(R.string.deposit_more_than_balance));
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelCreateUpdateTask task = new ChannelCreateUpdateTask(
|
||||
claimToSave, new BigDecimal(depositString), false, progressView, new ClaimResultHandler() {
|
||||
@Override
|
||||
public void beforeStart() {
|
||||
Helper.setViewEnabled(inputChannelName, false);
|
||||
Helper.setViewEnabled(inputDeposit, false);
|
||||
Helper.setViewEnabled(buttonCreate, false);
|
||||
Helper.setViewEnabled(linkCancel, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Claim claimResult) {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
LogPublishTask logPublishTask = new LogPublishTask(claimResult);
|
||||
logPublishTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
// channel created
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("claim_id", claimResult.getClaimId());
|
||||
bundle.putString("claim_name", claimResult.getName());
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_CHANNEL_CREATE, bundle);
|
||||
|
||||
// add the claim to the channel list and set it as the selected item
|
||||
channelSpinnerAdapter.add(claimResult);
|
||||
channelSpinner.setSelection(channelSpinnerAdapter.getCount() - 1);
|
||||
|
||||
Helper.setViewEnabled(inputChannelName, true);
|
||||
Helper.setViewEnabled(inputDeposit, true);
|
||||
Helper.setViewEnabled(buttonCreate, true);
|
||||
Helper.setViewEnabled(linkCancel, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
Helper.setViewEnabled(inputChannelName, true);
|
||||
Helper.setViewEnabled(inputDeposit, true);
|
||||
Helper.setViewEnabled(buttonCreate, true);
|
||||
Helper.setViewEnabled(linkCancel, true);
|
||||
showError(error.getMessage());
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
});
|
||||
|
||||
Helper.setViewText(inlineBalanceValue, Helper.shortCurrencyFormat(Lbry.walletBalance.getAvailable().doubleValue()));
|
||||
}
|
||||
|
||||
private void showError(String message) {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUploadButton() {
|
||||
|
||||
}
|
||||
|
|
|
@ -248,6 +248,8 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
|||
}
|
||||
});
|
||||
|
||||
channelSpinnerAdapter = new InlineChannelSpinnerAdapter(getContext(), R.layout.spinner_item_channel, new ArrayList<>());
|
||||
channelSpinnerAdapter.addPlaceholder(false);
|
||||
setupInlineChannelCreator(
|
||||
inlineChannelCreator,
|
||||
inlineChannelCreatorInputName,
|
||||
|
@ -256,7 +258,9 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
|||
inlineChannelCreatorInlineBalanceValue,
|
||||
inlineChannelCreatorCancelLink,
|
||||
inlineChannelCreatorCreateButton,
|
||||
inlineChannelCreatorProgress
|
||||
inlineChannelCreatorProgress,
|
||||
channelSpinner,
|
||||
channelSpinnerAdapter
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -455,120 +459,6 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
|||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
private void setupInlineChannelCreator(
|
||||
View container,
|
||||
TextInputEditText inputChannelName,
|
||||
TextInputEditText inputDeposit,
|
||||
View inlineBalanceView,
|
||||
TextView inlineBalanceValue,
|
||||
View linkCancel,
|
||||
MaterialButton buttonCreate,
|
||||
View progressView) {
|
||||
inputDeposit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
Helper.setViewVisibility(inlineBalanceView, hasFocus ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
linkCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Helper.setViewText(inputChannelName, null);
|
||||
Helper.setViewText(inputDeposit, null);
|
||||
Helper.setViewVisibility(container, View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
buttonCreate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// validate deposit and channel name
|
||||
String channelNameString = Helper.normalizeChannelName(Helper.getValue(inputChannelName.getText()));
|
||||
Claim claimToSave = new Claim();
|
||||
claimToSave.setName(channelNameString);
|
||||
String channelName = claimToSave.getName().startsWith("@") ? claimToSave.getName().substring(1) : claimToSave.getName();
|
||||
String depositString = Helper.getValue(inputDeposit.getText());
|
||||
if ("@".equals(channelName) || Helper.isNullOrEmpty(channelName)) {
|
||||
showError(getString(R.string.please_enter_channel_name));
|
||||
return;
|
||||
}
|
||||
if (!LbryUri.isNameValid(channelName)) {
|
||||
showError(getString(R.string.channel_name_invalid_characters));
|
||||
return;
|
||||
}
|
||||
if (Helper.channelExists(channelName)) {
|
||||
showError(getString(R.string.channel_name_already_created));
|
||||
return;
|
||||
}
|
||||
|
||||
double depositAmount = 0;
|
||||
try {
|
||||
depositAmount = Double.valueOf(depositString);
|
||||
} catch (NumberFormatException ex) {
|
||||
// pass
|
||||
showError(getString(R.string.please_enter_valid_deposit));
|
||||
return;
|
||||
}
|
||||
if (depositAmount == 0) {
|
||||
String error = getResources().getQuantityString(R.plurals.min_deposit_required, depositAmount == 1 ? 1 : 2, String.valueOf(Helper.MIN_DEPOSIT));
|
||||
showError(error);
|
||||
return;
|
||||
}
|
||||
if (Lbry.walletBalance == null || Lbry.walletBalance.getAvailable().doubleValue() < depositAmount) {
|
||||
showError(getString(R.string.deposit_more_than_balance));
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelCreateUpdateTask task = new ChannelCreateUpdateTask(
|
||||
claimToSave, new BigDecimal(depositString), false, progressView, new ClaimResultHandler() {
|
||||
@Override
|
||||
public void beforeStart() {
|
||||
Helper.setViewEnabled(inputChannelName, false);
|
||||
Helper.setViewEnabled(inputDeposit, false);
|
||||
Helper.setViewEnabled(buttonCreate, false);
|
||||
Helper.setViewEnabled(linkCancel, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Claim claimResult) {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
LogPublishTask logPublishTask = new LogPublishTask(claimResult);
|
||||
logPublishTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
// channel created
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("claim_id", claimResult.getClaimId());
|
||||
bundle.putString("claim_name", claimResult.getName());
|
||||
LbryAnalytics.logEvent(LbryAnalytics.EVENT_CHANNEL_CREATE, bundle);
|
||||
|
||||
// add the claim to the channel list and set it as the selected item
|
||||
channelSpinnerAdapter.add(claimResult);
|
||||
channelSpinner.setSelection(channelSpinnerAdapter.getCount() - 1);
|
||||
|
||||
Helper.setViewEnabled(inputChannelName, true);
|
||||
Helper.setViewEnabled(inputDeposit, true);
|
||||
Helper.setViewEnabled(buttonCreate, true);
|
||||
Helper.setViewEnabled(linkCancel, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception error) {
|
||||
Helper.setViewEnabled(inputChannelName, true);
|
||||
Helper.setViewEnabled(inputDeposit, true);
|
||||
Helper.setViewEnabled(buttonCreate, true);
|
||||
Helper.setViewEnabled(linkCancel, true);
|
||||
showError(error.getMessage());
|
||||
}
|
||||
});
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
});
|
||||
|
||||
Helper.setViewText(inlineBalanceValue, Helper.shortCurrencyFormat(Lbry.walletBalance.getAvailable().doubleValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalletBalanceUpdated(WalletBalance walletBalance) {
|
||||
if (walletBalance != null && inlineChannelCreatorInlineBalanceValue != null) {
|
||||
|
@ -577,14 +467,6 @@ public class InvitesFragment extends BaseFragment implements SdkStatusListener,
|
|||
checkRewardsDriver();
|
||||
}
|
||||
|
||||
private void showError(String message) {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
Snackbar.make(getView(), message, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRewardsDriver() {
|
||||
Context ctx = getContext();
|
||||
View root = getView();
|
||||
|
|
|
@ -70,6 +70,7 @@ public final class Helper {
|
|||
public static final MediaType JSON_MEDIA_TYPE = MediaType.get("application/json; charset=utf-8");
|
||||
public static final int CONTENT_PAGE_SIZE = 25;
|
||||
public static final double MIN_DEPOSIT = 0.001;
|
||||
public static final String PLAIN_CURRENCY_FORMAT_PATTERN = "####.##";
|
||||
public static final String LBC_CURRENCY_FORMAT_PATTERN = "#,###.##";
|
||||
public static final String FILE_SIZE_FORMAT_PATTERN = "#,###.#";
|
||||
public static final DecimalFormat LBC_CURRENCY_FORMAT = new DecimalFormat(LBC_CURRENCY_FORMAT_PATTERN);
|
||||
|
|
|
@ -89,6 +89,8 @@ public final class Lbry {
|
|||
public static final String METHOD_PREFERENCE_GET = "preference_get";
|
||||
public static final String METHOD_PREFERENCE_SET = "preference_set";
|
||||
|
||||
public static final String METHOD_COMMENT_CREATE = "comment_create";
|
||||
|
||||
public static final String METHOD_TXO_LIST = "txo_list";
|
||||
public static final String METHOD_TXO_SPEND = "txo_spend";
|
||||
|
||||
|
|
118
app/src/main/res/layout/container_comment_form.xml
Normal file
118
app/src/main/res/layout/container_comment_form.xml
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/post_as"
|
||||
android:fontFamily="@font/inter"
|
||||
android:textSize="14sp"
|
||||
android:textFontWeight="300" />
|
||||
<ProgressBar
|
||||
android:id="@+id/comment_form_channels_loading"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
android:id="@+id/comment_form_channel_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp" />
|
||||
|
||||
<include layout="@layout/container_inline_channel_form" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
<RelativeLayout
|
||||
android:id="@+id/comment_form_avatar_container"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp">
|
||||
<RelativeLayout
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/bg_channel_icon"
|
||||
android:id="@+id/comment_form_no_thumbnail"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:visibility="invisible">
|
||||
<TextView
|
||||
android:id="@+id/comment_form_thumbnail_alpha"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="24sp"
|
||||
android:textColor="@color/white"
|
||||
android:textFontWeight="300" />
|
||||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:layout_centerInParent="true"
|
||||
android:id="@+id/comment_form_thumbnail"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/comment_form_avatar_container"
|
||||
android:layout_marginLeft="16dp">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/comment_form_body"
|
||||
android:hint="@string/comment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter"
|
||||
android:textFontWeight="300"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="2000"
|
||||
android:singleLine="false"
|
||||
android:scrollbars="vertical"
|
||||
android:textSize="14sp" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_form_text_limit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginTop="2dp"
|
||||
android:fontFamily="@font/inter"
|
||||
android:textColor="@color/lightGrey"
|
||||
android:textFontWeight="300"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/comment_form_post"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter" />
|
||||
<ProgressBar
|
||||
android:id="@+id/comment_form_post_progress"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toRightOf="@id/comment_form_post"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
|
@ -37,7 +37,6 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/file_view_claim_display_area"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="10"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible">
|
||||
|
@ -45,8 +44,7 @@
|
|||
android:id="@+id/file_view_media_container"
|
||||
android:background="@color/mediaContainerBackground"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="3.55">
|
||||
android:layout_height="246dp">
|
||||
<RelativeLayout
|
||||
android:id="@+id/file_view_media_meta_container"
|
||||
android:clickable="true"
|
||||
|
@ -167,8 +165,7 @@
|
|||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/file_view_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="6.45"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
|
@ -571,7 +568,7 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/file_view_related_content_area"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp">
|
||||
<RelativeLayout
|
||||
|
@ -590,7 +587,7 @@
|
|||
android:id="@+id/file_view_related_content_progress"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
@ -623,7 +620,7 @@
|
|||
android:id="@+id/file_view_comments_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -631,12 +628,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/file_view_comments_progress"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
@ -649,6 +645,8 @@
|
|||
android:textSize="16sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/container_comment_form" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_view_no_comments"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -11,26 +11,78 @@
|
|||
android:paddingRight="16dp"
|
||||
android:paddingTop="8dp">
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/comment_avatar_container"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp">
|
||||
<RelativeLayout
|
||||
android:layout_centerHorizontal="true"
|
||||
android:background="@drawable/bg_channel_icon"
|
||||
android:id="@+id/comment_no_thumbnail"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp">
|
||||
<TextView
|
||||
android:id="@+id/comment_channel_name"
|
||||
android:id="@+id/comment_thumbnail_alpha"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="24sp"
|
||||
android:textColor="@color/white"
|
||||
android:textFontWeight="300" />
|
||||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:layout_centerHorizontal="true"
|
||||
android:id="@+id/comment_thumbnail"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/comment_avatar_container"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/comment_channel_name"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/inter"
|
||||
android:text="channel_name"
|
||||
android:textColor="@color/lbryGreen"
|
||||
android:textSize="14sp" />
|
||||
<TextView
|
||||
android:id="@+id/comment_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:fontFamily="@font/inter"
|
||||
android:textColor="@color/lightGrey"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:lineSpacingMultiplier="1.05"
|
||||
android:fontFamily="@font/inter"
|
||||
android:text="comment_text" />
|
||||
android:textFontWeight="300"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -60,8 +60,8 @@
|
|||
<string name="loading_decentralized_data">Loading decentralized data...</string>
|
||||
<string name="related_content">Related Content</string>
|
||||
<string name="comments">Comments</string>
|
||||
<string name="no_comments">No comments to display.</string>
|
||||
<string name="sdk_initializing_comments">Comments will display once the background service is done initializing.</string>
|
||||
<string name="no_comments">No comments to display at this time.</string>
|
||||
<string name="sdk_initializing_comments">Comments will display after the background service is initialized.</string>
|
||||
<string name="share_lbry_content">Share LBRY content</string>
|
||||
<string name="view">View</string>
|
||||
<string name="play">Play</string>
|
||||
|
@ -81,6 +81,20 @@
|
|||
<string name="confirm_delete_content_message">Are you sure you want to unpublish this content? No files will be removed from your device.</string>
|
||||
<string name="content_deleted">The content was successfully deleted from the blockchain.</string>
|
||||
<string name="content_failed_delete">The content could not be deleted at this time. Please try again later.</string>
|
||||
<string name="comment">Comment</string>
|
||||
<string name="post_as">Post as</string>
|
||||
<string name="please_enter_comment">Please enter a comment to post.</string>
|
||||
<string name="please_select_channel">Please select a channel to post your comment as.</string>
|
||||
<string name="post_comment">Post comment with tip?</string>
|
||||
<string name="comment_posted">Your comment was successfully posted.</string>
|
||||
<plurals name="post_for_credits">
|
||||
<item quantity="one">Post for %1$s credit</item>
|
||||
<item quantity="other">Post for %1$s credits</item>
|
||||
</plurals>
|
||||
<plurals name="confirm_post_comment">
|
||||
<item quantity="one">This will post your comment with a tip of %1$s credit for %2$s</item>
|
||||
<item quantity="other">This will post your comment with a tip of %1$s credits for %2$s</item>
|
||||
</plurals>
|
||||
<plurals name="view_count">
|
||||
<item quantity="one">%1$s view</item>
|
||||
<item quantity="other">%1$s views</item>
|
||||
|
|
Loading…
Reference in a new issue