[Memo] 數位遊牧的生活 Part 1

Image Credit

digital_monad

前言

從七月離職後就一直想寫一篇有關「數位遊牧民族」的生活,但是一直被拖稿(??)真心覺得這一段旅程應該會是人生中特別值得紀念的一部分,所以要好好的寫些東西來記錄一下!

起點

我想,所有的起點都是從 2014 年這封信開始的吧:

beginnings

真沒想到我還翻的出來這封信,對我來說,這封信是目前職涯的轉折點(加現在這裡也才第三間公司,職涯是有多長啦 XD),也是我數位遊牧生活的起點。

想想,我開始認真學「寫」程式,應該是我在大二的時候吧,那個時候因為社群的關係認識了一些人,一起做了一些有的沒的的小專案,雖然沒賺多少錢但是不知不覺中也建立起寫程式的熱情還有能力。又因為當時認識的朋友們給了我很多機會,所以也在各個地方遊走了一些時間,又從中認識了好多人還有提昇了一些能力。

大學畢業後,我就設立了一個目標,就是每一年至少要寫一些有趣的開放源始碼專案,先不管這些東西對別人來說有沒有用(有用當然最好),但是至少要寫一些東西出來。久而久之,我的 GitHub 開始累積了一些東西,而之中還真的有人在用 XD (我都不敢用了你們怎麼敢用!!?)。其實當初在寫程式的時候也沒想這麼多,主要也就是好玩而已呀(玩心 driven development xD),天知道這竟然會是日後和 Nick 接上線的橋樑!

不過管他的,「機會」就是來了,想擋也擋不住。

Let’s talk

這邊真的要特別講一下,我真的覺得外國人找人的方法很特別(樣本數只有一,應該很不準 xD),有別於以往在 LinkedIn 上面的罐頭信,Nick (我們的 CEO)的做法就真的很不一樣,從上面那封信其實就可以看的出來如果他們對於你這個人有興趣的話,他們會先試著了解你這個人做過的所有事情不論是技術或是非技術相關的。以 Nick 為例,他的做法是上 GitHub 把所有在台灣的 JavaScript 開發者從頭到尾全部看一遍,然後從你的作品去了解你這個人的能力在哪裡,如果對你有興趣的話會再透過你在 GitHub 上面留的信箱來聯絡你,對你做進一步的認識。

補充:這裡有兩件事情我覺得很重要,一就是 GitHub 對於一個軟體工程師帶來的影響,二就是你一定要留一個別人找的到你的信箱,如果怕被機器人找到你的話就把 Email 的特別字換掉也是一種不錯的做法。所以如果想要和國外工作機會接軌的話,麻煩參考一下這段。

在初步的 Email 往來後(約十幾封 xD),就和 Nick 約了某天去士林吃夜市。我覺得對他們來說,實體接觸似乎是一個必要的過程,它提供一個無壓力的環境介紹(推銷)他們想要做的事情給你,也會從中和你聊許多有的沒的事情,從技術、工作、玩樂一直到生活層面都有。簡單來說,我覺得 Nick 這個人給我的感覺是除了找員工之外,還多了一種交朋友的味道在裡面,你唯一要特別注意的事情就是用英文坦住 4 個小時以上,並且試著用各種方法騙他們吃一些奇怪的東西像是「豬血糕」、「臭豆腐」或是「皮蛋」就可以了 XDD

不過說真的,我們約出來的次數應該有超過 2 ~ 3 次以上,而且每次的時間也都頗長,畢竟對一個 Startup 來說時間還有資源怎麼樣都是比大公司還受限呀,所以多花一點點時間找到對的人相對就重要許多了,那過程相對耗時也就可以理解了。如果硬要算的話,我覺得在這些過程上所花的時間真的比我過去面試(也才兩間而已是在大聲什麼 )過的公司還長許多呀。

遊牧的生活

vectr-2

終於來到這篇的重點「遊牧生活」了!

對我來說,我覺得如果沒有經過第一份工作離職後那短暫 3 ~ 5 個月和室友在家自己寫程式的時候,我想遊牧的生活對我來說是一件非常困難的事情吧!還記得那個時候的我們對於離職自己創業(玩耍)有著一些憧憬,剛好前後我們都遇到了跳潮的時候,就順理成章的在家自己開著電腦工作。

那幾個月是一年中最熱的時候,而我們每天都在悶熱的頂樓加蓋中幻想著不存在的未來。雖然我們沒有錢、沒有可以賺錢的想法什麼都沒有,但每天我們還是很樂天的朝著自己夢想中的方向前進。

不過想也知道這怎麼可能賺錢,到後面其實都是在用自己的老本來付房租還有生活費,存款也不知不覺中快見底了,而最後也不得不去接一些 Case 來試著養活自己,步調也就從此亂掉了。不過事後想想,我覺得這些事情都不是最難的,最難的事情其實是維持「規律的生活」還有「自制力」。而很剛好我們就是沒有自制力的那兩位,很常每天都睡到中午、想做事的時候就做事、想睡到的時候就睡覺,生活和工作再也此分不開來。而當然爾,最後這場鬧劇也就不了了之,我和我室友也各自另尋出路去了新公司工作了。

