@@ -53,12 +53,9 @@ public class DashboardDetailFragment extends Fragment {
5353 private View updatingCancel ; // ADFA-5333: the Cancel affordance beside the bar
5454 private boolean updating ; // ADFA-5333: a background rebuild is in flight; don't re-emphasize Rebuild
5555 private boolean updateAvailable ; // ADFA-5339: last-known — the confirm dialog matches the button
56- // ADFA-5339: expandable Details — the live rebuild log, minimized by default. The toggle is hidden
57- // until there are lines (an older box without /rebuild/log, or a rebuild that hasn't logged yet).
58- private TextView detailsToggle ;
59- private android .widget .ScrollView logScroll ;
60- private TextView logText ;
61- private boolean logExpanded ;
56+ // ADFA-5339 / K2GO-374: expandable Details — the live rebuild log via the shared LiveLogPanel. The
57+ // toggle stays hidden until there are lines (an older box without /rebuild/log shows no Details).
58+ private org .iiab .controller .widget .LiveLogPanel logPanel ;
6259 private static final long LOG_POLL_MS = 1500L ;
6360 private final Runnable logPoll = this ::pollLog ;
6461 // K2GO-95 (Phase 2): the in-progress bar is determinate, driven by RebuildProgress from the polled
@@ -319,31 +316,11 @@ private View buildUpdatingRow(Button rebuildBtn) {
319316
320317 row .addView (line );
321318
322- // ADFA-5339: Details — a "Show details" toggle (hidden until there are log lines) that reveals
323- // the live rebuild log in place. Mirrors the module-install Details pattern; the button above
324- // stays fixed. Text chevron (▾/▴) to avoid a new drawable.
325- detailsToggle = new TextView (requireContext ());
326- detailsToggle .setText (getString (R .string .k2go_maps_log_show ) + " ▾" );
327- detailsToggle .setTextAppearance (com .google .android .material .R .style .TextAppearance_Material3_LabelLarge );
328- detailsToggle .setTextColor (ContextCompat .getColor (requireContext (), R .color .k2go_teal ));
329- detailsToggle .setPadding (0 , Math .round (8 * d ), 0 , Math .round (4 * d ));
330- detailsToggle .setClickable (true );
331- detailsToggle .setVisibility (View .GONE );
332- detailsToggle .setOnClickListener (v -> toggleLog ());
333- row .addView (detailsToggle );
334-
335- logScroll = new android .widget .ScrollView (requireContext ());
336- LinearLayout .LayoutParams slp = new LinearLayout .LayoutParams (
337- ViewGroup .LayoutParams .MATCH_PARENT , Math .round (160 * d ));
338- logScroll .setLayoutParams (slp );
339- logScroll .setVisibility (View .GONE );
340- logText = new TextView (requireContext ());
341- logText .setTextAppearance (com .google .android .material .R .style .TextAppearance_Material3_BodySmall );
342- logText .setTextColor (ContextCompat .getColor (requireContext (), R .color .k2go_muted ));
343- logText .setTypeface (android .graphics .Typeface .MONOSPACE );
344- logText .setTextIsSelectable (true );
345- logScroll .addView (logText );
346- row .addView (logScroll );
319+ // K2GO-374: Details — the shared LiveLogPanel (was a hand-rolled toggle + ScrollView). Fork B:
320+ // the toggle stays hidden until there are log lines (an older box without /rebuild/log = empty).
321+ logPanel = new org .iiab .controller .widget .LiveLogPanel (requireContext ());
322+ logPanel .setHideUntilContent (true );
323+ row .addView (logPanel );
347324
348325 row .setVisibility (View .GONE );
349326 parent .addView (row , parent .indexOfChild (rebuildBtn ));
@@ -384,22 +361,10 @@ private void setUpdating(boolean on) {
384361 // K2GO-95: a fresh run starts indeterminate until the first marker; pollLog then drives it.
385362 progressPhase = RebuildPhase .NONE ;
386363 if (progressBar != null ) progressBar .setIndeterminate (true );
364+ if (logPanel != null ) logPanel .reset (); // K2GO-374: start clean; toggle hidden until lines
387365 main .post (logPoll );
388- } else if (detailsToggle != null ) {
389- detailsToggle .setVisibility (View .GONE );
390- if (logScroll != null ) logScroll .setVisibility (View .GONE );
391- }
392- }
393-
394- /** ADFA-5339: reveal/hide the live log in place; the Rebuild button and everything else stay put. */
395- private void toggleLog () {
396- logExpanded = !logExpanded ;
397- if (logScroll != null ) logScroll .setVisibility (logExpanded ? View .VISIBLE : View .GONE );
398- if (detailsToggle != null ) {
399- detailsToggle .setText (getString (
400- logExpanded ? R .string .k2go_maps_log_hide : R .string .k2go_maps_log_show )
401- + (logExpanded ? " ▴" : " ▾" ));
402366 }
367+ // On "off" the whole updatingRow is hidden above, which takes the panel with it.
403368 }
404369
405370 /** ADFA-5339: poll the rebuild log tail while updating. Fork B — the toggle appears only once there
@@ -412,17 +377,11 @@ private void pollLog() {
412377 if (!isAdded () || !updating ) return ;
413378 String log = android .text .TextUtils .join ("\n " , lines );
414379 updateProgressBar (log );
415- if (!lines .isEmpty ()) {
416- if (detailsToggle != null ) detailsToggle .setVisibility (View .VISIBLE );
417- if (logText != null ) logText .setText (log );
418- if (logExpanded && logScroll != null ) {
419- logScroll .post (() -> logScroll .fullScroll (View .FOCUS_DOWN ));
420- }
421- }
380+ if (logPanel != null ) logPanel .setContent (log ); // K2GO-374: reveal + auto-scroll handled here
422381 main .postDelayed (logPoll , LOG_POLL_MS );
423382 }
424383 @ Override public void onErr (String message ) {
425- // No endpoint / transient: keep the toggle as-is (hidden if never populated) and retry.
384+ // No endpoint / transient: keep the panel as-is (toggle hidden if never populated) and retry.
426385 if (isAdded () && updating ) main .postDelayed (logPoll , LOG_POLL_MS );
427386 }
428387 });
0 commit comments