OSDN Git Service

・FujiとNikonで保存するファイル名を本当のファイル名を使うようにする。
authorMRSa <mrsa@myad.jp>
Tue, 26 Nov 2019 15:04:09 +0000 (00:04 +0900)
committerMRSa <mrsa@myad.jp>
Tue, 26 Nov 2019 15:04:09 +0000 (00:04 +0900)
・ファイル名の並びを 年月日_本当のファイル名 から 本当のファイル名_年月日.拡張子に変えた。(これでダウンロード後撮影順に並べられる。)

19 files changed:
app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/playback/ICameraContent.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/playback/CameraContentInfo.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/fujix/wrapper/FujiXImageContentInfo.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonFullImageReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonImageContentInfo.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonImageObjectReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenCameraContent.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/panasonic/wrapper/playback/PanasonicImageContentInfo.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/IPtpIpMessages.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonImageContentInfo.java [moved from app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/PtpIpImageContentInfo.java with 77% similarity]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/CanonImageObjectReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/playback/PtpIpPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/sony/wrapper/playback/SonyImageContentInfo.java
app/src/main/java/net/osdn/gokigen/pkremote/playback/ImageGridViewFragment.java
app/src/main/java/net/osdn/gokigen/pkremote/playback/MyContentDownloader.java
app/src/main/java/net/osdn/gokigen/pkremote/playback/detail/CameraContentEx.java
app/src/main/java/net/osdn/gokigen/pkremote/playback/grid/ImageGridViewAdapter.java
app/src/main/java/net/osdn/gokigen/pkremote/playback/grid/ImageThumbnailLoader.java

index 0777078..1f0712d 100644 (file)
@@ -8,7 +8,11 @@ public interface ICameraContent
     String getCardId();
     String getContentPath();
     String getContentName();
+    String getOriginalName();
+    boolean isRaw();
+    boolean isMovie();
     boolean isDateValid();
+    boolean isContentNameValid();
     Date getCapturedDate();
     void setCapturedDate(Date date);
 }
index 907148e..6c6d347 100644 (file)
@@ -56,12 +56,54 @@ public class CameraContentInfo implements ICameraContent
     }
 
     @Override
