mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
@@ -98,6 +98,46 @@
|
|||||||
tools:src="@drawable/ic_launcher"
|
tools:src="@drawable/ic_launcher"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/author"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toRightOf="@id/avatar"
|
||||||
|
android:layout_alignBottom="@+id/avatar"
|
||||||
|
android:layout_alignTop="@+id/avatar"
|
||||||
|
android:gravity="center"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="@dimen/text_size_tiny"
|
||||||
|
tools:text="John Smith"/>
|
||||||
|
|
||||||
|
<org.briarproject.android.util.TrustIndicatorView
|
||||||
|
android:id="@+id/trustIndicator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@+id/avatar"
|
||||||
|
android:layout_alignTop="@+id/avatar"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:layout_marginLeft="@dimen/margin_small"
|
||||||
|
android:layout_marginStart="@dimen/margin_small"
|
||||||
|
android:layout_toRightOf="@+id/author"
|
||||||
|
tools:src="@drawable/trust_indicator_verified"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/date"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@+id/avatar"
|
||||||
|
android:layout_alignTop="@+id/avatar"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_toRightOf="@+id/trustIndicator"
|
||||||
|
android:layout_marginLeft="@dimen/margin_small"
|
||||||
|
android:layout_marginStart="@dimen/margin_small"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="@dimen/text_size_tiny"
|
||||||
|
tools:text="09:09"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/chevron"
|
android:id="@+id/chevron"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -131,35 +171,13 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBaseline="@id/btn_reply"
|
android:layout_alignBaseline="@id/btn_reply"
|
||||||
android:layout_toLeftOf="@id/btn_reply"
|
android:layout_toLeftOf="@id/btn_reply"
|
||||||
android:layout_toRightOf="@+id/trustIndicator"
|
android:layout_toRightOf="@+id/date"
|
||||||
android:gravity="right|end"
|
android:gravity="right|end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:padding="@dimen/margin_medium"
|
android:padding="@dimen/margin_medium"
|
||||||
android:textSize="@dimen/text_size_tiny"
|
android:textSize="@dimen/text_size_tiny"
|
||||||
tools:text="2 replies"/>
|
tools:text="2 replies"/>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/date"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignBaseline="@id/replies"
|
|
||||||
android:layout_toRightOf="@id/avatar"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textSize="@dimen/text_size_tiny"
|
|
||||||
tools:text="09:09 John Smith"/>
|
|
||||||
|
|
||||||
<org.briarproject.android.util.TrustIndicatorView
|
|
||||||
android:id="@+id/trustIndicator"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignBottom="@+id/date"
|
|
||||||
android:layout_alignTop="@+id/date"
|
|
||||||
android:layout_marginLeft="@dimen/margin_small"
|
|
||||||
android:layout_marginStart="@dimen/margin_small"
|
|
||||||
android:layout_toRightOf="@+id/date"
|
|
||||||
tools:src="@drawable/trust_indicator_verified"/>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/top_divider"
|
android:id="@+id/top_divider"
|
||||||
style="@style/Divider.ForumList"
|
style="@style/Divider.ForumList"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.graphics.drawable.ColorDrawable;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
@@ -64,8 +65,8 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(ForumActivity.class.getName());
|
Logger.getLogger(ForumActivity.class.getName());
|
||||||
|
|
||||||
public static final String FORUM_NAME = "briar.FORUM_NAME";
|
|
||||||
public static final String MIN_TIMESTAMP = "briar.MIN_TIMESTAMP";
|
public static final String MIN_TIMESTAMP = "briar.MIN_TIMESTAMP";
|
||||||
|
static final String FORUM_NAME = "briar.FORUM_NAME";
|
||||||
private static final int REQUEST_FORUM_SHARED = 3;
|
private static final int REQUEST_FORUM_SHARED = 3;
|
||||||
|
|
||||||
private final static int UNDEFINED = -1;
|
private final static int UNDEFINED = -1;
|
||||||
@@ -73,7 +74,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
private static final String KEY_REPLY_ID = "replyId";
|
private static final String KEY_REPLY_ID = "replyId";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected AndroidNotificationManager notificationManager;
|
AndroidNotificationManager notificationManager;
|
||||||
|
|
||||||
// uncomment the next line for a test component with dummy data
|
// uncomment the next line for a test component with dummy data
|
||||||
// @Named("ForumTestController")
|
// @Named("ForumTestController")
|
||||||
@@ -331,20 +332,21 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
|
|
||||||
static class ForumViewHolder extends RecyclerView.ViewHolder {
|
static class ForumViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
public final TextView textView, lvlText, dateText, repliesText;
|
final TextView textView, lvlText, authorText, dateText, repliesText;
|
||||||
public final View[] lvls;
|
final View[] lvls;
|
||||||
public final ImageView avatar;
|
public final ImageView avatar;
|
||||||
final TrustIndicatorView trust;
|
final TrustIndicatorView trust;
|
||||||
public final View chevron, replyButton;
|
final View chevron, replyButton;
|
||||||
public final ViewGroup cell;
|
final ViewGroup cell;
|
||||||
public final View topDivider;
|
final View topDivider;
|
||||||
public ValueAnimator highlightAnimator;
|
public ValueAnimator highlightAnimator;
|
||||||
|
|
||||||
public ForumViewHolder(View v) {
|
ForumViewHolder(View v) {
|
||||||
super(v);
|
super(v);
|
||||||
|
|
||||||
textView = (TextView) v.findViewById(R.id.text);
|
textView = (TextView) v.findViewById(R.id.text);
|
||||||
lvlText = (TextView) v.findViewById(R.id.nested_line_text);
|
lvlText = (TextView) v.findViewById(R.id.nested_line_text);
|
||||||
|
authorText = (TextView) v.findViewById(R.id.author);
|
||||||
dateText = (TextView) v.findViewById(R.id.date);
|
dateText = (TextView) v.findViewById(R.id.date);
|
||||||
repliesText = (TextView) v.findViewById(R.id.replies);
|
repliesText = (TextView) v.findViewById(R.id.replies);
|
||||||
int[] nestedLineIds = {
|
int[] nestedLineIds = {
|
||||||
@@ -367,13 +369,13 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
public class ForumAdapter extends RecyclerView.Adapter<ForumViewHolder> {
|
public class ForumAdapter extends RecyclerView.Adapter<ForumViewHolder> {
|
||||||
|
|
||||||
private final List<ForumEntry> forumEntries;
|
private final List<ForumEntry> forumEntries;
|
||||||
// highlight not depandant on time
|
// highlight not dependant on time
|
||||||
private ForumEntry replyEntry;
|
private ForumEntry replyEntry;
|
||||||
// temporary highlight
|
// temporary highlight
|
||||||
private ForumEntry addedEntry;
|
private ForumEntry addedEntry;
|
||||||
Map<ForumEntry, ValueAnimator> animatingEntries = new HashMap<>();
|
Map<ForumEntry, ValueAnimator> animatingEntries = new HashMap<>();
|
||||||
|
|
||||||
public ForumAdapter(@NonNull List<ForumEntry> forumEntries) {
|
ForumAdapter(@NonNull List<ForumEntry> forumEntries) {
|
||||||
this.forumEntries = forumEntries;
|
this.forumEntries = forumEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +383,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
return replyEntry;
|
return replyEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEntry(int index, ForumEntry entry,
|
void addEntry(int index, ForumEntry entry,
|
||||||
boolean isScrolling) {
|
boolean isScrolling) {
|
||||||
forumEntries.add(index, entry);
|
forumEntries.add(index, entry);
|
||||||
boolean isShowingDescendants = false;
|
boolean isShowingDescendants = false;
|
||||||
@@ -412,7 +414,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
addedEntry = entry;
|
addedEntry = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToEntry(ForumEntry entry) {
|
void scrollToEntry(ForumEntry entry) {
|
||||||
int visiblePos = getVisiblePos(entry);
|
int visiblePos = getVisiblePos(entry);
|
||||||
linearLayoutManager.scrollToPositionWithOffset(visiblePos, 0);
|
linearLayoutManager.scrollToPositionWithOffset(visiblePos, 0);
|
||||||
}
|
}
|
||||||
@@ -431,6 +433,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
private boolean hasVisibleDescendants(ForumEntry forumEntry) {
|
private boolean hasVisibleDescendants(ForumEntry forumEntry) {
|
||||||
int visiblePos = getVisiblePos(forumEntry);
|
int visiblePos = getVisiblePos(forumEntry);
|
||||||
int levelLimit = forumEntry.getLevel();
|
int levelLimit = forumEntry.getLevel();
|
||||||
|
// TODO This loop doesn't really loop. @ernir please review!
|
||||||
for (int i = visiblePos + 1; i < getItemCount(); i++) {
|
for (int i = visiblePos + 1; i < getItemCount(); i++) {
|
||||||
ForumEntry entry = getVisibleEntry(i);
|
ForumEntry entry = getVisibleEntry(i);
|
||||||
if (entry.getLevel() <= levelLimit)
|
if (entry.getLevel() <= levelLimit)
|
||||||
@@ -456,7 +459,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplyEntryById(byte[] id) {
|
void setReplyEntryById(byte[] id) {
|
||||||
MessageId messageId = new MessageId(id);
|
MessageId messageId = new MessageId(id);
|
||||||
for (ForumEntry entry : forumEntries) {
|
for (ForumEntry entry : forumEntries) {
|
||||||
if (entry.getMessageId().equals(messageId)) {
|
if (entry.getMessageId().equals(messageId)) {
|
||||||
@@ -466,7 +469,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplyEntry(ForumEntry entry) {
|
void setReplyEntry(ForumEntry entry) {
|
||||||
if (replyEntry != null) {
|
if (replyEntry != null) {
|
||||||
notifyItemChanged(getVisiblePos(replyEntry));
|
notifyItemChanged(getVisiblePos(replyEntry));
|
||||||
}
|
}
|
||||||
@@ -531,7 +534,7 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
@Nullable
|
||||||
public ForumEntry getVisibleEntry(int position) {
|
public ForumEntry getVisibleEntry(int position) {
|
||||||
int levelLimit = UNDEFINED;
|
int levelLimit = UNDEFINED;
|
||||||
for (ForumEntry forumEntry : forumEntries) {
|
for (ForumEntry forumEntry : forumEntries) {
|
||||||
@@ -629,9 +632,10 @@ public class ForumActivity extends BriarActivity implements
|
|||||||
} else {
|
} else {
|
||||||
ui.lvlText.setVisibility(GONE);
|
ui.lvlText.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
|
ui.authorText.setText(data.getAuthor());
|
||||||
ui.dateText.setText(DateUtils
|
ui.dateText.setText(DateUtils
|
||||||
.getRelativeTimeSpanString(ForumActivity.this,
|
.getRelativeTimeSpanString(ForumActivity.this,
|
||||||
data.getTimestamp()) + " " + data.getAuthor());
|
data.getTimestamp()));
|
||||||
ui.trust.setTrustLevel(data.getStatus());
|
ui.trust.setTrustLevel(data.getStatus());
|
||||||
|
|
||||||
int replies = getReplyCount(data);
|
int replies = getReplyCount(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user