Moved attachments up, small layout improvements

pull/146/head
M66B 7 years ago
parent e310c43bf2
commit c5a489bb61

@ -172,6 +172,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private TextView tvHeaders; private TextView tvHeaders;
private ProgressBar pbHeaders; private ProgressBar pbHeaders;
private RecyclerView rvAttachment;
private BottomNavigationView bnvActions; private BottomNavigationView bnvActions;
private View vSeparatorBody; private View vSeparatorBody;
@ -180,14 +182,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private TextView tvBody; private TextView tvBody;
private ProgressBar pbBody; private ProgressBar pbBody;
private RecyclerView rvAttachment;
private AdapterAttachment adapter;
private Group grpAddress; private Group grpAddress;
private Group grpHeaders; private Group grpHeaders;
private Group grpAttachments; private Group grpAttachments;
private Group grpExpanded; private Group grpExpanded;
private AdapterAttachment adapter;
private LiveData<List<EntityAttachment>> liveAttachments = null; private LiveData<List<EntityAttachment>> liveAttachments = null;
private Observer<List<EntityAttachment>> observerAttachments = null; private Observer<List<EntityAttachment>> observerAttachments = null;
@ -227,14 +227,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvHeaders = itemView.findViewById(R.id.tvHeaders); tvHeaders = itemView.findViewById(R.id.tvHeaders);
pbHeaders = itemView.findViewById(R.id.pbHeaders); pbHeaders = itemView.findViewById(R.id.pbHeaders);
bnvActions = itemView.findViewById(R.id.bnvActions);
vSeparatorBody = itemView.findViewById(R.id.vSeparatorBody);
btnHtml = itemView.findViewById(R.id.btnHtml);
btnImages = itemView.findViewById(R.id.btnImages);
tvBody = itemView.findViewById(R.id.tvBody);
pbBody = itemView.findViewById(R.id.pbBody);
rvAttachment = itemView.findViewById(R.id.rvAttachment); rvAttachment = itemView.findViewById(R.id.rvAttachment);
rvAttachment.setHasFixedSize(false); rvAttachment.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(context); LinearLayoutManager llm = new LinearLayoutManager(context);
@ -244,6 +236,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
adapter = new AdapterAttachment(context, owner, true); adapter = new AdapterAttachment(context, owner, true);
rvAttachment.setAdapter(adapter); rvAttachment.setAdapter(adapter);
bnvActions = itemView.findViewById(R.id.bnvActions);
vSeparatorBody = itemView.findViewById(R.id.vSeparatorBody);
btnHtml = itemView.findViewById(R.id.btnHtml);
btnImages = itemView.findViewById(R.id.btnImages);
tvBody = itemView.findViewById(R.id.tvBody);
pbBody = itemView.findViewById(R.id.pbBody);
grpAddress = itemView.findViewById(R.id.grpAddress); grpAddress = itemView.findViewById(R.id.grpAddress);
grpHeaders = itemView.findViewById(R.id.grpHeaders); grpHeaders = itemView.findViewById(R.id.grpHeaders);
grpAttachments = itemView.findViewById(R.id.grpAttachments); grpAttachments = itemView.findViewById(R.id.grpAttachments);
@ -481,6 +481,26 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bodyTask.load(context, owner, args); bodyTask.load(context, owner, args);
} }
// Observe attachments
observerAttachments = new Observer<List<EntityAttachment>>() {
@Override
public void onChanged(@Nullable List<EntityAttachment> attachments) {
if (attachments == null)
attachments = new ArrayList<>();
adapter.set(attachments);
if (message.content) {
Bundle args = new Bundle();
args.putSerializable("message", message);
bodyTask.load(context, owner, args);
}
}
};
liveAttachments = db.attachment().liveAttachments(message.id);
liveAttachments.observe(owner, observerAttachments);
// Setup action
Bundle sargs = new Bundle(); Bundle sargs = new Bundle();
sargs.putLong("account", message.account); sargs.putLong("account", message.account);
@ -532,25 +552,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Helper.unexpectedError(context, owner, ex); Helper.unexpectedError(context, owner, ex);
} }
}.load(context, owner, sargs); }.load(context, owner, sargs);
// Observe attachments
observerAttachments = new Observer<List<EntityAttachment>>() {
@Override
public void onChanged(@Nullable List<EntityAttachment> attachments) {
if (attachments == null)
attachments = new ArrayList<>();
adapter.set(attachments);
if (message.content) {
Bundle args = new Bundle();
args.putSerializable("message", message);
bodyTask.load(context, owner, args);
}
}
};
liveAttachments = db.attachment().liveAttachments(message.id);
liveAttachments.observe(owner, observerAttachments);
} }
itemView.setActivated(selectionTracker != null && selectionTracker.isSelected(message.id)); itemView.setActivated(selectionTracker != null && selectionTracker.isSelected(message.id));

