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.olympus.IOlympusInterfaceProvider;
14 import net.osdn.gokigen.a01d.camera.olympus.operation.ICaptureControl;
15 import net.osdn.gokigen.a01d.camera.olympus.operation.IFocusingControl;
16 import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraInformation;
17 import net.osdn.gokigen.a01d.camera.ICameraConnection;
18 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
19 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
20 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
26 class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener
28 private final String TAG = toString();
29 private final Context context;
30 private final ILiveImageStatusNotify statusNotify;
31 private final IStatusViewDrawer statusViewDrawer;
32 private final IChangeScene changeScene;
33 private final IFocusingControl focusingControl;
34 private final ICaptureControl captureControl;
35 private final IOlyCameraPropertyProvider propertyProvider;
36 private final ICameraInformation cameraInformation;
37 private final ICameraConnection cameraConnection;
38 private final IFavoriteSettingDialogKicker dialogKicker;
40 LiveViewClickTouchListener(Context context, ILiveImageStatusNotify imageStatusNotify, IStatusViewDrawer statusView, IChangeScene changeScene, IOlympusInterfaceProvider interfaceProvider, IFavoriteSettingDialogKicker dialogKicker)
42 this.context = context;
43 this.statusNotify = imageStatusNotify;
44 this.statusViewDrawer = statusView;
45 this.changeScene = changeScene;
46 this.focusingControl = interfaceProvider.getFocusingControl();
47 this.captureControl = interfaceProvider.getCaptureControl();
48 this.propertyProvider = interfaceProvider.getCameraPropertyProvider();
49 this.cameraInformation = interfaceProvider.getCameraInformation();
50 this.cameraConnection = interfaceProvider.getOlyCameraConnection();
51 this.dialogKicker = dialogKicker;
59 public void onClick(View view)
61 int id = view.getId();
62 //Log.v(TAG, "onClick() : " + id);
67 case R.id.show_hide_grid_button:
69 statusNotify.toggleShowGridFrame();
70 statusViewDrawer.updateGridIcon();
73 case R.id.show_preference_button:
75 changeScene.changeSceneToConfiguration();
78 case R.id.camera_property_settings_button:
80 changeScene.changeSceneToCameraPropertyList();
83 case R.id.connect_disconnect_button:
85 changeScene.changeCameraConnection();
88 case R.id.shutter_button:
90 pushedShutterButton();
93 case R.id.focusing_button:
94 // AF と MFの切り替えボタンが押された
98 case R.id.live_view_scale_button:
100 statusViewDrawer.updateLiveViewScale(true);
103 case R.id.show_favorite_settings_button:
104 // お気に入り設定のダイアログを表示する
105 showFavoriteDialog();
109 Log.v(TAG, "onClick() : " + id);
124 private void pushedShutterButton()
126 Log.v(TAG, "pushedShutterButton()");
130 captureControl.doCapture(0);
132 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
133 if (preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true))
136 statusNotify.takePicture();
149 private void changeFocusingMode()
151 if ((propertyProvider == null)||(cameraInformation == null))
153 Log.v(TAG, "changeFocusingMode() : OBJECT IS NULL.");
158 boolean isManualFocus = cameraInformation.isManualFocus();
161 // AF ⇒ MF時には、オートフォーカスのロックを解除する
162 focusingControl.unlockAutoFocus();
164 String value = (isManualFocus) ? IOlyCameraProperty.STILL_AF : IOlyCameraProperty.STILL_MF;
165 propertyProvider.setCameraPropertyValue(IOlyCameraProperty.FOCUS_STILL, value);
177 private void showFavoriteDialog()
179 Log.v(TAG, "showFavoriteDialog()");
182 if (!useOlympusCamera())
184 // OPCカメラでない場合には、「OPCカメラのみ有効です」表示をして画面遷移させない
185 Toast.makeText(context, context.getText(R.string.only_opc_feature), Toast.LENGTH_SHORT).show();
189 if (cameraConnection.getConnectionStatus() == ICameraConnection.CameraConnectionStatus.CONNECTED)
191 // お気に入り設定のダイアログを表示する
192 dialogKicker.showFavoriteSettingDialog();
206 public boolean onTouch(View view, MotionEvent motionEvent)
208 int id = view.getId();
209 //Log.v(TAG, "onTouch() : " + id + " (" + motionEvent.getX() + "," + motionEvent.getY() + ")");
210 return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent)));
216 * @return true : OPCカメラ / false : OPCカメラではない
218 private boolean useOlympusCamera()
223 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
224 String connectionMethod = preferences.getString(IPreferencePropertyAccessor.CONNECTION_METHOD, "OPC");
225 ret = connectionMethod.contains("OPC");