Skip to content

Commit

Permalink
Merge pull request #10126 from wordpress-mobile/release/12.7
Browse files Browse the repository at this point in the history
Merge Release/12.7 into Master
  • Loading branch information
loremattei authored Jul 2, 2019
2 parents da7d077 + 3cd97a2 commit f6262da
Show file tree
Hide file tree
Showing 54 changed files with 638 additions and 292 deletions.
4 changes: 2 additions & 2 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ android {

defaultConfig {
applicationId "org.wordpress.android"
versionName "12.7-rc-1"
versionCode 738
versionName "12.7"
versionCode 744
minSdkVersion 21
targetSdkVersion 26

Expand Down
1 change: 1 addition & 0 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
<activity
android:name=".ui.themes.ThemeWebActivity"
android:label="@string/selected_theme"
android:theme="@style/Calypso.NoActionBar"
android:parentActivityName=".ui.themes.ThemeBrowserActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.wordpress.android.ui.activitylog.list.ActivityLogListActivity;
import org.wordpress.android.ui.comments.CommentsActivity;
import org.wordpress.android.ui.domains.DomainRegistrationActivity;
import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose;
import org.wordpress.android.ui.giphy.GiphyPickerActivity;
import org.wordpress.android.ui.history.HistoryDetailActivity;
import org.wordpress.android.ui.history.HistoryDetailContainerFragment;
Expand Down Expand Up @@ -414,6 +415,14 @@ public static void viewDomainRegistrationActivity(Activity activity, SiteModel s
activity.startActivity(intent);
}

public static void viewDomainRegistrationActivityForResult(Activity activity, SiteModel site,
DomainRegistrationPurpose purpose) {
Intent intent = new Intent(activity, DomainRegistrationActivity.class);
intent.putExtra(WordPress.SITE, site);
intent.putExtra(DomainRegistrationActivity.DOMAIN_REGISTRATION_PURPOSE_KEY, purpose);
activity.startActivityForResult(intent, RequestCodes.DOMAIN_REGISTRATION);
}

public static void viewActivityLogList(Activity activity, SiteModel site) {
if (site == null) {
ToastUtils.showToast(activity, R.string.blog_not_found, ToastUtils.Duration.SHORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ public class RequestCodes {
public static final int QUICK_START_REMINDER_NOTIFICATION = 4001;

public static final int GIPHY_PICKER = 3200;

// Domain Registration
public static final int DOMAIN_REGISTRATION = 5000;
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void onCreate(Bundle savedInstanceState) {
}

@Override
public void configureView() {
public final void configureView() {
setContentView(R.layout.wpwebview_activity);

mActionableEmptyView = findViewById(R.id.actionable_empty_view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import kotlinx.android.parcel.Parcelize

@Parcelize
data class DomainProductDetails(
val productId: String,
val productId: Int,
val domainName: String
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
package org.wordpress.android.ui.domains

import android.app.Activity
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.toolbar.*
import org.wordpress.android.R
import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose.CTA_DOMAIN_CREDIT_REDEMPTION

class DomainRegistrationActivity : AppCompatActivity(), DomainRegistrationStepsListener {
enum class DomainRegistrationPurpose {
AUTOMATED_TRANSFER,
CTA_DOMAIN_CREDIT_REDEMPTION
}

companion object {
const val DOMAIN_REGISTRATION_PURPOSE_KEY = "DOMAIN_REGISTRATION_PURPOSE_KEY"
}

private var domainRegistrationPurpose: DomainRegistrationPurpose? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.activity_domain_suggestions_activity)

domainRegistrationPurpose = intent.getSerializableExtra(DOMAIN_REGISTRATION_PURPOSE_KEY)
as? DomainRegistrationPurpose

setSupportActionBar(toolbar)
supportActionBar?.let {
it.setHomeButtonEnabled(true)
Expand Down Expand Up @@ -50,15 +66,20 @@ class DomainRegistrationActivity : AppCompatActivity(), DomainRegistrationStepsL
}

override fun onDomainRegistered(domainName: String) {
supportFragmentManager.beginTransaction()
.setCustomAnimations(
R.anim.activity_slide_in_from_right, R.anim.activity_slide_out_to_left,
R.anim.activity_slide_in_from_left, R.anim.activity_slide_out_to_right
)
.replace(
R.id.fragment_container,
DomainRegistrationResultFragment.newInstance(domainName)
)
.commit()
if (domainRegistrationPurpose == null || domainRegistrationPurpose == CTA_DOMAIN_CREDIT_REDEMPTION) {
supportFragmentManager.beginTransaction()
.setCustomAnimations(
R.anim.activity_slide_in_from_right, R.anim.activity_slide_out_to_left,
R.anim.activity_slide_in_from_left, R.anim.activity_slide_out_to_right
)
.replace(
R.id.fragment_container,
DomainRegistrationResultFragment.newInstance(domainName)
)
.commit()
} else {
setResult(Activity.RESULT_OK)
finish()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.wordpress.android.ui.plugins;

import android.animation.ObjectAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
Expand Down Expand Up @@ -41,6 +43,7 @@

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.jetbrains.annotations.NotNull;
import org.wordpress.android.BuildConfig;
import org.wordpress.android.R;
import org.wordpress.android.WordPress;
Expand Down Expand Up @@ -71,6 +74,10 @@
import org.wordpress.android.fluxc.store.SiteStore.OnPlansFetched;
import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged;
import org.wordpress.android.ui.ActivityLauncher;
import org.wordpress.android.ui.RequestCodes;
import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose;
import org.wordpress.android.ui.posts.BasicFragmentDialog;
import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogPositiveClickInterface;
import org.wordpress.android.util.AniUtils;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
Expand Down Expand Up @@ -103,7 +110,8 @@
import javax.inject.Inject;


public class PluginDetailActivity extends AppCompatActivity implements OnDomainRegistrationRequestedListener {
public class PluginDetailActivity extends AppCompatActivity implements OnDomainRegistrationRequestedListener,
BasicDialogPositiveClickInterface {
public static final String KEY_PLUGIN_SLUG = "KEY_PLUGIN_SLUG";
private static final String KEY_IS_CONFIGURING_PLUGIN = "KEY_IS_CONFIGURING_PLUGIN";
private static final String KEY_IS_INSTALLING_PLUGIN = "KEY_IS_INSTALLING_PLUGIN";
Expand All @@ -119,6 +127,12 @@ public class PluginDetailActivity extends AppCompatActivity implements OnDomainR
= "KEY_IS_SHOWING_AUTOMATED_TRANSFER_PROGRESS";
private static final String KEY_IS_SHOWING_DOMAIN_CREDIT_CHECK_PROGRESS
= "KEY_IS_SHOWING_DOMAIN_CREDIT_CHECK_PROGRESS";
private static final String KEY_PLUGIN_RECHECKED_TIMES = "KEY_PLUGIN_RECHECKED_TIMES";
private static final String TAG_ERROR_DIALOG = "ERROR_DIALOG";

private static final int MAX_PLUGIN_CHECK_TRIES = 10;
private static final int DEFAULT_RETRY_DELAY_MS = 3000;
private static final int PLUGIN_RETRY_DELAY_MS = 10000;

private SiteModel mSite;
private String mSlug;
Expand Down Expand Up @@ -162,6 +176,8 @@ public class PluginDetailActivity extends AppCompatActivity implements OnDomainR
protected boolean mIsShowingInstallFirstPluginConfirmationDialog;
protected boolean mIsShowingAutomatedTransferProgress;

private int mPluginReCheckTimer = 0;

// These flags reflects the UI state
protected boolean mIsActive;
protected boolean mIsAutoUpdateEnabled;
Expand Down Expand Up @@ -226,6 +242,7 @@ public void onCreate(Bundle savedInstanceState) {
.getBoolean(KEY_IS_SHOWING_AUTOMATED_TRANSFER_PROGRESS);
isShowingDomainCreditCheckProgress = savedInstanceState
.getBoolean(KEY_IS_SHOWING_DOMAIN_CREDIT_CHECK_PROGRESS);
mPluginReCheckTimer = savedInstanceState.getInt(KEY_PLUGIN_RECHECKED_TIMES, 0);
}

setContentView(R.layout.plugin_detail_activity);
Expand Down Expand Up @@ -310,7 +327,24 @@ public void onPlansFetched(OnPlansFetched event) {

@Override
public void onDomainRegistrationRequested() {
ActivityLauncher.viewDomainRegistrationActivity(this, mSite);
ActivityLauncher.viewDomainRegistrationActivityForResult(this, mSite,
DomainRegistrationPurpose.AUTOMATED_TRANSFER);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RequestCodes.DOMAIN_REGISTRATION) {
if (resultCode != Activity.RESULT_OK || isFinishing()) {
return;
}
confirmInstallPluginForAutomatedTransfer();
}
}

@Override
public void onPositiveClicked(@NotNull String instanceTag) {
// do nothing
}

public static class DomainRegistrationPromptDialog extends DialogFragment {
Expand Down Expand Up @@ -412,6 +446,7 @@ public void onSaveInstanceState(Bundle outState) {
outState.putBoolean(KEY_IS_SHOWING_AUTOMATED_TRANSFER_PROGRESS, mIsShowingAutomatedTransferProgress);
outState.putBoolean(KEY_IS_SHOWING_DOMAIN_CREDIT_CHECK_PROGRESS,
mCheckingDomainCreditsProgressDialog != null && mCheckingDomainCreditsProgressDialog.isShowing());
outState.putInt(KEY_PLUGIN_RECHECKED_TIMES, mPluginReCheckTimer);
}

// UI Helpers
Expand Down Expand Up @@ -1353,6 +1388,7 @@ private void automatedTransferCompleted() {
AnalyticsUtils.trackWithSiteDetails(Stat.AUTOMATED_TRANSFER_FLOW_COMPLETE, mSite);
cancelAutomatedTransferDialog();
refreshPluginFromStore();
dispatchConfigurePluginAction(true);
refreshViews();
showSuccessfulInstallSnackbar();
invalidateOptionsMenu();
Expand All @@ -1364,7 +1400,10 @@ private void automatedTransferCompleted() {
*/
private void handleAutomatedTransferFailed(String errorMessage) {
cancelAutomatedTransferDialog();
ToastUtils.showToast(this, errorMessage, Duration.LONG);
BasicFragmentDialog errorDialog = new BasicFragmentDialog();
errorDialog.initialize(TAG_ERROR_DIALOG, null, errorMessage,
getString(R.string.dialog_button_ok), null, null);
errorDialog.show(getSupportFragmentManager(), TAG_ERROR_DIALOG);
}

/**
Expand Down Expand Up @@ -1483,7 +1522,7 @@ public void run() {
// Wait 3 seconds before checking the status again
mDispatcher.dispatch(SiteActionBuilder.newCheckAutomatedTransferStatusAction(mSite));
}
}, 3000);
}, DEFAULT_RETRY_DELAY_MS);
}
}
}
Expand Down Expand Up @@ -1514,10 +1553,9 @@ public void onSiteChanged(OnSiteChanged event) {
// We try to fetch the site after Automated Transfer is completed so that we can fetch its plugins. If
// we are still showing the AT progress and the site is AT site, we can continue with plugins fetch
if (mSite.isAutomatedTransfer()) {
AppLog.v(T.PLUGINS, "Site is successfully fetched after Automated Transfer, fetching the site plugins "
+ "to complete the process...");
mDispatcher.dispatch(PluginActionBuilder.newFetchPluginDirectoryAction(new PluginStore
.FetchPluginDirectoryPayload(PluginDirectoryType.SITE, mSite, false)));
AppLog.v(T.PLUGINS, "Site is successfully fetched after Automated Transfer, fetching"
+ " the site plugins to complete the process...");
fetchPluginDirectory(0);
} else {
// Either an error occurred while fetching the site or Automated Transfer is not yet reflected in the
// API response. We need to keep fetching the site until we get the updated site. Otherwise, any changes
Expand All @@ -1532,7 +1570,7 @@ public void run() {
// Wait 3 seconds before fetching the site again
mDispatcher.dispatch(SiteActionBuilder.newFetchSiteAction(mSite));
}
}, 3000);
}, DEFAULT_RETRY_DELAY_MS);
}
}
}
Expand All @@ -1551,26 +1589,38 @@ public void onPluginDirectoryFetched(OnPluginDirectoryFetched event) {
if (isFinishing()) {
return;
}

refreshPluginFromStore();

if (event.isError()) {
if (mIsShowingAutomatedTransferProgress) {
AppLog.e(T.PLUGINS, "Fetching the plugin directory after Automated Transfer has failed with error type"
+ event.error.type + " and message: " + event.error.message);
// Although unlikely, fetching the plugins after a successful Automated Transfer can result in an error.
// This should hopefully be an edge case and fetching the plugins again should
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
AppLog.v(T.PLUGINS, "Fetching the site plugins again after Automated Transfer since the"
+ " changes are not yet reflected");
// Wait 3 seconds before fetching the site plugins again
mDispatcher.dispatch(PluginActionBuilder.newFetchPluginDirectoryAction(new PluginStore
.FetchPluginDirectoryPayload(PluginDirectoryType.SITE, mSite, false)));
}
}, 3000);
AppLog.v(T.PLUGINS, "Fetching the site plugins again after Automated Transfer since the"
+ " changes are not yet reflected");
fetchPluginDirectory(PLUGIN_RETRY_DELAY_MS);
}
// We are safe to ignore the errors for this event unless it's for Automated Transfer since that's the only
// one triggered in this page and only one we care about.
return;
} else if (!mPlugin.isInstalled()) {
// it sometimes take a bit of time for plugin to get marked as installed, especially when
// Automated Transfer is performed right after domain registration
if (mIsShowingAutomatedTransferProgress) {
if (mPluginReCheckTimer < MAX_PLUGIN_CHECK_TRIES) {
AppLog.v(T.PLUGINS, "Targeted plugin is not marked as installed after Automated Transfer."
+ " Fetching the site plugins to reflect the changes.");
fetchPluginDirectory(PLUGIN_RETRY_DELAY_MS);
mPluginReCheckTimer++;
return;
} else {
// if plugin is still not marked as installed, we ask user to check back later, and proceed to
// finish Automated Transfer
ToastUtils.showToast(this, R.string.plugin_fetching_error_after_at, Duration.LONG);
}
}
}
if (event.type == PluginDirectoryType.SITE && mIsShowingAutomatedTransferProgress) {
// After Automated Transfer flow is completed, we fetch the site and then it's plugins. The only way site's
Expand All @@ -1580,11 +1630,20 @@ public void run() {
} else {
// Although it's unlikely that a directory might be fetched while we are in the plugin detail page, we
// should be safe to refresh the plugin and the view in case the plugin we are showing has changed
refreshPluginFromStore();
refreshViews();
}
}

private void fetchPluginDirectory(int delay) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mDispatcher.dispatch(PluginActionBuilder.newFetchPluginDirectoryAction(new PluginStore
.FetchPluginDirectoryPayload(PluginDirectoryType.SITE, mSite, false)));
}
}, delay);
}

private String getEligibilityErrorMessage(String errorCode) {
int errorMessageRes;
switch (errorCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.LocaleManager;
import org.wordpress.android.util.NetworkUtils;
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.util.analytics.AnalyticsUtils;

Expand Down Expand Up @@ -375,10 +374,6 @@ public void onClick(DialogInterface dialog, int which) {
}

private void startWebActivity(String themeId, ThemeWebActivity.ThemeWebActivityType type) {
if (!NetworkUtils.checkConnection(this)) {
return;
}

ThemeModel theme =
TextUtils.isEmpty(themeId) ? null : mThemeStore.getWpComThemeByThemeId(themeId.replace("-wpcom", ""));
if (theme == null) {
Expand Down
Loading

0 comments on commit f6262da

Please sign in to comment.