Manger au Japon

Petit déjeuner:
Saumon grillé, bol de riz, soupe et petits accompagnements pour bien démarrer la journée

Katsudon:
Porc pané dans une omelette, posée dans un bol de riz tapissé d’oignons. Toujours bon.

Tonkotsu Ramen:
Sans doute la meilleure soupe de nouilles au monde, et de mon point de vue le meilleur plat du Japon. Des os de porc ont été mijotés dans cette mixture, auquels ils ajoutent entre autre de l’ail brun et autres légumes avant d’y cuire les nouilles
Le service vient avec ail à volonté!

Okonomiyaki:
Si le plat est bon, l’intérêt se porte plus dans la fabrication que dans la dégustation.


Soba:
Nouilles Soba, à tremper dans de la sauce soja au wasabi. On peut boire le jus de cuisson des nouilles. Très simple mais bon.

Curry:
Si la sauce n’est pas aussi bonne qu’un curry indien, la viande panée rattrape bien le tout.

Haricots blancs confits:
S’il fallait donner la plus grosse différence culinaire entre les cuisines françaises et japonaises, ce serait la relation avec les haricots. Ici c’est utilisé comme le chocolat en france.

Chirachi
Censé être meilleur à Hokkaido, l’hiver ne doit sans doute pas être la meilleure saison pour déguster des fruits de mer crus.

Tempura:
Une merveille, de la panure partout autour de champignons, crevettes, légumes,….

Crêpes de canard chinoises:
Ne pas aller dans les restau chinois au Japon. Il nous a fallu négocier pour avoir de la viande et pas seulement de la peau dans ce plat déjà trop cher de crêpes de canard.

Moulin à sésame:

Open thé:
Le thé est en libre service, comme le pain peut l’être en France.

Android binding framework: a deception

Data binding is a wonderful feature for user interface developement. It ease the development process, help to clean the code, and do a lot of the job for you.

A quick insight of the gain

You have a form screen, we will take the android materiel design sample:

Drawing

Before databinding

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

TextView tv;
User user = DataManager.getActiveUser();

public void onCreate(){
[...]
tv = findViewById(R.id.name);
tv.setText(user.name);
}

public void validate(){
String name = tv.getText().toString();
}

We have to get each views by id or by annotations libraries. We use them by calling the getters and setters when we need

With Binding

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{user.name}" />

User user = DataManager.getActiveUser();

public void onCreate(){
[...]
binding.setUser(user);
}

public void validate(){
String name = user.getName();
}

Notice the removable of the id, an information that has now become irrelevant. Things are automatics. The data (should) be a direct image of what is in the screen.
If the Java code change the name, it is immediatly set in the TextView without setText(),.
If the user tap some characters, the model is updated without tv.getText();

Other cool stuff you can do

You want to bind the color or the text to a custom rules (red if too short, green if ok)?
You can do it without multiple lines of java code.

You want to link the progress of a ProgressBar to the advance of a media object?
Just do it in one line of XML.

You want to set a view’s visibility according to your data, nothing easier:

1
android:visibility="@{user.hasAccount ? View.VISIBLE : View.GONE}"

The deception

When google announced the beta of Android binding it was a wonderful news.
When they released the guide, it was wonderful too. A lot of features were availables (converters, expressions, collection support, …)

But, using the android databinding framework has proven to be quite a deception after working with Qt or Windows store sdk:

Not as straightforward as concurrents

A library to include, ViewModels to declare in each layout, different layout root, another generated class to import, a different way to inflate fragment’s layout.
It is normal since DataBinding is not included as part as Android SDK. But we see the difference when we used a language designed with binding in mind.

Verbose viewmodel

Android binding require you to change your model, making it extend a class, or worst, transform all your members into an observable instead of a simple type (Observable instead of String).

This is not acceptable for a clean structure, as well as for Gson auto deserializing. So the solution is to expose every attributes of the model inside the viewModel, which is sooo verbose.

