mirror of
				https://codeberg.org/tom79/Fedilab.git
				synced 2025-10-20 11:20:16 +03:00 
			
		
		
		
	Live remove when muting tags
This commit is contained in:
		
							parent
							
								
									c7420a8760
								
							
						
					
					
						commit
						a796d54166
					
				
					 4 changed files with 18 additions and 5 deletions
				
			
		|  | @ -218,6 +218,7 @@ public class Helper { | |||
|     public static final String ARG_NOTIFICATION_TYPE = "ARG_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_TIMELINE_REFRESH_ALL = "ARG_TIMELINE_REFRESH_ALL"; | ||||
|     public static final String ARG_STATUS_DELETED = "ARG_STATUS_DELETED"; | ||||
|     public static final String ARG_STATUS_UPDATED = "ARG_STATUS_UPDATED"; | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,6 +17,7 @@ package app.fedilab.android.helper; | |||
| 
 | ||||
| import static app.fedilab.android.BaseMainActivity.currentAccount; | ||||
| import static app.fedilab.android.helper.ThemeHelper.linkColor; | ||||
| import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction; | ||||
| 
 | ||||
| import android.content.ClipData; | ||||
| import android.content.ClipboardManager; | ||||
|  | @ -148,7 +149,7 @@ public class SpannableHelper { | |||
|                 content.removeSpan(span); | ||||
|             } | ||||
|             //Make tags, mentions, groups | ||||
|             interaction(context, content, mentionList); | ||||
|             interaction(context, content, status, mentionList); | ||||
|             //Make all links | ||||
|             linkify(context, content, urlDetails); | ||||
|             linkifyURL(context, content, urlDetails); | ||||
|  | @ -751,7 +752,7 @@ public class SpannableHelper { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private static void interaction(Context context, Spannable content, List<Mention> mentions) { | ||||
|     private static void interaction(Context context, Spannable content, Status status, List<Mention> mentions) { | ||||
|         // --- For all patterns defined in Helper class --- | ||||
|         for (Map.Entry<Helper.PatternType, Pattern> entry : Helper.patternHashMap.entrySet()) { | ||||
|             Helper.PatternType patternType = entry.getKey(); | ||||
|  | @ -802,11 +803,11 @@ public class SpannableHelper { | |||
|                                             .observe((LifecycleOwner) context, filter -> { | ||||
|                                                 if (filter != null) { | ||||
|                                                     MainActivity.mainFilters.add(filter); | ||||
|                                                     addTagToFilter(context, finalTag, filter); | ||||
|                                                     addTagToFilter(context, finalTag, status, filter); | ||||
|                                                 } | ||||
|                                             }); | ||||
|                                 } else { | ||||
|                                     addTagToFilter(context, tag, fedilabFilter); | ||||
|                                     addTagToFilter(context, tag, status, fedilabFilter); | ||||
|                                 } | ||||
|                             } | ||||
|                         } | ||||
|  | @ -901,7 +902,7 @@ public class SpannableHelper { | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public static void addTagToFilter(Context context, String tag, Filter filter) { | ||||
|     public static void addTagToFilter(Context context, String tag, Status status, Filter filter) { | ||||
|         for (Filter.KeywordsAttributes keywords : filter.keywords) { | ||||
|             if (keywords.keyword.equalsIgnoreCase(tag)) { | ||||
|                 return; | ||||
|  | @ -921,6 +922,10 @@ public class SpannableHelper { | |||
|                     filterParams.context = filter.context; | ||||
|                     FiltersVM filtersVM = new ViewModelProvider((ViewModelStoreOwner) context).get(FiltersVM.class); | ||||
|                     filtersVM.editFilter(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, filterParams); | ||||
|                     if (status != null) { | ||||
|                         status.filteredByApp = filter; | ||||
|                     } | ||||
|                     sendAction(context, Helper.ARG_TIMELINE_REFRESH_ALL, null, null); | ||||
|                     dialog.dismiss(); | ||||
|                 }) | ||||
|                 .setNegativeButton(R.string.no, (dialog, which) -> dialog.dismiss()) | ||||
|  |  | |||
|  | @ -24,6 +24,7 @@ import static app.fedilab.android.BaseMainActivity.regex_public; | |||
| import static app.fedilab.android.BaseMainActivity.show_boosts; | ||||
| import static app.fedilab.android.BaseMainActivity.show_replies; | ||||
| import static app.fedilab.android.activities.ContextActivity.expand; | ||||
| import static app.fedilab.android.helper.Helper.ARG_TIMELINE_REFRESH_ALL; | ||||
| import static app.fedilab.android.helper.Helper.PREF_USER_ID; | ||||
| import static app.fedilab.android.helper.Helper.PREF_USER_INSTANCE; | ||||
| import static app.fedilab.android.helper.Helper.PREF_USER_TOKEN; | ||||
|  | @ -2178,6 +2179,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> | |||
|         if (id != null) { | ||||
|             b.putSerializable(type, id); | ||||
|         } | ||||
|         if (type == ARG_TIMELINE_REFRESH_ALL) { | ||||
|             b.putSerializable(ARG_TIMELINE_REFRESH_ALL, true); | ||||
|         } | ||||
|         Intent intentBC = new Intent(Helper.RECEIVE_STATUS_ACTION); | ||||
|         intentBC.putExtras(b); | ||||
|         LocalBroadcastManager.getInstance(context).sendBroadcast(intentBC); | ||||
|  |  | |||
|  | @ -98,6 +98,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. | |||
|                 Status status_to_delete = (Status) b.getSerializable(Helper.ARG_STATUS_DELETED); | ||||
|                 Status status_to_update = (Status) b.getSerializable(Helper.ARG_STATUS_UPDATED); | ||||
|                 Status statusPosted = (Status) b.getSerializable(Helper.ARG_STATUS_DELETED); | ||||
|                 boolean refreshAll = b.getBoolean(Helper.ARG_TIMELINE_REFRESH_ALL, false); | ||||
|                 if (receivedStatus != null && statusAdapter != null) { | ||||
|                     int position = getPosition(receivedStatus); | ||||
|                     if (position >= 0) { | ||||
|  | @ -154,6 +155,8 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. | |||
|                             statusAdapter.notifyItemRemoved(position); | ||||
|                         } | ||||
|                     } | ||||
|                 } else if (refreshAll) { | ||||
|                     refreshAllAdapters(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue