Skip to content
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
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.{kt,kts}]
ktlint_standard_function-naming = disabled
6 changes: 6 additions & 0 deletions .github/workflows/ktlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ jobs:
report-path: build/*.xml # Support glob patterns by https://www.npmjs.com/package/@actions/glob
ignore-warnings: true # Ignore Lint Warnings
continue-on-error: false # If annotations contain error of severity, action-ktlint exit 1.
- name: Upload ktlint report
uses: actions/upload-artifact@v4
if: always()
with:
name: ktlint-report
path: build/ktlint-report.xml
11 changes: 11 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RenaultCar(
effects: List<MotionEffect> = emptyList(),
) : BaseContourMotionView(context, startFrame, endFrame, effects = effects) {
companion object {
const val imageAssetSubFolder = "renault_kiger_bg"
const val IMAGE_ASSET_SUB_FOLDER = "renault_kiger_bg"
}

private val imageView: ImageView =
Expand Down Expand Up @@ -78,7 +78,7 @@ class RenaultCar(
)

// Determine which image to show based on the current frame
val imageName = "$imageAssetSubFolder/$frame.png"
val imageName = "$IMAGE_ASSET_SUB_FOLDER/$frame.png"

try {
val inputStream: InputStream = assetManager.open(imageName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ data class MotionLayoutInfo(
val height: Int = WRAP_CONTENT,
val padding: Padding = Padding(),
val margin: Margin = Margin(),
val gravity: Int = Gravity.NO_GRAVITY
val gravity: Int = Gravity.NO_GRAVITY,
) {
data class Padding(
val left: Int = 0,
val top: Int = 0,
val right: Int = 0,
val bottom: Int = 0
val bottom: Int = 0,
)

data class Margin(
val left: Int = 0,
val top: Int = 0,
val right: Int = 0,
val bottom: Int = 0
val bottom: Int = 0,
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tejpratapsingh.motionlib.core

@Suppress("ClassName")
sealed class VideoAspectRatio(
val width: Int,
val height: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.junit.Before
import org.junit.Test

class MotionTextSizeProviderTest {

@Before
fun setup() {
// Reset baseTextScale before each test
Expand All @@ -15,33 +14,33 @@ class MotionTextSizeProviderTest {
@Test
fun testDefaultFontSizes() {
val aspectRatio = VideoAspectRatio.Ratio16x9_1080 // 1920x1080, min is 1080, scale is 1.0

// H1 should be 160f * 1.0 = 160f
assertEquals(160f, MotionTextSizeProvider.getFontSize(aspectRatio, MotionTextVariant.H1), 0.01f)

// P should be 48f * 1.0 = 48f
assertEquals(48f, MotionTextSizeProvider.getFontSize(aspectRatio, MotionTextVariant.P), 0.01f)
}

@Test
fun testBaseTextScale() {
val aspectRatio = VideoAspectRatio.Ratio16x9_1080 // 1920x1080, min is 1080, scale is 1.0

MotionTextSizeProvider.baseTextScale = 2.0f

// H1 should be 160f * 2.0 = 320f
assertEquals(320f, MotionTextSizeProvider.getFontSize(aspectRatio, MotionTextVariant.H1), 0.01f)

// P should be 48f * 2.0 = 96f
assertEquals(96f, MotionTextSizeProvider.getFontSize(aspectRatio, MotionTextVariant.P), 0.01f)
}

@Test
fun testScalingWithAspectRatio() {
// 480p 16:9 is 854x480, min is 480.
// 480p 16:9 is 854x480, min is 480.
// Scale = 480 / 1080 = 0.4444...
val aspectRatio = VideoAspectRatio.Ratio16x9_480

val expectedH1 = 160f * (480f / 1080f)
assertEquals(expectedH1, MotionTextSizeProvider.getFontSize(aspectRatio, MotionTextVariant.H1), 0.01f)
}
Expand Down
4 changes: 2 additions & 2 deletions modules/ivi-demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ plugins {
}

android {
namespace 'com.tejpratapsingh.ivi_demo'
namespace 'com.tejpratapsingh.ividemo'
compileSdk 36

defaultConfig {
applicationId "com.tejpratapsingh.ivi_demo"
applicationId "com.tejpratapsingh.ividemo"
minSdk 28
targetSdk 36
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tejpratapsingh.ivi_demo
package com.tejpratapsingh.ividemo

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.tejpratapsingh.ivi_demo
package com.tejpratapsingh.ividemo

import RenaultCar
import android.os.Build
import android.os.Bundle
import com.tejpratapsingh.ivi_demo.extension.enableSwipeSeekReverse
import com.tejpratapsingh.ividemo.extension.enableSwipeSeekReverse
import com.tejpratapsingh.ividemo.motion.RenaultCar
import com.tejpratapsingh.motionlib.activities.PreviewActivity
import com.tejpratapsingh.motionlib.core.MotionConfig
import com.tejpratapsingh.motionlib.core.VideoAspectRatio
Expand Down Expand Up @@ -39,9 +38,7 @@ class MainActivity : PreviewActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
motionVideoPlayer.seekBar.min = 1
}
motionVideoPlayer.seekBar.min = 1

motionView.enableSwipeSeekReverse(
maxProgress = video.totalFrames,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tejpratapsingh.ivi_demo.extension
package com.tejpratapsingh.ividemo.extension
Comment thread
coderabbitai[bot] marked this conversation as resolved.

import android.annotation.SuppressLint
import android.view.MotionEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.tejpratapsingh.ividemo.motion

import android.content.Context
import android.graphics.BitmapFactory
import android.widget.ImageView
Expand All @@ -22,8 +24,8 @@ class RenaultCar(
effects: List<MotionEffect> = emptyList(),
) : BaseContourMotionView(context, startFrame, endFrame, effects = effects) {
companion object {
const val imageAssetSubFolder = "renault_kiger_bg"
const val roadAssetSubFolder = "road"
const val IMAGE_ASSET_SUB_FOLDER = "renault_kiger_bg"
const val ROAD_ASSET_SUB_FOLDER = "road"
}

private val imageViewBg: ImageView =
Expand All @@ -37,8 +39,8 @@ class RenaultCar(
}

private val assetManager = context.assets
private val files = assetManager.list(imageAssetSubFolder)
private val roadFiles = assetManager.list(roadAssetSubFolder)
private val files = assetManager.list(IMAGE_ASSET_SUB_FOLDER)
private val roadFiles = assetManager.list(ROAD_ASSET_SUB_FOLDER)

init {
imageViewBg.layoutBy(
Expand Down Expand Up @@ -120,7 +122,7 @@ class RenaultCar(
// val road = String.format(
// Locale.getDefault(),
// "%s/%02d.png",
// roadAssetSubFolder,
// ROAD_ASSET_SUB_FOLDER,
// min(roadInterpolator, (roadFiles?.size ?: 1) - 1)
// )
//
Expand All @@ -137,7 +139,7 @@ class RenaultCar(
String.format(
Locale.getDefault(),
"%s/%d.png",
imageAssetSubFolder,
IMAGE_ASSET_SUB_FOLDER,
min(frame, (files?.size ?: 1) - 1),
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tejpratapsingh.ivi_demo.motion
package com.tejpratapsingh.ividemo.motion

import android.content.Context
import android.graphics.BitmapFactory
Expand All @@ -18,7 +18,7 @@ class Road(
effects: List<MotionEffect> = emptyList(),
) : BaseContourMotionView(context, startFrame, endFrame, effects = effects) {
companion object {
const val imageAssetSubFolder = "road"
const val IMAGE_ASSET_SUB_FOLDER = "road"
}

private val imageView: ImageView =
Expand Down Expand Up @@ -60,7 +60,7 @@ class Road(
super.forFrame(frame)

// Determine which image to show based on the current frame
val imageName = "$imageAssetSubFolder/$frame.png"
val imageName = "$IMAGE_ASSET_SUB_FOLDER/$frame.png"

try {
val inputStream: InputStream = assetManager.open(imageName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.tejpratapsingh.ivi_demo.sequence
package com.tejpratapsingh.ividemo.sequence

import RenaultCar
import android.content.Context
import com.tejpratapsingh.ividemo.motion.RenaultCar
import com.tejpratapsingh.motionlib.core.MotionConfig
import com.tejpratapsingh.motionlib.core.VideoAspectRatio
import com.tejpratapsingh.motionlib.core.motion.BaseContourMotionView
Expand All @@ -18,7 +18,7 @@ fun sampleMotionVideo(applicationContext: Context): MotionVideoProducer {
setCurrentConfig(motionConfig)

val assetManager = applicationContext.assets
val files = assetManager.list(RenaultCar.imageAssetSubFolder)
val files = assetManager.list(RenaultCar.IMAGE_ASSET_SUB_FOLDER)

val motionView: BaseContourMotionView =
RenaultCar(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tejpratapsingh.ivi_demo.view
package com.tejpratapsingh.ividemo.view

import android.content.Context
import android.graphics.Bitmap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.tejpratapsingh.ivi_demo
package com.tejpratapsingh.ividemo

import org.junit.Assert.assertEquals
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.junit.runner.RunWith
*/
@RunWith(AndroidJUnit4::class)
class ProjectDetailsScreenTest {

@get:Rule
val composeTestRule = createComposeRule()

Expand Down Expand Up @@ -72,6 +71,7 @@ class ProjectDetailsScreenTest {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = {},
onShareClick = {},
)
}
Expand All @@ -91,6 +91,7 @@ class ProjectDetailsScreenTest {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = {},
onShareClick = {},
)
}
Expand All @@ -113,6 +114,7 @@ class ProjectDetailsScreenTest {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = {},
onShareClick = {},
)
}
Expand All @@ -133,6 +135,7 @@ class ProjectDetailsScreenTest {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = {},
onShareClick = {},
)
}
Expand All @@ -149,6 +152,7 @@ class ProjectDetailsScreenTest {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = {},
onShareClick = { sharedProject = it },
)
}
Expand All @@ -170,6 +174,7 @@ class ProjectDetailsScreenTest {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = {},
onShareClick = {},
)
}
Expand All @@ -186,6 +191,7 @@ class ProjectDetailsScreenTest {
ProjectDetailsScreen(
project = project,
onBackClick = { backClicked = true },
onEditClick = {},
onShareClick = {},
)
}
Expand All @@ -194,4 +200,43 @@ class ProjectDetailsScreenTest {

assertEquals(true, backClicked)
}
}

