Titanium Mobile 2.0 の変更点まとめ

Titanium Mobileが1.8から2.0にメジャーバージョンアップした。
iPhoneアプリもAndroidもTitaniumを使っているので、
変更された箇所とか、バージョンアップでのアプリ側で
対応が必要だった箇所をまとめておこうと思う。

Titanium Mobile 2.0ローンチイベントについて
Titanium Mobile 2.0ローンチイベントレポート – Titanium News
Titanium Mobile 2.0 ローンチ記念イベントに行ってきた « kwLog
Titanium 2.0 ローンチイベントに参加して LT もしてきました | imthinker.net
ローンチイベントに参加された方のリンクを貼っておきます。

こちらのまとめも良かったです。
Titanium Mobile 2.0 対応など – Naoya’s Hatena Diary
とても参考になりました!

まずは、appceleratorのRelease Notesを転載。
http://docs.appcelerator.com/titanium/release-notes/?version=2.0.1.GA

New in This Relase
・Layout System Updates
・Support for Appcelerator Cloud Services (formerly CocoaFish)
・Mobile Web Platform Release Candidate
・Android Geolocation Enhancements
・Defined Module APIs for Android and iOS

書いてあるままですが、
UIまわりの変更が自分的には大きかったです。
1.8系で作っていたアプリも、2.0にしてから、
レイアウト崩れが発生しました。

レイアウトに関する変更点をRelease Notesから転載。

The major changes to the layout system involve:
1)Improved handling for automatic sizing of views
2)Batch layout updates for improved performance
3)Post-layout event generated when layout is complete
4)New precedence order for layout parameters

それぞれ説明します。

1)自動サイジングの精度向上
 Ti.UI.FILL(指定された領域でなるべく大きく配置)
 Ti.UI.SIZE(指定された領域でなるべく小さく配置)
 の新規定数が用意されました。
 画面サイズの違うAndroidには多用されそう。

2)バッチレイアウト
レイアウトでバッチ処理が可能に。
コンポーネントで以下の様に複数のプロパティを設定すると、設定毎に再描画が走っていた。

myView.startLayout();
myView.top = 50;
myView.left = 50;
myView.width = 200;
myView.finishLayout();

それが、

myView.updateLayout({
top: 50,
left: 50,
width: 200
});

の様にまとめて描画処理ができる。
(まとめて今まで書いてたけど、描画は別々だったってこと?)

3)レイアウト変更完了を検知するイベントが出来ました。

View.postLayout ですね。

var postLayoutCallback = function(e) {
Ti.API.info(String.format(“Layout done, left: %f, width: %f”, myView.rect.x, myView.rect.width));
myView.removeEventListener(‘postlayout’, postLayoutCallback);
}
myView.addEventListener(‘postlayout’, postLayoutCallback);
myView.updateLayout({
left: ’25%’,
width: ’25%’
});

こんな感じで、位置変更後のタイミングでpostLayoutイベントが発行されます。

4)レイアウトパラメータの優先規則が変わった様です。

変更点は公式のここに詳しく書いてました。
https://wiki.appcelerator.org/display/guides/Titanium+2.0+Layout+Changes

・Any UI component with the width property defined as “auto” can safely define its width parameter as Ti.UI.SIZE to return to 1.8 behavior.
・Any UI component with the width property undefined and with less than 2 positioning pins defined can safely define its width parameter as Ti.UI.FILL to return to 1.8 behavior.

とあるので、
・1.8系でautoを指定してた場所には、2.0ではTi.UI.SIZEを
・1.8系で何も指定していなかった場合は、2.0ではTi.UI.FILLを
指定すれば互換するとのこと。

実際に、width:Ti.UI.FILLなどを指定して、画面の崩れは無くなりました。

このエントリーをはてなブックマークに追加
はてなブックマーク - Titanium Mobile 2.0 の変更点まとめ
Share on Facebook
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed
Titanium Mobile 2.0 の変更点まとめpagnum.jp BLOG

メモ:Titaniumで用意する画像のサイズまとめ

Titaniumで使うアプリのアイコンは下記の内容で格納。

・アプリアイコン(3G、4、iPad)
appicon.png      57×57
appicon@2x.png    114×114
appicon-72.png     72×72

こちらから引用。他にもたくさん書いてあります。
http://www.sawadaru.com/blog/?p=293

こちらも参考になりました。
http://blog.syuhari.jp/archives/2194

このエントリーをはてなブックマークに追加
はてなブックマーク - メモ:Titaniumで用意する画像のサイズまとめ
Share on Facebook
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed
メモ:Titaniumで用意する画像のサイズまとめpagnum.jp BLOG

【作ったアプリにかっこいいリンクバッチをつけたい】Abailable on the App Store Badge & Get it on Google Play button の入手方法

iPhoneアプリやAndroidアプリを作ったら、自身のブログやサイトにかっこいいバッチをつけたいですよね。


とか、

Get it on Google Play

とかです。

それぞれの入手方法を掲載します。

■App Store

Marketing Resources
http://developer.apple.com/iphone/appstore/marketing.html

※アカウントが必要ですよ。

■Google Play

Build a Google Play button
http://developer.android.com/guide/publishing/publishing.html#BuildaButton

AppStoreとは違い、リンクをジェネレートできます。

公式のボタンを設置できると、なんだか安心感増しますね。

このエントリーをはてなブックマークに追加
はてなブックマーク - 【作ったアプリにかっこいいリンクバッチをつけたい】Abailable on the App Store Badge & Get it on Google Play button の入手方法
Share on Facebook
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed
【作ったアプリにかっこいいリンクバッチをつけたい】Abailable on the App Store Badge & Get it on Google Play button の入手方法pagnum.jp BLOG

