private final RicohGr2SingleShotControl singleShotControl;
private final RicohGr2MovieShotControl movieShotControl;
private final ICameraStatus cameraStatus;
- private final boolean useGrCommand;
private final boolean captureAfterAf;
+ private boolean useGR2command = false;
+
/**
*
*
*/
- public RicohGr2CameraCaptureControl(boolean useGrCommand, boolean captureAfterAf, @NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull ICameraStatus cameraStatus)
+ public RicohGr2CameraCaptureControl(boolean captureAfterAf, @NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull ICameraStatus cameraStatus)
{
- this.useGrCommand = useGrCommand;
this.captureAfterAf = captureAfterAf;
this.cameraStatus = cameraStatus;
singleShotControl = new RicohGr2SingleShotControl(frameDisplayer);
movieShotControl = new RicohGr2MovieShotControl(frameDisplayer);
}
+ public void setUseGR2Command(boolean useGR2command)
+ {
+ this.useGR2command = useGR2command;
+ }
+
/**
*
*
}
else
{
- singleShotControl.singleShot(useGrCommand, captureAfterAf);
+ singleShotControl.singleShot(useGR2command, captureAfterAf);
}
}
catch (Exception e)
*
*
*/
- public RicohGr2CameraFocusControl(boolean useGrCommand, @NonNull final IAutoFocusFrameDisplay frameDisplayer, @NonNull final IIndicatorControl indicator)
+ public RicohGr2CameraFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, @NonNull final IIndicatorControl indicator)
{
this.frameDisplay = frameDisplayer;
- this.afControl = new RicohGr2AutoFocusControl(useGrCommand, frameDisplayer, indicator);
+ this.afControl = new RicohGr2AutoFocusControl(frameDisplayer, indicator);
+ }
+
+ public void setUseGR2Command(boolean useGR2command)
+ {
+ afControl.setUseGR2Command(useGR2command);
}
/**
private static final String TAG = RicohGr2AutoFocusControl.class.getSimpleName();
private final IIndicatorControl indicator;
private final IAutoFocusFrameDisplay frameDisplayer;
- private final boolean useGrCommand;
private String autoFocusUrl = "http://192.168.0.1/v1/lens/focus";
private String lockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/lock";
private String unlockAutoFocusUrl = "http://192.168.0.1/v1/lens/focus/unlock";
private int timeoutMs = 6000;
+ private boolean useGR2command = false;
/**
*
*
*/
- public RicohGr2AutoFocusControl(boolean useGrCommand, @NonNull final IAutoFocusFrameDisplay frameDisplayer, final IIndicatorControl indicator)
+ public RicohGr2AutoFocusControl(@NonNull final IAutoFocusFrameDisplay frameDisplayer, final IIndicatorControl indicator)
{
this.frameDisplayer = frameDisplayer;
this.indicator = indicator;
- this.useGrCommand = useGrCommand;
+ }
+
+ public void setUseGR2Command(boolean useGR2command)
+ {
+ this.useGR2command = useGR2command;
}
/**
//int posX = (int) (Math.round(point.x * 100.0));
//int posY = (int) (Math.round(point.y * 100.0));
- String focusUrl = (useGrCommand) ? lockAutoFocusUrl : autoFocusUrl;
+ String focusUrl = (useGR2command) ? lockAutoFocusUrl : autoFocusUrl;
String postData = "pos=" + ( (int) (Math.round(point.x * 100.0))) + "," + ((int) (Math.round(point.y * 100.0)));
Log.v(TAG, "AF (" + postData + ")");
String result = SimpleHttpClient.httpPost(focusUrl, postData, timeoutMs);
package net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper;
-import android.app.Activity;
import android.content.SharedPreferences;
import android.util.Log;
import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraFocusControl;
import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2CameraZoomLensControl;
import net.osdn.gokigen.gr2control.camera.ricohgr2.operation.RicohGr2HardwareStatus;
+import net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper.connection.IUseGR2CommandNotify;
import net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper.connection.RicohGr2Connection;
import net.osdn.gokigen.gr2control.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.gr2control.liveview.IIndicatorControl;
import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
import androidx.annotation.NonNull;
+import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceManager;
/**
*
*
*/
-public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector
+public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, IDisplayInjector, IUseGR2CommandNotify
{
private final String TAG = toString();
//private final Activity activity;
private final RicohGr2PlaybackControl playbackControl;
private final RicohGr2HardwareStatus hardwareStatus;
private final RicohGr2RunMode runMode;
- private final boolean useGrCommand;
+ //private final boolean useGrCommand;
private final boolean pentaxCaptureAfterAf;
private RicohGr2LiveViewControl liveViewControl;
private RicohGr2CameraZoomLensControl zoomControl;
private RicohGr2CameraFocusControl focusControl;
+ private boolean useGR2Command = false;
+ private boolean useGR2CommandUpdated = false;
+
/**
*
*
*/
- public RicohGr2InterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider)
+ public RicohGr2InterfaceProvider(@NonNull FragmentActivity context, @NonNull ICameraStatusReceiver provider)
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- useGrCommand = preferences.getBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
pentaxCaptureAfterAf = preferences.getBoolean(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF, false);
int communicationTimeoutMs = 5000; // デフォルトは 5000ms とする
try
}
//this.activity = context;
//this.provider = provider;
- gr2Connection = new RicohGr2Connection(context, provider);
- liveViewControl = new RicohGr2LiveViewControl(useGrCommand);
+ gr2Connection = new RicohGr2Connection(context, provider, this);
+ liveViewControl = new RicohGr2LiveViewControl();
zoomControl = new RicohGr2CameraZoomLensControl();
buttonControl = new RicohGr2CameraButtonControl();
- statusChecker = new RicohGr2StatusChecker(500, useGrCommand);
+ statusChecker = new RicohGr2StatusChecker(500);
playbackControl = new RicohGr2PlaybackControl(communicationTimeoutMs);
hardwareStatus = new RicohGr2HardwareStatus();
runMode = new RicohGr2RunMode();
public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify)
{
Log.v(TAG, "injectDisplay()");
- focusControl = new RicohGr2CameraFocusControl(useGrCommand, frameDisplayer, indicator);
- captureControl = new RicohGr2CameraCaptureControl(useGrCommand, pentaxCaptureAfterAf, frameDisplayer, statusChecker);
+ focusControl = new RicohGr2CameraFocusControl(frameDisplayer, indicator);
+ captureControl = new RicohGr2CameraCaptureControl(pentaxCaptureAfterAf, frameDisplayer, statusChecker);
+ if (useGR2CommandUpdated)
+ {
+ captureControl.setUseGR2Command(useGR2Command);
+ focusControl.setUseGR2Command(useGR2Command);
+ }
}
@Override
}
@Override
- public IDisplayInjector getDisplayInjector() {
+ public IDisplayInjector getDisplayInjector()
+ {
return (this);
}
}
@Override
- public ICameraStatusWatcher getCameraStatusWatcher() {
+ public ICameraStatusWatcher getCameraStatusWatcher()
+ {
return (statusChecker);
}
{
return (runMode);
}
+
+ @Override
+ public void setUseGR2Command(boolean useGR2Command)
+ {
+ try
+ {
+ this.useGR2Command = useGR2Command;
+ this.useGR2CommandUpdated = true;
+ statusChecker.setUseGR2Command(useGR2Command);
+ liveViewControl.setUseGR2Command(useGR2Command);
+ if (captureControl != null)
+ {
+ captureControl.setUseGR2Command(useGR2Command);
+ }
+ if (focusControl != null)
+ {
+ focusControl.setUseGR2Command(useGR2Command);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
}
{
private final String TAG = toString();
private final CameraLiveViewListenerImpl liveViewListener;
- private final boolean useGrCommand;
private String cameraDisplayUrl = "http://192.168.0.1/v1/display"; // カメラの画面をコピーする場合...
private String liveViewUrl = "http://192.168.0.1/v1/liveview"; // 何も表示しない(ライブビューモード)の場合...
private float cropScale = 1.0f;
private boolean whileFetching = false;
private static final int FETCH_ERROR_MAX = 30;
+ private boolean useGR2command = false;
/**
*
*
*/
- RicohGr2LiveViewControl(boolean useGrControl)
+ RicohGr2LiveViewControl()
{
- this.useGrCommand = useGrControl;
liveViewListener = new CameraLiveViewListenerImpl();
}
}
*/
+ public void setUseGR2Command(boolean useGR2command)
+ {
+ this.useGR2command = useGR2command;
+ }
+
@Override
public void changeLiveViewSize(String size)
{
@Override
public void startLiveView(final boolean useCameraScreen)
{
- final boolean isCameraScreen = useGrCommand && useCameraScreen;
+ final boolean isCameraScreen = useGR2command && useCameraScreen;
Log.v(TAG, "startLiveView()");
try
{
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(int sleepMs, boolean useGrCommand)
+ RicohGr2StatusChecker(int sleepMs)
{
- this.useGrCommand = useGrCommand;
this.sleepMs = sleepMs;
}
+ public void setUseGR2Command(boolean useGR2command)
+ {
+ this.useGR2command = useGR2command;
+ }
+
/**
*
*
{
String response;
String postData = key + "=" + value;
- if ((useGrCommand)&&(key.equals("exposureMode")))
+ if ((useGR2command)&&(key.equals("exposureMode")))
{
// 撮影モードを変更するときは、GR専用コマンドを送ることにする。
postData = "cmd=" + decideButtonCode(value);
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);
--- /dev/null
+package net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper.connection;
+
+public interface IUseGR2CommandNotify
+{
+ void setUseGR2Command(boolean useGR2Command);
+}
private final Activity context;
private final ICameraConnection cameraConnection;
private final ICameraStatusReceiver cameraStatusReceiver;
+ private final IUseGR2CommandNotify gr2CommandNotify;
- RicohGr2CameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection)
+ RicohGr2CameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection, @NonNull IUseGR2CommandNotify gr2CommandNotify)
{
Log.v(TAG, "RicohGr2CameraConnectSequence");
this.context = context;
this.cameraConnection = cameraConnection;
this.cameraStatusReceiver = statusReceiver;
+ this.gr2CommandNotify = gr2CommandNotify;
}
@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 enableGr2Command = (response0.length() > 0);
+ try
+ {
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, enableGr2Command);
+ editor.apply();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ gr2CommandNotify.setUseGR2Command(enableGr2Command);
+
+ // 接続時、カメラの画面を消す
+ if ((enableGr2Command)&&(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();
}
private final Activity context;
private final ICameraStatusReceiver statusReceiver;
private final BroadcastReceiver connectionReceiver;
+ private final IUseGR2CommandNotify gr2CommandNotify;
//private final ConnectivityManager connectivityManager;
private final Executor cameraExecutor = Executors.newFixedThreadPool(1);
//private final Handler networkConnectionTimeoutHandler;
*
*
*/
- public RicohGr2Connection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver)
+ public RicohGr2Connection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IUseGR2CommandNotify gr2CommandNotify)
{
Log.v(TAG, "RicohGr2Connection()");
this.context = context;
this.statusReceiver = statusReceiver;
+ this.gr2CommandNotify = gr2CommandNotify;
connectionReceiver = new BroadcastReceiver()
{
@Override
WifiInfo info = wifiManager.getConnectionInfo();
if (wifiManager.isWifiEnabled() && info != null)
{
- if (info.getNetworkId() != -1)
+ if (info.getNetworkId() == -1)
{
Log.v(TAG, "Network ID is -1, there is no currently connected network.");
}
+ else
+ {
+ Log.v(TAG, "Network ID is " + info.getNetworkId());
+ }
// 自動接続が指示されていた場合は、カメラとの接続処理を行う
connectToCamera();
- } else {
+ }
+ else
+ {
if (info == null)
{
Log.v(TAG, "NETWORK INFO IS NULL.");
- } else {
+ }
+ else
+ {
Log.v(TAG, "isWifiEnabled : " + wifiManager.isWifiEnabled() + " NetworkId : " + info.getNetworkId());
}
}
connectionStatus = CameraConnectionStatus.CONNECTING;
try
{
- cameraExecutor.execute(new RicohGr2CameraConnectSequence(context, statusReceiver, this));
+ cameraExecutor.execute(new RicohGr2CameraConnectSequence(context, statusReceiver, this, gr2CommandNotify));
}
catch (Exception e)
{
import net.osdn.gokigen.gr2control.playback.detail.ImageContentInfoEx;
import net.osdn.gokigen.gr2control.playback.detail.ImagePagerViewFragment;
import net.osdn.gokigen.gr2control.playback.detail.MyContentDownloader;
+import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
if (preferences != null)
{
- isShowActionBar = preferences.getBoolean("use_playback_menu", false);
+ isShowActionBar = preferences.getBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, true);
}
if (isShowActionBar)
{
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 RAW_SUFFIX_4 = ".RAF";
private static final String MOVIE_SUFFIX = ".MOV";
private static final String JPEG_SUFFIX = ".JPG";
private ProgressDialog downloadDialog = null;
mimeType = "image/x-pentax-pef";
isSmallSize = false;
}
+ else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_4))
+ {
+ mimeType = "image/x-fuji-raf";
+ isSmallSize = false;
+ }
else if (targetFileName.toUpperCase().contains(MOVIE_SUFFIX))
{
mimeType = "video/mp4";
outputStream.close();
outputStream = null;
}
- if ((!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_1))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_2))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_3)))
+ //if ((!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_1))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_2))&&(!targetFileName.toUpperCase().endsWith(RAW_SUFFIX_3)))
{
// ギャラリーに受信したファイルを登録する
long now = System.currentTimeMillis();
editor.putBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
}
if (!items.containsKey(IPreferencePropertyAccessor.USE_PLAYBACK_MENU)) {
- editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, false);
+ editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, true);
}
if (!items.containsKey(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW)) {
editor.putBoolean(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, true);
editor.putBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
}
if (!items.containsKey(IPreferencePropertyAccessor.USE_PLAYBACK_MENU)) {
- editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, false);
+ editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, true);
}
if (!items.containsKey(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW)) {
editor.putBoolean(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, true);
editor.putBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
}
if (!items.containsKey(IPreferencePropertyAccessor.USE_PLAYBACK_MENU)) {
- editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, false);
+ editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, true);
}
if (!items.containsKey(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW)) {
editor.putBoolean(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, true);