mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Prevent users from trying to post to blogs that aren't theirs.
This commit is contained in:
@@ -61,6 +61,8 @@
|
||||
<string name="choose_blog_name">Choose a name for your blog:</string>
|
||||
<string name="blog_visible_to_all">Share this blog with all contacts</string>
|
||||
<string name="blog_visible_to_some">Share this blog with chosen contacts</string>
|
||||
<string name="not_your_blog">Only the creator of this blog can write posts</string>
|
||||
<string name="ok_button">OK</string>
|
||||
<string name="compose_blog_title">New Post</string>
|
||||
<string name="new_blog_item">New blog\u2026</string>
|
||||
<string name="create_nickname_item">New nickname\u2026</string>
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.AscendingHeaderComparator;
|
||||
import net.sf.briar.android.BriarActivity;
|
||||
import net.sf.briar.android.BriarFragmentActivity;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
@@ -44,8 +44,8 @@ import android.widget.ListView;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class BlogActivity extends BriarActivity implements DatabaseListener,
|
||||
OnClickListener, OnItemClickListener {
|
||||
public class BlogActivity extends BriarFragmentActivity
|
||||
implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BlogActivity.class.getName());
|
||||
@@ -54,6 +54,7 @@ OnClickListener, OnItemClickListener {
|
||||
new BriarServiceConnection();
|
||||
|
||||
private String groupName = null;
|
||||
private boolean postable = false;
|
||||
private BlogAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
|
||||
@@ -73,6 +74,7 @@ OnClickListener, OnItemClickListener {
|
||||
groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
||||
if(groupName == null) throw new IllegalStateException();
|
||||
setTitle(groupName);
|
||||
postable = i.getBooleanExtra("net.sf.briar.POSTABLE", false);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setLayoutParams(MATCH_MATCH);
|
||||
@@ -208,9 +210,14 @@ OnClickListener, OnItemClickListener {
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||
startActivity(i);
|
||||
if(postable) {
|
||||
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||
startActivity(i);
|
||||
} else {
|
||||
NotYourBlogDialog dialog = new NotYourBlogDialog();
|
||||
dialog.show(getSupportFragmentManager(), "NotYourBlogDialog");
|
||||
}
|
||||
}
|
||||
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
@@ -223,6 +230,7 @@ OnClickListener, OnItemClickListener {
|
||||
Intent i = new Intent(this, ReadBlogPostActivity.class);
|
||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("net.sf.briar.GROUP_NAME", groupName);
|
||||
i.putExtra("net.sf.briar.POSTABLE", postable);
|
||||
i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes());
|
||||
Author author = item.getAuthor();
|
||||
if(author != null) {
|
||||
|
||||
@@ -103,6 +103,7 @@ implements OnItemClickListener {
|
||||
Intent i = new Intent(getContext(), BlogActivity.class);
|
||||
i.putExtra("net.sf.briar.GROUP_ID", item.getGroupId().getBytes());
|
||||
i.putExtra("net.sf.briar.GROUP_NAME", item.getGroupName());
|
||||
i.putExtra("net.sf.briar.POSTABLE", item.isPostable());
|
||||
getContext().startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.sf.briar.android.blogs;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
public class NotYourBlogDialog extends DialogFragment {
|
||||
|
||||
private static final DialogInterface.OnClickListener IGNORE =
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {}
|
||||
};
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle state) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.not_your_blog);
|
||||
builder.setPositiveButton(R.string.ok_button, IGNORE);
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarActivity;
|
||||
import net.sf.briar.android.BriarFragmentActivity;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||
@@ -49,7 +49,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class ReadBlogPostActivity extends BriarActivity
|
||||
public class ReadBlogPostActivity extends BriarFragmentActivity
|
||||
implements OnClickListener {
|
||||
|
||||
static final int RESULT_REPLY = RESULT_FIRST_USER;
|
||||
@@ -64,6 +64,7 @@ implements OnClickListener {
|
||||
|
||||
@Inject private BundleEncrypter bundleEncrypter;
|
||||
private GroupId groupId = null;
|
||||
private boolean postable = false;
|
||||
private Rating rating = UNRATED;
|
||||
private boolean read;
|
||||
private ImageView thumb = null;
|
||||
@@ -89,6 +90,7 @@ implements OnClickListener {
|
||||
String groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
||||
if(groupName == null) throw new IllegalStateException();
|
||||
setTitle(groupName);
|
||||
postable = i.getBooleanExtra("net.sf.briar.POSTABLE", false);
|
||||
b = i.getByteArrayExtra("net.sf.briar.MESSAGE_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
messageId = new MessageId(b);
|
||||
@@ -324,12 +326,17 @@ implements OnClickListener {
|
||||
setResult(RESULT_NEXT);
|
||||
finish();
|
||||
} else if(view == replyButton) {
|
||||
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
|
||||
startActivity(i);
|
||||
setResult(RESULT_REPLY);
|
||||
finish();
|
||||
if(postable) {
|
||||
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
|
||||
startActivity(i);
|
||||
setResult(RESULT_REPLY);
|
||||
finish();
|
||||
} else {
|
||||
NotYourBlogDialog dialog = new NotYourBlogDialog();
|
||||
dialog.show(getSupportFragmentManager(), "NotYourBlogDialog");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user