Where the ** is the 2-ways binding?

There is no 2-way binding. Some hacks are availables, but it is not a good long term solution for a complex project.
Good bye auto-handled form (the typical always annoying screen to implement), where databinding is nothing else than a saviour.

Pain Pizza

A full-fat meal you can bring in your role-play table, everybody will have sufficient food for the event.

Ingredients:

Receipe:

  1. Make your bread, stop before cooking it
  2. Find a high tin with a small surface, add some flour at the bottom
  3. Put one layer of bread, one of cheese and one of chorizo
  4. Do it two or three time and finish by a layer of bread
  5. For a more tasty looking, spread a egg on the top, with some cheese
  6. Cook it like bread (230°) until the subtle smell of the cheese brings your neighbour into your house with his fork.

Manger en Thaïlande

Pas déçu du voyage culinaire en Thaïlande. On en trouve partout, à toutes heures, toutes sortes de plats généralement sans mauvaise surprise en terme de goût.
Ils sont généralement peu copieux, les thaïlandais s’offrent plus de repas par jours qu’en europe.


Pad Thai: On trouve partout de ces nouilles frites accompagnées de légumes


Le riz n’est pas toujours fris lorqu’il est accompagné de viande et de légumes. Mais il reste très bon.
Le coca à 20bath (45cents) soulage bien le portefeuille.


Les accompagnements sont infinis. Ici j’ai eu de la salade de papaye et du poulet mijoté en sauce piquante, sud de la thaïlande oblige.
Le tout accompagné de choux et de mini comcombre frais. Il parait que ce concombre sert à adoucir la bouche après tout ce piquant.


L’un des meilleurs mets que j’ai trouvé! Du riz gluant au sucre roux et à la noix de coco grillé au feu dans une feuille de bambou.
Légèrement caramélisé, ce riz est succulent.


Légumes vides sautés à l’ail et pimentés. Toujours aussi bon.


Les thaïs sont des experts en poulets fris. Le Kentucky peut se rhabiller.
Quand on a la chance de tomber sur un cuisinier qui utilise une panure aromatisée à l’ail, ça devient sublime.


Ces minis crèpes sont fourrées avec une meringue très légèrement cuite. Elle colle au dents, mais c’est intéressant.
Ca m’a l’air d’être traditionnel pour les fêtes tel que le Lyo Krathong.


Un énième stand de brochettes et poulets fris parmis tant d’autres.


Cette omelette est très proche d’une galette bretonne en terme de texture. Et les huitres fraîches par dessus ne sont vraiment pas chères.


Les produits de la mer ne sont par contre pas tous donnés en Thaïlande et ces scampis de chinatown étaient plus alléchantes que fameuses


Soupe au lait de coco. Ca peut tout aussi bien arracher la gueule comme être extrêmement doux, celon la recette.


Champignons pânés fris. Dès que j’ai un accès à une cuisine je me fait ça avec une panure à l’ail.


Champignons enroulé de jambon pour être grillé au barbecue. A faire avec une vraie tranche de lard et ce serait une merveille.


Quelques sucreries correctes à base de coco et de riz.

Photo by restaurant-douvaine
Non malheureusement, ça, ça commence a sévèrement manquer…

XPeria for development on Linux

adb

First thing first, install the Android developer tools with android studio.
Then add adb to the PATH.

1
2
3
4
5
sudo gedit ~/.bashrc

#Add these lines to the file with gedit
PATH=$PATH:/home/benoit/Android/Sdk/platform-tools/
export PATH

Devices steps

Then the devices need to be reached by adb.
These steps concern the XPeria devices (at least the M4 Aqua and Z2).

  1. Go to Settings > About Phone > Click many times on “Build Number”
  2. Go to Settings > Developer options > Put “On” and USB debugging “on” too
  3. Go To Settings > XPeria Connectivity > USB Connectivity > Choose MTP as the USB Connection type

Linux steps

Adb will lack the required permissions to access the device. The steps to solve the problem are easy.

1
2
cd /etc/udev/rules.d
sudo gedit 70-android.rules

Add this line:
SUBSYSTEM==”usb”, ATTR{idVendor}==”0fce″, MODE=”0666″

1
2
3
sudo service udev restart
adb kill-server
adb devices

Some websites proposes a list of idVendor to add the permissions to many devices:
https://github.com/faux123/ubuntu_udev_rules_4_android

Bacon confit

A medieval receipe, full of spices, it may reveal mervellous tastes. This one could be name a bacon confit: medium pieces of bacon slowly cooked in its own fat with overtasty spices.

Ingredients:

  • As much thick bacon as possible
  • As much spices as possible among:
    .. cinnamon
    ..
    pepper
    .. anise
    ..
    clove
    .. unpeeled garlic
    ..
    nutmeg
    .. ginger
    ..
    thyme in branch
  • A shooter of water

This is the spices I used, but you can use different ones (chili, coriander,…)

Receipe:

  1. Remove the skin from the pieces of bacon. Save all the fat from the skin with a knife and put it the frying pan.
  2. Start the frying pan at medium/low fire to get the fat off the pieces
  3. Get rid of the bones and cut the bacon into large dices
  4. You may remove the fat from the pan (even if I’d recommand not to do it) and put all the ingredients in it. Don’t be shy on the spicies
  5. Cook it at low fire for 2 hours at least, while stiring from time to time.
  6. Serve with toothpicks for aperitif or with brown bread to eat it as a regular menu.

UX303LB and linux dual boot

Setting up a dual boot Linux Mint / Windows 10 on a fresh Asus UX303LB

Choice of Linux distribution

I wanted an easy to install and to configure Linux distribution, for a developping purpose as well as for every day needs (game, media, music, browsing…)

Ubuntu:
Works great, but Unity is not my favorite desktop interface. Moreover Unity happened to bug too often while gaming on native as well as on Wine games

Fedora:
Sounds better and gnome 3 is great! But it needs more configuration to have steam, mp3, proprietary drivers, …

OpenSuse:
KDE is efficient, and OpenSuse has a good user documentation. Open Suse is a good choice.

Mint:
It comes with the diversity of ubuntu applications and support, but with a stable gaming desktop. That was my final choice

Other:
They are so many other distributions than may be better, but well…

Issues with installation

Windows partitions

Windows 10 had trouble to install itself, with errors messages about GPT file system required. But it is unable to solve the issue itself.
Reading an article on the subject helps a lot to understand the situation: https://fr.wikipedia.org/wiki/GUID_Partition_Table

A linux started from a live USB can help windows:

1) Create a linux live USB
You can use lili, which works well : http://www.linuxliveusb.com/fr/home

2) Reformat the drive with gdisk
This post contains a great answer that helps me a lot:
http://askubuntu.com/questions/84501/how-can-i-change-convert-a-ubuntu-mbr-drive-to-a-gpt-and-make-ubuntu-boot-from

You’ll have to enter into the terminal

1
gdisk /dev/sda1

And follow the guide:
d to delete the partition
n to create a new partition, and then select the GPT system.
h to get a list of the available commands

Execute access with NTFS

After installing Windows and Linux, the last one cannot access my Windows files with execute rights.
This is a common and solvable problem:

1
2
3
4
sudo apt-get install ntfs-3g
sudo umount -a
sugo gedit /etc/fstab
sudo mount -a

And add this line to the fstab file
UUID=YOUR_DISK_UUID /media/data ntfs-3g rw,user,auto,exec,gid=100,uid=1000,nls=utf8,umask=002 0 0

HiDpi

This Asus comes with a high definition (3200*1800) screen which is not handled correctly by a lot of apps. But with a little configuration, it is easy to tell them how to behave.

General Desktop:
Search for “general” in the main menu to set the dpi settings to Double and then restart. The desktop will now be usable.

