Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved color scheme & theming #4507

Merged
merged 6 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class ListsActivity : BaseActivity() {
)

binding.swipeRefreshLayout.setOnRefreshListener { viewModel.retryLoading() }
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

lifecycleScope.launch {
viewModel.state.collect(this@ListsActivity::update)
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/keylesspalace/tusky/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.target.FixedSizeDrawable
import com.bumptech.glide.request.transition.Transition
import com.google.android.material.R as materialR
import com.google.android.material.color.MaterialColors
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
Expand Down Expand Up @@ -698,8 +699,8 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
startActivityWithSlideInAnimation(AnnouncementsActivity.newIntent(context))
}
badgeStyle = BadgeStyle().apply {
textColor = ColorHolder.fromColor(MaterialColors.getColor(binding.mainDrawer, com.google.android.material.R.attr.colorOnPrimary))
color = ColorHolder.fromColor(MaterialColors.getColor(binding.mainDrawer, com.google.android.material.R.attr.colorPrimary))
textColor = ColorHolder.fromColor(MaterialColors.getColor(binding.mainDrawer, materialR.attr.colorOnPrimary))
color = ColorHolder.fromColor(MaterialColors.getColor(binding.mainDrawer, materialR.attr.colorPrimary))
}
},
DividerDrawerItem(),
Expand Down Expand Up @@ -856,7 +857,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
if (tabs[position].id == DIRECT) {
val badge = tab.orCreateBadge
badge.isVisible = accountManager.activeAccount?.hasDirectMessageBadge ?: false
badge.backgroundColor = MaterialColors.getColor(binding.mainDrawer, com.google.android.material.R.attr.colorPrimary)
badge.backgroundColor = MaterialColors.getColor(binding.mainDrawer, materialR.attr.colorPrimary)
directMessageTab = tab
}
}.also { it.attach() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.viewpager2.widget.MarginPageTransformer
import com.bumptech.glide.Glide
import com.google.android.material.R as materialR
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.chip.Chip
import com.google.android.material.color.MaterialColors
Expand Down Expand Up @@ -189,9 +190,9 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
* Load colors and dimensions from resources
*/
private fun loadResources() {
toolbarColor = MaterialColors.getColor(this, com.google.android.material.R.attr.colorSurface, Color.BLACK)
toolbarColor = MaterialColors.getColor(this, materialR.attr.colorSurface, Color.BLACK)
statusBarColorTransparent = getColor(R.color.transparent_statusbar_background)
statusBarColorOpaque = MaterialColors.getColor(this, androidx.appcompat.R.attr.colorPrimaryDark, Color.BLACK)
statusBarColorOpaque = MaterialColors.getColor(this, materialR.attr.colorPrimaryDark, Color.BLACK)
avatarSize = resources.getDimension(R.dimen.account_activity_avatar_size)
titleVisibleHeight = resources.getDimensionPixelSize(R.dimen.account_activity_scroll_title_visible_height)
}
Expand Down Expand Up @@ -458,7 +459,6 @@ class AccountActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvide
binding.swipeToRefreshLayout.isRefreshing = isRefreshing == true
}
}
binding.swipeToRefreshLayout.setColorSchemeResources(R.color.tusky_blue)
}

