Skip to content

Commit 0f02cd3

Browse files
committed
Make all boolean parameters nullable to avoid unintended defaults
The trunk editPostOrPageForResult methods never set boolean extras like EXTRA_IS_PAGE, EXTRA_IS_PROMO, or EXTRA_LOAD_AUTO_SAVE_REVISION unless explicitly required. Making all boolean parameters nullable ensures they're only set when explicitly provided, matching trunk behavior exactly. Changes: - Make all boolean fields nullable in EditorLauncherParams and Builder - Update EditorLauncher to only set extras when parameters are non-null - Remove unnecessary loadAutoSaveRevision(false) from first editPostOrPageForResult - Preserves explicit boolean settings in other methods (pages, promos, etc.)
1 parent 29c3d84 commit 0f02cd3

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ public static void editPostOrPageForResult(Activity activity, @NonNull SiteModel
10491049

10501050
EditorLauncherParams params = new EditorLauncherParams.Builder(site)
10511051
.postLocalId(post.getId())
1052-
.loadAutoSaveRevision(false)
10531052
.build();
10541053

10551054
Intent editorIntent = EditorLauncher.getInstance().createEditorIntent(activity, params);

WordPress/src/main/java/org/wordpress/android/ui/posts/EditorLauncher.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,20 @@ class EditorLauncher @Inject constructor(
9191

9292
private fun Intent.addBasicExtras(params: EditorLauncherParams) {
9393
putExtra(WordPress.SITE, params.site)
94-
putExtra(EditPostActivityConstants.EXTRA_IS_PAGE, params.isPage)
95-
putExtra(EditPostActivityConstants.EXTRA_IS_PROMO, params.isPromo)
94+
params.isPage?.let { putExtra(EditPostActivityConstants.EXTRA_IS_PAGE, it) }
95+
params.isPromo?.let { putExtra(EditPostActivityConstants.EXTRA_IS_PROMO, it) }
9696
putExtra(EXTRA_LAUNCHED_VIA_EDITOR_LAUNCHER, true)
9797
}
9898

9999
private fun Intent.addPostExtras(params: EditorLauncherParams) {
100100
params.postLocalId?.let { putExtra(EditPostActivityConstants.EXTRA_POST_LOCAL_ID, it) }
101101
params.postRemoteId?.let { putExtra(EditPostActivityConstants.EXTRA_POST_REMOTE_ID, it) }
102-
putExtra(EditPostActivityConstants.EXTRA_LOAD_AUTO_SAVE_REVISION, params.loadAutoSaveRevision)
103-
putExtra(EditPostActivityConstants.EXTRA_IS_QUICKPRESS, params.isQuickPress)
104-
putExtra(EditPostActivityConstants.EXTRA_IS_LANDING_EDITOR, params.isLandingEditor)
105-
putExtra(
106-
EditPostActivityConstants.EXTRA_IS_LANDING_EDITOR_OPENED_FOR_NEW_SITE,
107-
params.isLandingEditorOpenedForNewSite
108-
)
102+
params.loadAutoSaveRevision?.let { putExtra(EditPostActivityConstants.EXTRA_LOAD_AUTO_SAVE_REVISION, it) }
103+
params.isQuickPress?.let { putExtra(EditPostActivityConstants.EXTRA_IS_QUICKPRESS, it) }
104+
params.isLandingEditor?.let { putExtra(EditPostActivityConstants.EXTRA_IS_LANDING_EDITOR, it) }
105+
params.isLandingEditorOpenedForNewSite?.let {
106+
putExtra(EditPostActivityConstants.EXTRA_IS_LANDING_EDITOR_OPENED_FOR_NEW_SITE, it)
107+
}
109108
}
110109

111110
private fun Intent.addReblogExtras(params: EditorLauncherParams) {

WordPress/src/main/java/org/wordpress/android/ui/posts/EditorLauncherParams.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import org.wordpress.android.ui.posts.PostUtils.EntryPoint
1515
*/
1616
data class EditorLauncherParams(
1717
val site: SiteModel,
18-
val isPage: Boolean = false,
19-
val isPromo: Boolean = false,
18+
val isPage: Boolean? = null,
19+
val isPromo: Boolean? = null,
2020
val postLocalId: Int? = null,
2121
val postRemoteId: Long? = null,
22-
val loadAutoSaveRevision: Boolean = false,
23-
val isQuickPress: Boolean = false,
24-
val isLandingEditor: Boolean = false,
25-
val isLandingEditorOpenedForNewSite: Boolean = false,
22+
val loadAutoSaveRevision: Boolean? = null,
23+
val isQuickPress: Boolean? = null,
24+
val isLandingEditor: Boolean? = null,
25+
val isLandingEditorOpenedForNewSite: Boolean? = null,
2626
val reblogPostTitle: String? = null,
2727
val reblogPostQuote: String? = null,
2828
val reblogPostImage: String? = null,
@@ -41,14 +41,14 @@ data class EditorLauncherParams(
4141
* Java-friendly builder pattern for EditorLauncherParams.
4242
*/
4343
class Builder(private val site: SiteModel) {
44-
private var isPage: Boolean = false
45-
private var isPromo: Boolean = false
44+
private var isPage: Boolean? = null
45+
private var isPromo: Boolean? = null
4646
private var postLocalId: Int? = null
4747
private var postRemoteId: Long? = null
48-
private var loadAutoSaveRevision: Boolean = false
49-
private var isQuickPress: Boolean = false
50-
private var isLandingEditor: Boolean = false
51-
private var isLandingEditorOpenedForNewSite: Boolean = false
48+
private var loadAutoSaveRevision: Boolean? = null
49+
private var isQuickPress: Boolean? = null
50+
private var isLandingEditor: Boolean? = null
51+
private var isLandingEditorOpenedForNewSite: Boolean? = null
5252
private var reblogPostTitle: String? = null
5353
private var reblogPostQuote: String? = null
5454
private var reblogPostImage: String? = null
@@ -63,17 +63,17 @@ data class EditorLauncherParams(
6363
private var promptId: Int? = null
6464
private var entryPoint: EntryPoint? = null
6565

66-
fun isPage(isPage: Boolean) = apply { this.isPage = isPage }
67-
fun isPromo(isPromo: Boolean) = apply { this.isPromo = isPromo }
66+
fun isPage(isPage: Boolean?) = apply { this.isPage = isPage }
67+
fun isPromo(isPromo: Boolean?) = apply { this.isPromo = isPromo }
6868
fun postLocalId(postLocalId: Int?) = apply { this.postLocalId = postLocalId }
6969
fun postRemoteId(postRemoteId: Long?) = apply { this.postRemoteId = postRemoteId }
70-
fun loadAutoSaveRevision(loadAutoSaveRevision: Boolean) = apply {
70+
fun loadAutoSaveRevision(loadAutoSaveRevision: Boolean?) = apply {
7171
this.loadAutoSaveRevision = loadAutoSaveRevision
7272
}
7373

74-
fun isQuickPress(isQuickPress: Boolean) = apply { this.isQuickPress = isQuickPress }
75-
fun isLandingEditor(isLandingEditor: Boolean) = apply { this.isLandingEditor = isLandingEditor }
76-
fun isLandingEditorOpenedForNewSite(isLandingEditorOpenedForNewSite: Boolean) = apply {
74+
fun isQuickPress(isQuickPress: Boolean?) = apply { this.isQuickPress = isQuickPress }
75+
fun isLandingEditor(isLandingEditor: Boolean?) = apply { this.isLandingEditor = isLandingEditor }
76+
fun isLandingEditorOpenedForNewSite(isLandingEditorOpenedForNewSite: Boolean?) = apply {
7777
this.isLandingEditorOpenedForNewSite = isLandingEditorOpenedForNewSite
7878
}
7979

0 commit comments

Comments
 (0)