jqMobiのサンプルを調べ尽くす その3

ようやくサンプル文のbodyに入れます!
今回は初期に表示される画面の構成を書きます。

前回はこちら
#そんなに詳しくない人が頑張って解読してますので、間違ってる内容とかあったらぜひともコメントくださいませ。

102
<div id="header">

</div>

headerは何にも入ってない。

106
<div id="content">
	<div title='Welcome' id="main" class="panel" selected="true">
</div>

contentです。
アプリ面の構成は、
content : ヘッドの部分(タイトルとか戻るボタンがあるバー)+タッチできるメイン画面
navbar : 下に不動で出続けるメニュー
という作りみたいですね。
(footerは無いみたい。headerは何のために??)

titleは最初にアプリ起動したときにヘッドバーに表示される名前なので、
アプリ名でも入れておけば良いと思います。

でも、ヘッドバーの文字はなんだか中央より左にずれていて気持ち悪いです。

109
	<h2 class='expanded' onclick='showHide(this,"main_info");'>Welcome</h2>
		<p id='main_info'>Welcome to the kitchen sink demo for jqMobi.  Here you will find samples of how to use the jqMobi libraries.  Please select an option from below.</p>
		<ul>
		 <li><a href="#jqm" >jqMobi</a></li>
		 <li><a href="#jqmui" >jqUi</a></li>
		 <li><a href="#jqmweb" >jqPlugins</a></li>
		</ul>

	</div>

はい。初期表示画面の中身ですね。

onclick='showHide(this,"main_info");

これを設定しておけば、ポチット押すと表示されたり非表示したりします。
「main_info」 はidの指定ですね。

<p id='main_info'>

この内容を表示・非表示できます。

<ul>
		 <li><a href="#jqm" >jqMobi</a></li>
		 <li><a href="#jqmui" >jqUi</a></li>
		 <li><a href="#jqmweb" >jqPlugins</a></li>
</ul>

これは分かりやすい。スマホっぽいUIに勝手になります。
これは多用しそう。

ちょっとだいぶ下の方になりますが、

1159
<!-- ------------------------------------------ -->
<!-- navbar -->
<div id="navbar">
	<div class="horzRule"></div>
    <a href="#main" class='navbar_home' ontouchstart="">home</a>
    <a href="#jqm" class="navbar_js" ontouchstart="">selectors</a>
    <a href="#jqmui"  class="navbar_ui" ontouchstart="">ui</a>
	<a href="#jqmweb"  class="navbar_plugins" ontouchstart="">plugins</a>
</div>

<!-- ------------------------------------------ -->

ここが下に表示されるメニューの部分ですね。
初期表示は#mainです。117行目で、id=”main”ってdivに指定してましたが、
ボタンを押すと、その内容が表示されます。
同様に、#jqmならば、id=”jqm”で指定された箇所だけを表示します。

その4に続く

このエントリーをはてなブックマークに追加
はてなブックマーク - jqMobiのサンプルを調べ尽くす その3
Share on Facebook
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed
jqMobiのサンプルを調べ尽くす その3pagnum.jp BLOG

jqMobiのサンプルを調べ尽くす その2

前回の続きです。
#そんなに詳しくない人が頑張って解読してますので、間違ってる内容とかあったらぜひともコメントくださいませ。

59行目のスクリプトは、
This function runs once the page is loaded, but appMobi is not yet active
「この関数は、一度ページが読み込まれて実行されますが、appMobiはまだアクティブではありません」by Google先生
中に書いてあるのは、

var webRoot="./kitchensink/";

webRootの設定。

63行目
    var init = function(){
	   $.ui.backButtonText="back";
    };

ヘッダの左に表示されるバックボタンの表示名を指定できる。
日本語ならbackを戻るに変えればOK。

66
    window.addEventListener("load",init,false);

windowロード時にセット

68
    /* This code prevents users from dragging the page */
    var preventDefaultScroll = function(event) {
        event.preventDefault();
        window.scroll(0,0);
        return false;
    };
    document.addEventListener('touchmove', preventDefaultScroll, false);

タッチによるスクロールの挙動を制御。初期位置を決めてるんでしょうか。

76
    /* This code is used to run as soon as appMobi activates */
    var onDeviceReady=function(){
		AppMobi.device.setRotateOrientation("portrait");
        AppMobi.device.setAutoRotate(false);
		webRoot=AppMobi.webRoot+"kitchensink/";
	    //hide splash screen
	    AppMobi.device.hideSplashScreen();	

    };
    document.addEventListener("appMobi.device.ready",onDeviceReady,false);
	function showHide(obj,objToHide){
		var el=$("#"+objToHide)[0];
		if(obj.className=="expanded"){
			obj.className="collapsed";
		}
		else{
			obj.className="expanded";
		}
		$(el).toggle();

	}

いたるところにappMobiが出てきますが、AppMobi社のライブラリを読みにいくんでしょうか。
そういえば、jqMobiはAppMobi社の作ったオープンプラットフォームです。
AppMobiはChromeのエクステンションで、iPhoneやAndroidアプリが作れる
クラウドプラットフォームです。
http://www.lexues.co.jp/appmobi/
詳細はこちら。

とりあえずREADME読む限り、AppMobiを何度も見に行く様に作られてるみたいです。

その3に続く。

このエントリーをはてなブックマークに追加
はてなブックマーク - jqMobiのサンプルを調べ尽くす その2
Share on Facebook
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed
jqMobiのサンプルを調べ尽くす その2pagnum.jp BLOG