Other tools:
Follow this complete guide: https://wiki.archlinux.org/index.php/HiDPI

Best Applications

Web Browser
Chrome is for the time being the web browser that behave the best with a multitouch HiDpi screen.
Mint’s Chromium fails with HiDpi while firefox and opera cannot take advantage of the touchscreen

Usefull Apps

Some applications that tweaks your system:

Because having a terminal entry in the File browser is great:
http://community.linuxmint.com/software/view/nemo-terminal

Brackets is a good simple web editor, with a specific extension:
https://github.com/cgaspard/brackets-hidpi

White label structure for Android

In the projects we worked on, I often faced the need to create multiple builds of one application for different clients. Android SDK is very powerful in such situation and exposes many possibilities.

Here a proposition of different solutions for an Android application that is expected to be built into many different targets.
The main purposes I see are :

  • reducing the number of code lines
  • propagating the bug fixes to every flavour
  • isolating the specific codes of one flavour

Some definitions are needed, taken from the the Android Documentation:

  • Flavour: A product flavor defines a customized version of the application build by the project.
  • Build Type: A build type allows configuration of how an application is packaged for debugging or release purpose.
  • Build Variant: This is a combination af a flavour and a build Type.
      

White label sample

This article is based on a fake sample: a white label application that is declined for different restaurants, among which “PizzaGood”, “Kebab200” and “JapSushi”. The design will change as well as the available features.

Building the variant with gradle

  1. Create the main folder as well as one folder for each white flavour, in the “src” folder of the project.

  2. Edit your project build.gradle to configure the flavour

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
productFlavors {
main {
versionName "6.0.0"
packageName "eu.hithredin.sample"
}
pizzaGood {
versionName "1.0.1"
packageName "com.pizzagood"
}
}
```
&nbsp;&nbsp;

## Implementing specific features

### The config file method
A good solution consists on implementating a custom config file that is read dynamically at startup. The code will be activated and parametrized according to this config.

#### PROS:
+ Only one code to handle all the specific features
+ Easy to re-configure and create a new white label

#### CONS:
- Impose a reflexion to generify the specific features
- Complex if the specific requirement is a big feature

#### HOWTO:

1. Create a Json config file in the "res/raw" folder of each flavour

``` json
{
"flavorSearch": {
"filters": ["ingredient", "price"],
},
"flavorGlobal": {
"facebookEnabled": false,
"subscribeEnabled": true,
"noteAppEnabled": false,
"shareAppEnabled": false
}
}
  1. Create a singleton manager, named FlavorParam, which is basically a model binded to the Json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class FlavorParam {

private static FlavorParam instance;

public FlavorSearch flavorSearch;
public FlavorGlobal flavorGlobal;

public static void init(Context ctx) {
//Load config
Gson gson = new Gson();
try {
InputStream inStream = ctx.getResources().openRawResource(R.raw.flavor_param.json);
instance = gson.fromJson(BaseUtils.inputStreamToString(inStream), FlavorParam.class);
} catch (Exception e) {
Log.e("AppContext", "FATAL error, cannot load AppContext");
e.printStackTrace();
}
}

public static FlavorParam get() {
return instance;
}

public static class FlavorGlobal implements Serializable {
public boolean subscribeEnabled;
public boolean facebookEnabled;
public boolean noteAppEnabled;
public boolean shareAppEnabled;
}

public static class FlavorSearch implements Serializable {
public List<String> filters;
}

}
  1. Implement the thing, for exemple the activation of a Facebook login for PizzaGood but not Kebab200.
1
2
3
if(FlavorParam.get().flavorGlobal.facebookEnabled()){
showFacebookLogin();
}

  

The build constants method

Use the gradle system to send the configuration of the flavour.

PROS:

  • Very efficient for constants
  • Easy to re-configure and create new white label

CONS:

  • No code, just data

HOWTO:

Just add a line to the gradle configuration:

