Skip to content

Commit

Permalink
Merge pull request #20304 from wordpress-mobile/issue/move_constants_…
Browse files Browse the repository at this point in the history
…to_a_kotlin_file

Moves: the constants from EditPostActivity to a new kotlin file
  • Loading branch information
zwarm authored Feb 27, 2024
2 parents f831640 + a8a3dbd commit 01a3506
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import org.wordpress.android.ui.plugins.PluginDetailActivity;
import org.wordpress.android.ui.plugins.PluginUtils;
import org.wordpress.android.ui.posts.EditPostActivity;
import org.wordpress.android.ui.posts.EditPostActivityConstants;
import org.wordpress.android.ui.posts.JetpackSecuritySettingsActivity;
import org.wordpress.android.ui.posts.PostListType;
import org.wordpress.android.ui.posts.PostUtils;
Expand Down Expand Up @@ -438,7 +439,7 @@ public static void openEditorForSiteInNewStack(Context context, @NonNull SiteMod

Intent editorIntent = new Intent(context, EditPostActivity.class);
editorIntent.putExtra(WordPress.SITE, site);
editorIntent.putExtra(EditPostActivity.EXTRA_IS_PAGE, false);
editorIntent.putExtra(EditPostActivityConstants.EXTRA_IS_PAGE, false);

taskStackBuilder.addNextIntent(mainActivityIntent);
taskStackBuilder.addNextIntent(editorIntent);
Expand All @@ -452,8 +453,8 @@ public static void openEditorForPostInNewStack(Context context, @NonNull SiteMod

Intent editorIntent = new Intent(context, EditPostActivity.class);
editorIntent.putExtra(WordPress.SITE, site);
editorIntent.putExtra(EditPostActivity.EXTRA_POST_LOCAL_ID, localPostId);
editorIntent.putExtra(EditPostActivity.EXTRA_IS_PAGE, false);
editorIntent.putExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, localPostId);
editorIntent.putExtra(EditPostActivityConstants.EXTRA_IS_PAGE, false);

taskStackBuilder.addNextIntent(mainActivityIntent);
taskStackBuilder.addNextIntent(editorIntent);
Expand Down Expand Up @@ -493,11 +494,11 @@ public static void openEditorForReblog(
);

Intent editorIntent = new Intent(activity, EditPostActivity.class);
editorIntent.putExtra(EditPostActivity.EXTRA_REBLOG_POST_TITLE, post.getTitle());
editorIntent.putExtra(EditPostActivity.EXTRA_REBLOG_POST_QUOTE, post.getExcerpt());
editorIntent.putExtra(EditPostActivity.EXTRA_REBLOG_POST_IMAGE, post.getFeaturedImage());
editorIntent.putExtra(EditPostActivity.EXTRA_REBLOG_POST_CITATION, post.getUrl());
editorIntent.setAction(EditPostActivity.ACTION_REBLOG);
editorIntent.putExtra(EditPostActivityConstants.EXTRA_REBLOG_POST_TITLE, post.getTitle());
editorIntent.putExtra(EditPostActivityConstants.EXTRA_REBLOG_POST_QUOTE, post.getExcerpt());
editorIntent.putExtra(EditPostActivityConstants.EXTRA_REBLOG_POST_IMAGE, post.getFeaturedImage());
editorIntent.putExtra(EditPostActivityConstants.EXTRA_REBLOG_POST_CITATION, post.getUrl());
editorIntent.setAction(EditPostActivityConstants.ACTION_REBLOG);

addNewPostForResult(editorIntent, activity, site, false, reblogSource, -1, null);
}
Expand Down Expand Up @@ -1019,11 +1020,11 @@ public static void addNewPostForResult(
}

intent.putExtra(WordPress.SITE, site);
intent.putExtra(EditPostActivity.EXTRA_IS_PAGE, false);
intent.putExtra(EditPostActivity.EXTRA_IS_PROMO, isPromo);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_PAGE, false);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_PROMO, isPromo);
intent.putExtra(AnalyticsUtils.EXTRA_CREATION_SOURCE_DETAIL, source);
intent.putExtra(EditPostActivity.EXTRA_PROMPT_ID, promptId);
intent.putExtra(EditPostActivity.EXTRA_ENTRY_POINT, entryPoint);
intent.putExtra(EditPostActivityConstants.EXTRA_PROMPT_ID, promptId);
intent.putExtra(EditPostActivityConstants.EXTRA_ENTRY_POINT, entryPoint);
activity.startActivityForResult(intent, RequestCodes.EDIT_POST);
}

