Theme refactoring (#1656)
* Theme refactoring * disable the automatic tinting of surfaces with elevation in dark mode * make the media warning visible again with the dark theme * fix nav bar on api 27+ * use correct color for all media warnings
This commit is contained in:
parent
29ef92edd3
commit
8767d2ed3d
122 changed files with 330 additions and 724 deletions
|
@ -19,13 +19,14 @@ import android.animation.ArgbEvaluator
|
|||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.*
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.Px
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
|
@ -239,9 +240,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
|||
setDisplayShowTitleEnabled(false)
|
||||
}
|
||||
|
||||
ThemeUtils.setDrawableTint(this, accountToolbar.navigationIcon, R.attr.account_toolbar_icon_tint_uncollapsed)
|
||||
ThemeUtils.setDrawableTint(this, accountToolbar.overflowIcon, R.attr.account_toolbar_icon_tint_uncollapsed)
|
||||
|
||||
val appBarElevation = resources.getDimension(R.dimen.actionbar_elevation)
|
||||
|
||||
val toolbarBackground = MaterialShapeDrawable.createWithElevationOverlay(this, appBarElevation)
|
||||
|
@ -262,9 +260,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
|||
// Add a listener to change the toolbar icon color when it enters/exits its collapsed state.
|
||||
accountAppBarLayout.addOnOffsetChangedListener(object : AppBarLayout.OnOffsetChangedListener {
|
||||
|
||||
@AttrRes
|
||||
var priorAttribute = R.attr.account_toolbar_icon_tint_uncollapsed
|
||||
|
||||
override fun onOffsetChanged(appBarLayout: AppBarLayout, verticalOffset: Int) {
|
||||
|
||||
if (verticalOffset == oldOffset) {
|
||||
|
@ -272,20 +267,10 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidI
|
|||
}
|
||||
oldOffset = verticalOffset
|
||||
|
||||
@AttrRes val attribute = if (titleVisibleHeight + verticalOffset < 0) {
|
||||
if (titleVisibleHeight + verticalOffset < 0) {
|
||||
supportActionBar?.setDisplayShowTitleEnabled(true)
|
||||
|
||||
R.attr.account_toolbar_icon_tint_collapsed
|
||||
} else {
|
||||
supportActionBar?.setDisplayShowTitleEnabled(false)
|
||||
|
||||
R.attr.account_toolbar_icon_tint_uncollapsed
|
||||
}
|
||||
if (attribute != priorAttribute) {
|
||||
priorAttribute = attribute
|
||||
val context = accountToolbar.context
|
||||
ThemeUtils.setDrawableTint(context, accountToolbar.navigationIcon, attribute)
|
||||
ThemeUtils.setDrawableTint(context, accountToolbar.overflowIcon, attribute)
|
||||
}
|
||||
|
||||
if (hideFab && !viewModel.isSelf && !blocking) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
/* set the taskdescription programmatically, the theme would turn it blue */
|
||||
String appName = getString(R.string.app_name);
|
||||
Bitmap appIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
|
||||
int recentsBackgroundColor = ThemeUtils.getColor(this, R.attr.recents_background_color);
|
||||
int recentsBackgroundColor = ThemeUtils.getColor(this, R.attr.colorSurface);
|
||||
|
||||
setTaskDescription(new ActivityManager.TaskDescription(appName, appIcon, recentsBackgroundColor));
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ class LoginActivity : BaseActivity(), Injectable {
|
|||
|
||||
private fun openInCustomTab(uri: Uri, context: Context): Boolean {
|
||||
|
||||
val toolbarColor = ThemeUtils.getColor(context, R.attr.custom_tab_toolbar)
|
||||
val toolbarColor = ThemeUtils.getColor(context, R.attr.colorSurface)
|
||||
val customTabsIntentBuilder = CustomTabsIntent.Builder()
|
||||
.setToolbarColor(toolbarColor)
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut
|
|||
|
||||
ImageView background = headerResult.getHeaderBackgroundView();
|
||||
background.setColorFilter(ContextCompat.getColor(this, R.color.header_background_filter));
|
||||
background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark));
|
||||
background.setBackgroundColor(ContextCompat.getColor(this, R.color.tusky_grey_10));
|
||||
|
||||
final boolean animateAvatars = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.getBoolean("animateGifAvatars", false);
|
||||
|
|
|
@ -44,7 +44,7 @@ fun createTabDataFromId(id: String, arguments: List<String> = emptyList()): TabD
|
|||
NOTIFICATIONS -> TabData(NOTIFICATIONS, R.string.title_notifications, R.drawable.ic_notifications_24dp, { NotificationsFragment.newInstance() })
|
||||
LOCAL -> TabData(LOCAL, R.string.title_public_local, R.drawable.ic_local_24dp, { TimelineFragment.newInstance(TimelineFragment.Kind.PUBLIC_LOCAL) })
|
||||
FEDERATED -> TabData(FEDERATED, R.string.title_public_federated, R.drawable.ic_public_24dp, { TimelineFragment.newInstance(TimelineFragment.Kind.PUBLIC_FEDERATED) })
|
||||
DIRECT -> TabData(DIRECT, R.string.title_direct_messages, R.drawable.reblog_direct_dark, { ConversationsFragment.newInstance() })
|
||||
DIRECT -> TabData(DIRECT, R.string.title_direct_messages, R.drawable.ic_reblog_direct_24dp, { ConversationsFragment.newInstance() })
|
||||
HASHTAG -> TabData(HASHTAG, R.string.hashtag, R.drawable.ic_hashtag, { args -> TimelineFragment.newInstance(TimelineFragment.Kind.TAG, args.getOrNull(0).orEmpty()) }, arguments)
|
||||
LIST -> TabData(LIST, R.string.list, R.drawable.ic_list, { args -> TimelineFragment.newInstance(TimelineFragment.Kind.LIST, args.getOrNull(0).orEmpty()) }, arguments)
|
||||
else -> throw IllegalArgumentException("unknown tab type")
|
||||
|
|
|
@ -41,7 +41,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
|
|||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.android.synthetic.main.activity_tab_preference.*
|
||||
import kotlinx.android.synthetic.main.toolbar_basic.*
|
||||
import kotlinx.android.synthetic.main.item_tab_preference.view.removeButton
|
||||
import java.util.regex.Pattern
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -27,19 +27,16 @@ import kotlinx.android.synthetic.main.item_picker_list.view.*
|
|||
|
||||
class ListSelectionAdapter(context: Context) : ArrayAdapter<MastoList>(context, R.layout.item_autocomplete_hashtag) {
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
var view = convertView
|
||||
|
||||
if (convertView == null) {
|
||||
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
view = layoutInflater.inflate(R.layout.item_picker_list, parent, false)
|
||||
}
|
||||
view!!
|
||||
val layoutInflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||
|
||||
val list = getItem(position)
|
||||
if (list != null) {
|
||||
val view = convertView
|
||||
?: 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, android.R.attr.textColorTertiary)
|
||||
val icon = ThemeUtils.getTintedDrawable(context, R.drawable.ic_list, R.attr.iconColor)
|
||||
title.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null)
|
||||
}
|
||||
|
||||
|
|
|
@ -153,10 +153,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
this.avatarRadius36dp = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.avatar_radius_36dp);
|
||||
this.avatarRadius24dp = itemView.getContext().getResources().getDimensionPixelSize(R.dimen.avatar_radius_24dp);
|
||||
|
||||
mediaPreviewUnloaded = itemView.getContext().getDrawable(
|
||||
ThemeUtils.getDrawableId(itemView.getContext(),
|
||||
R.attr.media_preview_unloaded_drawable, android.R.color.black)
|
||||
);
|
||||
mediaPreviewUnloaded = new ColorDrawable(ThemeUtils.getColor(itemView.getContext(), R.attr.colorBackgroundAccent));
|
||||
}
|
||||
|
||||
protected abstract int getMediaPreviewHeight(Context context);
|
||||
|
@ -353,12 +350,10 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
int inactiveId;
|
||||
int activeId;
|
||||
if (visibility == Status.Visibility.PRIVATE) {
|
||||
inactiveId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_disabled_drawable, R.drawable.reblog_private_dark);
|
||||
activeId = R.drawable.reblog_private_active;
|
||||
inactiveId = R.drawable.ic_reblog_private_24dp;
|
||||
activeId = R.drawable.ic_reblog_private_active_24dp;
|
||||
} else {
|
||||
inactiveId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_inactive_drawable, R.drawable.reblog_inactive_dark);
|
||||
inactiveId = R.drawable.ic_reblog_24dp;
|
||||
activeId = R.drawable.ic_reblog_active_24dp;
|
||||
}
|
||||
reblogButton.setInactiveImage(inactiveId);
|
||||
|
@ -366,11 +361,9 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
} else {
|
||||
int disabledId;
|
||||
if (visibility == Status.Visibility.DIRECT) {
|
||||
disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_direct_drawable, R.drawable.reblog_direct_dark);
|
||||
disabledId = R.drawable.ic_reblog_direct_24dp;
|
||||
} else {
|
||||
disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(),
|
||||
R.attr.status_reblog_disabled_drawable, R.drawable.reblog_private_dark);
|
||||
disabledId = R.drawable.ic_reblog_private_24dp;
|
||||
}
|
||||
reblogButton.setInactiveImage(disabledId);
|
||||
reblogButton.setActiveImage(disabledId);
|
||||
|
@ -468,8 +461,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
BitmapDrawable blurhashBitmap = decodeBlurHash(attachment.getBlurhash());
|
||||
imageView.setImageDrawable(blurhashBitmap);
|
||||
} else {
|
||||
imageView.setImageDrawable(new ColorDrawable(ThemeUtils.getColor(
|
||||
context, R.attr.sensitive_media_warning_background_color)));
|
||||
imageView.setImageDrawable(mediaPreviewUnloaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class TabAdapter(private var data: List<TabData>,
|
|||
ThemeUtils.setDrawableTint(
|
||||
holder.itemView.context,
|
||||
holder.itemView.removeButton.drawable,
|
||||
(if (removeButtonEnabled) android.R.attr.textColorTertiary else R.attr.image_button_disabled_tint)
|
||||
(if (removeButtonEnabled) android.R.attr.textColorTertiary else R.attr.textColorDisabled)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ import androidx.annotation.ColorInt
|
|||
import androidx.annotation.StringRes
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
|
@ -387,9 +386,7 @@ class ComposeActivity : BaseActivity(),
|
|||
title = null
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
setDisplayShowHomeEnabled(true)
|
||||
val closeIcon = AppCompatResources.getDrawable(this@ComposeActivity, R.drawable.ic_close_24dp)
|
||||
ThemeUtils.setDrawableTint(this@ComposeActivity, closeIcon!!, R.attr.compose_close_button_tint)
|
||||
setHomeAsUpIndicator(closeIcon)
|
||||
setHomeAsUpIndicator(R.drawable.ic_close_24dp)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -505,7 +502,7 @@ class ComposeActivity : BaseActivity(),
|
|||
@ColorInt val color = if (contentWarningShown) {
|
||||
composeHideMediaButton.setImageResource(R.drawable.ic_hide_media_24dp)
|
||||
composeHideMediaButton.isClickable = false
|
||||
ContextCompat.getColor(this, R.color.compose_media_visible_button_disabled_blue)
|
||||
ContextCompat.getColor(this, R.color.transparent_tusky_blue)
|
||||
|
||||
} else {
|
||||
composeHideMediaButton.isClickable = true
|
||||
|
@ -826,14 +823,14 @@ class ComposeActivity : BaseActivity(),
|
|||
button.isEnabled = clickable
|
||||
ThemeUtils.setDrawableTint(this, button.drawable,
|
||||
if (colorActive) android.R.attr.textColorTertiary
|
||||
else R.attr.image_button_disabled_tint)
|
||||
else R.attr.textColorDisabled)
|
||||
}
|
||||
|
||||
private fun enablePollButton(enable: Boolean) {
|
||||
addPollTextActionTextView.isEnabled = enable
|
||||
val textColor = ThemeUtils.getColor(this,
|
||||
if (enable) android.R.attr.textColorTertiary
|
||||
else R.attr.image_button_disabled_tint)
|
||||
else R.attr.textColorDisabled)
|
||||
addPollTextActionTextView.setTextColor(textColor)
|
||||
addPollTextActionTextView.compoundDrawablesRelative[0].colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public final class ProgressImageView extends AppCompatImageView {
|
|||
|
||||
markBgPaint.setStyle(Paint.Style.FILL);
|
||||
markBgPaint.setColor(ContextCompat.getColor(getContext(),
|
||||
R.color.description_marker_unselected));
|
||||
R.color.tusky_grey_10));
|
||||
captionDrawable = AppCompatResources.getDrawable(getContext(), R.drawable.spellcheck);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public final class ProgressImageView extends AppCompatImageView {
|
|||
|
||||
public void setChecked(boolean checked) {
|
||||
this.markBgPaint.setColor(ContextCompat.getColor(getContext(),
|
||||
checked ? R.color.tusky_blue : R.color.description_marker_unselected));
|
||||
checked ? R.color.tusky_blue : R.color.tusky_grey_10));
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,14 +60,11 @@ class ReportActivity : BottomSheetActivity(), HasAndroidInjector {
|
|||
|
||||
setSupportActionBar(toolbar)
|
||||
|
||||
val closeIcon = AppCompatResources.getDrawable(this, R.drawable.ic_close_24dp)
|
||||
ThemeUtils.setDrawableTint(this, closeIcon!!, R.attr.compose_close_button_tint)
|
||||
|
||||
supportActionBar?.apply {
|
||||
title = getString(R.string.report_username_format, viewModel.accountUserName)
|
||||
setDisplayHomeAsUpEnabled(true)
|
||||
setDisplayShowHomeEnabled(true)
|
||||
setHomeAsUpIndicator(closeIcon)
|
||||
setHomeAsUpIndicator(R.drawable.ic_close_24dp)
|
||||
}
|
||||
|
||||
initViewPager()
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -179,15 +178,11 @@ class AccountMediaFragment : BaseFragment(), RefreshableFragment, Injectable {
|
|||
val columnCount = view.context.resources.getInteger(R.integer.profile_media_column_count)
|
||||
val layoutManager = GridLayoutManager(view.context, columnCount)
|
||||
|
||||
val bgRes = ThemeUtils.getColorId(view.context, R.attr.window_background)
|
||||
|
||||
adapter.baseItemColor = ContextCompat.getColor(recyclerView.context, bgRes)
|
||||
adapter.baseItemColor = ThemeUtils.getColor(view.context, android.R.attr.windowBackground)
|
||||
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
|
||||
|
||||
if (isSwipeToRefreshEnabled) {
|
||||
swipeRefreshLayout.setOnRefreshListener {
|
||||
refresh()
|
||||
|
|
|
@ -92,9 +92,9 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
|
|||
publicFiltersPreference = requirePreference("publicFilters")
|
||||
threadFiltersPreference = requirePreference("threadFilters")
|
||||
|
||||
notificationPreference.icon = IconicsDrawable(notificationPreference.context, GoogleMaterial.Icon.gmd_notifications).sizePx(iconSize).color(ThemeUtils.getColor(notificationPreference.context, R.attr.preference_icon_tint))
|
||||
notificationPreference.icon = IconicsDrawable(notificationPreference.context, GoogleMaterial.Icon.gmd_notifications).sizePx(iconSize).color(ThemeUtils.getColor(notificationPreference.context, R.attr.iconColor))
|
||||
mutedUsersPreference.icon = getTintedIcon(R.drawable.ic_mute_24dp)
|
||||
blockedUsersPreference.icon = IconicsDrawable(blockedUsersPreference.context, GoogleMaterial.Icon.gmd_block).sizePx(iconSize).color(ThemeUtils.getColor(blockedUsersPreference.context, R.attr.preference_icon_tint))
|
||||
blockedUsersPreference.icon = IconicsDrawable(blockedUsersPreference.context, GoogleMaterial.Icon.gmd_block).sizePx(iconSize).color(ThemeUtils.getColor(blockedUsersPreference.context, R.attr.iconColor))
|
||||
mutedDomainsPreference.icon = getTintedIcon(R.drawable.ic_mute_24dp)
|
||||
|
||||
notificationPreference.onPreferenceClickListener = this
|
||||
|
@ -288,9 +288,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
|
|||
}
|
||||
|
||||
private fun getTintedIcon(iconId: Int): Drawable? {
|
||||
val drawable = context?.getDrawable(iconId)
|
||||
ThemeUtils.setDrawableTint(context, drawable, R.attr.preference_icon_tint)
|
||||
return drawable
|
||||
return ThemeUtils.getTintedDrawable(requireContext(), iconId, R.attr.iconColor)
|
||||
}
|
||||
|
||||
private fun launchFilterActivity(filterContext: String, titleResource: Int): Boolean {
|
||||
|
@ -303,9 +301,7 @@ class AccountPreferencesFragment : PreferenceFragmentCompat(),
|
|||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(): AccountPreferencesFragment {
|
||||
return AccountPreferencesFragment()
|
||||
}
|
||||
fun newInstance() = AccountPreferencesFragment()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,13 +38,13 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
|||
addPreferencesFromResource(R.xml.preferences)
|
||||
|
||||
val themePreference: Preference = requirePreference("appTheme")
|
||||
themePreference.icon = IconicsDrawable(themePreference.context, GoogleMaterial.Icon.gmd_palette).sizePx(iconSize).color(ThemeUtils.getColor(themePreference.context, R.attr.preference_icon_tint))
|
||||
themePreference.icon = IconicsDrawable(themePreference.context, GoogleMaterial.Icon.gmd_palette).sizePx(iconSize).color(ThemeUtils.getColor(themePreference.context, R.attr.iconColor))
|
||||
|
||||
val emojiPreference: Preference = requirePreference("emojiCompat")
|
||||
emojiPreference.icon = IconicsDrawable(emojiPreference.context, GoogleMaterial.Icon.gmd_sentiment_satisfied).sizePx(iconSize).color(ThemeUtils.getColor(emojiPreference.context, R.attr.preference_icon_tint))
|
||||
emojiPreference.icon = IconicsDrawable(emojiPreference.context, GoogleMaterial.Icon.gmd_sentiment_satisfied).sizePx(iconSize).color(ThemeUtils.getColor(emojiPreference.context, R.attr.iconColor))
|
||||
|
||||
val textSizePreference: Preference = requirePreference("statusTextSize")
|
||||
textSizePreference.icon = IconicsDrawable(textSizePreference.context, GoogleMaterial.Icon.gmd_format_size).sizePx(iconSize).color(ThemeUtils.getColor(textSizePreference.context, R.attr.preference_icon_tint))
|
||||
textSizePreference.icon = IconicsDrawable(textSizePreference.context, GoogleMaterial.Icon.gmd_format_size).sizePx(iconSize).color(ThemeUtils.getColor(textSizePreference.context, R.attr.iconColor))
|
||||
|
||||
val timelineFilterPreferences: Preference = requirePreference("timelineFilterPreferences")
|
||||
timelineFilterPreferences.setOnPreferenceClickListener {
|
||||
|
@ -67,12 +67,11 @@ class PreferencesFragment : PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
val languagePreference: Preference = requirePreference("language")
|
||||
languagePreference.icon = IconicsDrawable(languagePreference.context, GoogleMaterial.Icon.gmd_translate).sizePx(iconSize).color(ThemeUtils.getColor(languagePreference.context, R.attr.preference_icon_tint))
|
||||
languagePreference.icon = IconicsDrawable(languagePreference.context, GoogleMaterial.Icon.gmd_translate).sizePx(iconSize).color(ThemeUtils.getColor(languagePreference.context, R.attr.iconColor))
|
||||
|
||||
val botIndicatorPreference = requirePreference("showBotOverlay")
|
||||
val botDrawable = botIndicatorPreference.context.getDrawable(R.drawable.ic_bot_24dp)
|
||||
ThemeUtils.setDrawableTint(context, botDrawable, R.attr.preference_icon_tint)
|
||||
botIndicatorPreference.icon = botDrawable
|
||||
|
||||
botIndicatorPreference.icon = ThemeUtils.getTintedDrawable(requireContext(), R.drawable.ic_bot_24dp, R.attr.iconColor)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
@ -228,7 +228,7 @@ public class LinkHelper {
|
|||
* @param context context
|
||||
*/
|
||||
public static void openLinkInCustomTab(Uri uri, Context context) {
|
||||
int toolbarColor = ThemeUtils.getColor(context, R.attr.custom_tab_toolbar);
|
||||
int toolbarColor = ThemeUtils.getColor(context, R.attr.colorSurface);
|
||||
|
||||
CustomTabsIntent.Builder customTabsIntentBuilder = new CustomTabsIntent.Builder()
|
||||
.setToolbarColor(toolbarColor)
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.widget.ImageView
|
|||
import android.widget.TextView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.bumptech.glide.Glide
|
||||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.entity.Attachment
|
||||
|
@ -87,8 +88,7 @@ class StatusViewHelper(private val itemView: View) {
|
|||
}
|
||||
|
||||
|
||||
val mediaPreviewUnloaded = ThemeUtils.getDrawable(context,
|
||||
R.attr.media_preview_unloaded_drawable, android.R.color.black)
|
||||
val mediaPreviewUnloaded = ColorDrawable(ThemeUtils.getColor(context, R.attr.colorBackgroundAccent))
|
||||
|
||||
val n = min(attachments.size, Status.MAX_MEDIA_ATTACHMENTS)
|
||||
|
||||
|
@ -141,8 +141,7 @@ class StatusViewHelper(private val itemView: View) {
|
|||
val blurhashBitmap = decodeBlurHash(context, attachment.blurhash)
|
||||
mediaPreviews[i].setImageDrawable(blurhashBitmap)
|
||||
} else {
|
||||
mediaPreviews[i].setImageDrawable(ColorDrawable(ThemeUtils.getColor(
|
||||
context, R.attr.sensitive_media_warning_background_color)))
|
||||
mediaPreviews[i].setImageDrawable(mediaPreviewUnloaded)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import androidx.annotation.AttrRes;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
@ -42,29 +41,6 @@ public class ThemeUtils {
|
|||
private static final String THEME_AUTO = "auto";
|
||||
private static final String THEME_SYSTEM = "auto_system";
|
||||
|
||||
public static Drawable getDrawable(@NonNull Context context, @AttrRes int attribute,
|
||||
@DrawableRes int fallbackDrawable) {
|
||||
TypedValue value = new TypedValue();
|
||||
@DrawableRes int resourceId;
|
||||
if (context.getTheme().resolveAttribute(attribute, value, true)) {
|
||||
resourceId = value.resourceId;
|
||||
} else {
|
||||
resourceId = fallbackDrawable;
|
||||
}
|
||||
return context.getDrawable(resourceId);
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public static int getDrawableId(@NonNull Context context, @AttrRes int attribute,
|
||||
@DrawableRes int fallbackDrawableId) {
|
||||
TypedValue value = new TypedValue();
|
||||
if (context.getTheme().resolveAttribute(attribute, value, true)) {
|
||||
return value.resourceId;
|
||||
} else {
|
||||
return fallbackDrawableId;
|
||||
}
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
public static int getColor(@NonNull Context context, @AttrRes int attribute) {
|
||||
TypedValue value = new TypedValue();
|
||||
|
@ -75,13 +51,6 @@ public class ThemeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
public static int getColorId(@NonNull Context context, @AttrRes int attribute) {
|
||||
TypedValue value = new TypedValue();
|
||||
context.getTheme().resolveAttribute(attribute, value, true);
|
||||
return value.resourceId;
|
||||
}
|
||||
|
||||
/** 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) {
|
||||
|
|
|
@ -20,15 +20,14 @@ import android.graphics.Canvas
|
|||
import android.graphics.drawable.Drawable
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
|
||||
import com.keylesspalace.tusky.R
|
||||
import com.keylesspalace.tusky.adapter.ThreadAdapter
|
||||
import com.keylesspalace.tusky.util.ThemeUtils
|
||||
|
||||
class ConversationLineItemDecoration(private val context: Context) : RecyclerView.ItemDecoration() {
|
||||
|
||||
private val divider: Drawable = ThemeUtils.getDrawable(context, R.attr.conversation_thread_line_drawable,
|
||||
R.drawable.conversation_thread_line_dark)
|
||||
private val divider: Drawable = ContextCompat.getDrawable(context, R.drawable.conversation_thread_line)!!
|
||||
|
||||
override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||
val dividerStart = parent.paddingStart + context.resources.getDimensionPixelSize(R.dimen.status_line_margin_start)
|
||||
|
|
|
@ -34,7 +34,7 @@ class LicenseCard
|
|||
init {
|
||||
inflate(context, R.layout.card_license, this)
|
||||
|
||||
setCardBackgroundColor(ThemeUtils.getColor(context, android.R.attr.colorBackground))
|
||||
setCardBackgroundColor(ThemeUtils.getColor(context, R.attr.colorSurface))
|
||||
|
||||
val a = context.theme.obtainStyledAttributes(attrs, R.styleable.LicenseCard, 0, 0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue