From 6035ecaf1ace2dea9bf2f6f8c5ed8c3876528ce6 Mon Sep 17 00:00:00 2001 From: cuj1559 Date: Sat, 8 Apr 2023 19:02:03 +0900 Subject: [PATCH] Minimize other item when one item is selected at Plugin app list --- .../main/ui/prefs/custom/PluginFragment.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/noti/main/ui/prefs/custom/PluginFragment.java b/app/src/main/java/com/noti/main/ui/prefs/custom/PluginFragment.java index c71f1b1..d7c7bf5 100644 --- a/app/src/main/java/com/noti/main/ui/prefs/custom/PluginFragment.java +++ b/app/src/main/java/com/noti/main/ui/prefs/custom/PluginFragment.java @@ -45,6 +45,7 @@ public class PluginFragment extends Fragment { AppCompatActivity mContext; + ArrayList pluginAppHolderArrayList = new ArrayList<>(); @Override public void onAttach(@NonNull Context context) { @@ -108,6 +109,13 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat taskerActionMenuLayout.setVisibility(View.GONE); taskerPluginParent.setOnClickListener(v -> { boolean isDetailGone = taskerActionMenuLayout.getVisibility() == View.GONE; + + if(isDetailGone) { + for(PluginAppHolder holder1 : pluginAppHolderArrayList) { + setDetailVisibility(holder1, false); + } + } + taskerActionMenuLayout.setVisibility(isDetailGone ? View.VISIBLE : View.GONE); taskerDescriptionText.setSingleLine(!isDetailGone); }); @@ -172,10 +180,17 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat holder.pluginEnabled.setOnCheckedChangeListener((buttonView, isChecked) -> pluginPrefs.setPluginEnabled(isChecked).apply()); holder.pluginActionMenuLayout.setVisibility(View.GONE); holder.Parent.setOnClickListener((v) -> { - boolean isDetailGone = holder.pluginActionMenuLayout.getVisibility() == View.GONE; - holder.pluginActionMenuLayout.setVisibility(isDetailGone ? View.VISIBLE : View.GONE); - holder.pluginTitle.setSingleLine(!isDetailGone); - holder.pluginDescription.setSingleLine(!isDetailGone); + boolean isVisible = holder.pluginActionMenuLayout.getVisibility() == View.VISIBLE; + if(!isVisible) { + taskerActionMenuLayout.setVisibility(View.GONE); + taskerDescriptionText.setSingleLine(true); + + for(PluginAppHolder holder1 : pluginAppHolderArrayList) { + setDetailVisibility(holder1, false); + } + } + + setDetailVisibility(holder, !isVisible); }); holder.settingButton.setOnClickListener((v) -> startActivity(new Intent().setComponent(new ComponentName(packageName, data.getString(PluginConst.PLUGIN_SETTING_ACTIVITY))))); holder.infoButton.setOnClickListener((v) -> startActivity(new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(Uri.parse("package:" + packageName)))); @@ -183,10 +198,17 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat e.printStackTrace(); } + pluginAppHolderArrayList.add(holder); pluginListLayout.addView(layout); }; } + void setDetailVisibility(PluginAppHolder holder, boolean isVisible) { + holder.pluginActionMenuLayout.setVisibility(isVisible ? View.VISIBLE : View.GONE); + holder.pluginTitle.setSingleLine(!isVisible); + holder.pluginDescription.setSingleLine(!isVisible); + } + void loadPluginList(PackageManager packageManager) { Intent intent = new Intent(PluginConst.RECEIVER_ACTION_NAME); List listApps;