OSDN Git Service

Olympusのスモール取得サイズを設定可能にする。
authorMRSa <mrsa@myad.jp>
Sat, 19 Oct 2019 12:57:14 +0000 (21:57 +0900)
committerMRSa <mrsa@myad.jp>
Sat, 19 Oct 2019 12:57:14 +0000 (21:57 +0900)
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/OlympusPenInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/olympuspen/wrapper/playback/OlympusPenPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java
app/src/main/java/net/osdn/gokigen/pkremote/preference/olympus/OpcPreferenceFragment.java
app/src/main/java/net/osdn/gokigen/pkremote/preference/olympuspen/OlympusPenPreferenceFragment.java
app/src/main/res/xml/preferences_olympus.xml

index 97d85d7..ccd6f3e 100644 (file)
@@ -71,7 +71,7 @@ public class OlympusPenInterfaceProvider implements IOlympusPenInterfaceProvider
         //this.provider = provider;
         olympusPenConnection = new OlympusPenConnection(context, provider);
         buttonControl = new OlympusPenButtonControl();
-        playbackControl = new OlympusPenPlaybackControl(communicationTimeoutMs);
+        playbackControl = new OlympusPenPlaybackControl(context, communicationTimeoutMs);
         hardwareStatus = new OlympusPenHardwareStatus();
         runMode = new OlympusPenRunMode();
     }
index edc743d..9d82673 100644 (file)
@@ -1,4 +1,6 @@
 package net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.playback;
+import android.app.Activity;
+import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 import android.util.Log;
 
@@ -11,11 +13,13 @@ import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailIm
 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
 import net.osdn.gokigen.pkremote.camera.playback.ProgressEvent;
 import net.osdn.gokigen.pkremote.camera.utils.SimpleHttpClient;
+import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
 
 import java.util.HashMap;
 import java.util.Map;
 
 import androidx.annotation.NonNull;
+import androidx.preference.PreferenceManager;
 
 /**
  *
@@ -25,12 +29,14 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
 {
     private final String TAG = toString();
     private static final int DEFAULT_TIMEOUT = 3000;
+    private final Activity activity;
     private final int timeoutValue;
     private OlympusPenObjectDataHolder imageListHolder = new OlympusPenObjectDataHolder();
 
-    public OlympusPenPlaybackControl(int timeoutMs)
+    public OlympusPenPlaybackControl(@NonNull Activity activity, int timeoutMs)
     {
         Log.v(TAG, "OlympusPenPlaybackControl()");
+        this.activity = activity;
         this.timeoutValue  = (timeoutMs < DEFAULT_TIMEOUT) ? DEFAULT_TIMEOUT : timeoutMs;
     }
 
@@ -115,8 +121,18 @@ public class OlympusPenPlaybackControl implements IPlaybackControl
             String url;
             if ((isSmallSize)&&(path.contains(".JPG")))
             {
+                String smallSize = "1600";
+                try
+                {
+                    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
+                    smallSize = preferences.getString(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE, IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE_DEFAULT_VALUE);
+                }
+                catch (Exception e)
+                {
+                    e.printStackTrace();
+                }
                 // 縮小サイズで画像をとる
-                url = "http://192.168.0.10/get_resizeimg.cgi?DIR=" + path + "&size=" + "1600";
+                url = "http://192.168.0.10/get_resizeimg.cgi?DIR=" + path + "&size=" + smallSize;
             }
             else
             {
index 4bbb2fd..07015dc 100644 (file)
@@ -28,6 +28,10 @@ public interface IPreferencePropertyAccessor
     String SMALL_PICTURE_SIZE = "download_small_picture_size";
     String SMALL_PICTURE_SIZE_DEFAULT_VALUE = "1600";
 
+    String PEN_SMALL_PICTURE_SIZE = "pen_download_small_picture_size";
+    String PEN_SMALL_PICTURE_SIZE_DEFAULT_VALUE = "1600";
+
+
     String CAMERAKIT_VERSION = "camerakit_version";
 
     String SHOW_GRID_STATUS = "show_grid";
index 0031e89..1c5b66e 100644 (file)
@@ -155,6 +155,9 @@ public class OpcPreferenceFragment extends PreferenceFragmentCompat implements S
         if (!items.containsKey(IPreferencePropertyAccessor.SMALL_PICTURE_SIZE)) {
             editor.putString(IPreferencePropertyAccessor.SMALL_PICTURE_SIZE, IPreferencePropertyAccessor.SMALL_PICTURE_SIZE_DEFAULT_VALUE);
         }
+        if (!items.containsKey(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE)) {
+            editor.putString(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE, IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE_DEFAULT_VALUE);
+        }
         editor.apply();
     }
 
index 39450e6..e15fb0b 100644 (file)
@@ -117,6 +117,9 @@ public class OlympusPenPreferenceFragment  extends PreferenceFragmentCompat impl
             if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) {
                 editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE)) {
+                editor.putString(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE, IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE_DEFAULT_VALUE);
+            }
             editor.apply();
         }
         catch (Exception e)
@@ -179,6 +182,16 @@ public class OlympusPenPreferenceFragment  extends PreferenceFragmentCompat impl
             });
             connectionMethod.setSummary(connectionMethod.getValue() + " ");
 
+            ListPreference smallPictureSize = findPreference(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE);
+            smallPictureSize.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+                @Override
+                public boolean onPreferenceChange(Preference preference, Object newValue) {
+                    preference.setSummary(newValue + " ");
+                    return (true);
+                }
+            });
+            smallPictureSize.setSummary(smallPictureSize.getValue() + " ");
+
             findPreference("exit_application").setOnPreferenceClickListener(powerOffController);
             findPreference("debug_info").setOnPreferenceClickListener(logCatViewer);
         }
index 58394c3..7066b96 100644 (file)
     <PreferenceCategory
         android:title="@string/pref_cat_camera">
 
-        <!--
-
-        <PreferenceScreen
-            android:key="sony_api_list"
-            android:title="@string/pref_sony_api_list"
-            android:summary="@string/pref_summary_sony_api_list" />
-
-        <CheckBoxPreference
-            android:key="use_smartphone_transfer_mode"
-            android:title="@string/pref_sony_use_smartphone_transfer"
-            android:summary="@string/pref_summary_sony_use_smartphone_transfer" />
-
-        <CheckBoxPreference
-            android:key="get_small_picture_as_vga"
-            android:title="@string/pref_get_small_picture_as_vga"
-            android:summary="@string/pref_summary_get_small_picture_as_vga" />
+        <ListPreference
+            android:title="@string/pref_download_small_picture_size"
+            android:entryValues="@array/pen_picture_quality_value"
+            android:entries="@array/pen_picture_quality"
+            android:key="pen_download_small_picture_size"
+            android:defaultValue="1600"/>
 
-                <CheckBoxPreference
-                    android:key="capture_both_camera_and_live_view"
-                    android:title="@string/pref_capture_both_camera_and_live_view" />
-        -->
     </PreferenceCategory>
 
     <PreferenceCategory