Added forum settings button to GroupActivity.

This commit is contained in:
akwizgran
2014-05-02 10:04:28 +01:00
parent faaed862d5
commit 2165b26553

View File

@@ -24,6 +24,7 @@ import javax.inject.Inject;
import org.briarproject.R; import org.briarproject.R;
import org.briarproject.android.BriarActivity; import org.briarproject.android.BriarActivity;
import org.briarproject.android.util.ElasticHorizontalSpace;
import org.briarproject.android.util.HorizontalBorder; import org.briarproject.android.util.HorizontalBorder;
import org.briarproject.android.util.ListLoadingProgressBar; import org.briarproject.android.util.ListLoadingProgressBar;
import org.briarproject.api.Author; import org.briarproject.api.Author;
@@ -67,11 +68,12 @@ OnClickListener, OnItemClickListener {
private GroupAdapter adapter = null; private GroupAdapter adapter = null;
private ListView list = null; private ListView list = null;
private ListLoadingProgressBar loading = null; private ListLoadingProgressBar loading = null;
private ImageButton composeButton = null, configureButton = null;
// Fields that are accessed from background threads must be volatile // Fields that are accessed from background threads must be volatile
@Inject private volatile DatabaseComponent db; @Inject private volatile DatabaseComponent db;
private volatile GroupId groupId = null; private volatile GroupId groupId = null;
private volatile String groupName = null; private volatile Group group = null;
@Override @Override
public void onCreate(Bundle state) { public void onCreate(Bundle state) {
@@ -114,11 +116,21 @@ OnClickListener, OnItemClickListener {
footer.setGravity(CENTER); footer.setGravity(CENTER);
Resources res = getResources(); Resources res = getResources();
footer.setBackgroundColor(res.getColor(R.color.button_bar_background)); footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
ImageButton composeButton = new ImageButton(this); footer.addView(new ElasticHorizontalSpace(this));
composeButton = new ImageButton(this);
composeButton.setBackgroundResource(0); composeButton.setBackgroundResource(0);
composeButton.setImageResource(R.drawable.content_new_email); composeButton.setImageResource(R.drawable.content_new_email);
composeButton.setOnClickListener(this); composeButton.setOnClickListener(this);
footer.addView(composeButton); footer.addView(composeButton);
footer.addView(new ElasticHorizontalSpace(this));
configureButton = new ImageButton(this);
configureButton.setBackgroundResource(0);
configureButton.setImageResource(R.drawable.action_settings);
configureButton.setOnClickListener(this);
footer.addView(configureButton);
footer.addView(new ElasticHorizontalSpace(this));
layout.addView(footer); layout.addView(footer);
setContentView(layout); setContentView(layout);
@@ -137,8 +149,7 @@ OnClickListener, OnItemClickListener {
public void run() { public void run() {
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
Group g = db.getGroup(groupId); group = db.getGroup(groupId);
groupName = g.getName();
long duration = System.currentTimeMillis() - now; long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO)) if(LOG.isLoggable(INFO))
LOG.info("Loading group " + duration + " ms"); LOG.info("Loading group " + duration + " ms");
@@ -156,7 +167,7 @@ OnClickListener, OnItemClickListener {
private void displayGroupName() { private void displayGroupName() {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
setTitle(groupName); setTitle(group.getName());
} }
}); });
} }
@@ -315,11 +326,20 @@ OnClickListener, OnItemClickListener {
} }
public void onClick(View view) { public void onClick(View view) {
Intent i = new Intent(this, WriteGroupPostActivity.class); if(view == composeButton) {
i.putExtra("briar.GROUP_ID", groupId.getBytes()); Intent i = new Intent(this, WriteGroupPostActivity.class);
i.putExtra("briar.GROUP_NAME", groupName); i.putExtra("briar.GROUP_ID", groupId.getBytes());
i.putExtra("briar.MIN_TIMESTAMP", getMinTimestampForNewMessage()); i.putExtra("briar.GROUP_NAME", group.getName());
startActivity(i); i.putExtra("briar.MIN_TIMESTAMP", getMinTimestampForNewMessage());
startActivity(i);
} else if(view == configureButton) {
Intent i = new Intent(this, ConfigureGroupActivity.class);
i.putExtra("briar.GROUP_ID", groupId.getBytes());
i.putExtra("briar.GROUP_NAME", group.getName());
i.putExtra("briar.GROUP_SALT", group.getSalt());
i.putExtra("briar.SUBSCRIBED", true);
startActivity(i);
}
} }
private long getMinTimestampForNewMessage() { private long getMinTimestampForNewMessage() {
@@ -342,7 +362,7 @@ OnClickListener, OnItemClickListener {
MessageHeader item = adapter.getItem(position).getHeader(); MessageHeader item = adapter.getItem(position).getHeader();
Intent i = new Intent(this, ReadGroupPostActivity.class); Intent i = new Intent(this, ReadGroupPostActivity.class);
i.putExtra("briar.GROUP_ID", groupId.getBytes()); i.putExtra("briar.GROUP_ID", groupId.getBytes());
i.putExtra("briar.GROUP_NAME", groupName); i.putExtra("briar.GROUP_NAME", group.getName());
i.putExtra("briar.MESSAGE_ID", item.getId().getBytes()); i.putExtra("briar.MESSAGE_ID", item.getId().getBytes());
Author author = item.getAuthor(); Author author = item.getAuthor();
if(author != null) i.putExtra("briar.AUTHOR_NAME", author.getName()); if(author != null) i.putExtra("briar.AUTHOR_NAME", author.getName());