-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Async promo dialog #6467
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
Async promo dialog #6467
Changes from 16 commits
6f9b886
ab4d8b6
8cf524f
9825316
4628c60
8474b99
de468b3
0b353a0
fa2bb7c
4c5022b
ccd7950
bb983c0
eae5185
91f9870
1c1a6de
e521d3d
0a81c29
f4e7063
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
import org.wordpress.android.ui.accounts.HelpActivity; | ||
import org.wordpress.android.ui.accounts.LoginActivity; | ||
import org.wordpress.android.ui.accounts.LoginEpilogueActivity; | ||
import org.wordpress.android.ui.accounts.login.LoginEpilogueFragment; | ||
import org.wordpress.android.ui.accounts.NewBlogFragment; | ||
import org.wordpress.android.ui.accounts.NewUserFragment; | ||
import org.wordpress.android.ui.accounts.SignInActivity; | ||
|
@@ -26,6 +25,7 @@ | |
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; | ||
import org.wordpress.android.ui.accounts.login.LoginMagicLinkRequestFragment; | ||
import org.wordpress.android.ui.accounts.login.LoginSiteAddressFragment; | ||
import org.wordpress.android.ui.accounts.login.LoginSiteAddressHelpDialogFragment; | ||
|
@@ -68,9 +68,9 @@ | |
import org.wordpress.android.ui.prefs.AccountSettingsFragment; | ||
import org.wordpress.android.ui.prefs.AppSettingsFragment; | ||
import org.wordpress.android.ui.prefs.BlogPreferencesActivity; | ||
import org.wordpress.android.ui.prefs.EditorReleaseNotesActivity; | ||
import org.wordpress.android.ui.prefs.MyProfileActivity; | ||
import org.wordpress.android.ui.prefs.MyProfileFragment; | ||
import org.wordpress.android.ui.prefs.ReleaseNotesActivity; | ||
import org.wordpress.android.ui.prefs.SiteSettingsFragment; | ||
import org.wordpress.android.ui.prefs.SiteSettingsInterface; | ||
import org.wordpress.android.ui.prefs.notifications.NotificationsSettingsFragment; | ||
|
@@ -221,7 +221,7 @@ public interface AppComponent { | |
void inject(ReaderWebView object); | ||
void inject(ReaderPostPagerActivity object); | ||
|
||
void inject(EditorReleaseNotesActivity object); | ||
void inject(ReleaseNotesActivity object); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice reuse |
||
void inject(WPWebViewActivity object); | ||
void inject(WPWebViewClient object); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ | |
import org.wordpress.android.ui.posts.services.AztecImageLoader; | ||
import org.wordpress.android.ui.posts.services.AztecVideoLoader; | ||
import org.wordpress.android.ui.prefs.AppPrefs; | ||
import org.wordpress.android.ui.prefs.EditorReleaseNotesActivity; | ||
import org.wordpress.android.ui.prefs.ReleaseNotesActivity; | ||
import org.wordpress.android.ui.prefs.SiteSettingsInterface; | ||
import org.wordpress.android.ui.uploads.PostEvents; | ||
import org.wordpress.android.ui.uploads.UploadService; | ||
|
@@ -109,6 +109,7 @@ | |
import org.wordpress.android.util.DateTimeUtils; | ||
import org.wordpress.android.util.DisplayUtils; | ||
import org.wordpress.android.util.FluxCUtils; | ||
import org.wordpress.android.util.HelpshiftHelper; | ||
import org.wordpress.android.util.ImageUtils; | ||
import org.wordpress.android.util.ListUtils; | ||
import org.wordpress.android.util.MediaUtils; | ||
|
@@ -176,6 +177,7 @@ public class EditPostActivity extends AppCompatActivity implements | |
private static final int AUTOSAVE_INTERVAL_MILLIS = 60000; | ||
|
||
private static final String PHOTO_PICKER_TAG = "photo_picker"; | ||
private static final String ASYNC_PROMO_DIALOG_TAG = "async_promo"; | ||
|
||
private Handler mHandler; | ||
private boolean mShowAztecEditor; | ||
|
@@ -471,11 +473,17 @@ public void onConfigurationChanged(Configuration newConfig) { | |
if (orientation != mPhotoPickerOrientation) { | ||
resizePhotoPicker(); | ||
} | ||
|
||
// If we're showing the Async promo dialog, we need to redraw it so it takes into account | ||
|
||
PromoDialog fragment = (PromoDialog) getSupportFragmentManager().findFragmentByTag(ASYNC_PROMO_DIALOG_TAG); | ||
if (fragment != null) { | ||
fragment.redrawForOrientationChange(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onBetaClicked() { | ||
startActivity(new Intent(EditPostActivity.this, EditorReleaseNotesActivity.class)); | ||
ActivityLauncher.showAztecEditorReleaseNotes(this); | ||
AnalyticsTracker.track(Stat.EDITOR_AZTEC_BETA_LABEL); | ||
} | ||
|
||
|
@@ -765,7 +773,11 @@ public boolean onOptionsItemSelected(final MenuItem item) { | |
} | ||
|
||
if (itemId == R.id.menu_save_post) { | ||
publishPost(); | ||
if (!AppPrefs.isAsyncPromoRequired()) { | ||
publishPost(); | ||
} else { | ||
showAsyncPromoDialog(); | ||
} | ||
} else { | ||
// Disable other action bar buttons while a media upload is in progress | ||
// (unnecessary for Aztec since it supports progress reattachment) | ||
|
@@ -2477,7 +2489,7 @@ protected void showSnackbarBeta() { | |
new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
startActivity(new Intent(EditPostActivity.this, EditorReleaseNotesActivity.class)); | ||
ActivityLauncher.showAztecEditorReleaseNotes(EditPostActivity.this); | ||
AnalyticsTracker.track(Stat.EDITOR_AZTEC_BETA_LINK); | ||
} | ||
} | ||
|
@@ -2507,6 +2519,27 @@ public void onClick(View view) { | |
} | ||
} | ||
|
||
private void showAsyncPromoDialog() { | ||
PromoDialogAdvanced asyncPromoDialog = new PromoDialogAdvanced.Builder( | ||
R.drawable.img_promo_async, | ||
R.string.async_promo_title, | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's create an issue so we track this one before release There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 created #6470. |
||
.build(); | ||
|
||
asyncPromoDialog.setPositiveButtonOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
publishPost(); | ||
} | ||
}); | ||
|
||
asyncPromoDialog.show(getSupportFragmentManager(), ASYNC_PROMO_DIALOG_TAG); | ||
AppPrefs.setAsyncPromoRequired(false); | ||
} | ||
|
||
// EditPostActivityHook methods | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,48 +2,74 @@ | |
|
||
import android.app.Dialog; | ||
import android.os.Bundle; | ||
import android.support.annotation.DrawableRes; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.StringRes; | ||
import android.support.v7.app.AppCompatDialog; | ||
import android.support.v7.app.AppCompatDialogFragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.Window; | ||
import android.widget.Button; | ||
import android.widget.ImageView; | ||
import android.widget.LinearLayout; | ||
|
||
import org.wordpress.android.R; | ||
import org.wordpress.android.util.DisplayUtils; | ||
import org.wordpress.android.widgets.WPTextView; | ||
|
||
public class PromoDialog extends AppCompatDialogFragment { | ||
public static class Builder { | ||
@StringRes int buttonPositiveId; | ||
@StringRes int descriptionId; | ||
@DrawableRes int drawableId; | ||
@StringRes int titleId; | ||
|
||
public Builder(@DrawableRes int drawableId, @StringRes int titleId, @StringRes int descriptionId, | ||
@StringRes int buttonPositiveId) { | ||
this.drawableId = drawableId; | ||
this.titleId = titleId; | ||
this.descriptionId = descriptionId; | ||
this.buttonPositiveId = buttonPositiveId; | ||
} | ||
|
||
public PromoDialog build() { | ||
PromoDialog fragment = new PromoDialog(); | ||
Bundle args = new Bundle(); | ||
args.putInt("drawableId", drawableId); | ||
args.putInt("titleId", titleId); | ||
args.putInt("descriptionId", descriptionId); | ||
args.putInt("buttonPositiveId", buttonPositiveId); | ||
fragment.setArguments(args); | ||
return fragment; | ||
} | ||
} | ||
|
||
protected int mButtonPositiveId; | ||
protected int mDescriptionId; | ||
protected int mDrawableId; | ||
protected int mTitleId; | ||
|
||
public static PromoDialog newInstance(int drawableId, int titleId, int descriptionId, int buttonPositiveId) { | ||
PromoDialog fragment = new PromoDialog(); | ||
Bundle args = new Bundle(); | ||
args.putInt("drawableId", drawableId); | ||
args.putInt("titleId", titleId); | ||
args.putInt("descriptionId", descriptionId); | ||
args.putInt("buttonPositiveId", buttonPositiveId); | ||
fragment.setArguments(args); | ||
return fragment; | ||
} | ||
protected View.OnClickListener mPositiveButtonOnClickListener; | ||
|
||
@Override | ||
public Dialog onCreateDialog(Bundle savedInstanceState) { | ||
public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) { | ||
Dialog dialog = super.onCreateDialog(savedInstanceState); | ||
mDrawableId = getArguments().getInt("drawableId"); | ||
mTitleId = getArguments().getInt("titleId"); | ||
mDescriptionId = getArguments().getInt("descriptionId"); | ||
mButtonPositiveId = getArguments().getInt("buttonPositiveId"); | ||
// request a window without the title | ||
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); | ||
dialog.setCanceledOnTouchOutside(false); | ||
dialog.setCancelable(false); | ||
return dialog; | ||
} | ||
|
||
@Override | ||
public void setupDialog(Dialog dialog, int style) { | ||
((AppCompatDialog) dialog).supportRequestWindowFeature(Window.FEATURE_NO_TITLE); | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
|
@@ -53,19 +79,33 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, | |
@Override | ||
public void onViewCreated(View view, Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
Button btn = (Button) view.findViewById(R.id.promo_dialog_button_positive); | ||
btn.setText(mButtonPositiveId); | ||
ImageView image = (ImageView) view.findViewById(R.id.promo_dialog_image); | ||
image.setImageResource(mDrawableId); | ||
WPTextView title = (WPTextView) view.findViewById(R.id.promo_dialog_title); | ||
title.setText(mTitleId); | ||
WPTextView desc = (WPTextView) view.findViewById(R.id.promo_dialog_description); | ||
desc.setText(mDescriptionId); | ||
btn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
getDialog().cancel(); | ||
} | ||
}); | ||
|
||
Button btn = (Button) view.findViewById(R.id.promo_dialog_button_positive); | ||
btn.setText(mButtonPositiveId); | ||
if (mPositiveButtonOnClickListener == null) { | ||
btn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
getDialog().cancel(); | ||
} | ||
}); | ||
} else { | ||
btn.setOnClickListener(mPositiveButtonOnClickListener); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're lacking a dialog The default click handler does issue a cancel:
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 ok |
||
} | ||
} | ||
|
||
public void setPositiveButtonOnClickListener(View.OnClickListener listener) { | ||
mPositiveButtonOnClickListener = listener; | ||
} | ||
|
||
public void redrawForOrientationChange() { | ||
LinearLayout imageContainer = (LinearLayout) getView().findViewById(R.id.promo_dialog_image_container); | ||
imageContainer.setVisibility(DisplayUtils.isLandscape(getActivity()) ? View.GONE : View.VISIBLE); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice name