OSDN Git Service

とりあえず、一覧を取得するロジックを入れてみた。(動作確認はこれから。)
authorMRSa <mrsa@myad.jp>
Mon, 11 Feb 2019 14:15:42 +0000 (23:15 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 11 Feb 2019 14:15:42 +0000 (23:15 +0900)
18 files changed:
app/src/main/java/net/osdn/gokigen/pkremote/IInformationReceiver.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/MainActivity.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/CameraInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/IInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContent.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContentListCallback.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContentsRecognizer.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/IPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/playback/CameraContentInfo.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/playback/CameraContentsRecognizer.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympus/wrapper/playback/OlyCameraPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ricoh/wrapper/RicohGr2InterfaceProvider.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ricoh/wrapper/RicohGr2PlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ricoh/wrapper/RicohGr2StatusChecker.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ricoh/wrapper/RicohGr2StatusHolder.java
app/src/main/java/net/osdn/gokigen/pkremote/scene/CameraSceneUpdater.java
app/src/main/java/net/osdn/gokigen/pkremote/scene/IChangeScene.java
app/src/main/res/values/strings.xml

diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/IInformationReceiver.java b/app/src/main/java/net/osdn/gokigen/pkremote/IInformationReceiver.java
new file mode 100644 (file)
index 0000000..7a01d0e
--- /dev/null
@@ -0,0 +1,6 @@
+package net.osdn.gokigen.pkremote;
+
+public interface IInformationReceiver
+{
+    void updateMessage(final String message, final boolean isBold, final boolean isColor,  final int color);
+}
index 6947c90..d801b43 100644 (file)
@@ -3,6 +3,8 @@ package net.osdn.gokigen.pkremote;
 import android.Manifest;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
+import android.graphics.Color;
+import android.graphics.Typeface;
 import android.os.Bundle;
 
 import androidx.annotation.NonNull;
@@ -20,6 +22,7 @@ import android.view.MenuItem;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.ImageButton;
+import android.widget.TextView;
 
 import net.osdn.gokigen.pkremote.camera.CameraInterfaceProvider;
 import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
@@ -30,7 +33,7 @@ import net.osdn.gokigen.pkremote.scene.CameraSceneUpdater;
  *
  *
  */
-public class MainActivity extends AppCompatActivity implements View.OnClickListener
+public class MainActivity extends AppCompatActivity implements View.OnClickListener, IInformationReceiver
 {
     private final String TAG = toString();
     private IInterfaceProvider interfaceProvider = null;
@@ -43,10 +46,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
             = new BottomNavigationView.OnNavigationItemSelectedListener() {
 
         @Override
-        public boolean onNavigationItemSelected(@NonNull MenuItem item)
-        {
-            switch (item.getItemId())
-            {
+        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+            switch (item.getItemId()) {
                 case R.id.navigation_home:
                     //
                     return (true);
@@ -78,17 +79,13 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
-        try
-        {
+        try {
             ActionBar bar = getSupportActionBar();
-            if (bar != null)
-            {
+            if (bar != null) {
                 // タイトルバーは表示しない
                 bar.hide();
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             e.printStackTrace();
         }
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@@ -122,12 +119,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
     }
 
     /**
-     *   パーミッション設定が終わった後...
-     *
+     * パーミッション設定が終わった後...
      */
     @Override
-    public void onRequestPermissionsResult(int requestCode, @NonNull String  permissions[], @NonNull int[] grantResults)
-    {
+    public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
         super.onRequestPermissionsResult(requestCode, permissions, grantResults);
         prepareClass();
         onReadyClass();
@@ -135,70 +130,54 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
 
     /**
      * クラスの初期化 (instantiate)
-     *
      */
     private void initializeClass()
     {
-        try
-        {
+        try {
             scenceUpdater = CameraSceneUpdater.newInstance(this);
-            interfaceProvider = CameraInterfaceProvider.newInstance(this, scenceUpdater);
+            interfaceProvider = CameraInterfaceProvider.newInstance(this, scenceUpdater, this);
             scenceUpdater.changeFirstFragment(interfaceProvider);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
     /**
-     *    本クラスの準備
+     * 本クラスの準備
      */
-    private void prepareClass()
-    {
-        try
-        {
+    private void prepareClass() {
+        try {
             mImageConnectButton.setOnClickListener(this);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
     /**
-     *    初期化終了時の処理 (カメラへの自動接続)
+     * 初期化終了時の処理 (カメラへの自動接続)
      */
-    private void onReadyClass()
-    {
-        try
-        {
+    private void onReadyClass() {
+        try {
             // カメラに自動接続するかどうか確認
             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
             boolean isAutoConnectCamera = preferences.getBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
             Log.v(TAG, "isAutoConnectCamera() : " + isAutoConnectCamera);
 
             // カメラに接続する
-            if (isAutoConnectCamera)
-            {
+            if (isAutoConnectCamera) {
                 // 自動接続の指示があったとき
                 scenceUpdater.changeCameraConnection();
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
     @Override
-    public void onClick(View v)
-    {
-        try
-        {
+    public void onClick(View v) {
+        try {
             int id = v.getId();
-            switch (id)
-            {
+            switch (id) {
                 case R.id.button_wifi_connect:
                     // カメラとの接続を行う
                     scenceUpdater.changeCameraConnection();
@@ -207,6 +186,44 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
                 default:
                     break;
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void updateMessage(final String message, final boolean isBold, final boolean isColor,  final int color)
+    {
+        try {
+            final TextView messageArea = findViewById(R.id.message);
+            runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        if ((messageArea != null) && (message != null))
+                        {
+                            messageArea.setText(message);
+                            if (isBold)
+                            {
+                                messageArea.setTypeface(Typeface.DEFAULT_BOLD);
+                            }
+                            if (isColor)
+                            {
+                                messageArea.setTextColor(color);
+                            }
+                            else
+                            {
+                                messageArea.setTextColor(Color.DKGRAY);
+                            }
+                            messageArea.invalidate();
+                        }
+                    }
+                    catch (Exception e)
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
         }
         catch (Exception e)
         {
index 03a68f1..272aaef 100644 (file)
@@ -1,11 +1,12 @@
 package net.osdn.gokigen.pkremote.camera;
 
-import android.app.Activity;
 import android.content.SharedPreferences;
 
+import net.osdn.gokigen.pkremote.IInformationReceiver;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentsRecognizer;
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus;
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
@@ -19,12 +20,14 @@ import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl;
+import net.osdn.gokigen.pkremote.camera.playback.CameraContentsRecognizer;
 import net.osdn.gokigen.pkremote.camera.vendor.olympus.IOlympusInterfaceProvider;
 import net.osdn.gokigen.pkremote.camera.vendor.olympus.wrapper.OlympusInterfaceProvider;
 import net.osdn.gokigen.pkremote.camera.vendor.ricoh.wrapper.RicohGr2InterfaceProvider;
 import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
 
 import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
 import androidx.preference.PreferenceManager;
 
 /**
@@ -36,24 +39,28 @@ public class CameraInterfaceProvider implements IInterfaceProvider
     //private final SonyCameraWrapper sony;
     private final OlympusInterfaceProvider olympus;
     private final RicohGr2InterfaceProvider ricohGr2;
-    private final Activity context;
+    private final IInformationReceiver informationReceiver;
+    private final CameraContentsRecognizer cameraContentsRecognizer;
+    private final AppCompatActivity context;
     private ICameraConnection.CameraConnectionMethod connectionMethod = ICameraConnection.CameraConnectionMethod.UNKNOWN;
 
-    public static IInterfaceProvider newInstance(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
+    public static IInterfaceProvider newInstance(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
     {
-        return (new CameraInterfaceProvider(context, provider));
+        return (new CameraInterfaceProvider(context, provider, informationReceiver));
     }
 
     /**
      *
      *
      */
-    private CameraInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
+    private CameraInterfaceProvider(@NonNull AppCompatActivity context, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver)
     {
         this.context = context;
         olympus = new OlympusInterfaceProvider(context, provider);
         ricohGr2 = new RicohGr2InterfaceProvider(context, provider);
         //sony = new SonyCameraWrapper(context, provider);
+        this.informationReceiver = informationReceiver;
+        this.cameraContentsRecognizer = new CameraContentsRecognizer(context, this);
     }
 
     @Override
@@ -398,6 +405,22 @@ public class CameraInterfaceProvider implements IInterfaceProvider
      *
      *
      */
+    @Override
+    public IInformationReceiver getInformationReceiver()
+    {
+        return (informationReceiver);
+    }
+
+    @Override
+    public ICameraContentsRecognizer getCameraContentsRecognizer()
+    {
+        return (cameraContentsRecognizer);
+    }
+
+    /**
+     *
+     *
+     */
     private ICameraConnection.CameraConnectionMethod getCammeraConnectionMethodImpl()
     {
         if (connectionMethod != ICameraConnection.CameraConnectionMethod.UNKNOWN)
index c9c0f3e..46cd3d0 100644 (file)
@@ -1,5 +1,6 @@
 package net.osdn.gokigen.pkremote.camera.interfaces;
 
+import net.osdn.gokigen.pkremote.IInformationReceiver;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
@@ -9,6 +10,7 @@ import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl;
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector;
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl;
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentsRecognizer;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus;
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation;
@@ -43,4 +45,8 @@ public interface IInterfaceProvider
     IOlympusInterfaceProvider getOlympusInterfaceProvider();
 
     ICameraConnection.CameraConnectionMethod getCammeraConnectionMethod();
-    void resetCameraConnectionMethod();}
+    void resetCameraConnectionMethod();
+
+    IInformationReceiver getInformationReceiver();
+    ICameraContentsRecognizer getCameraContentsRecognizer();
+}
\ No newline at end of file
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContent.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContent.java
new file mode 100644 (file)
index 0000000..6f9bff2
--- /dev/null
@@ -0,0 +1,13 @@
+package net.osdn.gokigen.pkremote.camera.interfaces.playback;
+
+import java.util.Date;
+
+public interface ICameraContent
+{
+    String getCameraId();
+    String getCardId();
+    String getContentPath();
+    String getContentName();
+    Date getCapturedDate();
+    void setCapturedDate(Date date);
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContentListCallback.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContentListCallback.java
new file mode 100644 (file)
index 0000000..518e291
--- /dev/null
@@ -0,0 +1,9 @@
+package net.osdn.gokigen.pkremote.camera.interfaces.playback;
+
+import java.util.List;
+
+public interface ICameraContentListCallback
+{
+    void onCompleted(List<ICameraContent> contentList);
+    void onErrorOccurred(Exception  e);
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContentsRecognizer.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContentsRecognizer.java
new file mode 100644 (file)
index 0000000..031d3c4
--- /dev/null
@@ -0,0 +1,12 @@
+package net.osdn.gokigen.pkremote.camera.interfaces.playback;
+
+
+public interface ICameraContentsRecognizer
+{
+    void getRemoteCameraContentsList(ICameraContentsListCallback callback);
+
+    interface ICameraContentsListCallback
+    {
+        void contentsListCreated(int nofContents);
+    }
+}
index 644db0f..0d8b2e7 100644 (file)
@@ -1,5 +1,7 @@
 package net.osdn.gokigen.pkremote.camera.interfaces.playback;
 
+import java.util.List;
+
 /**
  *   画像再生・取得用インタフェース
  *
@@ -14,4 +16,6 @@ public interface IPlaybackControl
     void downloadContentScreennail(String  path, IDownloadThumbnailImageCallback callback);
     void downloadContentThumbnail(String path, IDownloadThumbnailImageCallback callback);
     void downloadContent(String  path, boolean isSmallSize, IDownloadContentCallback callback);
+
+    void getCameraContentList(ICameraContentListCallback callback);
 }
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/playback/CameraContentInfo.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/playback/CameraContentInfo.java
new file mode 100644 (file)
index 0000000..4efd103
--- /dev/null
@@ -0,0 +1,60 @@
+package net.osdn.gokigen.pkremote.camera.playback;
+
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
+
+import java.util.Date;
+
+public class CameraContentInfo implements ICameraContent
+{
+    private final String cameraId;
+    private final String cardId;
+    private final String contentPath;
+    private final String contentName;
+    private Date capturedDate;
+
+    public CameraContentInfo(String cameraId, String cardId, String contentPath, String contentName, Date date)
+    {
+        this.cameraId = cameraId;
+        this.cardId = cardId;
+        this.contentPath = contentPath;
+        this.contentName = contentName;
+        this.capturedDate = date;
+
+    }
+
+    @Override
+    public String getCameraId()
+    {
+        return (cameraId);
+    }
+
+    @Override
+    public String getCardId()
+    {
+        return (cardId);
+    }
+
+    @Override
+    public String getContentPath()
+    {
+        return (contentPath);
+    }
+
+    @Override
+    public String getContentName()
+    {
+        return (contentName);
+    }
+
+    @Override
+    public Date getCapturedDate()
+    {
+        return (capturedDate);
+    }
+
+    @Override
+    public void setCapturedDate(Date date)
+    {
+        this.capturedDate = date;
+    }
+}
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/playback/CameraContentsRecognizer.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/playback/CameraContentsRecognizer.java
new file mode 100644 (file)
index 0000000..3489f96
--- /dev/null
@@ -0,0 +1,175 @@
+package net.osdn.gokigen.pkremote.camera.playback;
+
+import android.content.DialogInterface;
+import android.graphics.Color;
+import android.util.Log;
+
+import net.osdn.gokigen.pkremote.IInformationReceiver;
+import net.osdn.gokigen.pkremote.R;
+import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentsRecognizer;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
+
+import java.util.Date;
+import java.util.List;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatActivity;
+
+/**
+ *   遠隔カメラのコンテンツを解析・保持するクラス
+ *
+ *
+ */
+public class CameraContentsRecognizer implements ICameraContentsRecognizer, ICameraContentListCallback
+{
+    private final String TAG = toString();
+    private final AppCompatActivity activity;
+    private final IInformationReceiver informationReceiver;
+    private final  IInterfaceProvider interfaceProvider;
+    private ICameraContentsListCallback contentsListCallback = null;
+    private List<ICameraContent> cameraContentsList = null;
+
+    /**
+     *
+     *
+     */
+    public CameraContentsRecognizer(@NonNull AppCompatActivity activity, @NonNull IInterfaceProvider interfaceProvider)
+    {
+        this.activity = activity;
+        this.interfaceProvider = interfaceProvider;
+        this.informationReceiver = interfaceProvider.getInformationReceiver();
+    }
+
+    /**
+     *
+     *
+     */
+    @Override
+    public void getRemoteCameraContentsList(ICameraContentsListCallback callback)
+    {
+        contentsListCallback = callback;
+        getRemoteCameraContentsListImpl(this);
+    }
+
+    /**
+     *
+     *
+     */
+    private void getRemoteCameraContentsListImpl(final ICameraContentListCallback callback)
+    {
+        Thread thread = new Thread(new Runnable() {
+            @Override
+            public void run()
+            {
+                try
+                {
+                    IPlaybackControl playbackControl = interfaceProvider.getPlaybackControl();
+                    playbackControl.getCameraContentList(callback);
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
+            }
+        });
+        try
+        {
+            if (informationReceiver != null)
+            {
+                informationReceiver.updateMessage(activity.getString(R.string.get_camera_contents_wait), false, false, 0);
+            }
+            thread.start();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void onCompleted(List<ICameraContent> contentList)
+    {
+        cameraContentsList = contentList;
+        if (contentsListCallback != null)
+        {
+            try
+            {
+                // 遠隔のカメラ内のコンテンツ一覧を引っ張ることができたよ、の通知
+                contentsListCallback.contentsListCreated(contentList.size());
+                if (informationReceiver != null)
+                {
+                    informationReceiver.updateMessage(activity.getString(R.string.get_camera_contents_finished), false, false, 0);
+                }
+
+                // とりあえず、できたコンテンツ一覧をログにダンプしてみる。
+                dumpCameraContentList();
+            }
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public void onErrorOccurred(Exception e)
+    {
+        cameraContentsList = null;
+        if (informationReceiver != null)
+        {
+            informationReceiver.updateMessage(activity.getString(R.string.get_camera_contents_error), false, true, Color.RED);
+        }
+
+        //  再試行する? の確認を出す
+        e.printStackTrace();
+        final AlertDialog.Builder builder = new AlertDialog.Builder(activity)
+                .setCancelable(true)
+                .setTitle(activity.getString(R.string.get_camera_contents_error))
+                .setMessage(activity.getString(R.string.get_camera_contents_error_retry))
+                .setPositiveButton(activity.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which)
+                    {
+                        getRemoteCameraContentsList(contentsListCallback);
+                    }
+                });
+        activity.runOnUiThread(new Runnable()
+        {
+            @Override
+            public void run()
+            {
+                builder.show();
+            }
+        });
+    }
+
+    private void dumpCameraContentList()
+    {
+        Log.v(TAG, "dumpCameraContentList()");
+        if (cameraContentsList == null)
+        {
+            return;
+        }
+        try {
+            int index = 1;
+            for (ICameraContent content : cameraContentsList)
+            {
+                String cameraId = content.getCameraId();
+                String cardId = content.getCardId();
+                String path = content.getContentPath();
+                String name = content.getContentName();
+                Date date = content.getCapturedDate();
+                Log.v(TAG, index + " [" + cameraId + "] " + cardId + " : " + path + " " + name + " " + date);
+                index++;
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+}
index 25682a6..556d4c4 100644 (file)
@@ -3,12 +3,15 @@ package net.osdn.gokigen.pkremote.camera.vendor.olympus.wrapper.playback;
 import android.graphics.BitmapFactory;
 import android.util.Log;
 
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraFileInfo;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IContentInfoCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentListCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
+import net.osdn.gokigen.pkremote.camera.playback.CameraContentInfo;
 import net.osdn.gokigen.pkremote.camera.playback.CameraFileInfo;
 import net.osdn.gokigen.pkremote.camera.playback.ProgressEvent;
 
@@ -230,4 +233,42 @@ public class OlyCameraPlaybackControl implements IPlaybackControl
             callback.onErrorOccurred(e);
         }
     }
+
+    @Override
+    public void getCameraContentList(final ICameraContentListCallback callback)
+    {
+        if (callback == null)
+        {
+            // 何もせず戻る
+            return;
+        }
+        try
+        {
+            camera.downloadContentList(new OLYCamera.DownloadContentListCallback()
+            {
+                @Override
+                public void onCompleted(List<OLYCameraFileInfo> list)
+                {
+                    List<ICameraContent> list2 = new ArrayList<>();
+                    for (OLYCameraFileInfo fileInfo : list)
+                    {
+                        CameraContentInfo contentInfo = new CameraContentInfo("AirA01", "sd1", fileInfo.getDirectoryPath(), fileInfo.getDirectoryPath(), fileInfo.getDatetime());
+                        list2.add(contentInfo);
+                    }
+                    callback.onCompleted(list2);
+                }
+
+                @Override
+                public void onErrorOccurred(Exception e)
+                {
+                    callback.onErrorOccurred(e);
+                }
+            });
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            callback.onErrorOccurred(e);
+        }
+    }
 }
index 62a013e..0502b8a 100644 (file)
@@ -75,7 +75,7 @@ public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, ID
         zoomControl = new RicohGr2CameraZoomLensControl();
         buttonControl = new RicohGr2CameraButtonControl();
         statusChecker = new RicohGr2StatusChecker(500, useGrCommand);
-        playbackControl = new RicohGr2PlaybackControl();
+        playbackControl = new RicohGr2PlaybackControl(statusChecker);
         hardwareStatus = new RicohGr2HardwareStatus();
         runMode = new RicohGr2RunMode();
     }
index 8e2c044..8c4a5f9 100644 (file)
@@ -2,12 +2,15 @@ package net.osdn.gokigen.pkremote.camera.vendor.ricoh.wrapper;
 import android.graphics.Bitmap;
 import android.util.Log;
 
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraFileInfo;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IContentInfoCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentListCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
+import net.osdn.gokigen.pkremote.camera.playback.CameraContentInfo;
 import net.osdn.gokigen.pkremote.camera.playback.CameraFileInfo;
 import net.osdn.gokigen.pkremote.camera.playback.ProgressEvent;
 import net.osdn.gokigen.pkremote.camera.utils.SimpleHttpClient;
@@ -16,6 +19,7 @@ import org.json.JSONArray;
 import org.json.JSONObject;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
@@ -29,6 +33,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
 {
     private final String TAG = toString();
     private final String getPhotoUrl = "http://192.168.0.1/v1/photos/";
+    private final RicohGr2StatusChecker statusChecker;
     private static final int DEFAULT_TIMEOUT = 5000;
 
     /*****
@@ -44,9 +49,9 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
             動画をダウンロードする      : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.MOV?size=full
      *****/
 
-    RicohGr2PlaybackControl()
+    RicohGr2PlaybackControl(RicohGr2StatusChecker statusChecker)
     {
-
+        this.statusChecker = statusChecker;
     }
 
     @Override
@@ -253,4 +258,62 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
             e.printStackTrace();
         }
     }
+
+    private Date getCameraContentDate(@NonNull ICameraContent cameraContent)
+    {
+        return (cameraContent.getCapturedDate());
+    }
+
+    @Override
+    public void getCameraContentList(ICameraContentListCallback callback)
+    {
+        List<ICameraContent> fileList = new ArrayList<>();
+        String imageListurl = "http://192.168.0.1/v1/photos?limit=3000";
+        String contentList;
+        try
+        {
+            contentList = SimpleHttpClient.httpGet(imageListurl, DEFAULT_TIMEOUT);
+            if (contentList == null)
+            {
+                // ぬるぽ発行
+                callback.onErrorOccurred(new NullPointerException());
+                return;
+            }
+        }
+        catch (Exception e)
+        {
+            // 例外をそのまま転送
+            callback.onErrorOccurred(e);
+            return;
+        }
+        try
+        {
+            String cameraId = statusChecker.getCameraId();
+            JSONArray dirsArray = new JSONObject(contentList).getJSONArray("dirs");
+            if (dirsArray != null)
+            {
+                int size = dirsArray.length();
+                for (int index = 0; index < size; index++)
+                {
+                    JSONObject object = dirsArray.getJSONObject(index);
+                    String dirName = object.getString("name");
+                    JSONArray filesArray = object.getJSONArray("files");
+                    int nofFiles = filesArray.length();
+                    for (int fileIndex = 0; fileIndex < nofFiles; fileIndex++)
+                    {
+                        String fileName = filesArray.getString(fileIndex);
+                        ICameraContent cameraContent = new CameraContentInfo(cameraId, "sd1", dirName, fileName, new Date());
+                        cameraContent.setCapturedDate(getCameraContentDate(cameraContent));
+                        fileList.add(cameraContent);
+                    }
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            callback.onErrorOccurred(e);
+            return;
+        }
+        callback.onCompleted(fileList);
+    }
 }
index effbb3c..aa6e8c1 100644 (file)
@@ -44,6 +44,19 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
      *
      *
      */
+    String getCameraId()
+    {
+        if (statusHolder != null)
+        {
+            return (statusHolder.getCameraId());
+        }
+        return ("");
+    }
+
+    /**
+     *
+     *
+     */
     @Override
     public void startStatusWatch(@NonNull ICameraStatusUpdateNotify notifier)
     {
@@ -242,6 +255,7 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
                 buttonCode = "bdial P";
                 break;
             case "auto":
+            default:
                 buttonCode = "bdial AUTO";
                 break;
         }
index 5d24f99..c5a7055 100644 (file)
@@ -31,6 +31,8 @@ class RicohGr2StatusHolder
     private String meteringModeStatus = "";
     private String wbModeStatus = "";
     private String batteryStatus = "";
+    private String model = "";
+    private String serialNo = "";
 
     /**
      *
@@ -45,6 +47,15 @@ class RicohGr2StatusHolder
      *
      *
      */
+    String getCameraId()
+    {
+        return (model + " " + serialNo);
+    }
+
+    /**
+     *
+     *
+     */
     List<String> getAvailableItemList(@NonNull String key)
     {
         List<String> itemList = new ArrayList<>();
@@ -137,6 +148,9 @@ class RicohGr2StatusHolder
             boolean focus = getBooleanStatus(latestResultObject,"focused");
             boolean focusLock = getBooleanStatus(latestResultObject,"focusLocked");
 
+            String modelRx = getStatusString(latestResultObject,"model");
+            String serialNoRx = getStatusString(latestResultObject,"serialNo");
+
             if (result.contains("OK"))
             {
                 if (!avStatus.equals(av))
@@ -180,6 +194,15 @@ class RicohGr2StatusHolder
                     focusLocked = focusLock;
                     notifier.updateFocusedStatus(focused, focusLocked);
                 }
+
+                if (!model.equals(modelRx))
+                {
+                    model = modelRx;
+                }
+                if (!serialNo.equals(serialNoRx))
+                {
+                    serialNo = serialNoRx;
+                }
             }
             System.gc();
         }
index 530236b..ef377a8 100644 (file)
@@ -8,6 +8,7 @@ import net.osdn.gokigen.pkremote.R;
 import net.osdn.gokigen.pkremote.calendar.CalendarFragment;
 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection;
 import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IStatusViewDrawer;
+import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentsRecognizer;
 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver;
 import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
 import net.osdn.gokigen.pkremote.logcat.LogCatFragment;
@@ -24,12 +25,13 @@ import androidx.preference.PreferenceFragmentCompat;
  *
  *
  */
-public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene
+public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene, ICameraContentsRecognizer.ICameraContentsListCallback
 {
     private final String TAG = toString();
     private final AppCompatActivity activity;
     private IInterfaceProvider interfaceProvider;
     private IStatusViewDrawer statusViewDrawer;
+    private ICameraStatusReceiver anotherStatusReceiver = null;
 
     private PreferenceFragmentCompat preferenceFragment = null;
     private LogCatFragment logCatFragment = null;
@@ -95,6 +97,10 @@ public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene
                     statusViewDrawer.updateConnectionStatus(connection.getConnectionStatus());
                 }
             }
+            if (anotherStatusReceiver != null)
+            {
+                anotherStatusReceiver.onStatusNotify(message);
+            }
         }
         catch (Exception e)
         {
@@ -122,6 +128,16 @@ public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene
                 // ライブビューの開始... 今回は手動化。
                 //statusViewDrawer.startLiveView();
             }
+            if (anotherStatusReceiver != null)
+            {
+                anotherStatusReceiver.onCameraConnected();
+            }
+            ICameraContentsRecognizer recognizer = interfaceProvider.getCameraContentsRecognizer();
+            if (recognizer != null)
+            {
+                // カメラ内のコンテンツ一覧を作成するように指示する
+                recognizer.getRemoteCameraContentsList(this);
+            }
         }
         catch (Exception e)
         {
@@ -136,10 +152,21 @@ public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene
         Log.v(TAG, "onCameraDisconnected()");
         String message = activity.getString(R.string.camera_disconnected);
         updateConnectionStatus(message, ICameraConnection.CameraConnectionStatus.DISCONNECTED);
-        if (statusViewDrawer != null)
+        try
+        {
+            if (statusViewDrawer != null)
+            {
+                statusViewDrawer.updateStatusView(activity.getString(R.string.camera_disconnected));
+                statusViewDrawer.updateConnectionStatus(ICameraConnection.CameraConnectionStatus.DISCONNECTED);
+            }
+            if (anotherStatusReceiver != null)
+            {
+                anotherStatusReceiver.onCameraDisconnected();
+            }
+        }
+        catch (Exception e)
         {
-            statusViewDrawer.updateStatusView(activity.getString(R.string.camera_disconnected));
-            statusViewDrawer.updateConnectionStatus(ICameraConnection.CameraConnectionStatus.DISCONNECTED);
+            e.printStackTrace();
         }
     }
 
@@ -168,6 +195,10 @@ public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene
                     statusViewDrawer.updateConnectionStatus(connectionStatus);
                 }
             }
+            if (anotherStatusReceiver != null)
+            {
+                anotherStatusReceiver.onCameraOccursException(message, e);
+            }
         }
         catch (Exception ee)
         {
@@ -445,9 +476,21 @@ public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene
         }
     }
 
+    @Override
+    public void setAnotherStatusReceiver(ICameraStatusReceiver statusReceiver)
+    {
+        this.anotherStatusReceiver = statusReceiver;
+    }
+
     private ICameraConnection getCameraConnection(ICameraConnection.CameraConnectionMethod method)
     {
         Log.v(TAG, "method : " + method);
         return (interfaceProvider.getCameraConnection());
     }
+
+    @Override
+    public void contentsListCreated(int nofContents)
+    {
+        Log.v(TAG, "contentsListCreated() : " + nofContents);
+    }
 }
index 1a86345..8301ee2 100644 (file)
@@ -1,5 +1,7 @@
 package net.osdn.gokigen.pkremote.scene;
 
+import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver;
+
 /**
  *
  */
@@ -13,4 +15,5 @@ public interface IChangeScene
     void changeSceneToApiList();
     //void changeScenceToImageList();
     void exitApplication();
+    void setAnotherStatusReceiver(ICameraStatusReceiver statusReceiver);
 }
index c6e3ad3..8ad033b 100644 (file)
     <string name="time_picker_end_separator"> </string>
     <string name="information_month_picker">Set Year and Month</string>
 
+    <string name="get_camera_contents_wait">Check contents&#8230; wait</string>
+    <string name="get_camera_contents_error">Check contents&#8230; Error!</string>
+    <string name="get_camera_contents_finished">Check contents&#8230; finished</string>
+    <string name="get_camera_contents_error_retry">Try Again?</string>
+
 </resources>