Skip to content
Snippets Groups Projects
Commit 3d4abee1 authored by akwizgran's avatar akwizgran
Browse files

Merge branch '305-forum-list-snackbar' into 'master'

Add Snackbar and Toolbar Button to Forum List

This MR is a small change that replaces the custom UI elements in
the forum list with a Snackbar and a Toolbar menu.

It also fixes a background color that was still present with fragment from the NavDrawer.

Before:

![before](/uploads/6dcc545827c035dcffcdf7863893753e/before.png)

After:

![after](/uploads/427de01d8bec779ee81e6ebded3fcd2b/after.png)

It addresses one part (2b) of #305 and is part of #121.


See merge request !163
parents ea973b61 82e1ef0e
No related branches found
No related tags found
No related merge requests found
Showing
with 61 additions and 53 deletions
briar-android/res/drawable-hdpi/social_new_chat.png

716 B

briar-android/res/drawable-hdpi/social_reply.png

1.45 KiB

briar-android/res/drawable-hdpi/social_share_old.png

1.66 KiB

briar-android/res/drawable-mdpi/social_new_chat.png

583 B

briar-android/res/drawable-mdpi/social_reply.png

1.31 KiB

briar-android/res/drawable-mdpi/social_share_old.png

1.36 KiB

briar-android/res/drawable-xhdpi/social_new_chat.png

830 B

briar-android/res/drawable-xhdpi/social_reply.png

1.66 KiB

briar-android/res/drawable-xhdpi/social_share_old.png

1.94 KiB

