Simplify server page actions
Gitea Smoke / smoke (push) Successful in 2s
Gitea Android APK / build (push) Failing after 1m2s

This commit is contained in:
Codex
2026-07-15 14:40:01 +00:00
parent 0d32e6105a
commit 813a74f3ef
@@ -293,20 +293,11 @@ public final class MainActivity extends Activity {
ScrollView scroll = new ScrollView(this); ScrollView scroll = new ScrollView(this);
LinearLayout content = pageContent(); LinearLayout content = pageContent();
List<String> serverUrls = savedServerUrls(); List<String> serverUrls = savedServerUrls();
content.addView(createPageHeader( content.addView(createServerPageHeader(serverUrls.size() + " nodes"));
serverUrls.size() + " nodes",
"Servers",
" Add",
view -> promptCustomServer(),
"",
"More navigation",
view -> showMainNavigation()
));
for (String url : serverUrls) { for (String url : serverUrls) {
content.addView(serverProfileCard(url), spacedHeight(72, 0, 12)); content.addView(serverProfileCard(url), spacedHeight(72, 0, 12));
} }
content.addView(createServerUtilityRow());
scroll.addView(content); scroll.addView(content);
root.addView(scroll, new LinearLayout.LayoutParams( root.addView(scroll, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
@@ -495,18 +486,6 @@ public final class MainActivity extends Activity {
String titleText, String titleText,
String actionLabel, String actionLabel,
View.OnClickListener action View.OnClickListener action
) {
return createPageHeader(eyebrow, titleText, actionLabel, action, null, null, null);
}
private View createPageHeader(
String eyebrow,
String titleText,
String actionLabel,
View.OnClickListener action,
String utilityLabel,
String utilityDescription,
View.OnClickListener utilityAction
) { ) {
LinearLayout header = new LinearLayout(this); LinearLayout header = new LinearLayout(this);
header.setOrientation(LinearLayout.HORIZONTAL); header.setOrientation(LinearLayout.HORIZONTAL);
@@ -535,23 +514,49 @@ public final class MainActivity extends Activity {
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
dp(38) dp(38)
)); ));
if (utilityAction != null) {
Button utility = terminalToolButton(utilityLabel, utilityAction);
utility.setContentDescription(utilityDescription);
LinearLayout.LayoutParams utilityParams = new LinearLayout.LayoutParams(dp(38), dp(38));
utilityParams.leftMargin = dp(6);
header.addView(utility, utilityParams);
}
return header; return header;
} }
private View createServerUtilityRow() { private View createServerPageHeader(String eyebrow) {
LinearLayout row = new LinearLayout(this); LinearLayout header = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL); header.setOrientation(LinearLayout.HORIZONTAL);
row.setPadding(0, dp(4), 0, 0); header.setGravity(Gravity.BOTTOM);
row.addView(compactButton("Probe all", view -> probeServerProfiles())); header.setPadding(dp(2), dp(6), dp(2), dp(18));
row.addView(compactButton("Update", view -> renderUpdateScreen()));
return row; LinearLayout titleBlock = new LinearLayout(this);
titleBlock.setOrientation(LinearLayout.VERTICAL);
TextView eyebrowView = new TextView(this);
eyebrowView.setText(eyebrow.toUpperCase(java.util.Locale.ROOT));
eyebrowView.setTextColor(COLOR_TEXT_MUTED);
eyebrowView.setTextSize(10);
eyebrowView.setTypeface(Typeface.MONOSPACE);
TextView title = new TextView(this);
title.setText("Servers");
title.setTextColor(COLOR_TEXT);
title.setTextSize(25);
title.setTypeface(Typeface.DEFAULT_BOLD);
title.setIncludeFontPadding(false);
titleBlock.addView(eyebrowView);
titleBlock.addView(title);
header.addView(titleBlock, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
addHeaderTool(header, "", "Refresh servers", view -> probeServerProfiles());
addHeaderTool(header, "", "Add server", view -> promptCustomServer());
addHeaderTool(header, "", "More navigation", view -> showMainNavigation());
return header;
}
private void addHeaderTool(
LinearLayout header,
String label,
String description,
View.OnClickListener action
) {
Button button = terminalToolButton(label, action);
button.setContentDescription(description);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(dp(38), dp(38));
params.leftMargin = dp(4);
header.addView(button, params);
} }
private View createSessionPageHeader() { private View createSessionPageHeader() {