@ -473,6 +473,7 @@
android:layout_marginTop="3dp" android:layout_marginTop="3dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:fontFamily="monospace" android:fontFamily="monospace"
android:minHeight="24dp"
android:text="Headers" android:text="Headers"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textIsSelectable="true" android:textIsSelectable="true"
@ -487,10 +488,33 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:indeterminate="true" android:indeterminate="true"
app:layout_constraintBottom_toTopOf="@+id/bnvActions" app:layout_constraintBottom_toBottomOf="@id/tvHeaders"
app:layout_constraintEnd_toEndOf="@id/tvHeaders" app:layout_constraintEnd_toEndOf="@id/tvHeaders"
app:layout_constraintStart_toStartOf="@id/tvHeaders" app:layout_constraintStart_toStartOf="@id/tvHeaders"
app:layout_constraintTop_toBottomOf="@id/vSeparatorHeaders" /> app:layout_constraintTop_toTopOf="@id/tvHeaders" />
<View
android:id="@+id/vSeparatorAttachments"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="3dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHeaders" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvAttachment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
<com.google.android.material.bottomnavigation.BottomNavigationView <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnvActions" android:id="@+id/bnvActions"
@ -503,7 +527,7 @@
app:labelVisibilityMode="labeled" app:labelVisibilityMode="labeled"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHeaders" app:layout_constraintTop_toBottomOf="@id/rvAttachment"
app:menu="@menu/action_message" /> app:menu="@menu/action_message" />
<View <View
@ -571,34 +595,10 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:indeterminate="true" android:indeterminate="true"
app:layout_constraintBottom_toTopOf="@+id/vSeparatorAttachments" app:layout_constraintBottom_toBottomOf="@id/tvBody"
app:layout_constraintEnd_toEndOf="@id/tvBody" app:layout_constraintEnd_toEndOf="@id/tvBody"
app:layout_constraintStart_toStartOf="@id/tvBody" app:layout_constraintStart_toStartOf="@id/tvBody"
app:layout_constraintTop_toBottomOf="@id/bnvActions" /> app:layout_constraintTop_toTopOf="@id/tvBody" />
<View
android:id="@+id/vSeparatorAttachments"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="3dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBody" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvAttachment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments"
app:layout_goneMarginBottom="3dp" />
<View <View
android:id="@+id/vSeparator" android:id="@+id/vSeparator"
@ -606,7 +606,7 @@
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/colorSeparator" android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAttachment" /> app:layout_constraintTop_toBottomOf="@id/tvBody" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpAddress" android:id="@+id/grpAddress"

@ -469,6 +469,7 @@
android:layout_marginTop="3dp" android:layout_marginTop="3dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:fontFamily="monospace" android:fontFamily="monospace"
android:minHeight="24dp"
android:text="Headers" android:text="Headers"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textIsSelectable="true" android:textIsSelectable="true"
@ -483,10 +484,33 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:indeterminate="true" android:indeterminate="true"
app:layout_constraintBottom_toTopOf="@+id/bnvActions" app:layout_constraintBottom_toBottomOf="@id/tvHeaders"
app:layout_constraintEnd_toEndOf="@id/tvHeaders" app:layout_constraintEnd_toEndOf="@id/tvHeaders"
app:layout_constraintStart_toStartOf="@id/tvHeaders" app:layout_constraintStart_toStartOf="@id/tvHeaders"
app:layout_constraintTop_toBottomOf="@id/vSeparatorHeaders" /> app:layout_constraintTop_toTopOf="@id/tvHeaders" />
<View
android:id="@+id/vSeparatorAttachments"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="3dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHeaders" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvAttachment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
<com.google.android.material.bottomnavigation.BottomNavigationView <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnvActions" android:id="@+id/bnvActions"
@ -499,7 +523,7 @@
app:labelVisibilityMode="labeled" app:labelVisibilityMode="labeled"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHeaders" app:layout_constraintTop_toBottomOf="@id/rvAttachment"
app:menu="@menu/action_message" /> app:menu="@menu/action_message" />
<View <View
@ -567,34 +591,10 @@
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:indeterminate="true" android:indeterminate="true"
app:layout_constraintBottom_toTopOf="@+id/vSeparatorAttachments" app:layout_constraintBottom_toBottomOf="@id/tvBody"
app:layout_constraintEnd_toEndOf="@id/tvBody" app:layout_constraintEnd_toEndOf="@id/tvBody"
app:layout_constraintStart_toStartOf="@id/tvBody" app:layout_constraintStart_toStartOf="@id/tvBody"
app:layout_constraintTop_toBottomOf="@id/bnvActions" /> app:layout_constraintTop_toTopOf="@id/tvBody" />
<View
android:id="@+id/vSeparatorAttachments"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="3dp"
android:background="?attr/colorSeparator"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBody" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvAttachment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments"
app:layout_goneMarginBottom="3dp" />
<View <View
android:id="@+id/vSeparator" android:id="@+id/vSeparator"
@ -602,7 +602,7 @@
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/colorSeparator" android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAttachment" /> app:layout_constraintTop_toBottomOf="@id/tvBody" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpAddress" android:id="@+id/grpAddress"

Loading…
Cancel
Save