update reminders when dismissed

Closes #4325
// FREEBIE
This commit is contained in:
Jake McGinty 2015-10-28 16:33:06 -07:00 committed by Moxie Marlinspike
parent 50794ba49d
commit 02c781eb25
2 changed files with 22 additions and 6 deletions

View File

@ -51,6 +51,7 @@ import org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder;
import org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder; import org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder;
import org.thoughtcrime.securesms.components.reminder.Reminder; import org.thoughtcrime.securesms.components.reminder.Reminder;
import org.thoughtcrime.securesms.components.reminder.ReminderView; import org.thoughtcrime.securesms.components.reminder.ReminderView;
import org.thoughtcrime.securesms.components.reminder.ReminderView.OnDismissListener;
import org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder; import org.thoughtcrime.securesms.components.reminder.SystemSmsImportReminder;
import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
@ -87,6 +88,11 @@ public class ConversationListFragment extends Fragment
reminderView = (ReminderView) view.findViewById(R.id.reminder); reminderView = (ReminderView) view.findViewById(R.id.reminder);
list = (RecyclerView) view.findViewById(R.id.list); list = (RecyclerView) view.findViewById(R.id.list);
fab = (FloatingActionButton) view.findViewById(R.id.fab); fab = (FloatingActionButton) view.findViewById(R.id.fab);
reminderView.setOnDismissListener(new OnDismissListener() {
@Override public void onDismiss() {
updateReminders();
}
});
list.setHasFixedSize(true); list.setHasFixedSize(true);
list.setLayoutManager(new LinearLayoutManager(getActivity())); list.setLayoutManager(new LinearLayoutManager(getActivity()));
return view; return view;
@ -110,7 +116,7 @@ public class ConversationListFragment extends Fragment
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
initializeReminders(); updateReminders();
list.getAdapter().notifyDataSetChanged(); list.getAdapter().notifyDataSetChanged();
} }
@ -129,7 +135,7 @@ public class ConversationListFragment extends Fragment
} }
} }
private void initializeReminders() { private void updateReminders() {
reminderView.hide(); reminderView.hide();
new AsyncTask<Context, Void, Optional<? extends Reminder>>() { new AsyncTask<Context, Void, Optional<? extends Reminder>>() {
@Override protected Optional<? extends Reminder> doInBackground(Context... params) { @Override protected Optional<? extends Reminder> doInBackground(Context... params) {

View File

@ -22,6 +22,7 @@ public class ReminderView extends LinearLayout {
private ImageButton closeButton; private ImageButton closeButton;
private TextView title; private TextView title;
private TextView text; private TextView text;
private OnDismissListener dismissListener;
public ReminderView(Context context) { public ReminderView(Context context) {
super(context); super(context);
@ -59,6 +60,7 @@ public class ReminderView extends LinearLayout {
public void onClick(View v) { public void onClick(View v) {
hide(); hide();
if (reminder.getDismissListener() != null) reminder.getDismissListener().onClick(v); if (reminder.getDismissListener() != null) reminder.getDismissListener().onClick(v);
if (dismissListener != null) dismissListener.onDismiss();
} }
}); });
} else { } else {
@ -68,6 +70,10 @@ public class ReminderView extends LinearLayout {
container.setVisibility(View.VISIBLE); container.setVisibility(View.VISIBLE);
} }
public void setOnDismissListener(OnDismissListener dismissListener) {
this.dismissListener = dismissListener;
}
public void requestDismiss() { public void requestDismiss() {
closeButton.performClick(); closeButton.performClick();
} }
@ -75,4 +81,8 @@ public class ReminderView extends LinearLayout {
public void hide() { public void hide() {
container.setVisibility(View.GONE); container.setVisibility(View.GONE);
} }
public interface OnDismissListener {
void onDismiss();
}
} }