import android.content.Context;
import android.content.SharedPreferences;
-import android.support.v7.preference.PreferenceManager;
import android.util.Log;
+import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;
import net.osdn.gokigen.a01d.camera.IFocusingControl;
import net.osdn.gokigen.a01d.camera.ICameraInformation;
import net.osdn.gokigen.a01d.camera.ICameraConnection;
+import net.osdn.gokigen.a01d.camera.IZoomLensControl;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
+import androidx.annotation.NonNull;
+import androidx.preference.PreferenceManager;
+
/**
*
*
*/
-class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener
+class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener, View.OnKeyListener
{
private final String TAG = toString();
private final Context context;
private final IOlyCameraPropertyProvider propertyProvider;
private final ICameraInformation cameraInformation;
private final ICameraConnection cameraConnection;
- private final IFavoriteSettingDialogKicker dialogKicker;
+ private final IDialogKicker dialogKicker;
+ private final IZoomLensControl zoomLensControl;
- LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IInterfaceProvider interfaceProvider, IFavoriteSettingDialogKicker dialogKicker)
+ LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IInterfaceProvider interfaceProvider, IDialogKicker dialogKicker)
{
this.context = context;
this.statusNotify = imageStatusNotify;
this.changeScene = changeScene;
this.interfaceProvider = interfaceProvider;
- if (interfaceProvider.useOlympusCamera())
+ ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
+ if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
{
- this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
- this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
- this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
- this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
- this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
+ this.focusingControl = interfaceProvider.getRicohGr2Infterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getRicohGr2Infterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
+ this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection();
+ this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
}
- else
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
{
this.focusingControl = interfaceProvider.getSonyInterface().getFocusingControl();
this.captureControl = interfaceProvider.getSonyInterface().getCaptureControl();
this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
this.cameraConnection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
+ this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
+ }
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
+ {
+ this.focusingControl = interfaceProvider.getFujiXInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getFujiXInterface().getCaptureControl();
+ this.cameraInformation = interfaceProvider.getFujiXInterface().getCameraInformation();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
+ this.cameraConnection = interfaceProvider.getFujiXInterface().getFujiXCameraConnection();
+ this.zoomLensControl = interfaceProvider.getFujiXInterface().getZoomLensControl();
+ }
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
+ {
+ this.focusingControl = interfaceProvider.getPanasonicInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getPanasonicInterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
+ this.cameraInformation = interfaceProvider.getPanasonicInterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getPanasonicInterface().getPanasonicCameraConnection();
+ this.zoomLensControl = interfaceProvider.getPanasonicInterface().getZoomLensControl();
+ }
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
+ {
+ this.focusingControl = interfaceProvider.getOlympusPenInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getOlympusPenInterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusPenInterface().getCameraPropertyProvider();
+ this.cameraInformation = interfaceProvider.getOlympusPenInterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getOlympusPenInterface().getOlyCameraConnection();
+ this.zoomLensControl = interfaceProvider.getOlympusPenInterface().getZoomLensControl();
+ }
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
+ {
+ this.focusingControl = interfaceProvider.getThetaInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getThetaInterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
+ this.cameraInformation = interfaceProvider.getThetaInterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getThetaInterface().getCameraConnection();
+ this.zoomLensControl = interfaceProvider.getThetaInterface().getZoomLensControl();
+ }
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
+ {
+ this.focusingControl = interfaceProvider.getCanonInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getCanonInterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
+ this.cameraInformation = interfaceProvider.getCanonInterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getCanonInterface().getCameraConnection();
+ this.zoomLensControl = interfaceProvider.getCanonInterface().getZoomLensControl();
+ }
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
+ {
+ this.focusingControl = interfaceProvider.getNikonInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getNikonInterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
+ this.cameraInformation = interfaceProvider.getNikonInterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getNikonInterface().getCameraConnection();
+ this.zoomLensControl = interfaceProvider.getNikonInterface().getZoomLensControl();
+ }
+ else if (connectionMethod == ICameraConnection.CameraConnectionMethod.KODAK)
+ {
+ this.focusingControl = interfaceProvider.getKodakInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getKodakInterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
+ this.cameraInformation = interfaceProvider.getKodakInterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getKodakInterface().getCameraConnection();
+ this.zoomLensControl = interfaceProvider.getKodakInterface().getZoomLensControl();
}
+ else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
+ {
+ this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
+ this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
+ this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
+ this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
+ this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
+ this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
+ }
+
this.dialogKicker = dialogKicker;
}
showFavoriteDialog();
break;
+ case R.id.btn_zoomin:
+ // ズームインのボタンが押された
+ actionZoomin();
+ break;
+ case R.id.btn_zoomout:
+ // ズームアウトのボタンが押された
+ actionZoomout();
+ break;
+
+ case R.id.focus_indicator:
+ // フォーカスインジケータをクリックした
+ actionFocusButton();
+ break;
+
default:
Log.v(TAG, "onClick() : " + id);
break;
}
}
+ private void actionZoomin()
+ {
+ Log.v(TAG, "actionZoomin()");
+ try
+ {
+ // ズーム可能な場合、ズームインする
+ if (zoomLensControl.canZoom())
+ {
+ zoomLensControl.driveZoomLens(true);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void actionZoomout()
+ {
+ Log.v(TAG, "actionZoomout()");
+ try
+ {
+ // ズーム可能な場合、ズームアウトする
+ if (zoomLensControl.canZoom())
+ {
+ zoomLensControl.driveZoomLens(false);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+
+
/**
* シャッターボタンが押された時の処理
*
Log.v(TAG, "pushedShutterButton()");
try
{
- // カメラで撮影する
- captureControl.doCapture(0);
-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+
+ if (!preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW, false))
+ {
+ // カメラで撮影する
+ captureControl.doCapture(0);
+ }
if (preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true))
{
- // ã\83©ã\82¤ã\83\96ã\83\93ã\83¥ã\83¼ç\94»å\83\8fã\82\82保管する
+ // ã\83©ã\82¤ã\83\96ã\83\93ã\83¥ã\83¼ç\94»å\83\8fã\82\92保管する
statusNotify.takePicture();
}
}
}
/**
+ * フォーカスボタンが押されたとき...
+ *
+ */
+ private void actionFocusButton()
+ {
+ try
+ {
+ // シャッターを半押しする
+ if (focusingControl != null)
+ {
+ boolean isHalfPress = !statusViewDrawer.isFocusLocked();
+ focusingControl.halfPressShutter(isHalfPress);
+ Log.v(TAG, " actionFocusButton() : isHalfPress " + isHalfPress);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
* お気に入り設定ダイアログの表示
*
*/
Log.v(TAG, "showFavoriteDialog()");
try
{
- if (!interfaceProvider.useOlympusCamera())
+ if (interfaceProvider.getCammeraConnectionMethod() == ICameraConnection.CameraConnectionMethod.FUJI_X)
+ {
+ // FUJI X Seriesの場合は、カメラ状態を表示するダイアログを表示する
+ if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
+ {
+ dialogKicker.showCameraStatusDialog();
+ }
+ return;
+ }
+ else if (interfaceProvider.getCammeraConnectionMethod() != ICameraConnection.CameraConnectionMethod.OPC)
{
// OPCカメラでない場合には、「OPCカメラのみ有効です」表示をして画面遷移させない
Toast.makeText(context, context.getText(R.string.only_opc_feature), Toast.LENGTH_SHORT).show();
return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent)));
}
+ /**
+ * ボタンを押したときの対応
+ *
+ */
+ @Override
+ public boolean onKey(View view, int keyCode, @NonNull KeyEvent keyEvent)
+ {
+ Log.v(TAG, "onKey() : " + keyCode);
+ try
+ {
+ if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN)&&
+ ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)||(keyCode == KeyEvent.KEYCODE_CAMERA)))
+ {
+ pushedShutterButton();
+ return (true);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return (false);
+ }
}