所以,有了過去的慘痛經驗,我對於第二次的遊牧生活就有許多心理建設了,要用和上班族的態度一樣有正常的上下班生活,每天盡量十二點附近睡覺、早上九點起床開始一天的工作,然後六點多之後則是回歸自己的生活。切記,適當的把工作和生活是數位遊牧民族很重要的一件事情呀!

回到數位遊牧本身,我覺得這個工作帶來最大的好處就是「健康」還有「有更多的彈性去體驗這個世界」,以健康來說,我幾乎每兩天就會跑去游泳或是在家簡單的做一些運動。以前七點下班,搭車到家已經八點、吃完飯都九點了,還來其他的時間去運動,雖然還是會盡量播空逼自己先運動再吃飯,不過運動完後吃飯的時間也都九點多了,其實也沒有多健康就是了呀,囧。

而另一個好處就是關於彈性這件事情,因為大家都是遠端在自己的工作環境工作(家、咖啡廳…),所以大家並沒有很在意你人現在有沒有乖乖的待在座位上,只要個人負責的部分有所進度就夠了。因此很多時候,在快接近下班時間或是有點腦部缺氧的時候,我就會拿著我的游泳包去附近的泳池游個泳,因為通常很多時候坐在那邊也沒什麼意義,頂多就是繼續卡關而已呀!但是如果是在辦公室,有時候還是會很在意所謂的「下班時間」,沒有到那個時間之前離開的話都像是犯了淘天大罪一樣,那在這個風氣之下,其實也就很難這麼隨心所欲的說走就走了。

Vectr-ers

vectr-1

由左至右分別是 Nick 、Hychen、Yurenju、Emery 、 EragonJ
(雖然當時 Nick 人在國外,但我們還是請朋友硬是把他 Vectr-ed 進來 XDD)

(這篇文寫太長了,快轉鍵給他七略!)最後,我就告別 Mozilla(謝謝你們!)來到 Vectr 啦 😛 其實這也小小的圓了我想在外國工作的夢想呀(不是人在台灣嗎!)。以前雖然是在 Mozilla ,但是其實在台灣的人也都還是台灣人,說衝擊嗎其實也沒有很大的感覺,大家都是在網路上打打字、留留言比較多,也沒有什麼實際一起共事的機會。不過來到 Vect 就不太一樣了,也才只有五個人而且要打理所有大小事(還好我只要刷我家的馬桶就好),再加上我們每週定期有一次實體會議,所以其實大家接觸的時間真的蠻長的。而每次只要大家聚在一起的時候,我們三個台灣代表都要開啟全英文模式至少 4+ 小時以上,通常要一直到最後大家都元氣耗盡了才會結束 XDD 真的是一種很特別的體驗呀!

在這邊有很多新的東西可以學,也有很多機會和不同的人一起工作。對我來說,跳出自己的舒適圈只是第一步,數位遊牧生活也才剛開始而已,未來會怎麼走我也不知道,其他的就留到下一篇再說吧 😛

[Hack] Kaku – music player for next generation

kaku_radius

每年都要花點時間做自己的 Open Source Project,而今年意外的有一個很好的題目可以來發揮 xDDD,所以就利用一些下班的時間把 Kaku 的整個雛型打造出來了!Kaku 是一個音樂播放器可以讓你自由地聽各個網路平台上面的音樂(目前支援的平台有 YouTube、Vimeo 還有 SoundCloud),算是一個各平台整台的小作品。

