OSDN Git Service

FUJIFILM用画像詳細画面で、タイミングによってはスモールイメージを使用できるようにした。
authorMRSa <mrsa@myad.jp>
Sun, 10 May 2020 13:07:08 +0000 (22:07 +0900)
committerMRSa <mrsa@myad.jp>
Sun, 10 May 2020 13:07:08 +0000 (22:07 +0900)
17 files changed:
.gitignore
.project [new file with mode: 0644]
.settings/org.eclipse.buildship.core.prefs [new file with mode: 0644]
app/.classpath [new file with mode: 0644]
app/.project [new file with mode: 0644]
app/.settings/org.eclipse.buildship.core.prefs [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/command/messages/GetScreenNail.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/playback/FujiXPlaybackControl.java
app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/playback/FujiXReplyReceiver.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/gr2control/preference/Gr2ControlPreferenceFragment.java
app/src/main/java/net/osdn/gokigen/gr2control/preference/IPreferencePropertyAccessor.java
app/src/main/java/net/osdn/gokigen/gr2control/preference/fuji_x/FujiXPreferenceFragment.java
app/src/main/java/net/osdn/gokigen/gr2control/preference/olympus/PreferenceFragment.java
app/src/main/java/net/osdn/gokigen/gr2control/preference/ricohgr2/RicohGr2PreferenceFragment.java
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/preferences_fuji_x.xml

index 7498d53..6670752 100644 (file)
@@ -1,5 +1,6 @@
 *.iml
 .gradle
+.project
 .idea
 /local.properties
 /.idea/libraries
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..f4c557b
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>gr2control</name>
+       <comment>Project gr2control created by Buildship.</comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+       </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs
new file mode 100644 (file)
index 0000000..aa0311a
--- /dev/null
@@ -0,0 +1,13 @@
+arguments=
+auto.sync=false
+build.scans.enabled=false
+connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
+connection.project.dir=
+eclipse.preferences.version=1
+gradle.user.home=
+java.home=C\:/Program Files/Java/jdk1.8.0_112
+jvm.arguments=
+offline.mode=false
+override.workspace.settings=true
+show.console.view=true
+show.executions.view=true
diff --git a/app/.classpath b/app/.classpath
new file mode 100644 (file)
index 0000000..eb19361
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
+       <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
+       <classpathentry kind="output" path="bin/default"/>
+</classpath>
diff --git a/app/.project b/app/.project
new file mode 100644 (file)
index 0000000..ac485d7
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>app</name>
+       <comment>Project app created by Buildship.</comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
+       </natures>
+</projectDescription>
diff --git a/app/.settings/org.eclipse.buildship.core.prefs b/app/.settings/org.eclipse.buildship.core.prefs
new file mode 100644 (file)
index 0000000..b1886ad
--- /dev/null
@@ -0,0 +1,2 @@
+connection.project.dir=..
+eclipse.preferences.version=1
diff --git a/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/command/messages/GetScreenNail.java b/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/command/messages/GetScreenNail.java
new file mode 100644 (file)
index 0000000..3e2a9ba
--- /dev/null
@@ -0,0 +1,73 @@
+package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages;
+
+
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCallback;
+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXMessages;
+
+public class GetScreenNail  extends FujiXCommandBase
+{
+    private final IFujiXCommandCallback callback;
+    private final byte lower;
+    private final byte upper;
+    private final byte data0;
+    private final byte data1;
+    private final byte data2;
+    private final byte data3;
+
+    public GetScreenNail(int indexNumber, int imageSize, @NonNull IFujiXCommandCallback callback)
+    {
+        this.lower = ((byte) (0x000000ff & indexNumber));
+        this.upper = ((byte)((0x0000ff00 & indexNumber) >> 8));
+
+        data0 = ((byte) (0x000000ff & imageSize));
+        data1 = ((byte)((0x0000ff00 & imageSize) >> 8));
+        data2 = ((byte)((0x00ff0000 & imageSize) >> 16));
+        data3 = ((byte)((0xff000000 & imageSize) >> 24));
+        this.callback = callback;
+    }
+
+    @Override
+    public IFujiXCommandCallback responseCallback()
+    {
+        return (callback);
+    }
+
+    @Override
+    public int getId()
+    {
+        return (IFujiXMessages.SEQ_FULL_IMAGE);
+    }
+
+    @Override
+    public byte[] commandBody()
+    {
+        return (new byte[] {
+
+                // message_header.index : uint16 (0: terminate, 2: two_part_message, 1: other)
+                (byte)0x01, (byte)0x00,
+
+                // message_header.type : full_image (0x101b)
+                (byte)0x1b, (byte)0x10,
+
+                // sequence number
+                (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+
+                // data ... (index number)
+                lower, upper, (byte)0x00, (byte)0x00,
+
+                // 現物合わせ1  : 0~ 
+                (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+
+                // 現物合わせ2  : ~0x01000000 bytes
+                data0, data1, data2, data3,
+        });
+    }
+    @Override
+    public boolean dumpLog()
+    {
+        return (false);
+    }
+}
index 211d1f8..6d7d302 100644 (file)
@@ -1,11 +1,13 @@
 package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.playback;
 
 import android.app.Activity;
+import android.content.SharedPreferences;
 import android.util.Log;
 import android.util.SparseArray;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
+import androidx.preference.PreferenceManager;
 
 import net.osdn.gokigen.gr2control.camera.ICameraFileInfo;
 import net.osdn.gokigen.gr2control.camera.ICameraStatus;
@@ -14,13 +16,16 @@ import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCa
 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandPublisher;
 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.GetFullImage;
 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.GetImageInfo;
+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.GetScreenNail;
 import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.GetThumbNail;
+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.messages.SetPropertyValue;
 import net.osdn.gokigen.gr2control.camera.playback.ICameraContent;
 import net.osdn.gokigen.gr2control.camera.playback.IContentInfoCallback;
 import net.osdn.gokigen.gr2control.camera.playback.IDownloadContentCallback;
 import net.osdn.gokigen.gr2control.camera.playback.ICameraContentListCallback;
 import net.osdn.gokigen.gr2control.camera.playback.IDownloadThumbnailImageCallback;
 import net.osdn.gokigen.gr2control.camera.playback.IPlaybackControl;
+import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -87,8 +92,65 @@ public class FujiXPlaybackControl implements IPlaybackControl, IFujiXCommandCall
     @Override
     public void downloadContentScreennail(@Nullable String path, @NonNull String name, @NonNull IDownloadThumbnailImageCallback callback)
     {
-        // Thumbnail と同じ画像を表示する
-        downloadContentThumbnail(path, name, callback);
+        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
+        boolean useSmallImage = preferences.getBoolean(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE, false);
+        if (useSmallImage)
+        {
+            // small image を表示する
+            downloadContentScreennailImpl(path, name, callback);
+        }
+        else
+        {
+            // Thumbnail と同じ画像を表示する
+            downloadContentThumbnail(path, name, callback);
+        }
+    }
+
+    private void downloadContentScreennailImpl(@Nullable String path, @NonNull String name, @NonNull IDownloadThumbnailImageCallback callback)
+    {
+        try
+        {
+            Log.v(TAG, " ----- downloadContentScreennailImpl() ");
+            int start = 0;
+            if (name.indexOf("/") == 0)
+            {
+                start = 1;
+            }
+            Log.v(TAG, "  downloadContentThumbnail() : " + path + " " + name);
+            int index = getIndexNumber(start, name);
+            if ((index > 0)&&(index <= imageContentInfo.size()))
+            {
+                IFujiXCommandPublisher publisher = provider.getCommandPublisher();
+                FujiXImageContentInfo contentInfo = imageContentInfo.get(index);
+                if (contentInfo.isReceived())
+                {
+                    if (!contentInfo.isMovie())
+                    {
+                        // スモール画像を取得する (たぶんこのシーケンスでいけるはず...)
+                        publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyReceiver(), 0xd226, 2, 0x0001));
+                        publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyReceiver(), 0xd227, 2, 0x0001));
+                        publisher.enqueueCommand(new GetScreenNail(index, 0x00800000, new FujiXThumbnailImageReceiver(activity, callback)));
+                        publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyReceiver(), 0xd226, 2, 0x0000));
+                        publisher.enqueueCommand(new SetPropertyValue(new FujiXReplyReceiver(), 0xd227, 2, 0x0001));
+                    }
+                    else
+                    {
+                        // movieの時は、Small画像を使えないのでThumbnailで代用する。
+                        publisher.enqueueCommand(new GetThumbNail(index, new FujiXThumbnailImageReceiver(activity, callback)));
+                    }
+                }
+                else
+                {
+                    // まだ、ファイル情報を受信していない場合は、サムネイルの情報を流用する
+                    publisher.enqueueCommand(new GetImageInfo(index, index, contentInfo));
+                    publisher.enqueueCommand(new GetThumbNail(index, new FujiXThumbnailImageReceiver(activity, callback)));
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
     }
 
     @Override
