OSDN Git Service

GR系はjpegとRAW, 並べて表示するようにした。(冗長だけど) RAWの拡張子取得方法を変更する。
authorMRSa <mrsa@myad.jp>
Sat, 8 Sep 2018 15:15:25 +0000 (00:15 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 8 Sep 2018 15:15:25 +0000 (00:15 +0900)
app/src/main/java/net/osdn/gokigen/gr2control/playback/ImageGridViewFragment.java
app/src/main/java/net/osdn/gokigen/gr2control/playback/detail/ImageContentInfoEx.java
app/src/main/java/net/osdn/gokigen/gr2control/playback/detail/ImagePagerViewFragment.java
app/src/main/java/net/osdn/gokigen/gr2control/playback/detail/MyContentDownloader.java

index a5b53f1..9525eca 100644 (file)
@@ -284,24 +284,25 @@ public class ImageGridViewFragment extends Fragment
                     String path = item.getFilename().toLowerCase(Locale.getDefault());
                     if ((path.toLowerCase().endsWith(JPEG_SUFFIX))||(path.toLowerCase().endsWith(MOVIE_SUFFIX)))
                     {
-                        contentItems.add(new ImageContentInfoEx(item, false));
+                        contentItems.add(new ImageContentInfoEx(item, false, ""));
                     }
                     else if (path.toLowerCase().endsWith(DNG_RAW_SUFFIX))
                     {
-                        //rawItems.put(path, new ImageContentInfoEx(item, true));
-                        contentItems.add(new ImageContentInfoEx(item, true));
+                        //rawItems.put(path, new ImageContentInfoEx(item, true, DNG_RAW_SUFFIX));
+                        contentItems.add(new ImageContentInfoEx(item, true, DNG_RAW_SUFFIX));
                     }
                     else if (path.toLowerCase().endsWith(OLYMPUS_RAW_SUFFIX))
                     {
-                        rawItems.put(path, new ImageContentInfoEx(item, true));
+                        rawItems.put(path, new ImageContentInfoEx(item, true, OLYMPUS_RAW_SUFFIX));
                     }
                     else if (path.toLowerCase().endsWith(PENTAX_RAW_PEF_SUFFIX))
                     {
-                        //rawItems.put(path, new ImageContentInfoEx(item, true));
-                        contentItems.add(new ImageContentInfoEx(item, true));
+                        //rawItems.put(path, new ImageContentInfoEx(item, true, PENTAX_RAW_PEF_SUFFIX));
+                        contentItems.add(new ImageContentInfoEx(item, true, PENTAX_RAW_PEF_SUFFIX));
                     }
                 }
 
+                //List<ImageContentInfoEx> appendRawContents = new ArrayList<>();
                 for (ImageContentInfoEx item : contentItems)
                 {
                     String path = item.getFileInfo().getFilename().toLowerCase(Locale.getDefault());
@@ -312,17 +313,22 @@ public class ImageGridViewFragment extends Fragment
                         ImageContentInfoEx raw1 = rawItems.get(target1);
                         if (raw1 != null)
                         {
-                               // RAW は、JPEGファイルがあった場合にのみリストする
-                            item.setHasRaw(true);
+                               // JPEGファイルとRAWファイルがあるので、それをマークする
+                            item.setHasRaw(true, DNG_RAW_SUFFIX);
                             Log.v(TAG, "DETECT RAW FILE: " + target1);
                         }
+                        else
+                        {
+                            // RAWだけあった場合、一覧に追加する
+                            appendRawContents.add(rawItems.get(path));
+                        }
 */
                         String target2 = path.replace(JPEG_SUFFIX, OLYMPUS_RAW_SUFFIX);
                         ImageContentInfoEx raw2 = rawItems.get(target2);
                         if (raw2 != null)
                         {
                             // RAW は、JPEGファイルがあった場合にのみリストする
-                            item.setHasRaw(true);
+                            item.setHasRaw(true, OLYMPUS_RAW_SUFFIX);
                             Log.v(TAG, "DETECT RAW FILE: " + target2);
                         }
 /*
@@ -331,12 +337,18 @@ public class ImageGridViewFragment extends Fragment
                         if (raw3 != null)
                         {
                             // RAW は、JPEGファイルがあった場合にのみリストする
-                            item.setHasRaw(true);
+                            item.setHasRaw(true, PENTAX_RAW_PEF_SUFFIX);
                             Log.v(TAG, "DETECT RAW FILE: " + target3);
                         }
+                        else
+                        {
+                            // RAWだけあった場合、一覧に追加する
+                            appendRawContents.add(rawItems.get(path));
+                        }
 */
                     }
                 }
