mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Launch appropriate activity when replying to a group/blog post.
This commit is contained in:
@@ -4,6 +4,8 @@ import static android.view.Gravity.CENTER_HORIZONTAL;
|
|||||||
import static android.widget.LinearLayout.VERTICAL;
|
import static android.widget.LinearLayout.VERTICAL;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static net.sf.briar.android.groups.ReadGroupMessageActivity.RESULT_NEXT;
|
||||||
|
import static net.sf.briar.android.groups.ReadGroupMessageActivity.RESULT_PREV;
|
||||||
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_MATCH;
|
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_MATCH;
|
||||||
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_WRAP_1;
|
import static net.sf.briar.android.widgets.CommonLayoutParams.MATCH_WRAP_1;
|
||||||
|
|
||||||
@@ -162,11 +164,11 @@ OnClickListener, OnItemClickListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int request, int result, Intent data) {
|
public void onActivityResult(int request, int result, Intent data) {
|
||||||
if(result == ReadGroupMessageActivity.RESULT_PREV) {
|
if(result == RESULT_PREV) {
|
||||||
int position = request - 1;
|
int position = request - 1;
|
||||||
if(position >= 0 && position < adapter.getCount())
|
if(position >= 0 && position < adapter.getCount())
|
||||||
displayMessage(position);
|
displayMessage(position);
|
||||||
} else if(result == ReadGroupMessageActivity.RESULT_NEXT) {
|
} else if(result == RESULT_NEXT) {
|
||||||
int position = request + 1;
|
int position = request + 1;
|
||||||
if(position >= 0 && position < adapter.getCount())
|
if(position >= 0 && position < adapter.getCount())
|
||||||
displayMessage(position);
|
displayMessage(position);
|
||||||
@@ -227,6 +229,7 @@ OnClickListener, OnItemClickListener {
|
|||||||
private void displayMessage(int position) {
|
private void displayMessage(int position) {
|
||||||
GroupMessageHeader item = adapter.getItem(position);
|
GroupMessageHeader item = adapter.getItem(position);
|
||||||
Intent i = new Intent(this, ReadGroupMessageActivity.class);
|
Intent i = new Intent(this, ReadGroupMessageActivity.class);
|
||||||
|
i.putExtra("net.sf.briar.RESTRICTED", restricted);
|
||||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||||
i.putExtra("net.sf.briar.GROUP_NAME", groupName);
|
i.putExtra("net.sf.briar.GROUP_NAME", groupName);
|
||||||
i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes());
|
i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes());
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ implements OnClickListener {
|
|||||||
new BriarServiceConnection();
|
new BriarServiceConnection();
|
||||||
|
|
||||||
@Inject private BundleEncrypter bundleEncrypter;
|
@Inject private BundleEncrypter bundleEncrypter;
|
||||||
|
private boolean restricted = false;
|
||||||
private GroupId groupId = null;
|
private GroupId groupId = null;
|
||||||
private Rating rating = UNRATED;
|
private Rating rating = UNRATED;
|
||||||
private boolean read;
|
private boolean read;
|
||||||
@@ -83,6 +84,7 @@ implements OnClickListener {
|
|||||||
super.onCreate(null);
|
super.onCreate(null);
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
|
restricted = i.getBooleanExtra("net.sf.briar.RESTRICTED", false);
|
||||||
byte[] b = i.getByteArrayExtra("net.sf.briar.GROUP_ID");
|
byte[] b = i.getByteArrayExtra("net.sf.briar.GROUP_ID");
|
||||||
if(b == null) throw new IllegalStateException();
|
if(b == null) throw new IllegalStateException();
|
||||||
groupId = new GroupId(b);
|
groupId = new GroupId(b);
|
||||||
@@ -325,11 +327,17 @@ implements OnClickListener {
|
|||||||
setResult(RESULT_NEXT);
|
setResult(RESULT_NEXT);
|
||||||
finish();
|
finish();
|
||||||
} else if(view == replyButton) {
|
} else if(view == replyButton) {
|
||||||
// FIXME: Restricted/unrestricted
|
if(restricted) {
|
||||||
Intent i = new Intent(this, WriteGroupPostActivity.class);
|
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
||||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||||
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
|
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
|
} else {
|
||||||
|
Intent i = new Intent(this, WriteGroupPostActivity.class);
|
||||||
|
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||||
|
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
setResult(RESULT_REPLY);
|
setResult(RESULT_REPLY);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -361,7 +369,7 @@ implements OnClickListener {
|
|||||||
private void setRatingInUi(final Rating r) {
|
private void setRatingInUi(final Rating r) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
ReadGroupMessageActivity.this.rating = r;
|
rating = r;
|
||||||
if(r == GOOD) {
|
if(r == GOOD) {
|
||||||
thumb.setImageResource(R.drawable.rating_good);
|
thumb.setImageResource(R.drawable.rating_good);
|
||||||
thumb.setVisibility(VISIBLE);
|
thumb.setVisibility(VISIBLE);
|
||||||
|
|||||||
Reference in New Issue
Block a user