1
2
3
4
5
6
7
productFlavors {
pizzaGood {
versionName "1.0.1"
packageName "com.pizzagood"
buildConfigField "String", "PUSH_SENDER_ID", '"1010010404040"'
}
}

That can be easily accessed in Java:

1
GCMRegistrar.register(context, BuildConfig.PUSH_SENDER_ID);

  

The flavour file resolution method

Each xml or java file with a specific behaviour is duplicated in the flavour corresponding folder

PROS:

  • Very flexible: do what you want
  • Very efficient for styles, images and sizing customisation

CONS:

  • Code is duplicated
  • Specific code cannot be shared between multiple while label
  • No bug fix or new features propagation

How to reduce duplication

  • Do not hesitate to create multiple files for the same fonctions. For instance, create two dimen.xml files, one with generic values and the other one for specific values.
  • Highly rely on the composite design pattern, and divide your once unique class into multiple features class. Each class can then be redefined in the flavour without recoding everything
  • If not wanted, in the main project create an empty class that extends the real class, and use this one. This empty class can be redefined in the flavour. It will be able to keep or override all the generic code.

TODO UML diagram
  

The custom global code

Use a simple “if” each time you write a new feature (LabelManager.isPizzaGood())

PROS:

  • Very flexible

CONS:

  • The code is spread everywhere
  • Difficult to debug
  • Difficult to add a new white label
  • Complex if the specific requirement is a big feature

I would definitly not recommend to use this method. Easy at the beginning but the developer will faced parts of specific code everywhere which makes a new white label quite an horror to add.
  


Which solution for which case?

Cases Flavour file resolution Gradle build file Config file method
Resources (color, drawable, string, dimen, ….) V
Constants configuration V
Independant Features activated for multiple flavour V
Complex features that are specific to one flavour only V

UI Framework Comparison: Data Binding

Most UI frameworks for native mobile development are now based on a specific language, a DSL, to build the User Interface. This could be compared to HTML for the web developers. Each of them have a different approach which is interesting to compare.

Declaration of the UI

Android and Microsoft made the choice of xml. A well known format but quite verbose.

1
2
3
4
5
6
7
8
9
10
11
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/bg_distance">


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/bold_10_standard_less"/>


</RelativeLayout>

While QT prefers a more declarative syntax similar to the first JavaFx Script. Here a example with the qt-cascade framework:

1
Container {
    verticalAlignment: VerticalAlignment.Center
    ImageView {
        id: tIDBall
        verticalAlignment: VerticalAlignment.Center
        horizontalAlignment: HorizontalAlignment.Center
    }
}

And Tizen proposes a piece of xml that can only be generated by a WYSIWYG (which was quite buggy by the way) :

1
2
3
4
5
6
7
8
<ScenePanel Bversion="2.0.0.201307161753" Dversion="20120315">
<LogicalCoordinate>720</LogicalCoordinate>
<Panel id="CUSTOM_ITEM_RECIPE">
<property backgroundColor="" backgroundColorOpacity="0" compositeEnabled="true" groupStyle="GROUP_STYLE_NONE"/>
<layout height="130.0" mode="Portrait" type="LAYOUT_RELATIVE" width="720.0" x="0.0" y="0.0"/>
<layout height="300.0" mode="Landscape" type="LAYOUT_RELATIVE" width="93.0" x="0.0" y="0.0"/>
</Panel>
</ScenePanel>

The greatest advantage of these DSL is a cleaner code, since the UI is separated from the behaviour and from the logic code.
Just take a look at an old J2ME code, where all aspects of the interface are built with pure Java code:

1
2
3
4
5
6
7
8
9
10
public LoginScreen() {
super();
add(new CustomTextField(17, Utils.GREY_TEXT, "Title", 10));

loginForm = new FormManager(TableLayoutManager.USE_ALL_WIDTH);
loginForm.add(new TextForm("login", Local.get(Local.FORM_EMAIL), "", TextForm.TYPE_MAIL).setMandatory(true));
loginForm.add(new PasswordForm("password", Local.get(Local.FORM_PASSWORD), "").setMandatory(true));
loginForm.setPadding(5, 10, 5, 10);
add(loginForm);
}

