Category Archives: Lifestream

Create an app Firefox OS


Create an app Firefox OS

The garden of Eden for Front end developers


Few weeks ago, I went to @lxjs conference which was great. Soledad Penadés explained me the vision of Firefox OS, and I found it exciting.

Screenshot of my simulator

After ten days, I started to work on creating an app for this system on my free time. I needed a simple but useful idea for me: a Buffer client for Firefox OS.

Before I started to develop with a library or system, I like to read their documentation. On that point, Firefox OS has the advantage of the documenting spirit of Mozilla: detailed in different languages and examples https://developer.mozilla.org/en-US/Firefox_OS.

Preparation

Now time to develop this app! I setup a front-end project like I’m used to doing it: NPM, Bower, Gulp.

I chose AngularJS, but promise, I will try Polymer or React in the next one. I could use Ionic Framework for the UI, but I wanted to try the Gaia interface. Have a look there: http://buildingfirefoxos.com/index.html

What is truly good with Firefox OS, it’s the fact they’re using the same libraries as third-party developers to make the system: UI elements, transitions, etc. The code of the default apps is open source too. So you can get inspiration by looking at it: https://github.com/mozilla-b2g/gaia

The only difference with a website is the app manifest: https://developer.mozilla.org/en-US/Apps/Build/Manifest. It’s not that different from a Google Chrome App’s manifest. You have to set the permissions, icon files. Good point, you need to describe the need of each permission. It will help the user to understand what he allows. No more bullshit permissions for games, yeah!

You have three types of app:

  • Hosted: The app is hosted online. Limited access to the APIs
  • Privileged: The common one in mobile. Mix between the others.
  • Certified: Access to sensible APIs like manage the WIFI, monitor the networks. The system apps have this status.

You can check the list of permissions here: https://developer.mozilla.org/en-US/Apps/Build/App_permissions

Good point, the user can change the permissions of the app even after the installation. The spirit of Firefox OS is focused on the transparency of the system, letting the power to the user. I’m fond of the concept! So you need always to check if the permission is granted before making a call to the API.
If you root your Android phone, I think you can do it too but it’s a hack, some apps may be buggy, and I don’t even talk about the closed-mind spirit of iOS…

The Dev tools of Firefox OS 1.3 can’t debug network requests while Firefox OS 2.0 yes. So I decided to work only on my browser until I need a device-specific API.

Simple Python HTTP server

I didn’t use file:/// because you can set the origin property in the manifest. It will look like app://my-app.com. Useful for origin problems.

Redirector extension

It simulates the redirect property of app manifest. This property allows you to have an automatic redirection from a page to another inside your app. It’s much simpler to use that instead of having an in-app browser for OAuth authentication.

CORS proxy

