This commit is contained in:
Patrick
2026-06-20 22:42:29 +02:00
parent 8f84e829d6
commit cf5745808e
@@ -17,23 +17,20 @@ public class SettingsFragment extends Fragment {
root.setLayoutParams(new FrameLayout.LayoutParams( root.setLayoutParams(new FrameLayout.LayoutParams(
dp(520), dp(320), Gravity.CENTER)); dp(520), dp(320), Gravity.CENTER));
// --- LEFT PANEL: tab buttons stacked vertically ---
LinearLayout sidebar = new LinearLayout(getContext()); LinearLayout sidebar = new LinearLayout(getContext());
sidebar.setOrientation(LinearLayout.VERTICAL); sidebar.setOrientation(LinearLayout.VERTICAL);
sidebar.setPadding(dp(8), dp(8), dp(8), dp(8)); sidebar.setPadding(dp(8), dp(8), dp(8), dp(8));
// Semi-transparent dark background
sidebar.setBackground(makeRoundedBg(0xCC1A1A2E)); sidebar.setBackground(makeRoundedBg(0xCC1A1A2E));
var sidebarParams = new LinearLayout.LayoutParams(dp(110), ViewGroup.LayoutParams.MATCH_PARENT); var sidebarParams = new LinearLayout.LayoutParams(dp(110), ViewGroup.LayoutParams.MATCH_PARENT);
root.addView(sidebar, sidebarParams); root.addView(sidebar, sidebarParams);
// --- RIGHT PANEL: fragment host ---
FrameLayout contentArea = new FrameLayout(getContext()); FrameLayout contentArea = new FrameLayout(getContext());
contentArea.setId(R.id.content); // or any stable int ID, e.g. 0x10001 contentArea.setId(R.id.content);
contentArea.setBackground(makeRoundedBg(0xCC101018)); contentArea.setBackground(makeRoundedBg(0xCC101018));
var contentParams = new LinearLayout.LayoutParams( var contentParams = new LinearLayout.LayoutParams(
0, ViewGroup.LayoutParams.MATCH_PARENT, 1f); // weight=1, fills remaining space 0, ViewGroup.LayoutParams.MATCH_PARENT, 1f);
contentParams.leftMargin = dp(6); contentParams.leftMargin = dp(6);
root.addView(contentArea, contentParams); root.addView(contentArea, contentParams);
@@ -43,7 +40,6 @@ public class SettingsFragment extends Fragment {
new GeneralTabFragment() new GeneralTabFragment()
}; };
// Show the first tab immediately
getChildFragmentManager().beginTransaction() getChildFragmentManager().beginTransaction()
.replace(contentArea.getId(), tabFragments[0]) .replace(contentArea.getId(), tabFragments[0])
.commitNow(); .commitNow();
@@ -56,15 +52,13 @@ public class SettingsFragment extends Fragment {
tab.setTextSize(13); tab.setTextSize(13);
tab.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); tab.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
tab.setPadding(dp(10), dp(6), dp(10), dp(6)); tab.setPadding(dp(10), dp(6), dp(10), dp(6));
tab.setBackground(null); // we'll tint active tab manually tab.setBackground(null);
tab.setOnClickListener(v -> { tab.setOnClickListener(v -> {
// Swap content fragment
getChildFragmentManager().beginTransaction() getChildFragmentManager().beginTransaction()
.setReorderingAllowed(true) .setReorderingAllowed(true)
.replace(contentArea.getId(), tabFragments[index]) .replace(contentArea.getId(), tabFragments[index])
.commit(); .commit();
// Highlight active tab
for (Button b : tabs) b.setTextColor(0xFFAAAAAA); for (Button b : tabs) b.setTextColor(0xFFAAAAAA);
tab.setTextColor(0xFFFFFFFF); tab.setTextColor(0xFFFFFFFF);
}); });
@@ -76,19 +70,16 @@ public class SettingsFragment extends Fragment {
tabs[i] = tab; tabs[i] = tab;
} }
// Default: highlight first tab
tabs[0].setTextColor(0xFFFFFFFF); tabs[0].setTextColor(0xFFFFFFFF);
for (int i = 1; i < tabs.length; i++) tabs[i].setTextColor(0xFFAAAAAA); for (int i = 1; i < tabs.length; i++) tabs[i].setTextColor(0xFFAAAAAA);
return root; return root;
} }
// Helper: dp → px
private int dp(float dp) { private int dp(float dp) {
return (int) (dp * getContext().getResources().getDisplayMetrics().density); return (int) (dp * getContext().getResources().getDisplayMetrics().density);
} }
// Helper: semi-transparent rounded rectangle background
private ShapeDrawable makeRoundedBg(int color) { private ShapeDrawable makeRoundedBg(int color) {
ShapeDrawable d = new ShapeDrawable(); ShapeDrawable d = new ShapeDrawable();
d.setCornerRadius(dp(6)); d.setCornerRadius(dp(6));