Always show popups at the center of the screen; remove ScreenLocation

pull/1370/head
Alinson S. Xavier 3 years ago
parent 25aeafb759
commit d2d45991b0
No known key found for this signature in database
GPG Key ID: DCA0DAD4D2F58624

@ -45,7 +45,7 @@ class EntryButtonViewTest : BaseViewTest() {
value = Entry.NO
color = PaletteUtils.getAndroidTestColor(5)
onToggle = { _, _, _ -> toggled = true }
onEdit = { _ -> edited = true }
onEdit = { edited = true }
}
measureView(view, dpToPixels(48), dpToPixels(48))
}

@ -76,7 +76,7 @@ class NumberPanelViewTest : BaseViewTest() {
@Test
fun testEdit() {
val timestamps = mutableListOf<Timestamp>()
view.onEdit = { _, t -> timestamps.plusAssign(t) }
view.onEdit = { t -> timestamps.plusAssign(t) }
view.buttons[0].performLongClick()
view.buttons[2].performLongClick()
view.buttons[3].performLongClick()
@ -87,7 +87,7 @@ class NumberPanelViewTest : BaseViewTest() {
fun testEdit_withOffset() {
val timestamps = mutableListOf<Timestamp>()
view.dataOffset = 3
view.onEdit = { _, t -> timestamps += t }
view.onEdit = { t -> timestamps += t }
view.buttons[0].performLongClick()
view.buttons[2].performLongClick()
view.buttons[3].performLongClick()

@ -27,7 +27,6 @@ import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.widget.PopupWindow
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.R
import org.isoron.uhabits.core.models.Entry.Companion.NO
import org.isoron.uhabits.core.models.Entry.Companion.SKIP
@ -100,7 +99,7 @@ class CheckmarkPopup(
view.notes.setText(notes)
}
fun show(location: ScreenLocation) {
fun show() {
val popup = PopupWindow()
popup.contentView = view.root
popup.width = view.root.dp(POPUP_WIDTH).toInt()
@ -118,12 +117,7 @@ class CheckmarkPopup(
popup.setOnDismissListener {
onToggle(value, view.notes.text.toString())
}
popup.showAtLocation(
anchor,
Gravity.NO_GRAVITY,
view.root.dp(location.x.toFloat()).toInt(),
view.root.dp(location.y.toFloat()).toInt(),
)
popup.showAtLocation(anchor, Gravity.CENTER, 0, 0)
popup.dimBehind()
}
}

@ -28,7 +28,6 @@ import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.widget.PopupWindow
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.core.models.Entry
import org.isoron.uhabits.core.preferences.Preferences
import org.isoron.uhabits.databinding.CheckmarkPopupBinding
@ -72,7 +71,7 @@ class NumberPopup(
)
}
fun show(location: ScreenLocation) {
fun show() {
val popup = PopupWindow()
popup.contentView = view.root
popup.width = view.root.dp(POPUP_WIDTH).toInt()
@ -94,12 +93,7 @@ class NumberPopup(
view.value.setText((Entry.SKIP.toDouble() / 1000).toString())
popup.dismiss()
}
popup.showAtLocation(
anchor,
Gravity.NO_GRAVITY,
view.root.dp(location.x.toFloat()).toInt(),
view.root.dp(location.y.toFloat()).toInt(),
)
popup.showAtLocation(anchor, Gravity.CENTER, 0, 0)
view.value.requestFocusWithKeyboard()
popup.dimBehind()
}

@ -24,14 +24,12 @@ import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import dagger.Lazy
import org.isoron.platform.gui.ScreenLocation
import org.isoron.platform.gui.toInt
import org.isoron.uhabits.R
import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
import org.isoron.uhabits.activities.common.dialogs.ColorPickerDialogFactory
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
import org.isoron.uhabits.activities.common.dialogs.NumberPopup
import org.isoron.uhabits.activities.common.dialogs.POPUP_WIDTH
import org.isoron.uhabits.activities.habits.edit.HabitTypeDialog
import org.isoron.uhabits.activities.habits.list.views.HabitCardListAdapter
import org.isoron.uhabits.core.commands.ArchiveHabitsCommand
@ -232,7 +230,6 @@ class ListHabitsScreen
override fun showNumberPopup(
value: Double,
notes: String,
location: ScreenLocation,
callback: ListHabitsBehavior.NumberPickerCallback
) {
val view = rootView.get()
@ -244,7 +241,7 @@ class ListHabitsScreen
value = value,
).apply {
onToggle = { value, notes -> callback.onNumberPicked(value, notes) }
show(getPopupLocation(location))
show()
}
}
@ -252,7 +249,6 @@ class ListHabitsScreen
selectedValue: Int,
notes: String,
color: PaletteColor,
location: ScreenLocation,
callback: ListHabitsBehavior.CheckMarkDialogCallback
) {
val view = rootView.get()
@ -265,15 +261,10 @@ class ListHabitsScreen
value = selectedValue,
).apply {
onToggle = { value, notes -> callback.onNotesSaved(value, notes) }
show(getPopupLocation(location))
show()
}
}
private fun getPopupLocation(clickLocation: ScreenLocation) = ScreenLocation(
x = clickLocation.x - POPUP_WIDTH / 2,
y = clickLocation.y
)
private fun getExecuteString(command: Command): String? {
when (command) {
is ArchiveHabitsCommand -> {

@ -28,7 +28,6 @@ import android.text.TextPaint
import android.view.HapticFeedbackConstants
import android.view.View
import android.view.View.MeasureSpec.EXACTLY
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.R
import org.isoron.uhabits.core.models.Entry
import org.isoron.uhabits.core.models.Entry.Companion.NO
@ -39,7 +38,6 @@ import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
import org.isoron.uhabits.core.preferences.Preferences
import org.isoron.uhabits.inject.ActivityContext
import org.isoron.uhabits.utils.drawNotesIndicator
import org.isoron.uhabits.utils.getCenter
import org.isoron.uhabits.utils.getFontAwesome
import org.isoron.uhabits.utils.sp
import org.isoron.uhabits.utils.sres
@ -83,7 +81,7 @@ class CheckmarkButtonView(
var onToggle: (Int, String, Long) -> Unit = { _, _, _ -> }
var onEdit: (ScreenLocation) -> Unit = { _ -> }
var onEdit: () -> Unit = { }
private var drawer = Drawer()
@ -105,11 +103,11 @@ class CheckmarkButtonView(
override fun onClick(v: View) {
if (preferences.isShortToggleEnabled) performToggle(TOGGLE_DELAY_MILLIS)
else onEdit(getCenter())
else onEdit()
}
override fun onLongClick(v: View): Boolean {
if (preferences.isShortToggleEnabled) onEdit(getCenter())
if (preferences.isShortToggleEnabled) onEdit()
else performToggle(TOGGLE_DELAY_MILLIS)
return true
}

@ -20,7 +20,6 @@
package org.isoron.uhabits.activities.habits.list.views
import android.content.Context
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
import org.isoron.uhabits.core.models.Timestamp
import org.isoron.uhabits.core.preferences.Preferences
@ -67,7 +66,7 @@ class CheckmarkPanelView(
setupButtons()
}
var onEdit: (ScreenLocation, Timestamp) -> Unit = { _, _ -> }
var onEdit: (Timestamp) -> Unit = { _ -> }
set(value) {
field = value
setupButtons()
@ -91,7 +90,7 @@ class CheckmarkPanelView(
}
button.color = color
button.onToggle = { value, notes, delay -> onToggle(timestamp, value, notes, delay) }
button.onEdit = { location -> onEdit(location, timestamp) }
button.onEdit = { onEdit(timestamp) }
}
}
}

@ -167,17 +167,17 @@ class HabitCardView(
{ runPendingToggles(taskId) }.delay(delay)
}
}
onEdit = { location, timestamp ->
onEdit = { timestamp ->
triggerRipple(timestamp)
habit?.let { behavior.onEdit(location, it, timestamp) }
habit?.let { behavior.onEdit(it, timestamp) }
}
}
numberPanel = numberPanelFactory.create().apply {
visibility = GONE
onEdit = { location, timestamp ->
onEdit = { timestamp ->
triggerRipple(timestamp)
habit?.let { behavior.onEdit(location, it, timestamp) }
habit?.let { behavior.onEdit(it, timestamp) }
}
}

@ -28,7 +28,6 @@ import android.text.TextPaint
import android.view.View
import android.view.View.OnClickListener
import android.view.View.OnLongClickListener
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.R
import org.isoron.uhabits.core.models.Entry
import org.isoron.uhabits.core.models.NumericalHabitType.AT_LEAST
@ -38,7 +37,6 @@ import org.isoron.uhabits.inject.ActivityContext
import org.isoron.uhabits.utils.InterfaceUtils.getDimension
import org.isoron.uhabits.utils.dim
import org.isoron.uhabits.utils.drawNotesIndicator
import org.isoron.uhabits.utils.getCenter
import org.isoron.uhabits.utils.getFontAwesome
import org.isoron.uhabits.utils.sres
import java.text.DecimalFormat
@ -110,7 +108,7 @@ class NumberButtonView(
invalidate()
}
var onEdit: (ScreenLocation) -> Unit = { _ -> }
var onEdit: () -> Unit = { }
private var drawer: Drawer = Drawer(context)
@ -120,11 +118,11 @@ class NumberButtonView(
}
override fun onClick(v: View) {
onEdit(getCenter())
onEdit()
}
override fun onLongClick(v: View): Boolean {
onEdit(getCenter())
onEdit()
return true
}

@ -20,7 +20,6 @@
package org.isoron.uhabits.activities.habits.list.views
import android.content.Context
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.core.models.NumericalHabitType
import org.isoron.uhabits.core.models.Timestamp
import org.isoron.uhabits.core.preferences.Preferences
@ -79,7 +78,7 @@ class NumberPanelView(
setupButtons()
}
var onEdit: (ScreenLocation, Timestamp) -> Unit = { _, _ -> }
var onEdit: (Timestamp) -> Unit = { _ -> }
set(value) {
field = value
setupButtons()
@ -105,7 +104,7 @@ class NumberPanelView(
button.targetType = targetType
button.threshold = threshold
button.units = units
button.onEdit = { location -> onEdit(location, timestamp) }
button.onEdit = { onEdit(timestamp) }
}
}
}

@ -28,7 +28,6 @@ import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.isoron.platform.gui.ScreenLocation
import org.isoron.platform.gui.toInt
import org.isoron.uhabits.AndroidDirFinder
import org.isoron.uhabits.HabitsApplication
@ -39,7 +38,6 @@ import org.isoron.uhabits.activities.common.dialogs.CheckmarkPopup
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
import org.isoron.uhabits.activities.common.dialogs.HistoryEditorDialog
import org.isoron.uhabits.activities.common.dialogs.NumberPopup
import org.isoron.uhabits.activities.common.dialogs.POPUP_WIDTH
import org.isoron.uhabits.core.commands.Command
import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.models.Habit
@ -52,7 +50,6 @@ import org.isoron.uhabits.core.ui.screens.habits.show.ShowHabitPresenter
import org.isoron.uhabits.core.ui.views.OnDateClickedListener
import org.isoron.uhabits.intents.IntentFactory
import org.isoron.uhabits.utils.currentTheme
import org.isoron.uhabits.utils.getTopLeftCorner
import org.isoron.uhabits.utils.showMessage
import org.isoron.uhabits.utils.showSendFileScreen
import org.isoron.uhabits.widgets.WidgetUpdater
@ -173,7 +170,6 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
value: Double,
notes: String,
preferences: Preferences,
location: ScreenLocation,
callback: ListHabitsBehavior.NumberPickerCallback
) {
val anchor = getPopupAnchor() ?: return
@ -185,7 +181,7 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
value = value,
).apply {
onToggle = { v, n -> callback.onNumberPicked(v, n) }
show(computePopupLocation(anchor, location))
show()
}
}
@ -194,7 +190,6 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
notes: String,
preferences: Preferences,
color: PaletteColor,
location: ScreenLocation,
callback: ListHabitsBehavior.CheckMarkDialogCallback
) {
val anchor = getPopupAnchor() ?: return
@ -207,7 +202,7 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
value = selectedValue,
).apply {
onToggle = { v, n -> callback.onNotesSaved(v, n) }
show(computePopupLocation(anchor, location))
show()
}
}
@ -216,14 +211,6 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
return dialog?.dataView
}
private fun computePopupLocation(anchor: View, clickLocation: ScreenLocation): ScreenLocation {
val corner = anchor.getTopLeftCorner()
return ScreenLocation(
x = corner.x + clickLocation.x - POPUP_WIDTH / 2,
y = corner.y + clickLocation.y,
)
}
override fun showEditHabitScreen(habit: Habit) {
startActivity(IntentFactory().startEditActivity(this@ShowHabitActivity, habit))
}

