mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +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="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_all">Share this blog with all contacts</string>
|
||||||
<string name="blog_visible_to_some">Share this blog with chosen 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="compose_blog_title">New Post</string>
|
||||||
<string name="new_blog_item">New blog\u2026</string>
|
<string name="new_blog_item">New blog\u2026</string>
|
||||||
<string name="create_nickname_item">New nickname\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.R;
|
||||||
import net.sf.briar.android.AscendingHeaderComparator;
|
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;
|
||||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||||
@@ -44,8 +44,8 @@ import android.widget.ListView;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
public class BlogActivity extends BriarActivity implements DatabaseListener,
|
public class BlogActivity extends BriarFragmentActivity
|
||||||
OnClickListener, OnItemClickListener {
|
implements DatabaseListener, OnClickListener, OnItemClickListener {
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(BlogActivity.class.getName());
|
Logger.getLogger(BlogActivity.class.getName());
|
||||||
@@ -54,6 +54,7 @@ OnClickListener, OnItemClickListener {
|
|||||||
new BriarServiceConnection();
|
new BriarServiceConnection();
|
||||||
|
|
||||||
private String groupName = null;
|
private String groupName = null;
|
||||||
|
private boolean postable = false;
|
||||||
private BlogAdapter adapter = null;
|
private BlogAdapter adapter = null;
|
||||||
private ListView list = null;
|
private ListView list = null;
|
||||||
|
|
||||||
@@ -73,6 +74,7 @@ OnClickListener, OnItemClickListener {
|
|||||||
groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
||||||
if(groupName == null) throw new IllegalStateException();
|
if(groupName == null) throw new IllegalStateException();
|
||||||
setTitle(groupName);
|
setTitle(groupName);
|
||||||
|
postable = i.getBooleanExtra("net.sf.briar.POSTABLE", false);
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setLayoutParams(MATCH_MATCH);
|
layout.setLayoutParams(MATCH_MATCH);
|
||||||
@@ -208,9 +210,14 @@ OnClickListener, OnItemClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
if(postable) {
|
||||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
||||||
startActivity(i);
|
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,
|
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||||
@@ -223,6 +230,7 @@ OnClickListener, OnItemClickListener {
|
|||||||
Intent i = new Intent(this, ReadBlogPostActivity.class);
|
Intent i = new Intent(this, ReadBlogPostActivity.class);
|
||||||
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.POSTABLE", postable);
|
||||||
i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes());
|
i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes());
|
||||||
Author author = item.getAuthor();
|
Author author = item.getAuthor();
|
||||||
if(author != null) {
|
if(author != null) {
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ implements OnItemClickListener {
|
|||||||
Intent i = new Intent(getContext(), BlogActivity.class);
|
Intent i = new Intent(getContext(), BlogActivity.class);
|
||||||
i.putExtra("net.sf.briar.GROUP_ID", item.getGroupId().getBytes());
|
i.putExtra("net.sf.briar.GROUP_ID", item.getGroupId().getBytes());
|
||||||
i.putExtra("net.sf.briar.GROUP_NAME", item.getGroupName());
|
i.putExtra("net.sf.briar.GROUP_NAME", item.getGroupName());
|
||||||
|
i.putExtra("net.sf.briar.POSTABLE", item.isPostable());
|
||||||
getContext().startActivity(i);
|
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 java.util.logging.Logger;
|
||||||
|
|
||||||
import net.sf.briar.R;
|
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;
|
||||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||||
import net.sf.briar.android.widgets.HorizontalBorder;
|
import net.sf.briar.android.widgets.HorizontalBorder;
|
||||||
@@ -49,7 +49,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
public class ReadBlogPostActivity extends BriarActivity
|
public class ReadBlogPostActivity extends BriarFragmentActivity
|
||||||
implements OnClickListener {
|
implements OnClickListener {
|
||||||
|
|
||||||
static final int RESULT_REPLY = RESULT_FIRST_USER;
|
static final int RESULT_REPLY = RESULT_FIRST_USER;
|
||||||
@@ -64,6 +64,7 @@ implements OnClickListener {
|
|||||||
|
|
||||||
@Inject private BundleEncrypter bundleEncrypter;
|
@Inject private BundleEncrypter bundleEncrypter;
|
||||||
private GroupId groupId = null;
|
private GroupId groupId = null;
|
||||||
|
private boolean postable = false;
|
||||||
private Rating rating = UNRATED;
|
private Rating rating = UNRATED;
|
||||||
private boolean read;
|
private boolean read;
|
||||||
private ImageView thumb = null;
|
private ImageView thumb = null;
|
||||||
@@ -89,6 +90,7 @@ implements OnClickListener {
|
|||||||
String groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
String groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
||||||
if(groupName == null) throw new IllegalStateException();
|
if(groupName == null) throw new IllegalStateException();
|
||||||
setTitle(groupName);
|
setTitle(groupName);
|
||||||
|
postable = i.getBooleanExtra("net.sf.briar.POSTABLE", false);
|
||||||
b = i.getByteArrayExtra("net.sf.briar.MESSAGE_ID");
|
b = i.getByteArrayExtra("net.sf.briar.MESSAGE_ID");
|
||||||
if(b == null) throw new IllegalStateException();
|
if(b == null) throw new IllegalStateException();
|
||||||
messageId = new MessageId(b);
|
messageId = new MessageId(b);
|
||||||
@@ -324,12 +326,17 @@ implements OnClickListener {
|
|||||||
setResult(RESULT_NEXT);
|
setResult(RESULT_NEXT);
|
||||||
finish();
|
finish();
|
||||||
} else if(view == replyButton) {
|
} else if(view == replyButton) {
|
||||||
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
if(postable) {
|
||||||
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
Intent i = new Intent(this, WriteBlogPostActivity.class);
|
||||||
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
|
i.putExtra("net.sf.briar.GROUP_ID", groupId.getBytes());
|
||||||
startActivity(i);
|
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
|
||||||
setResult(RESULT_REPLY);
|
startActivity(i);
|
||||||
finish();
|
setResult(RESULT_REPLY);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
NotYourBlogDialog dialog = new NotYourBlogDialog();
|
||||||
|
dialog.show(getSupportFragmentManager(), "NotYourBlogDialog");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user