Skip to content

Commit

Permalink
Minimize other item when one item is selected at Plugin app list
Browse files Browse the repository at this point in the history
  • Loading branch information
choiman1559 committed Apr 8, 2023
1 parent 4329373 commit 6035eca
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

public class PluginFragment extends Fragment {
AppCompatActivity mContext;
ArrayList<PluginAppHolder> pluginAppHolderArrayList = new ArrayList<>();

@Override
public void onAttach(@NonNull Context context) {
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -172,21 +180,35 @@ 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))));
} catch (PackageManager.NameNotFoundException e) {
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<ResolveInfo> listApps;
Expand Down

0 comments on commit 6035eca

Please sign in to comment.