Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
335a430
Remove thumbnail mode selector from design picker
mkevins Apr 26, 2022
4f37a1c
Rename theme chooser title
mkevins Apr 27, 2022
b42d352
Remove subtitle text from theme chooser heading
mkevins Apr 27, 2022
7d11be3
Move lambdas outsite of parentheses
mkevins Apr 27, 2022
f16160f
Remove bottom toolbar from theme chooser screen
mkevins Apr 27, 2022
d1bc940
Add TODOS for loose ends from removed UI
mkevins Apr 27, 2022
d3c84c4
Fix lint issue
mkevins Apr 27, 2022
a69e2e4
Merge branch 'feature/site-design-revamp--remove-thumbnail-mode-selec…
mkevins Apr 27, 2022
faf4c03
Fix lint issue
mkevins Apr 27, 2022
48df301
Remove string resource hpp_subtitle that becomes unused
ovitrif Apr 27, 2022
1d8ef0e
Merge pull request #16419 from wordpress-mobile/pr/16414-remove-unuse…
mkevins Apr 28, 2022
522e2ec
Use mobile thumbnails in theme picker screen
mkevins Apr 28, 2022
ed4f540
Reword the test cases to reflect that thumbnails are not changed
mkevins Apr 28, 2022
6104d45
Merge branch 'feature/site-design-revamp--remove-thumbnail-mode-selec…
mkevins Apr 28, 2022
0079b9e
Remove thumbnail preview mode tracking in theme picker
mkevins Apr 28, 2022
6ddbf18
Merge pull request #16415 from wordpress-mobile/feature/site-design-r…
ovitrif Apr 28, 2022
be51e24
Remove unusd resource hpp_button_max_width
ovitrif Apr 28, 2022
7dbe9ed
Merge pull request #16414 from wordpress-mobile/feature/site-design-r…
ovitrif Apr 28, 2022
24ee21f
Hide the category pills recyclerview and skeleton view
ovitrif Apr 27, 2022
9f44324
Set text alignment of the big title to the left of the screen
ovitrif Apr 27, 2022
69b4968
Add horizontal padding to the big title to align it with the preview …
ovitrif Apr 27, 2022
92fcbc5
Align collapsed title text to left of Site Theme screen
ovitrif May 2, 2022
02bccd2
Merge pull request #16428 from wordpress-mobile/feature/site-design-r…
ovitrif May 3, 2022
05518bd
Merge branch 'trunk' into feature/site-design-revamp
ovitrif May 3, 2022
ae4b50f
Merge branch 'trunk' into feature/site-design-revamp
ovitrif May 3, 2022
3a3c9d5
Sets the layout picker thumbnail layout dimension dynamically
antonis May 4, 2022
ed9e0c6
Sets the loading skeleton layout dimension dynamically
antonis May 4, 2022
3f080de
Uses a different thumb dimension for tablet devices
antonis May 4, 2022
0b0fbcf
Sets the category row height dynamically
antonis May 4, 2022
10642c1
Present preview when the theme is tapped
mkevins May 5, 2022
c240b23
Deselect theme when the preview is dismissed
mkevins May 5, 2022
822a85e
Hide selected overlay (check mark) in theme picker
mkevins May 5, 2022
159b716
Merge pull request #16474 from wordpress-mobile/task/16408-enlarge-th…
antonis May 5, 2022
cc36732
Merge branch 'trunk' into feature/site-design-revamp
antonis May 5, 2022
35c1b9c
Merge branch 'feature/site-design-revamp' into feature/site-design-re…
mkevins May 6, 2022
c87bf46
Add content description for preview action to theme thumbnails
mkevins May 6, 2022
949bc2a
Update theme picker tests
mkevins May 6, 2022
8275b86
Remove unused test in theme picker viewmodel
mkevins May 6, 2022
84a1829
Add comment on tracker default NOOP implementation
mkevins May 6, 2022
3793ac3
Merge pull request #16480 from wordpress-mobile/feature/site-design-r…
antonis May 6, 2022
54390d9
Merge branch 'trunk' into feature/site-design-revamp
antonis May 6, 2022
b845651
Extracts default implementation for the scale property of the ThumbDi…
antonis May 6, 2022
c950f0f
Adds dimension provider for recommended designs
antonis May 6, 2022
8b3d3d7
WIP: Adds recommended designs row
antonis May 6, 2022
ceb4a36
Fixes lint issue
antonis May 6, 2022
e5128e3
Adds recommended title
antonis May 6, 2022
dfa6d16
Add id to divider view between layouts rows
ovitrif May 6, 2022
d8a612b
Add showDividers bool to layouts item view holder for showing/hiding …
ovitrif May 6, 2022
97aaf34
Hide layouts row separator on site design screen
ovitrif May 6, 2022
b596539
Merge pull request #16488 from wordpress-mobile/task/16487-hide-separ…
antonis May 6, 2022
2a1d5c1
Fixes broken tests
antonis May 6, 2022
9217d24
Workaround to prevent recyclerview from recycling rows of different size
antonis May 6, 2022
df0d9ea
Override getItemViewType to re-enable recycling
mkevins May 9, 2022
e7abed6
Merge branch 'trunk' into feature/site-design-revamp
mkevins May 9, 2022
9df16e1
Merge branch 'trunk' into feature/site-design-revamp
antonis May 9, 2022
d9eef78
Merge branch 'feature/site-design-revamp' into task/16393-recommended…
antonis May 9, 2022
443e445
Minor code optimization to avoid force unwrapping
antonis May 9, 2022
d0d65f0
Extracts (dummy) recommendation logic to a separate function
antonis May 9, 2022
df5065a
Sets Blogging as the default fallback recommendation
antonis May 9, 2022
c3d5ab5
Mocks resource provider call with one parameter
antonis May 9, 2022
cac586f
Merge pull request #16486 from wordpress-mobile/task/16393-recommende…
ovitrif May 9, 2022
259c91c
Merge branch 'trunk' into feature/site-design-revamp
antonis May 9, 2022
f502a2a
Updates FluxC reference
antonis May 10, 2022
a6f506f
Pass selected vertical to the design picker
antonis May 10, 2022
85d9074
Recommend designs based on the selected vertical
antonis May 10, 2022
8f5ea25
Merge branch 'trunk' into feature/site-design-revamp
antonis May 10, 2022
7142471
Merge branch 'feature/site-design-revamp' into task/16503-recommend-v…
antonis May 10, 2022
9677bb9
Extracts the recommendation logic to a separate file
antonis May 10, 2022
fe387f4
Tests the recommended designs logic
antonis May 10, 2022
0052838
Adds a mechanism for randomising the order of layouts in specific cat…
antonis May 12, 2022
29060b9
Randomises the order of site designs except for the recommended category
antonis May 12, 2022
69d9798
Also save the ordered layouts per category for efficiency
antonis May 12, 2022
9daa723
Unit tests for which categories should be randomised
antonis May 12, 2022
232a730
Merge branch 'trunk' into feature/site-design-revamp
antonis May 12, 2022
c349fca
Merge branch 'feature/site-design-revamp' into task/16503-recommend-v…
antonis May 12, 2022
11ff1a1
Merge branch 'task/16503-recommend-vertical-designs' into task/16506-…
antonis May 12, 2022
e0980a7
Unselect the layout after the choose action if fired
antonis May 12, 2022
2fa545a
Merge branch 'task/16503-recommend-vertical-designs' into task/16506-…
antonis May 12, 2022
3ddba5e
Adds recommended property in the enhanced_site_creation_site_design_s…
antonis May 13, 2022
8893ea3
Merge branch 'trunk' into feature/site-design-revamp
antonis May 13, 2022
e80ad38
Merge branch 'feature/site-design-revamp' into task/16503-recommend-v…
antonis May 13, 2022
319e4c5
Merge branch 'task/16503-recommend-vertical-designs' into task/16506-…
antonis May 13, 2022
62812e7
Merge branch 'task/16503-recommend-vertical-designs' into task/16528-…
antonis May 13, 2022
91c1cab
Hides keyboard on back
antonis May 13, 2022
db502a2
Add bottom helper text to theme picker
mkevins May 9, 2022
1020c4d
Merge pull request #16531 from wordpress-mobile/task/16506-randomise-…
ovitrif May 13, 2022
8a16b16
Merge pull request #16538 from wordpress-mobile/task/16528-track-reco…
ovitrif May 13, 2022
7f12781
Merge pull request #16510 from wordpress-mobile/task/16503-recommend-…
ovitrif May 13, 2022
ab4b4c0
Moves the site design picker loadSavedState call to the correct place
antonis May 13, 2022
ad8044c
Merge pull request #16546 from wordpress-mobile/fix/crash-on-site-int…
ovitrif May 13, 2022
8fe8fc8
Fix screens title visibility on the new & updated site creation screens
ovitrif May 13, 2022
3c6c94e
Updates the UI on vertical change
antonis May 13, 2022
18c2ac8
Adds unit test verifying that the vertical change triggers a reload
antonis May 13, 2022
89e7f74
Merge pull request #16549 from wordpress-mobile/fix/16540-handle-vert…
ovitrif May 13, 2022
9dbd048
Align collapsing titles on site creation screens to textStart
ovitrif May 14, 2022
eb9e6e2
Align header title & subtitle on site creation screens to textStart
ovitrif May 14, 2022
af3d168
Use site creation header v2 in site theme screen for consistency
ovitrif May 14, 2022
925ee73
Merge branch 'trunk' into feature/site-design-revamp
mkevins May 16, 2022
20383bf
Merge branch 'feature/site-design-revamp' into feature/site-design-re…
mkevins May 16, 2022
376303a
Fix detekt issues
mkevins May 16, 2022
f97da0a
Fix lint
mkevins May 16, 2022
d3af3a3
Rename appbar title id in site theme titlebar to avoid DuplicateInclu…
ovitrif May 16, 2022
f3c6c21
Remove unused dimension resource siq_title_padding_start
ovitrif May 16, 2022
157d929
Remove redundant horizontal margins override in the site creation hea…
ovitrif May 16, 2022
0147793
Merge pull request #16550 from wordpress-mobile/issue/16464-site-crea…
antonis May 16, 2022
fc56927
Merge branch 'feature/site-design-revamp' into issue/16551-align-site…
antonis May 16, 2022
c70fc58
Merge pull request #16556 from wordpress-mobile/issue/16551-align-sit…
antonis May 16, 2022
d11ba98
Merge branch 'trunk' into feature/site-design-revamp
mkevins May 17, 2022
789d613
Merge branch 'feature/site-design-revamp' into feature/site-design-re…
mkevins May 17, 2022
01d5a85
Make some style adjustments
mkevins May 17, 2022
3812665
Only show footer when list is populated
mkevins May 17, 2022
1509790
Merge pull request #16555 from wordpress-mobile/feature/site-design-r…
ovitrif May 17, 2022
3a7dd1a
Replace SiteCreationActivity dependency injection with Hilt
ovitrif May 17, 2022
2bf8d9f
Inject SiteCreationVM with Hilt
ovitrif May 17, 2022
600d725
Replace dagger with hilt for SiteCreationIntents fragment & viewModel
ovitrif May 17, 2022
c62b642
Replace dagger with hilt for SiteCreationSiteName fragment & viewModel
ovitrif May 17, 2022
496bd2a
Fix SiteCreationMainVM injection with Hilt
ovitrif May 17, 2022
0d6e4f8
Cleanup AppComponent
ovitrif May 17, 2022
f4810e0
Replace dagger with hilt for HomePagePicker fragment & viewModel
ovitrif May 17, 2022
1d62470
Replace dagger with hilt for SiteCreationDomains fragment & viewModel
ovitrif May 17, 2022
3e5e382
Replace dagger with hilt for SiteCreationPreview fragment & viewModel
ovitrif May 17, 2022
9f72fff
Fix whitespace indentation in SiteCreationDomainsFragment
ovitrif May 17, 2022
aca0745
Remove unused import in SiteCreationPreviewFragment
ovitrif May 17, 2022
2f24b9f
Merge pull request #16575 from wordpress-mobile/refactor/site-creatio…
antonis May 18, 2022
48a6dfc
Merge branch 'trunk' into feature/site-design-revamp
antonis May 18, 2022
2383dc9
Add temporary feature flag to facilitate testing
mkevins May 18, 2022
aa00844
Disable volley cache for MShots loader
mkevins May 18, 2022
1ce7d7c
Add reminder note about nested recycler viewholder pool
mkevins May 18, 2022
46cd6c0
Implement preloader function in main site creation view model
mkevins May 18, 2022
04a4cdb
Invoke preloading at the start, and cancel before theme picker loads
mkevins May 18, 2022
4ad7aff
Merge branch 'feature/site-design-revamp' into feature/site-design-re…
mkevins May 18, 2022
1faffab
Sets the loading skeleton to the size of the recommended row
antonis May 19, 2022
290de92
Merge pull request #16597 from wordpress-mobile/task/site-design-reva…
ovitrif May 19, 2022
283d30e
Sets the correct height in the Page Layout Picker
antonis May 19, 2022
ddca94e
Merge pull request #16599 from wordpress-mobile/fix/site-design-skele…
mkevins May 20, 2022
e48fbcd
Merge branch 'trunk' into feature/site-design-revamp
mkevins May 20, 2022
fe52805
Merge branch 'feature/site-design-revamp' into feature/site-design-re…
mkevins May 20, 2022
fc4d3e0
Merge branch 'trunk' into feature/site-design-revamp
antonis May 20, 2022
12f8f4c
Fixes Lint issue
antonis May 20, 2022
5130cbd
Merge branch 'feature/site-design-revamp' into feature/site-design-re…
antonis May 20, 2022
86f014e
Updates view model test with the new parameters
antonis May 20, 2022
28900f7
Merge branch 'feature/site-design-revamp--preload-mshots' of github.c…
mkevins May 23, 2022
ba5f8c1
Move preload cancellation inside when expression
mkevins May 23, 2022
290593e
Set preloading null outside of network check
mkevins May 23, 2022
1a67643
Revert "Add temporary feature flag to facilitate testing"
mkevins May 23, 2022
0cfce3d
Revert "Disable volley cache for MShots loader"
mkevins May 23, 2022
92ff57a
Merge branch 'trunk' into feature/site-design-revamp
mkevins May 23, 2022
e9b9a3d
Merge branch 'feature/site-design-revamp' into feature/site-design-re…
mkevins May 23, 2022
b2f99c7
Remove instantiation of nested recycledViewPools
mkevins May 23, 2022
29c2398
Merge pull request #16584 from wordpress-mobile/feature/site-design-r…
mkevins May 23, 2022
f56b967
Merge branch 'trunk' into feature/site-design-revamp
ovitrif May 23, 2022
34b10eb
Add divider on top of helper text of site theme screen
ovitrif May 23, 2022
a6df1ee
Increase padding of helper text to 16dp
ovitrif May 23, 2022
efb8acc
Increase font size of category title on site theme
ovitrif May 23, 2022
ebcd379
Fix increase padding of footer to 16dp
ovitrif May 23, 2022
5351d73
Remove TODO comment from init of SiteCreationMainVM that is no longer…
ovitrif May 23, 2022
0d522e6
Remove if condition for cancelling the preview preloading job
ovitrif May 23, 2022
cefc268
Add bool prop for useLargeCategoryHeading to keep LayoutCategoryAdapt…
ovitrif May 23, 2022
fed9a50
Move handling of row dividers to bind method block
ovitrif May 23, 2022
6287565
Suppress LongParameterList check for LayoutsItemViewHolder ctor
ovitrif May 23, 2022
ff0aa69
Merge pull request #16619 from wordpress-mobile/feature/site-design-r…
antonis May 23, 2022
af325dd
Merge branch 'trunk' into feature/site-design-revamp
antonis May 24, 2022
5794113
Uses the custom Glide loader for preloading the MShots
antonis May 24, 2022
4e3f28a
Removes unused import
antonis May 24, 2022
02805c6
Merge pull request #16624 from wordpress-mobile/task/preload-mshot
ovitrif May 24, 2022
71a21ee
Merge branch 'trunk' into feature/site-design-revamp
antonis May 25, 2022
a89ba30
Merge branch 'trunk' into feature/site-design-revamp
mkevins May 27, 2022
ea6d246
Merge branch 'trunk' into feature/site-design-revamp
antonis May 31, 2022
b30c49c
Adds release notes
antonis May 31, 2022
de2dd95
Merge pull request #16667 from wordpress-mobile/task/site-design-reva…
antonis May 31, 2022
9b818ae
Merge branch 'trunk' into feature/site-design-revamp
antonis Jun 2, 2022
66b37eb
Adds margin between recommended design title and subtitle
antonis Jun 2, 2022
eb916f8
Aligns overlay and stroke visibility in design selection
antonis Jun 2, 2022
f6d7e87
Merge pull request #16692 from wordpress-mobile/task/site-design-reva…
twstokes Jun 2, 2022
0abd1f3
Merge pull request #16693 from wordpress-mobile/task/site-design-reva…
twstokes Jun 2, 2022
f39946e
Save view model data in home page picker fragment on orientation changes
mkevins Jun 3, 2022
591dddf
Remove writing theme picker vm to activity bundle
mkevins Jun 3, 2022
2d3ab46
Merge pull request #16700 from wordpress-mobile/feature/site-design-r…
antonis Jun 3, 2022
d2ecdc4
Merge branch 'trunk' into feature/site-design-revamp
antonis Jun 3, 2022
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
2 changes: 1 addition & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

