forked from mirrors/Fedilab
Improve notifications
This commit is contained in:
parent
e50c0fa9fe
commit
d3bb4a285b
4 changed files with 18 additions and 0 deletions
|
@ -210,6 +210,7 @@ public class Helper {
|
||||||
public static final String ARG_EXCLUDED_NOTIFICATION_TYPE = "ARG_EXCLUDED_NOTIFICATION_TYPE";
|
public static final String ARG_EXCLUDED_NOTIFICATION_TYPE = "ARG_EXCLUDED_NOTIFICATION_TYPE";
|
||||||
public static final String ARG_STATUS = "ARG_STATUS";
|
public static final String ARG_STATUS = "ARG_STATUS";
|
||||||
public static final String ARG_TIMELINE_REFRESH_ALL = "ARG_TIMELINE_REFRESH_ALL";
|
public static final String ARG_TIMELINE_REFRESH_ALL = "ARG_TIMELINE_REFRESH_ALL";
|
||||||
|
public static final String ARG_REFRESH_NOTFICATION = "ARG_REFRESH_NOTFICATION";
|
||||||
public static final String ARG_STATUS_DELETED = "ARG_STATUS_DELETED";
|
public static final String ARG_STATUS_DELETED = "ARG_STATUS_DELETED";
|
||||||
public static final String ARG_STATUS_UPDATED = "ARG_STATUS_UPDATED";
|
public static final String ARG_STATUS_UPDATED = "ARG_STATUS_UPDATED";
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package app.fedilab.android.helper;
|
||||||
import static android.text.Html.FROM_HTML_MODE_LEGACY;
|
import static android.text.Html.FROM_HTML_MODE_LEGACY;
|
||||||
import static app.fedilab.android.helper.Helper.notify_user;
|
import static app.fedilab.android.helper.Helper.notify_user;
|
||||||
import static app.fedilab.android.helper.LogoHelper.getMainLogo;
|
import static app.fedilab.android.helper.LogoHelper.getMainLogo;
|
||||||
|
import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -379,6 +380,7 @@ public class NotificationsHelper {
|
||||||
Helper.NotifType finalNotifType = notifType;
|
Helper.NotifType finalNotifType = notifType;
|
||||||
String finalMessage = message;
|
String finalMessage = message;
|
||||||
String finalTitle = title;
|
String finalTitle = title;
|
||||||
|
sendAction(context, Helper.ARG_REFRESH_NOTFICATION, null, null);
|
||||||
Runnable myRunnable = () -> Glide.with(context)
|
Runnable myRunnable = () -> Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(finalNotificationUrl != null ? finalNotificationUrl : R.drawable.fedilab_logo_bubbles)
|
.load(finalNotificationUrl != null ? finalNotificationUrl : R.drawable.fedilab_logo_bubbles)
|
||||||
|
|
|
@ -64,6 +64,17 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
||||||
private boolean flagLoading;
|
private boolean flagLoading;
|
||||||
private List<Notification> notificationList;
|
private List<Notification> notificationList;
|
||||||
private NotificationAdapter notificationAdapter;
|
private NotificationAdapter notificationAdapter;
|
||||||
|
private final BroadcastReceiver receive_refresh = new BroadcastReceiver() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (notificationType != null && notificationType == NotificationTypeEnum.ALL) {
|
||||||
|
if (notificationList != null && notificationList.size() > 0) {
|
||||||
|
route(FragmentMastodonTimeline.DIRECTION.FETCH_NEW, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
private final BroadcastReceiver receive_action = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -192,6 +203,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
||||||
aggregateNotification = false;
|
aggregateNotification = false;
|
||||||
|
|
||||||
LocalBroadcastManager.getInstance(requireActivity()).registerReceiver(receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION));
|
LocalBroadcastManager.getInstance(requireActivity()).registerReceiver(receive_action, new IntentFilter(Helper.RECEIVE_STATUS_ACTION));
|
||||||
|
LocalBroadcastManager.getInstance(requireActivity()).registerReceiver(receive_refresh, new IntentFilter(Helper.ARG_REFRESH_NOTFICATION));
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,6 +667,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(receive_action);
|
LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(receive_action);
|
||||||
|
LocalBroadcastManager.getInstance(requireActivity()).unregisterReceiver(receive_refresh);
|
||||||
if (isAdded()) {
|
if (isAdded()) {
|
||||||
storeMarker();
|
storeMarker();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class FragmentNotificationContainer extends Fragment {
|
||||||
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.mention)));
|
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.mention)));
|
||||||
binding.tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
binding.tabLayout.setTabMode(TabLayout.MODE_FIXED);
|
||||||
binding.viewpagerNotificationContainer.setAdapter(new FedilabNotificationPageAdapter(getChildFragmentManager(), false));
|
binding.viewpagerNotificationContainer.setAdapter(new FedilabNotificationPageAdapter(getChildFragmentManager(), false));
|
||||||
|
binding.viewpagerNotificationContainer.setOffscreenPageLimit(2);
|
||||||
} else {
|
} else {
|
||||||
binding.tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
|
binding.tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
|
||||||
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.all)));
|
binding.tabLayout.addTab(binding.tabLayout.newTab().setText(getString(R.string.all)));
|
||||||
|
@ -84,6 +85,7 @@ public class FragmentNotificationContainer extends Fragment {
|
||||||
binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_person_add_alt_1_24));
|
binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_person_add_alt_1_24));
|
||||||
binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_report_24));
|
binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_report_24));
|
||||||
binding.viewpagerNotificationContainer.setAdapter(new FedilabNotificationPageAdapter(getChildFragmentManager(), true));
|
binding.viewpagerNotificationContainer.setAdapter(new FedilabNotificationPageAdapter(getChildFragmentManager(), true));
|
||||||
|
binding.viewpagerNotificationContainer.setOffscreenPageLimit(10);
|
||||||
}
|
}
|
||||||
AtomicBoolean changes = new AtomicBoolean(false);
|
AtomicBoolean changes = new AtomicBoolean(false);
|
||||||
binding.settings.setOnClickListener(v -> {
|
binding.settings.setOnClickListener(v -> {
|
||||||
|
|
Loading…
Reference in a new issue