Expand Down Expand Up @@ -1147,8 +1148,8 @@ public static void editPostOrPageForResult(Intent intent, Activity activity, Sit
// PostModel objects can be quite large, since content field is not size restricted,
// in order to avoid issues like TransactionTooLargeException it's better to pass the id of the post.
// However, we still want to keep passing the SiteModel to avoid confusion around local & remote ids.
intent.putExtra(EditPostActivity.EXTRA_POST_LOCAL_ID, postLocalId);
intent.putExtra(EditPostActivity.EXTRA_LOAD_AUTO_SAVE_REVISION, loadAutoSaveRevision);
intent.putExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, postLocalId);
intent.putExtra(EditPostActivityConstants.EXTRA_LOAD_AUTO_SAVE_REVISION, loadAutoSaveRevision);

activity.startActivityForResult(intent, RequestCodes.EDIT_POST);
}
Expand All @@ -1167,16 +1168,16 @@ public static void editPageForResult(Intent intent, @NonNull Fragment fragment,
public static void editLandingPageForResult(@NonNull Fragment fragment, @NonNull SiteModel site, int homeLocalId,
boolean isNewSite) {
Intent intent = new Intent(fragment.getContext(), EditPostActivity.class);
intent.putExtra(EditPostActivity.EXTRA_IS_LANDING_EDITOR, true);
intent.putExtra(EditPostActivity.EXTRA_IS_LANDING_EDITOR_OPENED_FOR_NEW_SITE, isNewSite);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_LANDING_EDITOR, true);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_LANDING_EDITOR_OPENED_FOR_NEW_SITE, isNewSite);
editPageForResult(intent, fragment, site, homeLocalId, false, RequestCodes.EDIT_LANDING_PAGE);
}

public static void editPageForResult(Intent intent, @NonNull Fragment fragment, @NonNull SiteModel site,
int pageLocalId, boolean loadAutoSaveRevision, int requestCode) {
intent.putExtra(WordPress.SITE, site);
intent.putExtra(EditPostActivity.EXTRA_POST_LOCAL_ID, pageLocalId);
intent.putExtra(EditPostActivity.EXTRA_LOAD_AUTO_SAVE_REVISION, loadAutoSaveRevision);
intent.putExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, pageLocalId);
intent.putExtra(EditPostActivityConstants.EXTRA_LOAD_AUTO_SAVE_REVISION, loadAutoSaveRevision);
fragment.startActivityForResult(intent, requestCode);
}

Expand All @@ -1190,11 +1191,11 @@ public static void addNewPageForResult(
) {
Intent intent = new Intent(activity, EditPostActivity.class);
intent.putExtra(WordPress.SITE, site);
intent.putExtra(EditPostActivity.EXTRA_IS_PAGE, true);
intent.putExtra(EditPostActivity.EXTRA_IS_PROMO, false);
intent.putExtra(EditPostActivity.EXTRA_PAGE_TITLE, title);
intent.putExtra(EditPostActivity.EXTRA_PAGE_CONTENT, content);
intent.putExtra(EditPostActivity.EXTRA_PAGE_TEMPLATE, template);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_PAGE, true);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_PROMO, false);
intent.putExtra(EditPostActivityConstants.EXTRA_PAGE_TITLE, title);
intent.putExtra(EditPostActivityConstants.EXTRA_PAGE_CONTENT, content);
intent.putExtra(EditPostActivityConstants.EXTRA_PAGE_TEMPLATE, template);
intent.putExtra(AnalyticsUtils.EXTRA_CREATION_SOURCE_DETAIL, source);
activity.startActivityForResult(intent, RequestCodes.EDIT_POST);
}
Expand All @@ -1208,11 +1209,11 @@ public static void addNewPageForResult(
@NonNull PagePostCreationSourcesDetail source) {
Intent intent = new Intent(fragment.getContext(), EditPostActivity.class);
intent.putExtra(WordPress.SITE, site);
intent.putExtra(EditPostActivity.EXTRA_IS_PAGE, true);
intent.putExtra(EditPostActivity.EXTRA_IS_PROMO, false);
intent.putExtra(EditPostActivity.EXTRA_PAGE_TITLE, title);
intent.putExtra(EditPostActivity.EXTRA_PAGE_CONTENT, content);
intent.putExtra(EditPostActivity.EXTRA_PAGE_TEMPLATE, template);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_PAGE, true);
intent.putExtra(EditPostActivityConstants.EXTRA_IS_PROMO, false);
intent.putExtra(EditPostActivityConstants.EXTRA_PAGE_TITLE, title);
intent.putExtra(EditPostActivityConstants.EXTRA_PAGE_CONTENT, content);
intent.putExtra(EditPostActivityConstants.EXTRA_PAGE_TEMPLATE, template);
intent.putExtra(AnalyticsUtils.EXTRA_CREATION_SOURCE_DETAIL, source);
fragment.startActivityForResult(intent, RequestCodes.EDIT_POST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.fluxc.tools.FluxCImageLoader;
import org.wordpress.android.ui.posts.EditPostActivity;
import org.wordpress.android.ui.posts.EditPostActivityConstants;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.ToastUtils;

Expand Down Expand Up @@ -142,8 +143,8 @@ public void onClick(DialogInterface dialog, int which) {
shortcutIntent.setAction(Intent.ACTION_MAIN);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.putExtra(EditPostActivity.EXTRA_QUICKPRESS_BLOG_ID, siteIds[position]);
shortcutIntent.putExtra(EditPostActivity.EXTRA_IS_QUICKPRESS, true);
shortcutIntent.putExtra(EditPostActivityConstants.EXTRA_QUICKPRESS_BLOG_ID, siteIds[position]);
shortcutIntent.putExtra(EditPostActivityConstants.EXTRA_IS_QUICKPRESS, true);

String shortcutName = quickPressShortcutName.getText().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogNegativeClickInterface;
import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogPositiveClickInterface;
import org.wordpress.android.ui.posts.EditPostActivity;
import org.wordpress.android.ui.posts.EditPostActivityConstants;
import org.wordpress.android.ui.posts.PostUtils.EntryPoint;
import org.wordpress.android.ui.posts.QuickStartPromptDialogFragment.QuickStartPromptClickInterface;
import org.wordpress.android.ui.prefs.AppPrefs;
Expand Down Expand Up @@ -1353,13 +1354,13 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_OK || data == null || isFinishing()) {
return;
}
int localId = data.getIntExtra(EditPostActivity.EXTRA_POST_LOCAL_ID, 0);
int localId = data.getIntExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, 0);
final SiteModel site = (SiteModel) data.getSerializableExtra(WordPress.SITE);
final PostModel post = mPostStore.getPostByLocalPostId(localId);

