Implement new empty state icons

This commit is contained in:
Torsten Grote
2018-08-17 12:09:30 -03:00
parent 169c59349e
commit 5ed0e9efec
17 changed files with 509 additions and 33 deletions

View File

@@ -81,7 +81,9 @@ public class FeedFragment extends BaseFragment implements
list = v.findViewById(R.id.postList);
list.setLayoutManager(layoutManager);
list.setAdapter(adapter);
list.setEmptyImage(R.drawable.ic_empty_state_blog);
list.setEmptyText(R.string.blogs_feed_empty_state);
list.setEmptyAction(R.string.blogs_feed_empty_state_action);
return v;
}

View File

@@ -148,7 +148,9 @@ public class ContactListFragment extends BaseFragment implements EventListener {
list = contentView.findViewById(R.id.list);
list.setLayoutManager(new LinearLayoutManager(getContext()));
list.setAdapter(adapter);
list.setEmptyImage(R.drawable.ic_empty_state_contact_list);
list.setEmptyText(getString(R.string.no_contacts));
list.setEmptyAction(getString(R.string.no_contacts_action));
return contentView;
}

View File

@@ -97,7 +97,6 @@ public class ForumListFragment extends BaseEventFragment implements
list = contentView.findViewById(R.id.forumList);
list.setLayoutManager(new LinearLayoutManager(getActivity()));
list.setAdapter(adapter);
list.setEmptyText(getString(R.string.no_forums));
snackbar = Snackbar.make(list, "", LENGTH_INDEFINITE);
snackbar.getView().setBackgroundResource(R.color.briar_primary);

View File

@@ -69,7 +69,9 @@ public class GroupListFragment extends BaseFragment implements
adapter = new GroupListAdapter(getContext(), this);
list = v.findViewById(R.id.list);
list.setEmptyImage(R.drawable.ic_empty_state_group_list);
list.setEmptyText(R.string.groups_list_empty);
list.setEmptyAction(R.string.groups_list_empty_action);
list.setLayoutManager(new LinearLayoutManager(getContext()));
list.setAdapter(adapter);

View File