@ -47,7 +47,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.content.FileProvider
import com.google.android.material.snackbar.Snackbar
import org.isoron.platform.gui.ScreenLocation
import org.isoron.platform.gui.toInt
import org.isoron.uhabits.HabitsApplication
import org.isoron.uhabits.R
@ -231,34 +230,6 @@ fun PopupWindow.dimBehind() {
wm.updateViewLayout(container, p)
}
/**
* Returns the absolute screen coordinates for the center of this view (in density-independent
* pixels).
*/
fun View.getCenter(): ScreenLocation {
val density = resources.displayMetrics.density
val loc = IntArray(2)
this.getLocationInWindow(loc)
return ScreenLocation(
x = ((loc[0] + width / 2) / density).toDouble(),
y = ((loc[1] + height / 2) / density).toDouble(),
)
}
/**
* Returns the absolute screen coordinates for the top left corner of this view (in
* density-independent pixels).
*/
fun View.getTopLeftCorner(): ScreenLocation {
val density = resources.displayMetrics.density
val loc = IntArray(2)
this.getLocationInWindow(loc)
return ScreenLocation(
x = (loc[0] / density).toDouble(),
y = (loc[1] / density).toDouble(),
)
}
fun View.requestFocusWithKeyboard() {
// For some reason, Android does not open the soft keyboard by default when view.requestFocus
// is called. Several online solutions suggest using InputMethodManager, but these solutions

@ -25,18 +25,14 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.FrameLayout
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.HabitsApplication
import org.isoron.uhabits.activities.AndroidThemeSwitcher
import org.isoron.uhabits.activities.common.dialogs.NumberPopup
import org.isoron.uhabits.activities.common.dialogs.POPUP_HEIGHT
import org.isoron.uhabits.activities.common.dialogs.POPUP_WIDTH
import org.isoron.uhabits.core.ui.screens.habits.list.ListHabitsBehavior
import org.isoron.uhabits.core.ui.widgets.WidgetBehavior
import org.isoron.uhabits.core.utils.DateUtils
import org.isoron.uhabits.intents.IntentParser
import org.isoron.uhabits.utils.SystemUtils
import org.isoron.uhabits.utils.getCenter
import org.isoron.uhabits.widgets.WidgetUpdater
class NumericalCheckmarkWidgetActivity : Activity(), ListHabitsBehavior.NumberPickerCallback {
@ -95,13 +91,7 @@ class NumericalCheckmarkWidgetActivity : Activity(), ListHabitsBehavior.NumberPi
finish()
overridePendingTransition(0, 0)
}
val center = rootView.getCenter()
show(
ScreenLocation(
x = center.x - POPUP_WIDTH / 2,
y = center.y - POPUP_HEIGHT / 2
)
)
show()
}
}