if (EditPostActivity.checkToRestart(data)) {
ActivityLauncher.editPostOrPageForResult(data, WPMainActivity.this, site,
data.getIntExtra(EditPostActivity.EXTRA_POST_LOCAL_ID, 0));
data.getIntExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, 0));

// a restart will happen so, no need to continue here
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import org.wordpress.android.ui.pages.SnackbarMessageHolder
import org.wordpress.android.ui.photopicker.MediaPickerConstants
import org.wordpress.android.ui.photopicker.MediaPickerLauncher
import org.wordpress.android.ui.posts.BasicDialogViewModel
import org.wordpress.android.ui.posts.EditPostActivity
import org.wordpress.android.ui.posts.EditPostActivityConstants
import org.wordpress.android.ui.posts.PostListType
import org.wordpress.android.ui.posts.PostUtils
import org.wordpress.android.ui.posts.QuickStartPromptDialogFragment
Expand Down Expand Up @@ -297,7 +297,7 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment),
viewModel.checkAndStartQuickStart(
data.getBooleanExtra(SitePickerActivity.KEY_SITE_TITLE_TASK_COMPLETED, false),
isNewSite = data.getBooleanExtra(
EditPostActivity.EXTRA_IS_LANDING_EDITOR_OPENED_FOR_NEW_SITE, false
EditPostActivityConstants.EXTRA_IS_LANDING_EDITOR_OPENED_FOR_NEW_SITE, false
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper
import org.wordpress.android.ui.mlp.ModalLayoutPickerFragment
import org.wordpress.android.ui.mlp.ModalLayoutPickerFragment.Companion.MODAL_LAYOUT_PICKER_TAG
import org.wordpress.android.ui.posts.EditPostActivity
import org.wordpress.android.ui.posts.EditPostActivityConstants
import org.wordpress.android.ui.posts.PostListAction.PreviewPost
import org.wordpress.android.ui.posts.PreviewStateHelper
import org.wordpress.android.ui.posts.ProgressDialogHelper
Expand Down Expand Up @@ -176,15 +177,15 @@ class PagesFragment : Fragment(R.layout.pages_fragment), ScrollableViewInitializ
data,
this@PagesFragment,
viewModel.site,
data.getIntExtra(EditPostActivity.EXTRA_POST_LOCAL_ID, 0),
data.getIntExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, 0),
false
)

// a restart will happen so, no need to continue here
return
}
// we need to work with local ids, since local drafts don't have remote ids
val localPageId = data.getIntExtra(EditPostActivity.EXTRA_POST_LOCAL_ID, -1)
val localPageId = data.getIntExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, -1)
if (localPageId != -1) {
viewModel.onPageEditFinished(localPageId, data)
}
Expand Down
Loading

0 comments on commit 01a3506

Please sign in to comment.