PHOTOSHOP.COM MOBILE APP FOR ANDROID™を使ってみました。

連携できるそうです。

PHOTOSHOP.COM MOBILE APP FOR ANDROID™

テキトーに翻訳してみる

アンドロイドケータイ上で画像を編集したいときは、
どんなアプリからでも「Photoshop.com Mobile1.1 エディタ」を利用することができます。
(Photoshop.com アプリをAndroidにインストールしてください。)

このエディタは「Intent.ACTION_EDIT」というアクションで操作できます。(MIME-TYPEは「image/*」)


以下が、あなたのアプリのアクティビティから「Photoshop.com Mobileエディタ」を起動する方法です。

// アクティビィティのメソッドの中で
Uri imageToEditUri = … // 編集する画像のuri
String imageToEditMimeType = … // “image/*”でなければならない
Intent launchEditor = new Intent();
launchEditor.setAction(Intent.ACTION_EDIT);
launchEditor.setDataAndType(imageToEditUri, imageToEditMimeType);

try
{
    // エディタアクティビティを起動
    startActivityForResult(launchEditor, LAUNCH_EDITOR);
}
catch (ActivityNotFoundException e)
{
    // エラーの場合
    // Photoshop.com Mobileのバージョンが低かったり、インストールしてなかったり。
}

エディタを利用して編集をした後ですが、onActivityResultを上書きしますので、
あなたのリクエストの「resultCode」をチェックしてください。
もし、編集後、画像を保存していたら、「RESULT_OK」を返し、画像を保存したURIを、Intent.getData()で取得することができます。
編集操作を途中でキャンセルしていると、「RESULT_CANCELED」を返します。


以下が、onActivityResultを利用したサンプルコードです。

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == LAUNCH_EDITOR)
    {
        if (resultCode == Activity.RESULT_OK)
        {
            Uri savedImage = data.getData();
            // savedImage is the Uri for the newly created
            // edited version of the original image.
        }
        else 
        {
            // Edit Operation canceled by user
        }
    }
}


以上の、アプリ-エディタ起動-エディタ編集-アプリ
をまとめたのが、以下のサンプルです。

package com.adobe.psmobile.editor.launcherappone;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

// LauncherOneMain: Main activity 
public class LauncherOneMain extends Activity
{
    private static final int SELECT_IMAGE = 0; // selector for image gallery call
    private static final int LAUNCH_EDITOR = 1; // selector for editor launch call

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // launch the image picker
        launchImagePicker();    

    }

    // Launches the image picker.
    public void launchImagePicker()
    {
        try
        {
            // This opens the Android Gallery or a similar activity
            // that displays the images on the Android devices's SD card.
            // The selected image is returned with a call to onActivityResult
            // with the request code SELECT_IMAGE
            startActivityForResult(new Intent(Intent.ACTION_PICK,
              android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI),
              SELECT_IMAGE);
        }
        catch (ActivityNotFoundException e)
        {
            // No activity found that handles Intent.ACTION_PICK
        }
    }

    /**
    * onActivityResult: Called when an activity you launched exits,
    * giving you the requestCode you started it with along with
    * the resultCode it returned, and any additional returned data.
    * The resultCode will be RESULT_CANCELED if the activity explicitly
    * returned that, didn't return any result, or
    * abnormally terminated during its operation.
    */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == SELECT_IMAGE)
        {
            if (resultCode == Activity.RESULT_OK)
            {
                // get the Uri for the selected image
                Uri selectedImage = data.getData();

                // create an Intent to launch activity that
                // supports ACTION_EDIT for
                // the selected image. Photoshop.com Mobile Editor
                // handles such intent
                Intent launchEditor = new Intent();
                launchEditor.setAction(Intent.ACTION_EDIT);
                launchEditor.setDataAndType(selectedImage, data.getType());

                try
                {
                    // start the activity. Result will be returned in                     // onActivityResult call with
                    // requestCode LAUNCH_EDITOR
                    startActivityForResult(launchEditor, LAUNCH_EDITOR);
                }
                catch (ActivityNotFoundException e)
                {
                    // No activity found. Correct version of Photoshop.com Mobile
                    // Editor not installed.
                    Toast myToast = Toast.makeText(this,
                    new String("Failed to Launch Editor. Please make sure
                      Photoshop.com Mobile 1.1 or above is installed."),
                    Toast.LENGTH_SHORT);
                    myToast.show();
                }
            }
        }
        else if (requestCode == LAUNCH_EDITOR)
        {
            // returned from editor

            String resultStr = null;

            if (resultCode == Activity.RESULT_OK)
            {
                // Editor operation returned after saving the image.
                // Get the Uri for the newly edited image that was saved.
                 Uri savedImage = data.getData();
                resultStr = new String("Editor saved image to Uri: ") +
                  savedImage.toString();
            }
            else
            {
                // Editor operation canceled by user
                resultStr = new String("Edit operation canceled.");
            }

            // display Toast with message
            Toast myToast = Toast.makeText(this, resultStr, Toast.LENGTH_SHORT);
            myToast.show();

            // now that the editing operation has completed,
            // launch the image picker again
            launchImagePicker();
        }
    }

} 

コピペして動かしてみる

コピペして、コンパイルして、インストールしてみました。


タップして起動すると、保存している画像の選択画面が表示されます。


画像を選択すると、Photoshopのエディタ起動でその画像が編集待ちになりました。

加工して、


保存ボタンで、保存されました。


ブラウザアプリなど起動中からの、[MENU]-[共有]の処理の流れのように、Photoshopエディタアクティビティ側で「ひたすら待っている」だけかと思っていたのだが違う。

コードについてのメモ

画像ギャラリーのサムネイル一覧を起動する
startActivityForResult(new Intent(Intent.ACTION_PICK,
                       android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI),
                       SELECT_IMAGE)

new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI)がそれに該当する。

他の(外部)アクティビティを利用する場合
try {
    startActivityForResult();
} catch (ActivityNotFoundException e) {
}

として、インストールなしの場合をActivityNotFoundException で拾う。

これからのアプリの連携

これから、アプリ同士が連携することが増えてくると思う。
この場合は、「画像処理」部分をPhotoshop側に任せて、その他の部分(連携元)を作成するという形。

画像処理アプリを単体でみると、

  • 画像処理に関しては餅屋である
  • 連携元アプリ(たとえばカメラアプリ)の人気に便乗できる

ということで、何の損もないような気がするし、

連携元アプリ側からみると、

  • 画像処理は連携すればよし
  • ほかの得意な処理の開発に注力すればよし

となる。


増えそうだ、連携アプリ。