private fun onAccountChanged(account: Account?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class AccountMediaFragment :

binding.swipeRefreshLayout.isEnabled = false
binding.swipeRefreshLayout.setOnRefreshListener { refreshContent() }
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

binding.statusView.visibility = View.GONE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.core.view.setPadding
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil
import com.bumptech.glide.Glide
import com.google.android.material.R as materialR
import com.google.android.material.color.MaterialColors
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.databinding.ItemAccountMediaBinding
Expand Down Expand Up @@ -47,7 +48,7 @@ class AccountMediaGridAdapter(

private val baseItemBackgroundColor = MaterialColors.getColor(
context,
com.google.android.material.R.attr.colorSurface,
materialR.attr.colorSurface,
Color.BLACK
)
private val videoIndicator = AppCompatResources.getDrawable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class AccountListFragment :
binding.recyclerView.addOnScrollListener(scrollListener)

binding.swipeRefreshLayout.setOnRefreshListener { fetchAccounts(adapter) }
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

fetchAccounts(adapter)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class AnnouncementsActivity :
}

binding.swipeRefreshLayout.setOnRefreshListener(this::refreshAnnouncements)
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

binding.announcementsList.setHasFixedSize(true)
binding.announcementsList.layoutManager = LinearLayoutManager(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.StringRes
import androidx.annotation.VisibleForTesting
Expand All @@ -61,6 +62,7 @@ import androidx.transition.TransitionManager
import com.canhub.cropper.CropImage
import com.canhub.cropper.CropImageContract
import com.canhub.cropper.options
import com.google.android.material.R as materialR
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
import com.google.android.material.color.MaterialColors
Expand Down Expand Up @@ -821,24 +823,26 @@ class ComposeActivity :
binding.descriptionMissingWarningButton.hide()
} else {
binding.composeHideMediaButton.show()
@ColorInt val color = if (contentWarningShown) {
@AttrRes val color = if (contentWarningShown) {
binding.composeHideMediaButton.setImageResource(R.drawable.ic_hide_media_24dp)
binding.composeHideMediaButton.isClickable = false
getColor(R.color.transparent_tusky_blue)
materialR.attr.colorPrimary
} else {
binding.composeHideMediaButton.isClickable = true
if (markMediaSensitive) {
binding.composeHideMediaButton.setImageResource(R.drawable.ic_hide_media_24dp)
getColor(R.color.tusky_blue)
materialR.attr.colorPrimary
} else {
binding.composeHideMediaButton.setImageResource(R.drawable.ic_eye_24dp)
MaterialColors.getColor(
binding.composeHideMediaButton,
android.R.attr.textColorTertiary
)
android.R.attr.textColorTertiary
}
}
binding.composeHideMediaButton.drawable.setTint(color)
binding.composeHideMediaButton.drawable.setTint(
MaterialColors.getColor(
binding.composeHideMediaButton,
color
)
)

var oneMediaWithoutDescription = false
for (media in viewModel.media.value) {
Expand All @@ -856,14 +860,15 @@ class ComposeActivity :
// Can't reschedule a published status
enableButton(binding.composeScheduleButton, clickable = false, colorActive = false)
} else {
@ColorInt val color = if (binding.composeScheduleView.time == null) {
@ColorInt val color =
MaterialColors.getColor(
binding.composeScheduleButton,
android.R.attr.textColorTertiary
if (binding.composeScheduleView.time == null) {
android.R.attr.textColorTertiary
} else {
materialR.attr.colorPrimary
}
)
} else {
getColor(R.color.tusky_blue)
}
binding.composeScheduleButton.drawable.setTint(color)
}
}
Expand Down Expand Up @@ -1242,22 +1247,24 @@ class ComposeActivity :
TransitionManager.beginDelayedTransition(
binding.composeContentWarningBar.parent as ViewGroup
)
@ColorInt val color = if (show) {
@AttrRes val color = if (show) {
binding.composeContentWarningBar.show()
binding.composeContentWarningField.setSelection(
binding.composeContentWarningField.text.length
)
binding.composeContentWarningField.requestFocus()
getColor(R.color.tusky_blue)
materialR.attr.colorPrimary
} else {
binding.composeContentWarningBar.hide()
binding.composeEditField.requestFocus()
android.R.attr.textColorTertiary
}
binding.composeContentWarningButton.drawable.setTint(
MaterialColors.getColor(
binding.composeContentWarningButton,
android.R.attr.textColorTertiary
binding.composeHideMediaButton,
color
)
}
binding.composeContentWarningButton.drawable.setTint(color)
)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import android.graphics.RectF
import android.util.AttributeSet
import androidx.appcompat.content.res.AppCompatResources
import at.connyduck.sparkbutton.helpers.Utils
import com.google.android.material.R as materialR
import com.google.android.material.color.MaterialColors
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.view.MediaPreviewImageView

Expand All @@ -37,7 +39,7 @@ class ProgressImageView
private val progressRect = RectF()
private val biggerRect = RectF()
private val circlePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = context.getColor(R.color.tusky_blue)
color = MaterialColors.getColor(this@ProgressImageView, materialR.attr.colorPrimary)
strokeWidth = Utils.dpToPx(context, 4).toFloat()
style = Paint.Style.STROKE
}
Expand All @@ -46,13 +48,15 @@ class ProgressImageView
}
private val markBgPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
style = Paint.Style.FILL
color = context.getColor(R.color.tusky_grey_10)
color = MaterialColors.getColor(this@ProgressImageView, android.R.attr.colorBackground)
}
private val captionDrawable = AppCompatResources.getDrawable(
context,
R.drawable.spellcheck
)!!.apply {
setTint(Color.WHITE)
setTint(
MaterialColors.getColor(this@ProgressImageView, android.R.attr.textColorTertiary)
)
}
private val circleRadius = Utils.dpToPx(context, 14)
private val circleMargin = Utils.dpToPx(context, 14)
Expand All @@ -68,8 +72,10 @@ class ProgressImageView
}

