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
23 changes: 21 additions & 2 deletions app/src/androidTest/kotlin/info/appdev/chartexample/StartTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class StartTest {

@After
fun cleanUp() {
Intents.release()
// release() may have already been called by the last loop iteration
try {
Intents.release()
} catch (_: IllegalStateException) { /* not initialised, nothing to do */ }
// Clean up test timber tree
Timber.uprootAll()
}
Expand Down Expand Up @@ -249,12 +252,17 @@ class StartTest {
if (!compose)
doClickTest(index, contentClass, contentItem)

//Thread.sleep(100)
Espresso.pressBack()

// Wait for MainActivity to be visible again
composeTestRule.waitForIdle()
Thread.sleep(200) // Small delay for back navigation

// Reset intent recording for next iteration; otherwise intents accumulate
// across the loop and Intents.intended() can no longer find a fresh
// unverified match for the current activity.
Intents.release()
Intents.init()
} catch (e: Exception) {
Timber.e("#$index/'${contentClass.simpleName}'->'$optionMenu' ${e.message}", e)
onView(ViewMatchers.isRoot())
Expand All @@ -264,6 +272,16 @@ class StartTest {
.replace(" ", "")
)
})
// Navigate back so subsequent iterations start from MainActivity
try {
Espresso.pressBack()
composeTestRule.waitForIdle()
} catch (_: Exception) { /* already on MainActivity */ }
// Reset intents so the next iteration starts clean
try {
Intents.release()
Intents.init()
} catch (_: Exception) { /* ignore if already released */ }
}
}
}
Expand All @@ -278,6 +296,7 @@ class StartTest {
contentItem.clazz == HorizontalBarFullComposeActivity::class.java ||
contentItem.clazz == MultiLineComposeActivity::class.java ||
contentItem.clazz == GradientActivity::class.java ||
// contentItem.clazz == TimeIntervalChartActivity::class.java ||
contentItem.clazz == TimeLineActivity::class.java
) {
// These charts have less clickable area, so skip further clicks
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<activity android:name="info.appdev.chartexample.HalfPieChartActivity" />
<activity android:name="info.appdev.chartexample.SpecificPositionsLineChartActivity" />
<activity android:name="info.appdev.chartexample.TimeLineActivity" />
<activity android:name="info.appdev.chartexample.TimeIntervalChartActivity" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package info.appdev.chartexample

import android.graphics.Color
import android.os.Bundle
import info.appdev.chartexample.databinding.ActivityTimeIntervalChartBinding
import info.appdev.chartexample.notimportant.DemoBase
import info.appdev.charting.data.EntryFloat
import info.appdev.charting.data.GanttChartData
import info.appdev.charting.data.GanttTask
import info.appdev.charting.highlight.Highlight
import info.appdev.charting.listener.OnChartValueSelectedListener

/**
* Demo activity showing Gantt-style timeline visualization.
* Each horizontal bar represents a task with start time and duration.
*/
class TimeIntervalChartActivity : DemoBase(), OnChartValueSelectedListener {

private lateinit var binding: ActivityTimeIntervalChartBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityTimeIntervalChartBinding.inflate(layoutInflater)
setContentView(binding.root)

// Create Gantt chart data
val ganttData = GanttChartData()

// Add sample project tasks
ganttData.addTask(GanttTask("Design", 0f, 50f, Color.rgb(255, 107, 107))) // Red: 0-50
ganttData.addTask(GanttTask("Dev", 40f, 100f, Color.rgb(66, 165, 245))) // Blue: 40-140
ganttData.addTask(GanttTask("Testing", 120f, 40f, Color.rgb(76, 175, 80), hatched = true)) // Green: 120-160
ganttData.addTask(GanttTask("Launch", 150f, 20f, Color.rgb(255, 193, 7))) // Yellow: 150-170
ganttData.minTime = 10f
ganttData.maxTime = 200f
// Set data and render
binding.chart1.setData(ganttData)
}

override fun saveToGallery() = Unit

override fun onValueSelected(entryFloat: EntryFloat, highlight: Highlight) = Unit

override fun onNothingSelected() = Unit

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import info.appdev.chartexample.ScrollViewActivity
import info.appdev.chartexample.SpecificPositionsLineChartActivity
import info.appdev.chartexample.StackedBarActivity
import info.appdev.chartexample.StackedBarActivityNegative
import info.appdev.chartexample.TimeIntervalChartActivity
import info.appdev.chartexample.TimeLineActivity
import info.appdev.chartexample.compose.HorizontalBarComposeActivity
import info.appdev.chartexample.compose.HorizontalBarFullComposeActivity
Expand Down Expand Up @@ -219,6 +220,7 @@ class MainActivity : ComponentActivity() {
add(ContentItem("Demonstrate and fix issues"))
add(ContentItem("Gradient", "Show a gradient edge case", GradientActivity::class.java))
add(ContentItem("Timeline", "Show a time line with Unix timestamp", TimeLineActivity::class.java))
add(ContentItem("Timeinterval", "Grantt chart", TimeIntervalChartActivity::class.java))
}
}
}
Expand Down
60 changes: 60 additions & 0 deletions app/src/main/res/layout/activity_time_interval_chart.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<info.appdev.charting.charts.GanttChart
android:id="@+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/seekBarX"/>

<SeekBar
android:id="@+id/seekBarY"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_margin="8dp"
android:layout_toLeftOf="@+id/tvYMax"
android:layout_marginRight="5dp"
android:max="100"
android:paddingBottom="12dp" />

<SeekBar
android:id="@+id/seekBarX"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/seekBarY"
android:layout_margin="8dp"
android:layout_marginBottom="35dp"
android:layout_toLeftOf="@+id/tvXMax"
android:layout_marginRight="5dp"
android:max="100"
android:paddingBottom="12dp" />

<TextView
android:id="@+id/tvXMax"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/seekBarX"
android:layout_alignParentRight="true"
android:text="@string/dash"
android:layout_marginBottom="15dp"
android:layout_marginRight="10dp"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/tvYMax"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/seekBarY"
android:layout_alignParentRight="true"
android:text="@string/dash"
android:layout_marginBottom="15dp"
android:layout_marginRight="10dp"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>
Loading
Loading