OSDN Git Service

GR2専用コマンドを、GR2と接続したときにだけ有効にするように仕様を変更した。
[gokigen/Gr2Control.git] / app / src / main / java / net / osdn / gokigen / gr2control / camera / ricohgr2 / wrapper / RicohGr2StatusChecker.java
index 3dbf99d..75d6eb7 100644 (file)
@@ -1,20 +1,17 @@
 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;
 
+import androidx.annotation.NonNull;
+
 /**
  *
  *
@@ -27,23 +24,25 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
     private final String grCommandUrl = "http://192.168.0.1/_gr";
     private final int sleepMs;
 
-    private final boolean useGrCommand;
-
     private int timeoutMs = 5000;
     private boolean whileFetching = false;
     private RicohGr2StatusHolder statusHolder;
+    private boolean useGR2command = false;
 
     /**
      *
      *
      */
-    RicohGr2StatusChecker(@NonNull Activity context, int sleepMs)
+    RicohGr2StatusChecker(int sleepMs)
     {
-        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
-        useGrCommand = preferences.getBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
         this.sleepMs = sleepMs;
     }
 
+    public void setUseGR2Command(boolean useGR2command)
+    {
+        this.useGR2command = useGR2command;
+    }
+
     /**
      *
      *
@@ -83,7 +82,7 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
      *
      */
     @Override
-    public void stoptStatusWatch()
+    public void stopStatusWatch()
     {
         Log.v(TAG, "stoptStatusWatch()");
         whileFetching = false;
@@ -180,7 +179,7 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
                 {
                     String response;
                     String postData = key + "=" + value;
-                    if ((useGrCommand)&&(key.equals("exposureMode")))
+                    if ((useGR2command)&&(key.equals("exposureMode")))
                     {
                         //  撮影モードを変更するときは、GR専用コマンドを送ることにする。
                         postData = "cmd=" + decideButtonCode(value);
@@ -191,7 +190,7 @@ public class RicohGr2StatusChecker implements ICameraStatusWatcher, ICameraStatu
                         response = SimpleHttpClient.httpPut(statusSetUrl, postData, timeoutMs);
                         Log.v(TAG, "SET PROPERTY : " + postData + " resp. (" + response.length() + "bytes.)");
                     }
-                    if (useGrCommand)
+                    if (useGR2command)
                     {
                         //  GR専用コマンドで、画面表示をリフレッシュ
                         response = SimpleHttpClient.httpPost(grCommandUrl, "cmd=mode refresh", timeoutMs);