+    public String getOriginalName()
+    {
+        return (contentName);
+    }
+
+    @Override
+    public boolean isRaw()
+    {
+        try
+        {
+            String target = contentName.toLowerCase();
+            return ((target.endsWith("orf")) || (target.endsWith("dng")) || (target.endsWith("pef")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public boolean isMovie()
+    {
+        try
+        {
+            String target = contentName.toLowerCase();
+            return ((target.endsWith("mov")) || (target.endsWith("mp4")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
     public boolean isDateValid()
     {
         return (isDateValid);
     }
 
     @Override
+    public boolean isContentNameValid()
+    {
+        return (true);
+    }
+
+    @Override
     public Date getCapturedDate()
     {
         return (capturedDate);
index 3d998f9..0c2ef15 100644 (file)
@@ -69,12 +69,62 @@ public class FujiXImageContentInfo implements ICameraContent, IFujiXCommandCallb
     }
 
     @Override
+    public String getOriginalName()
+    {
+        if (realFileName != null)
+        {
+            return (realFileName);
+        }
+        return (getContentName());
+    }
+
+    @Override
+    public boolean isRaw()
+    {
+        try
+        {
+            if ((realFileName != null)&&(realFileName.contains(".RAF")))
+            {
+                return (true);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public boolean isMovie()
+    {
+        try
+        {
+            if ((realFileName != null)&&(realFileName.contains(".MOV")))
+            {
+                return (true);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
     public boolean isDateValid()
     {
         return (isDateValid);
     }
 
     @Override
+    public boolean isContentNameValid()
+    {
+        return (false);
+    }
+
+    @Override
     public Date getCapturedDate()
     {
         return (date);
index a878d4a..b2a90ec 100644 (file)
@@ -51,13 +51,7 @@ public class NikonFullImageReceiver implements IPtpIpCommandCallback
         this.target_image_size = imageSize;
         this.isReceiveMulti = true;
         this.receivedFirstData = false;
-/*
-        NikonImageContentInfo content = imageObjectReceiver.getImageContent(objectId);
-        if (content != null)
-        {
-            imageSize = content.getOriginalSize();
-        }
-*/
+
         Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
         publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, true, 0, 0x101b, 12, objectId, 0, imageSize));  // GetPartialObject (0x101b)
     }
@@ -102,7 +96,7 @@ public class NikonFullImageReceiver implements IPtpIpCommandCallback
         // 受信したデータから、通信のヘッダ部分を削除する
         byte[] body = cutHeader(rx_body);
         int length = (body == null) ? 0 : body.length;
-        Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes + " (" + length + " bytes.)");
+        Log.v(TAG, " onReceiveProgress() " + currentBytes + "/" + totalBytes + " (" + length + " bytes.) ");
         callback.onProgress(body, length, new IProgressEvent() {
             @Override
             public float getProgress() {
index 410c4ee..de27993 100644 (file)
@@ -11,8 +11,8 @@ class NikonImageContentInfo implements ICameraContent
     private final String TAG = toString();
     private Date date;
     private String contentName = "";
+    private String originalFileName = null;
     private boolean isDateValid = false;
-    private boolean isContentNameValid = false;
     private int contentSize = 0;
 
 
@@ -72,20 +72,82 @@ class NikonImageContentInfo implements ICameraContent
     @Override
     public String getContentName()
     {
-        if (isContentNameValid)
+/*
+        try
         {
-            return (contentName);
+            if ((originalFileName != null)&&(originalFileName.contains(".MOV")))
+            {
+                return (String.format("0x%08x.MOV", objectId));
+            }
         }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+*/
         return (String.format("0x%08x.JPG", objectId));
     }
 
     @Override
+    public String getOriginalName()
+    {
+        if (originalFileName != null)
+        {
+            return (originalFileName);
+        }
+        return (getContentName());
+    }
+
+    @Override
+    public boolean isRaw()
+    {
+        try
+        {
+            if ((originalFileName != null)&&(originalFileName.contains(".NEF")))
+            {
+                return (true);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public boolean isMovie()
+    {
+        try
+        {
+            if (originalFileName != null)
+            {
+                if ((originalFileName.contains(".MOV"))||(originalFileName.contains(".MP4")))
+                {
+                    return (true);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
     public boolean isDateValid()
     {
         return (isDateValid);
     }
 
     @Override
+    public boolean isContentNameValid()
+    {
+        return (false);
+    }
+
+    @Override
     public Date getCapturedDate()
     {
         return (date);
@@ -99,14 +161,13 @@ class NikonImageContentInfo implements ICameraContent
         isDateValid = true;
     }
 
-    public void setContentName(String contentName)
+    void setContentName(String contentName)
     {
-        Log.v(TAG, "setContentName() : " + contentName);
-        this.contentName = contentName;
-        isContentNameValid = true;
+        Log.v(TAG, " ----- setContentName() : " + contentName);
+        this.originalFileName = contentName;
     }
 
-    public void setOriginalSize(int size)
+    void setOriginalSize(int size)
     {
         this.contentSize = size;
     }
index 9496289..680c0a9 100644 (file)
@@ -85,9 +85,9 @@ public class NikonImageObjectReceiver implements IPtpIpCommandCallback, NikonSto
     }
 
 /*
-    private List<PtpIpImageContentInfo> parseContentSubdirectories(byte[] rx_body, int offset)
+    private List<CanonImageContentInfo> parseContentSubdirectories(byte[] rx_body, int offset)
     {
-        List<PtpIpImageContentInfo> result = new ArrayList<>();
+        List<CanonImageContentInfo> result = new ArrayList<>();
         try
         {
             int nofObjects = (rx_body[offset] & 0xff);
@@ -109,7 +109,7 @@ public class NikonImageObjectReceiver implements IPtpIpCommandCallback, NikonSto
                 id = id + ((rx_body[dataIndex + 2] & 0xff) << 16);
                 id = id + ((rx_body[dataIndex + 3] & 0xff) << 24);
 
-                PtpIpImageContentInfo content = new PtpIpImageContentInfo(id, "", rx_body, dataIndex, objectSize);
+                CanonImageContentInfo content = new CanonImageContentInfo(id, "", rx_body, dataIndex, objectSize);
                 result.add(content);
                 dataIndex = dataIndex + objectSize;
                 if (result.size() >= nofObjects)
index 3be5b46..0a03b11 100644 (file)
@@ -5,10 +5,12 @@ import android.content.SharedPreferences;
 import android.graphics.Color;
 import android.util.Log;
 
+import androidx.annotation.NonNull;
 import androidx.preference.PreferenceManager;
 
 import net.osdn.gokigen.pkremote.IInformationReceiver;
 import net.osdn.gokigen.pkremote.R;
+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;
@@ -23,6 +25,11 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.Pt
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.playback.PtpIpThumbnailImageReceiver;
 import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+
 /**
  *
  *
@@ -33,8 +40,8 @@ public class NikonPlaybackControl implements IPlaybackControl
     private final Activity activity;
     private final NikonInterfaceProvider provider;
     private final NikonFullImageReceiver fullImageReceiver;
-    private final NikonSmallImageReceiver smallImageReciever;
-    private String raw_suffix = "NEF";
+    //private final NikonSmallImageReceiver smallImageReciever;
+   // private String raw_suffix = "NEF";
     private boolean use_screennail_image = false;
     private NikonImageObjectReceiver nikonImageObjectReceiver;
 
@@ -44,12 +51,12 @@ public class NikonPlaybackControl implements IPlaybackControl
         this.provider = provider;
         nikonImageObjectReceiver = new NikonImageObjectReceiver(provider);
         this.fullImageReceiver = new NikonFullImageReceiver(activity, provider.getCommandPublisher());
-        this.smallImageReciever = new NikonSmallImageReceiver(activity, provider.getCommandPublisher());
+        //this.smallImageReciever = new NikonSmallImageReceiver(activity, provider.getCommandPublisher());
 
         try
         {
             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
-            raw_suffix = preferences.getString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
+            //raw_suffix = preferences.getString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
             use_screennail_image = preferences.getBoolean(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, false);
         }
         catch (Exception e)
@@ -61,7 +68,8 @@ public class NikonPlaybackControl implements IPlaybackControl
     @Override
     public String getRawFileSuffix()
     {
-        return (raw_suffix);
+        //return (raw_suffix);
+        return ("NEF");
     }
 
     @Override
@@ -186,11 +194,48 @@ public class NikonPlaybackControl implements IPlaybackControl
                     (((int) rx_body[readPosition + 3] & 0x000000ff) << 24);
             content.setOriginalSize(imageSize);
             Log.v(TAG, " CONTENT SIZE : " + imageSize);
+
+            readPosition = 5 * 16 + 4;
+            int length = ((int) rx_body[readPosition] & 0x000000ff) -1;
+            byte[] fileNameArray = new byte[length];
+            for (int index = 0; index < length; index++)
+            {
+                readPosition++;
+                fileNameArray[index] = rx_body[readPosition];
+                readPosition++;
+            }
+            content.setContentName(new String(fileNameArray));
+
+            readPosition = 7 * 16 - 1;
+            int dateTimeLength = ((int) rx_body[readPosition] & 0x000000ff) -1;
+            byte[] dateTimeArray = new byte[dateTimeLength];
+            for (int index = 0; index < dateTimeLength; index++)
+            {
+                readPosition++;
+                dateTimeArray[index] = rx_body[readPosition];
+                readPosition++;
+            }
+            content.setCapturedDate(getCameraContentDate(new String(dateTimeArray)));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private Date getCameraContentDate(String dateTime)
+    {
+        try
+        {
+            SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.US); // "yyyyMMdd'T'HHmmss"
+            dateFormatter.setCalendar(new GregorianCalendar());
+            return (dateFormatter.parse(dateTime));
         }
         catch (Exception e)
         {
             e.printStackTrace();
         }
+        return (new Date());
     }
 
 
@@ -211,7 +256,8 @@ public class NikonPlaybackControl implements IPlaybackControl
                 if (isSmallSize)
                 {
                     // スモールサイズの画像取得コマンド(シーケンス)を発行する
-                    smallImageReciever.issueCommand(content.getObjectId(), callback);
+                    //smallImageReciever.issueCommand(content.getObjectId(), callback);
+                    fullImageReceiver.issueCommand(content.getObjectId(), content.getOriginalSize(), callback);
                 }
                 else
                 {
index 814f94c..1d22f6b 100644 (file)
@@ -56,12 +56,54 @@ public class OlympusPenCameraContent implements ICameraContent
     }
 
     @Override
+    public String getOriginalName()
+    {
+        return (name);
+    }
+
+    @Override
+    public boolean isRaw()
+    {
+        try
+        {
+            String target = name.toLowerCase();
+            return ((target.endsWith("orf")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public boolean isMovie()
+    {
+        try
+        {
+            String target = name.toLowerCase();
+            return ((target.endsWith("mov")) || (target.endsWith("mp4")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
     public boolean isDateValid()
     {
         return (true);
     }
 
     @Override
+    public boolean isContentNameValid()
+    {
+        return (true);
+    }
+
+    @Override
     public Date getCapturedDate()
     {
         try
index 0ad5640..e95402d 100644 (file)
@@ -44,11 +44,53 @@ public class PanasonicImageContentInfo implements ICameraContent
     }
 
     @Override
+    public String getOriginalName()
+    {
+        return (getContentName());
+    }
+
+    @Override
+    public boolean isRaw()
+    {
+        try
+        {
+            String target = getContentName().toLowerCase();
+            return ((target.endsWith("rw2")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public boolean isMovie()
+    {
+        try
+        {
+            String target = getContentName().toLowerCase();
+            return ((target.endsWith("mov")) || (target.endsWith("mp4")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
     public boolean isDateValid() {
         return (isDateValid);
     }
 
     @Override
+    public boolean isContentNameValid()
+    {
+        return (true);
+    }
+
+    @Override
     public Date getCapturedDate()
     {
         return (date);
index 1e0e95b..6532333 100644 (file)
@@ -22,8 +22,7 @@ public interface IPtpIpMessages
     int GET_STORAGE_HANDLE1 = 110;
     int GET_STORAGE_HANDLE2 = 111;
     int GET_STORAGE_HANDLE3 = 112;
-    int GET_PARTIAL_OBJECT = 113;
-
+    int GET_PARTIAL_OBJECT= 113;
 
 /*
     int SEQ_REGISTRATION = 1;
@@ -8,7 +8,7 @@ import java.util.Arrays;
 import java.util.Date;
 import java.util.TimeZone;
 
-public class PtpIpImageContentInfo implements ICameraContent
+public class CanonImageContentInfo implements ICameraContent
 {
     private final String TAG = toString();
     private final int indexNumber;
@@ -17,7 +17,7 @@ public class PtpIpImageContentInfo implements ICameraContent
     private Date date;
     private final byte[] rx_body;
 
-    public PtpIpImageContentInfo(int indexNumber, String contentPath, byte[] binaryData, int offset, int length)
+    public CanonImageContentInfo(int indexNumber, String contentPath, byte[] binaryData, int offset, int length)
     {
         this.indexNumber = indexNumber;
         this.contentPath = contentPath;
@@ -81,12 +81,54 @@ public class PtpIpImageContentInfo implements ICameraContent
     }
 
     @Override
+    public String getOriginalName()
+    {
+        return (getContentName());
+    }
+
+    @Override
+    public boolean isRaw()
+    {
+        try
+        {
+            String target = getContentName().toLowerCase();
+            return ((target.endsWith("crw")) || (target.endsWith("cr2")) || (target.endsWith("cr3")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public boolean isMovie()
+    {
+        try
+        {
+            String target = getContentName().toLowerCase();
+            return ((target.endsWith("mov")) || (target.endsWith("mp4")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
     public boolean isDateValid()
     {
         return (isDateValid);
     }
 
     @Override
+    public boolean isContentNameValid()
+    {
+        return (true);
+    }
+
+    @Override
     public Date getCapturedDate()
     {
         return (date);
index 8a89d83..ffd4922 100644 (file)
@@ -25,7 +25,7 @@ public class CanonImageObjectReceiver implements IPtpIpCommandCallback
     private final PtpIpInterfaceProvider provider;
     private boolean isDumpLog = false;
     private List<ICameraContent> imageObjectList;
-    private List<PtpIpImageContentInfo> ptpIpImageObjectList;
+    private List<CanonImageContentInfo> ptpIpImageObjectList;
     private ICameraContentListCallback callback = null;
     private int subDirectoriesCount = -1;
     private int receivedSubDirectoriesCount = -1;
@@ -58,10 +58,10 @@ public class CanonImageObjectReceiver implements IPtpIpCommandCallback
                     break;
 
                 case GET_OBJECT_INFO_EX:
-                    List<PtpIpImageContentInfo> directries =  parseContentSubdirectories(rx_body, 32);
+                    List<CanonImageContentInfo> directries =  parseContentSubdirectories(rx_body, 32);
                     {
                         // サブディレクトリの情報を拾う
-                        for (PtpIpImageContentInfo contentInfo : directries)
+                        for (CanonImageContentInfo contentInfo : directries)
                         {
                             publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_OBJECT_INFO_EX_2, isDumpLog, 0, 0x9109, 12, 0x00010001, contentInfo.getId(), 0x00200000));
                         }
@@ -69,10 +69,10 @@ public class CanonImageObjectReceiver implements IPtpIpCommandCallback
                     break;
 
                 case GET_OBJECT_INFO_EX_2:
-                    List<PtpIpImageContentInfo> subDirectries =  parseContentSubdirectories(rx_body, 32);
+                    List<CanonImageContentInfo> subDirectries =  parseContentSubdirectories(rx_body, 32);
                     {
                         // 画像の情報を拾う
-                        for (PtpIpImageContentInfo contentInfo : subDirectries)
+                        for (CanonImageContentInfo contentInfo : subDirectries)
                         {
                             publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_OBJECT_INFO_EX_3, isDumpLog, 0, 0x9109, 12, 0x00010001, contentInfo.getId(), 0x00200000));
                         }
@@ -91,7 +91,7 @@ public class CanonImageObjectReceiver implements IPtpIpCommandCallback
                     {
                         Log.v(TAG, " --- CONTENT ---");
                     }
-                    List<PtpIpImageContentInfo> objects =  parseContentSubdirectories(rx_body, 32);
+                    List<CanonImageContentInfo> objects =  parseContentSubdirectories(rx_body, 32);
                     if (objects.size() > 0)
                     {
                         imageObjectList.addAll(objects);
@@ -118,9 +118,9 @@ public class CanonImageObjectReceiver implements IPtpIpCommandCallback
         }
     }
 
-    private List<PtpIpImageContentInfo> parseContentSubdirectories(byte[] rx_body, int offset)
+    private List<CanonImageContentInfo> parseContentSubdirectories(byte[] rx_body, int offset)
     {
-        List<PtpIpImageContentInfo> result = new ArrayList<>();
+        List<CanonImageContentInfo> result = new ArrayList<>();
         try
         {
             int nofObjects = (rx_body[offset] & 0xff);
@@ -142,7 +142,7 @@ public class CanonImageObjectReceiver implements IPtpIpCommandCallback
                 id = id + ((rx_body[dataIndex + 2] & 0xff) << 16);
                 id = id + ((rx_body[dataIndex + 3] & 0xff) << 24);
 
-                PtpIpImageContentInfo content = new PtpIpImageContentInfo(id, "", rx_body, dataIndex, objectSize);
+                CanonImageContentInfo content = new CanonImageContentInfo(id, "", rx_body, dataIndex, objectSize);
                 result.add(content);
                 dataIndex = dataIndex + objectSize;
                 if (result.size() >= nofObjects)
@@ -171,9 +171,9 @@ public class CanonImageObjectReceiver implements IPtpIpCommandCallback
         return (false);
     }
 
-    PtpIpImageContentInfo getContentObject(String fileName)
+    CanonImageContentInfo getContentObject(String fileName)
     {
-        for (PtpIpImageContentInfo contentInfo : ptpIpImageObjectList)
+        for (CanonImageContentInfo contentInfo : ptpIpImageObjectList)
         {
 
             if (fileName.matches(contentInfo.getContentName()))
index 94d3de2..e435e16 100644 (file)
@@ -102,7 +102,7 @@ public class PtpIpPlaybackControl implements IPlaybackControl
                 start = 1;
             }
             final String indexStr = path.substring(start);
-            PtpIpImageContentInfo content = canonImageObjectReceiver.getContentObject(indexStr);
+            CanonImageContentInfo content = canonImageObjectReceiver.getContentObject(indexStr);
             if (content != null)
             {
                 IPtpIpCommandPublisher publisher = provider.getCommandPublisher();
@@ -142,7 +142,7 @@ public class PtpIpPlaybackControl implements IPlaybackControl
             final String indexStr = path.substring(start);
             //Log.v(TAG, "downloadContentThumbnail() : [" + path + "] " + indexStr);
 
-            PtpIpImageContentInfo content = canonImageObjectReceiver.getContentObject(indexStr);
+            CanonImageContentInfo content = canonImageObjectReceiver.getContentObject(indexStr);
             if (content != null)
             {
                 IPtpIpCommandPublisher publisher = provider.getCommandPublisher();
@@ -169,7 +169,7 @@ public class PtpIpPlaybackControl implements IPlaybackControl
                 start = 1;
             }
             final String indexStr = path.substring(start);
-            PtpIpImageContentInfo content = canonImageObjectReceiver.getContentObject(indexStr);
+            CanonImageContentInfo content = canonImageObjectReceiver.getContentObject(indexStr);
             if (content != null)
             {
                 if (isSmallSize)
index 3acdb6a..f66aca2 100644 (file)
@@ -127,6 +127,42 @@ public class SonyImageContentInfo implements ICameraContent
         return (getContentNameString());
     }
 
+    @Override
+    public String getOriginalName()
+    {
+        return (getContentName());
+    }
+
+    @Override
+    public boolean isRaw()
+    {
+        try
+        {
+            String target = getContentName().toLowerCase();
+            return ((target.endsWith("arw")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
+    @Override
+    public boolean isMovie()
+    {
+        try
+        {
+            String target = getContentName().toLowerCase();
+            return ((target.endsWith("mov")) || (target.endsWith("mp4")));
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        return (false);
+    }
+
     private String getContentNameObject()
     {
         String fileName = "";
@@ -149,7 +185,7 @@ public class SonyImageContentInfo implements ICameraContent
         {
             int startIndex = contentString.indexOf("<dc:title>");
             int endIndex = contentString.indexOf("</dc:title>");
-            Log.v(TAG, "getContentNameString : " + contentString.substring(startIndex + 10, endIndex));
+            //Log.v(TAG, "  getContentNameString : " + contentString.substring(startIndex + 10, endIndex));
             return (contentString.substring(startIndex + 10, endIndex));
         }
         catch (Exception e)
@@ -166,6 +202,12 @@ public class SonyImageContentInfo implements ICameraContent
     }
 
     @Override
+    public boolean isContentNameValid()
+    {
+        return (true);
+    }
+
+    @Override
     public Date getCapturedDate()
     {
         if (contentObject != null)
index bba49f9..d9cc9a3 100644 (file)
@@ -67,6 +67,8 @@ public class ImageGridViewFragment extends Fragment implements AdapterView.OnIte
     private static final String CANON_RAW_SUFFIX = ".crw";
     private static final String CANON_RAW_SUFFIX2 = ".cr2";
     private static final String CANON_RAW_SUFFIX3 = ".cr3";
+    private static final String FUJI_RAW_SUFFIX = ".raf";
+
 
     private MyContentDownloader contentDownloader;
     private GridView gridView;
@@ -75,6 +77,7 @@ public class ImageGridViewFragment extends Fragment implements AdapterView.OnIte
        private ICameraRunMode runMode;
 
     private LruCache<String, Bitmap> imageCache;
+    //private List<ICameraContent> imageContentList;
     private List<CameraContentEx> imageContentList;
        private ExecutorService executor;
        private ImageGridViewAdapter adapter = null;
@@ -439,6 +442,7 @@ public class ImageGridViewFragment extends Fragment implements AdapterView.OnIte
 
         List<CameraContentEx> contentItems = new ArrayList<>();
         HashMap<String, CameraContentEx> rawItems = new HashMap<>();
+
         for (ICameraContent item : contents)
         {
             //Log.v(TAG, "......contents : [" + item.getContentName() + "]");
@@ -483,6 +487,10 @@ public class ImageGridViewFragment extends Fragment implements AdapterView.OnIte
             {
                 contentItems.add(new CameraContentEx(item, true, NIKON_RAW_SUFFIX));
             }
+            else if (path.endsWith(FUJI_RAW_SUFFIX))
+            {
+                contentItems.add(new CameraContentEx(item, true, FUJI_RAW_SUFFIX));
+            }
         }
 
         for (CameraContentEx item : contentItems)
index be0420b..c793465 100644 (file)
@@ -41,11 +41,16 @@ public class MyContentDownloader implements IDownloadContentCallback
     private final Activity activity;
     private final IPlaybackControl playbackControl;
     private final IContentDownloadNotify receiver;
-    private static final String RAW_SUFFIX_1 = ".DNG";
-    private static final String RAW_SUFFIX_2 = ".ORF";
-    private static final String RAW_SUFFIX_3 = ".PEF";
-    private static final String RAW_SUFFIX_4 = ".RW2";
-    private static final String RAW_SUFFIX_5 = ".ARW";
+    private static final String RAW_SUFFIX_1 = ".DNG";  // RAW: Ricoh / Pentax
+    private static final String RAW_SUFFIX_2 = ".ORF";  // RAW: Olympus
+    private static final String RAW_SUFFIX_3 = ".PEF";  // RAW: Pentax
+    private static final String RAW_SUFFIX_4 = ".RW2";  // RAW: Panasonic
+    private static final String RAW_SUFFIX_5 = ".ARW";  // RAW: Sony
+    private static final String RAW_SUFFIX_6 = ".CRW";  // RAW: Canon
+    private static final String RAW_SUFFIX_7 = ".CR2";  // RAW: Canon
+    private static final String RAW_SUFFIX_8 = ".CR3";  // RAW: Canon
+    private static final String RAW_SUFFIX_9 = ".NEF";  // RAW: Nikon
+    private static final String RAW_SUFFIX_0 = ".RAF";  // RAW: Fuji
     private static final String MOVIE_SUFFIX = ".MOV";
     private static final String MOVIE_SUFFIX_MP4 = ".MP4";
     private static final String JPEG_SUFFIX = ".JPG";
@@ -78,50 +83,73 @@ public class MyContentDownloader implements IDownloadContentCallback
             Log.v(TAG, "startDownload() ICameraFileInfo is NULL...");
             return;
         }
-        Log.v(TAG, "startDownload() " + fileInfo.getContentName());
+        Log.v(TAG, "startDownload() " + fileInfo.getOriginalName());
 
         // Download the image.
         try
         {
             isDownloading = true;
-            Calendar calendar = Calendar.getInstance();
-            String extendName = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.getDefault()).format(calendar.getTime());
-            targetFileName = fileInfo.getContentName().toUpperCase();
+            String contentFileName  = fileInfo.getContentName().toUpperCase();
             if (replaceJpegSuffix != null)
             {
-                targetFileName = targetFileName.replace(JPEG_SUFFIX, replaceJpegSuffix);
+                contentFileName = contentFileName.replace(JPEG_SUFFIX, replaceJpegSuffix);
             }
-            if (targetFileName.toUpperCase().contains(RAW_SUFFIX_1))
+            if (contentFileName.toUpperCase().contains(RAW_SUFFIX_1))
             {
                 mimeType = "image/x-adobe-dng";
                 isSmallSize = false;
             }
-            else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_2))
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_2))
             {
                 mimeType = "image/x-olympus-orf";
                 isSmallSize = false;
             }
-            else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_3))
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_3))
             {
                 mimeType = "image/x-pentax-pef";
                 isSmallSize = false;
             }
-            else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_4))
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_4))
             {
-                mimeType = "image/x-panasonic-raw2";
+                mimeType = "image/x-panasonic-rw2";
                 isSmallSize = false;
             }
-            else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_5))
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_5))
             {
                 mimeType = "image/x-sony-arw";
                 isSmallSize = false;
             }
-            else if (targetFileName.toUpperCase().contains(MOVIE_SUFFIX))
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_6))
+            {
+                mimeType = "image/x-canon-crw";
+                isSmallSize = false;
+            }
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_7))
+            {
+                mimeType = "image/x-canon-cr2";
+                isSmallSize = false;
+            }
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_8))
+            {
+                mimeType = "image/x-canon-cr3";
+                isSmallSize = false;
+            }
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_9))
+            {
+                mimeType = "image/x-nikon-nef";
+                isSmallSize = false;
+            }
+            else if (contentFileName.toUpperCase().contains(RAW_SUFFIX_0))
+            {
+                mimeType = "image/x-fuji-raf";
+                isSmallSize = false;
+            }
+            else if (contentFileName.toUpperCase().contains(MOVIE_SUFFIX))
             {
                 mimeType =  "video/mp4";
                 isSmallSize = false;
             }
-            else if (targetFileName.toUpperCase().contains(MOVIE_SUFFIX_MP4))
+            else if (contentFileName.toUpperCase().contains(MOVIE_SUFFIX_MP4))
             {
                 mimeType =  "video/mp4";
                 isSmallSize = false;
@@ -131,6 +159,8 @@ public class MyContentDownloader implements IDownloadContentCallback
                 mimeType = "image/jpeg";
             }
 
+            targetFileName = fileInfo.getOriginalName().toUpperCase();
+
             ////// ダイアログの表示
             activity.runOnUiThread(new Runnable() {
                 @Override
@@ -147,10 +177,15 @@ public class MyContentDownloader implements IDownloadContentCallback
                     downloadDialog.show();
                 }
             });
-            String path = fileInfo.getContentPath() + "/" + targetFileName;
 
             final String directoryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getPath() + "/" + activity.getString(R.string.app_name2) + "/";
-            String outputFileName =  extendName + "_" + targetFileName;
+
+            Calendar calendar = Calendar.getInstance();
+            String  extendName = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.getDefault()).format(calendar.getTime());
+            int periodPosition = targetFileName.indexOf(".");
+            String extension = targetFileName.substring(periodPosition);
+            String baseFileName = targetFileName.substring(0, periodPosition);
+            String outputFileName =  baseFileName + "_" + extendName + extension;
             filepath = new File(directoryPath.toLowerCase(), outputFileName.toLowerCase()).getPath();
             try
             {
@@ -164,6 +199,7 @@ public class MyContentDownloader implements IDownloadContentCallback
                 }
                 outputStream = new FileOutputStream(filepath);
 
+                String path = fileInfo.getContentPath() + "/" + contentFileName;
                 Log.v(TAG, "downloadContent : " + path + " (small: " + isSmallSize + ")");
                 playbackControl.downloadContent(path, isSmallSize, this);
             }
@@ -240,7 +276,13 @@ public class MyContentDownloader implements IDownloadContentCallback
                 outputStream.close();
                 outputStream = null;
             }
-            if ((!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_1))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_2))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_3)))
+/*
+            // RAW ファイルを、ContentResolverに登録しない場合。。。
+            if ((!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_1))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_2))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_3))&&
+                (!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_4))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_5))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_6))&&
+                (!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_7))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_8))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_9))&&
+                (!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_0)))
+*/
             {
                 // ギャラリーに受信したファイルを登録する
                 long now = System.currentTimeMillis();
index 5dc2ea8..e2dbf7d 100644 (file)
@@ -35,6 +35,12 @@ public class CameraContentEx
 
     public boolean hasRaw()
     {
+        if (!(fileInfo.isContentNameValid()))
+        {
+            //
+
+
+        }
         return (hasRaw);
     }
 
index 79c976e..16c6e97 100644 (file)
@@ -136,17 +136,17 @@ public class ImageGridViewAdapter extends BaseAdapter implements AbsListView.OnS
                 {
                     executor = Executors.newFixedThreadPool(1);
                 }
-                executor.execute(new ImageThumbnailLoader(activity, playbackControl, imageCache, viewHolder, path, infoEx.hasRaw(), infoEx.isMovie()));
+                executor.execute(new ImageThumbnailLoader(activity, playbackControl, imageCache, viewHolder, path, infoEx));
             }
         }
         else
         {
             viewHolder.getImageView().setImageBitmap(thumbnail);
-            if (infoEx.isMovie())
+            if (infoEx.getFileInfo().isMovie())
             {
                 viewHolder.getIconView().setImageResource(R.drawable.ic_videocam_grey_24dp);
             }
-            else if (infoEx.hasRaw())
+            else if (infoEx.getFileInfo().isRaw())
             {
                 viewHolder.getIconView().setImageResource(R.drawable.ic_raw_black_1x);
             }
index 6401d43..9c36a1f 100644 (file)
@@ -6,6 +6,7 @@ import android.util.Log;
 import net.osdn.gokigen.pkremote.R;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback;
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
+import net.osdn.gokigen.pkremote.playback.detail.CameraContentEx;
 
 import java.util.Map;
 
@@ -21,18 +22,16 @@ public class ImageThumbnailLoader implements Runnable
     private final AppCompatActivity activity;
     private LruCache<String, Bitmap> imageCache;
     private String path;
-    private final boolean hasRaw;
-    private final boolean isMovie;
+    private final CameraContentEx infoEx;
 
-    ImageThumbnailLoader(@NonNull AppCompatActivity activity,  @NonNull IPlaybackControl playbackControl, LruCache<String, Bitmap> imageCache, ImageGridCellViewHolder viewHolder, String path, boolean hasRaw, boolean isMovie)
+    ImageThumbnailLoader(@NonNull AppCompatActivity activity, @NonNull IPlaybackControl playbackControl, LruCache<String, Bitmap> imageCache, ImageGridCellViewHolder viewHolder, String path, CameraContentEx infoEx)
     {
         this.activity = activity;
         this.playbackControl = playbackControl;
         this.imageCache = imageCache;
         this.viewHolder = viewHolder;
         this.path = path;
-        this.hasRaw = hasRaw;
-        this.isMovie = isMovie;
+        this.infoEx = infoEx;
     }
 
     @Override
@@ -57,9 +56,9 @@ public class ImageThumbnailLoader implements Runnable
                             @Override
                             public void run() {
                                 viewHolder.getImageView().setImageBitmap(thumbnail);
-                                if (isMovie) {
+                                if (infoEx.getFileInfo().isMovie()) {
                                     viewHolder.getIconView().setImageResource(R.drawable.ic_videocam_grey_24dp);
-                                } else if (hasRaw) {
+                                } else if (infoEx.getFileInfo().isRaw()) {
                                     viewHolder.getIconView().setImageResource(R.drawable.ic_raw_black_1x);
                                 } else {
                                     viewHolder.getIconView().setImageDrawable(null);