diff --git a/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/playback/FujiXReplyReceiver.java b/app/src/main/java/net/osdn/gokigen/gr2control/camera/fuji_x/wrapper/playback/FujiXReplyReceiver.java
new file mode 100644 (file)
index 0000000..e27f6da
--- /dev/null
@@ -0,0 +1,36 @@
+package net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.playback;
+
+import android.util.Log;
+
+import net.osdn.gokigen.gr2control.camera.fuji_x.wrapper.command.IFujiXCommandCallback;
+import net.osdn.gokigen.gr2control.camera.utils.SimpleLogDumper;
+
+public class FujiXReplyReceiver implements IFujiXCommandCallback
+{
+    private final String TAG = toString();
+
+    @Override
+    public void receivedMessage(int id, byte[] rx_body)
+    {
+        try
+        {
+            SimpleLogDumper.dump_bytes(" RECV : ", rx_body);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    @Override
+    public void onReceiveProgress(int currentBytes, int totalBytes, byte[] rx_body)
+    {
+        Log.v(TAG, " " + currentBytes + "/" + totalBytes);
+    }
+
+    @Override
+    public boolean isReceiveMulti()
+    {
+        return (false);
+    }
+}
index 50c95b2..f2c7ee0 100644 (file)
@@ -167,6 +167,9 @@ public class Gr2ControlPreferenceFragment  extends PreferenceFragmentCompat impl
             if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT)) {
                 editor.putString(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT, IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT_DEFAULT_VALUE);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE)) {
+                editor.putBoolean(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE, false);
+            }
             editor.apply();
         }
         catch (Exception e)
