Merge branch 'improve_comments' into develop

# Conflicts:
#	app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java
This commit is contained in:
Thomas 2020-11-27 11:39:07 +01:00
commit 550394a5e4
7 changed files with 271 additions and 188 deletions

View File

@ -40,7 +40,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;
@ -108,6 +107,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return new ViewHolder(itemBinding);
}
@SuppressLint({"SetJavaScriptEnabled", "ClickableViewAccessibility"})
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
@ -123,19 +123,19 @@ public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
return;
holder.binding.mainContainer.setTag(i);
ConstraintLayout.LayoutParams params = new ConstraintLayout.LayoutParams(
(int) Helper.convertDpToPixel(40, context),
(int) Helper.convertDpToPixel(40, context)
);
holder.binding.decorationContainer.removeAllViews();
if (comment.isReply()) {
int ident = CommentDecorationHelper.getIndentation(comment.getInReplyToCommentId(), comments);
holder.binding.decoration.setVisibility(View.VISIBLE);
params.setMargins((int) Helper.convertDpToPixel(ident * 10, context), 0, 0, 0);
} else {
holder.binding.decoration.setVisibility(View.GONE);
params.setMargins(0, 0, 0, 0);
for (int j = 0; j <= ident; j++) {
View view = new View(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, LinearLayout.LayoutParams.MATCH_PARENT);
params.setMargins((int) Helper.convertDpToPixel(5, context), 0, 0, 0);
view.setBackgroundResource(R.color.colorAccent);
view.setLayoutParams(params);
holder.binding.decorationContainer.addView(view, 0);
}
}
holder.binding.commentAccountProfile.setLayoutParams(params);
holder.binding.moreActions.setOnClickListener(view -> {
PopupMenu popup = new PopupMenu(context, holder.binding.moreActions);
popup.getMenuInflater()

View File

@ -14,8 +14,8 @@ package app.fedilab.fedilabtube.helper;
* 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 java.util.List;
import app.fedilab.fedilabtube.client.data.CommentData;
public class CommentDecorationHelper {
@ -24,6 +24,7 @@ public class CommentDecorationHelper {
return numberOfIndentation(0, replyToCommentId, comments);
}
private static int numberOfIndentation(int currentIdentation, String replyToCommentId, List<CommentData.Comment> comments) {
String targetedComment = null;
@ -37,7 +38,8 @@ public class CommentDecorationHelper {
currentIdentation++;
return numberOfIndentation(currentIdentation, targetedComment, comments);
} else {
return Math.min(currentIdentation, 5);
return Math.min(currentIdentation, 15);
}
}
}

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="180"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270">
<shape android:shape="rectangle">
<size
android:width="30dp"
android:height="30dp" />
<solid android:color="@color/colorAccent" />
<corners android:bottomLeftRadius="30dp" />
</shape>
</rotate>
</item>
<item
android:right="1.5dp"
android:top="1.5dp">
<rotate
android:fromDegrees="180"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="270">
<shape android:shape="rectangle">
<size
android:width="30dp"
android:height="30dp" />
<solid android:color="?attr/backgroundView" />
<corners android:bottomLeftRadius="30dp" />
</shape>
</rotate>
</item>
</layer-list>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<size
android:width="30dp"
android:height="30dp" />
<solid android:color="@color/colorAccent" />
<corners android:bottomLeftRadius="30dp" />
</shape>
</item>
<item
android:bottom="1.5dp"
android:left="1.5dp">
<shape android:shape="rectangle">
<size
android:width="30dp"
android:height="30dp" />
<solid android:color="?attr/backgroundView" />
<corners android:bottomLeftRadius="30dp" />
</shape>
</item>
</layer-list>

View File

@ -125,7 +125,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<TextView
android:id="@+id/peertube_title"
@ -325,7 +326,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_margin="10dp"
android:id="@+id/main_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -349,38 +349,74 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<androidx.core.widget.NestedScrollView
android:background="?android:colorBackground"
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- View where the video will be shown when video goes fullscreen -->
<RelativeLayout
android:id="@+id/videoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:visibility="gone" />
</LinearLayout>
<RelativeLayout
android:id="@+id/video_params"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/backgroundView"
android:minHeight="100dp"
android:translationZ="2dp"
android:visibility="gone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/main_options_video"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="30dp" />
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/post_comment"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?android:colorBackground"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_margin="10dp"
android:id="@+id/post_main_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:divider="?android:dividerHorizontal"
android:orientation="vertical"
android:showDividers="end">
<ImageView
android:layout_margin="5dp"
android:layout_gravity="end|center_vertical"
android:id="@+id/close_post"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end|center_vertical"
android:layout_margin="5dp"
android:contentDescription="@string/close"
android:src="@drawable/ic_baseline_close_24" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/reply_content"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView
android:id="@+id/comment_account_profile"
android:layout_width="40dp"
@ -405,8 +441,8 @@
android:id="@+id/comment_account_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginStart="5dp"
android:layout_marginTop="2dp"
android:ellipsize="end"
android:singleLine="true"
android:textSize="12sp"
@ -436,109 +472,84 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/comment_account_profile" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/write_comment_container"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_margin="10dp">
<View
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"
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"
android:layout_margin="5dp"
android:background="@android:color/darker_gray"
app:layout_constraintBottom_toTopOf="@+id/write_container"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/separator_bottom"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/write_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/separator_bottom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/separator_top">
<ImageView
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" />
android:contentDescription="@string/profile_picture"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/text_field_boxes"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/my_pp"
app:layout_constraintEnd_toEndOf="parent">
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/add_comment_write"
android:gravity="top"
android:inputType="textMultiLine"
android:hint="@string/add_public_reply"
android:minLines="4"
android:maxLines="8"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:gravity="top"
android:hint="@string/add_public_reply"
android:inputType="textMultiLine"
android:maxLines="8"
android:minLines="4" />
</com.google.android.material.textfield.TextInputLayout>
<Button
app:layout_constraintTop_toBottomOf="@+id/text_field_boxes"
app:layout_constraintEnd_toEndOf="parent"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:id="@+id/send"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send_comment"/>
android:text="@string/send_comment"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_field_boxes" />
</androidx.constraintlayout.widget.ConstraintLayout>
<View
android:id="@+id/separator_bottom"
android:layout_margin="5dp"
app:layout_constraintTop_toBottomOf="@+id/write_container"
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"/>
android:layout_margin="5dp"
android:background="@android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/write_container" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- View where the video will be shown when video goes fullscreen -->
<RelativeLayout
android:id="@+id/videoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:visibility="gone" />
</LinearLayout>
<RelativeLayout
android:id="@+id/video_params"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/backgroundView"
android:minHeight="100dp"
android:translationZ="2dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:layout_gravity="center"
android:id="@+id/main_options_video"
android:layout_margin="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/video_params_submenu"
android:layout_width="match_parent"

View File

@ -20,31 +20,34 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="?android:dividerHorizontal"
android:orientation="vertical"
android:orientation="horizontal"
android:clickable="true"
android:showDividers="end"
android:focusable="true">
<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"
<LinearLayout
android:layout_height="match_parent"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/decoration_container"
android:layout_width="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="wrap_content"
android:id="@+id/sub_comment_container"
android:layout_width="match_parent"
android:layout_marginStart="10dp">
<ImageView
android:id="@+id/comment_account_profile"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginStart="10dp"
android:src="@drawable/missing_peertube"
android:contentDescription="@string/profile_picture"
app:layout_constraintStart_toStartOf="@id/decoration"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
@ -108,7 +111,7 @@
<TextView
android:id="@+id/number_of_replies"
app:layout_constraintTop_toBottomOf="@+id/comment_content"
app:layout_constraintStart_toStartOf="@id/decoration"
app:layout_constraintStart_toStartOf="@id/comment_account_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/colorAccent"/>
@ -139,4 +142,5 @@
app:layout_constraintTop_toBottomOf="@+id/comment_content" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@ -9,6 +9,8 @@
<item name="colorAccent">@color/colorAccent</item>
<item name="android:textColor">?attr/colorOnBackground</item>
<item name="backgroundView">@color/backgroundDark</item>
<item name="android:windowBackground">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
</style>
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
@ -18,6 +20,8 @@
<item name="colorAccent">@color/colorAccent</item>
<item name="backgroundView">@color/backgroundDark</item>
<item name="android:textColor">?attr/colorOnBackground</item>
<item name="android:windowBackground">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
</style>
<style name="theme" parent="@style/ThemeOverlay.AppCompat.Dark" />