@@ -2,8 +2,13 @@ package org.briarproject.briar.android.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.constraint.Group;
import android.support.v7.widget.AppCompatImageView;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.util.AttributeSet;
@@ -29,7 +34,9 @@ public class BriarRecyclerView extends FrameLayout {
private final Handler handler = new Handler(Looper.getMainLooper());
private RecyclerView recyclerView;
private TextView emptyView;
private Group emptyState;
private AppCompatImageView emptyImage;
private TextView emptyText, emptyAction;
private ProgressBar progressBar;
private RecyclerView.AdapterDataObserver emptyObserver;
private Runnable refresher = null;
@@ -51,9 +58,15 @@ public class BriarRecyclerView extends FrameLayout {
R.styleable.BriarRecyclerView);
isScrollingToEnd = attributes
.getBoolean(R.styleable.BriarRecyclerView_scrollToEnd, true);
Drawable drawable = attributes
.getDrawable(R.styleable.BriarRecyclerView_emptyImage);
if (drawable != null) setEmptyImage(drawable);
String emtpyText =
attributes.getString(R.styleable.BriarRecyclerView_emptyText);
if (emtpyText != null) setEmptyText(emtpyText);
String emtpyAction =
attributes.getString(R.styleable.BriarRecyclerView_emptyAction);
if (emtpyAction != null) setEmptyAction(emtpyAction);
attributes.recycle();
}
@@ -68,7 +81,10 @@ public class BriarRecyclerView extends FrameLayout {
R.layout.briar_recycler_view, this, true);
recyclerView = v.findViewById(R.id.recyclerView);
emptyView = v.findViewById(R.id.emptyView);
emptyState = v.findViewById(R.id.emptyState);
emptyImage = v.findViewById(R.id.emptyImage);
emptyText = v.findViewById(R.id.emptyText);
emptyAction = v.findViewById(R.id.emptyAction);
progressBar = v.findViewById(R.id.progressBar);
showProgressBar();
@@ -129,20 +145,40 @@ public class BriarRecyclerView extends FrameLayout {
}
}
public void setEmptyText(String text) {
public void setEmptyImage(Drawable drawable) {
if (recyclerView == null) initViews();
emptyView.setText(text);
emptyImage.setImageDrawable(drawable);
}
public void setEmptyText(int res) {
public void setEmptyImage(@DrawableRes int res) {
if (recyclerView == null) initViews();
emptyView.setText(res);
emptyImage.setImageResource(res);
}
public void setEmptyText(String text) {
if (recyclerView == null) initViews();
emptyText.setText(text);
}
public void setEmptyText(@StringRes int res) {
if (recyclerView == null) initViews();
emptyText.setText(res);
}
public void setEmptyAction(String text) {
if (recyclerView == null) initViews();
emptyAction.setText(text);
}
public void setEmptyAction(@StringRes int res) {
if (recyclerView == null) initViews();
emptyAction.setText(res);
}
public void showProgressBar() {
if (recyclerView == null) initViews();
recyclerView.setVisibility(INVISIBLE);
emptyView.setVisibility(INVISIBLE);
emptyState.setVisibility(INVISIBLE);
progressBar.setVisibility(VISIBLE);
}
@@ -151,11 +187,11 @@ public class BriarRecyclerView extends FrameLayout {
Adapter adapter = recyclerView.getAdapter();
if (adapter != null) {
if (adapter.getItemCount() == 0) {
emptyView.setVisibility(VISIBLE);
emptyState.setVisibility(VISIBLE);
recyclerView.setVisibility(INVISIBLE);
} else {
// use GONE here so empty view doesn't use space on small lists
emptyView.setVisibility(GONE);
emptyState.setVisibility(GONE);
recyclerView.setVisibility(VISIBLE);
}
progressBar.setVisibility(GONE);

View File

@@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="96dp"
android:viewportHeight="156"
android:viewportWidth="162">
<path
android:fillColor="#ffffff"
android:pathData="M140.87,53.647H91.565V64.235H140.87V53.647Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M140.869,99.529V88.941H115.512L126.077,99.529H140.869Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M140.869,71.294H97.904L108.469,81.882H140.869V71.294Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M147.912,14.823H41.556L84.521,57.882V28.941H147.912V120.706H147.208L157.773,131.294C160.59,128.47 161.999,124.941 161.999,120.706V28.941C161.999,21.176 155.66,14.823 147.912,14.823Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M129.6,120.706L84.522,75.529L23.948,14.823L9.157,0L0,9.176L10.565,19.765C8.452,21.882 7.043,25.412 7.043,28.941V120.706C7.043,128.471 13.383,134.824 21.13,134.824H125.374L146.504,156L155.661,146.824L143.687,134.824L129.6,120.706ZM84.522,120.706V93.882L111.287,120.706H84.522Z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportHeight="164"
android:viewportWidth="164">
<path
android:fillColor="#ffffff"
android:pathData="M27.334,0L27.334,13.666L136.668,13.666L136.668,0L27.334,0zM27.334,27.334C19.817,27.334 13.666,33.483 13.666,41L13.666,123C13.666,130.517 19.817,136.668 27.334,136.668L136.668,136.668C144.184,136.668 150.332,130.517 150.332,123L150.332,41C150.332,33.483 144.184,27.334 136.668,27.334L27.334,27.334zM82.15,44.758C89.592,44.758 95.348,46.477 99.42,49.914C103.525,53.351 105.576,58.239 105.576,64.58C105.576,67.35 105.027,69.869 103.926,72.139C102.825,74.408 101.055,76.728 98.619,79.098L92.863,84.453C91.228,86.022 90.093,87.64 89.459,89.309C88.825,90.944 88.475,93.03 88.408,95.566L74.092,95.566C74.092,90.694 74.641,86.856 75.742,84.053C76.843,81.216 78.63,78.762 81.1,76.693C83.569,74.624 85.437,72.739 86.705,71.037C88.006,69.302 88.658,67.401 88.658,65.332C88.658,60.293 86.489,57.771 82.15,57.771C80.148,57.771 78.53,58.506 77.295,59.975C76.06,61.443 75.409,63.429 75.342,65.932L58.424,65.932C58.49,59.257 60.592,54.068 64.73,50.363C68.869,46.626 74.675,44.758 82.15,44.758zM81.398,102.324C84.068,102.324 86.288,103.125 88.057,104.727C89.859,106.295 90.76,108.314 90.76,110.783C90.76,113.253 89.859,115.289 88.057,116.891C86.288,118.459 84.068,119.242 81.398,119.242C78.729,119.242 76.493,118.459 74.691,116.891C72.923,115.289 72.039,113.253 72.039,110.783C72.039,108.314 72.923,106.295 74.691,104.727C76.493,103.125 78.729,102.324 81.398,102.324zM27.334,150.332L27.334,164L136.668,164L136.668,150.332L27.334,150.332z"/>
</vector>

View File

@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="100dp"
android:viewportHeight="148"
android:viewportWidth="148">
<path
android:fillColor="#ffffff"
android:pathData="M107.266,74.679C111.34,74.679 114.055,71.964 114.055,67.89V6.789C114.055,2.716 111.34,0 107.266,0H24.44L99.119,74.679H107.266Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M141.211,27.156H127.633V88.257H112.697L148,123.56V33.945C148,29.872 144.606,27.156 141.211,27.156Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M8.826,1.357L0,10.183L12.22,22.403V101.835L39.376,74.679H64.495L78.074,88.257H39.376V101.835C39.376,105.908 42.092,108.624 46.165,108.624H98.44L137.817,148L146.642,139.174L8.826,1.357Z"/>
</vector>

View File

@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="100dp"
android:height="81dp"
android:viewportHeight="140"
android:viewportWidth="172">
<path
android:fillColor="#ffffff"
android:pathData="M125.091,103.444L71.927,50.556L38.309,17.111L21.109,0L10.946,10.111L31.273,30.333C31.273,31.889 31.273,32.667 31.273,34.222C31.273,47.444 41.437,57.556 54.727,57.556C56.291,57.556 57.073,57.556 58.637,56.778L78.182,76.222C69.582,74.667 60.982,73.111 54.727,73.111C36.745,73.111 0,82.444 0,100.333V119.778H109.455V107.333L142.291,140L152.455,129.889L142.291,119.778L125.091,103.444Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M117.273,57.555C130.227,57.555 140.728,47.108 140.728,34.222C140.728,21.335 130.227,10.888 117.273,10.888C104.319,10.888 93.818,21.335 93.818,34.222C93.818,47.108 104.319,57.555 117.273,57.555Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M78.182,34.222C78.182,20.999 68.018,10.888 54.727,10.888C53.945,10.888 53.164,10.888 52.382,10.888L78.182,36.555C78.182,35.777 78.182,34.999 78.182,34.222Z"/>
<path
android:fillColor="#ffffff"
android:pathData="M117.272,73.11C116.49,73.11 115.709,73.11 114.927,73.11L161.836,119.777H172V100.333C172,82.444 135.254,73.11 117.272,73.11Z"/>
</vector>

View File

@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/relativeLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -10,24 +12,78 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
tools:listitem="@layout/list_item_contact"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/list_item_contact"
tools:visibility="visible"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:visibility="invisible"/>
<TextView
android:id="@+id/emptyView"
<android.support.constraint.Group
android:id="@+id/emptyState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:constraint_referenced_ids="emptyImage, emptyText, emptyAction"
tools:visibility="invisible"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/emptyImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/emptyText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:tint="?attr/colorControlNormal"
tools:src="@drawable/ic_empty_state_group_list"/>
<TextView
android:id="@+id/emptyText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/margin_activity_horizontal"
android:padding="@dimen/margin_large"
android:text="@string/no_data"
android:textSize="@dimen/text_size_large"
app:layout_constraintBottom_toTopOf="@+id/emptyAction"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emptyImage"
tools:text="@string/no_contacts"/>
</RelativeLayout>
<TextView
android:id="@+id/emptyAction"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="@dimen/margin_large"
android:paddingLeft="@dimen/margin_large"
android:paddingRight="@dimen/margin_large"
android:text="@string/no_data"
android:textSize="@dimen/text_size_small"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/emptyText"
tools:text="@string/no_contacts_action"/>
</android.support.constraint.ConstraintLayout>

View File

@@ -1,15 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<org.briarproject.briar.android.view.BriarRecyclerView
android:id="@+id/forumList"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.briarproject.briar.android.view.BriarRecyclerView
android:id="@+id/forumList"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="org.briarproject.briar.android.view.BriarRecyclerViewBehavior"/>
</android.support.design.widget.CoordinatorLayout>
android:layout_height="match_parent"
app:emptyAction="@string/no_forums_action"
app:emptyImage="@drawable/ic_empty_state_forum_list"
app:emptyText="@string/no_forums"
app:layout_behavior="org.briarproject.briar.android.view.BriarRecyclerViewBehavior"/>

View File

@@ -3,7 +3,9 @@
<declare-styleable name="BriarRecyclerView">
<attr name="scrollToEnd" format="boolean" />
<attr name="emptyImage" format="integer" />
<attr name="emptyText" format="string" />
<attr name="emptyAction" format="string" />
</declare-styleable>
<declare-styleable name="AuthorView">

View File

@@ -121,7 +121,8 @@
<string name="sorry">Sorry</string>
<!-- Contacts and Private Conversations-->
<string name="no_contacts">No contacts to show\n\nTap the + icon to add a contact</string>
<string name="no_contacts">No contacts to show</string>
<string name="no_contacts_action">Tap the + icon to add a contact</string>
<string name="date_no_private_messages">No messages.</string>
<string name="no_private_messages">No messages to show</string>
<string name="message_hint">Type message</string>
@@ -177,7 +178,8 @@
</plurals>
<!-- Private Groups -->
<string name="groups_list_empty">No groups to show\n\nTap the + icon to create a group, or ask your contacts to share groups with you</string>
<string name="groups_list_empty">No groups to show</string>
<string name="groups_list_empty_action">Tap the + icon to create a group, or ask your contacts to share groups with you</string>
<string name="groups_created_by">Created by %s</string>
<plurals name="messages">
<item quantity="one">%d message</item>
@@ -233,7 +235,8 @@
<string name="groups_reveal_invisible">Contact relationship is not visible to the group</string>
<!-- Forums -->
<string name="no_forums">No forums to show\n\nTap the + icon to create a forum, or ask your contacts to share forums with you</string>
<string name="no_forums">No forums to show</string>
<string name="no_forums_action">Tap the + icon to create a forum, or ask your contacts to share forums with you</string>
<string name="create_forum_title">Create Forum</string>
<string name="choose_forum_hint">Choose a name for your forum</string>
<string name="create_forum_button">Create Forum</string>
@@ -293,7 +296,8 @@
<string name="blogs_blog_post_created">Blog Post Created</string>
<string name="blogs_blog_post_received">New Blog Post Received</string>
<string name="blogs_blog_post_scroll_to">Scroll To</string>
<string name="blogs_feed_empty_state">No posts to show\n\nPosts from your contacts and blogs you subscribe to will appear here\n\nTap the pen icon to write a post</string>
<string name="blogs_feed_empty_state">No posts to show</string>
<string name="blogs_feed_empty_state_action">Posts from your contacts and blogs you subscribe to will appear here\n\nTap the pen icon to write a post</string>
<string name="blogs_remove_blog">Remove Blog</string>
<string name="blogs_remove_blog_dialog_message">Are you sure that you want to remove this blog?\n\nPosts will be removed from your device but not from other people\'s devices.\n\nAny contacts you\'ve shared this blog with might stop receiving updates.</string>
<string name="blogs_remove_blog_ok">Remove</string>