Firefox doesn’t have a security flag like Canary, so you need to bypass the checking of CORS by doing that if the API used doesn’t provide it. Remember it’s only on desktop. In Firefox OS, you have this permission: systemXHR (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#mozSystem)

Notification

Local notifications are the same as the one defined in the specs of HTML5. For the APIs which aren’t specific to the device, you can test them directly on your desktop. Sometimes, you’ll need to the nightly version. It wasn’t the case for me on this app.

Web Activity

This API allows you to delegate an activity to another. It’s the Intents of Android. I played a little bit with the simulator, and it’s easy to use. It’s well described here: https://developer.mozilla.org/en-US/docs/Web/API/Web_Activities

User Interface


Screenshot of the email app

As written earlier, all the UI elements of the system are open-sourced. You can custom them with CSS. Follow the guidelines to have an app well integrated: https://www.mozilla.org/en-US/styleguide/products/firefox-os/

I had some frustrations due to the lack of examples and uniformization of design elements (the icons of the header aren’t the same as the edit ones) but it will be improved.

I didn’t play enough with transitions due to the lack of time that I had but so far I tested; it’s easy to add them in your app. They look smoothed in the simulator. I will try on my soon-coming Firefox Flame.

Open System, Open services

The team of Mozilla is known by always open source their code. All the Firefox OS system is available online. But it is interesting to know they open sourced the code of the marketplace and the push server.

You can put your app in the default marketplace or another one, you’re free. You can set a whitelist of marketplaces in the manifest of your app. Android allows that too, but you need to enable the unknown sources. It’s not safe and hard for not advanced users to do it.

The push system is intelligent too. You wake up your app by sending a simple request. No title, description or sound. It’s like the silent notifications in iOS. The main advantage is to avoid sending sensitive data to Mozilla servers. We can trust them but to they can be compromised by a cracker (or the NSA). You can set a version property which is a number that keeps increasing. Your backend tells the Mozilla servers about a new version whenever it wants an App to be notified.

You can read more about it here:


My App

I didn’t describe in details the development of my app because the process was the same as a Single Page Application. The code is available here: https://github.com/yrezgui/buffer-firefoxos

If you have any questions, feel free to contact me: http://www.yrezgui.com

Screenshot of my app

Conclusion

I just loved to create an app for Firefox OS. I rediscovered the excitement that I got when I developed Firefox and Chrome extensions. The simulator debugger still need to be improved (a right-click on an element doesn’t display the options of the desktop one), the UI library is nearly done but the system is ready. I developed for Firefox 1.3, but version 2.0 is already available in beta.

Bonus point, the simulator, doesn’t take ten minutes to open as the Android one, and you don’t need to wait your app to be loaded to open the inspector like iOS. You can catch easier the errors at the loading.

The philosophy of having a complete open source system, default open source apps, manageable permissions for each app is the right way to do mobile OS. But it doesn’t mean the system needs to look ugly, or it’s hard to use it (I’m looking at you MeeGo!). Creating apps is starting to be cool again, so rush for it ☺

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.

از رنجی که میبریم…

آن سالهایی که برای کنکور می خواندم، در تصوراتم از روانشناسی، خودم را در اتاقی می دیدم در طبقات بالایی آپارتمانی در یکی از خیابان های پر تردد شهر، که پنجره هایش رو به خیابان و پیاده رو ها باز می شود. همیشه در خیالاتم فرد افسرده ای را می دیدم که به من مراجعه کرده و از ناامیدی هایش می گوید و من هم پس از کمی گفتگو بلند می شدم و قهوه ای می ریختم و بهش می دادم و خودم هم با فنجان قهوه ام به سمت پنجره می رفتم و پرده را کنار می کشیدم و به بیرون نگاه می کردم و از مراجع هم درخواست می کردم که با من به بیرون نگاه کند. به مردمی که بی تفاوت در حال و رفت و آمد هستند. مردمی که بعضی شان عجله دارند و بعضی شان آهسته راه می روند، بعضی ها تنها و بعضی ها با همراه، بعضی هایشان پیر هستند و بعضی جوان و خردسال، دست بعضی ها در جیب و دست بعضی ها در دست دیگری، بعضی شان می خندند و بعضی شان در فکر فرو رفته اند. آنوقت رو به مراجع می کردم و می گفتم؛ ببین! زندگی همین است، همین آدمهایی که بی تفاوت به من و تو در حال گذر هستند.
حالا چند سال است که درمان می کنم و هیچ وقت، هیچ مراجعی را به سمت پنجره نبرده ام تا آدمها را نگاه کند و بفهمد که زندگی همین است، اتفاقاً اتاق های درمانم همیشه رو به پیاده رو باز می شوند و می شود از آنجا آدمها را دید که بی تفاوت به ما، این سو و آن سو می روند. فلسفه ی آن خیالات درست بودند، اینکه زندگی بدون ذره ای اهمیت به ما در جریان است، چه ما خوشحال باشیم و چه غمگین، چه تنها باشیم و چه با همراه، چه پیر باشیم و چه جوان. به واقع این واقعیت بی رحم دنیای ماست که بی هیچ توجهی به ما روز را به شب می رساند و شب را به روز، فصل ها را عوض می کند و بهار را زمستان. و حتی آنقدر می تواند بی رحم باشد که روزی زمین دهان باز کند و خواب هزاران نفر را آشفته کند و ما آنقدر در این پهنای گسترده ریز هستیم که عملاً به حساب نمی آییم.
آدم هایی که در پیاده روهای خیالی افکار من زندگی می کردند، می توانستند به درمانجوی خیالی من کمک کنند، ولی حالا به این فکر می کنم که دنبال دلایل بیرونی برای زندگی گشتن، تلاش بیهوده ای است و راه به جایی نمی برد. شاید حالا ترجیح می دهم مراجع را به درونش هدایت کنم و با پیاده روهای درونش آشنا کنم، آنجایی که غم وجود دارد و شادی، آنجا که می تواند فصل های زندگی اش را خودش به دست گیرد، آنجا که می تواند تابستان زندگی اش را زمستان کند یا پاییز را بهار، آنجا که می تواند با تنهایی ها و بیهوده گی هایش روبرو شود، آنجا که زندگی واقعی با تمام دلهره ها و اضطراب هایش جریان دارد.
حالا فکر می کنم، هر وقت آدمها مسئولیت گرفتاری های زندگی شان را پذیرفتند، و معنایی برای همین رنجی که از زندگی می کشند پیدا کردند، زندگی شان بهبود پیدا می کند و این تجویزهای بیرونی دردی را دوا نمی کند.

منبع :وبلاگ اگزیستانسیالیسم/ روان درمانی، فلسفه

نویسنده:غلامرضا میناخانی

 

I’m on drugs

 فقط پاییز نیست. دارو هم می خورم. چقدر همه ی عمرم فکر کردم هیچ مشکل ذهنی و روانی با روانکاو و روان شناس و گروه درمانی حل نمی شه؟  چقدر به همه ی دوستای داخل ایران و ایرانی م که روانکاو و روان شناس دارند- که کم هم نیستند-  گفتم این ها همه ادای روشنفکریه؟ احتمالن هنوز یه قدم خیلی کوچک مانده تا به اون جا برسم که قبول کنم این ها ادای روشن فکری نیست اما فعلن به مرحله ای رسیدم که مطمئنم دارو نتیجه می ده. روان پزشکی از لیست اداهای روشن فکر حذف شده. هیچ وقت توی زندگی م نتونستم تمرکز کنم، و این جدید نیست، تمام سالهای ابتدایی مامانم آمد مدرسه معلم ها گفتند خیلی وول می خوره و حواسش پرته.  بعد فکر کردن شاید چون درسها رو بلدم حواس پرتم، این شد که وادرام کردن به تابستان ها هم درس خوندن تا از روی کلاسها بپرم. تابستان هم حواس پرت بودم، شهریوری که قرار بود کلاس دوم رو امتحان بدم صبح روز امتحان املا مامانم ازم املا گرفت، شدم منهای بیست و پنج. املا می گفتند گوش نمی کردم و به جای این که دقیقن همون کلمات رو بنویسم مضمون کلی رو می نوشتم. می گفتند کلمه، می نوشتم واژه یا بر عکس. می گفتند با سرعت، می نوشتم سریع. فقط مامانم شانس آورد که املای بچه ی دوم ابتدایی نیم صفحه است و نه پنج صفحه.  بقیه سالهای مدرسه و دانشگاه هم همین بود، بعدها توی اروپا دیگه خودم خیلی سر حواس پرتی سر کلاسهای دانشگاه سرزنش نکردم، عادت کرده بودم. تنها چیزی که می تونست باعث بشه تمرکز کنم کتاب خوندن بود، رمان. هیچ وقت نتونستم یه فیلم یک و نیم ساعته رو خودم ببینم بدونی این که بیست بار عقب و جلو بزنم. توی سینما و تئاتر نشستن برام عذاب بود وقتی از نیم ساعت می گذشت.  نمی تونستم  تمرکز کنم و این باعث می شد کارهام رو نتونم انجام بدم و کار انجام ندادنم باعث استرس م می شد و استرسم از یه حدی که می گذشت شبیه دیوانه هام می کرد. 

حالا حالم خیلی خوبه. می تونیم به پاییز هم ربطش بدیم، اما خودم می دونم که فرق می کنه. این که آدم احساس کنه که روی ذهنش کنترل داره  خیلی حس خوبیه. فکر می کنی روی جهان کنترل داری، و این برای آدمهای کنترل فریک خیلی مساله ی مهمیه. می دونی هیچ چیزی مهم تر از ذهنت برای کنترل کردن وجود نداره. بعد چون چیزی به این مهمی سر جاشه، دیگه چیزهای کوچیک خیلی اذیتت نمی کنه. همکارم که پنج شش ماهه آمده و از وقتی آمده بود من رو در حال داد زدن سر دیگران، در حال بغض و استرس دیده بود، باورش نمی شه آدمی که از سفر برگشته همون سارای قبلیه. هر بار که می بینه دیگه مثل ترقه نمی پرم با هر تلفنی، و  هر مشکلی که همه رو عصبی می کنه، با من کاری نداره هی می گه ?Are you on drugs Sara 

ازلی – هوشنگ ابتهاج


چو شب به راه تو ماندم که ماه من باشی

چراغ خلوت این عاشق کهن باشی

به سان سبزه پریشان سرگذشت شبم

نیامدی تو که مهتاب این چمن باشی

تو یار خواجه نگشتی به صد هنر، هیهات

که بر مراد دل بی قرار من باشی

تو را به آینه داران چه التفات بود

چنین که شیفته ی حسن خویشتن باشی

دلم ز نازکی خود شکست در غم عشق

وگرنه از تو نیاید که دلشکن باشی

وصال آن لب شیرین به خسروان دادند

تو را نصیب همین بس که کوهکن باشی

ز چاه غصه رهایی نباشدت، هر چند

به حسن یوسف و تدبیر تهمتن باشی

خموش سایه که فریاد بلبل از خامی ست

چو شمع سوخته آن به که بی سخن باشی