瀏覽代碼

Restore using radiolist

Bob Mottram 8 年之前
父節點
當前提交
d527e86c84
共有 1 個檔案被更改,包括 48 行新增64 行删除
  1. 48
    64
      src/freedombone-controlpanel

+ 48
- 64
src/freedombone-controlpanel 查看文件

@@ -937,80 +937,64 @@ function restore_data_from_storage {
937 937
 
938 938
     choices=$(dialog --stdout --backtitle $"Freedombone" \
939 939
                      --title $"Restore apps" \
940
-                     --checklist $'Choose:' \
940
+                     --radiolist $'Choose:' \
941 941
                      30 40 20 $applist)
942 942
 
943
-    if [ $? -eq 0 ]; then
944
-        clear
943
+    sel=$?
944
+    case $sel in
945
+        1) return;;
946
+        255) return;;
947
+    esac
948
+    app_name=$(cat $data)
945 949
 
946
-        # Test for exit
947
-        for choice in $choices
948
-        do
949
-            app_index=$[choice-1]
950
-            app_name=${app_list[app_index]}
951
-            if [[ $app_name == "$ExitStr" ]]; then
952
-                return
953
-            fi
954
-        done
955
-
956
-        # Test for restoring all apps
957
-        for choice in $choices
958
-        do
959
-            app_index=$[choice-2]
960
-            app_name=${app_list[app_index]}
961
-            if [[ $app_name == "$AllStr" ]]; then
962
-                $restore_command
963
-                retcode="$?"
964
-                if [[ "$retcode" != "0" ]]; then
965
-                    if [[ "$1" == "local" ]]; then
966
-                        dialog --title $"Restore all apps from USB" \
967
-                               --msgbox $"Restore failed with code $retcode" 6 60
968
-                    else
969
-                        dialog --title $"Restore all apps from $1" \
970
-                               --msgbox $"Restore failed with code $retcode" 6 60
971
-                    fi
972
-                    return
973
-                fi
950
+    # exit
951
+    if [[ $app_name == "$ExitStr" ]]; then
952
+        return
953
+    fi
974 954
 
975
-                if [[ "$1" == "local" ]]; then
976
-                    dialog --title $"Restore all apps from USB" \
977
-                           --msgbox $"Restore complete" 6 40
978
-                else
979
-                    dialog --title $"Restore all apps from $1" \
980
-                           --msgbox $"Restore complete" 6 40
981
-                fi
982
-                return
983
-            fi
984
-        done
985
-
986
-        ctr=0
987
-        for choice in $choices
988
-        do
989
-            app_index=$[choice-2]
990
-            app_name=${app_list[app_index]}
991
-            if [ ${#app_name} -gt 0 ]; then
992
-                $restore_command "${app_name}"
993
-                retcode="$?"
994
-                if [[ "$retcode" != "0" ]]; then
995
-                    dialog --title $"Restore apps from USB" \
996
-                           --msgbox $"Restore of ${app_name} failed with code $retcode" 6 60
997
-                    return
998
-                fi
999
-            fi
1000
-            ctr=$((ctr + 1))
1001
-        done
1002
-        if [ $ctr -gt 0 ]; then
955
+    # Restore all
956
+    if [[ $app_name == "$AllStr" ]]; then
957
+        clear
958
+        $restore_command
959
+        retcode="$?"
960
+        if [[ "$retcode" != "0" ]]; then
1003 961
             if [[ "$1" == "local" ]]; then
1004
-                dialog --title $"Restore apps from USB" \
1005
-                       --msgbox $"Restore complete" 6 40
962
+                dialog --title $"Restore all apps from USB" \
963
+                       --msgbox $"Restore failed with code $retcode" 6 60
1006 964
             else
1007
-                dialog --title $"Restore apps from $1" \
1008
-                       --msgbox $"Restore complete" 6 40
965
+                dialog --title $"Restore all apps from $1" \
966
+                       --msgbox $"Restore failed with code $retcode" 6 60
1009 967
             fi
1010 968
             return
1011 969
         fi
970
+
971
+        if [[ "$1" == "local" ]]; then
972
+            dialog --title $"Restore all apps from USB" \
973
+                   --msgbox $"Restore complete" 6 40
974
+        else
975
+            dialog --title $"Restore all apps from $1" \
976
+                   --msgbox $"Restore complete" 6 40
977
+        fi
978
+        return
979
+    fi
980
+
981
+    # Restore an app
982
+    $restore_command "${app_name}"
983
+    retcode="$?"
984
+    if [[ "$retcode" != "0" ]]; then
985
+        dialog --title $"Restore apps from USB" \
986
+               --msgbox $"Restore of ${app_name} failed with code $retcode" 6 60
987
+        return
988
+    fi
989
+
990
+    # finished
991
+    if [[ "$1" == "local" ]]; then
992
+        dialog --title $"Restore apps from USB" \
993
+               --msgbox $"Restore complete" 6 40
994
+    else
995
+        dialog --title $"Restore apps from $1" \
996
+               --msgbox $"Restore complete" 6 40
1012 997
     fi
1013
-    any_key
1014 998
 }
1015 999
 
1016 1000
 function restore_data {