package net.osdn.gokigen.a01d.camera.ricohgr2.operation;
-import android.content.Context;
import net.osdn.gokigen.a01d.camera.ICaptureControl;
import net.osdn.gokigen.a01d.camera.ricohgr2.operation.takepicture.RicohGr2SingleShotControl;
+import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.IUsePentaxCommand;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import androidx.annotation.NonNull;
{
private final RicohGr2SingleShotControl singleShotControl;
- public RicohGr2CameraCaptureControl(@NonNull Context context, @NonNull IAutoFocusFrameDisplay frameDisplayer)
+ public RicohGr2CameraCaptureControl(@NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IUsePentaxCommand usePentaxCommand)
{
- singleShotControl = new RicohGr2SingleShotControl(context, frameDisplayer);
+ singleShotControl = new RicohGr2SingleShotControl(frameDisplayer, usePentaxCommand);
}
@Override
package net.osdn.gokigen.a01d.camera.ricohgr2.operation;
-import android.content.Context;
import android.graphics.PointF;
import android.util.Log;
import android.view.MotionEvent;
import net.osdn.gokigen.a01d.camera.IFocusingControl;
import net.osdn.gokigen.a01d.camera.ricohgr2.operation.takepicture.RicohGr2AutoFocusControl;
+import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.IUsePentaxCommand;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
private final RicohGr2AutoFocusControl afControl;
private final IAutoFocusFrameDisplay frameDisplay;
- public RicohGr2CameraFocusControl(@NonNull Context context, @NonNull final IAutoFocusFrameDisplay frameDisplayer, @NonNull final IIndicatorControl indicator)
+ public RicohGr2CameraFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, @NonNull final IIndicatorControl indicator, @NonNull IUsePentaxCommand usePentaxCommand)
{
this.frameDisplay = frameDisplayer;
- this.afControl = new RicohGr2AutoFocusControl(context, frameDisplayer, indicator);
+ this.afControl = new RicohGr2AutoFocusControl(frameDisplayer, indicator, usePentaxCommand);
}
@Override
package net.osdn.gokigen.a01d.camera.ricohgr2.operation.takepicture;
-import android.content.Context;
-import android.content.SharedPreferences;
import android.graphics.PointF;
import android.graphics.RectF;
-import android.preference.PreferenceManager;
import android.util.Log;
+import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.IUsePentaxCommand;
import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
-import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
import org.json.JSONObject;
private static final String TAG = RicohGr2AutoFocusControl.class.getSimpleName();
private final IIndicatorControl indicator;
private final IAutoFocusFrameDisplay frameDisplayer;
- private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock"; // Pentax機の場合は /v1/lens/focus
+ private final IUsePentaxCommand usePentaxCommand;
private String unlockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/unlock";
private String halfPressShutterUrl = "http://192.168.0.1/_gr";
private int timeoutMs = 6000;
*
*
*/
- public RicohGr2AutoFocusControl(@NonNull Context context, @NonNull final IAutoFocusFrameDisplay frameDisplayer, final IIndicatorControl indicator)
+ public RicohGr2AutoFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, final IIndicatorControl indicator, @NonNull IUsePentaxCommand usePentaxCommand)
{
this.frameDisplayer = frameDisplayer;
this.indicator = indicator;
-
- prepare(context);
- }
-
- /**
- *
- *
- */
- private void prepare(@NonNull Context context)
- {
- lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock";
- try
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- if (preferences.getBoolean(IPreferencePropertyAccessor.USE_PENTAX_AUTOFOCUS, false))
- {
- lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus";
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- Log.v(TAG, "FOCUS LOCK URL : " + lockAutoFocusUrl);
+ this.usePentaxCommand = usePentaxCommand;
}
/**
{
showFocusFrame(preFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Running, 0.0);
+ String lockAutoFocusUrl = (usePentaxCommand.getUsePentaxCommand()) ? "http://192.168.0.1/v1/lens/focus" : "http://192.168.0.1/v1/lens/focus/lock";
//int posX = (int) (Math.round(point.x * 100.0));
//int posY = (int) (Math.round(point.y * 100.0));
String postData = "pos=" + ( (int) (Math.round(point.x * 100.0))) + "," + ((int) (Math.round(point.y * 100.0)));
package net.osdn.gokigen.a01d.camera.ricohgr2.operation.takepicture;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
import android.util.Log;
+import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.IUsePentaxCommand;
import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
-import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
import androidx.annotation.NonNull;
private static final String TAG = RicohGr2SingleShotControl.class.getSimpleName();
private final String shootUrl = "http://192.168.0.1/v1/camera/shoot";
private final IAutoFocusFrameDisplay frameDisplayer;
- private boolean usePentaxDslr = false;
+ private final IUsePentaxCommand usePentaxCommand;
private int timeoutMs = 6000;
/**
*
*
*/
- public RicohGr2SingleShotControl(@NonNull Context context, @NonNull IAutoFocusFrameDisplay frameDisplayer)
+ public RicohGr2SingleShotControl(IAutoFocusFrameDisplay frameDisplayer, @NonNull IUsePentaxCommand usePentaxCommand)
{
this.frameDisplayer = frameDisplayer;
- prepare(context);
- }
-
- /**
- *
- *
- */
- private void prepare(@NonNull Context context)
- {
- try
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- usePentaxDslr = preferences.getBoolean(IPreferencePropertyAccessor.USE_PENTAX_AUTOFOCUS, false);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- Log.v(TAG, "USE PENTAX DSLR : " + usePentaxDslr);
+ this.usePentaxCommand = usePentaxCommand;
}
/**
{
try
{
- String postData = (usePentaxDslr) ? "" : "af=camera";
+ String postData = (usePentaxCommand.getUsePentaxCommand()) ? "" : "af=camera";
String result = SimpleHttpClient.httpPost(shootUrl, postData, timeoutMs);
if ((result == null)||(result.length() < 1))
{
--- /dev/null
+package net.osdn.gokigen.a01d.camera.ricohgr2.wrapper;
+
+public interface IUsePentaxCommand
+{
+ void setUsePentaxCommand(boolean usePentaxCommand);
+ boolean getUsePentaxCommand();
+}
package net.osdn.gokigen.a01d.camera.ricohgr2.wrapper;
import android.app.Activity;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
import android.util.Log;
import net.osdn.gokigen.a01d.camera.ICameraConnection;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
+import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
import androidx.annotation.NonNull;
*
*
*/
-public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector
+public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector, IUsePentaxCommand
{
private final String TAG = toString();
private final Activity activity;
private RicohGr2CameraZoomLensControl zoomControl;
private RicohGr2CameraFocusControl focusControl;
+ private boolean usePentaxCommand = false;
+
/**
*
*
{
this.activity = context;
//this.provider = provider;
- gr2Connection = new RicohGr2Connection(context, provider);
- liveViewControl = new RicohGr2LiveViewControl(context);
+ gr2Connection = new RicohGr2Connection(context, provider, this);
+ liveViewControl = new RicohGr2LiveViewControl(context, this);
zoomControl = new RicohGr2CameraZoomLensControl();
}
public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
{
Log.v(TAG, "injectDisplay()");
- focusControl = new RicohGr2CameraFocusControl(activity, frameDisplayer, indicator);
- captureControl = new RicohGr2CameraCaptureControl(activity, frameDisplayer);
+ focusControl = new RicohGr2CameraFocusControl(frameDisplayer, indicator, this);
+ captureControl = new RicohGr2CameraCaptureControl(frameDisplayer, this);
}
/**
public IDisplayInjector getDisplayInjector() {
return (this);
}
+
+ @Override
+ public void setUsePentaxCommand(boolean usePentaxCommand)
+ {
+ this.usePentaxCommand = usePentaxCommand;
+ try
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean(IPreferencePropertyAccessor.USE_PENTAX_AUTOFOCUS, usePentaxCommand);
+ editor.apply();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ Log.v(TAG, " setUsePentaxCommand : " + usePentaxCommand);
+ }
+
+ @Override
+ public boolean getUsePentaxCommand()
+ {
+ return (usePentaxCommand);
+ }
}
{
private final String TAG = toString();
private final Context context;
+ private final IUsePentaxCommand usePentaxCommand;
private final CameraLiveViewListenerImpl liveViewListener;
- private String liveViewUrl = "http://192.168.0.1/v1/display"; // "http://192.168.0.1/v1/liveview";
+ //private String liveViewUrl = "http://192.168.0.1/v1/display"; // "http://192.168.0.1/v1/liveview";
private float cropScale = 1.0f;
private boolean whileFetching = false;
+ private boolean mirrorMode = false;
private static final int FETCH_ERROR_MAX = 30;
/**
*
*
*/
- RicohGr2LiveViewControl(final Context context)
+ RicohGr2LiveViewControl(final Context context, @NonNull IUsePentaxCommand usePentaxCommand)
{
this.context = context;
+ this.usePentaxCommand = usePentaxCommand;
prepare();
liveViewListener = new CameraLiveViewListenerImpl();
}
*/
private void prepare()
{
- liveViewUrl = "http://192.168.0.1/v1/display";
try
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- boolean mirrorMode = preferences.getBoolean(IPreferencePropertyAccessor.GR2_LIVE_VIEW, true);
- boolean pentaxMode = preferences.getBoolean(IPreferencePropertyAccessor.USE_PENTAX_AUTOFOCUS, false);
- if ((pentaxMode)||(!mirrorMode))
- {
- liveViewUrl = "http://192.168.0.1/v1/liveview";
- }
+ mirrorMode = preferences.getBoolean(IPreferencePropertyAccessor.GR2_LIVE_VIEW, true);
}
catch (Exception e)
{
e.printStackTrace();
}
- Log.v(TAG, "LIVE VIEW URL : " + liveViewUrl);
}
{
try
{
+ String liveViewUrl = ((usePentaxCommand.getUsePentaxCommand())||(!mirrorMode)) ? "http://192.168.0.1/v1/liveview" : "http://192.168.0.1/v1/display";
start(liveViewUrl);
}
catch (Exception e)
import net.osdn.gokigen.a01d.R;
import net.osdn.gokigen.a01d.camera.ICameraConnection;
import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
+import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.IUsePentaxCommand;
import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
private final Activity context;
private final ICameraConnection cameraConnection;
private final ICameraStatusReceiver cameraStatusReceiver;
+ private final IUsePentaxCommand usePentaxCommand;
- RicohGr2CameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection)
+ RicohGr2CameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection, @NonNull IUsePentaxCommand usePentaxCommand)
{
Log.v(TAG, "RicohGr2CameraConnectSequence");
this.context = context;
this.cameraConnection = cameraConnection;
this.cameraStatusReceiver = statusReceiver;
+ this.usePentaxCommand = usePentaxCommand;
}
@Override
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- // 接続時、レンズロックOFF
+ // 接続時、レンズロックOFF + GR2 コマンド有効/無効の確認
{
final String postData = "cmd=acclock off";
String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
Log.v(TAG, grCommandUrl + " " + response0);
- }
- // 接続時、カメラの画面を消す
- if (preferences.getBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false))
- {
- final String postData = "cmd=lcd sleep on";
- String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
- Log.v(TAG, grCommandUrl + " " + response0);
- }
+ // GR2 専用コマンドを受け付けられるかどうかで、Preference を書き換える
+ boolean pentaxCommand = !(response0.length() > 0);
+ usePentaxCommand.setUsePentaxCommand(pentaxCommand);
- // 表示するディスプレイモードを切り替える
- String dispMode = preferences.getString(IPreferencePropertyAccessor.GR2_DISPLAY_MODE, IPreferencePropertyAccessor.GR2_DISPLAY_MODE_DEFAULT_VALUE);
- if (dispMode.contains("1"))
- {
- // Disp. ボタンを 1回 押す
- final String postData = "cmd=bdisp";
- String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
- Log.v(TAG, grCommandUrl + " " + response0);
-
- }
- else if (dispMode.contains("2"))
- {
- // Disp. ボタンを 2回 押す
- final String postData = "cmd=bdisp";
- String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
- String response1 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
- Log.v(TAG, grCommandUrl + " " + response0 + " " + response1);
- }
- else if (dispMode.contains("3"))
- {
- // Disp. ボタンを 3回 押す
- final String postData = "cmd=bdisp";
- String response0 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
- String response1 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
- String response2 = SimpleHttpClient.httpPost(grCommandUrl, postData, TIMEOUT_MS);
- Log.v(TAG, grCommandUrl + " " + response0 + " " + response1 + response2);
+ // 接続時、カメラの画面を消す
+ if ((pentaxCommand)&&(preferences.getBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false)))
+ {
+ final String postData0 = "cmd=lcd sleep on";
+ String response1 = SimpleHttpClient.httpPost(grCommandUrl, postData0, TIMEOUT_MS);
+ Log.v(TAG, grCommandUrl + " " + response1);
+ }
}
onConnectNotify();
}
import net.osdn.gokigen.a01d.R;
import net.osdn.gokigen.a01d.camera.ICameraConnection;
import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
+import net.osdn.gokigen.a01d.camera.ricohgr2.wrapper.IUsePentaxCommand;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
private final String TAG = toString();
private final Activity context;
private final ICameraStatusReceiver statusReceiver;
+ private final IUsePentaxCommand usePentaxCommand;
private final BroadcastReceiver connectionReceiver;
//private final ConnectivityManager connectivityManager;
private final Executor cameraExecutor = Executors.newFixedThreadPool(1);
*
*
*/
- public RicohGr2Connection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver)
+ public RicohGr2Connection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IUsePentaxCommand usePentaxCommand)
{
Log.v(TAG, "RicohGr2Connection()");
this.context = context;
this.statusReceiver = statusReceiver;
+ this.usePentaxCommand = usePentaxCommand;
connectionReceiver = new BroadcastReceiver()
{
@Override
connectionStatus = CameraConnectionStatus.CONNECTING;
try
{
- cameraExecutor.execute(new RicohGr2CameraConnectSequence(context, statusReceiver, this));
+ cameraExecutor.execute(new RicohGr2CameraConnectSequence(context, statusReceiver, this, usePentaxCommand));
}
catch (Exception e)
{