index 9266a41..7676b87 100644 (file)
@@ -63,6 +63,7 @@ public interface IPreferencePropertyAccessor
     String FUJI_X_COMMAND_POLLING_WAIT = "fujix_command_polling_wait";
     String FUJI_X_COMMAND_POLLING_WAIT_DEFAULT_VALUE = "500";
 
+    String FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE = "fujix_get_screennail_as_small_picture";
 
 /*
     //String GR2_DISPLAY_MODE = "gr2_display_mode";
index a636f55..76869b4 100644 (file)
@@ -165,6 +165,9 @@ public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implement
             if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT)) {
                 editor.putString(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT, IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT_DEFAULT_VALUE);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE)) {
+                editor.putBoolean(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE, false);
+            }
             editor.apply();
         }
         catch (Exception e)
@@ -206,6 +209,11 @@ public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implement
                     Log.v(TAG, " DISPLAY CAMERA VIEW : " + key + " , " + value);
                     break;
 
+                case IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE:
+                    value = preferences.getBoolean(key, false);
+                    Log.v(TAG, " SMALL IMAGE AS SCREENNAIL : " + key + " , " + value);
+                    break;
+
                 case IPreferencePropertyAccessor.SHARE_AFTER_SAVE:
                     value = preferences.getBoolean(key, false);
                     Log.v(TAG, " SHARE AFTER SAVE : " + key + " , " + value);
@@ -378,6 +386,7 @@ public class FujiXPreferenceFragment  extends PreferenceFragmentCompat implement
                         setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, defaultValue);
                         setBooleanPreference(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, IPreferencePropertyAccessor.USE_PLAYBACK_MENU, defaultValue);
                         setBooleanPreference(IPreferencePropertyAccessor.FUJI_X_DISPLAY_CAMERA_VIEW, IPreferencePropertyAccessor.FUJI_X_DISPLAY_CAMERA_VIEW, false);
+                        setBooleanPreference(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE, IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE, false);
                         setBooleanPreference(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, IPreferencePropertyAccessor.SHARE_AFTER_SAVE, defaultValue);
                     }
                     catch (Exception e)
index e1603f3..eee02ca 100644 (file)
@@ -186,6 +186,9 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
         if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT)) {
             editor.putString(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT, IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT_DEFAULT_VALUE);
         }
+        if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE)) {
+            editor.putBoolean(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE, false);
+        }
         editor.apply();
     }
 
index 77948da..6f9ec34 100644 (file)
@@ -166,6 +166,9 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
             if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT)) {
                 editor.putString(IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT, IPreferencePropertyAccessor.FUJI_X_COMMAND_POLLING_WAIT_DEFAULT_VALUE);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE)) {
+                editor.putBoolean(IPreferencePropertyAccessor.FUJI_X_GET_SCREENNAIL_AS_SMALL_PICTURE, false);
+            }
             editor.apply();
         }
         catch (Exception e)
index 1710652..6fb7115 100644 (file)
     <string name="pref_fuji_x_exit_only">アプリ終了 (FUJI)</string>
     <string name="pref_opc_exit_power_off">アプリ終了 (OPC)</string>
     <string name="pref_ricoh_exit_power_off">アプリ終了 (RICOH)</string>
+
+    <string name="pref_fujix_get_screennail_as_small_picture">表示画像はスモール画像を使用</string>
+    <string name="pref_summary_fujix_get_screennail_as_small_picture">すこし時間がかかりますが、画像表示にスモール画像を使用します。</string>
 </resources>
index 9504cf2..d001d7b 100644 (file)
     <string name="pref_fuji_x_exit_only">Exit Application (FUJI)</string>
     <string name="pref_opc_exit_power_off">Exit Application (OPC)</string>
     <string name="pref_ricoh_exit_power_off">Exit Application (RICOH)</string>
+
+    <string name="pref_fujix_get_screennail_as_small_picture">Use small image as detail screen</string>
+    <string name="pref_summary_fujix_get_screennail_as_small_picture">Use small size image for detail screen.</string>
 </resources>
index 66c78a8..f96a952 100644 (file)
             android:defaultValue="80"
             android:summary="@string/pref_summary_fujix_liveview_wait" />
 
+        <CheckBoxPreference
+            android:key="fujix_get_screennail_as_small_picture"
+            android:title="@string/pref_fujix_get_screennail_as_small_picture"
+            android:summary="@string/pref_summary_fujix_get_screennail_as_small_picture" />
     </PreferenceCategory>
 <!--
     <PreferenceCategory