Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
android:label="@string/settings"
android:theme="@style/CalypsoTheme" />
<activity
android:name=".ui.prefs.EditorReleaseNotesActivity"
android:name=".ui.prefs.ReleaseNotesActivity"
android:theme="@style/Calypso.NoActionBar" />
<activity
android:name=".ui.prefs.LicensesActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
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

import org.wordpress.android.ui.accounts.login.LoginMagicLinkRequestFragment;
import org.wordpress.android.ui.accounts.login.LoginSiteAddressFragment;
import org.wordpress.android.ui.accounts.login.LoginSiteAddressHelpDialogFragment;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -221,7 +221,7 @@ public interface AppComponent {
void inject(ReaderWebView object);
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

void inject(WPWebViewActivity object);
void inject(WPWebViewClient object);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.wordpress.android.ui.prefs.AppSettingsActivity;
import org.wordpress.android.ui.prefs.BlogPreferencesActivity;
import org.wordpress.android.ui.prefs.MyProfileActivity;
import org.wordpress.android.ui.prefs.ReleaseNotesActivity;
import org.wordpress.android.ui.prefs.notifications.NotificationsSettingsActivity;
import org.wordpress.android.ui.publicize.PublicizeListActivity;
import org.wordpress.android.ui.reader.ReaderPostPagerActivity;
Expand Down Expand Up @@ -361,6 +362,14 @@ public static void loginWithoutMagicLink(Activity activity) {
activity.startActivityForResult(intent, RequestCodes.DO_LOGIN);
}

public static void showAztecEditorReleaseNotes(Activity activity) {
Intent intent = new Intent(activity, ReleaseNotesActivity.class);
intent.putExtra(ReleaseNotesActivity.KEY_TARGET_URL,
"https://make.wordpress.org/mobile/whats-new-in-beta-android-editor/");
intent.putExtra(ReleaseNotesActivity.KEY_HELPSHIFT_TAG, HelpshiftHelper.Tag.ORIGIN_FEEDBACK_AZTEC);
activity.startActivity(intent);
}

/*
* open the passed url in the device's external browser
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ private void setTabLayoutElevation(float newElevation){

private void showNewEditorPromoDialogIfNeeded() {
if (AppPrefs.isNewEditorPromoRequired()) {
AppCompatDialogFragment newFragment = PromoDialogEditor.newInstance(
AppCompatDialogFragment newFragment = new PromoDialogEditor.Builder(
R.drawable.img_promo_editor,
R.string.new_editor_promo_title,
R.string.new_editor_promo_title_beta,
R.string.new_editor_promo_description,
R.string.new_editor_promo_link,
R.string.new_editor_promo_button_negative,
R.string.new_editor_promo_button_positive
);
R.string.new_editor_promo_button_positive)
.setLinkText(R.string.new_editor_promo_link)
.setNegativeButtonText(R.string.new_editor_promo_button_negative)
.setTitleBetaText(R.string.new_editor_promo_title_beta)
.build();
newFragment.show(getSupportFragmentManager(), "new-editor-promo");
AppPrefs.setNewEditorPromoRequired(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
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.

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);
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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)
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.

.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
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

}
}

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);
}
}
Loading