+                //contentItems.addAll(appendRawContents);
                 contentList = contentItems;
 
                                runOnUiThread(new Runnable() {
index ecf074e..3020f7b 100644 (file)
@@ -5,23 +5,32 @@ import net.osdn.gokigen.gr2control.camera.ICameraFileInfo;
 public class ImageContentInfoEx
 {
     private final ICameraFileInfo fileInfo;
+    private String rawSuffix;
     private boolean hasRaw;
 
-    public ImageContentInfoEx(ICameraFileInfo fileInfo, boolean hasRaw)
+    public ImageContentInfoEx(ICameraFileInfo fileInfo, boolean hasRaw, String rawSuffix)
     {
         this.fileInfo = fileInfo;
         this.hasRaw = hasRaw;
+        this.rawSuffix = rawSuffix;
     }
 
-    public void setHasRaw(boolean value)
+    public void setHasRaw(boolean value, String rawSuffix)
     {
         hasRaw = value;
+        this.rawSuffix = rawSuffix;
     }
+
     public boolean hasRaw()
     {
         return (hasRaw);
     }
 
+    public String getRawSuffix()
+    {
+        return (rawSuffix);
+    }
+
     public ICameraFileInfo getFileInfo()
     {
         return (fileInfo);
index 7c122bf..9a7031b 100644 (file)
@@ -146,6 +146,7 @@ public class ImagePagerViewFragment extends Fragment
                boolean doDownload = false;
         boolean getInformation = false;
                boolean isSmallSize = false;
+               boolean isRaw = false;
         String specialSuffix = null;
         if ((item.getItemId() == R.id.action_get_information)||(item.getItemId() == R.id.action_get_information_raw))
         {
@@ -167,7 +168,7 @@ public class ImagePagerViewFragment extends Fragment
         else if (item.getItemId() == R.id.action_download_raw)
         {
             doDownload = true;
-            specialSuffix = playbackControl.getRawFileSuffix();
+            isRaw = true;
                }
 
                if (getInformation)
@@ -193,22 +194,14 @@ public class ImagePagerViewFragment extends Fragment
                {
                        try
                        {
-                ICameraFileInfo file = (contentList.get(contentIndex)).getFileInfo();
-                               String path = file.getDirectoryPath() + "/" + file.getFilename();
-                               String upperCasePath = path.toUpperCase();
-                               String suffix = (specialSuffix == null) ? upperCasePath.substring(upperCasePath.lastIndexOf(".")) : specialSuffix;
-                               Calendar calendar = Calendar.getInstance();
-                               String filename = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(calendar.getTime()) + suffix;
-
                                //  ダイアログを表示して保存する
-                               saveImageWithDialog(filename, isSmallSize);
+                               saveImageWithDialog(isRaw, isSmallSize);
                        }
                        catch (Exception e)
                        {
                                e.printStackTrace();
                        }
                }
-
                return (super.onOptionsItemSelected(item));
        }
 
@@ -484,12 +477,12 @@ public class ImagePagerViewFragment extends Fragment
        /**
         *   デバイスに画像ファイルをダウンロード(保存)する
         *
-        * @param filename       ファイル名(カメラ内の)
+        * @param isRaw           RAWファイルをダウンロードするか
         * @param isSmallSize    小さいサイズの量にするか
      */
-       public void saveImageWithDialog(final String filename, final boolean isSmallSize)
+       public void saveImageWithDialog(final boolean isRaw, final boolean isSmallSize)
        {
-        Log.v(TAG, "saveImageWithDialog() : " + filename + " (small : " + isSmallSize + ")");
+        Log.v(TAG, "saveImageWithDialog() : raw : " + isRaw + " (small : " + isSmallSize + ")");
         try
         {
             final Activity activity = getActivity();
@@ -499,8 +492,12 @@ public class ImagePagerViewFragment extends Fragment
                     @Override
                     public void run() {
                         MyContentDownloader contentDownloader = new MyContentDownloader(activity, playbackControl);
-                        ICameraFileInfo fileInfo = (contentList.get(contentIndex)).getFileInfo();
-                        contentDownloader.startDownload(fileInfo,  (filename.endsWith(playbackControl.getRawFileSuffix())) ? playbackControl.getRawFileSuffix() : null, isSmallSize);
+                        ImageContentInfoEx infoEx = contentList.get(contentIndex);
+                        if (infoEx != null)
+                        {
+                            ICameraFileInfo fileInfo = infoEx.getFileInfo();
+                            contentDownloader.startDownload(fileInfo, (isRaw) ? infoEx.getRawSuffix() : null, isSmallSize);
+                        }
                     }
                 });
                 thread.start();
index 6160a9c..12f5ff6 100644 (file)
@@ -39,6 +39,7 @@ class MyContentDownloader implements IDownloadContentCallback
     private final IPlaybackControl playbackControl;
     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 MOVIE_SUFFIX = ".MOV";
     private static final String JPEG_SUFFIX = ".JPG";
     private ProgressDialog downloadDialog = null;
@@ -86,7 +87,11 @@ class MyContentDownloader implements IDownloadContentCallback
             }
             else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_2))
             {
-                mimeType = "image/image/x-olympus-orf";
+                mimeType = "image/x-olympus-orf";
+            }
+            else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_3))
+            {
+                mimeType = "image/x-pentax-pef";
             }
             else if (targetFileName.toUpperCase().contains(MOVIE_SUFFIX))
             {
@@ -178,7 +183,7 @@ class MyContentDownloader implements IDownloadContentCallback
                 outputStream.close();
                 outputStream = null;
             }
-            if ((!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_1))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_2)))
+            if ((!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_1))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_2))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_3)))
             {
                 // ギャラリーに受信したファイルを登録する
                 long now = System.currentTimeMillis();