1 package net.osdn.gokigen.a01d.liveview;
3 import android.content.Context;
4 import android.content.SharedPreferences;
5 import android.support.v7.preference.PreferenceManager;
6 import android.util.Log;
7 import android.view.MotionEvent;
8 import android.view.View;
9 import android.widget.Toast;
11 import net.osdn.gokigen.a01d.IChangeScene;
12 import net.osdn.gokigen.a01d.R;
13 import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
14 import net.osdn.gokigen.a01d.camera.ICaptureControl;
15 import net.osdn.gokigen.a01d.camera.IFocusingControl;
16 import net.osdn.gokigen.a01d.camera.ICameraInformation;
17 import net.osdn.gokigen.a01d.camera.ICameraConnection;
18 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
19 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
20 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
21 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
27 class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener
29 private final String TAG = toString();
30 private final Context context;
31 private final ILiveImageStatusNotify statusNotify;
32 private final IStatusViewDrawer statusViewDrawer;
33 private final IChangeScene changeScene;
34 private final IInterfaceProvider interfaceProvider;
35 private final IFocusingControl focusingControl;
36 private final ICaptureControl captureControl;
37 private final IOlyCameraPropertyProvider propertyProvider;
38 private final ICameraInformation cameraInformation;
39 private final ICameraConnection cameraConnection;
40 private final IFavoriteSettingDialogKicker dialogKicker;
41 private final IZoomLensControl zoomLensControl;
43 LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IInterfaceProvider interfaceProvider, IFavoriteSettingDialogKicker dialogKicker)
45 this.context = context;
46 this.statusNotify = imageStatusNotify;
47 this.statusViewDrawer = statusView;
48 this.changeScene = changeScene;
49 this.interfaceProvider = interfaceProvider;
51 ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
52 if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
54 this.focusingControl = interfaceProvider.getRicohGr2Infterface().getFocusingControl();
55 this.captureControl = interfaceProvider.getRicohGr2Infterface().getCaptureControl();
56 this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
57 this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
58 this.cameraConnection = interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection();
59 this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
61 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
63 this.focusingControl = interfaceProvider.getSonyInterface().getFocusingControl();
64 this.captureControl = interfaceProvider.getSonyInterface().getCaptureControl();
65 this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
66 this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
67 this.cameraConnection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
68 this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
70 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
72 this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
73 this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
74 this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
75 this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
76 this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
77 this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
80 this.dialogKicker = dialogKicker;
88 public void onClick(View view)
90 int id = view.getId();
91 //Log.v(TAG, "onClick() : " + id);
96 case R.id.show_hide_grid_button:
98 statusNotify.toggleShowGridFrame();
99 statusViewDrawer.updateGridIcon();
102 case R.id.show_preference_button:
104 changeScene.changeSceneToConfiguration();
107 case R.id.camera_property_settings_button:
109 changeScene.changeSceneToCameraPropertyList();
112 case R.id.connect_disconnect_button:
113 // カメラと接続・切断のボタンが押された
114 changeScene.changeCameraConnection();
117 case R.id.shutter_button:
118 // シャッターボタンが押された (撮影)
119 pushedShutterButton();
122 case R.id.focusing_button:
123 // AF と MFの切り替えボタンが押された
124 changeFocusingMode();
127 case R.id.live_view_scale_button:
129 statusViewDrawer.updateLiveViewScale(true);
132 case R.id.show_favorite_settings_button:
133 // お気に入り設定のダイアログを表示する
134 showFavoriteDialog();
137 case R.id.btn_zoomin:
141 case R.id.btn_zoomout:
147 Log.v(TAG, "onClick() : " + id);
157 private void actionZoomin()
159 Log.v(TAG, "actionZoomin()");
163 if (zoomLensControl.canZoom())
165 zoomLensControl.driveZoomLens(true);
174 private void actionZoomout()
176 Log.v(TAG, "actionZoomout()");
180 if (zoomLensControl.canZoom())
182 zoomLensControl.driveZoomLens(false);
199 private void pushedShutterButton()
201 Log.v(TAG, "pushedShutterButton()");
205 captureControl.doCapture(0);
207 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
208 if (preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true))
211 statusNotify.takePicture();
224 private void changeFocusingMode()
226 if ((propertyProvider == null)||(cameraInformation == null))
228 Log.v(TAG, "changeFocusingMode() : OBJECT IS NULL.");
233 boolean isManualFocus = cameraInformation.isManualFocus();
236 // AF ⇒ MF時には、オートフォーカスのロックを解除する
237 focusingControl.unlockAutoFocus();
239 String value = (isManualFocus) ? IOlyCameraProperty.STILL_AF : IOlyCameraProperty.STILL_MF;
240 propertyProvider.setCameraPropertyValue(IOlyCameraProperty.FOCUS_STILL, value);
252 private void showFavoriteDialog()
254 Log.v(TAG, "showFavoriteDialog()");
257 if (interfaceProvider.getCammeraConnectionMethod() != ICameraConnection.CameraConnectionMethod.OPC)
259 // OPCカメラでない場合には、「OPCカメラのみ有効です」表示をして画面遷移させない
260 Toast.makeText(context, context.getText(R.string.only_opc_feature), Toast.LENGTH_SHORT).show();
264 if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
266 // お気に入り設定のダイアログを表示する
267 dialogKicker.showFavoriteSettingDialog();
281 public boolean onTouch(View view, MotionEvent motionEvent)
283 int id = view.getId();
284 if (focusingControl == null)
286 Log.v(TAG, "focusingControl is NULL.");
289 //Log.v(TAG, "onTouch() : " + id + " (" + motionEvent.getX() + "," + motionEvent.getY() + ")");
290 return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent)));