// ------------------------------------------------------------------
// Edit button
// ------------------------------------------------------------------

@Test
fun editButton_isDisplayed() {
val project = buildProject()

composeTestRule.setContent {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = {},
onShareClick = {},
)
}

composeTestRule.onNodeWithText("Edit Project").assertIsDisplayed()
}

@Test
fun editButton_invokesOnEditClickWithProject() {
val project = buildProject(id = "edit-test")
var editedProject: MotionProject? = null

composeTestRule.setContent {
ProjectDetailsScreen(
project = project,
onBackClick = {},
onEditClick = { editedProject = it },
onShareClick = {},
)
}

composeTestRule.onNodeWithText("Edit Project").performClick()

assertEquals(project.id, editedProject?.id)
}
}
Comment on lines +203 to +242

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check how the Edit button is actually rendered (Text vs contentDescription-only Icon)
rg -n -A5 -B15 'onEditClick\(project\)' modules/lyrics-maker/src/main/java/com/tejpratapsingh/lyricsmaker/presentation/compose/details/ProjectDetailsScreen.kt
rg -n '"Edit Project"' modules/lyrics-maker/src/main/java/com/tejpratapsingh/lyricsmaker/presentation/compose/details/ProjectDetailsScreen.kt

Repository: tejpratap46/AndroidVideoMotion

Length of output: 1033


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="modules/lyrics-maker/src/main/java/com/tejpratapsingh/lyricsmaker/presentation/compose/details/ProjectDetailsScreen.kt"

# Show the Edit button block with line numbers
sed -n '196,225p' "$file" | cat -n

# Also show any nearby text labels/semantics for the screen
rg -n '"Edit Project"|"Back"|contentDescription|Text\(' "$file"

Repository: tejpratap46/AndroidVideoMotion

Length of output: 1289


Use the correct semantics matcher for the Edit button

ProjectDetailsScreen renders the action as an icon-only IconButton with contentDescription = "Edit", so onNodeWithText("Edit Project") will never match. Switch both assertions to onNodeWithContentDescription("Edit").

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@modules/lyrics-maker/src/androidTest/java/com/tejpratapsingh/lyricsmaker/presentation/compose/ProjectDetailsScreenTest.kt`
around lines 203 - 242, The Edit action in ProjectDetailsScreen is an icon-only
IconButton with contentDescription "Edit", so the current tests are matching the
wrong semantics. Update both editButton_isDisplayed and
editButton_invokesOnEditClickWithProject in ProjectDetailsScreenTest to locate
the node with onNodeWithContentDescription("Edit") instead of
onNodeWithText("Edit Project"), then keep the display and click assertions
against that node.

Loading
Loading