Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Modify editor promo dialog to extend PromoDialogAdvanced
  • Loading branch information
aforcier committed Aug 2, 2017
commit 4628c60632f1849b7a67456b036043d67a9a8fca
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ private void showNewEditorPromoDialogIfNeeded() {
R.string.new_editor_promo_title,
R.string.new_editor_promo_description,
R.string.new_editor_promo_button_positive)
.setTitleBetaText(R.string.new_editor_promo_title_beta)
.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 @@ -24,29 +24,25 @@
import org.wordpress.android.util.DisplayUtils;
import org.wordpress.android.widgets.WPTextView;

public class PromoDialogEditor extends PromoDialog {
public static class Builder extends PromoDialog.Builder {
@StringRes int titleBetaId;
@StringRes int linkId;
@StringRes int buttonNegativeId;
public class PromoDialogEditor extends PromoDialogAdvanced {
public static class Builder extends PromoDialogAdvanced.Builder {
@StringRes private int titleBetaId;

public Builder(@DrawableRes int drawableId, @StringRes int titleId, @StringRes int descriptionId,
@StringRes int buttonPositiveId) {
super(drawableId, titleId, descriptionId, buttonPositiveId);
}

public Builder setTitleBetaText(@StringRes int titleBetaId) {
this.titleBetaId = titleBetaId;
return this;
}

public Builder setLinkText(@StringRes int linkId) {
this.linkId = linkId;
return this;
return (Builder) super.setLinkText(linkId);
}

public Builder setNegativeButtonText(@StringRes int buttonNegativeId) {
this.buttonNegativeId = buttonNegativeId;
return (Builder) super.setNegativeButtonText(buttonNegativeId);
}

public Builder setTitleBetaText(@StringRes int titleBetaId) {
this.titleBetaId = titleBetaId;
return this;
}

Expand All @@ -56,8 +52,6 @@ public PromoDialogEditor build() {
}
}

protected int mButtonNegativeId;
protected int mLinkId;
protected int mTitleBetaId;

protected static PromoDialogEditor newInstance(Builder builder) {
Expand Down Expand Up @@ -114,27 +108,31 @@ public void onViewCreated(View view, Bundle savedInstanceState) {

WPTextView link = (WPTextView) view.findViewById(R.id.promo_dialog_link);
link.setText(mLinkId);
link.setOnClickListener(
new View.OnClickListener() {
if (mLinkOnClickListener == null) {
link.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getActivity(), EditorReleaseNotesActivity.class));
AnalyticsTracker.track(AnalyticsTracker.Stat.EDITOR_AZTEC_PROMO_LINK);
}
}
);
});
} else {
link.setOnClickListener(mLinkOnClickListener);
}

Button buttonNegative = (Button) view.findViewById(R.id.promo_dialog_button_negative);
buttonNegative.setText(mButtonNegativeId);
buttonNegative.setOnClickListener(
new View.OnClickListener() {
if (mNegativeButtonOnClickListener == null) {
buttonNegative.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
getDialog().cancel();
AnalyticsTracker.track(AnalyticsTracker.Stat.EDITOR_AZTEC_PROMO_NEGATIVE);
}
}
);
});
} else {
buttonNegative.setOnClickListener(mNegativeButtonOnClickListener);
}

Button buttonPositive = (Button) view.findViewById(R.id.promo_dialog_button_positive);
buttonPositive.setText(mButtonPositiveId);
Expand Down