Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding Gabor Szabo's scripts

  • Loading branch information...
commit 2d5d4d447b3d54c6d601c751a148150fac1cd435 1 parent b7746ca
@xsawyerx authored
View
7 scriptlets/01_hello_world.pl
@@ -0,0 +1,7 @@
+
+use strict;
+use warnings;
+
+use Android;
+my $d = Android->new();
+$d->makeToast("Hello, Android!");
View
11 scriptlets/02_android_object.pl
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+
+my $d = Android->new();
+say($d); # HASH()
+dd($d); # Android object { conn => Symbol::GEN, IO::Socket::INET, id => 0 }
+
View
14 scriptlets/MyTools.pl
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+
+use Data::Dumper;
+
+sub dd {
+ print Dumper shift;
+}
+sub say {
+ print @_, "\n";
+}
+
+1;
+
View
17 scriptlets/airplane.pl
@@ -0,0 +1,17 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+
+# Currently this script shuts down the emulator
+
+# result is JSON::PP::Boolean
+#say($d->checkAirplaneMode->{result}); # is false or true
+#say($d->toggleAirplaneMode->{result}); # returns the new mode (false or true)
+#say $d->checkAirplaneMode->{result};
+
+
View
24 scriptlets/alert_dialog.pl
@@ -0,0 +1,24 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+
+dd($d->dialogCreateAlert("the title", "text"));
+dd($d->dialogSetPositiveButtonText("good"));
+dd($d->dialogSetNegativeButtonText("bad"));
+dd($d->dialogSetNeutralButtonText("ugly"));
+dd($d->dialogShow);
+
+say("Still running");
+
+dd($d->dialogGetResponse);
+
+# This call waits for someone to press a button
+# the result is a hash with one pair. The key is "which".
+# The value is one of the following:
+# "neutral", "negative", "positive"
+
View
20 scriptlets/dialog_dismiss.pl
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+
+dd($d->dialogCreateAlert("the title", "text"));
+dd($d->dialogShow);
+
+say("Still running");
+sleep(3);
+
+dd($d->dialogDismiss); #forcibly eliminate the dialog even if it was not clicked on
+
+dd($d->dialogGetResponse);
+
+
View
11 scriptlets/getinput.pl
@@ -0,0 +1,11 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+dd($d->getInput("title", "text"));
+
+# The 'result' will contain the string the user typed in
View
21 scriptlets/gps.pl
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+dd($d->startLocating("fine", 600, 30)); #coarse
+#dd($d->startSensing);
+for (1..20) {
+
+ my $loc;
+ print "READ LOCATION:\n";
+ dd($d->readLocation);
+ print "LAST_KNOWN_LOCATION:\n";
+ dd($d->getLastKnownLocation());
+#$d->readSensors;
+ #say("Long $loc->{result}->{longitude} Lat: $loc->{result}->{latitude}");
+ sleep 2;
+}
+
View
29 scriptlets/horizontal_progress.pl
@@ -0,0 +1,29 @@
+
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+my $max = 32;
+
+$d->dialogCreateHorizontalProgress(
+ "title",
+ "message",
+ $max, # maximum progress (shows a number 0/$max)
+ 0, # boolean, cancellable (Bug: I don't see any difference if I set it to 1)
+);
+dd($d->dialogShow);
+my $n = 0;
+while ($n < $max) {
+ sleep 1;
+ $n += int rand 7;
+ $n = $n > $max ? $max : $n;
+ $d->dialogSetCurrentProgress($n);
+}
+
+dd($d->dialogDismiss);
+
+
View
13 scriptlets/location.pl
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+
+my $d = Android->new();
+my $loc = $d->getLastKnownLocation();
+dd($loc);
+say($loc->{result}->{longitude});
+# fields are provider, time, longitude, latitude, speed, accuracy, altitude
+# the provider is a string - I got 'network' the others are numbers
View
20 scriptlets/ringer_silent_mode.pl
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+
+dd($d->checkRingerSilentMode); # result is a JSON::PP::Boolean object that stringifies to "true" or "false"
+say($d->checkRingerSilentMode->{result});
+
+dd($d->toggleRingerSilentMode(1));
+say($d->checkRingerSilentMode->{result}); # true
+say($d->checkRingerSilentMode->{result} ? 'ON' : 'OFF'); # ON
+
+dd($d->toggleRingerSilentMode(0));
+say($d->checkRingerSilentMode->{result}); # false
+say($d->checkRingerSilentMode->{result} ? 'ON' : 'OFF'); # OFF
+
View
16 scriptlets/sensing_location.pl
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+
+my $d = Android->new();
+dd($d->startSensing);
+
+my $l = $d->readLocation;
+dd($l);
+
+# this gives the hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this)
+dd($d->geocode(52.5, 13.5));
+
View
13 scriptlets/speak.pl
@@ -0,0 +1,13 @@
+
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+dd($d->speak("hello Android from Perl"));
+
+say("done");
+
View
29 scriptlets/spinning_progress.pl
@@ -0,0 +1,29 @@
+
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+my $max = 32;
+
+$d->dialogCreateSpinnerProgress(
+ "title",
+ "message",
+ $max, # maximum progress (shows a number 0/$max)
+ 0, # boolean, cancellable (Bug: I don't see any difference if I set it to 1)
+);
+dd($d->dialogShow);
+my $n = 0;
+while ($n < $max) {
+ sleep 1;
+ $n += int rand 7;
+ $n = $n > $max ? $max : $n;
+ $d->dialogSetCurrentProgress($n);
+}
+
+dd($d->dialogDismiss);
+
+
View
13 scriptlets/vibrate.pl
@@ -0,0 +1,13 @@
+
+use strict;
+use warnings;
+
+require "/sdcard/ase/scripts/MyTools.pl";
+
+use Android;
+my $d = Android->new();
+
+dd($d->vibrate(10000));
+
+say("done");
+
Please sign in to comment.
Something went wrong with that request. Please try again.