OSDN Git Service

GR2専用コマンドを使用するかどうか、設定で変えられるようにした。
authorMRSa <mrsa@myad.jp>
Mon, 27 Aug 2018 15:26:48 +0000 (00:26 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 27 Aug 2018 15:26:48 +0000 (00:26 +0900)
app/src/main/java/net/osdn/gokigen/gr2control/camera/ricohgr2/wrapper/RicohGr2InterfaceProvider.java
app/src/main/java/net/osdn/gokigen/gr2control/camera/ricohgr2/wrapper/RicohGr2StatusChecker.java
app/src/main/java/net/osdn/gokigen/gr2control/preference/IPreferencePropertyAccessor.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_ricoh_gr2.xml

index 4399be4..27196fa 100644 (file)
@@ -62,7 +62,7 @@ public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, ID
         liveViewControl = new RicohGr2LiveViewControl();
         zoomControl = new RicohGr2CameraZoomLensControl();
         buttonControl = new RicohGr2CameraButtonControl();
-        statusChecker = new RicohGr2StatusChecker(500);
+        statusChecker = new RicohGr2StatusChecker(context, 500);
         playbackControl = new RicohGr2PlaybackControl();
         hardwareStatus = new RicohGr2HardwareStatus();
         runMode = new RicohGr2RunMode();
index def17b7..3dbf99d 100644 (file)
@@ -1,12 +1,16 @@
 package net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper;
 
+import android.app.Activity;
+import android.content.SharedPreferences;
 import android.support.annotation.NonNull;
+import android.support.v7.preference.PreferenceManager;
 import android.util.Log;
 
 import net.osdn.gokigen.gr2control.camera.ICameraStatus;
 import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
 import net.osdn.gokigen.gr2control.camera.utils.SimpleHttpClient;
 import net.osdn.gokigen.gr2control.liveview.ICameraStatusUpdateNotify;
+import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -23,7 +27,7 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
     private final String grCommandUrl = "http://192.168.0.1/_gr";
     private final int sleepMs;
 
-    private boolean useGrCommand = true;
+    private final boolean useGrCommand;
 
     private int timeoutMs = 5000;
     private boolean whileFetching = false;
@@ -33,8 +37,10 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
      *
      *
      */
-    RicohGr2StatusChecker(int sleepMs)
+    RicohGr2StatusChecker(@NonNull Activity context, int sleepMs)
     {
+        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+        useGrCommand = preferences.getBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
         this.sleepMs = sleepMs;
     }
 
@@ -185,9 +191,12 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
                         response = SimpleHttpClient.httpPut(statusSetUrl, postData, timeoutMs);
                         Log.v(TAG, "SET PROPERTY : " + postData + " resp. (" + response.length() + "bytes.)");
                     }
-                    //  GR専用コマンドで、画面表示をリフレッシュ
-                    response = SimpleHttpClient.httpPost(grCommandUrl, "cmd=mode refresh", timeoutMs);
-                    Log.v(TAG, "refresh resp. (" + response.length() + "bytes.)");
+                    if (useGrCommand)
+                    {
+                        //  GR専用コマンドで、画面表示をリフレッシュ
+                        response = SimpleHttpClient.httpPost(grCommandUrl, "cmd=mode refresh", timeoutMs);
+                        Log.v(TAG, "refresh resp. (" + response.length() + "bytes.)");
+                    }
                 }
                 catch (Exception e)
                 {
index 472a884..b2623ab 100644 (file)
@@ -36,6 +36,8 @@ public interface IPreferencePropertyAccessor
 
     String GR2_LCD_SLEEP = "gr2_lcd_sleep";
 
+    String USE_GR2_SPECIAL_COMMAND = "use_gr2_special_command";
+
     String DIGITAL_ZOOM_LEVEL = "digital_zoom_level";
     String DIGITAL_ZOOM_LEVEL_DEFAULT_VALUE = "1.0";
 
index 54475ab..1a53214 100644 (file)
@@ -140,6 +140,15 @@ public class PreferenceFragment extends PreferenceFragmentCompat implements Shar
         if (!items.containsKey(IPreferencePropertyAccessor.USE_PLAYBACK_MENU)) {
             editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, false);
         }
+        if (!items.containsKey(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW)) {
+            editor.putBoolean(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, true);
+        }
+        if (!items.containsKey(IPreferencePropertyAccessor.GR2_LCD_SLEEP)) {
+            editor.putBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false);
+        }
+        if (!items.containsKey(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND)) {
+            editor.putBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
+        }
         editor.apply();
     }
 
index 1597208..14a80b4 100644 (file)
@@ -123,6 +123,9 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
             if (!items.containsKey(IPreferencePropertyAccessor.SHARE_AFTER_SAVE)) {
                 editor.putBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND)) {
+                editor.putBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
+            }
             editor.apply();
         }
         catch (Exception e)
@@ -174,6 +177,11 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
                     Log.v(TAG, " " + key + " , " + value);
                     break;
 
+                case IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND:
+                    value = preferences.getBoolean(key, true);
+                    Log.v(TAG, " " + key + " , " + value);
+                    break;
+
                 default:
                     String strValue = preferences.getString(key, "");
                     setListPreference(key, key, strValue);
@@ -328,6 +336,7 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
                         setBooleanPreference(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, defaultValue);
                         setBooleanPreference(IPreferencePropertyAccessor.GR2_LCD_SLEEP, IPreferencePropertyAccessor.GR2_LCD_SLEEP, defaultValue);
                         setBooleanPreference(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, IPreferencePropertyAccessor.SHARE_AFTER_SAVE, defaultValue);
+                        setBooleanPreference(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, defaultValue);
                     }
                     catch (Exception e)
                     {
index 66882be..09847e7 100644 (file)
     <string name="exif_metering_mode_title">測光モード :</string>
     <string name="exif_custom_process_title">(スペシャル・エフェクト使用)</string>
     <string name="exif_with_gps">(位置情報あり)</string>
+    <string name="pref_use_gr2_special_command">GR2専用コマンドの使用</string>
+    <string name="summary_use_gr2_special_command">制御指示の一部にGR2用コマンドを使用します。</string>
+
 </resources>
index afa55ed..82d2240 100644 (file)
     <string name="pref_camera_version">Camera Version</string>
     <string name="pref_camerakit_version">Camera kit Version</string>
 
+    <string name="pref_use_gr2_special_command">Use GR2 Special Command</string>
+    <string name="summary_use_gr2_special_command">Use some GR2 special command.</string>
+
 </resources>
index 21b5cb1..0a2c468 100644 (file)
             android:key="use_playback_menu"
             android:title="@string/pref_use_playback_menu"
             />
+
+        <CheckBoxPreference
+            android:key="use_gr2_special_command"
+            android:title="@string/pref_use_gr2_special_command"
+            android:summary="@string/summary_use_gr2_special_command"
+            />
     </PreferenceCategory>
 
     <PreferenceCategory