fix(#530): replay a date open that was never handled
This commit is contained in:
1 parent
ed4129580b
commit
2970ca08d0
2 files changed
+19
-6
No files matched your search
@@ -151,8 +151,8 @@ class MainActivity : AppCompatActivity() {
|
||||
// that event on every later launch, an error screen once the event had
|
||||
// been deleted (#309); the user left it long ago, and the activity
|
||||
// restores where they actually were along with its saved state. A date
|
||||
// open is held back the same way, so a finished widget day (#530) comes
|
||||
// back from Recents on the home view.
|
||||
// open is held back the same way once handled, so a finished widget day
|
||||
// (#530) comes back from Recents on the home view.
|
||||
//
|
||||
// Only those channels are held back. An .ics import or a prefilled
|
||||
// create form keeps no saved state of its own, so re-reading the intent
|
||||
@@ -164,8 +164,10 @@ class MainActivity : AppCompatActivity() {
|
||||
requests.detailKey = intent.detailKeyOrNull() ?: intent.viewEventKeyOrNull()
|
||||
requests.editKey = intent.editEventKeyOrNull()
|
||||
}
|
||||
requests.nav = intent.navRequestOrNull()
|
||||
?.takeUnless { replaying && (it is WidgetNavRequest.OpenEvent || it is WidgetNavRequest.OpenDate) }
|
||||
val navPendingBefore = savedInstanceState?.getBoolean(KEY_NAV_PENDING) == true
|
||||
requests.nav = intent.navRequestOrNull()?.takeUnless {
|
||||
replaying && (it is WidgetNavRequest.OpenEvent || (it is WidgetNavRequest.OpenDate && !navPendingBefore))
|
||||
}
|
||||
requests.importUri = intent.importUriOrNull()
|
||||
val insertOpenBefore = savedInstanceState?.getBoolean(KEY_INSERT_FORM_OPEN) == true
|
||||
requests.insert = intent.createRequestOrNull()?.takeIf { !replaying || insertOpenBefore }
|
||||
@@ -291,6 +293,7 @@ class MainActivity : AppCompatActivity() {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putBoolean(KEY_INSERT_FORM_OPEN, insertFormOpen)
|
||||
outState.putBoolean(KEY_LAUNCHED_FOR_INSERT, launchedForInsert)
|
||||
outState.putBoolean(KEY_NAV_PENDING, requests.nav != null)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
@@ -566,6 +569,7 @@ class MainActivity : AppCompatActivity() {
|
||||
private val CALENDAR_EXTENSIONS = listOf(".ics", ".vcs")
|
||||
private const val KEY_INSERT_FORM_OPEN = "insert_form_open"
|
||||
private const val KEY_LAUNCHED_FOR_INSERT = "launched_for_insert"
|
||||
private const val KEY_NAV_PENDING = "nav_pending"
|
||||
|
||||
private const val EXTRA_EVENT_ID = "de.jeanlucmakiola.calendula.extra.EVENT_ID"
|
||||
private const val EXTRA_BEGIN_MILLIS = "de.jeanlucmakiola.calendula.extra.BEGIN"
|
||||
@@ -605,8 +609,9 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
/**
|
||||
* Open the day view anchored on [date] from a home-screen widget; backing
|
||||
* out of the day returns to the home screen (#530). [source] only keeps
|
||||
* the PendingIntents of different widget kinds apart.
|
||||
* out of the day returns to the home screen (#530). [source] marks the
|
||||
* launch as a widget's and keeps different widget kinds' PendingIntents
|
||||
* apart; its value doesn't change where back goes.
|
||||
*/
|
||||
fun openDateIntent(context: Context, date: LocalDate, source: CalendarView): Intent =
|
||||
Intent(context, MainActivity::class.java).apply {
|
||||
|
||||
@@ -92,6 +92,14 @@ class ViewBackStackTest {
|
||||
assertThat(stack.first()).isEqualTo(CalendarView.Week)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a date launch drills the day over the home view only`() {
|
||||
assertThat(listOf(CalendarView.Week).drillToDay())
|
||||
.containsExactly(CalendarView.Week, CalendarView.Day)
|
||||
.inOrder()
|
||||
assertThat(listOf(CalendarView.Day).drillToDay()).containsExactly(CalendarView.Day)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a widget whose view is the home view does not duplicate the home`() {
|
||||
// Default = Agenda, agenda widget event tap → just the home, no extra layer.
|
||||
|
||||
Reference in new issue
Block a user