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 if (interfaceProvider.useOlympusCamera())
53 this.focusingControl = interfaceProvider.getOlympusInterface().getFocusingControl();
54 this.captureControl = interfaceProvider.getOlympusInterface().getCaptureControl();
55 this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
56 this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
57 this.cameraConnection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
58 this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
62 this.focusingControl = interfaceProvider.getSonyInterface().getFocusingControl();
63 this.captureControl = interfaceProvider.getSonyInterface().getCaptureControl();
64 this.propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider(); // 要変更
65 this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
66 this.cameraConnection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
67 this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
69 this.dialogKicker = dialogKicker;
77 public void onClick(View view)
79 int id = view.getId();
80 //Log.v(TAG, "onClick() : " + id);
85 case R.id.show_hide_grid_button:
87 statusNotify.toggleShowGridFrame();
88 statusViewDrawer.updateGridIcon();
91 case R.id.show_preference_button:
93 changeScene.changeSceneToConfiguration();
96 case R.id.camera_property_settings_button:
98 changeScene.changeSceneToCameraPropertyList();
101 case R.id.connect_disconnect_button:
102 // カメラと接続・切断のボタンが押された
103 changeScene.changeCameraConnection();
106 case R.id.shutter_button:
107 // シャッターボタンが押された (撮影)
108 pushedShutterButton();
111 case R.id.focusing_button:
112 // AF と MFの切り替えボタンが押された
113 changeFocusingMode();
116 case R.id.live_view_scale_button:
118 statusViewDrawer.updateLiveViewScale(true);
121 case R.id.show_favorite_settings_button:
122 // お気に入り設定のダイアログを表示する
123 showFavoriteDialog();
126 case R.id.btn_zoomin:
130 case R.id.btn_zoomout:
136 Log.v(TAG, "onClick() : " + id);
146 private void actionZoomin()
148 Log.v(TAG, "actionZoomin()");
152 if (zoomLensControl.canZoom())
154 zoomLensControl.driveZoomLens(true);
163 private void actionZoomout()
165 Log.v(TAG, "actionZoomout()");
169 if (zoomLensControl.canZoom())
171 zoomLensControl.driveZoomLens(false);
188 private void pushedShutterButton()
190 Log.v(TAG, "pushedShutterButton()");
194 captureControl.doCapture(0);
196 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
197 if (preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true))
200 statusNotify.takePicture();
213 private void changeFocusingMode()
215 if ((propertyProvider == null)||(cameraInformation == null))
217 Log.v(TAG, "changeFocusingMode() : OBJECT IS NULL.");
222 boolean isManualFocus = cameraInformation.isManualFocus();
225 // AF ⇒ MF時には、オートフォーカスのロックを解除する
226 focusingControl.unlockAutoFocus();
228 String value = (isManualFocus) ? IOlyCameraProperty.STILL_AF : IOlyCameraProperty.STILL_MF;
229 propertyProvider.setCameraPropertyValue(IOlyCameraProperty.FOCUS_STILL, value);
241 private void showFavoriteDialog()
243 Log.v(TAG, "showFavoriteDialog()");
246 if (!interfaceProvider.useOlympusCamera())
248 // OPCカメラでない場合には、「OPCカメラのみ有効です」表示をして画面遷移させない
249 Toast.makeText(context, context.getText(R.string.only_opc_feature), Toast.LENGTH_SHORT).show();
253 if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
255 // お気に入り設定のダイアログを表示する
256 dialogKicker.showFavoriteSettingDialog();
270 public boolean onTouch(View view, MotionEvent motionEvent)
272 int id = view.getId();
273 if (focusingControl == null)
275 Log.v(TAG, "focusingControl is NULL.");
278 //Log.v(TAG, "onTouch() : " + id + " (" + motionEvent.getX() + "," + motionEvent.getY() + ")");
279 return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent)));