diff --git a/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java b/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java index 76dd0bf78..3ee80dee1 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java +++ b/android/src/main/java/com/facebook/flipper/plugins/sections/ChangesetDebug.java @@ -8,12 +8,15 @@ package com.facebook.flipper.plugins.sections; import com.facebook.flipper.core.FlipperArray; import com.facebook.flipper.core.FlipperObject; +import com.facebook.litho.sections.Change; import com.facebook.litho.sections.ChangesInfo; import com.facebook.litho.sections.ChangesetDebugConfiguration; import com.facebook.litho.sections.ChangesetDebugConfiguration.ChangesetDebugListener; import com.facebook.litho.sections.Section; import com.facebook.litho.sections.SectionsLogEventUtils; import com.facebook.litho.sections.SectionsLogEventUtils.ApplyNewChangeSet; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; public class ChangesetDebug implements ChangesetDebugListener { @@ -55,6 +58,7 @@ public class ChangesetDebug implements ChangesetDebugListener { final FlipperObject.Builder changesetData = new FlipperObject.Builder(); final String sourceName = SectionsLogEventUtils.applyNewChangeSetSourceToString(attribution); + extractSidePanelChangesetData(changesInfo, changesetData, rootSection.getGlobalKey()); createSectionTree(rootSection, "", tree, oldSection); @@ -77,6 +81,52 @@ public class ChangesetDebug implements ChangesetDebugListener { } } + /** Extract the changesets for this section tree. */ + private static void extractSidePanelChangesetData( + ChangesInfo changesInfo, FlipperObject.Builder changesetData, String globalKey) { + final FlipperObject.Builder sectionChangesetInfo = new FlipperObject.Builder(); + + final List changeList = changesInfo.getAllChanges(); + + final FlipperObject.Builder changesets = new FlipperObject.Builder(); + for (int i = 0; i < changeList.size(); i++) { + final Change change = changeList.get(i); + final FlipperObject.Builder changeData = new FlipperObject.Builder(); + changeData.put("type", Change.changeTypeToString(change.getType())); + changeData.put("index", change.getIndex()); + if (change.getToIndex() >= 0) { + changeData.put("toIndex", change.getToIndex()); + } + + changeData.put("count", change.getCount()); + + changeData.put("render_infos", ChangesetDebugConfiguration.getRenderInfoNames(change)); + + changeData.put("prev_data", getDataNamesFromChange(change.getPrevData())); + + changeData.put("next_data", getDataNamesFromChange(change.getNextData())); + + changesets.put(i + "", changeData.build()); + } + sectionChangesetInfo.put("changesets", changesets.build()); + + changesetData.put(globalKey, sectionChangesetInfo.build()); + } + + private static List getDataNamesFromChange(List data) { + final List names = new ArrayList<>(); + + if (data == null) { + return names; + } + + for (int i = 0; i < data.size(); i++) { + names.add(data.get(i).toString()); + } + + return names; + } + /** Finds the section with the same global key in the previous tree, if it existed. */ private static Section findSectionInPreviousTree(Section previousRoot, String globalKey) { if (previousRoot == null) { diff --git a/gradle.properties b/gradle.properties index fdfd64e8a..003790b23 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ POM_DEVELOPER_ID=facebook POM_DEVELOPER_NAME=facebook # Shared version numbers -LITHO_VERSION=0.28.0 +LITHO_VERSION=0.29.0 ANDROIDX_VERSION=1.0.0 KOTLIN_VERSION=1.3.31