fun setChecked(checked: Boolean) {
markBgPaint.color =
context.getColor(if (checked) R.color.tusky_blue else R.color.tusky_grey_10)
val backgroundColor = if (checked) materialR.attr.colorPrimary else android.R.attr.colorBackground
val foregroundColor = if (checked) materialR.attr.colorOnPrimary else android.R.attr.textColorTertiary
markBgPaint.color = MaterialColors.getColor(this, backgroundColor)
captionDrawable.setTint(MaterialColors.getColor(this, foregroundColor))
invalidate()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ConversationsFragment :

setupRecyclerView(adapter)

initSwipeToRefresh()
binding.swipeRefreshLayout.setOnRefreshListener { refreshContent() }

adapter.addLoadStateListener { loadState ->
if (loadState.refresh != LoadState.Loading && loadState.source.refresh != LoadState.Loading) {
Expand Down Expand Up @@ -245,11 +245,6 @@ class ConversationsFragment :
adapter?.refresh()
}

private fun initSwipeToRefresh() {
binding.swipeRefreshLayout.setOnRefreshListener { refreshContent() }
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)
}

override fun onReblog(reblog: Boolean, position: Int) {
// its impossible to reblog private messages
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class FiltersActivity : BaseActivity(), FiltersListener {
}

binding.swipeRefreshLayout.setOnRefreshListener { reloadFilters() }
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

setTitle(R.string.pref_title_timeline_filters)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class NotificationsFragment :

// Setup the SwipeRefreshLayout.
binding.swipeRefreshLayout.setOnRefreshListener(this)
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

// Setup the RecyclerView.
binding.recyclerView.setHasFixedSize(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class ReportStatusesFragment :
startActivity(intent)
}
}

Attachment.Type.UNKNOWN -> {
}
}
Expand All @@ -111,7 +112,7 @@ class ReportStatusesFragment :
requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED)
handleClicks()
initStatusesView()
setupSwipeRefreshLayout()
binding.swipeRefreshLayout.setOnRefreshListener(this)
}

override fun onDestroyView() {
Expand All @@ -138,6 +139,7 @@ class ReportStatusesFragment :
onRefresh()
true
}

else -> false
}
}
Expand All @@ -148,12 +150,6 @@ class ReportStatusesFragment :
adapter?.refresh()
}

private fun setupSwipeRefreshLayout() {
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

binding.swipeRefreshLayout.setOnRefreshListener(this)
}

private fun initStatusesView() {
val statusDisplayOptions = StatusDisplayOptions(
animateAvatars = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class ScheduledStatusActivity :
}

binding.swipeRefreshLayout.setOnRefreshListener(this::refreshStatuses)
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)

binding.scheduledTootList.setHasFixedSize(true)
binding.scheduledTootList.layoutManager = LinearLayoutManager(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ abstract class SearchFragment<T : Any> :

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val adapter = initAdapter()
setupSwipeRefreshLayout()
binding.swipeRefreshLayout.setOnRefreshListener(this)
requireActivity().addMenuProvider(this, viewLifecycleOwner, Lifecycle.State.RESUMED)
subscribeObservables(adapter)
}
Expand All @@ -74,11 +74,6 @@ abstract class SearchFragment<T : Any> :
super.onDestroyView()
}

private fun setupSwipeRefreshLayout() {
binding.swipeRefreshLayout.setOnRefreshListener(this)
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)
}

private fun subscribeObservables(adapter: PagingDataAdapter<T, *>) {
viewLifecycleOwner.lifecycleScope.launch {
data.collectLatest { pagingData ->
Expand Down Expand Up @@ -131,6 +126,7 @@ abstract class SearchFragment<T : Any> :
onRefresh()
true
}

else -> false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ class TimelineFragment :
private fun setupSwipeRefreshLayout() {
binding.swipeRefreshLayout.isEnabled = isSwipeToRefreshEnabled
binding.swipeRefreshLayout.setOnRefreshListener(this)
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)
}

private fun setupRecyclerView(adapter: TimelinePagingAdapter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TrendingTagsFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val adapter = TrendingTagsAdapter(::onViewTag)
this.adapter = adapter
setupSwipeRefreshLayout()
binding.swipeRefreshLayout.setOnRefreshListener(this)
setupRecyclerView(adapter)

adapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
Expand Down Expand Up @@ -106,11 +106,6 @@ class TrendingTagsFragment :
super.onDestroyView()
}

private fun setupSwipeRefreshLayout() {
binding.swipeRefreshLayout.setOnRefreshListener(this)
binding.swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue)
}

private fun setupLayoutManager(adapter: TrendingTagsAdapter, columnCount: Int) {
binding.recyclerView.layoutManager = GridLayoutManager(context, columnCount).apply {
spanSizeLookup = object : SpanSizeLookup() {
Expand Down
Loading
Loading