[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[coco8] ScanApp and U8 - French.scc

0:00:00.000,0:00:05.960
Salut! comment êtes-vous? aujourd'hui, nous voulons examiner

0:00:04.020,0:00:09.139
à une nouvelle fonctionnalité

0:00:05.960,0:00:12.450
ajoutée à coco8. appelé ScanApp

0:00:09.139,0:00:14.309
C'est vraiment cool. ScannApp est

0:00:12.450, 00:00:16,760
une application très simple, inclus dans coco8

0:00:14.309,0:00:19.800
nous permettant, l'accès à la caméra de téléphone

0:00:16.760,0:00:21.840
pour scanner les codes QR

0:00:19.800,00:00:24.960
et utiliser le contenu

0:00:21.840,0:00:26.130
pour effectuer plusieurs activités.

0:00:24.960,0:00:27.840
pour préciser

0:00:26.130,0:00:31.220
Je voudrais vous montrer quelques exemples. En premier lieu,

0:00:27.840,0:00:33.070
Je vais faire de scanner d'une image preparée

0:00:31.220,0:00:35.829
Pour ce cas,

0:00:33.070,0:00:37.670
dont le contenu déterminera l'ouverture

0:00:35.829,0:00:43.000
d'une message box

0:00:37.670,0:00:46.050
disant #testOK. Nous ouvrons

0:00:43.000,0:00:47.780
ScanApp pointant vers l'image,

0:00:46.050,0:00:50.410
le téléphone ouvre rapidement une message box

0:00:47.780,0:00:53.199
avec le message #testOK. Dans un deuxième cas

0:00:50.410,0:00:55.670
Je vais faire de scanner une autre image dont le contenu

0:00:53.199,0:00:58.039
ouvre le navigateur de téléphone dans

0:00:55.670,0:01:01.500
le site "U8".

0:00:58.039,0:01:03.760
comme vous pouvez voir

0: 01: 01.500,0: 01: 06.240
ScanApp a des multiples

0: 01: 03.760,0: 01: 07.520
usages, mais aujourd'hui nous voulons parler

0: 01: 06.240,0: 01: 10.260
à propos, à mon avis,

0: 01: 07.520,00: 01: 13.070
est la caractéristique la plus intéressante

0: 01: 10.260,0: 01: 15.580
qui nous permet de partager notre

00: 01: 13,070,00: 01: 19,130
d'applications ou de cadres

0: 01: 15.580,0: 01: 21.439
coco8 d'une manière simple, agile et

0: 01: 19.130,0: 01: 23.820
moderne. Par exemple

0: 01: 21.439,0: 01: 26.659
je vais vous montrer une application super facile et minimal

0: 01: 23.820,0: 01: 28.200
conçu comme une démo.

0: 01: 26.659,0: 01: 30.229
Il s'agit d'une demande

0: 01: 28.200,0: 01: 33.150
nombres entiers, tests de primalité

0: 01: 30.229,00: 01: 35.409
(single ou composite). En ce moment, l'application

0: 01: 33.150,0: 01: 36.670
n'est pas installé sur mon téléphone. Je l'ai écrit,

0: 01: 35.409,0: 01: 38.950
et téléchargé sur le site U8

00: 01: 36,670,0: 01: 41,340
comme une contribution. U8 site fournit

0: 01: 38.950,0: 01: 44.399
l'image du code QR, alors quand

0: 01: 41.340,0: 01: 46.470
l'utilisateur de coco8 scanne le QR

0: 01: 44.399,0: 01: 47.310
avec ScanApp, il sera

0: 01: 46.470,0: 01: 48.630
installé sur le téléphone

0: 01: 47,310,0: 01: 52,079
et exécuté.

0: 01: 48.630,0: 01: 52.740
regarde ça. Je le signale, il est installé

0: 01: 52,079,0: 01: 57,030
puis exécuté.

0: 01: 52.740,0: 01: 58.590
Ici, nous pouvons l'essayer, nous écrivons

0: 01: 57.030,0: 02: 02.259
nombre entier

0: 01: 58.590,0: 02: 03.640
dans le même moment

0: 02: 02.259,0: 02: 05.530
les rapports de l'application

0:02:03.640,0:02:07.350
if typed number is prime

0:02:05.530,0:02:11.140
or composite.

0:02:07.350,0:02:13.670
Note that during scanning phase, the app

0:02:11.140,0:02:16.680
was found among contributions

00:02:13.670,0:02:22.040
in U8 site. It was downloaded

0:02:16.680,0:02:26.480
and executed. Right now the app is

0:02:22.040,0:02:35.680
in my phone and can be found

0:02:26.480,0:02:37.890
inside "Smalltalk run" icon.

0:02:35.680,0:02:45.910
The app was downloaded and it remains

00:02:37.890,0:02:48.569
in the phone as a part of coco8.

0:02:45.910,0:02:50.769
This is very interesting because it transforms

00:02:48.569,0:02:53.489
U8 site in a kind of store of

0:02:50.769,0:02:55.680
contributions where we can upload

0:02:53.489,0:02:57.500
our apps or frameworks and any

0:02:55.680,0:03:00.790
coco8 user can download it

0:02:57.500,0:03:04.989
simply pointing to the

0:03:00.790,0:03:11.920
QR code with ScanApp.

0:03:04.989,0:03:15.780
As you can see U8 provides the QR code

0:03:11.920,00:03:19.250
for each contribution. Now we will do a minimal

0:03:15.780,0:03:21.450
walkthrough on how to write

0:03:19.250,0:03:24.579
the demo sample app and how to publish it

0:03:21.450,0:03:26.660
as a contribution.

0:03:24.579,0:03:27.820
In this case the app

0:03:26.660,0:03:29.640
is a very simple to write.

0:03:27.820,0:03:34.060
Lets take a look

0:03:29.640,0:03:36.620
at the code.

0:03:34.060,0:03:39.349
The main class of our

0:03:36.620,0:03:42.209
app is PrimeViewController

0:03:39.349,0:03:43.760
a subclass of UIViewController

0:03:42.209,0:03:47.020
for those unfamiliar

0:03:43.760,0:03:49.569
with iOS programming, lets say

00:03:47.020,0:03:52.330
that UIViewController is a

0:03:49.569,0:03:56.330
MVC controller that works also

0:03:52.330,0:03:59.370
as a ViewManager. Lets see two

0:03:56.330,0:04:03.209
or three interesting methods in this class.

0:03:59.370,0:04:06.160
The first one is #viewDidLoad. This method is invoked

0:04:03.209,0:04:08.810
when view is recently loaded

0:04:06.160,0:04:11.160
so there, it is a good place

0:04:08.810,0:04:14.290
to define widgets and layouts

0:04:11.160,0:04:16.410
We can see the

0:04:14.290,0:04:18.620
label definition

0:04:16.410,0:04:21.489
asking for

0:04:18.620,0:04:24.540
an integer number. A text field definition

0:04:21.489,0:04:26.979
where we will type the integer number.

0:04:24.540,0:04:28.970
Another label for

0:04:26.979,0:04:31.410
showing the result of primality tests.

0:04:28.970,0:04:33.680
In other words, where it will be showed

0:04:31.410,0:04:40.050
the message saying

0:04:33.680,0:04:41.550
prime or composite.

0:04:40.050,0:04:44.870
In this method it is configured every widget.

0:04:41.550,0:04:49.860
Lets see the more important details

0:04:44.870,00:04:51.280
on configuring the text field.

0:04:49.860,0:04:52.020
Here an important property used

0:04:51.280,0:04:56.789
is

0:04:52.020,0:04:59.030
keyboard type.

0:04:56.789,0:05:01.850
In this case setting type 4

0:04:59.030,0:05:04.050
means this field will present

0:05:01.850,0:05:06.630
a numeric keyboard. It means

0:05:04.050,0:05:09.800
every time user touch

0:05:06.630,0:05:12.530
this text field

0:05:09.800,0:05:15.510
a numeric keyboard appears

0:05:12.530,0:05:17.570
avoiding the case

0:05:15.510,0:05:20.289
user inputs non numeric text

0:05:17.570,0:05:24.039
and eventualy have to handle

0:05:20.289,0:05:25.750
the suitable exceptions.

0:05:24.039,0:05:29.490
Another important detail

0:05:25.750,0:05:31.810
on configuration is that here

0:05:29.490,0:05:36.960
we are linking to

0:05:31.810,0:05:40.250
#editingChanged event the #inputTextoChanged: action.

0:05:36.960,0:05:44.419
What means that? It means

0:05:40.250,0:05:45.820
every time text field change,

0:05:44.419,0:05:50.930
by user input o delete action,

0:05:45.820,0:05:54.070
any character or number

0:05:50.930,0:05:54.970
it will be sent

0:05:54.070,0:06:02.330
#inputTextChanged:

0:05:54.970,0:06:07.220
So lets see the #inputTextChanged:

0:06:02.330,0:06:10.110
as we said, the method is activated every time

00:06:07.220,0:06:13.510
the text field content is modified

0:06:10.110,0:06:19.660
here, as you can see,

0:06:13.510,0:06:22.290
the input is tested for primality.

0:06:19.660,0:06:25.920
The typed text is converted

0:06:22.290,0:06:29.530
to number and then

0:06:25.920,0:06:31.800
#testPrimality: method is invoked

0:06:29.530,0:06:36.450
asking to number is prime,

0:06:31.800,0:06:39.330
according to response the label

0:06:36.450,0:06:43.030
shows the word prime or

0:06:39.330,0:06:44.310
composite. Here a couple

0:06:43.030,0:06:46.570
of lines worth showing.

0:06:44.310,0:06:50.900
Here, for example, I add

0:06:46.570,0:06:53.480
#isPrime method to Number class returning true or false

0:06:50.900,0:06:53.920
depending on receiver

0:06:53.480,0:06:56.450
is a prime number or not.

0:06:53,920 , 00:06:59,300
Here we can see two methods

0:06:56.450,0:07:00.180
providing diferent ways

0:06:59.300,0:07:04.270
of executing the app

0:07:00.180,0:07:07.680
once installed in coco8.

0:07:04.270,0:07:11.660
And these final lines

0:07:07.680,0:07:15.920
tells coco8 to execute the app

0:07:11.660,0:07:16.920
once is loaded

0:07:15.920,0:07:22.420
from U8 contribution.

0:07:16.920,0:07:24.360
Ok, that's all for coding issues.

0:07:22.420,00:07:28.170
Now we have to do

0:07:24.360,0:07:33.360
the build to compile S8 code

0:07:28.170,0:07:35.979
to javascript.

0:07:33.360,0:07:41.680
The last step is

0:07:35.979,0:07:54.240
upload the contribution to U8 site, lets see how.

0:07:41.680,0:08:00.580
We have to be logued in U8 site.

0:07:54.240,0:08:03.139
Go to Start Coding and click the cross,

0:08:00.580,0:08:07.270
the plus sign (+), do not click the button

0:08:03.139,0:08:09.439
Start Coding

0:08:07.270,0:08:11.039
so a menu it will be displayed

0:08:09.439,0:08:13.279
with several options to init a contribution

0:08:11.039,0:08:17.930
in this case

0:08:13.279,0:08:20.169
we choose iOSApp. This option

0:08:17.930,0:08:22.389
creates a contribution

0:08:20.169,0:08:25.770
forking a base

0:08:22.389,0:08:26.710
template for our

0:08:25.770,0:08:32.329
contribution.

0:08:26.710,0:08:34.829
Here we click in edit

0:08:32.329,0:08:37.870
so we can change the title

0:08:34.829,00:08:41.240
select an image

0:08:37.870,0:08:42.969
representing the app and then upload

0:08:41.240,0:08:47.529
the files of our contribution

0:08:42.969,0:08:53.070
It is impotant to say

0:08:47.529,0:08:56.269
that ScanApp will not accepts arbitrary

0:08:53.070,0:09:00.760
uploaded files. It will accept

0:08:56.269,0:09:07.390
files with names like index.app.st

0:09:00.760,0:09:13.820
or index.app.js or

0:09:07.390,0:09:15.649
index.app.st.js, so

0:09:13.820,0:09:21.079
we have to upload something with any of

0:09:15.649,0:09:25.260
these names. If we upload a st file, a

0:09:21.079,0:09:32.329
Smalltalk file, it will be compiled to javascript

0:09:25.260,0:09:37.470
on the device. If we upload a js file

0:09:32.329,0:09:39.630
it will be accepted as a compiled code.

0:09:37.470,00:09:41.500
In order to names conform to the rule

0:09:39.630,0:09:43.550
we can prepare the script build

0:09:41.500,0:09:46.920
to generetate the output

0:09:43.550,0:09:50.140
with names conforming the rule, or once

0:09:46.920,0:09:54.090
generated js file, as in my case

0:09:50.140,0:10:00.180
it generated prime.st.js,

0:09:54.090,0:10:03.310
prime8.st.js and

0:10:00.180,0:10:08.600
I renamed to index.app.st.js

0:10:03.310,0:10:10.670
In order to upload it

0:10:08.600,0:10:14.590
as a contribution so

0:10:10.670,0:10:20.250
that ScanApp finds it and run it

0:10:14.590,0:10:24.620
here we can see U8

0:10:20.250,0:10:27.510
generated the QR code image

0:10:24.620,0:10:31.350
so it is all done, now is a matter of

0:10:27.510,0:10:33.000
save the contribution, publish it

0:10:31.350,0:10:35.780
and spread it.

0:10:33.000,0:10:39.110
Well, that is all for today

0:10:35.780,0:10:41.800
any questions do not hesitate

00:10:39.110,0:10:50.400
to consult through smalltalking list

0:10:41.800,0:10:50.400
thanks and see you later.