Quellcode durchsuchen

Better implementation of selecting all apps

Bob Mottram vor 8 Jahren
Ursprung
Commit
5edcf011f4
1 geänderte Dateien mit 11 neuen und 29 gelöschten Zeilen
  1. 11
    29
      src/freedombone-addremove

+ 11
- 29
src/freedombone-addremove Datei anzeigen

@@ -56,12 +56,13 @@ do
56 56
 done
57 57
 
58 58
 function show_apps {
59
+    select_all_apps=$1
59 60
     applist=""
60 61
     n=1
61 62
     app_index=0
62 63
     for a in "${APPS_AVAILABLE[@]}"
63 64
     do
64
-        if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
65
+        if [[ ${APPS_INSTALLED[$app_index]} == "0" &&  "$select_all_apps" != "add-all" ]]; then
65 66
             applist="$applist $n $a off"
66 67
         else
67 68
             applist="$applist $n $a on"
@@ -130,33 +131,14 @@ function remove_apps_selected {
130 131
 }
131 132
 
132 133
 function install_apps_selected {
133
-    select_all_apps=$1
134 134
     # which apps need to be installed?
135 135
     installs=""
136 136
     app_index=0
137 137
     n=0
138
-
139
-    if [ ! $select_all_apps ]; then
140
-        for a in "${APPS_INSTALLED[@]}"
141
-        do
142
-            if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
143
-                if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
144
-                    if [ ${n} -gt 0 ]; then
145
-                        installs="$installs ${APPS_AVAILABLE[$app_index]}"
146
-                    else
147
-                        installs="${APPS_AVAILABLE[$app_index]}"
148
-                    fi
149
-                    n=$[n+1]
150
-                fi
151
-            fi
152
-            app_index=$[app_index+1]
153
-        done
154
-    fi
155
-
156
-    if [[ $select_all_apps == "add-all" ]]; then
157
-        for a in "${APPS_INSTALLED[@]}"
158
-        do
159
-            if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
138
+    for a in "${APPS_INSTALLED[@]}"
139
+    do
140
+        if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
141
+            if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
160 142
                 if [ ${n} -gt 0 ]; then
161 143
                     installs="$installs ${APPS_AVAILABLE[$app_index]}"
162 144
                 else
@@ -164,10 +146,9 @@ function install_apps_selected {
164 146
                 fi
165 147
                 n=$[n+1]
166 148
             fi
167
-            APPS_CHOSEN[$app_index]="1"
168
-            app_index=$[app_index+1]
169
-        done
170
-    fi
149
+        fi
150
+        app_index=$[app_index+1]
151
+    done
171 152
 
172 153
     # if no apps to be installed then don't do anything
173 154
     if [ ${n} -eq 0 ]; then
@@ -206,11 +187,12 @@ if [[ ${#APPS_AVAILABLE[@]} == 0 ]]; then
206 187
     exit 1
207 188
 fi
208 189
 
209
-show_apps
190
+show_apps $1
210 191
 
211 192
 clear
212 193
 
213 194
 remove_apps_selected
195
+
214 196
 if [[ $1 == "add-all" ]]; then
215 197
     install_apps_selected add-all
216 198
 else