Skip to content
Snippets Groups Projects
Unverified Commit dbdf567d authored by akwizgran's avatar akwizgran
Browse files

Overhaul notifications to fix various bugs.

Fixes #539, #564 and #568.
parent 98337a16
No related branches found
No related tags found
No related merge requests found
Showing with 341 additions and 98 deletions
......@@ -134,8 +134,10 @@
<string name="introduction_response_accepted_received">%1$s accepted the introduction to %2$s.</string>
<string name="introduction_response_declined_received">%1$s declined the introduction to %2$s.</string>
<string name="introduction_response_declined_received_by_introducee">%1$s says that %2$s declined the introduction.</string>
<string name="introduction_success_title">Introduced contact was added</string>
<string name="introduction_success_text">You have been introduced to %1$s.</string>
<plurals name="introduction_notification_text">
<item quantity="one">New contact added.</item>
<item quantity="other">%d new contacts added.</item>
</plurals>
<!-- Forums -->
<string name="no_forums">You don\'t have any forums yet.\n\nWhy don\'t you create a new one yourself by tapping the + icon at the top?\n\nYou can also ask your contacts to share forums with you.</string>
......
......@@ -2,26 +2,37 @@ package org.briarproject.android.api;
import org.briarproject.api.sync.GroupId;
/** Manages notifications for private messages and forum posts. */
/**
* Manages notifications for private messages, forum posts, blog posts and
* introductions.
*/
public interface AndroidNotificationManager {
void showPrivateMessageNotification(GroupId g);
void clearPrivateMessageNotification(GroupId g);
void showForumPostNotification(GroupId g);
void clearAllContactNotifications();
void clearForumPostNotification(GroupId g);
void showBlogPostNotification(GroupId g);
void clearAllForumPostNotifications();
void clearBlogPostNotification(GroupId g);
void clearBlogPostNotification();
void clearAllBlogPostNotifications();
void blockNotification(GroupId g);
void unblockNotification(GroupId g);
void blockBlogNotification();
void blockAllContactNotifications();
void unblockAllContactNotifications();
void blockAllForumPostNotifications();
void unblockAllForumPostNotifications();
void blockAllBlogPostNotifications();
void unblockBlogNotification();
void unblockAllBlogPostNotifications();
}
......@@ -2,6 +2,7 @@ package org.briarproject.android.blogs;
import android.app.Activity;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.controller.DbControllerImpl;
import org.briarproject.android.controller.handler.ResultExceptionHandler;
import org.briarproject.api.blogs.Blog;
......@@ -38,6 +39,8 @@ public class BlogControllerImpl extends DbControllerImpl
protected Activity activity;
@Inject
protected EventBus eventBus;
@Inject
protected AndroidNotificationManager notificationManager;
@Inject
protected volatile BlogManager blogManager;
......@@ -69,11 +72,14 @@ public class BlogControllerImpl extends DbControllerImpl
@Override
public void onActivityResume() {
notificationManager.blockNotification(groupId);
notificationManager.clearBlogPostNotification(groupId);
eventBus.addListener(this);
}
@Override
public void onActivityPause() {
notificationManager.unblockNotification(groupId);
eventBus.removeListener(this);
}
......
......@@ -121,6 +121,7 @@ public class BlogFragment extends BaseFragment implements BlogPostListener {
@Override
public void injectFragment(ActivityComponent component) {
component.inject(this);
blogController.setGroupId(groupId);
}
@Override
......
......@@ -33,12 +33,13 @@ public class FeedControllerImpl extends DbControllerImpl
@SuppressWarnings("WeakerAccess")
@Inject
AndroidNotificationManager notificationManager;
@Inject
protected EventBus eventBus;
@Inject
protected volatile BlogManager blogManager;
@Inject
protected volatile IdentityManager identityManager;
@Inject
protected volatile EventBus eventBus;
private volatile OnBlogPostAddedListener listener;
......@@ -48,14 +49,14 @@ public class FeedControllerImpl extends DbControllerImpl
@Override
public void onResume() {
notificationManager.blockBlogNotification();
notificationManager.clearBlogPostNotification();
notificationManager.blockAllBlogPostNotifications();
notificationManager.clearAllBlogPostNotifications();
eventBus.addListener(this);
}
@Override
public void onPause() {
notificationManager.unblockBlogNotification();
notificationManager.unblockAllBlogPostNotifications();
eventBus.removeListener(this);
}
......
......@@ -18,6 +18,7 @@ import android.widget.TextView.OnEditorActionListener;
import org.briarproject.R;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.BriarActivity;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.api.FormatException;
import org.briarproject.api.blogs.BlogManager;
import org.briarproject.api.blogs.BlogPost;
......@@ -47,6 +48,9 @@ public class WriteBlogPostActivity extends BriarActivity
Logger.getLogger(WriteBlogPostActivity.class.getName());
private static final String contentType = "text/plain";
@Inject
protected AndroidNotificationManager notificationManager;
private TextInputEditText titleInput;
private EditText bodyInput;
private Button publishButton;
......@@ -69,13 +73,8 @@ public class WriteBlogPostActivity extends BriarActivity
byte[] b = i.getByteArrayExtra(GROUP_ID);
if (b == null) throw new IllegalStateException("No Group in intent.");
groupId = new GroupId(b);
// String blogName = i.getStringExtra(BLOG_NAME);
// if (blogName != null) setTitle(blogName);
setContentView(R.layout.activity_write_blog_post);
// String title =
// getTitle() + ": " + getString(R.string.blogs_write_blog_post);
// setTitle(title);
TextInputLayout titleLayout =
(TextInputLayout) findViewById(R.id.titleLayout);
......@@ -116,6 +115,18 @@ public class WriteBlogPostActivity extends BriarActivity
progressBar = (ProgressBar) findViewById(R.id.progressBar);
}
@Override
public void onPause() {
super.onPause();
notificationManager.unblockNotification(groupId);
}
@Override
public void onResume() {
super.onResume();
notificationManager.blockNotification(groupId);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
......
......@@ -17,6 +17,7 @@ import android.view.ViewGroup;
import org.briarproject.R;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.fragment.BaseFragment;
import org.briarproject.android.keyagreement.KeyAgreementActivity;
import org.briarproject.android.util.BriarRecyclerView;
......@@ -75,6 +76,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
ConnectionRegistry connectionRegistry;
@Inject
protected EventBus eventBus;
@Inject
protected AndroidNotificationManager notificationManager;
private ContactListAdapter adapter = null;
private BriarRecyclerView list = null;
......@@ -184,6 +187,8 @@ public class ContactListFragment extends BaseFragment implements EventListener {
@Override
public void onResume() {
super.onResume();
notificationManager.blockAllContactNotifications();
notificationManager.clearAllContactNotifications();
eventBus.addListener(this);
loadContacts();
list.startPeriodicUpdate();
......@@ -193,6 +198,7 @@ public class ContactListFragment extends BaseFragment implements EventListener {
public void onPause() {
super.onPause();
eventBus.removeListener(this);
notificationManager.unblockAllContactNotifications();
adapter.clear();
list.showProgressBar();
list.stopPeriodicUpdate();
......
......@@ -15,6 +15,7 @@ import android.view.ViewGroup;
import org.briarproject.R;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.fragment.BaseEventFragment;
import org.briarproject.android.sharing.InvitationsForumActivity;
import org.briarproject.android.util.BriarRecyclerView;
......@@ -55,9 +56,14 @@ public class ForumListFragment extends BaseEventFragment implements
private ForumListAdapter adapter;
private Snackbar snackbar;
@Inject
protected AndroidNotificationManager notificationManager;
// Fields that are accessed from background threads must be volatile
@Inject protected volatile ForumManager forumManager;
@Inject protected volatile ForumSharingManager forumSharingManager;
@Inject
protected volatile ForumManager forumManager;
@Inject
protected volatile ForumSharingManager forumSharingManager;
public static ForumListFragment newInstance() {
......@@ -109,6 +115,8 @@ public class ForumListFragment extends BaseEventFragment implements
public void onResume() {
super.onResume();
notificationManager.blockAllForumPostNotifications();
notificationManager.clearAllForumPostNotifications();
loadForumHeaders();
loadAvailableForums();
list.startPeriodicUpdate();
......@@ -118,6 +126,7 @@ public class ForumListFragment extends BaseEventFragment implements
public void onPause() {
super.onPause();
notificationManager.unblockAllForumPostNotifications();
adapter.clear();
list.showProgressBar();
list.stopPeriodicUpdate();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment