diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt index e5470df6..f9b19c69 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/ListSelectionAdapter.kt @@ -22,7 +22,6 @@ import android.view.ViewGroup import android.widget.ArrayAdapter import com.keylesspalace.tusky.R import com.keylesspalace.tusky.entity.MastoList -import com.keylesspalace.tusky.util.ThemeUtils import kotlinx.android.synthetic.main.item_picker_list.view.* class ListSelectionAdapter(context: Context) : ArrayAdapter(context, R.layout.item_autocomplete_hashtag) { @@ -34,10 +33,7 @@ class ListSelectionAdapter(context: Context) : ArrayAdapter(context, ?: layoutInflater.inflate(R.layout.item_picker_list, parent, false) getItem(position)?.let { list -> - val title = view.title - title.text = list.title - val icon = ThemeUtils.getTintedDrawable(context, R.drawable.ic_list, R.attr.iconColor) - title.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null) + view.title.text = list.title } return view diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/PreviewPollOptionsAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/PreviewPollOptionsAdapter.kt index bb77cd27..328e9626 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/PreviewPollOptionsAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/PreviewPollOptionsAdapter.kt @@ -22,7 +22,6 @@ import android.widget.TextView import androidx.core.widget.TextViewCompat import androidx.recyclerview.widget.RecyclerView import com.keylesspalace.tusky.R -import com.keylesspalace.tusky.util.ThemeUtils class PreviewPollOptionsAdapter: RecyclerView.Adapter() { @@ -55,9 +54,7 @@ class PreviewPollOptionsAdapter: RecyclerView.Adapter() { R.drawable.ic_radio_button_unchecked_18dp } - val iconDrawable = ThemeUtils.getTintedDrawable(textView.context, iconId, android.R.attr.textColorTertiary) - - TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, iconDrawable, null, null, null) + TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(textView, iconId, 0, 0, 0) textView.text = options[position] diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java index dadfb50b..23c0ed28 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java @@ -56,7 +56,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Locale; -import java.util.Objects; import at.connyduck.sparkbutton.SparkButton; import at.connyduck.sparkbutton.helpers.Utils; @@ -600,9 +599,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder { // Set the icon next to the label. int drawableId = getLabelIcon(attachments.get(0).getType()); - Drawable drawable = Objects.requireNonNull(context.getDrawable(drawableId)); - ThemeUtils.setDrawableTint(context, drawable, android.R.attr.textColorTertiary); - mediaLabel.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); + mediaLabel.setCompoundDrawablesWithIntrinsicBounds(drawableId, 0, 0, 0); setAttachmentClickListener(mediaLabel, listener, i, attachment, false); } else { diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt b/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt index cd877a15..b4517dc6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/TabAdapter.kt @@ -15,6 +15,7 @@ package com.keylesspalace.tusky.adapter +import android.content.res.ColorStateList import android.view.LayoutInflater import android.view.MotionEvent import android.view.View @@ -68,8 +69,7 @@ class TabAdapter(private var data: List, } else { holder.itemView.textView.setText(tab.text) } - val iconDrawable = ThemeUtils.getTintedDrawable(context, tab.icon, android.R.attr.textColorSecondary) - holder.itemView.textView.setCompoundDrawablesRelativeWithIntrinsicBounds(iconDrawable, null, null, null) + holder.itemView.textView.setCompoundDrawablesRelativeWithIntrinsicBounds(tab.icon, 0, 0, 0) if (small) { holder.itemView.textView.setOnClickListener { listener.onTabAdded(tab) @@ -110,6 +110,7 @@ class TabAdapter(private var data: List, val chip = holder.itemView.chipGroup.getChildAt(i).takeUnless { it.id == R.id.actionChip } as Chip? ?: Chip(context).apply { holder.itemView.chipGroup.addView(this, holder.itemView.chipGroup.size - 1) + chipIconTint = ColorStateList.valueOf(ThemeUtils.getColor(context, android.R.attr.textColorPrimary)) } chip.text = arg @@ -118,8 +119,7 @@ class TabAdapter(private var data: List, chip.chipIcon = null chip.setOnClickListener(null) } else { - val cancelIcon = ThemeUtils.getTintedDrawable(context, R.drawable.ic_cancel_24dp, android.R.attr.textColorPrimary) - chip.chipIcon = cancelIcon + chip.setChipIconResource(R.drawable.ic_cancel_24dp) chip.setOnClickListener { listener.onChipClicked(tab, holder.adapterPosition, i) } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt index eee6b39d..be1a3490 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt @@ -774,8 +774,7 @@ class ComposeActivity : BaseActivity(), Status.Visibility.UNLISTED -> R.drawable.ic_lock_open_24dp else -> R.drawable.ic_lock_open_24dp } - val drawable = ThemeUtils.getTintedDrawable(this, iconRes, android.R.attr.textColorTertiary) - composeToggleVisibilityButton.setImageDrawable(drawable) + composeToggleVisibilityButton.setImageResource(iconRes) } private fun showComposeOptions() { diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java index ca663936..a1a99a7d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/ComposeScheduleView.java @@ -26,13 +26,13 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.core.content.ContextCompat; import com.google.android.material.datepicker.CalendarConstraints; import com.google.android.material.datepicker.DateValidatorPointForward; import com.google.android.material.datepicker.MaterialDatePicker; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.fragment.TimePickerFragment; -import com.keylesspalace.tusky.util.ThemeUtils; import java.text.DateFormat; import java.text.ParseException; @@ -106,7 +106,7 @@ public class ComposeScheduleView extends ConstraintLayout { } private void setEditIcons() { - Drawable icon = ThemeUtils.getTintedDrawable(getContext(), R.drawable.ic_create_24dp, android.R.attr.textColorTertiary); + Drawable icon = ContextCompat.getDrawable(getContext(), R.drawable.ic_create_24dp); if (icon == null) { return; } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt index b48596d4..231a9145 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/AccountPreferencesFragment.kt @@ -16,10 +16,10 @@ package com.keylesspalace.tusky.components.preference import android.content.Intent -import android.graphics.drawable.Drawable import android.os.Build import android.os.Bundle import android.util.Log +import androidx.annotation.DrawableRes import androidx.preference.PreferenceFragmentCompat import com.google.android.material.snackbar.Snackbar import com.keylesspalace.tusky.* @@ -72,7 +72,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { preference { setTitle(R.string.title_tab_preferences) - icon = getTintedIcon(R.drawable.ic_tabs) + setIcon(R.drawable.ic_tabs) setOnPreferenceClickListener { val intent = Intent(context, TabPreferenceActivity::class.java) activity?.startActivity(intent) @@ -84,7 +84,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { preference { setTitle(R.string.action_view_mutes) - icon = getTintedIcon(R.drawable.ic_mute_24dp) + setIcon(R.drawable.ic_mute_24dp) setOnPreferenceClickListener { val intent = Intent(context, AccountListActivity::class.java) intent.putExtra("type", AccountListActivity.Type.MUTES) @@ -113,7 +113,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { preference { setTitle(R.string.title_domain_mutes) - icon = getTintedIcon(R.drawable.ic_mute_24dp) + setIcon(R.drawable.ic_mute_24dp) setOnPreferenceClickListener { val intent = Intent(context, InstanceListActivity::class.java) activity?.startActivity(intent) @@ -133,11 +133,9 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { val visibility = accountManager.activeAccount?.defaultPostPrivacy ?: Status.Visibility.PUBLIC value = visibility.serverString() - icon = getIconForVisibility(visibility) + setIcon(getIconForVisibility(visibility)) setOnPreferenceChangeListener { _, newValue -> - icon = getIconForVisibility( - Status.Visibility.byString(newValue as String) - ) + setIcon(getIconForVisibility(Status.Visibility.byString(newValue as String))) syncWithServer(visibility = newValue) eventHub.dispatch(PreferenceChangedEvent(key)) true @@ -182,9 +180,9 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { val sensitivity = accountManager.activeAccount?.defaultMediaSensitivity ?: false setDefaultValue(sensitivity) - icon = getIconForSensitivity(sensitivity) + setIcon(getIconForSensitivity(sensitivity)) setOnPreferenceChangeListener { _, newValue -> - icon = getIconForSensitivity(newValue as Boolean) + setIcon(getIconForSensitivity(newValue as Boolean)) syncWithServer(sensitive = newValue) eventHub.dispatch(PreferenceChangedEvent(key)) true @@ -349,30 +347,28 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { } } - private fun getIconForVisibility(visibility: Status.Visibility): Drawable? { - val drawableId = when (visibility) { + @DrawableRes + private fun getIconForVisibility(visibility: Status.Visibility): Int { + return when (visibility) { Status.Visibility.PRIVATE -> R.drawable.ic_lock_outline_24dp Status.Visibility.UNLISTED -> R.drawable.ic_lock_open_24dp else -> R.drawable.ic_public_24dp } - - return getTintedIcon(drawableId) } - private fun getIconForSensitivity(sensitive: Boolean): Drawable? { - val drawableId = if (sensitive) { + @DrawableRes + private fun getIconForSensitivity(sensitive: Boolean): Int { + return if (sensitive) { R.drawable.ic_hide_media_24dp } else { R.drawable.ic_eye_24dp } - - return getTintedIcon(drawableId) } private fun getIconForSyntax(syntax: String): Drawable? { - val drawableId = when(syntax) { + return when(syntax) { "text/html" -> R.drawable.ic_html_24dp "text/bbcode" -> R.drawable.ic_bbcode_24dp "text/markdown" -> R.drawable.ic_markdown @@ -382,11 +378,6 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(), Injectable { return getTintedIcon(drawableId) } - private fun getTintedIcon(iconId: Int): Drawable? { - if(iconId == 0) return null - return ThemeUtils.getTintedDrawable(requireContext(), iconId, R.attr.iconColor) - } - private fun launchFilterActivity(filterContext: String, titleResource: Int) { val intent = Intent(context, FiltersActivity::class.java) intent.putExtra(FiltersActivity.FILTERS_CONTEXT, filterContext) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt index e5574287..a3b9070c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesFragment.kt @@ -39,7 +39,6 @@ class PreferencesFragment : PreferenceFragmentCompat(), Injectable { private var httpProxyPref: Preference? = null override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - val context = requireContext() makePreferenceScreen { preferenceCategory(R.string.pref_title_appearance_settings) { listPreference { @@ -115,11 +114,8 @@ class PreferencesFragment : PreferenceFragmentCompat(), Injectable { key = PrefKeys.SHOW_BOT_OVERLAY setTitle(R.string.pref_title_bot_overlay) isSingleLineTitle = false - icon = ThemeUtils.getTintedDrawable( - context, - R.drawable.ic_bot_24dp, - R.attr.iconColor - ) + setIcon(R.drawable.ic_bot_24dp) + } switchPreference { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt b/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt index 3fdf0015..e8b019f6 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/StatusViewHelper.kt @@ -23,7 +23,6 @@ import android.view.View import android.widget.ImageView import android.widget.TextView import androidx.annotation.DrawableRes -import androidx.appcompat.content.res.AppCompatResources import com.bumptech.glide.Glide import com.keylesspalace.tusky.R import com.keylesspalace.tusky.entity.Attachment @@ -220,9 +219,7 @@ class StatusViewHelper(private val itemView: View) { // Set the icon next to the label. val drawableId = getLabelIcon(attachments[0].type) - val drawable = AppCompatResources.getDrawable(context, drawableId) - ThemeUtils.setDrawableTint(context, drawable!!, android.R.attr.textColorTertiary) - mediaLabel.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null) + mediaLabel.setCompoundDrawablesWithIntrinsicBounds(drawableId, 0, 0, 0) mediaLabel.setOnClickListener { listener.onViewMedia(null, 0) } } diff --git a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java index 9f7be621..d01775dd 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java +++ b/app/src/main/java/com/keylesspalace/tusky/util/ThemeUtils.java @@ -22,9 +22,7 @@ import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import androidx.annotation.AttrRes; import androidx.annotation.ColorInt; -import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatDelegate; import android.util.TypedValue; @@ -59,17 +57,6 @@ public class ThemeUtils { return dimen; } - /** this can be replaced with drawableTint in xml once minSdkVersion >= 23 */ - @Nullable - public static Drawable getTintedDrawable(@NonNull Context context, @DrawableRes int drawableId, @AttrRes int colorAttr) { - Drawable drawable = context.getDrawable(drawableId); - if(drawable == null) { - return null; - } - setDrawableTint(context, drawable, colorAttr); - return drawable; - } - public static void setDrawableTint(Context context, Drawable drawable, @AttrRes int attribute) { drawable.setColorFilter(getColor(context, attribute), PorterDuff.Mode.SRC_IN); } diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index 3ada6d9e..2003d37c 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -193,11 +193,11 @@ - + android:scrollbars="none" + android:visibility="gone" /> + + app:srcCompat="@drawable/ic_attach_file_24dp" + app:tooltipText="@string/action_add_media" /> + app:srcCompat="@drawable/ic_cw_24dp" + app:tooltipText="@string/action_content_warning" /> + app:srcCompat="@drawable/ic_emoji_24dp" + app:tooltipText="@string/action_emoji_keyboard" /> + app:srcCompat="@drawable/ic_access_time" + app:tooltipText="@string/action_schedule_toot" /> + app:srcCompat="@drawable/ic_markdown" + app:tooltipText="@string/action_markdown" /> + app:srcCompat="@drawable/ic_sticker" + app:tooltipText="@string/action_sticker" /> diff --git a/app/src/main/res/layout/item_autocomplete_hashtag.xml b/app/src/main/res/layout/item_autocomplete_hashtag.xml index 33247421..79148d25 100644 --- a/app/src/main/res/layout/item_autocomplete_hashtag.xml +++ b/app/src/main/res/layout/item_autocomplete_hashtag.xml @@ -1,8 +1,11 @@ + android:textStyle="normal|bold" + app:drawableStartCompat="@drawable/ic_list" + app:drawableTint="?attr/iconColor" /> diff --git a/app/src/main/res/layout/item_media_preview.xml b/app/src/main/res/layout/item_media_preview.xml index ab0fe073..27b58e7a 100644 --- a/app/src/main/res/layout/item_media_preview.xml +++ b/app/src/main/res/layout/item_media_preview.xml @@ -141,6 +141,7 @@ android:importantForAccessibility="no" android:textSize="?attr/status_text_medium" android:visibility="gone" + app:drawableTint="?android:attr/textColorTertiary" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -154,6 +155,7 @@ android:importantForAccessibility="no" android:textSize="?attr/status_text_medium" android:visibility="gone" + app:drawableTint="?android:attr/textColorTertiary" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/status_media_label_0" /> @@ -167,6 +169,7 @@ android:importantForAccessibility="no" android:textSize="?attr/status_text_medium" android:visibility="gone" + app:drawableTint="?android:attr/textColorTertiary" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/status_media_label_1" /> @@ -180,6 +183,7 @@ android:importantForAccessibility="no" android:textSize="?attr/status_text_medium" android:visibility="gone" + app:drawableTint="?android:attr/textColorTertiary" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/status_media_label_2" /> diff --git a/app/src/main/res/layout/item_poll_preview_option.xml b/app/src/main/res/layout/item_poll_preview_option.xml index d7f5887a..e8fa9849 100644 --- a/app/src/main/res/layout/item_poll_preview_option.xml +++ b/app/src/main/res/layout/item_poll_preview_option.xml @@ -1,5 +1,6 @@ \ No newline at end of file + android:maxEms="20" + app:drawableTint="?android:attr/textColorTertiary" /> \ No newline at end of file diff --git a/app/src/main/res/layout/item_report_status.xml b/app/src/main/res/layout/item_report_status.xml index 1bb6b774..2fe858f4 100644 --- a/app/src/main/res/layout/item_report_status.xml +++ b/app/src/main/res/layout/item_report_status.xml @@ -198,8 +198,8 @@ app:layout_constraintLeft_toLeftOf="@+id/status_media_preview_container" app:layout_constraintTop_toTopOf="@+id/status_media_preview_container" app:srcCompat="@drawable/ic_eye_24dp" - tools:visibility="visible" - app:tint="@color/white" /> + app:tint="@color/white" + tools:visibility="visible" /> diff --git a/app/src/main/res/layout/item_status.xml b/app/src/main/res/layout/item_status.xml index 82e3a2a7..a85bbe47 100644 --- a/app/src/main/res/layout/item_status.xml +++ b/app/src/main/res/layout/item_status.xml @@ -199,9 +199,9 @@ android:foreground="?attr/selectableItemBackground" android:minHeight="80dp" android:orientation="vertical" + app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="@id/status_display_name" app:layout_constraintTop_toBottomOf="@+id/button_toggle_content" - app:layout_constraintEnd_toEndOf="parent" tools:visibility="gone"> + android:textSize="?attr/status_text_large" + app:drawableStartCompat="@drawable/ic_home_24dp" + app:drawableTint="?android:attr/textColorSecondary" /> diff --git a/app/src/main/res/layout/view_compose_schedule.xml b/app/src/main/res/layout/view_compose_schedule.xml index b07270f6..7ae003c4 100644 --- a/app/src/main/res/layout/view_compose_schedule.xml +++ b/app/src/main/res/layout/view_compose_schedule.xml @@ -23,6 +23,7 @@ android:paddingBottom="16dp" android:textColor="?android:textColorTertiary" android:textSize="?attr/status_text_medium" + app:drawableTint="?android:attr/textColorTertiary" app:layout_constraintBottom_toTopOf="@id/invalidScheduleWarning" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="1" @@ -39,11 +40,11 @@ android:paddingBottom="16dp" android:textColor="?android:textColorTertiary" android:textSize="?attr/status_text_medium" + android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="1" app:layout_constraintStart_toStartOf="parent" - tools:text="@string/warning_scheduling_interval" - android:visibility="gone" /> + tools:text="@string/warning_scheduling_interval" /> \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ea5ace31..d8a801e0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -86,6 +86,8 @@ @color/textColorSecondary @style/Widget.MaterialComponents.Chip.Choice + + @style/TuskyPreferenceTheme + +