......@@ -22,15 +22,13 @@
<FrameLayout
android:id="@+id/content_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/default_background"/>
android:layout_height="match_parent"/>
<RelativeLayout
android:id="@+id/container_progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@color/default_background"
android:visibility="invisible"
tools:visibility="visible">
......
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_create_forum"
android:icon="@drawable/ic_add_white"
android:title="@string/create_forum_button"
app:showAsAction="ifRoom"/>
</menu>
\ No newline at end of file
......@@ -31,10 +31,11 @@
<color name="briar_text_primary_inverse">#ffffff</color>
<color name="briar_text_secondary">#333333</color>
<color name="briar_text_tertiary">#333333</color>
<color name="briar_button_positive">#06b9ff</color>
<color name="briar_button_negative">#ff0000</color>
<!-- this is needed as preference_category_material layout uses this color as the text color -->
<color name="preference_fallback_accent_color">@color/briar_accent</color>
<color name="default_background">#ffffff</color>
<color name="default_separator">#000000</color>
<color name="default_separator_inverted">#ffffff</color>
<color name="menu_background">#FFFFFF</color>
......
......@@ -77,6 +77,7 @@
<item quantity="one">%d forum shared by contacts</item>
<item quantity="other">%d forums shared by contacts</item>
</plurals>
<string name="show_forums">Show</string>
<string name="unsubscribe">Unsubscribe</string>
<string name="unsubscribed_toast">Unsubscribed</string>
<string name="no_forum_posts">No posts</string>
......
......@@ -67,13 +67,13 @@
<style name="BriarButton.Default"/>
<style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textColor">#ff0000</item>
<item name="android:textColor">@color/briar_button_negative</item>
<item name="android:textSize">@dimen/text_size_medium</item>
<item name="android:padding">@dimen/margin_large</item>
</style>
<style name="BriarButtonFlat.Positive" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textColor">#06b9ff</item>
<item name="android:textColor">@color/briar_button_positive</item>
<item name="android:textSize">@dimen/text_size_medium</item>
<item name="android:padding">@dimen/margin_large</item>
</style>
......
......@@ -98,7 +98,7 @@ public class ContactListFragment extends BaseEventFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View contentView =
inflater.inflate(R.layout.activity_contact_list, container,
inflater.inflate(R.layout.fragment_contact_list, container,
false);
BaseContactListAdapter.OnItemClickListener onItemClickListener =
......
package org.briarproject.android.forum;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
......@@ -21,8 +23,6 @@ import android.widget.Toast;
import org.briarproject.R;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.fragment.BaseEventFragment;
import org.briarproject.android.util.HorizontalBorder;
import org.briarproject.android.util.LayoutUtils;
import org.briarproject.android.util.ListLoadingProgressBar;
import org.briarproject.api.db.DbException;
import org.briarproject.api.db.NoSuchGroupException;
......@@ -43,12 +43,12 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import static android.support.design.widget.Snackbar.LENGTH_INDEFINITE;
import static android.view.Gravity.CENTER;
import static android.view.Gravity.CENTER_HORIZONTAL;
import static android.view.Menu.NONE;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static android.widget.LinearLayout.HORIZONTAL;
import static android.widget.LinearLayout.VERTICAL;
import static android.widget.Toast.LENGTH_SHORT;
import static java.util.logging.Level.INFO;
......@@ -56,7 +56,6 @@ import static java.util.logging.Level.WARNING;
import static org.briarproject.android.BriarActivity.GROUP_ID;
import static org.briarproject.android.forum.ForumActivity.FORUM_NAME;
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP;
import static org.briarproject.android.util.CommonLayoutParams.MATCH_WRAP_1;
public class ForumListFragment extends BaseEventFragment implements
......@@ -82,8 +81,7 @@ public class ForumListFragment extends BaseEventFragment implements
private ForumListAdapter adapter = null;
private ListView list = null;
private ListLoadingProgressBar loading = null;
private TextView available = null;
private ImageButton newForumButton = null;
private Snackbar snackbar;
// Fields that are accessed from background threads must be volatile
@Inject protected volatile ForumManager forumManager;
......@@ -93,13 +91,14 @@ public class ForumListFragment extends BaseEventFragment implements
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
setHasOptionsMenu(true);
LinearLayout layout = new LinearLayout(getContext());
layout.setLayoutParams(MATCH_MATCH);
layout.setOrientation(VERTICAL);
layout.setGravity(CENTER_HORIZONTAL);
int pad = LayoutUtils.getPadding(getContext());
empty = new TextView(getContext());
empty.setLayoutParams(MATCH_WRAP_1);
empty.setGravity(CENTER);
......@@ -121,32 +120,6 @@ public class ForumListFragment extends BaseEventFragment implements
loading = new ListLoadingProgressBar(getContext());
layout.addView(loading);
available = new TextView(getContext());
available.setLayoutParams(MATCH_WRAP);
available.setGravity(CENTER);
available.setTextSize(18);
available.setPadding(pad, pad, pad, pad);
Resources res = getResources();
int background = res.getColor(R.color.forums_available_background);
available.setBackgroundColor(background);
available.setOnClickListener(this);
available.setVisibility(GONE);
layout.addView(available);
layout.addView(new HorizontalBorder(getContext()));
LinearLayout footer = new LinearLayout(getContext());
footer.setLayoutParams(MATCH_WRAP);
footer.setOrientation(HORIZONTAL);
footer.setGravity(CENTER);
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
newForumButton = new ImageButton(getContext());
newForumButton.setBackgroundResource(0);
newForumButton.setImageResource(R.drawable.social_new_chat);
newForumButton.setOnClickListener(this);
footer.addView(newForumButton);
layout.addView(footer);
return layout;
}
......@@ -163,9 +136,36 @@ public class ForumListFragment extends BaseEventFragment implements
@Override
public void onResume() {
super.onResume();
snackbar = Snackbar.make(getView(), "", LENGTH_INDEFINITE);
snackbar.getView().setBackgroundResource(R.color.briar_primary);
snackbar.setAction(R.string.show_forums, this);
snackbar.setActionTextColor(ContextCompat
.getColor(getContext(), R.color.briar_button_positive));
loadHeaders();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.forum_list_actions, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_create_forum:
Intent intent =
new Intent(getContext(), CreateForumActivity.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void loadHeaders() {
clearHeaders();
listener.runOnDbThread(new Runnable() {
......@@ -203,7 +203,7 @@ public class ForumListFragment extends BaseEventFragment implements
public void run() {
empty.setVisibility(GONE);
list.setVisibility(GONE);
available.setVisibility(GONE);
snackbar.dismiss();
loading.setVisibility(VISIBLE);
adapter.clear();
}
......@@ -240,10 +240,10 @@ public class ForumListFragment extends BaseEventFragment implements
listener.runOnUiThread(new Runnable() {
public void run() {
if (availableCount == 0) {
available.setVisibility(GONE);
snackbar.dismiss();
} else {
available.setVisibility(VISIBLE);
available.setText(getResources().getQuantityString(
snackbar.show();
snackbar.setText(getResources().getQuantityString(
R.plurals.forums_shared, availableCount,
availableCount));
}
......@@ -363,12 +363,8 @@ public class ForumListFragment extends BaseEventFragment implements
}
public void onClick(View view) {
if (view == available) {
startActivity(new Intent(getContext(),
AvailableForumsActivity.class));
} else if (view == newForumButton) {
startActivity(new Intent(getContext(), CreateForumActivity.class));
}
// snackbar click
startActivity(new Intent(getContext(), AvailableForumsActivity.class));
}
public void onItemClick(AdapterView<?> parent, View view, int position,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment