Skip to content

Move publish to new screen#10183

Merged
khaykov merged 14 commits intofeature/post_scheduling_readonlyfrom
feature/move_publish_to_new_screen
Jul 11, 2019
Merged

Move publish to new screen#10183
khaykov merged 14 commits intofeature/post_scheduling_readonlyfrom
feature/move_publish_to_new_screen

Conversation

@planarvoid
Copy link
Contributor

@planarvoid planarvoid commented Jul 9, 2019

This PR is the first step of the improved post scheduling. It introduces a new screen that appears when the user clicks on the "Publish" button in post settings.
In this PR you can click on the "Time and Date" to select a date from Date/Time picker and the label gets filled correctly. Going back to the Post settings sets the scheduled date.
I'll add tests in another PR.

To test:

  • Go to Post editor
  • Click on Menu/Post settings
  • Click on "Publish"
  • A new screen opens
  • Click on "Time and Date"
  • Select a Date from a date picker
  • Select a Time from a time picker
  • The "Time and Date" label is now set
  • Go back
  • The "Publish" field has now a label same as the "Time and Date"

Overall notice that the date selection behaviour should be the same as before.

date_picking_2

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@planarvoid planarvoid added this to the 12.9 milestone Jul 9, 2019
@planarvoid planarvoid requested a review from khaykov July 9, 2019 08:42
@planarvoid planarvoid self-assigned this Jul 9, 2019
@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Jul 9, 2019

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

Copy link
Contributor

@khaykov khaykov left a comment

Choose a reason for hiding this comment

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

Good job with new scheduling! Post status thing looks pretty complicated 😅 I have a couple of comments:

  • Post time is updated without pressing the update button. It's pretty easy to mess up stuff without even noticing.
  • What is the difference between Publish label and Scheduled? Also, what is the difference between IMMEDIATELY and NOW in date picker? Button said NOW, but I messed with time somehow and it says IMMEDIATELY.
  • Selecting future date, opening dialog again and selecting NOW/IMMEDIATELY sometimes results in Publish label and sometimes in Published. Doing it a couple of time cycles between those.

// having the app be smart about it - we don't want to accidentally publish a post.
finalPostStatus = DRAFT
// show toast only once, when time is shown
ToastUtils.showToast(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move the Toast away from VM, into fragment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

totally, I actually did that in the following PR but I'll move the change here 👍

@khaykov
Copy link
Contributor

khaykov commented Jul 10, 2019

Also, I found a crash, that I think might have been introduced in this branch (maybe something to do with ViewPager?), since I can't reproduce it in develop.
Steps to reproduce:

  • Open Post.
  • Open Post settings.
  • Navigate back to post.
  • Rotate device, and rotate it back again.
  • Observe the following crash:
31250-31250/org.wordpress.android.beta E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.wordpress.android.beta, PID: 31250
    kotlin.UninitializedPropertyAccessException: lateinit property viewModel has not been initialized
        at org.wordpress.android.ui.posts.HistoryListFragment.onSaveInstanceState(HistoryListFragment.kt:60)
        at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:2626)
        at androidx.fragment.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:2910)
        at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2971)
        at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:134)
        at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:591)
        at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:510)
        at org.wordpress.android.ui.posts.EditPostActivity.onSaveInstanceState(EditPostActivity.java:807)
        at android.app.Activity.performSaveInstanceState(Activity.java:1414)
        at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1300)
        at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4541)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4492)
        at android.app.ActivityThread.-wrap19(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

@planarvoid
Copy link
Contributor Author

planarvoid commented Jul 10, 2019

hey @khaykov, thanks for the review!

Post time is updated without pressing the update button. It's pretty easy to mess up stuff without even noticing.

I've checked the previous implementation and this behaves the same way. It's a pretty bad experience but I'd rather not change it now 😞

What is the difference between Publish label and Scheduled?

If I understand it correctly, Publish label is shown for local drafts with a created date set to the future where you haven't clicked the Schedule button yet

...what is the difference between IMMEDIATELY and NOW in date picker? Button said NOW, but I messed with time somehow and it says IMMEDIATELY.

Good question, I have no idea why it was introduced but we show the IMMEDIATELY status only when the post is a draft. However, when you select a date, the status changes to SCHEDULED and it's not draft any more so we show NOW. I don't think this is a great experience either.

Selecting future date, opening dialog again and selecting NOW/IMMEDIATELY sometimes results in Publish label and sometimes in Published. Doing it a couple of time cycles between those.

edit: I've found the issue and man, what a hack it was. Previously we were relying on updating the status twice after both date and time were set. The first set changed the status from Draft to Published and the second one from Published to Scheduled. Since I've removed the first update, the first iteration set the status from Draft to Published (and showed the "Published" label) and the second iteration from Published to Scheduled (and showed the "Publish" label)!!! It took me 3 hours to find this but it should be fixed now.

Also, I found a crash...
kotlin.UninitializedPropertyAccessException: lateinit property viewModel has not been initialized
at org.wordpress.android.ui.posts.HistoryListFragment.onSaveInstanceState(HistoryListFragment.kt:60)

I'm pretty sure this happens in the post History which was implemented recently and has nothing to do with my PR. It's strange it's not happening in develop. I've fixed it by initializing the view model in onCreate instead of onViewCreated

Copy link
Contributor

@khaykov khaykov left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! I haven't used post settings that munch and didn't realize the logic comes from there :)

I have one comment in code, and one here:
.

..what is the difference between IMMEDIATELY and NOW in date picker? Button said NOW, but I >messed with time somehow and it says IMMEDIATELY.

Good question, I have no idea why it was introduced but we show the IMMEDIATELY status only when the post is a draft. However, when you select a date, the status changes to SCHEDULED and it's not draft any more so we show NOW. I don't think this is a great experience either.

I compared the effect of changing the published post status (not the post date) to the button label with develop and there is one difference:
When you manually change post status from Publish to Draft, button in date picker reflects this change (switches from now to immediate and back). In this branch does not happen. Maybe changes to the post model not correctly picked up by Publish settings VM/Fragment?

Image from Gyazo

@planarvoid
Copy link
Contributor Author

@khaykov thanks for the check! I was not indeed reacting to the post status change in the post settings. This should now be fixed. I think there should be a singleton class like PostProvider keeps the post and triggers the UI updates. I think I'll try to create it in a separate PR because this is a mess.

@wordpress-mobile wordpress-mobile deleted a comment from wpmobilebot Jul 11, 2019
Copy link
Contributor

@khaykov khaykov left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes! Works well now :)

@khaykov khaykov merged commit 5ca4848 into feature/post_scheduling_readonly Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants