#!/data/data/com.google.ase/perl/perl
use strict;
use warnings;

use Android;
use Data::Dumper;

my $droid = Android->new;

## don't even ask if there are no SMS
my $n = $droid->smsGetMessageCount();
if (!$n)
{
    $droid->makeToast("You have no SMS to search through");
}

## ask regex
my $regex = '';
while (!length $regex) {
    $regex = = $droid->getInput(
        "Search SMS by regex",
        "Regex:",
    );
}

$droid->makeToast("Searching through $n SMS..");
my $ndump = 3;
for my $sms ( $droid->smsGetMessages )
{
    print "Got SMS: ", Dumper($sms);
    print '-'x30, "\n";
    $ndump--;
    if (!$ndump) {
        $droid->makeToast("DEBUG end");
        exit 1
    }
}

$droid->dialogCreateAlert($result);
$droid->dialogShow();

