This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Track( | |
trackInfo: TrackInfo, | |
isPlaying: Boolean, | |
playAction: () -> Unit, | |
pauseAction: () -> Unit, | |
moreAction: () -> Unit, | |
modifier: Modifier = Modifier | |
) { | |
Row( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example | |
import android.content.Context | |
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.graphics.Paint | |
import android.graphics.Rect | |
import android.os.Bundle | |
import android.util.AttributeSet | |
import android.view.MotionEvent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun dispatchHoverEvent(event: MotionEvent): Boolean { | |
return if (accessHelper.dispatchHoverEvent(event)) { | |
true | |
} else { | |
super.dispatchHoverEvent(event) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val intervalBounds = Rect() | |
@Suppress("DEPRECATION") // setBoundsInParent is required by [ExploreByTouchHelper] | |
override fun onPopulateNodeForVirtualView(virtualViewId: Int, node: AccessibilityNodeInfoCompat) { | |
node.className = RatingsHistogramView::class.simpleName | |
node.contentDescription = "content desc $virtualViewId" | |
updateBoundsForInterval(virtualViewId) | |
node.setBoundsInParent(intervalBounds) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun getVirtualViewAt(x: Float, y: Float): Int { | |
ratingsHistogram?.let { | |
val intervalWidth = width.toFloat() / it.intervals.size | |
return min((x / intervalWidth).toInt(), it.intervals.size - 1) | |
} | |
return HOST_ID | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun getVisibleVirtualViews(virtualViewIds: MutableList<Int>) { | |
val numberOfIntervals = ratingsHistogram?.intervals?.size ?: 0 | |
for (i in 0 until numberOfIntervals) { | |
virtualViewIds.add(i) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RatingsView(context: Context, attrs: AttributeSet) | |
: View(context, attrs) { | |
private val accessHelper = AccessHelper() | |
init { | |
ViewCompat.setAccessibilityDelegate(this, accessHelper) | |
} | |
// override fun onDraw(canvas: Canvas) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override val issues: List<Issue> = listOf( | |
MaterialThemeOverlayInLayoutDetector.ISSUE, | |
MonzoToolbarAttributeDetectors.ISSUE_LAYOUT_HEIGHT, | |
MonzoToolbarAttributeDetectors.ISSUE_MIN_HEIGHT, | |
MonzoToolbarAttributeDetectors.ISSUE_STYLE, | |
MonzoToolbarNotUsedDetector.ISSUE, | |
StatusBarAttrsDetector.ISSUE, | |
StyleAttrUsesTextAppearanceDetector.ISSUE, | |
StyleAttrUsesThemeDetector.ISSUE, | |
SwitchMaterialNotUsedDetector.ISSUE, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prohibits use of hardcoded colors in XML layouts and color resources. | |
* | |
* A hardcoded color includes: | |
* | |
* - a reference to a color resource which doesn't include "mds" in the name. | |
* "mds" is used as an allowlist filter, where we'll assume that the resource contains theme-friendly colors | |
* or it's an exception to the rule. | |
* - a color hexcode | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal fun Attr.belongsToItem() = ownerElement.nodeName == "item" | |
internal fun Element.belongsToStyle() = parentNode.nodeName == "style" | |
internal fun Element.belongsToThemeOrThemeOverlay() = belongsToStyle() | |
&& parentNode.attributes.getNamedItem("name").nodeValue.startsWith("Theme") | |
/** | |
* Looks for VALUE in a <style> resource | |
* e.g. <item name="attrName">VALUE</item> |
NewerOlder