@ -18,7 +18,6 @@
*/
package org.isoron.uhabits.core.ui.screens.habits.list
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
import org.isoron.uhabits.core.models.Habit
@ -49,11 +48,11 @@ open class ListHabitsBehavior @Inject constructor(
screen.showHabitScreen(h)
}
fun onEdit(location: ScreenLocation, habit: Habit, timestamp: Timestamp?) {
fun onEdit(habit: Habit, timestamp: Timestamp?) {
val entry = habit.computedEntries.get(timestamp!!)
if (habit.type == HabitType.NUMERICAL) {
val oldValue = entry.value.toDouble() / 1000
screen.showNumberPopup(oldValue, entry.notes, location) { newValue: Double, newNotes: String ->
screen.showNumberPopup(oldValue, entry.notes) { newValue: Double, newNotes: String ->
val value = (newValue * 1000).roundToInt()
commandRunner.run(CreateRepetitionCommand(habitList, habit, timestamp, value, newNotes))
}
@ -62,7 +61,6 @@ open class ListHabitsBehavior @Inject constructor(
entry.value,
entry.notes,
habit.color,
location,
) { newValue, newNotes ->
commandRunner.run(CreateRepetitionCommand(habitList, habit, timestamp, newValue, newNotes))
}
@ -158,14 +156,12 @@ open class ListHabitsBehavior @Inject constructor(
fun showNumberPopup(
value: Double,
notes: String,
location: ScreenLocation,
callback: NumberPickerCallback
)
fun showCheckmarkPopup(
selectedValue: Int,
notes: String,
color: PaletteColor,
location: ScreenLocation,
callback: CheckMarkDialogCallback
)
fun showSendBugReportToDeveloperScreen(log: String)

@ -19,7 +19,6 @@
package org.isoron.uhabits.core.ui.screens.habits.show.views
import org.isoron.platform.gui.ScreenLocation
import org.isoron.platform.time.DayOfWeek
import org.isoron.platform.time.LocalDate
import org.isoron.uhabits.core.commands.CommandRunner
@ -65,36 +64,35 @@ class HistoryCardPresenter(
val screen: Screen,
) : OnDateClickedListener {
override fun onDateLongPress(location: ScreenLocation, date: LocalDate) {
override fun onDateLongPress(date: LocalDate) {
val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback()
if (habit.isNumerical) {
showNumberPopup(location, timestamp)
showNumberPopup(timestamp)
} else {
if (preferences.isShortToggleEnabled) showCheckmarkPopup(location, timestamp)
if (preferences.isShortToggleEnabled) showCheckmarkPopup(timestamp)
else toggle(timestamp)
}
}
override fun onDateShortPress(location: ScreenLocation, date: LocalDate) {
override fun onDateShortPress(date: LocalDate) {
val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback()
if (habit.isNumerical) {
showNumberPopup(location, timestamp)
showNumberPopup(timestamp)
} else {
if (preferences.isShortToggleEnabled) toggle(timestamp)
else showCheckmarkPopup(location, timestamp)
else showCheckmarkPopup(timestamp)
}
}
private fun showCheckmarkPopup(location: ScreenLocation, timestamp: Timestamp) {
private fun showCheckmarkPopup(timestamp: Timestamp) {
val entry = habit.computedEntries.get(timestamp)
screen.showCheckmarkPopup(
entry.value,
entry.notes,
preferences,
habit.color,
location,
) { newValue, newNotes ->
commandRunner.run(
CreateRepetitionCommand(
@ -126,14 +124,13 @@ class HistoryCardPresenter(
)
}
private fun showNumberPopup(location: ScreenLocation, timestamp: Timestamp) {
private fun showNumberPopup(timestamp: Timestamp) {
val entry = habit.computedEntries.get(timestamp)
val oldValue = entry.value
screen.showNumberPopup(
value = oldValue / 1000.0,
notes = entry.notes,
preferences = preferences,
location = location,
) { newValue: Double, newNotes: String ->
val thousands = (newValue * 1000).roundToInt()
commandRunner.run(
@ -207,7 +204,6 @@ class HistoryCardPresenter(
value: Double,
notes: String,
preferences: Preferences,
location: ScreenLocation,
callback: ListHabitsBehavior.NumberPickerCallback,
)
fun showCheckmarkPopup(
@ -215,7 +211,6 @@ class HistoryCardPresenter(
notes: String,
preferences: Preferences,
color: PaletteColor,
location: ScreenLocation,
callback: ListHabitsBehavior.CheckMarkDialogCallback,
)
}

@ -22,7 +22,6 @@ package org.isoron.uhabits.core.ui.views
import org.isoron.platform.gui.Canvas
import org.isoron.platform.gui.Color
import org.isoron.platform.gui.DataView
import org.isoron.platform.gui.ScreenLocation
import org.isoron.platform.gui.TextAlign
import org.isoron.platform.time.DayOfWeek
import org.isoron.platform.time.LocalDate
@ -34,8 +33,8 @@ import kotlin.math.min
import kotlin.math.round
interface OnDateClickedListener {
fun onDateShortPress(location: ScreenLocation, date: LocalDate) {}
fun onDateLongPress(location: ScreenLocation, date: LocalDate) {}
fun onDateShortPress(date: LocalDate) {}
fun onDateLongPress(date: LocalDate) {}
}
class HistoryChart(
@ -91,11 +90,10 @@ class HistoryChart(
if (x - padding < 0 || row == 0 || row > 7 || col == nColumns) return
val clickedDate = topLeftDate.plus(offset)
if (clickedDate.isNewerThan(today)) return
val location = ScreenLocation(x, y)
if (isLongClick) {
onDateClickedListener.onDateLongPress(location, clickedDate)
onDateClickedListener.onDateLongPress(clickedDate)
} else {
onDateClickedListener.onDateShortPress(location, clickedDate)
onDateClickedListener.onDateShortPress(clickedDate)
}
}

@ -31,7 +31,6 @@ import junit.framework.Assert.assertTrue
import org.apache.commons.io.FileUtils
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.core.IsEqual.equalTo
import org.isoron.platform.gui.ScreenLocation
import org.isoron.uhabits.core.BaseUnitTest
import org.isoron.uhabits.core.models.Entry
import org.isoron.uhabits.core.models.Habit
@ -79,11 +78,10 @@ class ListHabitsBehaviorTest : BaseUnitTest() {
@Test
fun testOnEdit() {
behavior.onEdit(ScreenLocation(0.0, 0.0), habit2, getToday())
behavior.onEdit(habit2, getToday())
verify(screen).showNumberPopup(
eq(0.1),
eq(""),
any(),
picker.capture()
)
picker.lastValue.onNumberPicked(100.0, "")

@ -24,7 +24,6 @@ import com.nhaarman.mockitokotlin2.reset
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import kotlinx.coroutines.runBlocking
import org.isoron.platform.gui.ScreenLocation
import org.isoron.platform.gui.assertRenders
import org.isoron.platform.time.DayOfWeek
import org.isoron.platform.time.DayOfWeek.SUNDAY
@ -90,32 +89,20 @@ class HistoryChartTest {
// Click top left date
view.onClick(20.0, 46.0)
verify(dateClickedListener).onDateShortPress(
ScreenLocation(20.0, 46.0),
LocalDate(2014, 10, 26)
)
verify(dateClickedListener).onDateShortPress(LocalDate(2014, 10, 26))
reset(dateClickedListener)
view.onClick(2.0, 28.0)
verify(dateClickedListener).onDateShortPress(
ScreenLocation(2.0, 28.0),
LocalDate(2014, 10, 26)
)
verify(dateClickedListener).onDateShortPress(LocalDate(2014, 10, 26))
reset(dateClickedListener)
// Click date in the middle
view.onClick(163.0, 113.0)
verify(dateClickedListener).onDateShortPress(
ScreenLocation(163.0, 113.0),
LocalDate(2014, 12, 10)
)
verify(dateClickedListener).onDateShortPress(LocalDate(2014, 12, 10))
reset(dateClickedListener)
// Click today
view.onClick(336.0, 37.0)
verify(dateClickedListener).onDateShortPress(
ScreenLocation(336.0, 37.0),
LocalDate(2015, 1, 25)
)
verify(dateClickedListener).onDateShortPress(LocalDate(2015, 1, 25))
reset(dateClickedListener)
// Click header
@ -133,32 +120,20 @@ class HistoryChartTest {
// Click top left date
view.onLongClick(20.0, 46.0)
verify(dateClickedListener).onDateLongPress(
ScreenLocation(20.0, 46.0),
LocalDate(2014, 10, 26)
)
verify(dateClickedListener).onDateLongPress(LocalDate(2014, 10, 26))
reset(dateClickedListener)
view.onLongClick(2.0, 28.0)
verify(dateClickedListener).onDateLongPress(
ScreenLocation(2.0, 28.0),
LocalDate(2014, 10, 26)
)
verify(dateClickedListener).onDateLongPress(LocalDate(2014, 10, 26))
reset(dateClickedListener)
// Click date in the middle
view.onLongClick(163.0, 113.0)
verify(dateClickedListener).onDateLongPress(
ScreenLocation(163.0, 113.0),
LocalDate(2014, 12, 10)
)
verify(dateClickedListener).onDateLongPress(LocalDate(2014, 12, 10))
reset(dateClickedListener)
// Click today
view.onLongClick(336.0, 37.0)
verify(dateClickedListener).onDateLongPress(
ScreenLocation(336.0, 37.0),
LocalDate(2015, 1, 25)
)
verify(dateClickedListener).onDateLongPress(LocalDate(2015, 1, 25))
reset(dateClickedListener)
// Click header

Loading…
Cancel
Save