Skip to content

Conversation

aforcier
Copy link
Contributor

@aforcier aforcier commented Aug 3, 2017

Adds a promo dialog, shown the first time a user presses the 'Publish' button:

async-promo-dialog-pr

Note: For now, the 'How does it work?' text is hidden. Closer (or just after) the beta we'll put up a post on mobile make, link to that, and unhide the link text.

I also added a new PromoDialogAdvanced, intended for reuse for any dialogs requiring a link or negative button field (the existing PromoDialogEditor now extends this one, adding an extra title field for 'Beta'). The pre-existing PromoDialog can be used for simple (image, title, description, positive button) promos.

Also some design changes:

  • All promo dialogs (currently this includes Aztec, the stats widget, and this one) now have a divider above the button row:

dialogs-with-divider

cc @iamthomasbishop (no visual changes to the async promo since we last spoke)

import org.wordpress.android.ui.accounts.login.Login2FaFragment;
import org.wordpress.android.ui.accounts.login.LoginEmailFragment;
import org.wordpress.android.ui.accounts.login.LoginEmailPasswordFragment;
import org.wordpress.android.ui.accounts.login.LoginEpilogueFragment;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice name

void inject(ReaderPostPagerActivity object);

void inject(EditorReleaseNotesActivity object);
void inject(ReleaseNotesActivity object);
Copy link
Contributor

Choose a reason for hiding this comment

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

nice reuse

resizePhotoPicker();
}

// If we're showing the Async promo dialog, we need to redraw it so it takes into account
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure what the comment meant, it should continue but ends abruptly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Woops! Fixed in 0a81c29.

*/
public class PromoDialogAdvanced extends PromoDialog {
public static class Builder extends PromoDialog.Builder {
@StringRes int linkId;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make these linkResId, buttonNegativeResId, descriptionResId etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in f4e7063.

protected static PromoDialogAdvanced newInstance(Builder builder) {
PromoDialogAdvanced fragment = new PromoDialogAdvanced();
Bundle args = new Bundle();
args.putInt("drawableId", builder.drawableId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move the "drawableId", "titleId", etc strings to private static final String...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An excellent idea - done in f4e7063.

@iamthomasbishop
Copy link

This is looking great! I'm thinking the illustration should have slightly less top/bottom padding, but let's roll with this for now.

R.string.async_promo_description,
android.R.string.ok)
// TODO: Re-enable once a release notes page exists for Async
// .setLinkText(R.string.async_promo_link)
Copy link
Contributor

Choose a reason for hiding this comment

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

let's create an issue so we track this one before release

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 created #6470.

});
} else {
btn.setOnClickListener(mPositiveButtonOnClickListener);
}
Copy link
Contributor

@mzorz mzorz Aug 3, 2017

Choose a reason for hiding this comment

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

We're lacking a dialog cancel() call here like we do in https://github.com/wordpress-mobile/WordPress-Android/pull/6467/files#diff-1999fe3664a86fade02c8922f6857c75R134

The default click handler does issue a cancel:
https://github.com/wordpress-mobile/WordPress-Android/pull/6467/files#diff-42c777438a1a186bb67bd763a279089eR100
I’m wondering, shouldn’t we make sure that when you set a handler we also cancel the dialog, either by giving the new handler that responsibility, or if not, we could maybe set our own anonymous handler and call the other listener within it, like this:

            btn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    getDialog().cancel();
                    mPositiveButtonOnClickListener.onClick(view);
                }
            });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure we should hard-code that behavior. It's conceivable that you might not want to dismiss the dialog on the positive button, or do something else with the dialog first, so to me it makes sense to leave it up to the dialog 'client' to dictate the behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 ok


Button buttonPositive = (Button) view.findViewById(R.id.promo_dialog_button_positive);
buttonPositive.setText(mButtonPositiveId);
buttonPositive.setOnClickListener(mPositiveButtonOnClickListener);
Copy link
Contributor

Choose a reason for hiding this comment

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

None of this is necessary as the positive button's text and listener are already being set in the base class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's not necessary as things currently stand. But, we don't have a way of checking that the layout we're using matches the layout of the parent class. So I left in the setup so it's explicit what view names each dialog expects to be there. This is around where the usefulness of the inheritance pattern wears thin 😞

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave it as is - I think the layouts will be kept similar for the context of use we are giving to these Dialogs, but really no harm in leaving this and re-inforcing the need to have a specific promo_dialog_button positive set in the view.

@mzorz
Copy link
Contributor

mzorz commented Aug 3, 2017

Nice job @aforcier @iamthomasbishop !
Tested this on a couple of handsets and emus, even very small screens, and works alright 👍
:shipit:

@mzorz mzorz merged commit b422e87 into develop Aug 3, 2017
@aforcier aforcier deleted the feature/async-promo-dialog branch August 3, 2017 18:05
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.

3 participants