From 2327ab5221a1311930f1ec4eeb59c03dd502b176 Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Mon, 17 Jun 2024 20:38:19 +0200 Subject: [PATCH] refactor: Move actions.xml to core.ui (#754) --- .../util/ListStatusAccessibilityDelegate.kt | 84 +++++++++---------- .../ui}/src/main/res/values/actions.xml | 0 2 files changed, 42 insertions(+), 42 deletions(-) rename {app => core/ui}/src/main/res/values/actions.xml (100%) diff --git a/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt b/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt index 596f9592a..f0422dbcf 100644 --- a/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt +++ b/app/src/main/java/app/pachli/util/ListStatusAccessibilityDelegate.kt @@ -72,10 +72,10 @@ class ListStatusAccessibilityDelegate( info.addAction(if (actionable.bookmarked) unbookmarkAction else bookmarkAction) val mediaActions = intArrayOf( - R.id.action_open_media_1, - R.id.action_open_media_2, - R.id.action_open_media_3, - R.id.action_open_media_4, + app.pachli.core.ui.R.id.action_open_media_1, + app.pachli.core.ui.R.id.action_open_media_2, + app.pachli.core.ui.R.id.action_open_media_3, + app.pachli.core.ui.R.id.action_open_media_4, ) val attachmentCount = min(actionable.attachments.size, MAX_MEDIA_ATTACHMENTS) for (i in 0 until attachmentCount) { @@ -111,37 +111,37 @@ class ListStatusAccessibilityDelegate( val pos = recyclerView.getChildAdapterPosition(host) val status = statusProvider.getStatus(pos) ?: return false when (action) { - R.id.action_reply -> { + app.pachli.core.ui.R.id.action_reply -> { interrupt() statusActionListener.onReply(status) } - R.id.action_favourite -> statusActionListener.onFavourite(status, true) - R.id.action_unfavourite -> statusActionListener.onFavourite(status, false) - R.id.action_bookmark -> statusActionListener.onBookmark(status, true) - R.id.action_unbookmark -> statusActionListener.onBookmark(status, false) - R.id.action_reblog -> statusActionListener.onReblog(status, true) - R.id.action_unreblog -> statusActionListener.onReblog(status, false) - R.id.action_open_profile -> { + app.pachli.core.ui.R.id.action_favourite -> statusActionListener.onFavourite(status, true) + app.pachli.core.ui.R.id.action_unfavourite -> statusActionListener.onFavourite(status, false) + app.pachli.core.ui.R.id.action_bookmark -> statusActionListener.onBookmark(status, true) + app.pachli.core.ui.R.id.action_unbookmark -> statusActionListener.onBookmark(status, false) + app.pachli.core.ui.R.id.action_reblog -> statusActionListener.onReblog(status, true) + app.pachli.core.ui.R.id.action_unreblog -> statusActionListener.onReblog(status, false) + app.pachli.core.ui.R.id.action_open_profile -> { interrupt() statusActionListener.onViewAccount(status.actionable.account.id) } - R.id.action_open_media_1 -> { + app.pachli.core.ui.R.id.action_open_media_1 -> { interrupt() statusActionListener.onViewMedia(status, 0, null) } - R.id.action_open_media_2 -> { + app.pachli.core.ui.R.id.action_open_media_2 -> { interrupt() statusActionListener.onViewMedia(status, 1, null) } - R.id.action_open_media_3 -> { + app.pachli.core.ui.R.id.action_open_media_3 -> { interrupt() statusActionListener.onViewMedia(status, 2, null) } - R.id.action_open_media_4 -> { + app.pachli.core.ui.R.id.action_open_media_4 -> { interrupt() statusActionListener.onViewMedia(status, 3, null) } - R.id.action_expand_cw -> { + app.pachli.core.ui.R.id.action_expand_cw -> { // Toggling it directly to avoid animations // which cannot be disabled for detailed status for some reason val holder = recyclerView.getChildViewHolder(host) as StatusBaseViewHolder @@ -151,26 +151,26 @@ class ListStatusAccessibilityDelegate( // to be possible. forceFocus(host) } - R.id.action_collapse_cw -> { + app.pachli.core.ui.R.id.action_collapse_cw -> { statusActionListener.onExpandedChange(status, false) interrupt() } - R.id.action_links -> showLinksDialog(host) - R.id.action_mentions -> showMentionsDialog(host) - R.id.action_hashtags -> showHashtagsDialog(host) - R.id.action_open_reblogger -> { + app.pachli.core.ui.R.id.action_links -> showLinksDialog(host) + app.pachli.core.ui.R.id.action_mentions -> showMentionsDialog(host) + app.pachli.core.ui.R.id.action_hashtags -> showHashtagsDialog(host) + app.pachli.core.ui.R.id.action_open_reblogger -> { interrupt() statusActionListener.onOpenReblog(status.actionable) } - R.id.action_open_reblogged_by -> { + app.pachli.core.ui.R.id.action_open_reblogged_by -> { interrupt() statusActionListener.onShowReblogs(status.actionableId) } - R.id.action_open_faved_by -> { + app.pachli.core.ui.R.id.action_open_faved_by -> { interrupt() statusActionListener.onShowFavs(status.actionableId) } - R.id.action_more -> { + app.pachli.core.ui.R.id.action_more -> { statusActionListener.onMore(host, status) } else -> return super.performAccessibilityAction(host, action, args) @@ -279,87 +279,87 @@ class ListStatusAccessibilityDelegate( private fun isHashtag(text: CharSequence) = text.startsWith("#") private val collapseCwAction = AccessibilityActionCompat( - R.id.action_collapse_cw, + app.pachli.core.ui.R.id.action_collapse_cw, context.getString(R.string.post_content_warning_show_less), ) private val expandCwAction = AccessibilityActionCompat( - R.id.action_expand_cw, + app.pachli.core.ui.R.id.action_expand_cw, context.getString(R.string.post_content_warning_show_more), ) private val replyAction = AccessibilityActionCompat( - R.id.action_reply, + app.pachli.core.ui.R.id.action_reply, context.getString(R.string.action_reply), ) private val unreblogAction = AccessibilityActionCompat( - R.id.action_unreblog, + app.pachli.core.ui.R.id.action_unreblog, context.getString(R.string.action_unreblog), ) private val reblogAction = AccessibilityActionCompat( - R.id.action_reblog, + app.pachli.core.ui.R.id.action_reblog, context.getString(R.string.action_reblog), ) private val unfavouriteAction = AccessibilityActionCompat( - R.id.action_unfavourite, + app.pachli.core.ui.R.id.action_unfavourite, context.getString(R.string.action_unfavourite), ) private val favouriteAction = AccessibilityActionCompat( - R.id.action_favourite, + app.pachli.core.ui.R.id.action_favourite, context.getString(R.string.action_favourite), ) private val bookmarkAction = AccessibilityActionCompat( - R.id.action_bookmark, + app.pachli.core.ui.R.id.action_bookmark, context.getString(R.string.action_bookmark), ) private val unbookmarkAction = AccessibilityActionCompat( - R.id.action_unbookmark, + app.pachli.core.ui.R.id.action_unbookmark, context.getString(R.string.action_bookmark), ) private val openProfileAction = AccessibilityActionCompat( - R.id.action_open_profile, + app.pachli.core.ui.R.id.action_open_profile, context.getString(app.pachli.core.ui.R.string.action_view_profile), ) private val linksAction = AccessibilityActionCompat( - R.id.action_links, + app.pachli.core.ui.R.id.action_links, context.getString(app.pachli.core.ui.R.string.action_links), ) private val mentionsAction = AccessibilityActionCompat( - R.id.action_mentions, + app.pachli.core.ui.R.id.action_mentions, context.getString(app.pachli.core.ui.R.string.action_mentions), ) private val hashtagsAction = AccessibilityActionCompat( - R.id.action_hashtags, + app.pachli.core.ui.R.id.action_hashtags, context.getString(app.pachli.core.ui.R.string.action_hashtags), ) private val openRebloggerAction = AccessibilityActionCompat( - R.id.action_open_reblogger, + app.pachli.core.ui.R.id.action_open_reblogger, context.getString(R.string.action_open_reblogger), ) private val openRebloggedByAction = AccessibilityActionCompat( - R.id.action_open_reblogged_by, + app.pachli.core.ui.R.id.action_open_reblogged_by, context.getString(R.string.action_open_reblogged_by), ) private val openFavsAction = AccessibilityActionCompat( - R.id.action_open_faved_by, + app.pachli.core.ui.R.id.action_open_faved_by, context.getString(R.string.action_open_faved_by), ) private val moreAction = AccessibilityActionCompat( - R.id.action_more, + app.pachli.core.ui.R.id.action_more, context.getString(app.pachli.core.ui.R.string.action_more), ) diff --git a/app/src/main/res/values/actions.xml b/core/ui/src/main/res/values/actions.xml similarity index 100% rename from app/src/main/res/values/actions.xml rename to core/ui/src/main/res/values/actions.xml