Skip to content

Commit

Permalink
On boot: Disaply scripts that are set on boot
Browse files Browse the repository at this point in the history
Signed-off-by: sunilpaulmathew <sunil.kde@gmail.com>
  • Loading branch information
sunilpaulmathew committed May 1, 2020
1 parent 3fb24bc commit 5707b56
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Created by willi on 04.08.16.
Expand Down Expand Up @@ -206,10 +208,11 @@ private void load(List<RecyclerViewItem> items) {
items.addAll(profiles);
}

if (Prefs.getBoolean("scripts_onboot", false, getActivity())
&& !ScriptManager.list().isEmpty()) {
if (!ScriptManager.list().isEmpty()) {
boolean script_onboot = Prefs.getBoolean("scripts_onboot", false, getActivity());
final Set<String> onBootScripts = Prefs.getStringSet("on_boot_scripts", new HashSet<>(), getActivity());
for (final String script : ScriptManager.list()) {
if (Utils.getExtension(script).equals("sh")) {
if (script_onboot && Utils.getExtension(script).equals("sh")) {
DescriptionView scriptItems = new DescriptionView();
scriptItems.setSummary(getString(R.string.script_manger) + ": " + script);
scriptItems.setOnItemClickListener(item -> {
Expand All @@ -225,6 +228,21 @@ private void load(List<RecyclerViewItem> items) {
mDeleteDialog.show();
});

items.add(scriptItems);
} else if (Prefs.getStringSet("on_boot_scripts", new HashSet<>(), getActivity()).contains(script)
&& Utils.getExtension(script).equals("sh")) {
DescriptionView scriptItems = new DescriptionView();
scriptItems.setSummary(getString(R.string.script_manger) + ": " + script);
scriptItems.setOnItemClickListener(item -> {
mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.delete_question, script),
(dialogInterface, i) -> {
}, (dialogInterface, i) -> {
onBootScripts.remove(script);
reload();
}, dialogInterface -> mDeleteDialog = null, getActivity());
mDeleteDialog.show();
});

items.add(scriptItems);
}
}
Expand Down

0 comments on commit 5707b56

Please sign in to comment.