New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze time #617

Merged
merged 13 commits into from Dec 21, 2018

Conversation

Projects
None yet
2 participants
@fourlastor
Copy link
Contributor

fourlastor commented Dec 21, 2018

Problem

We want to be able to set which time it is when developing

Solution

Add a new functionality to the debug screen! Now the app will either get the real time (if you unfreeze) or the set time (if you freeze)

Screenshots

device-2018-12-21-112925

Time Frozen Time not frozen
screenshot from 2018-12-21 14-50-30 screenshot from 2018-12-21 14-50-37
@rock3r

This comment has been minimized.

Copy link
Collaborator

rock3r commented Dec 21, 2018

Damn, our debug screen is fugly LOL

@rock3r
Copy link
Collaborator

rock3r left a comment

Nice one, few notes inline, and one consideration: should we show somewhere that we have frozen time? Like an appbar icon in the main screen (tapping it opens the debug screen), dunno. Just so that we don't forget about that. Maybe in a separate PR, even.

@@ -41,6 +47,9 @@ class DebugActivity : AppCompatActivity() {
buttonResetOnboarding.setOnClickListener { resetOnboarding() }

notificationCreator = NotificationCreator(this)

findViewById<Button>(R.id.freezeTime).setOnClickListener { freezeTime() }

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

Would require it of boyscouting, but we could use kotlinx synthetics instead of findViewById

This comment has been minimized.

@fourlastor

fourlastor Dec 21, 2018

Contributor

I tried, it doesn't work on other source sets than main (there's also a bug open somewhere which has been apparently fixed but not released)

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

TIL! Ok :)


fun unfreeze(context: Context) {
PreferenceManager.getDefaultSharedPreferences(context)
.edit {

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

Nit: on one line?

This comment has been minimized.

@fourlastor
private fun Int.to0Based() = this - 1

private fun pickTime(now: ZonedDateTime, frozenDate: LocalDate) {
val timePickerDialog = TimePickerDialog(this, TimePickerDialog.OnTimeSetListener { _, hourOfDay, minute ->

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

Whatever happened to one argument per line? :D

This comment has been minimized.

@fourlastor

private fun freezeTime() {
val now = DebugCurrentTime(applicationContext).currentDateTime()

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

This empty line would be perfect to put in a "show currently frozen time on a label" thing 💃

This comment has been minimized.

@fourlastor

class DebugCurrentTime : CurrentTime {
class DebugCurrentTime(context: Context) : CurrentTime {

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

Maybe we should rename to FreezableCurrentTime?

This comment has been minimized.

@fourlastor
@fourlastor

This comment has been minimized.

Copy link
Contributor

fourlastor commented Dec 21, 2018

Like an appbar icon in the main screen (tapping it opens the debug screen), dunno. Just so that we don't forget about that.

We need to find a way not to pollute main with the logic, other than that I'm in for it (separate PR for sure, though)

@rock3r
Copy link
Collaborator

rock3r left a comment

Couple more notes :)

}

private fun updateFrozenTimeLabel() {
findViewById<TextView>(R.id.timeFrozenIndicator).text = if (currentTime.isTimeFrozen()) {

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

💯

updateFrozenTimeLabel()
}

private fun updateFrozenTimeLabel() {

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

Should go after the last usage (L210)

This comment has been minimized.

@fourlastor
preferences.edit { remove(KEY_FROZEN_TIME) }
}

fun isTimeFrozen(): Boolean {

This comment has been minimized.

@rock3r

rock3r Dec 21, 2018

Collaborator

Expression body?

This comment has been minimized.

@fourlastor
@rock3r

rock3r approved these changes Dec 21, 2018

@rock3r rock3r merged commit 3db99a1 into develop Dec 21, 2018

5 checks passed

ci/circleci: checkout Your tests passed on CircleCI!
Details
ci/circleci: license_checks Your tests passed on CircleCI!
Details
ci/circleci: prepare_for_checks Your tests passed on CircleCI!
Details
ci/circleci: static_analysis Your tests passed on CircleCI!
Details
ci/circleci: tests Your tests passed on CircleCI!
Details

@rock3r rock3r deleted the freeze-time branch Dec 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment