From f087bc526010d57b99b51635bedb2177c76aaa72 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Sun, 3 Nov 2024 16:24:11 -0500 Subject: [PATCH] Hide "Edit Theme" and "Change Name" options if the online theme is not created by the current user. --- ...CustomThemeOptionsBottomSheetFragment.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java index ffd68c93f5..a0e09c8f33 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java @@ -49,12 +49,22 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, themeName = getArguments().getString(EXTRA_THEME_NAME); onlineCustomThemeMetadata = getArguments().getParcelable(EXTRA_ONLINE_CUSTOM_THEME_METADATA); - binding.themeNameTextViewCustomThemeOptionsBottomSheetFragment.setText(themeName); + if (onlineCustomThemeMetadata != null && !onlineCustomThemeMetadata.username.equals(activity.accountName)) { + binding.editThemeTextViewCustomThemeOptionsBottomSheetFragment.setVisibility(View.GONE); + binding.changeThemeNameTextViewCustomThemeOptionsBottomSheetFragment.setVisibility(View.GONE); + } else { + binding.editThemeTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { + ((CustomThemeOptionsBottomSheetFragmentListener) activity).editTheme(themeName, onlineCustomThemeMetadata, getArguments().getInt(EXTRA_INDEX_IN_THEME_LIST, -1)); + dismiss(); + }); + + binding.changeThemeNameTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { + ((CustomThemeOptionsBottomSheetFragmentListener) activity).changeName(themeName); + dismiss(); + }); + } - binding.editThemeTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { - ((CustomThemeOptionsBottomSheetFragmentListener) activity).editTheme(themeName, onlineCustomThemeMetadata, getArguments().getInt(EXTRA_INDEX_IN_THEME_LIST, -1)); - dismiss(); - }); + binding.themeNameTextViewCustomThemeOptionsBottomSheetFragment.setText(themeName); binding.shareThemeTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { if (onlineCustomThemeMetadata != null) { @@ -65,11 +75,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, dismiss(); }); - binding.changeThemeNameTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { - ((CustomThemeOptionsBottomSheetFragmentListener) activity).changeName(themeName); - dismiss(); - }); - binding.deleteThemeTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { ((CustomThemeOptionsBottomSheetFragmentListener) activity).delete(themeName); dismiss();