Allow phone number find in send text submenu

This allow the user to use a non formated phone number. We
split valid number check in a dedicated script to allow this.
master
Stacy Harper 3 years ago
parent 55985a8f20
commit 87d86b7cf0
No known key found for this signature in database
GPG Key ID: EABA44759877E02A
  1. 25
      scripts/core/sxmo_contactmenu.sh
  2. 25
      scripts/core/sxmo_validnumber.sh
  3. 8
      scripts/modem/sxmo_modemtext.sh

@ -3,29 +3,6 @@
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
valid_number() {
if pn valid "$1"; then
echo "$1"
return
fi
REFORMATTED="$(pn find ${DEFAULT_COUNTRY:+-c "$DEFAULT_COUNTRY"} "$1")"
if pn valid "$REFORMATTED"; then
echo "$REFORMATTED"
return
fi
notify-send "\"$1\" is not a valid phone number"
PICKED="$(printf "Ok\nUse as it is\n" | dmenu -p "Invalid Number")"
if [ "$PICKED" = "Use as it is" ]; then
echo "$1"
return
fi
exit
}
newcontact() {
name="$(echo | sxmo_dmenu_with_kb.sh -p "$icon_usr Name")"
number=
@ -72,7 +49,7 @@ editcontactnumber() {
editcontact "$1"
return
fi
PICKED="$(valid_number "$PICKED")"
PICKED="$(sxmo_validnumber.sh "$PICKED")"
done
newcontact="$PICKED $oldname"

@ -0,0 +1,25 @@
#!/usr/bin/env sh
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
if pn valid "$1"; then
printf %s "$1"
exit
fi
REFORMATTED="$(pn find ${DEFAULT_COUNTRY:+-c "$DEFAULT_COUNTRY"} "$1")"
if pn valid "$REFORMATTED"; then
printf %s "$REFORMATTED"
exit
fi
notify-send "\"$1\" is not a valid phone number"
PICKED="$(printf "Ok\nUse as it is\n" | sxmo_dmenu.sh -p "Invalid Number")"
if [ "$PICKED" = "Use as it is" ]; then
printf %s "$1"
exit
fi
exit 1

@ -29,12 +29,12 @@ choosenumbermenu() {
)"
fi
if echo "$NUMBER" | grep -q "Cancel"; then
if printf %s "$NUMBER" | grep -q "Cancel"; then
exit 1
elif ! echo "$NUMBER" | grep -qE '^[+0-9]+$'; then
notify-send "That doesn't seem like a valid number"
elif NUMBER="$(sxmo_validnumber.sh "$NUMBER")"; then
printf %s "$NUMBER"
else
echo "$NUMBER"
notify-send "That doesn't seem like a valid number"
fi
}

Loading…
Cancel
Save