Feeding the data

Now that the UI is written inside the DSL, it becomes more difficult to access it from the code. The dev has to find the view, inject the dynamic data to it and then code the behaviour like hiding a view, animating, activate on click, …

Android’s native solution consists of giving ids to the views, which are put into an id catalog, the famous R file. Then the dev may find the view with the id:

1
2
3
4
5
public void onResume(){
super.onResume();
TextView title = (TextView) getActivity().findViewById(R.id.title_text);
title.setText(R.string.myTitle);
}

Html/Javascript provides a similar solution, greatly improved by the powerful selector:

1
$('#errorLayout h3').text("error title");

Finding ids quickly become too verbose and tedious on Android. That’s why some guys added annotations library, which saves some line of code:

1
2
3
4
5
6
7
@InjectView(R.id.title_text) 
EditText title;

public void onResume(){
super.onResume();
title.setText(R.string.myTitle);
}

Data-Binding

But recently, Android announced the support of the data-binding pattern. What is that?
This is a very common practice for Windows or Qml developers that allows to write less code, to highly reduce the code dependency, to ease the development in team, …

Have a look at this Windows 10 XAML binding on WPF framework:

1
<TextBlock 
    Text="{Binding User.Name}"
/>

The text is directly binded to a model’s value. Its sounds great but the dev loose the flexibility to manipulate the data.
WPF has a solution with the converter. We can expose converter classes to transform a value to another. Useful if you want, for instance, to convert a boolean to a visibility:

1
<TextBlock 
    Visibility="{Binding User.Security.NameIsPublic, Converter={StaticResource BoolToVisibilityConverter}}" 
    Text="{Binding User.Name}"
/>

But sometimes we need a more complex data transformation, for instance a string composition or a visibility of a view relative to a non-trivial logic.
To achieve this, we can bind to multiple values with a logic, or expose a fake data and bind to it:
(ps: Multiple binding is not always available “thanks” to the restriction of the Windows Store app)

1
<TextBlock 
    Text="{Binding PriceText}"
/>

public string PriceText {
    get {
        if(Price != null){
            return $"It costs {Price} {Currency}"
        }
        return "Not for sell";
    }
}

In another world, the QT one, QML found a way to keep an high flexibility by providing a full language to bind with, the javascript. It reduces the declarative aspect for a gain a power.
We can even write an entire application in qml/Javascript similar to html/Javascript:

1
Container {
    topPadding: isWide ? 24 : 12
    layout: StackLayout {
        orientation: Qt.trManager.isRTL ? LayoutOrientation.RightToLeft : LayoutOrientation.LeftToRight
    }

    ImageView {
        imageSource: "asset:///images/" + ListItemData.news_image
    }
}

By reading android documentation, It feels like they made a mixed choice. They have converters but still provide a minimal dynamism with logical and mathematical operators (or, and, …) and calls to a function, directly in the xml.

The risk of DataBinding

Yes the code is cleaner, loosely coupled, less verbose, easier to maintain, easier to unit-test…

But with the weak coupling also comes bugs harder to investigate.
To debug a binding that is not working as expected, one should have a good knowledge of the code to understand the data affectation.

Particularly for the new data-binding system of Android. While Windows forces a declarative syntax, Android would propose a thousand way to code the same thing.
Should we choose a converter, a call to a method, directly write the code with xml logic or add a fake field in the model class, … A project will require a good “Best practice” to guide the developers on the same path.

Null Propagation

From my Java point of view, one of the best discovered feature thanks to C# is the Null propagation:

1
var artist = data?.Radio?.Artist;

It will return null or a object without NullReferenceException

Handler

Applyed to the handlers it also becomes interesting:

1
MyHander?.Invoke(this, null);

Instead of:

1
if (MyHandler != null){
    MyHandler(this, null);
}