mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Update blog backend to match current usage
This commit is contained in:
@@ -2,7 +2,6 @@ package org.briarproject.android.blogs;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
@@ -18,8 +17,6 @@ public class BlogActivity extends BriarActivity implements
|
||||
|
||||
static final int REQUEST_WRITE_POST = 1;
|
||||
static final int REQUEST_SHARE = 2;
|
||||
static final String BLOG_NAME = "briar.BLOG_NAME";
|
||||
static final String IS_NEW_BLOG = "briar.IS_NEW_BLOG";
|
||||
|
||||
@Inject
|
||||
BlogController blogController;
|
||||
@@ -35,17 +32,10 @@ public class BlogActivity extends BriarActivity implements
|
||||
GroupId groupId = new GroupId(b);
|
||||
blogController.setGroupId(groupId);
|
||||
|
||||
// Name of the blog
|
||||
String blogName = i.getStringExtra(BLOG_NAME);
|
||||
if (blogName != null) setTitle(blogName);
|
||||
|
||||
// Was this blog just created?
|
||||
boolean isNew = i.getBooleanExtra(IS_NEW_BLOG, false);
|
||||
|
||||
setContentView(R.layout.activity_fragment_container);
|
||||
|
||||
if (state == null) {
|
||||
BlogFragment f = BlogFragment.newInstance(groupId, blogName, isNew);
|
||||
BlogFragment f = BlogFragment.newInstance(groupId);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragmentContainer, f, f.getUniqueTag())
|
||||
.commit();
|
||||
|
||||
@@ -38,12 +38,9 @@ import javax.inject.Inject;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static android.support.design.widget.Snackbar.LENGTH_LONG;
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeCustomAnimation;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.briarproject.android.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.android.blogs.BlogActivity.BLOG_NAME;
|
||||
import static org.briarproject.android.blogs.BlogActivity.IS_NEW_BLOG;
|
||||
import static org.briarproject.android.blogs.BlogActivity.REQUEST_SHARE;
|
||||
import static org.briarproject.android.blogs.BlogActivity.REQUEST_WRITE_POST;
|
||||
|
||||
@@ -56,21 +53,17 @@ public class BlogFragment extends BaseFragment implements
|
||||
BlogController blogController;
|
||||
|
||||
private GroupId groupId;
|
||||
private String blogName;
|
||||
private BlogPostAdapter adapter;
|
||||
private BriarRecyclerView list;
|
||||
private MenuItem writeButton, deleteButton;
|
||||
private boolean isMyBlog = false, canDeleteBlog = false;
|
||||
|
||||
static BlogFragment newInstance(GroupId groupId, @Nullable String name,
|
||||
boolean isNew) {
|
||||
static BlogFragment newInstance(GroupId groupId) {
|
||||
|
||||
BlogFragment f = new BlogFragment();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putByteArray(GROUP_ID, groupId.getBytes());
|
||||
bundle.putString(BLOG_NAME, name);
|
||||
bundle.putBoolean(IS_NEW_BLOG, isNew);
|
||||
|
||||
f.setArguments(bundle);
|
||||
return f;
|
||||
@@ -84,8 +77,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
byte[] b = args.getByteArray(GROUP_ID);
|
||||
if (b == null) throw new IllegalStateException("No group ID in args");
|
||||
groupId = new GroupId(b);
|
||||
blogName = args.getString(BLOG_NAME);
|
||||
boolean isNew = args.getBoolean(IS_NEW_BLOG);
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_blog, container, false);
|
||||
|
||||
@@ -97,16 +88,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
list.showProgressBar();
|
||||
list.setEmptyText(getString(R.string.blogs_other_blog_empty_state));
|
||||
|
||||
// show snackbar if this blog was just created
|
||||
if (isNew) {
|
||||
Snackbar s = Snackbar.make(list, R.string.blogs_my_blogs_created,
|
||||
LENGTH_LONG);
|
||||
s.getView().setBackgroundResource(R.color.briar_primary);
|
||||
s.show();
|
||||
|
||||
// show only once
|
||||
args.putBoolean(IS_NEW_BLOG, false);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -152,7 +133,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
Intent i = new Intent(getActivity(),
|
||||
WriteBlogPostActivity.class);
|
||||
i.putExtra(GROUP_ID, groupId.getBytes());
|
||||
i.putExtra(BLOG_NAME, blogName);
|
||||
startActivityForResult(i, REQUEST_WRITE_POST,
|
||||
options.toBundle());
|
||||
return true;
|
||||
@@ -266,10 +246,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
private void setToolbarTitle(Author a) {
|
||||
String title = getString(R.string.blogs_personal_blog, a.getName());
|
||||
getActivity().setTitle(title);
|
||||
|
||||
// safe title in intent, so it can be restored automatically
|
||||
Intent intent = getActivity().getIntent();
|
||||
intent.putExtra(BLOG_NAME, title);
|
||||
}
|
||||
|
||||
private void showWriteButton() {
|
||||
|
||||
@@ -17,10 +17,6 @@ class BlogItem {
|
||||
return blog;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return blog.getName();
|
||||
}
|
||||
|
||||
boolean isOurs() {
|
||||
return ours;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import static android.app.Activity.RESULT_OK;
|
||||
import static android.support.design.widget.Snackbar.LENGTH_LONG;
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeCustomAnimation;
|
||||
import static org.briarproject.android.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.android.blogs.BlogActivity.BLOG_NAME;
|
||||
import static org.briarproject.android.blogs.BlogActivity.REQUEST_WRITE_POST;
|
||||
|
||||
public class FeedFragment extends BaseFragment implements
|
||||
@@ -171,7 +170,6 @@ public class FeedFragment extends BaseFragment implements
|
||||
Intent i1 =
|
||||
new Intent(getActivity(), WriteBlogPostActivity.class);
|
||||
i1.putExtra(GROUP_ID, personalBlog.getId().getBytes());
|
||||
i1.putExtra(BLOG_NAME, personalBlog.getName());
|
||||
startActivityForResult(i1, REQUEST_WRITE_POST,
|
||||
options.toBundle());
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user