|
| 1 | +## Visual Comparison & Adjustment |
| 2 | + |
| 3 | +### Overview |
| 4 | + |
| 5 | +``` |
| 6 | +Two Android emulators should be running side by side: |
| 7 | + 1. Reference emulator — has the existing native OneSignal demo app installed |
| 8 | + 2. SDK emulator — running the new SDK demo app from examples/demo/ |
| 9 | +
|
| 10 | +The goal is to visually compare the SDK app against the reference app |
| 11 | +section by section, then fix any inconsistencies in layout, spacing, colors, |
| 12 | +section order, typography, dialog flows, or overall look and feel. |
| 13 | +``` |
| 14 | + |
| 15 | +### Identify the emulators |
| 16 | + |
| 17 | +``` |
| 18 | +Run `adb devices` to list connected emulators. You should see two entries. |
| 19 | +
|
| 20 | +Identify which emulator is the reference by checking for the native demo package: |
| 21 | + adb -s <emulator-id> shell pm list packages | grep -i onesignal |
| 22 | +
|
| 23 | +The emulator that returns `package:com.onesignal.sdktest` is the reference. |
| 24 | +The other emulator is the SDK demo. |
| 25 | +
|
| 26 | +Assign them to variables for the steps below: |
| 27 | +
|
| 28 | + REF=<emulator-with-com.onesignal.sdktest> |
| 29 | + SDK=<emulator-with-com.onesignal.example> |
| 30 | +
|
| 31 | +(Replace with the actual emulator names from `adb devices`.) |
| 32 | +``` |
| 33 | + |
| 34 | +### Launch both apps |
| 35 | + |
| 36 | +``` |
| 37 | +If the reference app is not already running, launch it: |
| 38 | + adb -s $REF shell am start -n com.onesignal.sdktest/.ui.main.MainActivity |
| 39 | +
|
| 40 | +If the SDK demo app is not already running, launch it on the other emulator: |
| 41 | + cd examples/demo && run the app on $SDK |
| 42 | +
|
| 43 | +Before capturing screenshots, dismiss any in-app messages showing on |
| 44 | +either emulator. Tap the X or click-through button on each IAM until |
| 45 | +both apps show their main UI with no overlays. |
| 46 | +
|
| 47 | +Then pause in-app messages on both emulators so new IAMs don't |
| 48 | +interrupt the comparison. Scroll to the "In-App Messaging" section |
| 49 | +on each emulator and toggle "Pause In-App Messages" on. |
| 50 | +``` |
| 51 | + |
| 52 | +### Capture and compare screenshots |
| 53 | + |
| 54 | +``` |
| 55 | +Create output directories: |
| 56 | + mkdir -p /tmp/onesignal_reference /tmp/onesignal_sdk |
| 57 | +
|
| 58 | +Layout note: Both apps have a sticky LOGS section pinned at the top. |
| 59 | +On both emulators the scrollable content area starts at roughly y=800. |
| 60 | +When calculating swipe distances or tap targets, account for this offset. |
| 61 | +The screen resolution is 1344x2992 on both emulators, giving a visible |
| 62 | +scrollable viewport of about 2200px below the LOGS section. |
| 63 | +
|
| 64 | +Use uiautomator to find exact element positions before scrolling or tapping: |
| 65 | + adb -s $REF shell uiautomator dump /sdcard/ui.xml && adb -s $REF pull /sdcard/ui.xml /tmp/onesignal_reference/ui.xml |
| 66 | + adb -s $SDK shell uiautomator dump /sdcard/ui.xml && adb -s $SDK pull /sdcard/ui.xml /tmp/onesignal_sdk/ui.xml |
| 67 | +
|
| 68 | +Parse bounds to locate section headers and buttons: |
| 69 | + python3 -c " |
| 70 | + import xml.etree.ElementTree as ET |
| 71 | + tree = ET.parse('/tmp/onesignal_sdk/ui.xml') |
| 72 | + for node in tree.iter(): |
| 73 | + d = node.get('content-desc','') |
| 74 | + b = node.get('bounds','') |
| 75 | + if d.strip(): |
| 76 | + print(d.split(chr(10))[0][:50], b) |
| 77 | + " |
| 78 | +
|
| 79 | +To scroll a specific section header into view, dump the UI hierarchy, |
| 80 | +find the nearest visible element, and compute the swipe delta needed |
| 81 | +to bring the target section just below the LOGS area (y~800). For example, |
| 82 | +if the TAGS header is currently at y=2400 and you want it at y=850: |
| 83 | + delta = 2400 - 850 = 1550 |
| 84 | + adb -s $SDK shell input swipe 672 2000 672 450 |
| 85 | + (swipe from y=2000 up by ~1550px to y=450) |
| 86 | +
|
| 87 | +After scrolling, re-dump the UI hierarchy to confirm the section is now |
| 88 | +visible and get updated coordinates before tapping any buttons. |
| 89 | +
|
| 90 | +Capture matching screenshots at each scroll position: |
| 91 | + adb -s $REF shell screencap -p /sdcard/ref_01.png && adb -s $REF pull /sdcard/ref_01.png /tmp/onesignal_reference/ref_01.png |
| 92 | + adb -s $SDK shell screencap -p /sdcard/sdk_01.png && adb -s $SDK pull /sdcard/sdk_01.png /tmp/onesignal_sdk/sdk_01.png |
| 93 | +
|
| 94 | +Scroll section by section, aligning both emulators so the same section |
| 95 | +header sits just below the LOGS area on each, then capture and compare. |
| 96 | +Repeat until you have covered all sections from top to bottom. |
| 97 | +
|
| 98 | +Compare each pair of screenshots side by side. Look for differences in: |
| 99 | + - Section order and grouping |
| 100 | + - Card spacing and padding |
| 101 | + - Button styles, sizes, and colors |
| 102 | + - Typography (font size, weight, color) |
| 103 | + - Toggle/switch alignment |
| 104 | + - List item layout (key-value pairs, delete icons) |
| 105 | + - Empty state text |
| 106 | + - Logs section styling (background colors, text colors, header style) |
| 107 | + must match the reference app screenshots |
| 108 | +``` |
| 109 | + |
| 110 | +### Compare dialogs (ask before proceeding) |
| 111 | + |
| 112 | +``` |
| 113 | +Ask the user: "The main UI comparison is complete. Would you like to also compare key dialogs?" |
| 114 | +
|
| 115 | +If yes, for each dialog below, tap the corresponding button on both emulators, |
| 116 | +capture and compare the screenshots, then dismiss before moving on. |
| 117 | +
|
| 118 | +To tap an element, compute the center of its bounds from the UI dump: |
| 119 | + adb -s $SDK shell input tap <centerX> <centerY> |
| 120 | +
|
| 121 | +To type into a focused field: |
| 122 | + adb -s $SDK shell input text "test" |
| 123 | +
|
| 124 | +Dialogs to compare: |
| 125 | + - Add Alias (single pair input) |
| 126 | + - Add Multiple Aliases/Tags (dynamic rows with add/remove) |
| 127 | + - Remove Selected Tags (checkbox multi-select) |
| 128 | + - Login User |
| 129 | + - Send Outcome (radio options) |
| 130 | + - Track Event (with JSON properties field) |
| 131 | + - Custom Notification (title + body) |
| 132 | +
|
| 133 | +For each dialog, compare field layout, button placement, spacing, |
| 134 | +and validation behavior. Dismiss the dialog on both before moving on. |
| 135 | +``` |
| 136 | + |
| 137 | +### Fix inconsistencies |
| 138 | + |
| 139 | +``` |
| 140 | +After comparing, update the SDK demo source code in examples/demo/lib/ |
| 141 | +to fix any visual differences. Common things to adjust: |
| 142 | +
|
| 143 | + - Padding/margin values in section widgets |
| 144 | + - Font sizes or weights in theme.dart or individual sections |
| 145 | + - Button colors or styles in action_button.dart |
| 146 | + - Card elevation or border radius in theme.dart |
| 147 | + - Section ordering in home_screen.dart |
| 148 | + - Dialog field layout in dialogs.dart |
| 149 | +
|
| 150 | +After each fix, hot reload by pressing 'r' in the user's active SDK |
| 151 | +terminal (check open terminals for a running build process) and |
| 152 | +re-capture the SDK screenshot to verify the change matches the reference. |
| 153 | +``` |
0 commit comments