Rework Settings Menu

This commit is contained in:
Patrick
2026-06-20 23:22:17 +02:00
parent 09fadb4c0c
commit 0212277cab
5 changed files with 201 additions and 102 deletions
@@ -2,6 +2,8 @@ package de.winniepat.parrotmod.ui;
import icyllis.modernui.animation.ObjectAnimator; import icyllis.modernui.animation.ObjectAnimator;
import icyllis.modernui.fragment.Fragment; import icyllis.modernui.fragment.Fragment;
import icyllis.modernui.graphics.drawable.ShapeDrawable;
import icyllis.modernui.view.Gravity;
import icyllis.modernui.view.View; import icyllis.modernui.view.View;
import icyllis.modernui.view.ViewGroup; import icyllis.modernui.view.ViewGroup;
import icyllis.modernui.widget.LinearLayout; import icyllis.modernui.widget.LinearLayout;
@@ -9,6 +11,9 @@ import icyllis.modernui.widget.TextView;
public abstract class BaseTabFragment extends Fragment { public abstract class BaseTabFragment extends Fragment {
protected static final int COLOR_CARD = 0xFF1A1A22;
protected static final int COLOR_ACCENT = 0xFF00E5FF;
protected int dp(float dp) { protected int dp(float dp) {
return (int) (dp * getContext().getResources().getDisplayMetrics().density); return (int) (dp * getContext().getResources().getDisplayMetrics().density);
} }
@@ -25,12 +30,65 @@ public abstract class BaseTabFragment extends Fragment {
return tv; return tv;
} }
protected void addSectionHeader(LinearLayout parent, String title) {
TextView tv = new TextView(getContext());
tv.setText(title.toUpperCase());
tv.setTextSize(11);
tv.setTextColor(COLOR_ACCENT);
// Letter spacing might not be available in all ModernUI versions, but let's try if it exists or just skip
var p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
p.topMargin = dp(24);
p.bottomMargin = dp(8);
p.leftMargin = dp(4);
parent.addView(tv, p);
}
protected LinearLayout createSettingCard(String title, String description) {
LinearLayout card = new LinearLayout(getContext());
card.setOrientation(LinearLayout.HORIZONTAL);
card.setGravity(Gravity.CENTER_VERTICAL);
card.setPadding(dp(16), dp(12), dp(16), dp(12));
card.setBackground(makeRoundedBg(COLOR_CARD, 12));
var cardParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
cardParams.bottomMargin = dp(8);
card.setLayoutParams(cardParams);
LinearLayout textLayout = new LinearLayout(getContext());
textLayout.setOrientation(LinearLayout.VERTICAL);
var textParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f);
card.addView(textLayout, textParams);
TextView titleView = new TextView(getContext());
titleView.setText(title);
titleView.setTextSize(15);
titleView.setTextColor(0xFFFFFFFF);
textLayout.addView(titleView);
if (description != null) {
TextView descView = new TextView(getContext());
descView.setText(description);
descView.setTextSize(12);
descView.setTextColor(0xFF888888);
textLayout.addView(descView);
}
return card;
}
protected ShapeDrawable makeRoundedBg(int color, float radius) {
ShapeDrawable d = new ShapeDrawable();
d.setCornerRadius(dp(radius));
d.setColor(color);
return d;
}
@Override @Override
public void onViewCreated(View view, icyllis.modernui.util.DataSet savedInstanceState) { public void onViewCreated(View view, icyllis.modernui.util.DataSet savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
view.setAlpha(0); view.setAlpha(0);
view.setTranslationY(dp(20)); view.setTranslationY(dp(10));
ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1).setDuration(400).start(); ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1).setDuration(400).start();
ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, dp(20), 0).setDuration(400).start(); ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, dp(10), 0).setDuration(400).start();
} }
} }
@@ -1,5 +1,4 @@
package de.winniepat.parrotmod.ui; package de.winniepat.parrotmod.ui;
import de.winniepat.parrotmod.config.ConfigManager; import de.winniepat.parrotmod.config.ConfigManager;
import icyllis.modernui.util.DataSet; import icyllis.modernui.util.DataSet;
import icyllis.modernui.view.LayoutInflater; import icyllis.modernui.view.LayoutInflater;
@@ -7,60 +6,57 @@ import icyllis.modernui.view.View;
import icyllis.modernui.view.ViewGroup; import icyllis.modernui.view.ViewGroup;
import icyllis.modernui.widget.LinearLayout; import icyllis.modernui.widget.LinearLayout;
import icyllis.modernui.widget.Switch; import icyllis.modernui.widget.Switch;
import icyllis.modernui.widget.TextView; import icyllis.modernui.widget.ScrollView;
import icyllis.modernui.view.Gravity;
public class DiscordTabFragment extends BaseTabFragment { public class DiscordTabFragment extends BaseTabFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) { public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
ScrollView scrollView = new ScrollView(getContext());
scrollView.setFillViewport(true);
LinearLayout layout = new LinearLayout(getContext()); LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL); layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(dp(20), dp(20), dp(20), dp(20)); layout.setPadding(dp(24), dp(8), dp(24), dp(24));
scrollView.addView(layout);
addSwitch(layout, "Enable DiscordRPC", ConfigManager.getInstance().enableDiscordRPC, (v, checked) -> { addSectionHeader(layout, "Discord Integration");
addSwitchRow(layout, "Enable DiscordRPC", "Show your game status on Discord",
ConfigManager.getInstance().enableDiscordRPC, (v, checked) -> {
ConfigManager.getInstance().enableDiscordRPC = checked; ConfigManager.getInstance().enableDiscordRPC = checked;
ConfigManager.save(); ConfigManager.save();
}); });
addSwitch(layout, "Show Biome in RPC", ConfigManager.getInstance().showBiomeInRPC, (v, checked) -> { addSectionHeader(layout, "RPC Details");
addSwitchRow(layout, "Show Biome", "Display current biome in status",
ConfigManager.getInstance().showBiomeInRPC, (v, checked) -> {
ConfigManager.getInstance().showBiomeInRPC = checked; ConfigManager.getInstance().showBiomeInRPC = checked;
ConfigManager.save(); ConfigManager.save();
}); });
addSwitch(layout, "Show Held Item in RPC", ConfigManager.getInstance().showHeldItemInRPC, (v, checked) -> { addSwitchRow(layout, "Show Held Item", "Display what you are holding",
ConfigManager.getInstance().showHeldItemInRPC, (v, checked) -> {
ConfigManager.getInstance().showHeldItemInRPC = checked; ConfigManager.getInstance().showHeldItemInRPC = checked;
ConfigManager.save(); ConfigManager.save();
}); });
addSwitch(layout, "Show Health in RPC", ConfigManager.getInstance().showHealthInRPC, (v, checked) -> { addSwitchRow(layout, "Show Health", "Display your current HP",
ConfigManager.getInstance().showHealthInRPC, (v, checked) -> {
ConfigManager.getInstance().showHealthInRPC = checked; ConfigManager.getInstance().showHealthInRPC = checked;
ConfigManager.save(); ConfigManager.save();
}); });
return layout; return scrollView;
} }
private void addSwitch(LinearLayout parent, String label, boolean checked, Switch.OnCheckedChangeListener listener) { private void addSwitchRow(LinearLayout parent, String title, String desc, boolean checked, Switch.OnCheckedChangeListener listener) {
LinearLayout row = new LinearLayout(getContext()); LinearLayout card = createSettingCard(title, desc);
row.setOrientation(LinearLayout.HORIZONTAL);
row.setGravity(Gravity.CENTER_VERTICAL);
var rowParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
rowParams.bottomMargin = dp(12);
row.setLayoutParams(rowParams);
TextView tv = new TextView(getContext());
tv.setText(label);
tv.setTextSize(15);
tv.setTextColor(0xFFEEEEEE);
var labelParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f);
row.addView(tv, labelParams);
Switch s = new Switch(getContext()); Switch s = new Switch(getContext());
s.setChecked(checked); s.setChecked(checked);
s.setOnCheckedChangeListener(listener); s.setOnCheckedChangeListener(listener);
row.addView(s); card.addView(s);
parent.addView(card);
parent.addView(row);
} }
} }
@@ -15,23 +15,26 @@ public class GeneralTabFragment extends BaseTabFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) { public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
LinearLayout layout = new LinearLayout(getContext()); LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL); layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(dp(20), dp(20), dp(20), dp(20)); layout.setPadding(dp(24), dp(8), dp(24), dp(24));
layout.addView(makeLabel("Minecraft Version: " + Minecraft.getInstance().getLaunchedVersion())); addSectionHeader(layout, "Client Info");
layout.addView(createSettingCard("Minecraft Version", Minecraft.getInstance().getLaunchedVersion()));
addSectionHeader(layout, "Config Management");
LinearLayout reloadCard = createSettingCard("Reload Config", "Reset all settings to saved values");
Button reloadBtn = new Button(getContext()); Button reloadBtn = new Button(getContext());
reloadBtn.setText("Reload Config"); reloadBtn.setText("Reload");
reloadBtn.setOnClickListener(v -> ConfigManager.load()); reloadBtn.setOnClickListener(v -> ConfigManager.load());
var p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); reloadCard.addView(reloadBtn);
p.topMargin = dp(24); layout.addView(reloadCard);
layout.addView(reloadBtn, p);
LinearLayout saveCard = createSettingCard("Save Config", "Persist current settings to disk");
Button saveBtn = new Button(getContext()); Button saveBtn = new Button(getContext());
saveBtn.setText("Save Config"); saveBtn.setText("Save");
saveBtn.setOnClickListener(v -> ConfigManager.save()); saveBtn.setOnClickListener(v -> ConfigManager.save());
var p2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); saveCard.addView(saveBtn);
p2.topMargin = dp(12); layout.addView(saveCard);
layout.addView(saveBtn, p2);
return layout; return layout;
} }
@@ -5,6 +5,7 @@ import icyllis.modernui.view.LayoutInflater;
import icyllis.modernui.view.View; import icyllis.modernui.view.View;
import icyllis.modernui.view.ViewGroup; import icyllis.modernui.view.ViewGroup;
import icyllis.modernui.widget.LinearLayout; import icyllis.modernui.widget.LinearLayout;
import icyllis.modernui.widget.ScrollView;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -12,31 +13,34 @@ public class InfoTabFragment extends BaseTabFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) { public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
ScrollView scrollView = new ScrollView(getContext());
scrollView.setFillViewport(true);
LinearLayout layout = new LinearLayout(getContext()); LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL); layout.setOrientation(LinearLayout.VERTICAL);
layout.setPadding(dp(20), dp(20), dp(20), dp(20)); layout.setPadding(dp(24), dp(8), dp(24), dp(24));
scrollView.addView(layout);
addSectionHeader(layout, "Mod Versions");
String parrotVersion = FabricLoader.getInstance().getModContainer("parrotmod").orElseThrow().getMetadata().getVersion().getFriendlyString(); String parrotVersion = FabricLoader.getInstance().getModContainer("parrotmod").orElseThrow().getMetadata().getVersion().getFriendlyString();
layout.addView(makeLabel("Parrotmod version: " + parrotVersion)); layout.addView(createSettingCard("Parrotmod", parrotVersion));
String mcVersion = FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion().getFriendlyString(); String mcVersion = FabricLoader.getInstance().getModContainer("minecraft").orElseThrow().getMetadata().getVersion().getFriendlyString();
layout.addView(makeLabel("Minecraft Version: " + Minecraft.getInstance().getLaunchedVersion() + " (" + mcVersion + ")")); layout.addView(createSettingCard("Minecraft", Minecraft.getInstance().getLaunchedVersion() + " (" + mcVersion + ")"));
String loaderVersion = FabricLoader.getInstance().getModContainer("fabricloader").orElseThrow().getMetadata().getVersion().getFriendlyString(); String loaderVersion = FabricLoader.getInstance().getModContainer("fabricloader").orElseThrow().getMetadata().getVersion().getFriendlyString();
layout.addView(makeLabel("Fabric Loader Version: " + loaderVersion)); layout.addView(createSettingCard("Fabric Loader", loaderVersion));
int modCount = FabricLoader.getInstance().getAllMods().size(); addSectionHeader(layout, "System Info");
layout.addView(makeLabel("Loaded Mods: " + modCount)); layout.addView(createSettingCard("Java", System.getProperty("java.version") + " (" + System.getProperty("os.arch") + ")"));
layout.addView(createSettingCard("OS", System.getProperty("os.name") + " (" + System.getProperty("os.version") + ")"));
layout.addView(makeLabel("Java Version: " + System.getProperty("java.version") + " (" + System.getProperty("os.arch") + ")"));
layout.addView(makeLabel("OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ")"));
long maxMemory = Runtime.getRuntime().maxMemory(); long maxMemory = Runtime.getRuntime().maxMemory();
long totalMemory = Runtime.getRuntime().totalMemory(); long totalMemory = Runtime.getRuntime().totalMemory();
long freeMemory = Runtime.getRuntime().freeMemory(); long freeMemory = Runtime.getRuntime().freeMemory();
long usedMemory = totalMemory - freeMemory; long usedMemory = totalMemory - freeMemory;
layout.addView(makeLabel(String.format("Memory: %dMB / %dMB", usedMemory / 1024 / 1024, maxMemory / 1024 / 1024))); layout.addView(createSettingCard("Memory Usage", String.format("%dMB / %dMB", usedMemory / 1024 / 1024, maxMemory / 1024 / 1024)));
return layout; return scrollView;
} }
} }
@@ -8,47 +8,71 @@ import icyllis.modernui.view.*;
import icyllis.modernui.widget.*; import icyllis.modernui.widget.*;
import icyllis.modernui.graphics.drawable.ShapeDrawable; import icyllis.modernui.graphics.drawable.ShapeDrawable;
import icyllis.modernui.graphics.*; import icyllis.modernui.graphics.*;
import net.fabricmc.loader.api.FabricLoader;
public class SettingsFragment extends Fragment { public class SettingsFragment extends Fragment {
private static final int COLOR_BACKGROUND = 0xFF0F0F13;
private static final int COLOR_SIDEBAR = 0xFF15151B;
private static final int COLOR_ACCENT = 0xFF00E5FF;
private static final int COLOR_TEXT_DIM = 0xFFAAAAAA;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceState) {
LinearLayout root = new LinearLayout(getContext()); // Main container with shadow/margin if needed, but here it's centering
root.setOrientation(LinearLayout.HORIZONTAL); FrameLayout root = new FrameLayout(getContext());
root.setLayoutParams(new FrameLayout.LayoutParams( root.setLayoutParams(new FrameLayout.LayoutParams(dp(720), dp(480), Gravity.CENTER));
dp(700), dp(450), Gravity.CENTER));
root.setAlpha(0); // Background
root.setScaleX(0.95f); View bg = new View(getContext());
root.setScaleY(0.95f); bg.setBackground(makeRoundedBg(COLOR_BACKGROUND, 16));
ObjectAnimator.ofFloat(root, View.ALPHA, 0, 1).setDuration(400).start(); root.addView(bg);
ObjectAnimator.ofFloat(root, View.SCALE_X, 0.95f, 1).setDuration(400).start();
ObjectAnimator.ofFloat(root, View.SCALE_Y, 0.95f, 1).setDuration(400).start();
LinearLayout sidebar = new LinearLayout(getContext()); LinearLayout layout = new LinearLayout(getContext());
sidebar.setOrientation(LinearLayout.VERTICAL); layout.setOrientation(LinearLayout.HORIZONTAL);
sidebar.setPadding(dp(12), dp(16), dp(12), dp(16)); root.addView(layout);
sidebar.setBackground(makeRoundedBg(0xEE161625));
// Sidebar Container
FrameLayout sidebarContainer = new FrameLayout(getContext());
var sidebarParams = new LinearLayout.LayoutParams(dp(170), ViewGroup.LayoutParams.MATCH_PARENT);
layout.addView(sidebarContainer, sidebarParams);
View sidebarBg = new View(getContext());
sidebarBg.setBackground(makeRoundedBg(COLOR_SIDEBAR, 16));
// We only want right side to be sharp, but for simplicity we just overlap or use a large radius
sidebarContainer.addView(sidebarBg);
LinearLayout sidebarContent = new LinearLayout(getContext());
sidebarContent.setOrientation(LinearLayout.VERTICAL);
sidebarContent.setPadding(0, dp(24), 0, dp(16)); // Removed horizontal padding to allow edge indicator
sidebarContainer.addView(sidebarContent, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
TextView title = new TextView(getContext()); TextView title = new TextView(getContext());
title.setText("ParrotMod"); title.setText("PARROT");
title.setTextSize(20); title.setTextSize(22);
title.setGravity(Gravity.CENTER); title.setGravity(Gravity.CENTER);
title.setTextColor(0xFFFFFFFF); title.setTextColor(COLOR_ACCENT);
title.setPadding(0, 0, 0, dp(20)); title.setPadding(dp(16), 0, dp(16), dp(32)); // Added horizontal padding back to title
sidebar.addView(title); sidebarContent.addView(title);
var sidebarParams = new LinearLayout.LayoutParams(dp(160), ViewGroup.LayoutParams.MATCH_PARENT); // Tabs container
root.addView(sidebar, sidebarParams); FrameLayout tabsContainer = new FrameLayout(getContext());
sidebarContent.addView(tabsContainer, new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
LinearLayout tabsLayout = new LinearLayout(getContext());
tabsLayout.setOrientation(LinearLayout.VERTICAL);
// Center tabs vertically in available space
tabsContainer.addView(tabsLayout, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));
// Content Area
FrameLayout contentArea = new FrameLayout(getContext()); FrameLayout contentArea = new FrameLayout(getContext());
contentArea.setId(R.id.content); contentArea.setId(R.id.content);
contentArea.setBackground(makeRoundedBg(0xEE101018)); var contentParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1f);
layout.addView(contentArea, contentParams);
var contentParams = new LinearLayout.LayoutParams(
0, ViewGroup.LayoutParams.MATCH_PARENT, 1f);
contentParams.leftMargin = dp(6);
root.addView(contentArea, contentParams);
String[] tabNames = {"Info", "General", "Discord"}; String[] tabNames = {"Info", "General", "Discord"};
Fragment[] tabFragments = { Fragment[] tabFragments = {
@@ -57,46 +81,60 @@ public class SettingsFragment extends Fragment {
new DiscordTabFragment() new DiscordTabFragment()
}; };
getChildFragmentManager().beginTransaction() Button[] tabButtons = new Button[tabNames.length];
.replace(contentArea.getId(), tabFragments[0])
.commitNow();
Button[] tabs = new Button[tabNames.length];
for (int i = 0; i < tabNames.length; i++) { for (int i = 0; i < tabNames.length; i++) {
final int index = i; final int index = i;
Button tab = new Button(getContext()); Button tab = new Button(getContext());
tab.setText(tabNames[index]); tab.setText(tabNames[index]);
tab.setTextSize(15); tab.setTextSize(14);
tab.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); tab.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
tab.setPadding(dp(16), dp(8), dp(16), dp(8)); tab.setPadding(dp(32), 0, dp(16), 0);
tab.setBackground(null); tab.setBackground(null);
tab.setTextColor(COLOR_TEXT_DIM);
tab.setOnClickListener(v -> { tab.setOnClickListener(v -> {
getChildFragmentManager().beginTransaction() getChildFragmentManager().beginTransaction()
.setReorderingAllowed(true) .setReorderingAllowed(true)
.replace(contentArea.getId(), tabFragments[index]) .replace(contentArea.getId(), tabFragments[index])
.commit(); .commit();
for (Button b : tabs) {
b.setTextColor(0xFFAAAAAA); for (int j = 0; j < tabButtons.length; j++) {
b.setBackground(null); boolean selected = (j == index);
tabButtons[j].setTextColor(selected ? 0xFFFFFFFF : COLOR_TEXT_DIM);
tabButtons[j].setBackground(selected ? makeRoundedBg(0x12FFFFFF, 8) : null);
} }
tab.setTextColor(0xFFFFFFFF);
tab.setBackground(makeRoundedBg(0x33FFFFFF));
}); });
var tabParams = new LinearLayout.LayoutParams( var tabParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp(44));
ViewGroup.LayoutParams.MATCH_PARENT, dp(40)); tabParams.bottomMargin = dp(4);
tabParams.bottomMargin = dp(8); tabsLayout.addView(tab, tabParams);
sidebar.addView(tab, tabParams); tabButtons[index] = tab;
tabs[index] = tab;
} }
tabs[0].setTextColor(0xFFFFFFFF); // Footer
tabs[0].setBackground(makeRoundedBg(0x33FFFFFF)); TextView footer = new TextView(getContext());
for (int i = 1; i < tabs.length; i++) { String version = FabricLoader.getInstance().getModContainer("parrotmod")
tabs[i].setTextColor(0xFFAAAAAA); .map(m -> m.getMetadata().getVersion().getFriendlyString()).orElse("?.?.?");
tabs[i].setBackground(null); footer.setText("ParrotMod v" + version);
} footer.setTextSize(11);
footer.setTextColor(0x44FFFFFF);
footer.setGravity(Gravity.CENTER);
footer.setPadding(dp(16), dp(12), dp(16), dp(12));
sidebarContent.addView(footer);
// Entrance Animation
root.setAlpha(0);
root.setScaleX(0.96f);
root.setScaleY(0.96f);
ObjectAnimator.ofFloat(root, View.ALPHA, 0, 1).setDuration(450).start();
ObjectAnimator.ofFloat(root, View.SCALE_X, 0.96f, 1).setDuration(450).start();
ObjectAnimator.ofFloat(root, View.SCALE_Y, 0.96f, 1).setDuration(450).start();
// Initial tab
root.post(() -> {
tabButtons[0].callOnClick();
});
return root; return root;
} }
@@ -105,9 +143,9 @@ public class SettingsFragment extends Fragment {
return (int) (dp * getContext().getResources().getDisplayMetrics().density); return (int) (dp * getContext().getResources().getDisplayMetrics().density);
} }
private ShapeDrawable makeRoundedBg(int color) { private ShapeDrawable makeRoundedBg(int color, float radius) {
ShapeDrawable d = new ShapeDrawable(); ShapeDrawable d = new ShapeDrawable();
d.setCornerRadius(dp(12)); d.setCornerRadius(dp(radius));
d.setColor(color); d.setColor(color);
return d; return d;
} }