20.1
-----

* [*] Site creation: enhances the design selection screen with recommended designs [https://github.com/wordpress-mobile/WordPress-Android/pull/16468]

20.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,8 @@
import org.wordpress.android.ui.reader.views.ReaderSiteSearchResultView;
import org.wordpress.android.ui.reader.views.ReaderTagHeaderView;
import org.wordpress.android.ui.reader.views.ReaderWebView;
import org.wordpress.android.ui.sitecreation.SiteCreationActivity;
import org.wordpress.android.ui.sitecreation.domains.SiteCreationDomainsFragment;
import org.wordpress.android.ui.sitecreation.previews.SiteCreationPreviewFragment;
import org.wordpress.android.ui.sitecreation.services.SiteCreationService;
import org.wordpress.android.ui.sitecreation.sitename.SiteCreationSiteNameFragment;
import org.wordpress.android.ui.sitecreation.theme.DesignPreviewFragment;
import org.wordpress.android.ui.sitecreation.theme.HomePagePickerFragment;
import org.wordpress.android.ui.sitecreation.verticals.SiteCreationIntentsFragment;
import org.wordpress.android.ui.stats.StatsConnectJetpackActivity;
import org.wordpress.android.ui.stats.refresh.lists.StatsListFragment;
import org.wordpress.android.ui.stats.refresh.lists.widget.alltime.AllTimeWidgetBlockListProviderFactory;
Expand Down Expand Up @@ -260,12 +254,6 @@ public interface AppComponent {

void inject(PostSignupInterstitialActivity object);

void inject(SiteCreationActivity object);

void inject(SiteCreationDomainsFragment object);

void inject(SiteCreationPreviewFragment object);

void inject(JetpackConnectionResultActivity object);

void inject(StatsConnectJetpackActivity object);
Expand Down Expand Up @@ -546,12 +534,6 @@ public interface AppComponent {

void inject(ModalLayoutPickerFragment object);

void inject(HomePagePickerFragment object);

void inject(SiteCreationIntentsFragment object);

void inject(SiteCreationSiteNameFragment object);

void inject(SubfilterBottomSheetFragment object);

void inject(AddContentAdapter object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@
import org.wordpress.android.ui.reader.viewmodels.ReaderPostListViewModel;
import org.wordpress.android.ui.reader.viewmodels.ReaderViewModel;
import org.wordpress.android.ui.reader.viewmodels.SubfilterPageViewModel;
import org.wordpress.android.ui.sitecreation.SiteCreationMainVM;
import org.wordpress.android.ui.sitecreation.domains.SiteCreationDomainsViewModel;
import org.wordpress.android.ui.sitecreation.previews.SitePreviewViewModel;
import org.wordpress.android.ui.sitecreation.sitename.SiteCreationSiteNameViewModel;
import org.wordpress.android.ui.sitecreation.theme.HomePagePickerViewModel;
import org.wordpress.android.ui.sitecreation.verticals.SiteCreationIntentsViewModel;
import org.wordpress.android.ui.stats.refresh.lists.DaysListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.InsightsDetailListViewModel;
import org.wordpress.android.ui.stats.refresh.lists.InsightsListViewModel;
Expand Down Expand Up @@ -261,31 +255,6 @@ abstract class ViewModelModule {
@ViewModelKey(HistoryViewModel.class)
abstract ViewModel historyViewModel(HistoryViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(SiteCreationIntentsViewModel.class)
abstract ViewModel siteCreationIntentsViewModel(SiteCreationIntentsViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(SiteCreationSiteNameViewModel.class)
abstract ViewModel siteCreationSiteNameViewModel(SiteCreationSiteNameViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(SiteCreationDomainsViewModel.class)
abstract ViewModel siteCreationDomainsViewModel(SiteCreationDomainsViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(SiteCreationMainVM.class)
abstract ViewModel siteCreationMainVM(SiteCreationMainVM viewModel);

@Binds
@IntoMap
@ViewModelKey(SitePreviewViewModel.class)
abstract ViewModel newSitePreviewViewModel(SitePreviewViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(PostListViewModel.class)
Expand Down Expand Up @@ -351,11 +320,6 @@ abstract class ViewModelModule {
@ViewModelKey(ModalLayoutPickerViewModel.class)
abstract ViewModel mlpViewModel(ModalLayoutPickerViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(HomePagePickerViewModel.class)
abstract ViewModel hppViewModel(HomePagePickerViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(PostSignupInterstitialViewModel.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@ import android.os.Bundle
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView.Adapter
import org.wordpress.android.ui.layoutpicker.LayoutCategoryViewType.DEFAULT
import org.wordpress.android.ui.layoutpicker.LayoutCategoryViewType.FOOTER
import org.wordpress.android.ui.layoutpicker.LayoutCategoryViewType.RECOMMENDED

enum class LayoutCategoryViewType {
DEFAULT,
RECOMMENDED,
FOOTER,
}

/**
* Renders the layout categories
*/
class LayoutCategoryAdapter(private var nestedScrollStates: Bundle) : Adapter<LayoutsItemViewHolder>() {
class LayoutCategoryAdapter(
private var nestedScrollStates: Bundle,
private val thumbDimensionProvider: ThumbDimensionProvider,
private val recommendedDimensionProvider: ThumbDimensionProvider? = null,
private val showRowDividers: Boolean = true,
private val useLargeCategoryHeading: Boolean = false,
private val footerLayoutResId: Int? = null
) : Adapter<LayoutsRowViewHolder>() {
private var items: List<LayoutCategoryUiState> = listOf()
private val shouldShowFooter get() = footerLayoutResId != null && items.isNotEmpty()

fun update(newItems: List<LayoutCategoryUiState>) {
val diffResult = DiffUtil.calculateDiff(
Expand All @@ -22,19 +39,38 @@ class LayoutCategoryAdapter(private var nestedScrollStates: Bundle) : Adapter<La
diffResult.dispatchUpdatesTo(this)
}

override fun getItemCount(): Int = items.size
override fun getItemCount(): Int = items.size + if (shouldShowFooter) 1 else 0

override fun onBindViewHolder(holder: LayoutsRowViewHolder, position: Int) {
(holder as? LayoutsItemViewHolder)?.bind(items[position])
}

override fun onBindViewHolder(holder: LayoutsItemViewHolder, position: Int) {
holder.bind(items[position])
override fun getItemViewType(position: Int): Int {
return when {
items.size <= position -> FOOTER.ordinal
items[position].isRecommended -> RECOMMENDED.ordinal
else -> DEFAULT.ordinal
}
}

override fun onViewRecycled(holder: LayoutsItemViewHolder) {
override fun onViewRecycled(holder: LayoutsRowViewHolder) {
super.onViewRecycled(holder)
holder.onRecycled()
(holder as? LayoutsItemViewHolder)?.onRecycled()
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
LayoutsItemViewHolder(parent = parent, nestedScrollStates = nestedScrollStates)
when (viewType) {
FOOTER.ordinal -> LayoutsFooterViewHolder(parent, footerLayoutResId!!)
else ->
LayoutsItemViewHolder(
parent = parent,
nestedScrollStates = nestedScrollStates,
thumbDimensionProvider = thumbDimensionProvider,
recommendedDimensionProvider = recommendedDimensionProvider,
showRowDividers = showRowDividers,
useLargeCategoryHeading = useLargeCategoryHeading
)
}

fun onRestoreInstanceState(savedInstanceState: Bundle) {
nestedScrollStates = savedInstanceState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ class LayoutCategoryDiffCallback(
) : Callback() {
object Payload
override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return newList[newItemPosition].slug == oldList[oldItemPosition].slug
return newList[newItemPosition].isRecommended == oldList[oldItemPosition].isRecommended &&
newList[newItemPosition].slug == oldList[oldItemPosition].slug
}

override fun getOldListSize(): Int = oldList.size

override fun getNewListSize(): Int = newList.size

override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
return newList[newItemPosition].layouts == oldList[oldItemPosition].layouts
return newList[newItemPosition].isRecommended == oldList[oldItemPosition].isRecommended &&
newList[newItemPosition].layouts == oldList[oldItemPosition].layouts
}

override fun getChangePayload(oldItemPosition: Int, newItemPosition: Int): Any? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.wordpress.android.fluxc.network.rest.wpcom.theme.StarterDesignCategor
@SuppressLint("ParcelCreator")
class LayoutCategoryModel(
private val starterDesignCategory: StarterDesignCategory? = null,
private val blockLayoutCategory: GutenbergLayoutCategory? = null
private val blockLayoutCategory: GutenbergLayoutCategory? = null,
val isRecommended: Boolean = false,
val randomizeOrder: Boolean = false
) : Parcelable {
val slug: String
get() = starterDesignCategory?.slug ?: blockLayoutCategory?.slug ?: ""
Expand All @@ -23,7 +25,14 @@ class LayoutCategoryModel(
}

@JvmName("starterDesignToLayoutCategories")
fun List<StarterDesignCategory>.toLayoutCategories() = map { LayoutCategoryModel(starterDesignCategory = it) }
fun List<StarterDesignCategory>.toLayoutCategories(recommended: Boolean = false, randomizeOrder: Boolean = false) =
map {
LayoutCategoryModel(
starterDesignCategory = it,
isRecommended = recommended,
randomizeOrder = randomizeOrder
)
}

@JvmName("gutenbergLayoutToLayoutCategories")
fun List<GutenbergLayoutCategory>.toLayoutCategories() = map { LayoutCategoryModel(blockLayoutCategory = it) }
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ package org.wordpress.android.ui.layoutpicker
* @param title the layout category title
* @param description the layout category description
* @param layouts the layouts list
* @param isRecommended defines if the category is recommended (optional with default `false`)
*/
data class LayoutCategoryUiState(
val slug: String,
val title: String,
val description: String,
val layouts: List<LayoutListItemUiState>
val layouts: List<LayoutListItemUiState>,
val isRecommended: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ data class LayoutListItemUiState(
val slug: String,
val title: String,
val preview: String,
val mShotPreview: String,
val selected: Boolean,
val onItemTapped: (() -> Unit),
val onThumbnailReady: (() -> Unit)
val onThumbnailReady: (() -> Unit),
private val tapOpensPreview: Boolean
) {
val contentDescriptionResId: Int
get() = if (selected) R.string.mlp_selected_description else R.string.mlp_notselected_description

get() = when {
tapOpensPreview -> R.string.hpp_preview_tapped_theme
selected -> R.string.mlp_selected_description
else -> R.string.mlp_notselected_description
}
val selectedOverlayVisible: Boolean
get() = selected
get() = !tapOpensPreview && selected
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package org.wordpress.android.ui.layoutpicker
interface LayoutPickerTracker {
fun trackPreviewModeChanged(mode: String)

fun trackThumbnailModeTapped(mode: String)
// NOOP implementation provided to make override optional in subclasses
fun trackThumbnailModeTapped(mode: String) {
}

fun trackPreviewModeTapped(mode: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sealed class LayoutPickerUiState(
override val isToolbarVisible: Boolean = false,
val selectedCategoriesSlugs: ArrayList<String> = arrayListOf(),
val selectedLayoutSlug: String? = null,
val isSelectedLayoutRecommended: Boolean = false,
val loadedThumbnailSlugs: ArrayList<String> = arrayListOf(),
val categories: List<CategoryListItemUiState> = listOf(),
val layoutCategories: List<LayoutCategoryUiState> = listOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ abstract class LayoutPickerViewModel(
}

abstract val useCachedData: Boolean
abstract val shouldUseMobileThumbnail: Boolean
open val thumbnailTapOpensPreview = false

var nestedScrollStates: Bundle = Bundle()

// Map that holds the ordered/randomised layouts list per category (key: slug)
val orderedLayouts: MutableMap<String, List<LayoutModel>> = mutableMapOf()

abstract fun fetchLayouts(preferCache: Boolean = false)

open fun onPreviewChooseTapped() = onDismissPreview()
Expand Down Expand Up @@ -141,7 +146,7 @@ abstract class LayoutPickerViewModel(
}
}

private fun loadLayouts() {
fun loadLayouts() {
val state = uiState.value as? Content ?: Content()
launch(bgDispatcher) {
val listItems = ArrayList<LayoutCategoryUiState>()
Expand All @@ -153,18 +158,30 @@ abstract class LayoutPickerViewModel(
}

selectedCategories.forEach { category ->

val layouts = layouts.getFilteredLayouts(category.slug).map { layout ->
val ordered = orderedLayouts[category.slug] ?: if (category.randomizeOrder) {
val randomised = layouts.getFilteredLayouts(category.slug).shuffled()
orderedLayouts[category.slug] = randomised
randomised
} else {
val ordered = layouts.getFilteredLayouts(category.slug)
orderedLayouts[category.slug] = ordered
ordered
}
val layouts = ordered.map { layout ->
val preview = when (_previewMode.value) {
MOBILE -> layout.previewMobile
TABLET -> layout.previewTablet
else -> layout.preview
}
val thumbnailPreview = if (shouldUseMobileThumbnail) layout.previewMobile else preview
LayoutListItemUiState(
slug = layout.slug,
title = layout.title,
preview = when (_previewMode.value) {
MOBILE -> layout.previewMobile
TABLET -> layout.previewTablet
else -> layout.preview
},
preview = preview,
mShotPreview = thumbnailPreview,
selected = layout.slug == state.selectedLayoutSlug,
onItemTapped = { onLayoutTapped(layoutSlug = layout.slug) },
tapOpensPreview = thumbnailTapOpensPreview,
onItemTapped = { onLayoutTapped(layoutSlug = layout.slug, category.isRecommended) },
onThumbnailReady = { onThumbnailReady(layoutSlug = layout.slug) }
)
}
Expand All @@ -173,7 +190,8 @@ abstract class LayoutPickerViewModel(
category.slug,
category.title,
category.description,
layouts
layouts,
category.isRecommended
)
)
}
Expand All @@ -187,7 +205,7 @@ abstract class LayoutPickerViewModel(
* Layout tapped
* @param layoutSlug the slug of the tapped layout
*/
fun onLayoutTapped(layoutSlug: String) {
open fun onLayoutTapped(layoutSlug: String, isRecommended: Boolean = false) {
(uiState.value as? Content)?.let { state ->
if (!state.loadedThumbnailSlugs.contains(layoutSlug)) return // No action
if (layoutSlug == state.selectedLayoutSlug) { // deselect
Expand Down
Loading