(先點連結看看再說:http://kaku.rocks

而在開發這個程式的時候也發生許多有趣的問題,所以想把我還記得的部分寫下來做個記錄 xD。

Node Webkit(NW.js) 起手式

因為我一開始的目標就是希望這個程式是各個作業系統的使用者都可以使用的,因此桌上型應用程式勢必是我的首選,又因為在實際寫 Kaku 之前,我有幫 Atraci 寫過一些相關的程式碼,所以對於如何操作 Node Webkit 提供的 API 有一點點研究,所以就選用 Node Webkit 當作我開發的基底。(我只是前端工程師阿阿阿)

說到 Node Webkit,他有個有趣的設計就是他提供不同的 JavaScript Context,因此你的應用程式雖然是用前端的技術打造的,但是因為可以跨用到 Node Context,所以就可以混用許多現有的 npm module 當做後端來處理資料,所以在我的設計下,在這個程式裡面就有這兩類不同的資料夾,讓程式可以很明確的切分他們的職責。

搞定開發環境

因為有過幾次合作開發 Open Source Project 的經驗,所以如果你要讓你的專案吸引其他開發者的注意力的話,那你一定要把開發環境搞定或是簡化到一個指令複製貼上就可以跑起來,要不然光是一開始就讓別人有很強烈的挫折感,那你的專案也不用期望會有多少人來幫忙開發了 xDD。

又因為 Kaku 是我想要來嘗試練習 React 的一個專案,裡面用到很多 jsx 的語法所以需要 precompile 的動作,而且又因為要把整個程式包裝成 Node Webkit 的應用程式,也需要另外做 build 的動作,因此我就用 gulp 當做我 building tool 的基底來把這些操作都包裝起來,讓開發者只要按一兩個 gulp 指令就可以了!

現在想想,一開始就把這件事情做好所帶來的效益真的很高,也真的有一些人上了一些 patch !

開心寫程式…嗎?

以前在 Mozilla 的時候,我們 app 的程式是架構在 require.js 之上以 AMD 的模式開發,所以時間久了我也漸漸的習慣了這種寫程式的方式,所以一開始的 Kaku 也是以這種方式寫的(對,之後被我全砍了)。但是時間久了我發現我漸漸的被他的東西綁住,整個 repo 開始要加入他專屬的設定檔去設定東西,最慘的就是寫測試的時候還要特別去設定一些東西才可以讓 AMD 的程式碼順利的跑在 require.js 上面。然後我記得最麻煩的是前端用的 require.js 和後端用的 require.js 無法混用,我還要特別抓一份存在 node_module (WTF),然後它對於 ES6 的支援度不知道為什麼有很多問題,所以到後面有很多東西不是沒有測試,而是我不知道要怎麼讓他成功的跑在測試環境上面所以才沒有寫,囧!

這些其實不是壓倒我的最後一根稻草,壓倒我的是 3rd-party library 對 AMD 的支援有一些問題,不知道是那些作者在寫 UMD 寫太爛還是怎樣,有時候那些判斷的順序寫錯就無法用,囧!!所以那個時候為了讓很多 3rd-party library 可以使用,還特別 fork 並改了好多個專案,雖然大多都是 quickfix 不過也是很麻煩呀!

之後,因為強者我前同事 @rickychien (Mozilla 已經變前公司了你不知道嗎 xDDD) 在這段期間內一直和我在討論引入 webpack 的事情,所以就在某兩天想說長痛不如短痛,一次改了一百多個檔案把之前 AMD 的東西全部拿掉然後把測試還有開發環境一次全部用壞之後,就成功的把程式碼全部轉過去了 xDDD(完全錯誤示範,請不要學!!)

這邊真的要慶幸之前是用 AMD 的模式寫程式,才可以把各個模組切的這麼乾淨,然後通通改用 Common js 的方式載入,然後透過 webpack 來做打包的動作,整個世界美好!

Test + CI + Documentations +++

雖然是 Open Source Project,還是要用高規格來寫程式,該有的 CI、測試、文件都沒有少(有很多還沒寫完就是了…),這些東西真的都是在你要改程式的時候才特別有感!還記得以前不知道在哪個文章上看到幾句話關於工程師最討厭做的事情(以下為大概):

  1. 寫文件
  2. 寫註解
  3. 寫測試
  4. 別人不寫文件
  5. 別人不寫註解
  6. 別人不寫測試

為了不要變成那個讓別人討厭的人,所以只好默默的把這些東西都補齊了 xDD,這些真的很重要呀!

從 NW.js 到 Electron

其實說實在的原本 NodeWebkit(NW.js) 用的好好的,只是想要嘗試一下 Github 特製的 Electron ,所以就一口氣換過去了 xDDD ,說真的之所以會想要轉換過去是覬覦他自動更新的功能,能夠讓應用程式自動更新真的很棒呀,不過研究後才發現他原生只有支援 Mac OS ,Windows 的則是要另外把他包進來,而 Linux 就什麼都沒有了 xDD,而且最麻煩的是要有提供一個 endpoint 讓他去存取得知最新版本,然後當使用者需要更新的時候才會再去相對應的載點下載。

其實想一想整個流程也是很合理啦,不過因為我不想要有伺服器來存這些東西,維護也有成本,所以我的東西都是放在 GitHub Releases 裡,因此就自己利用 GitHub API 自己簡單實做一個各平台都可以用的自動更新程式放在 Kaku 裡,讓他每次被啟動後會去判斷是否需要更新,如果使用者確認要更新後,會再把使用者導到下載程式的地方,完成半自動更新的流程(使用者唯一要多做一步的就是要自己解壓縮檔案然後覆蓋舊的程式這樣)。

說實在的 Electron 本身並沒有帶來太大的好處,一來是整合相關的 gulp 工具不多,二來是因為他的 global shortcut 的設計和 nw.js 的不一樣,需要多處理程式得到 focus 還有失去 focus 的事情(雖然也是好事啦),三來是我的程式沒有複雜到要用到很多特殊功能,所以花了很多不必要的時間 xD。不過用了就用了,有 GitHub 帶著社群開發也可以讓 Electron 更長久,持續觀注!

善用工具、改善工具

Kaku 有使用了很多社群開發的工具,盡量把主要的時間留在開發主要的商業邏輯,或是整合這些工具讓自己可以用得更順手。也因為這樣子,中間發現了一些工具的問題,這個時候要做的第一件事情就是先找找看有沒有其他更好的工具,如果沒有的話,我就會試著去 fork 那個專案然後修有問題的地方,最後再上 PR 給原作者。先不論那個 PR 會不會被接受,但至少在這個過程中,我也試著推動了輪子,試著讓這些東西變得更好,省下別人的時間。如果最後沒被 merge,笑笑也就過了是吧?

行銷!

通常程式設計師都不太會注重這一塊,但是我覺得對於 Open Source Project 來說,這一塊相當重要。這邊想講的不是說要砸多少錢買廣告幹嘛的(拜託,這是 Open Source Project 耶),而是要有一個基本的門面,至少簡單做個網頁加點程式相關的圖片嘛!不得不說在這個資訊暴炸時代,如果資訊本身不夠吸引別人,即使你改變了這個世界幾百次,也不會有任何人注意到的。

沒有人注意到這個專案,就不會有人使用你的程式,就不會有開發者加入和你開發新東西,你就會開始覺得這些東西做了不知道要幹嘛只能自 High,久了也就失去動力繼續下去了。不過至少,你可以去一些開發者論壇以技術的角度切入並和大家分享你做了這些東西,除了彼此技術的成長之外,無形當中也是一種行銷不是嗎?

所以,我就請設計師朋友幫我做了 Logo,也自己簡單的做了一個網頁展示這個程式,雖然沒有多專業但也比什麼都沒有好多了!再適時加上一點點 Social buttons ,如果有人想要分享的話自然就會分享,這樣也就夠啦!

最後最後最後

如果你沒用過 Kaku 的話,請立馬去官網下載,有什麼意見或想法都很歡迎留言給我,敬請期待下一篇文章 😛

[Memo] 兩年之後

Image Credit

two-years-later

時間過的超快,2015 年的七月也過了一半了,在離開 Mozilla Taiwan 半個月後,覺得要好好寫一篇文章記錄這段兩年的旅程。

還記得兩年前,在剛離開前前公司 Trend Micro 後(現在 Mozilla 已經變成前公司了 xDD),再次陷入了找工作的轟炸期,當時還特別寫了一篇文章記錄那幾個月的心境還有過程,在經過各大公司、團隊的連環面試後,意外的拿到很多間公司給的 offer,其中最感謝的就是讓我來到 Mozilla 的主管 – Timdream,沒有因為我只有 10 個月短短的經歷就刷掉我,讓我加入這個大家庭和每位強者同事學習很多東西,除了技術上的成長之外,也因為公司是跨國的公司,所以很多時候要和外國人還有自己 team 的人一起討論事情,雖然英文還是有待加強,不過也讓我在團隊合作這件事情上面學了很多呀。

在 Mozilla 的這段時間,去了很多國家、城市, 最讓我印象深刻的就是在剛進去的時候,剛好遇到三年(還兩年)一次的 Summit 大會,第一次看到規模如此大的會議(全世界的 Mozilla 員工還有 Contributors)、第一次去了美國的 Portland、第一次和同事出國旅遊。這次的會議真的讓我感受到西方國家的人對於工作還有生活的態度,雖然工作重要,但是工作後的玩樂還有 party 也是不能少的,該放鬆的時候就一定要放鬆,玩的比大家都還要 High 呀。

portland-1

portland-2

portland-3

從 Summit 回來之後不知道過了多久,因為職務調動的關係就被分配到 Settings App team,這個 team 主要就是由人生勝利組的學長 Arthur 帶著其他人一起守住 FxOS 裡面的 Settings app(就是大家手機裡面的「設定」),不得不說這個 app 真的是包山包海包了又包包了再包,有一大堆和電信業者之間的通訊問題要處理、有一大家和系統之間的複雜互動還有一堆各 app 都要進來插一些自己的客製化設定,真的是一個不得小覷的 app!

在這個 team 裡,真的要特別感謝 Arthur、Ian 還有 Fred。感謝 Arthur 教我很多程式設計的一些眉眉角角,我永遠都會記得 Data / UI 分離這個準則的 xD。感謝 Ian 在 Settings app 裡藍芽的貢獻,如果沒有你擋下這些東西我們就屎定了 xD。感謝 Fred 和我一起處理很多 FxOS Tablet 的問題,當時 tune CSS 真的 tune 的很想死。到底是哪個____把 CSS rule 寫這麼死的啦 xD

也因為這個 team,在 FxOS 1.3 -> FxOS 1.4 workweek 的時候,我和 Arthur 一起和國外飛來的同事處理了很多 DSDS 的問題(就是所謂的雙卡雙待),而那是我唯一一次在 Mozilla 辦公室待到超過 11 點的時候,雖然那個時候很累,不過有這些戰友撐過那一週也是一個很特別的體驗!如果沒有這個 workweek,我也沒有機會去 101 頂樓看整片台北市的夜景(雖然裡面的商店都在賣高價商品給陸客有點煩人之外其他都算不錯),真的,很美。

101

之後,和整個 Gaia team 的大家也變得比較熟了,每一季大家都會舉辦 Team Building 出去某個地方玩一整天,大家一起打過桌遊、打過保齡球、玩過密室逃脫、去過淡水、去挑戰過熱血的抱石活動、去日月潭一起環湖騎腳踏車,好多有趣的事情都在這兩年內發生過,我還記得當時的宮博說過一句話,大意是說「在一些日子之後,最讓你印象深刻的不會是在這間公司工作過了什麼、做了哪些事情。反之,是那些曾經一起工作的人、那些回憶,才會讓你永藏於心」。

兩年之後,我覺得這句話說的真的很有道理,以前曾經去過的那些地方、那些景點都不會有太大的改變,變的是陪你再次來到這裡的人。不過想想,如果沒有前前公司的結束,也就不會有前公司的開始,也就不會有這些精彩的回憶了吧?我們不也是這樣從國小、國中、高中到大學這樣走來的嗎?

兩年之後,很高興認識了你們,謝謝你們給我這個機會參與這一段回憶與歷史,中間也許難免有好、有壞、有淚水、有歡笑,不過這也是人生之所以稱作人生的原因不是嗎?

下一段旅程即將開始,
謝謝你們,在兩年之後。

Special thanks to : Ricky, Gary, Greg, Arthur, Evan, Dominic, George, Ian, Rudy, Steve, Jessica, Sylvia, HsinYi, popochess, Yang-Jhu, Tim, Evelyn, Yuren, Edgar, Fred, Alive, Bella, Fang, Carol, Rex, Tzu-Lin, Luke, Clarice, Paul, Peko, Kate, Michelle … etc.

team3

team4

team1

team2

[FxOS] Settings App – Call Settings

Call Panel

Screenshots

F1C9BD08-E0FE-4327-8D41-0289D3357DC9

Call Panel

Introduction

Call Settings is one of the most important panel that can let users highly customize their own call related settings like Call Waiting, Call Forwarding … etc. (We will cover each part later) Based on the screenshot above, you can see that for this panel, it’s more like an entry point for every panel and also it will display some useful information taken from hardware.

But when you navigate from this panel to others and navigate back, you may notice that some menu items are disabled at first and you can’t manipulate that. This is not a bug but also quite a feature. By doing so, we can make sure that each time when displaying them, we will always use latest value from hardware to make sure we won’t display some outdated information to mislead users.

Call Voice Mail Settings Panel (Dialog)

Screenshots

7E8274FF-D506-492F-9457-B42CA6A4C049

Call Voicemail Panel

Introduction

For every simcard, there must be a special number that you can dial to set your voicemail number and this is why we need this dialog in Settings App. When showing this dialog, it will try to get preset voicemail number in mozSettings db and show it at first. Here, you may get confused why it can get the right number from db, this is because in settings/js/panels/call/panel.js, we also need to show voicemail number on the menu item, so when trying to initialize the item, we will check whether there is any provided number from mozVoicemail API and store it into db, so that’s why in this dialog, you can get this value from db.

Call FDN Settings Panel

Screenshots

28B3155B-DB63-4498-9586-101599D1A41A

Call FDN Settings Panel

0B2234D7-091F-4ACA-9497-9FBB3D0AC630

Enable / Disable FDN

Introduction

This panel is also an entry point that we can set settings related to Fixed Dialing Numbers. Here, we provide a toggle that you can enable / disable this feature. When clicking on the toggle, it will trigger DialogService to show SimpinDialog which is responsible for all Simpin related operations. This feature will only be enabled / disabled when you successfully type your PIN2 correctly in the dialog.

Call FDN List Panel

Screenshots

8A1982D3-2ACC-46D7-BC38-05E587BD17D2

Call FDN List Panel

568610E8-C6ED-46F5-B2BB-01F1940DAF78

Popup menu when clicking on FDN number

Introduction

Here, in this panel, we will list down all preset FDN numbers in the list. When clicking on any number, we will show an popup for it and you can decide whether to call, edit and delete or not. Same with enable FDN, if you are going to do any operation I mentioned, we will use DialogService to show SimpinDialog to confirm this operation.

For any FDN number, they will all be stored inside your simcard. Sometime, based on your simcard, you may have an upper bound for the number of FDN numbers, but this depended on operators so the number may vary. So, if you hit an error message when creating a new number, you may go into this situation.

Call FDN List Add Panel (Dialog)

Screenshots

10125634-9757-44FA-82A4-252CF2A3B4E9

Call FDN List Add Panel (add mode)

DFD4AD2B-5B62-472F-BB03-5C5062C98E83

Call FDN List Add Panel (edit mode)

Introduction

When clicking on the Add button in Call FDN List Panel, this dialog will pop up and ask users to input preferred name and number for this set of FDN number. Instead of adding, this dialog is also can be reused for editing. Normally there is no specific validation rules for these two fields in our codes, instead, we will pass wrapped object from FdnContext.createAction and pass it to SimpinDialog, it will directly communicate with operator and if there is any error coming up, we will directly report it and display to users.

Call Forwarding Panel

Screenshots

6964464D-617A-4356-8CC4-5E39FADF56E6

Call Forwarding Panel

Introduction

Honestly, Call Forwarding can be the most complex panel in Call Settings (especially before it was refactored), so let me briefly tell you a story behind this panel.

When users click on any menu item and type number for any Call Forwarding option (For this part, please check Call Forwarding Details section), after submitting, we can get wrapped results from the dialog and use call/call_forwarding.js to help us handle this object. After doing some tests, it seems that it is not able to do multi tasks when interacting with Gecko’s API (This should be the problem in modem). So, in order to make anything works perfect, we create another module called CallSettingsTaskScheduler (call/call_settings_task_scheduler.js) inherited from TaskScheduler (modules/base/task_scheduler.js).

TaskScheduler is obvious responsible for handling different tasks and make sure they are all scheduled and can be executed one by one without conflicting each other. While for CallSettingsTaskScheduler, it is just an extended class with some customized TASK_TYPE and error handling.

So back to topic, because we aren’t able to do more than one request on modem each time, we need the help from task scheduler to achieve this. This operation includes get and set, so they all should be scheduled. If we don’t do this in order, modem will directly throw out errors and our request would be dropped and this would make our state inconsistent with hardware.

In addition to this, there is also another special feature that TaskScheduler provides – if there is another same-type task coming up, we will remove queued same-type task and push the new on in the array. By doing so, we can make sure we won’t send outdated request and would always keep the latest one.

And for UI, when modem is busy on handling our operation, we should disable all UIs while normal, we should make them back. So, in panel, we will observe CallForwarding’s internal _state to lock / unlock UI.

For anything else, please check our script.

Call Forwarding Details Panel (Dialog)

Screenshots

CF3AF5AE-E101-4564-B490-624B24F61061

Call Forwarding Details Panel (Dialog)

Introduction

This is the dialog that you can set any number on each Call Forwarding option. Right now, because we do support 4 different options for Call Forwarding but with the same UI, we will reuse this dialog for all of them instead of duplicating many codes. But basically, there is no much logics hidden in this dialog and all what it does is pass the result back to Call Forwarding Panel (Caller) and the caller will do following operations based on returned values.

For more details about how Call Forwarding works internally, please check Call Forwarding Panel section for more details.

Call Barring Panel

Screenshots

5E57AD2D-F02A-46F9-9647-098B898D4993

Call Barring Panel

Introduction

In this panel, you can restrict certain types of outgoing calls and incoming calls. There are no special logics handled in this panel and this can be treated as a toggle that helps you customize your Call settings.

[FxOS] Settings App – SimCardManager

Simcard Manager

Screenshots

root2

Root panel

SimcardManager2

Simcard Manager

Introduction

After 1.4+, FxOS has started to support DSDS (Dual Sim feature) that you can insert 2 simcards into your FxOS device. By default, because FxOS is a unified OS that should be used in different devices, we will automatically hide this entry point by default if there is no more than one physical simcard slot.

If you check source codes in settings/js/panels/simcard_manager, you would notice that we have sim_ui_model.js and simcard_manager.js. Let me briefly explain the responsibilities of these two different scripts below.

For SimUIModel, this is a abstract interface between hardware information and our UI. Based on UX’s spec, there are so many different scenarios that we have to show / hide some parts of UI like simcard is not inserted, simcard is locked, simcard is blocked …etc. So, that’s why we need SimUIModel to control every sub-states.

While for SimcardManager, it will bridge the internal state of SimUIModel and real UI to make sure what should be hidden and what should be updated. In addition to this, SimcardManager also needs to watch some hardware events (like AirplaneMode, cardstatechange … etc) to update its UI to make sure they do reflect the real status.

In SimcardManager, there are three important select/option called Outgoing Calls, Outgoing Messages and Data. For some apps (like dialer), they will watch these mozSettingsKey to show / hide some hints to users, for example, if you choose Always Ask for outgoing calls, every time when you are trying to dial out a number, it will keep popping up a simcard picker UI so that you can choose which number you are going to use to dial.

But, there is one black magic that you need to keep in mind when you are dealing with these three select/option. In system app, there is one file called sim_settings_helper.js which does lots of works with these three options. Based on UX’s spec, there is a special request that we have to automatically switch options if from 2 simcards to 1 simcard. Interestingly, because from Gaia (including Gecko) aspect, we can’t directly make sure the second card is indeed inserted (We did encountered one edge case that one of colleague’s old simcard is hard to be recognized by our hardware and it takes more than 3 ~ 5 seconds to get its information from Gecko), due to this, sim_settings_helper.js will wait for upcoming event – simslotready from simslot_manager.js to make sure we did wait longer enough for the second card, and we can based on current situation to decided whether to switch option to another card or not.

[FxOS] Settings App – Wifi

Wifi

Flowchart

Wifi-4

Wifi Panel

Screenshot

44890310-4321-4780-B47D-7C55F31C131E

Wifi Panel (A)

208C8D9A-B39D-4A81-A6C3-19DBAEC8259D

Wifi Panel (B)

Introduction

Wifi panel is the main entry point for the other dialogs / panels. As you may see on the screenshot above, in this panel, users can turn on / off Wifi, decide which AP to connect with and manage certificates or whatever settings related to Wifi.

If you check settings/js/panels/wifi/, you will notice a script which is called wifi_network_list.js. This script is so important that we will use it to generate a list of APs that users can interact with. For example, if you click on any listed AP, it will automatically check its own encryption to show which kind of dialog or just connect to that AP directly.

In addition to this, it will also automatically check its current status from Gecko to see whether it should update its signal / wording … etc. By doing so, we encapsulate all logics within this list and caller doesn’t have to know these details when using it.

Wifi WPS Panel (Dialog)

Screenshot

C6FBDCA2-D54B-4D51-90DC-FDEFA73CEE12

Wifi WPS Panel

Introduction

WPS is another way to connect to AP but this needs some special support from it to make the functionality work. If your AP does support this, users can click on Connect with WPS button to select which way to use to connect with WPS.

From Gaia side, there is no much works here and we simply provide a basic UI for users to choose and configure. So for more details, please go check Gecko’s source code for this part.

Wifi Status Panel (Dialog)

Screenshot

C5B6EB09-BA07-4D67-8684-AD4DDC662D62

Wifi Status Panel

Introduction

When clicking on connected AP in Wifi Panel, this dialog would be popped up to tell users all needed information about this AP including Security, Signal strength, IP address and Link Speed. In addition to this, you can also forget this AP by clicking right-up button.

Wifi Auth Panel (Dialog)

Screenshot

A13A9735-54E0-46A8-9002-688E15DC8097

Wifi Auth Panel

Introduction

If users click on non-connected and encrypted AP from Wifi panel, we will pop up Wifi Auth Panel to users. Compared with non-encrypted AP, normally users have to type password or do some extra pre-settings to connect to this AP.

Wifi Manage Networks Panel

Screenshot

AE570F39-07F3-41A8-BC11-5A02C01939A2

Wifi Manage Networks Panel

Introduction

In this panel, we will list down all connected AP here. If users click on the item, the confirm pop-up will be shown to double confirm whether they really want to remove forget connected AP or not. So for this panel’s code, there is no much complex works but only some UI related stuffs.

Wifi Join Hidden Panel (Dialog)

Screenshot

F8F1053A-C63E-4ED6-804A-596755C6F966

Wifi Join Hidden Panel

Introduction

This panel is pretty simple enough and it will transform all user’s input into a recognizable object for WifiManager. But there is one thing that should be noticed. Because there are some shared UI / logics for users to select security, EAP method … etc across panels (Wifi Auth Panel & Wifi Join Hidden Panel), we have to use a shared script to control them.

But, sadly, because there are still some minor difference between these two pages, in shard script, we will check some element’s existence before manipulating. So please remember to double check UI codes and shard script for this part before adding new rules. Otherwise, you may break another panel.

Wifi Manage Certificates Panel

Screenshot

CAF97E29-4E6B-4921-A4E9-D302DD874DC3

Wifi Manage Certificates Panel

Introduction

If users are trying to connect with AP with WPA-EAP encryption, under some special EAP methods, they need users to provide needed Server Certificates and User Certificates for authentications.

So, if users are trying to connect to AP with these EAP methods, they have to go to this panel and import needed certificates first, otherwise, we can’t find out needed certificates when users are trying to join hidden network.

Wifi Select Certificate File Panel

Screenshot

2E3A5B59-0C08-444B-A12F-AEEDAA211886

Wifi Select Certificate File Panel

Introduction

In this panel, we will list down all possible certificates from SD card and present them to users. When clicking on these items, we will redirect them to Wifi Enter Certificate Nickname Panel.

Wifi Enter Certificate Nickname Panel (Dialog)

Screenshot

D1A80F77-1DC3-42E8-AC72-B6FC88C65FA0

Wifi Enter Certificate Nickname Panel

Introduction

After selecting needed certificate from Wifi Select Certificate File Panel, users will be redirected to this dialog. In this dialog, users can decide whether to rename this certificate or not. Interestingly, if you already have one certificate named with the same name, you are not allowed to name it again because Gecko would throw out some error in this special case.

[FxOS] Settings App – AirplaneModeHelper

AirplaneModeHelper

Flowchart

AirplaneModeHelper

Screenshots

root2

 Setting’s root panel

Introduction

For developers, AirplaneMode is a complicated service that has deep relationships between different services like Bluetooth, Wifi and MobileConnections. Because these services are all related to hardwares, there must be some round-trip time that you have to wait. In order to make these operations encapsulated, they are all handled in system/js/airplane_mode.js. and we think the other apps should just use a trigger to tell System app to do following works.

But due to the restriction that we can’t easily communicate across apps easily, we have to use some internal settings key to communicate. But in order to make sure other apps won’t directly manipulate the communication key that would break the other apps, we think the better way is to design an unified helper for everyone to use, and all these details will be hidden within APIs which it exposes and that’s why we need AirplaneModeHelper (its abbreviation would be AMH, and related file would be shared/js/airplane_mode_helper.js).

If you check below flowchart, you can notice that there are some useful API like ready(), setEnabled(), getStatus(), addEventListener() and removeEventListener() that you can use to build up your business logics. Take Settings app for example, there is a toggle in its root panel and users can click on it to enable / disable AirplaneMode, we use AMH to manipulate it and make sure we will block UI when enabling/disabling and unblock UI when enabled/disabled.

So with AMH, you can do whatever you want which relates to AirplaneMode, while for more details, please check its source code and flowchart below.

[FxOS] Settings App – DialogService v.s. DialogManager

Image Credit

settings

DialogService

Flowchart

DialogService-3

DialogService focuses on controlling states between dialogs, it will make sure every time there is only one dialog showing up on the screen and for the others, they will be queued as an internal state and will be executed one by one when current dialog is dismissed.

Right now we support 4 different types of dialogs, AlertDialog, ConfirmDialog, PromptDialog and PanelDialog in DialogService.

For the previous three dialogs, they are used as a substitution of native alert, confirm and prompt API with predefined layout based on UX’s spec. While for PanelDialog, you can define your own dialog with pre-defined interface and DialogService will help you show it with all necessary callbacks are bounded on UI.

While for lifecycle of dialogs, they are all handled in DialogManager and please go check related documentation for this part.

DialogManager

DialogManager-2

DialogManager is a manager that mainly focuses on controlling the whole life cycle of each dialog. It will load panel, initialize panel, use pre-defined transition to show panel when DialogManager.open() is called. While for DialogManager.close(), it will find out which panel is going to be closed, validate the result of onSubmit() or onCancel(), and use pre-defined transition to hide panel.

Basically, this DialogManager will be only used accompanied with DialogService. If you want to know more details about how they are communicated with each other, you can go check settings/js/modules/dialog_service.js for more details.

[FxOS] Settings App – Dialog v.s. Panel

fxos

In Settings app, we have two different concepts – one is Dialog while the other one is Panel. The main difference between them is how they are presented. From UX spec, if we need users to do some actions and then submit, normally they will be presented with Dialog with cancel and submit button. While for Panel, it is just a simple view that focuses on presenting data and basically you can notice that there is always a “<“ backward arrow in the header that can help you navigate back to previous panel.

63BF65E7-D01A-4934-B67B-D396E067C044

Wifi Auth Dialog

C2C748FE-3B37-4CF1-A0B4-C96DE1767C15

Wifi Panel

If you are going to create a dialog, here comes some notes that you need to be aware of at first. Let’s use Wifi Auth Dialog for example :

[Setup]

  1. You have to register one section element in Setting’s index.html.
    1. <section is=”wifi-auth” role=”region” id=”wifi-auth” class=”dialog”></section>
    2. remember, you need to add one extra dialog class to make sure the section can be applied with right CSS style
  2. Remember to add one more link element in index.html to make sure related sub-document will be loaded.
    1. <link rel=”import” href=”/elements/wifi_auth.html”>
  3. And then, you can follow scripts under settings/js/panels/* to make sure all dialog needed codes can be loaded.

Take settings/js/panels/wifi_auth/panel.js for example, for Dialog, there are some special API you can use and something that you need to know.

  1. In order to pass data back to caller, you can use onCancel and onSubmit function with resolved data. By doing so, caller can use DialogService.show(‘panelId’).then(function(result) {}); to get needed data.
  2. And also, if you want to programmatically cancel or submit, after Bug 1166495 is landed, you can use this.cancel() and this.submit() to achieve this.

For Panel, you can follow [Setup] part above without adding extra class and everything is done ! Based on our design, they share the same interface and there is no much difference between them, just make sure you won’t use onSubmit(), onCancel() and Dialog related API described above, then you are good !

[Movie] Furious 7 – all about bonds

Image Credit

https://www.youtube.com/watch?v=0aIo2dlGMvY

It’s been a long day without you my friend
And I’ll tell you all about it when I see you again
We’ve come a long way from where we began
Oh I’ll tell you all about it when I see you again

We all have these kinds of good friends that we have such bonds with each other. No matter what (s)he does, you will always back her/him up.

After watching this movie last weekend, it really makes me think of some old times with them. For all my best friends.