Add the logic

This commit is contained in:
Thomas 2020-11-09 18:48:10 +01:00
parent dfdda7627f
commit 58f10d9372
15 changed files with 528 additions and 296 deletions

View File

@ -105,6 +105,11 @@
android:configChanges="orientation|screenSize"
android:label="@string/sepia_search"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name=".ManageInstancesActivity"
android:configChanges="orientation|screenSize"
android:label="@string/instances_picker"
android:windowSoftInputMode="stateAlwaysHidden" />
<activity
android:name=".WebviewActivity"
android:configChanges="keyboardHidden|orientation|screenSize"

View File

@ -26,8 +26,11 @@ import android.os.Bundle;
import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
@ -83,27 +86,28 @@ public class MainActivity extends AppCompatActivity {
private DisplayOverviewFragment overviewFragment;
public static UserMe userMe;
private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= item -> {
DisplayVideosFragment displayVideosFragment = null;
int itemId = item.getItemId();
if (itemId == R.id.navigation_subscription) {
displayVideosFragment = subscriptionFragment;
setTitle(R.string.subscriptions);
setTitleCustom(R.string.subscriptions);
} else if (itemId == R.id.navigation_trending) {
setTitle(R.string.title_trending);
setTitleCustom(R.string.title_trending);
displayVideosFragment = trendingFragment;
} else if (itemId == R.id.navigation_most_liked) {
setTitle(R.string.title_most_liked);
setTitleCustom(R.string.title_most_liked);
displayVideosFragment = mostLikedFragment;
} else if (itemId == R.id.navigation_recently_added) {
setTitle(R.string.title_recently_added);
setTitleCustom(R.string.title_recently_added);
displayVideosFragment = recentFragment;
} else if (itemId == R.id.navigation_local) {
setTitle(R.string.title_local);
setTitleCustom(R.string.title_local);
displayVideosFragment = locaFragment;
} else if (itemId == R.id.navigation_discover) {
setTitle(R.string.title_discover);
setTitleCustom(R.string.title_discover);
fm.beginTransaction().hide(active).show(overviewFragment).commit();
active = overviewFragment;
return true;
@ -117,6 +121,13 @@ public class MainActivity extends AppCompatActivity {
}
};
private void setTitleCustom(int titleRId) {
Toolbar toolbar = findViewById(R.id.toolbar);
TextView mTitle = toolbar.findViewById(R.id.toolbar_title);
mTitle.setText(getString(titleRId));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -125,10 +136,15 @@ public class MainActivity extends AppCompatActivity {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
BottomNavigationView navView = findViewById(R.id.nav_view);
navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
if( getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
Fragment fragment = getSupportFragmentManager().findFragmentByTag("5");
if (fragment != null)
getSupportFragmentManager().beginTransaction().remove(fragment).commit();
@ -192,9 +208,19 @@ public class MainActivity extends AppCompatActivity {
}
});
setTitle(R.string.title_discover);
setTitleCustom(R.string.title_discover);
if (Helper.isLoggedIn(MainActivity.this)) {
if( BuildConfig.full_instances) {
ImageButton instances = toolbar.findViewById(R.id.instances);
instances.setVisibility(View.VISIBLE);
instances.setOnClickListener(v->{
Intent intent = new Intent(MainActivity.this, ManageInstancesActivity.class);
startActivity(intent);
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
});
}
navView.inflateMenu(R.menu.bottom_nav_menu_connected);
new Thread(() -> {
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
@ -369,7 +395,7 @@ public class MainActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_change_instance) {
if (BuildConfig.full_instances) {
showRadioButtonDialogFullInstances();
showRadioButtonDialogFullInstances(MainActivity.this);
} else {
showRadioButtonDialog();
}
@ -494,12 +520,12 @@ public class MainActivity extends AppCompatActivity {
}
@SuppressLint("ApplySharedPref")
private void showRadioButtonDialogFullInstances() {
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
public static void showRadioButtonDialogFullInstances(Activity activity) {
final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
AlertDialog.Builder alt_bld = new AlertDialog.Builder(activity);
alt_bld.setTitle(R.string.instance_choice);
String instance = Helper.getLiveInstance(MainActivity.this);
final EditText input = new EditText(MainActivity.this);
String instance = Helper.getLiveInstance(activity);
final EditText input = new EditText(activity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
@ -510,17 +536,18 @@ public class MainActivity extends AppCompatActivity {
(dialog, which) -> new Thread(() -> {
try {
String newInstance = input.getText().toString().trim();
WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(MainActivity.this, newInstance, null).getNodeInfo();
WellKnownNodeinfo.NodeInfo instanceNodeInfo = new RetrofitPeertubeAPI(activity, newInstance, null).getNodeInfo();
if (instanceNodeInfo.getSoftware() != null && instanceNodeInfo.getSoftware().getName().trim().toLowerCase().compareTo("peertube") == 0) {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_INSTANCE, newInstance);
editor.commit();
runOnUiThread(() -> {
activity.runOnUiThread(() -> {
dialog.dismiss();
recreate();
Intent intent = new Intent(activity, MainActivity.class);
activity.startActivity(intent);
});
} else {
runOnUiThread(() -> Toasty.error(MainActivity.this, getString(R.string.not_valide_instance), Toast.LENGTH_LONG).show());
activity.runOnUiThread(() -> Toasty.error(activity, activity.getString(R.string.not_valide_instance), Toast.LENGTH_LONG).show());
}
} catch (Exception e) {
e.printStackTrace();
@ -529,8 +556,8 @@ public class MainActivity extends AppCompatActivity {
}).start());
alt_bld.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
alt_bld.setNeutralButton(R.string.help, (dialog, which) -> {
Intent intent = new Intent(MainActivity.this, InstancePickerActivity.class);
startActivityForResult(intent, PICK_INSTANCE);
Intent intent = new Intent(activity, InstancePickerActivity.class);
activity.startActivityForResult(intent, PICK_INSTANCE);
});
AlertDialog alert = alt_bld.create();
alert.show();
@ -547,7 +574,8 @@ public class MainActivity extends AppCompatActivity {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_INSTANCE, String.valueOf(data.getData()));
editor.commit();
recreate();
finish();
}
}
}

View File

@ -0,0 +1,87 @@
package app.fedilab.fedilabtube;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import app.fedilab.fedilabtube.databinding.ActivityManageInstancesBinding;
import app.fedilab.fedilabtube.helper.Helper;
import static app.fedilab.fedilabtube.MainActivity.PICK_INSTANCE;
import static app.fedilab.fedilabtube.MainActivity.showRadioButtonDialogFullInstances;
public class ManageInstancesActivity extends AppCompatActivity {
private ActivityManageInstancesBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityManageInstancesBinding.inflate(getLayoutInflater());
View view = binding.getRoot();
setContentView(view);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
binding.actionButton.setOnClickListener(v-> showRadioButtonDialogFullInstances(ManageInstancesActivity.this));
}
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition( R.anim.slide_out_up, R.anim.slide_in_up_down );
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
overridePendingTransition( R.anim.slide_out_up, R.anim.slide_in_up_down );
return true;
}
return super.onOptionsItemSelected(item);
}
@SuppressLint("ApplySharedPref")
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_INSTANCE && resultCode == Activity.RESULT_OK) {
if (data != null && data.getData() != null) {
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_INSTANCE, String.valueOf(data.getData()));
editor.commit();
Intent intent = new Intent(ManageInstancesActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}
}
}

View File

@ -38,6 +38,7 @@ import android.os.Looper;
import android.support.v4.media.session.MediaSessionCompat;
import android.text.Html;
import android.text.Spanned;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -246,7 +247,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.myPp);
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.myPpReply);
}
TorrentOptions torrentOptions = new TorrentOptions.Builder()
@ -298,7 +298,6 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
});
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
binding.writeCommentContainerReply.setVisibility(View.GONE);
binding.writeCommentContainer.setVisibility(View.GONE);
}
playInMinimized = sharedpreferences.getBoolean(getString(R.string.set_video_minimize_choice), true);
@ -382,8 +381,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
comments = new ArrayList<>();
binding.closeReply.setOnClickListener(v -> closeCommentThread());
binding.closePost.setOnClickListener(v -> closePostComment());
commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube));
commentListAdapter = new CommentListAdapter(comments, isMyVideo || Helper.isVideoOwner(PeertubeActivity.this, peertube), false);
commentListAdapter.allCommentRemoved = PeertubeActivity.this;
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
binding.peertubeComments.setLayoutManager(mLayoutManager);
@ -419,6 +419,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
binding.postCommentButton.setOnClickListener(v-> openPostComment(null, 0));
}
@ -459,7 +460,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
public void manageVIewCommentReply(APIResponse apiResponse) {
public void manageVIewCommentReply(Comment comment, APIResponse apiResponse) {
if (apiResponse == null || apiResponse.getError() != null || apiResponse.getCommentThreadData() == null) {
if (apiResponse == null || apiResponse.getError() == null)
Toasty.error(PeertubeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
@ -469,7 +470,10 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
List<CommentData.CommentThreadData> commentThreadDataList = apiResponse.getCommentThreadData().getChildren();
commentsThread = generateCommentReply(commentThreadDataList, new ArrayList<>());
commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube));
comment.setInReplyToCommentId(null);
comment.setTotalReplies(0);
commentsThread.add(0, comment);
commentReplyListAdapter = new CommentListAdapter(commentsThread, Helper.isVideoOwner(PeertubeActivity.this, peertube), true);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(PeertubeActivity.this);
binding.peertubeReply.setLayoutManager(mLayoutManager);
binding.peertubeReply.setNestedScrollingEnabled(false);
@ -742,24 +746,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
if (!Helper.isLoggedIn(PeertubeActivity.this) || sepiaSearch) {
binding.writeCommentContainer.setVisibility(View.GONE);
binding.writeCommentContainerReply.setVisibility(View.GONE);
}
binding.send.setOnClickListener(v -> {
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
String comment = binding.addCommentWrite.getText().toString();
if (comment.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, comment).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
binding.addCommentWrite.setText("");
}
} else {
if (sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
});
binding.peertubePlaylist.setOnClickListener(v -> {
PlaylistsVM viewModelOwnerPlaylist = new ViewModelProvider(PeertubeActivity.this).get(PlaylistsVM.class);
@ -770,13 +757,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
commentViewModel.getThread(sepiaSearch ? peertubeInstance : null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
binding.writeCommentContainerReply.setVisibility(View.VISIBLE);
binding.writeCommentContainer.setVisibility(View.VISIBLE);
}
binding.peertubeComments.setVisibility(View.VISIBLE);
} else {
binding.peertubeComments.setVisibility(View.GONE);
binding.writeCommentContainerReply.setVisibility(View.GONE);
binding.writeCommentContainer.setVisibility(View.GONE);
binding.noActionText.setText(getString(R.string.comment_no_allowed_peertube));
binding.noAction.setVisibility(View.VISIBLE);
@ -1193,9 +1178,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
@Override
public void onBackPressed() {
if (binding.replyThread.getVisibility() == View.VISIBLE) {
if(binding.postComment.getVisibility() == View.VISIBLE){
closePostComment();
} else if (binding.replyThread.getVisibility() == View.VISIBLE) {
closeCommentThread();
} else {
} else {
if (playInMinimized && player != null) {
enterVideoMode();
} else {
@ -1285,24 +1272,18 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
fullScreenDialog.show();
}
public void openCommentThread(Comment comment, int position) {
public void openCommentThread(Comment comment) {
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
binding.peertubeReply.setVisibility(View.GONE);
commentViewModel.getRepliesComment(videoUuid, comment.getId()).observe(PeertubeActivity.this, this::manageVIewCommentReply);
commentViewModel.getRepliesComment(videoUuid, comment.getId()).observe(PeertubeActivity.this, apiResponse->manageVIewCommentReply(comment, apiResponse));
Account account = comment.getAccount();
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.commentAccountProfile);
binding.commentAccountDisplayname.setText(account.getDisplayName());
binding.commentAccountUsername.setText(account.getAcct());
Spanned commentSpan;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
commentSpan = Html.fromHtml(comment.getText(), Html.FROM_HTML_MODE_COMPACT);
else
commentSpan = Html.fromHtml(comment.getText());
binding.commentContent.setText(commentSpan);
binding.commentDate.setText(Helper.dateDiff(PeertubeActivity.this, comment.getCreatedAt()));
binding.replyThread.setVisibility(View.VISIBLE);
TranslateAnimation animate = new TranslateAnimation(
binding.peertubeInformationContainer.getWidth(),
@ -1324,26 +1305,33 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
}
});
animate.setDuration(500);
binding.addCommentWriteReply.setText(String.format("@%s ", comment.getAccount().getAcct()));
binding.addCommentWriteReply.setSelection(binding.addCommentWriteReply.getText().length());
binding.replyThread.startAnimation(animate);
binding.sendReply.setOnClickListener(null);
binding.sendReply.setOnClickListener(v -> {
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
String commentView = binding.addCommentWriteReply.getText().toString();
}
private void sendComment(Comment comment, int position) {
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
if( comment == null) {
String commentStr = binding.addCommentWrite.getText().toString();
if (commentStr.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
viewModelComment.comment(ADD_COMMENT, peertube.getId(), null, commentStr).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(ADD_COMMENT, 0, apiResponse1));
binding.addCommentWrite.setText("");
}
}else{
String commentView = binding.addCommentWrite.getText().toString();
if (commentView.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
viewModelComment.comment(REPLY, peertube.getId(), comment.getId(), commentView).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(REPLY, position, apiResponse1));
binding.addCommentWriteReply.setText("");
}
} else {
if (sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
binding.addCommentWrite.setText("");
}
}
});
} else {
if (sepiaSearch) {
Toasty.info(PeertubeActivity.this, getString(R.string.federation_issue), Toasty.LENGTH_SHORT).show();
} else {
Toasty.error(PeertubeActivity.this, getString(R.string.not_logged_in), Toast.LENGTH_SHORT).show();
}
}
}
private void closeCommentThread() {
@ -1371,6 +1359,86 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
binding.replyThread.startAnimation(animate);
}
public void openPostComment(Comment comment, int position) {
if( comment != null) {
binding.replyContent.setVisibility(View.VISIBLE);
Account account = comment.getAccount();
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, binding.commentAccountProfile);
binding.commentAccountDisplayname.setText(account.getDisplayName());
binding.commentAccountUsername.setText(account.getAcct());
Spanned commentSpan;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
commentSpan = Html.fromHtml(comment.getText(), Html.FROM_HTML_MODE_COMPACT);
else
commentSpan = Html.fromHtml(comment.getText());
binding.commentContent.setText(commentSpan);
binding.commentDate.setText(Helper.dateDiff(PeertubeActivity.this, comment.getCreatedAt()));
}else{
binding.replyContent.setVisibility(View.GONE);
}
binding.postComment.setVisibility(View.VISIBLE);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
TranslateAnimation animateComment = new TranslateAnimation(
0,
0,
height,
binding.mediaVideo.getHeight());
animateComment.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
binding.peertubeInformationContainer.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animateComment.setDuration(500);
binding.postComment.startAnimation(animateComment);
if( comment != null) {
binding.addCommentWrite.setText(String.format("@%s ", comment.getAccount().getAcct()));
binding.addCommentWrite.setSelection(binding.addCommentWrite.getText().length());
}
binding.send.setOnClickListener(null);
binding.send.setOnClickListener(v-> sendComment(comment, position));
}
private void closePostComment() {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int height = displayMetrics.heightPixels;
binding.peertubeInformationContainer.setVisibility(View.VISIBLE);
TranslateAnimation animateComment = new TranslateAnimation(
0,
0,
binding.mediaVideo.getHeight(),
height);
animateComment.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
binding.postComment.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
animateComment.setDuration(500);
binding.postComment.startAnimation(animateComment);
}
@SuppressWarnings({"unused", "RedundantSuppression"})
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int position, APIResponse apiResponse) {

View File

@ -33,6 +33,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -41,7 +42,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelProvider;
@ -59,15 +59,14 @@ import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.CommentData.Comment;
import app.fedilab.fedilabtube.client.entities.Report;
import app.fedilab.fedilabtube.helper.CommentDecorationHelper;
import app.fedilab.fedilabtube.helper.EmojiHelper;
import app.fedilab.fedilabtube.helper.Helper;
import app.fedilab.fedilabtube.viewmodel.PostActionsVM;
import es.dmoral.toasty.Toasty;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE;
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY;
import static app.fedilab.fedilabtube.helper.Helper.isLoggedIn;
public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -78,11 +77,13 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
public AllCommentRemoved allCommentRemoved;
boolean isVideoOwner;
private Context context;
private final boolean isThread;
public CommentListAdapter(List<Comment> comments, boolean isVideoOwner) {
public CommentListAdapter(List<Comment> comments, boolean isVideoOwner, boolean isThread) {
this.comments = comments;
commentListAdapter = this;
this.isVideoOwner = isVideoOwner;
this.isThread = isThread;
}
@Override
@ -120,6 +121,19 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return;
holder.main_container.setTag(i);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
if( comment.isReply()) {
int ident = CommentDecorationHelper.getIndentation(comment.getInReplyToCommentId(), comments);
holder.decoration.setVisibility(View.VISIBLE);
params.setMargins((int)Helper.convertDpToPixel(ident*15, context), 0, 0, 0);
}else{
holder.decoration.setVisibility(View.GONE);
params.setMargins(0, 0, 0, 0);
}
holder.main_container.setLayoutParams(params);
holder.more_actions.setOnClickListener(view -> {
PopupMenu popup = new PopupMenu(context, holder.more_actions);
popup.getMenuInflater()
@ -224,9 +238,10 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
holder.comment_account_displayname.setText(comment.getAccount().getDisplayName());
if (context instanceof PeertubeActivity && !comment.isReply()) {
holder.main_container.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment, i));
holder.comment_content.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment, i));
if (context instanceof PeertubeActivity && !isThread) {
holder.main_container.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
holder.comment_content.setOnClickListener(v -> ((PeertubeActivity) context).openCommentThread(comment));
}
if (comment.getTotalReplies() > 0) {
holder.number_of_replies.setVisibility(View.VISIBLE);
@ -269,33 +284,13 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
} else {
holder.replyButton.setVisibility(View.GONE);
}
if (comment.isReply() && comment.isReplyViewOpen()) {
holder.write_comment_container_reply.setVisibility(View.VISIBLE);
} else {
holder.write_comment_container_reply.setVisibility(View.GONE);
if( i == 0 && isThread) {
holder.post_reply_button.setVisibility(View.VISIBLE);
}else {
holder.post_reply_button.setVisibility(View.GONE);
}
if (holder.add_comment_write_reply.getText() == null || holder.add_comment_write_reply.getText().toString().trim().length() == 0) {
holder.add_comment_write_reply.setText(String.format("@%s ", comment.getAccount().getAcct()));
holder.add_comment_write_reply.setSelection(holder.add_comment_write_reply.getText().length());
}
holder.replyButton.setOnClickListener(v -> {
comment.setReplyViewOpen(!comment.isReplyViewOpen());
notifyItemChanged(i);
});
holder.send_reply.setOnClickListener(null);
holder.send_reply.setOnClickListener(v -> {
if (isLoggedIn(context)) {
String commentView = holder.add_comment_write_reply.getText().toString();
if (commentView.trim().length() > 0) {
PostActionsVM viewModelComment = new ViewModelProvider((ViewModelStoreOwner) context).get(PostActionsVM.class);
viewModelComment.comment(REPLY, comment.getVideoId(), comment.getId(), commentView).observe((LifecycleOwner) context, apiResponse1 -> manageVIewPostActions(REPLY, (int) holder.main_container.getTag(), apiResponse1));
holder.add_comment_write_reply.setText("");
comment.setReplyViewOpen(false);
notifyItemChanged(i);
}
}
});
holder.post_reply_button.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i));
holder.replyButton.setOnClickListener(v -> ((PeertubeActivity) context).openPostComment(comment, i));
}
public void manageVIewPostActions(RetrofitPeertubeAPI.ActionType statusAction, int i, APIResponse apiResponse) {
@ -361,13 +356,12 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
TextView comment_content;
TextView comment_account_username;
TextView comment_account_displayname;
ImageView comment_account_profile, send_reply;
ImageView comment_account_profile;
TextView comment_date, replyButton;
LinearLayout main_container;
TextView more_actions, number_of_replies;
ExtendedEditText add_comment_write_reply;
ConstraintLayout write_comment_container_reply;
Button post_reply_button;
View decoration;
@SuppressLint("SetJavaScriptEnabled")
ViewHolder(View itemView) {
@ -380,10 +374,9 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
main_container = itemView.findViewById(R.id.main_container);
more_actions = itemView.findViewById(R.id.more_actions);
number_of_replies = itemView.findViewById(R.id.number_of_replies);
add_comment_write_reply = itemView.findViewById(R.id.add_comment_write_reply);
send_reply = itemView.findViewById(R.id.send_reply);
replyButton = itemView.findViewById(R.id.replyButton);
write_comment_container_reply = itemView.findViewById(R.id.write_comment_container_reply);
decoration = itemView.findViewById(R.id.decoration);
post_reply_button = itemView.findViewById(R.id.post_reply_button);
}

View File

@ -0,0 +1,42 @@
package app.fedilab.fedilabtube.helper;
/* Copyright 2020 Thomas Schneider
*
* This file is a part of TubeLab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
* see <http://www.gnu.org/licenses>. */
import java.util.List;
import app.fedilab.fedilabtube.client.data.CommentData;
public class CommentDecorationHelper {
public static int getIndentation(String replyToCommentId, List<CommentData.Comment> comments){
return numberOfIndentation(0, replyToCommentId, comments);
}
private static int numberOfIndentation(int currentIdentation, String replyToCommentId, List<CommentData.Comment> comments) {
String targetedComment = null;
for(CommentData.Comment comment: comments) {
if( replyToCommentId.compareTo(comment.getId()) == 0) {
targetedComment = comment.getInReplyToCommentId();
break;
}
}
if ( targetedComment != null) {
currentIdentation++;
return numberOfIndentation(currentIdentation, targetedComment, comments);
}else{
return Math.min(currentIdentation, 5);
}
}
}

View File

@ -21,7 +21,7 @@ import android.database.sqlite.SQLiteOpenHelper;
public class Sqlite extends SQLiteOpenHelper {
public static final int DB_VERSION = 1;
public static final int DB_VERSION = 2;
public static final String DB_NAME = "mastodon_etalab_db";
/***
* List of tables to manage users and data
@ -83,6 +83,14 @@ public class Sqlite extends SQLiteOpenHelper {
+ COL_CACHE + " TEXT NOT NULL, "
+ COL_DATE + " TEXT NOT NULL)";
static final String COL_USER_INSTANCE = "USER_INSTANCE";
static final String TABLE_BOOKMARKED_INSTANCES = "BOOKMARKED_INSTANCES";
private final String CREATE_TABLE_STORED_INSTANCES = "CREATE TABLE "
+ TABLE_BOOKMARKED_INSTANCES + "("
+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ COL_INSTANCE + " TEXT NOT NULL, "
+ COL_USER_ID + " TEXT NOT NULL, "
+ COL_USER_INSTANCE + " TEXT NOT NULL)";
public Sqlite(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
@ -101,17 +109,22 @@ public class Sqlite extends SQLiteOpenHelper {
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_TABLE_USER_ACCOUNT);
db.execSQL(CREATE_TABLE_PEERTUBE_FAVOURITES);
db.execSQL(CREATE_TABLE_STORED_INSTANCES);
}
@Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch (oldVersion) {
case 2:
db.execSQL("DROP TABLE IF EXISTS " +TABLE_BOOKMARKED_INSTANCES);
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch (oldVersion) {
case 1:
db.execSQL(CREATE_TABLE_STORED_INSTANCES);
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="100%p" android:toYDelta="0%p"
android:duration="@android:integer/config_longAnimTime"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p" android:toYDelta="100%p"
android:duration="@android:integer/config_longAnimTime"/>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p"
android:duration="@android:integer/config_longAnimTime"/>

View File

@ -1,10 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM11,19.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L9,15v1c0,1.1 0.9,2 2,2v1.93zM17.9,17.39c-0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L8,12v-2h2c0.55,0 1,-0.45 1,-1L11,7h2c1.1,0 2,-0.9 2,-2v-0.41c2.93,1.19 5,4.06 5,7.41 0,2.08 -0.8,3.97 -2.1,5.39z" />
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM11,19.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L9,15v1c0,1.1 0.9,2 2,2v1.93zM17.9,17.39c-0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L8,12v-2h2c0.55,0 1,-0.45 1,-1L11,7h2c1.1,0 2,-0.9 2,-2v-0.41c2.93,1.19 5,4.06 5,7.41 0,2.08 -0.8,3.97 -2.1,5.39z"/>
</vector>

View File

@ -43,7 +43,22 @@
app:popupTheme="@style/popupTheme"
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true"
/>
>
<ImageButton
android:id="@+id/instances"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_public_24"
android:layout_gravity="start"
android:contentDescription="@string/instance_choice"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toolbar_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"/>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?><!--
<!-
Copyright 2020 Thomas Schneider
This file is a part of TubeLab
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
TubeLab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along with TubeLab; if not,
see <http://www.gnu.org/licenses>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/fab_margin"
android:scrollbars="none"
tools:context=".ManageInstancesActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/lv_instances"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/fab_margin_button"
android:src="@drawable/ic_baseline_add_24"
android:tint="@android:color/white"
/>
</RelativeLayout>

View File

@ -244,80 +244,13 @@
android:textColor="?attr/colorAccent"
android:layout_marginTop="2dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/write_comment_container"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/separator_top"
android:layout_margin="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/write_container"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/darker_gray"/>
<androidx.constraintlayout.widget.ConstraintLayout
app:layout_constraintTop_toBottomOf="@+id/separator_top"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/separator_bottom"
android:id="@+id/write_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/my_pp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginEnd="5dp"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@string/profile_picture" />
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
android:id="@+id/text_field_boxes"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/my_pp"
app:layout_constraintEnd_toStartOf="@+id/send"
app:labelText="@string/add_public_comment"
app:secondaryColor="?attr/colorAccent"
app:primaryColor="?attr/colorAccent"
>
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/add_comment_write"
app:alwaysShowHint="false"
app:useDenseSpacing="false"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
<ImageView
android:layout_marginStart="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/send_comment"
android:src="@drawable/ic_baseline_send_24" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/separator_bottom"
android:layout_margin="5dp"
app:layout_constraintTop_toBottomOf="@+id/write_container"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/darker_gray"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:layout_gravity="center"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:id="@+id/post_comment_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/add_public_comment"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/peertube_comments"
android:layout_width="match_parent"
@ -370,7 +303,47 @@
android:layout_height="24dp"
android:contentDescription="@string/close"
android:src="@drawable/ic_close_black_48dp"/>
<androidx.recyclerview.widget.RecyclerView
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/peertube_reply"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<androidx.core.widget.NestedScrollView
android:background="?android:colorBackground"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/post_comment"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:id="@+id/post_main_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="?android:dividerHorizontal"
android:orientation="vertical"
android:showDividers="end">
<ImageView
android:layout_gravity="end|center_vertical"
android:id="@+id/close_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@string/close"
android:src="@drawable/ic_close_black_48dp"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/reply_content"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
@ -429,69 +402,72 @@
app:layout_constraintTop_toBottomOf="@+id/comment_account_profile" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/write_comment_container_reply"
android:id="@+id/write_comment_container"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/separator_top_reply"
android:id="@+id/separator_top"
android:layout_margin="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/write_container_reply"
app:layout_constraintBottom_toTopOf="@+id/write_container"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/darker_gray"/>
<androidx.constraintlayout.widget.ConstraintLayout
app:layout_constraintTop_toBottomOf="@+id/separator_top_reply"
app:layout_constraintTop_toBottomOf="@+id/separator_top"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/separator_bottom_reply"
android:id="@+id/write_container_reply"
app:layout_constraintBottom_toTopOf="@+id/separator_bottom"
android:id="@+id/write_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/my_pp_reply"
android:id="@+id/my_pp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="30dp"
android:layout_height="30dp"
android:contentDescription="@string/profile_picture" />
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
android:id="@+id/text_field_boxes_reply"
android:id="@+id/text_field_boxes"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/my_pp_reply"
app:layout_constraintEnd_toStartOf="@+id/send_reply"
app:layout_constraintStart_toEndOf="@+id/my_pp"
app:layout_constraintEnd_toEndOf="parent"
app:labelText="@string/add_public_reply"
app:secondaryColor="?attr/colorAccent"
app:primaryColor="?attr/colorAccent"
>
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/add_comment_write_reply"
android:id="@+id/add_comment_write"
app:alwaysShowHint="false"
app:useDenseSpacing="false"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:minLines="4"
android:maxLines="8"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
<ImageView
app:layout_constraintBottom_toBottomOf="parent"
<Button
app:layout_constraintTop_toBottomOf="@+id/text_field_boxes"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/send_reply"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/send_comment"
android:src="@drawable/ic_baseline_send_24"
/>
android:text="@string/send_comment"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/separator_bottom_reply"
android:id="@+id/separator_bottom"
android:layout_margin="5dp"
app:layout_constraintTop_toBottomOf="@+id/write_container_reply"
app:layout_constraintTop_toBottomOf="@+id/write_container"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@ -499,12 +475,6 @@
android:layout_height="1px"
android:background="@android:color/darker_gray"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/peertube_reply"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -28,14 +28,23 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/decoration"
android:layout_width="2dp"
android:layout_height="0dp"
android:background="?attr/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/comment_account_profile"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginStart="10dp"
android:contentDescription="@string/profile_picture"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="@id/decoration"
app:layout_constraintTop_toTopOf="parent" />
<TextView
@ -51,13 +60,14 @@
<TextView
android:id="@+id/comment_account_username"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginStart="5dp"
android:ellipsize="end"
android:singleLine="true"
android:textSize="12sp"
app:layout_constraintEnd_toStartOf="@id/more_actions"
app:layout_constraintStart_toEndOf="@+id/comment_account_profile"
app:layout_constraintTop_toBottomOf="@+id/comment_account_displayname" />
@ -71,7 +81,7 @@
android:gravity="end"
android:maxLines="1"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/more_actions"
app:layout_constraintTop_toTopOf="parent" />
<TextView
@ -91,14 +101,14 @@
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/more_actions"
app:layout_constraintStart_toStartOf="@id/comment_account_profile"
app:layout_constraintTop_toBottomOf="@+id/comment_account_profile" />
<TextView
android:id="@+id/number_of_replies"
app:layout_constraintTop_toBottomOf="@+id/comment_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="@id/decoration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/colorAccent"/>
@ -106,7 +116,7 @@
<TextView
app:layout_constraintTop_toBottomOf="@+id/comment_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="@id/comment_account_profile"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:id="@+id/replyButton"
@ -115,73 +125,18 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.constraintlayout.widget.ConstraintLayout
app:layout_constraintTop_toBottomOf="@+id/replyButton"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/write_comment_container_reply"
android:layout_margin="10dp"
android:visibility="gone"
<Button
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:id="@+id/post_reply_button"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/separator_top_reply"
android:layout_margin="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/write_container_reply"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/darker_gray"/>
<androidx.constraintlayout.widget.ConstraintLayout
app:layout_constraintTop_toBottomOf="@+id/separator_top_reply"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/separator_bottom_reply"
android:id="@+id/write_container_reply"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
android:id="@+id/text_field_boxes_reply"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/send_reply"
app:labelText="@string/add_public_reply"
app:secondaryColor="?attr/colorAccent"
app:primaryColor="?attr/colorAccent"
>
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:id="@+id/add_comment_write_reply"
app:alwaysShowHint="false"
app:useDenseSpacing="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
<ImageView
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/send_reply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/send_comment"
android:src="@drawable/ic_baseline_send_24"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/separator_bottom_reply"
android:layout_margin="5dp"
app:layout_constraintTop_toBottomOf="@+id/write_container_reply"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/darker_gray"/>
</androidx.constraintlayout.widget.ConstraintLayout>
android:gravity="center"
android:visibility="gone"
android:layout_height="wrap_content"
android:text="@string/add_public_reply"
android:textColor="?attr/colorAccent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/comment_content" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>