Skip to content

Commit 83a3e58

Browse files
authored
Gutenberg Android X migration (#10020)
1 parent 3cd011d commit 83a3e58

File tree

7 files changed

+45
-12
lines changed

7 files changed

+45
-12
lines changed

WordPress/build.gradle

+4-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ android {
6262
}
6363

6464
// Gutenberg's dependency - react-native-video is using
65-
// Java API 1.8 so we need this when building from source
66-
if (rootProject.ext.buildGutenbergFromSource) {
67-
compileOptions {
68-
sourceCompatibility JavaVersion.VERSION_1_8
69-
targetCompatibility JavaVersion.VERSION_1_8
70-
}
65+
// Java API 1.8
66+
compileOptions {
67+
sourceCompatibility JavaVersion.VERSION_1_8
68+
targetCompatibility JavaVersion.VERSION_1_8
7169
}
7270

7371
flavorDimensions "buildType"

WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
5757
get() = bgDispatcher + job
5858
private var isStarted = false
5959
private var segmentId by Delegates.notNull<Long>()
60+
private var siteTitle: String? = null
6061

6162
private val _uiState: MutableLiveData<DomainsUiState> = MutableLiveData()
6263
val uiState: LiveData<DomainsUiState> = _uiState
@@ -92,6 +93,7 @@ class SiteCreationDomainsViewModel @Inject constructor(
9293
return
9394
}
9495
this.segmentId = segmentId
96+
this.siteTitle = siteTitle
9597
isStarted = true
9698
tracker.trackDomainsAccessed()
9799
// isNullOrBlank not smart-casting for some reason..
@@ -119,7 +121,12 @@ class SiteCreationDomainsViewModel @Inject constructor(
119121
}
120122

121123
fun updateQuery(query: String) {
122-
updateQueryInternal(UserQuery(query))
124+
val siteTitle: String? = this.siteTitle
125+
if (query.isBlank() && !siteTitle.isNullOrBlank()) {
126+
updateQueryInternal(TitleQuery(siteTitle))
127+
} else {
128+
updateQueryInternal(UserQuery(query))
129+
}
123130
}
124131

125132
private fun updateQueryInternal(query: DomainSuggestionsQuery?) {

WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt

+29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.wordpress.android.ui.sitecreation.domains
33
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
44
import androidx.lifecycle.Observer
55
import com.nhaarman.mockitokotlin2.firstValue
6+
import com.nhaarman.mockitokotlin2.lastValue
67
import com.nhaarman.mockitokotlin2.secondValue
78
import com.nhaarman.mockitokotlin2.thirdValue
89
import com.nhaarman.mockitokotlin2.times
@@ -193,6 +194,34 @@ class SiteCreationDomainsViewModelTest {
193194
)
194195
}
195196

197+
/**
198+
* Verifies the UI state after the user enters an empty query (presses clear button) with a non-empty site title
199+
* which results in multiple domain suggestions.
200+
*/
201+
@Test
202+
fun verifyClearQueryWithNonEmptyTitleUiStateAfterResponseWithMultipleResults() = testWithSuccessResponse {
203+
viewModel.start(MULTI_RESULT_DOMAIN_FETCH_QUERY.first, SEGMENT_ID)
204+
viewModel.updateQuery(MULTI_RESULT_DOMAIN_FETCH_QUERY.first)
205+
viewModel.updateQuery("")
206+
val captor = ArgumentCaptor.forClass(DomainsUiState::class.java)
207+
verify(uiStateObserver, times(6)).onChanged(captor.capture())
208+
verifyVisibleItemsContentUiState(captor.lastValue, false, 20)
209+
}
210+
211+
/**
212+
* Verifies the UI state after the user enters an empty query (presses clear button) with an empty site title
213+
* which results in initial UI state
214+
*/
215+
@Test
216+
fun verifyClearQueryWithEmptyTitleInitialState() = testWithSuccessResponse {
217+
viewModel.start(null, SEGMENT_ID)
218+
viewModel.updateQuery(MULTI_RESULT_DOMAIN_FETCH_QUERY.first)
219+
viewModel.updateQuery("")
220+
val captor = ArgumentCaptor.forClass(DomainsUiState::class.java)
221+
verify(uiStateObserver, times(4)).onChanged(captor.capture())
222+
verifyInitialContentUiState(captor.lastValue)
223+
}
224+
196225
/**
197226
* Verifies that help button is properly propagated.
198227
*/

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ allprojects {
4848

4949
configurations.all {
5050
resolutionStrategy {
51-
force 'org.webkit:android-jsc:r224109'
51+
force 'org.webkit:android-jsc:r241213'
5252
}
5353
}
5454

libs/editor/WordPressEditor/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildscript {
22

33
ext {
4-
aztecVersion = 'v1.3.27'
4+
aztecVersion = 'v1.3.28'
55
}
66

77
repositories {

libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import androidx.lifecycle.LiveData;
3333

3434
import com.android.volley.toolbox.ImageLoader;
35-
import com.facebook.react.bridge.ReadableArray;
3635

3736
import org.wordpress.android.util.AppLog;
3837
import org.wordpress.android.util.AppLog.T;
@@ -271,7 +270,7 @@ public void onQueryCurrentProgressForUploadingMedia() {
271270
},
272271
new OnEditorMountListener() {
273272
@Override
274-
public void onEditorDidMount(ReadableArray unsupportedBlocks) {
273+
public void onEditorDidMount(ArrayList<Object> unsupportedBlocks) {
275274
mEditorDidMount = true;
276275
mEditorFragmentListener.onEditorFragmentContentReady(unsupportedBlocks.size() > 0);
277276

libs/gutenberg-mobile

Submodule gutenberg-mobile updated 61 files

0 commit comments

Comments
 (0)