From 91dcf841dcb6b35be08a36631cb1c5d81627fc6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Tue, 30 Apr 2024 16:41:34 +0200 Subject: [PATCH 1/8] Remove unused icon definitions --- app/ui/legacy/src/main/res/values/attrs.xml | 1 - app/ui/legacy/src/main/res/values/themes.xml | 2 -- 2 files changed, 3 deletions(-) diff --git a/app/ui/legacy/src/main/res/values/attrs.xml b/app/ui/legacy/src/main/res/values/attrs.xml index 0aa9f5659..9e8d76229 100644 --- a/app/ui/legacy/src/main/res/values/attrs.xml +++ b/app/ui/legacy/src/main/res/values/attrs.xml @@ -2,7 +2,6 @@ - diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index 1809a50dd..3cefe7ee6 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -66,7 +66,6 @@ @style/PreferenceThemeOverlay - @drawable/ic_inbox_multiple @drawable/ic_folder @drawable/ic_inbox @drawable/ic_outbox @@ -268,7 +267,6 @@ @style/PreferenceThemeOverlay - @drawable/ic_inbox_multiple @drawable/ic_folder @drawable/ic_inbox @drawable/ic_outbox From b586e6e18bcd05c610fdabfef645d39c53e1d421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Mon, 6 May 2024 16:24:49 +0200 Subject: [PATCH 2/8] Remove folders.json --- app/ui/legacy/sampledata/folders.json | 48 ------------------- .../src/main/res/layout/folder_list_item.xml | 5 +- 2 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 app/ui/legacy/sampledata/folders.json diff --git a/app/ui/legacy/sampledata/folders.json b/app/ui/legacy/sampledata/folders.json deleted file mode 100644 index e02d14f4e..000000000 --- a/app/ui/legacy/sampledata/folders.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "data": [ - { - "name": "Inbox", - "icon": "?attr/iconFolderInbox" - }, - { - "name": "Outbox", - "icon": "?attr/iconFolderOutbox" - }, - { - "name": "Archive", - "icon": "?attr/iconFolderArchive" - }, - { - "name": "Drafts", - "icon": "?attr/iconFolderDrafts" - }, - { - "name": "Sent", - "icon": "?attr/iconFolderSent" - }, - { - "name": "Spam", - "icon": "?attr/iconFolderSpam" - }, - { - "name": "Trash", - "icon": "?attr/iconFolderTrash" - }, - { - "name": "Regular folder", - "icon": "?attr/iconFolder" - }, - { - "name": "Another folder", - "icon": "?attr/iconFolder" - }, - { - "name": "And yet another folder", - "icon": "?attr/iconFolder" - }, - { - "name": "Folder", - "icon": "?attr/iconFolder" - } - ] -} diff --git a/app/ui/legacy/src/main/res/layout/folder_list_item.xml b/app/ui/legacy/src/main/res/layout/folder_list_item.xml index 6a040f435..825bcef72 100644 --- a/app/ui/legacy/src/main/res/layout/folder_list_item.xml +++ b/app/ui/legacy/src/main/res/layout/folder_list_item.xml @@ -1,6 +1,5 @@ + tools:srcCompat="@drawable/ic_inbox"/> + tools:text="Inbox" /> From 75e315e61aa381b2177f3a16f84f9627b125f97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Mon, 6 May 2024 17:56:03 +0200 Subject: [PATCH 3/8] Delete unused FoldableLinearLayout --- .../fsck/k9/view/FoldableLinearLayout.java | 255 ------------------ .../main/res/layout/foldable_linearlayout.xml | 42 --- app/ui/legacy/src/main/res/values/attrs.xml | 5 - 3 files changed, 302 deletions(-) delete mode 100644 app/ui/legacy/src/main/java/com/fsck/k9/view/FoldableLinearLayout.java delete mode 100644 app/ui/legacy/src/main/res/layout/foldable_linearlayout.xml diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/view/FoldableLinearLayout.java b/app/ui/legacy/src/main/java/com/fsck/k9/view/FoldableLinearLayout.java deleted file mode 100644 index 5d0e84ae8..000000000 --- a/app/ui/legacy/src/main/java/com/fsck/k9/view/FoldableLinearLayout.java +++ /dev/null @@ -1,255 +0,0 @@ -package com.fsck.k9.view; - -import com.fsck.k9.ui.R; - -import android.content.Context; -import android.content.res.Resources.Theme; -import android.content.res.TypedArray; -import android.os.Parcel; -import android.os.Parcelable; -import android.util.AttributeSet; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -/** - * Class representing a LinearLayout that can fold and hide it's content when - * pressed To use just add the following to your xml layout - *
{@code
- *
- *    
- *}
- * 
- */ -public class FoldableLinearLayout extends LinearLayout { - - private ImageView mFoldableIcon; - - // Start with the view folded - private boolean mIsFolded = true; - private boolean mHasMigrated = false; - private Integer mShortAnimationDuration = null; - private TextView mFoldableTextView = null; - private LinearLayout mFoldableContainer = null; - private View mFoldableLayout = null; - private String mFoldedLabel; - private String mUnFoldedLabel; - private int mIconActionCollapseId; - private int mIconActionExpandId; - - public FoldableLinearLayout(Context context) { - super(context); - processAttributes(context, null); - } - - public FoldableLinearLayout(Context context, AttributeSet attrs) { - super(context, attrs); - processAttributes(context, attrs); - } - - public FoldableLinearLayout(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs); - processAttributes(context, attrs); - } - - /** - * Load given attributes to inner variables, - * - * @param context - * @param attrs - */ - private void processAttributes(Context context, AttributeSet attrs) { - Theme theme = context.getTheme(); - TypedValue outValue = new TypedValue(); - boolean found = theme.resolveAttribute(R.attr.iconActionCollapse, outValue, true); - if (found) { - mIconActionCollapseId = outValue.resourceId; - } - found = theme.resolveAttribute(R.attr.iconActionExpand, outValue, true); - if (found) { - mIconActionExpandId = outValue.resourceId; - } - if (attrs != null) { - TypedArray a = context.obtainStyledAttributes(attrs, - R.styleable.FoldableLinearLayout, 0, 0); - mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel); - mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel); - a.recycle(); - } - // If any attribute isn't found then set a default one - mFoldedLabel = (mFoldedLabel == null) ? "No text!" : mFoldedLabel; - mUnFoldedLabel = (mUnFoldedLabel == null) ? "No text!" : mUnFoldedLabel; - } - - @Override - protected void onFinishInflate() { - // if the migration has already happened - // there is no need to move any children - if (!mHasMigrated) { - migrateChildrenToContainer(); - mHasMigrated = true; - } - initialiseInnerViews(); - super.onFinishInflate(); - } - - @Override - protected Parcelable onSaveInstanceState() { - Parcelable superState = super.onSaveInstanceState(); - SavedState savedState = new SavedState(superState); - savedState.mFolded = mIsFolded; - return savedState; - } - - @Override - protected void onRestoreInstanceState(Parcelable state) { - if (state instanceof SavedState) { - SavedState savedState = (SavedState) state; - super.onRestoreInstanceState(savedState.getSuperState()); - mIsFolded = savedState.mFolded; - updateFoldedState(mIsFolded, false); - } else { - super.onRestoreInstanceState(state); - } - } - - public static class SavedState extends BaseSavedState { - - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - - @Override - public SavedState createFromParcel(Parcel source) { - return new SavedState(source); - } - - @Override - public SavedState[] newArray(int size) { - return new SavedState[size]; - } - }; - - private boolean mFolded; - - private SavedState(Parcel parcel) { - super(parcel); - mFolded = (parcel.readInt() == 1); - } - - private SavedState(Parcelable superState) { - super(superState); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeInt(mFolded ? 1 : 0); - } - } - - /** - * Migrates Child views as declared in xml to the inner foldableContainer - */ - private void migrateChildrenToContainer() { - // Collect children of FoldableLinearLayout as declared in XML - int childNum = getChildCount(); - View[] children = new View[childNum]; - for (int i = 0; i < childNum; i++) { - children[i] = getChildAt(i); - } - if (children[0].getId() == R.id.foldableControl) { - } - // remove all of them from FoldableLinearLayout - detachAllViewsFromParent(); - // Inflate the inner foldable_linearlayout.xml - LayoutInflater inflator = (LayoutInflater) getContext().getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true); - mFoldableContainer = mFoldableLayout.findViewById(R.id.foldableContainer); - // Push previously collected children into foldableContainer. - for (int i = 0; i < childNum; i++) { - addView(children[i]); - } - } - - private void initialiseInnerViews() { - mFoldableIcon = mFoldableLayout.findViewById(R.id.foldableIcon); - mFoldableTextView = mFoldableLayout.findViewById(R.id.foldableText); - mFoldableTextView.setText(mFoldedLabel); - // retrieve and cache the system's short animation time - mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); - LinearLayout foldableControl = mFoldableLayout - .findViewById(R.id.foldableControl); - foldableControl.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - mIsFolded = !mIsFolded; - updateFoldedState(mIsFolded, true); - } - }); - } - - protected void updateFoldedState(boolean newStateIsFolded, boolean animate) { - if (newStateIsFolded) { - mFoldableIcon.setImageResource(mIconActionExpandId); - if (animate) { - AlphaAnimation animation = new AlphaAnimation(1f, 0f); - animation.setDuration(mShortAnimationDuration); - animation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) { - } - - @Override - public void onAnimationEnd(Animation animation) { - /* - * Make sure that at the end the container is - * completely invisible. GONE is not used in - * order to prevent parent views from jumping - * around as they re-center themselves - * vertically. - */ - mFoldableContainer.setVisibility(View.INVISIBLE); - } - - @Override - public void onAnimationRepeat(Animation animation) { - } - }); - mFoldableContainer.startAnimation(animation); - } else { - mFoldableContainer.setVisibility(View.INVISIBLE); - } - mFoldableTextView.setText(mFoldedLabel); - } else { - mFoldableIcon.setImageResource(mIconActionCollapseId); - mFoldableContainer.setVisibility(View.VISIBLE); - if (animate) { - AlphaAnimation animation = new AlphaAnimation(0f, 1f); - animation.setDuration(mShortAnimationDuration); - mFoldableContainer.startAnimation(animation); - } - mFoldableTextView.setText(mUnFoldedLabel); - } - } - - /** - * Adds provided child view to foldableContainer View - * - * @param child - */ - @Override - public void addView(View child) { - if (mFoldableContainer != null) { - mFoldableContainer.addView(child); - } - } -} diff --git a/app/ui/legacy/src/main/res/layout/foldable_linearlayout.xml b/app/ui/legacy/src/main/res/layout/foldable_linearlayout.xml deleted file mode 100644 index 6c76c42fe..000000000 --- a/app/ui/legacy/src/main/res/layout/foldable_linearlayout.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/ui/legacy/src/main/res/values/attrs.xml b/app/ui/legacy/src/main/res/values/attrs.xml index 9e8d76229..64d15fbb5 100644 --- a/app/ui/legacy/src/main/res/values/attrs.xml +++ b/app/ui/legacy/src/main/res/values/attrs.xml @@ -129,11 +129,6 @@
- - - - - From 270fb1d2c62a410baa8ec38e04d554696d722e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Mon, 6 May 2024 17:57:07 +0200 Subject: [PATCH 4/8] Change FolderIconProvider and K9Drawer to reference drawables directly --- .../src/main/java/com/fsck/k9/ui/K9Drawer.kt | 14 +------ .../fsck/k9/ui/folders/FolderIconProvider.kt | 40 +++++-------------- .../java/com/fsck/k9/ui/folders/KoinModule.kt | 3 +- 3 files changed, 12 insertions(+), 45 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt index 3f72bca02..6bffaddb8 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/K9Drawer.kt @@ -7,7 +7,6 @@ import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.net.Uri import android.os.Bundle -import android.util.TypedValue import android.widget.ImageView import androidx.core.view.GravityCompat import androidx.drawerlayout.widget.DrawerLayout @@ -71,6 +70,7 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K private val resources: Resources by inject() private val messagingController: MessagingController by inject() private val accountImageLoader: AccountImageLoader by inject() + private val folderIconProvider: FolderIconProvider by inject() private val drawer: DrawerLayout = parent.findViewById(R.id.drawerLayout) private val sliderView: MaterialDrawerSliderView = parent.findViewById(R.id.material_drawer_slider) @@ -79,7 +79,6 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K dividerBelowHeader = false displayBadgesOnCurrentProfileImage = false } - private val folderIconProvider: FolderIconProvider = FolderIconProvider(parent.theme) private val swipeRefreshLayout: SwipeRefreshLayout private val userFolderDrawerIds = ArrayList() @@ -288,22 +287,13 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K sliderView.addStickyFooterItem( PrimaryDrawerItem().apply { nameRes = R.string.preferences_action - iconRes = getResId(R.attr.iconActionSettings) + iconRes = R.drawable.ic_cog identifier = DRAWER_ID_PREFERENCES isSelectable = false }, ) } - private fun getResId(resAttribute: Int): Int { - val typedValue = TypedValue() - val found = parent.theme.resolveAttribute(resAttribute, typedValue, true) - if (!found) { - throw AssertionError("Couldn't find resource with attribute $resAttribute") - } - return typedValue.resourceId - } - private fun getFolderDisplayName(folder: Folder): String { return folderNameFormatter.displayName(folder) } diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/FolderIconProvider.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/FolderIconProvider.kt index 40625b974..15076dbe0 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/FolderIconProvider.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/FolderIconProvider.kt @@ -1,39 +1,17 @@ package com.fsck.k9.ui.folders -import android.content.res.Resources -import android.util.TypedValue import com.fsck.k9.mailstore.FolderType import com.fsck.k9.ui.R -class FolderIconProvider(private val theme: Resources.Theme) { - private val iconFolderInboxResId: Int - private val iconFolderOutboxResId: Int - private val iconFolderSentResId: Int - private val iconFolderTrashResId: Int - private val iconFolderDraftsResId: Int - private val iconFolderArchiveResId: Int - private val iconFolderSpamResId: Int - var iconFolderResId: Int - - init { - iconFolderInboxResId = getResId(R.attr.iconFolderInbox) - iconFolderOutboxResId = getResId(R.attr.iconFolderOutbox) - iconFolderSentResId = getResId(R.attr.iconFolderSent) - iconFolderTrashResId = getResId(R.attr.iconFolderTrash) - iconFolderDraftsResId = getResId(R.attr.iconFolderDrafts) - iconFolderArchiveResId = getResId(R.attr.iconFolderArchive) - iconFolderSpamResId = getResId(R.attr.iconFolderSpam) - iconFolderResId = getResId(R.attr.iconFolder) - } - - private fun getResId(resAttribute: Int): Int { - val typedValue = TypedValue() - val found = theme.resolveAttribute(resAttribute, typedValue, true) - if (!found) { - throw AssertionError("Couldn't find resource with attribute $resAttribute") - } - return typedValue.resourceId - } +class FolderIconProvider { + private val iconFolderInboxResId: Int = R.drawable.ic_inbox + private val iconFolderOutboxResId: Int = R.drawable.ic_outbox + private val iconFolderSentResId: Int = R.drawable.ic_send + private val iconFolderTrashResId: Int = R.drawable.ic_trash_can + private val iconFolderDraftsResId: Int = R.drawable.ic_drafts_folder + private val iconFolderArchiveResId: Int = R.drawable.ic_archive + private val iconFolderSpamResId: Int = R.drawable.ic_alert_octagon + var iconFolderResId: Int = R.drawable.ic_folder fun getFolderIcon(type: FolderType): Int = when (type) { FolderType.INBOX -> iconFolderInboxResId diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/KoinModule.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/KoinModule.kt index 30fb5814f..835f93b2b 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/KoinModule.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/folders/KoinModule.kt @@ -1,11 +1,10 @@ package com.fsck.k9.ui.folders -import android.content.res.Resources.Theme import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.dsl.module val foldersUiModule = module { factory { FolderNameFormatter(resources = get()) } viewModel { FoldersViewModel(folderRepository = get(), messageCountsProvider = get()) } - factory { (theme: Theme) -> FolderIconProvider(theme) } + factory { FolderIconProvider() } } From 71d2bceccefc75430f1fe24cda294f52cfd2399d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Mon, 6 May 2024 16:39:22 +0200 Subject: [PATCH 5/8] Replace icon attr by direct drawable reference --- .../main/res/menu/unread_widget_option.xml | 4 +- .../k9/ui/messageview/MessageViewFragment.kt | 21 +-- .../ic_action_request_read_receipt_dark.png | Bin 979 -> 0 bytes .../ic_action_request_read_receipt_dark.png | Bin 705 -> 0 bytes .../ic_action_request_read_receipt_dark.png | Bin 1322 -> 0 bytes .../res/layout/message_compose_attachment.xml | 2 +- .../res/layout/message_compose_recipients.xml | 4 +- .../main/res/layout/message_list_fragment.xml | 2 +- .../res/layout/message_view_attachment.xml | 2 +- .../openpgp_encrypt_description_dialog.xml | 2 +- .../res/layout/recipient_alternate_item.xml | 2 +- .../main/res/layout/text_icon_list_item.xml | 2 +- .../main/res/menu/choose_folder_option.xml | 4 +- .../src/main/res/menu/folder_list_option.xml | 6 +- .../main/res/menu/general_settings_option.xml | 2 +- .../res/menu/manage_identities_option.xml | 2 +- .../main/res/menu/message_compose_option.xml | 10 +- .../main/res/menu/message_list_context.xml | 20 +-- .../src/main/res/menu/message_list_option.xml | 24 ++-- app/ui/legacy/src/main/res/values/attrs.xml | 49 ------- app/ui/legacy/src/main/res/values/themes.xml | 130 +++--------------- .../src/main/res/xml/account_settings.xml | 16 +-- .../src/main/res/xml/general_settings.xml | 12 +- 23 files changed, 87 insertions(+), 229 deletions(-) delete mode 100644 app/ui/legacy/src/main/res/drawable-hdpi/ic_action_request_read_receipt_dark.png delete mode 100644 app/ui/legacy/src/main/res/drawable-mdpi/ic_action_request_read_receipt_dark.png delete mode 100644 app/ui/legacy/src/main/res/drawable-xhdpi/ic_action_request_read_receipt_dark.png diff --git a/app/common/src/main/res/menu/unread_widget_option.xml b/app/common/src/main/res/menu/unread_widget_option.xml index 1033e42af..9e827f65d 100644 --- a/app/common/src/main/res/menu/unread_widget_option.xml +++ b/app/common/src/main/res/menu/unread_widget_option.xml @@ -5,6 +5,6 @@ android:id="@+id/done" android:title="@string/unread_widget_action_done" app:showAsAction="always" - android:icon="?attr/iconActionSave" + android:icon="@drawable/ic_floppy" /> - \ No newline at end of file + diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt index f01616905..ea8f7d852 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messageview/MessageViewFragment.kt @@ -18,7 +18,7 @@ import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.Toast import androidx.core.app.ActivityCompat -import androidx.core.content.withStyledAttributes +import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.Fragment import androidx.fragment.app.setFragmentResultListener @@ -240,16 +240,14 @@ class MessageViewFragment : menu.findItem(R.id.toggle_unread).setTitle(R.string.mark_as_read_action) } - val drawableAttr = if (isMessageRead) { - intArrayOf(R.attr.iconActionMarkAsUnread) + val drawableId = if (isMessageRead) { + R.drawable.ic_mark_new } else { - intArrayOf(R.attr.iconActionMarkAsRead) + R.drawable.ic_opened_envelope } - val toolbarContext = requireActivity().findViewById(R.id.toolbar).context - toolbarContext.withStyledAttributes(attrs = drawableAttr) { - menu.findItem(R.id.toggle_unread).icon = getDrawable(0) - } + val drawable = ContextCompat.getDrawable(requireContext(), drawableId) + menu.findItem(R.id.toggle_unread).icon = drawable } if (isMoveCapable) { @@ -588,9 +586,11 @@ class MessageViewFragment : MessageDetailsFragment.ACTION_SEARCH_KEYS -> { messageCryptoPresenter.onClickSearchKey() } + MessageDetailsFragment.ACTION_SHOW_WARNING -> { messageCryptoPresenter.onClickShowCryptoWarningDetails() } + else -> { error("Unsupported action: $action") } @@ -691,6 +691,7 @@ class MessageViewFragment : cancelText, ) } + R.id.dialog_confirm_spam -> { val title = getString(R.string.dialog_confirm_spam_title) val message = resources.getQuantityString(R.plurals.dialog_confirm_spam_message, 1) @@ -704,6 +705,7 @@ class MessageViewFragment : cancelText, ) } + R.id.dialog_attachment_progress -> { val currentAttachmentViewInfo = checkNotNull(this.currentAttachmentViewInfo) @@ -711,6 +713,7 @@ class MessageViewFragment : val size = currentAttachmentViewInfo.size AttachmentDownloadDialogFragment.newInstance(size, message) } + else -> { throw RuntimeException("Called showDialog(int) with unknown dialog id.") } @@ -787,9 +790,11 @@ class MessageViewFragment : putExtra(MessageCompose.EXTRA_ACCOUNT, messageReference.accountUuid) } } + is HttpsUnsubscribeUri -> { Intent(Intent.ACTION_VIEW, unsubscribeUri.uri) } + else -> error("Unknown UnsubscribeUri - $unsubscribeUri") } diff --git a/app/ui/legacy/src/main/res/drawable-hdpi/ic_action_request_read_receipt_dark.png b/app/ui/legacy/src/main/res/drawable-hdpi/ic_action_request_read_receipt_dark.png deleted file mode 100644 index 1950ff406cd4d17604db5da8023ca6ca9c130da5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 979 zcmV;^11$WBP)8}PxGvq^|KJ2(!%cX+p#QKSaeK-5NpZAJ;^iWN zDgs5@or2GWUp#<^3i^M-J9roucbTiymby;-BF@#6ZDUES`fNepX}lu*Vn048vF*8T zO6n3=%9N#Gr()xe;q{LBmP*FgvaMg$=tip@lgJTotIp0zs3LH%qyIwUymwfAu8)f1 zt!|=P#$xvO`7)s@0`JvSRD?|hZ68X@vdeh4n^09TmrwaA*ig`Rrib}TZK>LUXYi@m z##9GBf}eA3sZormspiBb>4hSJDgxsoe$U}!98jOgXSGc%#s=4KbrNYGt+T@MI*o73K8BaF-y3nis89!XrEFtNyh_aCd0eA7 zJYOx6+d4ekknTob=GJ42c*H8gpTZxuYOsW9`e|`qyuN*1(052&lIELK*mNN-CGJ9 zvFe{Bv9h)DibMz@G>S+CVS`$DR7KKgi?R6qnz=J>J9nnjj73j!Gjo5B^Znj)zQ1#R zxk90!k=E2u^#6fC%N+K$V-4CchEYt;H-Q%HL>}vqOU(VkW8A@bR)@JNMR*X$Dy(^j zi};hpVKo|9gkem@_bGh9Yo(#zfNfcwW{E&6daxf)BG`oRrR%X2FK`acanB_p*0o2U1LY3VBCt6AUNyUtCxzp7 zMhLn1eo6SSD~YvD=uh~bmB6$O31@pI>%{p4_-F+G65mJ4aQf4nq!D;4sJYVd=uLos z#RW4LpaS0DclkuMg(zufu`&L?hKIE{NfY4-EYGla1TW+BDZ}~|(RYcZrJzR$?-1?@ zM=Z^5W&nkiLJ7|cskl*z06_yi=oYHq-4r4@tQGQ_7J&{N!Vbj>`H!e8b;D+%qUG^4 z5*dr&r_mMH4JsbH&Ir6+hF+7k9XDf_(28#fwZAJdpBL)JkqDl-$yIwJnvTd%rAKO9 zh)Q?0K5MxVbwm=Eu}8@3Z5$PvR8>~%m8?&=2RswL{IJrL%sTtYR0!2*H5JQ{U!T-4)Y00000NkvXXu0mjfqs}?L diff --git a/app/ui/legacy/src/main/res/drawable-xhdpi/ic_action_request_read_receipt_dark.png b/app/ui/legacy/src/main/res/drawable-xhdpi/ic_action_request_read_receipt_dark.png deleted file mode 100644 index f39686cb34b133de9fb2445fceebd9d76c7fbec2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1322 zcmV+_1=aeAP)ehAYq0_Nd5T#w~CTiywLgwJrcO2LLIPJ|ZXPOR4(*~jo6_LV7A zE2<>mGCYe}1?M@7m+@<1iQ1sbAb13aOPFUCo)m6WI;uVeJ}GIQF>EPmu5(aT5L_an z``5ycFP-uKqd163VI_010yjwCloeG7S~dYoa5vTn7kCLfu~i&vUt*U~KEVQ<#1|si zJ%yn*b1xD^ohnn{vItm;yM*G2@QZP^ILbyE&p(AZZ`RBO=88PvLrmZ&?RR?!%Y@ZD zDvrrRMFlTPz*4c}tF_;?E!d8au@VnA#?CbJdBXfBL?V=C?sG*@T!*#zRuFM8Wqe2U zO29JB9nZpIJdbJ2=`i+4<2jl!=D4sRg7CEs8TJVxCOfQg9=au9ndXk?#q1noPKgs^ zzHp6pm=*zb)r`-F1PN<2Eh0A&c?no9cDx(K^Wr34#cy~_I$_@nqS6SWNkn212RbdD zhkz$=ZH{rh;E+)M4?H053TfCWV!(|#=3U)*eT6r(2Ie7PWsWhuU_V}Oyx%6}ehd4@C;g^iDL%54VGZTLm zoHxO+2(n4mnCZfKPl1J^s&j`X5xtu00XZ%yJzy9cgyM;tb*vtBdkkKJhZ>6%C88|M z7K-04J-(!(*E}F0BC&`G{U>5JZo+M{izt~Wng}frF=CS_XzY=Xh+&M2Bk_zVY5kmY z%{iKi&+k&+wt|#_1>!!RxW)KCI zKKfk|+A1RbyP|Q?ipxdsurI!!ppKH*IGz)o;z`Y}Z)wR*H>j&9N~E#lHLj1r4 + app:srcCompat="@drawable/ic_chevron_down" /> diff --git a/app/ui/legacy/src/main/res/layout/message_list_fragment.xml b/app/ui/legacy/src/main/res/layout/message_list_fragment.xml index 45ee0ebcb..0b9268298 100644 --- a/app/ui/legacy/src/main/res/layout/message_list_fragment.xml +++ b/app/ui/legacy/src/main/res/layout/message_list_fragment.xml @@ -33,7 +33,7 @@ android:layout_margin="@dimen/floatingActionButtonMargin" android:contentDescription="@string/compose_action" app:layout_behavior="com.fsck.k9.ui.fab.HideFabOnScrollBehavior" - app:srcCompat="?attr/iconActionCompose" + app:srcCompat="@drawable/ic_pencil" /> diff --git a/app/ui/legacy/src/main/res/layout/message_view_attachment.xml b/app/ui/legacy/src/main/res/layout/message_view_attachment.xml index 52d09b52a..f959e0ac4 100644 --- a/app/ui/legacy/src/main/res/layout/message_view_attachment.xml +++ b/app/ui/legacy/src/main/res/layout/message_view_attachment.xml @@ -90,7 +90,7 @@ android:layout_marginBottom="8dp" android:background="?attr/selectableItemBackgroundBorderless" android:contentDescription="@string/remove_attachment_action" - app:srcCompat="?attr/iconActionSaveAttachment" + app:srcCompat="@drawable/ic_download" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/attachment_preview" /> diff --git a/app/ui/legacy/src/main/res/layout/openpgp_encrypt_description_dialog.xml b/app/ui/legacy/src/main/res/layout/openpgp_encrypt_description_dialog.xml index cca575f8d..7cc150f3b 100644 --- a/app/ui/legacy/src/main/res/layout/openpgp_encrypt_description_dialog.xml +++ b/app/ui/legacy/src/main/res/layout/openpgp_encrypt_description_dialog.xml @@ -65,7 +65,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - app:srcCompat="?attr/iconActionNextStatus" + app:srcCompat="@drawable/ic_chevron_right" /> diff --git a/app/ui/legacy/src/main/res/layout/text_icon_list_item.xml b/app/ui/legacy/src/main/res/layout/text_icon_list_item.xml index c3c77f8d6..faf18f624 100644 --- a/app/ui/legacy/src/main/res/layout/text_icon_list_item.xml +++ b/app/ui/legacy/src/main/res/layout/text_icon_list_item.xml @@ -24,7 +24,7 @@ android:layout_height="40dp" android:contentDescription="@string/account_settings_action" android:padding="8dp" - app:srcCompat="?attr/iconActionSettings" /> + app:srcCompat="@drawable/ic_cog" /> @@ -22,7 +22,7 @@ android:title="@string/folder_list_display_mode_not_second_class" /> diff --git a/app/ui/legacy/src/main/res/menu/folder_list_option.xml b/app/ui/legacy/src/main/res/menu/folder_list_option.xml index 2f861c3b8..75f30c10a 100644 --- a/app/ui/legacy/src/main/res/menu/folder_list_option.xml +++ b/app/ui/legacy/src/main/res/menu/folder_list_option.xml @@ -3,12 +3,12 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> diff --git a/app/ui/legacy/src/main/res/menu/general_settings_option.xml b/app/ui/legacy/src/main/res/menu/general_settings_option.xml index e32677ed8..298cc51af 100644 --- a/app/ui/legacy/src/main/res/menu/general_settings_option.xml +++ b/app/ui/legacy/src/main/res/menu/general_settings_option.xml @@ -5,7 +5,7 @@ diff --git a/app/ui/legacy/src/main/res/menu/manage_identities_option.xml b/app/ui/legacy/src/main/res/menu/manage_identities_option.xml index 676b48be6..a6328e877 100644 --- a/app/ui/legacy/src/main/res/menu/manage_identities_option.xml +++ b/app/ui/legacy/src/main/res/menu/manage_identities_option.xml @@ -3,6 +3,6 @@ diff --git a/app/ui/legacy/src/main/res/menu/message_compose_option.xml b/app/ui/legacy/src/main/res/menu/message_compose_option.xml index 38d13b446..85a4966dd 100644 --- a/app/ui/legacy/src/main/res/menu/message_compose_option.xml +++ b/app/ui/legacy/src/main/res/menu/message_compose_option.xml @@ -4,13 +4,13 @@ diff --git a/app/ui/legacy/src/main/res/menu/message_list_option.xml b/app/ui/legacy/src/main/res/menu/message_list_option.xml index 7d57918c3..78ae2a971 100644 --- a/app/ui/legacy/src/main/res/menu/message_list_option.xml +++ b/app/ui/legacy/src/main/res/menu/message_list_option.xml @@ -11,7 +11,7 @@ @@ -19,7 +19,7 @@ @@ -27,7 +27,7 @@ @@ -35,7 +35,7 @@ @@ -43,7 +43,7 @@ @@ -51,7 +51,7 @@ @@ -59,7 +59,7 @@ @@ -67,7 +67,7 @@ @@ -121,14 +121,14 @@ @@ -159,7 +159,7 @@ @@ -172,7 +172,7 @@ diff --git a/app/ui/legacy/src/main/res/values/attrs.xml b/app/ui/legacy/src/main/res/values/attrs.xml index 64d15fbb5..4e75c4bea 100644 --- a/app/ui/legacy/src/main/res/values/attrs.xml +++ b/app/ui/legacy/src/main/res/values/attrs.xml @@ -2,55 +2,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index 3cefe7ee6..ef6621d57 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -66,55 +66,6 @@ @style/PreferenceThemeOverlay - @drawable/ic_folder - @drawable/ic_inbox - @drawable/ic_outbox - @drawable/ic_archive - @drawable/ic_drafts_folder - @drawable/ic_send - @drawable/ic_alert_octagon - @drawable/ic_trash_can - @drawable/ic_attachment - @drawable/ic_archive - @drawable/ic_pencil - @drawable/ic_trash_can - @drawable/ic_move_to_folder - @drawable/ic_content_copy - @drawable/ic_chevron_right - @drawable/ic_refresh - @drawable/ic_magnify - @drawable/ic_folder_magnify - @drawable/ic_send - @drawable/ic_cog - @drawable/ic_sort - @drawable/ic_alert_octagon - @drawable/ic_star - @drawable/ic_star_outline - @drawable/ic_opened_envelope - @drawable/ic_mark_new - @drawable/ic_magnify_cloud - @drawable/ic_plus - @drawable/ic_arrow_up_down - @drawable/ic_file_upload - @drawable/ic_select_all - @drawable/ic_floppy - @drawable/ic_download - @drawable/ic_clear - @drawable/ic_action_request_read_receipt_light - @drawable/ic_chevron_down - @drawable/ic_chevron_up - @drawable/ic_tv - @drawable/ic_touch - @drawable/ic_notifications - @drawable/ic_arrow_up_down - @drawable/ic_shield - @drawable/ic_bug - @drawable/ic_folder - @drawable/ic_magnify - @drawable/ic_preferences_crypto - @drawable/ic_preferences_check_mail - @drawable/ic_opened_envelope - @drawable/ic_pencil @drawable/ic_info @drawable/ic_cog @drawable/ic_account @@ -151,19 +102,19 @@ @color/material_gray_200 @drawable/ic_check_circle @color/material_blue_600 - ?attr/iconActionMarkAsRead - ?attr/iconActionMarkAsUnread + @drawable/ic_opened_envelope + @drawable/ic_mark_new @color/material_blue_600 - ?attr/iconActionFlag - ?attr/iconActionUnflag + @drawable/ic_star + @drawable/ic_star_outline @color/material_orange_600 - ?attr/iconActionArchive + @drawable/ic_archive @color/material_green_600 - ?attr/iconActionDelete + @drawable/ic_trash_can @color/material_red_600 - ?attr/iconActionSpam + @drawable/ic_alert_octagon @color/material_red_700 - ?attr/iconActionMove + @drawable/ic_move_to_folder @color/material_purple_500 #fbbc04 @@ -267,55 +218,6 @@ @style/PreferenceThemeOverlay - @drawable/ic_folder - @drawable/ic_inbox - @drawable/ic_outbox - @drawable/ic_archive - @drawable/ic_drafts_folder - @drawable/ic_send - @drawable/ic_alert_octagon - @drawable/ic_trash_can - @drawable/ic_attachment - @drawable/ic_archive - @drawable/ic_pencil - @drawable/ic_trash_can - @drawable/ic_folder - @drawable/ic_content_copy - @drawable/ic_chevron_right - @drawable/ic_refresh - @drawable/ic_magnify - @drawable/ic_folder_magnify - @drawable/ic_send - @drawable/ic_cog - @drawable/ic_sort - @drawable/ic_alert_octagon - @drawable/ic_star - @drawable/ic_star_outline - @drawable/ic_opened_envelope - @drawable/ic_mark_new - @drawable/ic_magnify_cloud - @drawable/ic_plus - @drawable/ic_arrow_up_down - @drawable/ic_file_upload - @drawable/ic_select_all - @drawable/ic_floppy - @drawable/ic_download - @drawable/ic_clear - @drawable/ic_action_request_read_receipt_dark - @drawable/ic_chevron_down - @drawable/ic_chevron_up - @drawable/ic_tv - @drawable/ic_touch - @drawable/ic_notifications - @drawable/ic_arrow_up_down - @drawable/ic_shield - @drawable/ic_bug - @drawable/ic_folder - @drawable/ic_magnify - @drawable/ic_preferences_crypto - @drawable/ic_preferences_check_mail - @drawable/ic_opened_envelope - @drawable/ic_pencil @drawable/ic_info @drawable/ic_cog @drawable/ic_account @@ -351,19 +253,19 @@ @color/material_gray_900 @drawable/ic_check_circle @color/material_blue_700 - ?attr/iconActionMarkAsRead - ?attr/iconActionMarkAsUnread + @drawable/ic_opened_envelope + @drawable/ic_mark_new @color/material_blue_700 - ?attr/iconActionFlag - ?attr/iconActionUnflag + @drawable/ic_star + @drawable/ic_star_outline @color/material_orange_700 - ?attr/iconActionArchive + @drawable/ic_archive @color/material_green_700 - ?attr/iconActionDelete + @drawable/ic_trash_can @color/material_red_700 - ?attr/iconActionSpam + @drawable/ic_alert_octagon @color/material_red_800 - ?attr/iconActionMove + @drawable/ic_move_to_folder @color/material_purple_600 #fdd663 diff --git a/app/ui/legacy/src/main/res/xml/account_settings.xml b/app/ui/legacy/src/main/res/xml/account_settings.xml index ffef29a1b..0510b076e 100644 --- a/app/ui/legacy/src/main/res/xml/account_settings.xml +++ b/app/ui/legacy/src/main/res/xml/account_settings.xml @@ -7,7 +7,7 @@ android:title="@string/account_settings_title_fmt"> @@ -25,7 +25,7 @@ @@ -45,7 +45,7 @@ @@ -152,7 +152,7 @@ @@ -228,7 +228,7 @@ @@ -293,7 +293,7 @@ @@ -378,7 +378,7 @@ @@ -393,7 +393,7 @@ diff --git a/app/ui/legacy/src/main/res/xml/general_settings.xml b/app/ui/legacy/src/main/res/xml/general_settings.xml index 4368c7d6f..a94f851f2 100644 --- a/app/ui/legacy/src/main/res/xml/general_settings.xml +++ b/app/ui/legacy/src/main/res/xml/general_settings.xml @@ -8,7 +8,7 @@ search:ignore="true"> @@ -305,7 +305,7 @@ @@ -364,7 +364,7 @@ @@ -415,7 +415,7 @@ @@ -431,7 +431,7 @@ @@ -449,7 +449,7 @@ From 5b25f302288aeaa99197aaf4d15ab667f8b9a2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Mon, 6 May 2024 18:28:24 +0200 Subject: [PATCH 6/8] Change Settings attr to direct drawable resource --- .../fsck/k9/ui/settings/SettingsActionItem.kt | 9 +++------ .../k9/ui/settings/SettingsListFragment.kt | 20 +++++++++---------- .../com/fsck/k9/ui/settings/UrlActionItem.kt | 9 +++------ .../src/main/res/layout/account_list_item.xml | 2 +- app/ui/legacy/src/main/res/values/attrs.xml | 8 -------- app/ui/legacy/src/main/res/values/themes.xml | 18 ++--------------- 6 files changed, 19 insertions(+), 47 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt index 83aa3d668..32b3bd986 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsActionItem.kt @@ -1,9 +1,9 @@ package com.fsck.k9.ui.settings -import android.util.TypedValue import android.view.View import android.widget.ImageView import android.widget.TextView +import androidx.annotation.DrawableRes import androidx.annotation.IdRes import com.fsck.k9.ui.R import com.mikepenz.fastadapter.FastAdapter @@ -13,7 +13,7 @@ internal class SettingsActionItem( override var identifier: Long, val text: String, @IdRes val navigationAction: Int, - val icon: Int, + @DrawableRes val icon: Int, ) : AbstractItem() { override val type = R.id.settings_list_action_item @@ -27,10 +27,7 @@ internal class SettingsActionItem( override fun bindView(item: SettingsActionItem, payloads: List) { text.text = item.text - - val outValue = TypedValue() - icon.context.theme.resolveAttribute(item.icon, outValue, true) - icon.setImageResource(outValue.resourceId) + icon.setImageResource(item.icon) } override fun unbindView(item: SettingsActionItem) { diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt index 42d08b88a..bc6ca12f7 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/SettingsListFragment.kt @@ -8,7 +8,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast -import androidx.annotation.AttrRes +import androidx.annotation.DrawableRes import androidx.annotation.IdRes import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController @@ -87,7 +87,7 @@ class SettingsListFragment : Fragment(), ItemTouchCallback { addAction( text = getString(R.string.general_settings_title), navigationAction = R.id.action_settingsListScreen_to_generalSettingsScreen, - icon = R.attr.iconSettingsGeneral, + icon = R.drawable.ic_cog, ) addSection(title = getString(R.string.accounts_title)) { @@ -99,7 +99,7 @@ class SettingsListFragment : Fragment(), ItemTouchCallback { addAction( text = getString(R.string.add_account_action), navigationAction = R.id.action_settingsListScreen_to_addAccountScreen, - icon = R.attr.iconSettingsAccountAdd, + icon = R.drawable.ic_account_plus, ) } @@ -107,13 +107,13 @@ class SettingsListFragment : Fragment(), ItemTouchCallback { addAction( text = getString(R.string.settings_export_title), navigationAction = R.id.action_settingsListScreen_to_settingsExportScreen, - icon = R.attr.iconSettingsExport, + icon = R.drawable.ic_export, ) addAction( text = getString(SettingsImportR.string.settings_import_title), navigationAction = R.id.action_settingsListScreen_to_settingsImportScreen, - icon = R.attr.iconSettingsImport, + icon = R.drawable.ic_import, ) } @@ -121,19 +121,19 @@ class SettingsListFragment : Fragment(), ItemTouchCallback { addAction( text = getString(R.string.about_action), navigationAction = R.id.action_settingsListScreen_to_aboutScreen, - icon = R.attr.iconSettingsAbout, + icon = R.drawable.ic_info, ) addUrlAction( text = getString(R.string.user_manual_title), url = getString(R.string.user_manual_url), - icon = R.attr.iconUserManual, + icon = R.drawable.ic_open_book, ) addUrlAction( text = getString(R.string.get_help_title), url = getString(R.string.user_forum_url), - icon = R.attr.iconHelp, + icon = R.drawable.ic_help, ) } } @@ -176,12 +176,12 @@ class SettingsListFragment : Fragment(), ItemTouchCallback { private val settingsList = mutableListOf() private var itemId = 0L - fun addAction(text: String, @IdRes navigationAction: Int, @AttrRes icon: Int) { + fun addAction(text: String, @IdRes navigationAction: Int, @DrawableRes icon: Int) { itemId++ settingsList.add(SettingsActionItem(itemId, text, navigationAction, icon)) } - fun addUrlAction(text: String, url: String, @AttrRes icon: Int) { + fun addUrlAction(text: String, url: String, @DrawableRes icon: Int) { itemId++ settingsList.add(UrlActionItem(itemId, text, url, icon)) } diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/UrlActionItem.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/UrlActionItem.kt index 6a2064a45..28ffb0ca5 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/UrlActionItem.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/settings/UrlActionItem.kt @@ -1,9 +1,9 @@ package com.fsck.k9.ui.settings -import android.util.TypedValue import android.view.View import android.widget.ImageView import android.widget.TextView +import androidx.annotation.DrawableRes import com.fsck.k9.ui.R import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.items.AbstractItem @@ -12,7 +12,7 @@ internal class UrlActionItem( override var identifier: Long, val text: String, val url: String, - val icon: Int, + @DrawableRes val icon: Int, ) : AbstractItem() { override val type = R.id.settings_list_url_item @@ -26,10 +26,7 @@ internal class UrlActionItem( override fun bindView(item: UrlActionItem, payloads: List) { text.text = item.text - - val outValue = TypedValue() - icon.context.theme.resolveAttribute(item.icon, outValue, true) - icon.setImageResource(outValue.resourceId) + icon.setImageResource(item.icon) } override fun unbindView(item: UrlActionItem) { diff --git a/app/ui/legacy/src/main/res/layout/account_list_item.xml b/app/ui/legacy/src/main/res/layout/account_list_item.xml index 9437333e2..f6163a231 100644 --- a/app/ui/legacy/src/main/res/layout/account_list_item.xml +++ b/app/ui/legacy/src/main/res/layout/account_list_item.xml @@ -21,7 +21,7 @@ android:layout_height="40dp" android:contentDescription="@string/account_settings_action" android:padding="8dp" - app:srcCompat="?attr/iconSettingsAccount" /> + app:srcCompat="@drawable/ic_account" /> - - - - - - @@ -67,8 +61,6 @@ - - diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index ef6621d57..7d9d1e5dd 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -66,12 +66,7 @@ @style/PreferenceThemeOverlay - @drawable/ic_info - @drawable/ic_cog - @drawable/ic_account - @drawable/ic_account_plus - @drawable/ic_export - @drawable/ic_import + // TODO: Remove iconSettingsImportStatus as soon icons are migrated to icon module @drawable/ic_import_status @android:color/primary_text_light @@ -134,8 +129,6 @@ @drawable/ic_description @drawable/ic_link @drawable/ic_forum - @drawable/ic_open_book - @drawable/ic_help @drawable/ic_mastodon @drawable/ic_visibility @@ -218,12 +211,7 @@ @style/PreferenceThemeOverlay - @drawable/ic_info - @drawable/ic_cog - @drawable/ic_account - @drawable/ic_account_plus - @drawable/ic_export - @drawable/ic_import + // TODO: Remove iconSettingsImportStatus as soon icons are migrated to icon module @drawable/ic_import_status @android:color/primary_text_dark @@ -285,8 +273,6 @@ @drawable/ic_description @drawable/ic_link @drawable/ic_forum - @drawable/ic_open_book - @drawable/ic_help @drawable/ic_mastodon @drawable/ic_visibility From 15682b779687106ab1ee442cbfbb7f97e0cc0161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Tue, 7 May 2024 11:46:46 +0200 Subject: [PATCH 7/8] Change about icons to direct reference --- .../src/main/res/layout/fragment_about.xml | 14 +++++++------- app/ui/legacy/src/main/res/values/attrs.xml | 8 -------- app/ui/legacy/src/main/res/values/themes.xml | 16 ---------------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/app/ui/legacy/src/main/res/layout/fragment_about.xml b/app/ui/legacy/src/main/res/layout/fragment_about.xml index 20a0fc43d..8c84ec5c9 100644 --- a/app/ui/legacy/src/main/res/layout/fragment_about.xml +++ b/app/ui/legacy/src/main/res/layout/fragment_about.xml @@ -47,7 +47,7 @@ android:layout_height="24dp" android:layout_gravity="center" android:contentDescription="@null" - app:srcCompat="?attr/iconAboutVersion" /> + app:srcCompat="@drawable/ic_info" /> + app:srcCompat="@drawable/ic_people" /> + app:srcCompat="@drawable/ic_code" /> + app:srcCompat="@drawable/ic_description" /> + app:srcCompat="@drawable/ic_link" /> + app:srcCompat="@drawable/ic_forum" /> + app:srcCompat="@drawable/ic_mastodon" /> - - - - - - - - diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index 7d9d1e5dd..160214a2f 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -123,14 +123,6 @@ #dd2222 #888 - @drawable/ic_info - @drawable/ic_people - @drawable/ic_code - @drawable/ic_description - @drawable/ic_link - @drawable/ic_forum - @drawable/ic_mastodon - @drawable/ic_visibility #000 #FF8800 @@ -267,14 +259,6 @@ #dd2222 #bbb - @drawable/ic_info - @drawable/ic_people - @drawable/ic_code - @drawable/ic_description - @drawable/ic_link - @drawable/ic_forum - @drawable/ic_mastodon - @drawable/ic_visibility #fff #ee7700 From de43f5aff51c44dd9714709e42dba0cb0070b077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Tue, 7 May 2024 12:24:00 +0200 Subject: [PATCH 8/8] Change message icons to direct drawable reference --- .../java/com/fsck/k9/ui/ThemeExtensions.kt | 12 -------- .../k9/ui/messagelist/MessageListAdapter.kt | 12 +++++--- .../ui/messagelist/SwipeResourceProvider.kt | 26 ++++++++-------- .../message_details_participant_item.xml | 2 +- .../src/main/res/layout/message_list_item.xml | 4 +-- .../layout/message_view_attachment_locked.xml | 2 +- app/ui/legacy/src/main/res/values/attrs.xml | 15 ---------- app/ui/legacy/src/main/res/values/themes.xml | 30 ------------------- 8 files changed, 25 insertions(+), 78 deletions(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt index 51c73e2d0..70819969e 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/ThemeExtensions.kt @@ -2,7 +2,6 @@ package com.fsck.k9.ui import android.content.res.Resources.Theme import android.graphics.Color -import android.graphics.drawable.Drawable import android.util.TypedValue fun Theme.resolveColorAttribute(attrId: Int): Int { @@ -42,17 +41,6 @@ fun Theme.resolveColorAttribute(colorAttrId: Int, alphaFractionAttrId: Int, back return Color.rgb(red.toInt(), green.toInt(), blue.toInt()) } -fun Theme.resolveDrawableAttribute(attrId: Int): Drawable { - val typedValue = TypedValue() - - val found = resolveAttribute(attrId, typedValue, true) - if (!found) { - throw IllegalStateException("Couldn't resolve attribute ($attrId)") - } - - return getDrawable(typedValue.resourceId) -} - fun Theme.getIntArray(attrId: Int): IntArray { val typedValue = TypedValue() diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt index 17263d9d0..8ae2d0b53 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/MessageListAdapter.kt @@ -33,7 +33,6 @@ import com.fsck.k9.mail.Address import com.fsck.k9.ui.R import com.fsck.k9.ui.helper.RelativeDateTimeFormatter import com.fsck.k9.ui.resolveColorAttribute -import com.fsck.k9.ui.resolveDrawableAttribute import kotlin.math.max private const val FOOTER_ID = 1L @@ -51,9 +50,10 @@ class MessageListAdapter internal constructor( private val relativeDateTimeFormatter: RelativeDateTimeFormatter, ) : RecyclerView.Adapter() { - private val forwardedIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListForwarded) - private val answeredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnswered) - private val forwardedAnsweredIcon: Drawable = theme.resolveDrawableAttribute(R.attr.messageListAnsweredForwarded) + private val forwardedIcon: Drawable = ResourcesCompat.getDrawable(res, R.drawable.ic_messagelist_forwarded, theme)!! + private val answeredIcon: Drawable = ResourcesCompat.getDrawable(res, R.drawable.ic_messagelist_answered, theme)!! + private val forwardedAnsweredIcon: Drawable = ResourcesCompat + .getDrawable(res, R.drawable.ic_messagelist_answered_forwarded, theme)!! private val unreadTextColor: Int = theme.resolveColorAttribute(R.attr.messageListUnreadTextColor) private val readTextColor: Int = theme.resolveColorAttribute(R.attr.messageListReadTextColor) private val previewTextColor: Int = theme.resolveColorAttribute(R.attr.messageListPreviewTextColor) @@ -317,11 +317,13 @@ class MessageListAdapter internal constructor( textViewMarginTop = compactTextViewMarginTop lineSpacingMultiplier = compactLineSpacingMultiplier } + UiDensity.Default -> { verticalPadding = defaultVerticalPadding textViewMarginTop = defaultTextViewMarginTop lineSpacingMultiplier = defaultLineSpacingMultiplier } + UiDensity.Relaxed -> { verticalPadding = relaxedVerticalPadding textViewMarginTop = relaxedTextViewMarginTop @@ -349,9 +351,11 @@ class MessageListAdapter internal constructor( val messageListItem = getItem(position) bindMessageViewHolder(holder as MessageViewHolder, messageListItem) } + TYPE_FOOTER -> { bindFooterViewHolder(holder as FooterViewHolder) } + else -> { error("Unsupported type: $viewType") } diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt index 55b09c816..c98305661 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/SwipeResourceProvider.kt @@ -2,24 +2,24 @@ package com.fsck.k9.ui.messagelist import android.content.res.Resources.Theme import android.graphics.drawable.Drawable -import androidx.annotation.AttrRes +import androidx.annotation.DrawableRes +import androidx.core.content.res.ResourcesCompat import com.fsck.k9.SwipeAction import com.fsck.k9.ui.R import com.fsck.k9.ui.resolveColorAttribute -import com.fsck.k9.ui.resolveDrawableAttribute class SwipeResourceProvider(val theme: Theme) { val iconTint = theme.resolveColorAttribute(R.attr.messageListSwipeIconTint) - private val selectIcon = theme.loadDrawable(R.attr.messageListSwipeSelectIcon) - private val markAsReadIcon = theme.loadDrawable(R.attr.messageListSwipeMarkAsReadIcon) - private val markAsUnreadIcon = theme.loadDrawable(R.attr.messageListSwipeMarkAsUnreadIcon) - private val addStarIcon = theme.loadDrawable(R.attr.messageListSwipeAddStarIcon) - private val removeStarIcon = theme.loadDrawable(R.attr.messageListSwipeRemoveStarIcon) - private val archiveIcon = theme.loadDrawable(R.attr.messageListSwipeArchiveIcon) - private val deleteIcon = theme.loadDrawable(R.attr.messageListSwipeDeleteIcon) - private val spamIcon = theme.loadDrawable(R.attr.messageListSwipeSpamIcon) - private val moveIcon = theme.loadDrawable(R.attr.messageListSwipeMoveIcon) + private val selectIcon = theme.loadDrawable(R.drawable.ic_check_circle) + private val markAsReadIcon = theme.loadDrawable(R.drawable.ic_opened_envelope) + private val markAsUnreadIcon = theme.loadDrawable(R.drawable.ic_mark_new) + private val addStarIcon = theme.loadDrawable(R.drawable.ic_star) + private val removeStarIcon = theme.loadDrawable(R.drawable.ic_star_outline) + private val archiveIcon = theme.loadDrawable(R.drawable.ic_archive) + private val deleteIcon = theme.loadDrawable(R.drawable.ic_trash_can) + private val spamIcon = theme.loadDrawable(R.drawable.ic_alert_octagon) + private val moveIcon = theme.loadDrawable(R.drawable.ic_move_to_folder) private val noActionColor = theme.resolveColorAttribute(R.attr.messageListSwipeDisabledBackgroundColor) private val selectColor = theme.resolveColorAttribute(R.attr.messageListSwipeSelectBackgroundColor) @@ -81,6 +81,6 @@ class SwipeResourceProvider(val theme: Theme) { } } -private fun Theme.loadDrawable(@AttrRes attributeId: Int): Drawable { - return resolveDrawableAttribute(attributeId).mutate() +private fun Theme.loadDrawable(@DrawableRes drawableResId: Int): Drawable { + return ResourcesCompat.getDrawable(resources, drawableResId, this)!! } diff --git a/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml b/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml index 84078125f..4a8079986 100644 --- a/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml +++ b/app/ui/legacy/src/main/res/layout/message_details_participant_item.xml @@ -63,7 +63,7 @@ android:paddingHorizontal="12dp" app:layout_constraintEnd_toStartOf="@id/menu_overflow" app:layout_constraintTop_toTopOf="@+id/menu_overflow" - app:srcCompat="?attr/messageDetailsAddContactIcon" /> + app:srcCompat="@drawable/ic_person_add" /> + app:srcCompat="@drawable/ic_messagelist_answered" /> + app:srcCompat="@drawable/ic_messagelist_attachment" /> - - - - - - - - - - - - - - @@ -54,7 +40,6 @@ - diff --git a/app/ui/legacy/src/main/res/values/themes.xml b/app/ui/legacy/src/main/res/values/themes.xml index 160214a2f..2b216d577 100644 --- a/app/ui/legacy/src/main/res/values/themes.xml +++ b/app/ui/legacy/src/main/res/values/themes.xml @@ -88,32 +88,18 @@ #ff444444 #ffcccccc #bbbbbb - @drawable/ic_messagelist_attachment - @drawable/ic_messagelist_answered - @drawable/ic_messagelist_forwarded - @drawable/ic_messagelist_answered_forwarded #ffffff @color/material_gray_200 - @drawable/ic_check_circle @color/material_blue_600 - @drawable/ic_opened_envelope - @drawable/ic_mark_new @color/material_blue_600 - @drawable/ic_star - @drawable/ic_star_outline @color/material_orange_600 - @drawable/ic_archive @color/material_green_600 - @drawable/ic_trash_can @color/material_red_600 - @drawable/ic_alert_octagon @color/material_red_700 - @drawable/ic_move_to_folder @color/material_purple_500 #fbbc04 - @drawable/ic_person_add #ffcccccc #ffababab @array/contact_picture_fallback_background_colors_light @@ -123,7 +109,6 @@ #dd2222 #888 - @drawable/ic_visibility #000 #FF8800 #CC0000 @@ -224,32 +209,18 @@ #ffaaaaaa #ff333333 #777777 - @drawable/ic_messagelist_attachment - @drawable/ic_messagelist_answered - @drawable/ic_messagelist_forwarded - @drawable/ic_messagelist_answered_forwarded #ffffff @color/material_gray_900 - @drawable/ic_check_circle @color/material_blue_700 - @drawable/ic_opened_envelope - @drawable/ic_mark_new @color/material_blue_700 - @drawable/ic_star - @drawable/ic_star_outline @color/material_orange_700 - @drawable/ic_archive @color/material_green_700 - @drawable/ic_trash_can @color/material_red_700 - @drawable/ic_alert_octagon @color/material_red_800 - @drawable/ic_move_to_folder @color/material_purple_600 #fdd663 - @drawable/ic_person_add #ff555555 #313131 #ff606060 @@ -259,7 +230,6 @@ #dd2222 #bbb - @drawable/ic_visibility #fff #ee7700 #CC0000