2015年10月14日水曜日

[Swift][GoogleAnalytics]CustomDimensionを追加してイベント送信する

Google Analyticsのイベント送信時にCustomDimensionを追加する方法です。

        let tracker = GAI.sharedInstance().defaultTracker
        let params = GAIDictionaryBuilder.createEventWithCategory(
            category,
            action: action,
            label: label,
            value: value)
            .set(_corpId, forKey: GAIFields.customDimensionForIndex(1))
            .build() as [NSObject : AnyObject]
        
        tracker.send(params)


set(_corpId, forKey: GAIFields.customDimensionForIndex(1))でCustomDimensionの要素を追加しています。

2015年10月7日水曜日

[Nexus5][Android 6.0]OTAを手動でUpdateする

Android 6.0のOTA配信が始まりました。
XDAでOTA URLが投稿されています。

http://forum.xda-developers.com/google-nexus-5/general/ref-nexus-5-stock-ota-urls-t2475327

と、いうことでadbコマンドを使用して手動でUpdateしました。


curl -L https://android.googleapis.com/packages/ota/google_hammerhead/8f8cc12f7a9d7561be21f95914f289bda86e402b.signed-hammerhead-MRA58K-from-LMY48M.zip > 8f8cc12f7a9d7561be21f95914f289bda86e402b.signed-hammerhead-MRA58K-from-LMY48M.zip
adb reboot bootloader 
adb sideload 8f8cc12f7a9d7561be21f95914f289bda86e402b.signed-hammerhead-MRA58K-from-LMY48M.zip


2015年9月16日水曜日

Android Mリリース目前のAOSP mirrorの容量



久々にAOSP mirrorを作ってみました。
(備考:ローカルにAOSPのミラーを作成)


容量80GB超えたよ

上記の画像を見ていただければ、お分かり頂けると思いますが、容量が81.25GBと良い勢いで増えています。
いまSSD 128GB上に作成していますが、Android Mがリリースされると100GBまで行くんじゃないかと心配です。



とはいえ、頻繁にAOSPのソースを取得する現場ですと、mirrorがある方が効率的ですので導入を推奨いたします。

2015年9月15日火曜日

AOSP mirrorのrepo syncエラー: GPGが更新されない

久々にAOSP mirrorのrepo syncを実行したところ、エラーとなりました。
どうも、repoの更新ができていないよう。

info: A new version of repo is available


object 5ea32d135963da5542b78895f95332c6a17bbe11
type commit
tag v1.12.31
tagger Dan Willemsen  1441912006 -0700

repo v1.12.31

error: cannot run gpg: No such file or directory
error: could not run gpg.
error: could not verify the tag 'v1.12.31'


warning: Skipped upgrade to unverified version

ググってみたところ、次の方法で解決できるとのこと。
https://groups.google.com/forum/#!searchin/android-building/repo/android-building/ICajKIQlwC8/hxKulJLZ278J

mv ~/.repoconfig/gnupg ~/.repoconfig/gnupg_OLD

repoのconfig内のgnupgが更新されていないようなので、新規で取ってこいってことかな???
mv実行後、repo syncは無事に完遂しました。

2015年8月21日金曜日

iOS8.xでUITableViewAutomaticDimensionを使うと、セル位置が正常にならない

iOS8.xでTableViewのセル高さの自動調整が可能です。

    self.tableView.rowHeight = UITableViewAutomaticDimension



ただし、TableViewからセル選択により画面遷移後、戻ってきたときなど再表示をするとセル位置が調整されていないことがあります。 対策として、一度表示したセルの高さを保持しておいて、estimatedHeightForRowAtIndexPathで値を返します。

    var cellHeight:Dictionary = ["":0]
    
    override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        
        cell.contentView.updateConstraints()
        self.cellHeight[String(indexPath.item )] = Float(cell.frame.size.height)
        
    }
    
    override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        if(self.cellHeight[String(indexPath.item )] != nil){
            return CGFloat(self.cellHeight[String(indexPath.item )]!)
        }
        return self.tableView.estimatedRowHeight
        
    }

2015年6月13日土曜日

CoordinatorLayoutで困った時に確認するIssue Tracker

Android Design Support LibraryのCoordinatorLayoutを使った際に、困った既知(known issue)の問題をまとめます。

画面回転でBehaviorが正常に表示されない

AndroidManifest.xmlで、ActivityにconfigChanges属性で画面回転での再生成を追加すると、Behaviorが正常に表示されないことがあります。
ユースケースとしてはLandscapeからPortraitの画面回転で、現象が発生します。


この現象は、すでに本家Issue Trackerに登録されています。
CoordinatorLayout in design support library does not update child size on rotation
layout_behavior view height doesn't restore when keyboard goes down / ActionBar ActionView partially visible

AppBarLayoutがアニメーションしない

タッチを止めると、次のようにAppBarLayoutの部分が中途半端に残ってしまうことがあります。
Google Playアプリのようにアニメーションで全部消す/表示するには、タッチイベントとAppBarLayoutのオフセット位置、およびBehaviorのonNestedFlingを組み合わせて実装しないといけないのかな?
(ベストプラクティスを教えて欲しい)

Toolbar should settle when only partially scrolled

2015年6月6日土曜日

Android Support library v22.2で追加されたTextInputLayoutを使う

Material DesignのText fieldアニメーションが楽々に実装できるレイアウトです。
http://www.google.com/design/spec/components/text-fields.html#text-fields-single-line-text-field


実装は非常に簡単で、EditTextをTextInputLayutで囲うだけです。
    <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputLayout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:hintTextAppearance="@style/TextInputLayoutHintAppearance">
        <EditText
                android:id="@+id/editText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:inputType="textEmailAddress"
                android:hint="HintText"
                android:ems="10"/>
    </android.support.design.widget.TextInputLayout>




各パーツはマテリアルカラーに準じています。