1 package net.osdn.gokigen.a01d.liveview;
3 import android.app.Activity;
4 import android.content.Context;
5 import android.content.SharedPreferences;
6 import android.graphics.Color;
7 import android.graphics.drawable.Drawable;
8 import android.os.Bundle;
9 import android.util.Log;
10 import android.view.KeyEvent;
11 import android.view.LayoutInflater;
12 import android.view.View;
13 import android.view.ViewGroup;
14 import android.widget.Button;
15 import android.widget.ImageButton;
16 import android.widget.ImageView;
17 import android.widget.SeekBar;
18 import android.widget.TextView;
20 import net.osdn.gokigen.a01d.IChangeScene;
21 import net.osdn.gokigen.a01d.R;
22 import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
23 import net.osdn.gokigen.a01d.camera.IDisplayInjector;
24 import net.osdn.gokigen.a01d.camera.fujix.cameraproperty.FujiXCameraStatusDialog;
25 import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveCameraProperties;
26 import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveMyCameraPropertyDialog;
27 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
28 import net.osdn.gokigen.a01d.camera.ICameraInformation;
29 import net.osdn.gokigen.a01d.camera.IFocusingModeNotify;
30 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
31 import net.osdn.gokigen.a01d.camera.ICameraConnection;
32 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
33 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
34 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
35 import net.osdn.gokigen.a01d.liveview.liveviewlistener.OlympusCameraLiveViewListenerImpl;
36 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
38 import androidx.annotation.NonNull;
39 import androidx.core.content.res.ResourcesCompat;
40 import androidx.core.graphics.drawable.DrawableCompat;
41 import androidx.fragment.app.Fragment;
42 import androidx.fragment.app.FragmentManager;
43 import androidx.preference.PreferenceManager;
49 public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IDialogKicker, ICameraStatusUpdateNotify, IFocusLockIndicator {
50 private final String TAG = this.toString();
51 private static final int COMMAND_MY_PROPERTY = 0x00000100;
52 public static final int SEEKBAR_MAX_SCALE = 1000;
54 private ILiveViewControl liveViewControl = null;
55 private IZoomLensControl zoomLensControl = null;
56 private IInterfaceProvider interfaceProvider = null;
57 private IDisplayInjector interfaceInjector = null;
58 private OlympusCameraLiveViewListenerImpl liveViewListener = null;
59 private IChangeScene changeScene = null;
60 private ICameraInformation cameraInformation = null;
61 private LiveViewClickTouchListener onClickTouchListener = null;
63 private TextView statusArea = null;
64 private TextView focalLengthArea = null;
65 private CameraLiveImageView imageView = null;
67 private ImageView manualFocus = null;
68 private ImageView focusIndicator = null;
69 private ImageButton showGrid = null;
70 private ImageButton connectStatus = null;
71 private Button changeLiveViewScale = null;
73 private boolean imageViewCreated = false;
74 private View myView = null;
75 private String messageValue = "";
76 private boolean focusLocked = false;
78 private ICameraConnection.CameraConnectionStatus currentConnectionStatus = ICameraConnection.CameraConnectionStatus.UNKNOWN;
80 public static LiveViewFragment newInstance(IChangeScene sceneSelector, @NonNull IInterfaceProvider provider) {
81 LiveViewFragment instance = new LiveViewFragment();
82 instance.prepare(sceneSelector, provider);
84 // パラメータはBundleにまとめておく
85 Bundle arguments = new Bundle();
86 //arguments.putString("title", title);
87 //arguments.putString("message", message);
88 instance.setArguments(arguments);
97 public void onCreate(Bundle savedInstanceState) {
98 super.onCreate(savedInstanceState);
99 Log.v(TAG, "onCreate()");
100 if (liveViewListener == null) {
101 liveViewListener = new OlympusCameraLiveViewListenerImpl();
109 public void onAttach(@NonNull Context context) {
110 super.onAttach(context);
111 Log.v(TAG, "onAttach()");
118 public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
119 super.onCreateView(inflater, container, savedInstanceState);
121 Log.v(TAG, "onCreateView()");
122 if ((imageViewCreated) && (myView != null)) {
124 Log.v(TAG, "onCreateView() : called again, so do nothing... : " + myView);
128 View view = inflater.inflate(R.layout.fragment_live_view, container, false);
130 imageViewCreated = true;
132 imageView = view.findViewById(R.id.cameraLiveImageView);
133 if (interfaceInjector != null) {
134 interfaceInjector.injectDisplay(imageView, imageView, this);
136 Log.v(TAG, "interfaceInjector is NULL...");
138 if (onClickTouchListener == null) {
139 onClickTouchListener = new LiveViewClickTouchListener(this.getContext(), imageView, this, changeScene, interfaceProvider, this);
141 imageView.setOnClickListener(onClickTouchListener);
142 imageView.setOnTouchListener(onClickTouchListener);
143 imageView.setFocuslockIndicator(this);
146 setupCacheSeekBar(view, imageView);
149 view.setOnKeyListener(onClickTouchListener);
150 view.setFocusableInTouchMode(true);
152 view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
153 view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
154 view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
155 view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
156 view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
158 focusIndicator = view.findViewById(R.id.focus_indicator);
159 if (focusIndicator != null) {
160 focusIndicator.setOnClickListener(onClickTouchListener);
162 manualFocus = view.findViewById(R.id.focusing_button);
163 changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
165 ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
167 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC) {
168 view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
170 // OPCのときには、フォーカスインジケータのマークを消す。
171 if (focusIndicator != null) {
172 focusIndicator.setVisibility(View.INVISIBLE);
175 // お気に入りボタン(とMFボタン)は、SONYモード, RICOH GR2モードのときには表示しない
176 final View favoriteButton = view.findViewById(R.id.show_favorite_settings_button);
177 final View propertyButton = view.findViewById(R.id.camera_property_settings_button);
178 if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY) {
179 if ((favoriteButton != null) && (manualFocus != null)) {
180 runOnUiThread(new Runnable() {
183 favoriteButton.setVisibility(View.INVISIBLE);
184 if (manualFocus != null) {
185 manualFocus.setVisibility(View.INVISIBLE);
187 propertyButton.setVisibility(View.VISIBLE); // 押すとAPI一覧に遷移
191 if (changeLiveViewScale != null) {
192 changeLiveViewScale.setVisibility(View.INVISIBLE);
194 if (focusIndicator != null) {
195 focusIndicator.setVisibility(View.VISIBLE);
197 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2) {
198 if ((favoriteButton != null) && (manualFocus != null)) {
199 runOnUiThread(new Runnable() {
202 favoriteButton.setVisibility(View.INVISIBLE);
203 if (manualFocus != null) {
204 manualFocus.setVisibility(View.INVISIBLE);
206 propertyButton.setVisibility(View.VISIBLE);
210 if (changeLiveViewScale != null) {
211 changeLiveViewScale.setVisibility(View.VISIBLE);
213 if (focusIndicator != null) {
214 focusIndicator.setVisibility(View.INVISIBLE);
216 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC) {
217 if ((favoriteButton != null) && (manualFocus != null)) {
218 runOnUiThread(new Runnable() {
221 favoriteButton.setVisibility(View.INVISIBLE);
222 if (manualFocus != null) {
223 manualFocus.setVisibility(View.INVISIBLE);
225 propertyButton.setVisibility(View.VISIBLE); // 押すとAPI一覧に遷移
229 if (changeLiveViewScale != null) {
230 changeLiveViewScale.setVisibility(View.INVISIBLE);
232 if (focusIndicator != null) {
233 focusIndicator.setVisibility(View.VISIBLE);
235 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X) {
236 if (favoriteButton != null) {
237 favoriteButton.setVisibility(View.VISIBLE);
238 favoriteButton.setOnClickListener(onClickTouchListener);
240 if (manualFocus != null) {
241 manualFocus.setVisibility(View.INVISIBLE);
243 if (changeLiveViewScale != null) {
244 changeLiveViewScale.setVisibility(View.INVISIBLE);
246 if (focusIndicator != null) {
247 focusIndicator.setVisibility(View.VISIBLE);
249 if (propertyButton != null) {
250 propertyButton.setOnClickListener(onClickTouchListener);
252 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS) {
253 if (manualFocus != null) {
254 manualFocus.setVisibility(View.INVISIBLE);
256 if (favoriteButton != null) {
257 favoriteButton.setVisibility(View.INVISIBLE);
258 //favoriteButton.setOnClickListener(onClickTouchListener);
260 if (focusIndicator != null) {
261 focusIndicator.setVisibility(View.VISIBLE);
263 if (propertyButton != null) {
264 propertyButton.setVisibility(View.VISIBLE);
265 propertyButton.setOnClickListener(onClickTouchListener);
267 if (changeLiveViewScale != null) {
268 changeLiveViewScale.setVisibility(View.INVISIBLE);
270 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA) {
271 if (favoriteButton != null) {
272 favoriteButton.setVisibility(View.VISIBLE);
273 favoriteButton.setOnClickListener(onClickTouchListener);
275 if (manualFocus != null) {
276 manualFocus.setVisibility(View.INVISIBLE);
278 if (changeLiveViewScale != null) {
279 changeLiveViewScale.setVisibility(View.INVISIBLE);
281 if (focusIndicator != null) {
282 focusIndicator.setVisibility(View.INVISIBLE);
284 if (propertyButton != null) {
285 propertyButton.setOnClickListener(onClickTouchListener);
287 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON) {
288 if (favoriteButton != null) {
289 favoriteButton.setVisibility(View.VISIBLE);
290 favoriteButton.setOnClickListener(onClickTouchListener);
292 if (manualFocus != null) {
293 manualFocus.setVisibility(View.INVISIBLE);
295 if (changeLiveViewScale != null) {
296 changeLiveViewScale.setVisibility(View.INVISIBLE);
298 if (focusIndicator != null) {
299 focusIndicator.setVisibility(View.VISIBLE);
301 if (propertyButton != null) {
302 propertyButton.setOnClickListener(onClickTouchListener);
304 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON) {
305 if (favoriteButton != null) {
306 favoriteButton.setVisibility(View.VISIBLE);
307 favoriteButton.setOnClickListener(onClickTouchListener);
309 if (manualFocus != null) {
310 manualFocus.setVisibility(View.INVISIBLE);
312 if (changeLiveViewScale != null) {
313 changeLiveViewScale.setVisibility(View.INVISIBLE);
315 if (focusIndicator != null) {
316 focusIndicator.setVisibility(View.VISIBLE);
318 if (propertyButton != null) {
319 propertyButton.setOnClickListener(onClickTouchListener);
323 if (manualFocus != null) {
324 manualFocus.setOnClickListener(onClickTouchListener);
326 changedFocusingMode();
328 if (changeLiveViewScale != null) {
329 changeLiveViewScale.setOnClickListener(onClickTouchListener);
332 showGrid = view.findViewById(R.id.show_hide_grid_button);
333 showGrid.setOnClickListener(onClickTouchListener);
336 connectStatus = view.findViewById(R.id.connect_disconnect_button);
337 connectStatus.setOnClickListener(onClickTouchListener);
338 updateConnectionStatus(ICameraConnection.CameraConnectionStatus.UNKNOWN);
340 statusArea = view.findViewById(R.id.informationMessageTextView);
341 focalLengthArea = view.findViewById(R.id.focal_length_with_digital_zoom_view);
343 } catch (Exception e) {
350 private void setupCacheSeekBar(View view, CameraLiveImageView liveImageView)
352 SeekBar seekBar = view.findViewById(R.id.liveview_cache_seekbar);
357 SharedPreferences preference = android.preference.PreferenceManager.getDefaultSharedPreferences(getActivity());
358 if ((preference != null)&&(preference.getBoolean(IPreferencePropertyAccessor.CACHE_LIVEVIEW_PICTURES, false)))
360 seekBar.setVisibility(View.VISIBLE);
361 seekBar.setMax(SEEKBAR_MAX_SCALE);
362 seekBar.setOnSeekBarChangeListener(liveImageView);
366 seekBar.setVisibility(View.GONE);
379 private void prepare(IChangeScene sceneSelector, IInterfaceProvider interfaceProvider)
381 Log.v(TAG, "prepare()");
383 IDisplayInjector interfaceInjector;
384 ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
385 if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
387 interfaceInjector = interfaceProvider.getRicohGr2Infterface().getDisplayInjector();
389 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
391 interfaceInjector = interfaceProvider.getSonyInterface().getDisplayInjector();
393 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
395 interfaceInjector = interfaceProvider.getFujiXInterface().getDisplayInjector();
397 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
399 interfaceInjector = interfaceProvider.getPanasonicInterface().getDisplayInjector();
401 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
403 interfaceInjector = interfaceProvider.getOlympusPenInterface().getDisplayInjector();
405 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
407 interfaceInjector = interfaceProvider.getThetaInterface().getDisplayInjector();
409 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
411 interfaceInjector = interfaceProvider.getCanonInterface().getDisplayInjector();
413 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
415 interfaceInjector = interfaceProvider.getNikonInterface().getDisplayInjector();
417 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
419 interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
421 this.changeScene = sceneSelector;
422 this.interfaceProvider = interfaceProvider;
423 this.interfaceInjector = interfaceInjector;
425 if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
427 this.liveViewControl = interfaceProvider.getRicohGr2Infterface().getLiveViewControl();
428 this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
429 this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
431 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
433 this.liveViewControl = interfaceProvider.getSonyInterface().getSonyLiveViewControl();
434 this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
435 this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
437 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
439 this.liveViewControl = interfaceProvider.getFujiXInterface().getLiveViewControl();
440 this.zoomLensControl = interfaceProvider.getFujiXInterface().getZoomLensControl();
441 this.cameraInformation = interfaceProvider.getFujiXInterface().getCameraInformation();
443 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
445 this.liveViewControl = interfaceProvider.getPanasonicInterface().getPanasonicLiveViewControl();
446 this.zoomLensControl = interfaceProvider.getPanasonicInterface().getZoomLensControl();
447 this.cameraInformation = interfaceProvider.getPanasonicInterface().getCameraInformation();
449 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
451 this.liveViewControl = interfaceProvider.getOlympusPenInterface().getLiveViewControl();
452 this.zoomLensControl = interfaceProvider.getOlympusPenInterface().getZoomLensControl();
453 this.cameraInformation = interfaceProvider.getOlympusPenInterface().getCameraInformation();
455 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
457 this.liveViewControl = interfaceProvider.getThetaInterface().getLiveViewControl();
458 this.zoomLensControl = interfaceProvider.getThetaInterface().getZoomLensControl();
459 this.cameraInformation = interfaceProvider.getThetaInterface().getCameraInformation();
461 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
463 this.liveViewControl = interfaceProvider.getCanonInterface().getLiveViewControl();
464 this.zoomLensControl = interfaceProvider.getCanonInterface().getZoomLensControl();
465 this.cameraInformation = interfaceProvider.getCanonInterface().getCameraInformation();
467 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
469 this.liveViewControl = interfaceProvider.getNikonInterface().getLiveViewControl();
470 this.zoomLensControl = interfaceProvider.getNikonInterface().getZoomLensControl();
471 this.cameraInformation = interfaceProvider.getNikonInterface().getCameraInformation();
473 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
475 this.liveViewControl = interfaceProvider.getOlympusInterface().getLiveViewControl();
476 this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
477 this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
479 interfaceProvider.setUpdateReceiver(this);
487 public void updateConnectionStatus(ICameraConnection.CameraConnectionStatus connectionStatus)
491 currentConnectionStatus = connectionStatus;
492 runOnUiThread(new Runnable()
497 int id = R.drawable.ic_cloud_off_black_24dp;
498 if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTING)
500 id = R.drawable.ic_cloud_queue_black_24dp;
502 else if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
504 id = R.drawable.ic_cloud_done_black_24dp;
506 connectStatus.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
507 connectStatus.invalidate();
508 imageView.invalidate();
524 public void updateGridIcon()
528 int id = (imageView.isShowGrid()) ? R.drawable.ic_grid_off_black_24dp : R.drawable.ic_grid_on_black_24dp;
529 showGrid.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
530 showGrid.invalidate();
531 imageView.invalidate();
544 public void changedFocusingMode()
548 if ((cameraInformation == null)||(manualFocus == null))
552 runOnUiThread(new Runnable()
557 if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
559 manualFocus.setSelected(cameraInformation.isManualFocus());
560 manualFocus.invalidate();
572 public void updateLiveViewScale(boolean isChangeScale)
576 Log.v(TAG, "updateLiveViewScale() : " + isChangeScale);
579 liveViewControl.updateMagnifyingLiveViewScale(isChangeScale);
582 float scale = liveViewControl.getMagnifyingLiveViewScale();
583 final String datavalue = "LV: " + scale;
586 float digitalZoom = liveViewControl.getDigitalZoomScale();
587 final String digitalValue = (digitalZoom > 1.0f) ? "D x" + digitalZoom : "";
590 runOnUiThread(new Runnable()
595 changeLiveViewScale.setText(datavalue);
596 changeLiveViewScale.postInvalidate();
598 focalLengthArea.setText(digitalValue);
599 focalLengthArea.postInvalidate();
615 public void onStart()
618 Log.v(TAG, "onStart()");
626 public void onResume()
629 Log.v(TAG, "onResume() Start");
631 // 撮影モードかどうかを確認して、撮影モードではなかったら撮影モードに切り替える
632 if ((changeRunModeExecutor != null)&&(!changeRunModeExecutor.isRecordingMode()))
634 // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。
635 changeRunModeExecutor.changeRunMode(true);
639 camera.setCameraStatusListener(statusListener);
641 // 画面下部の表示エリアの用途を切り替える
642 setupLowerDisplayArea();
647 Context context = getContext();
650 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
652 // グリッド・フォーカスアシストの情報を戻す
653 boolean showGrid = preferences.getBoolean(IPreferencePropertyAccessor.SHOW_GRID_STATUS, false);
654 if ((imageView != null) && (imageView.isShowGrid() != showGrid)) {
655 imageView.toggleShowGridFrame();
656 imageView.postInvalidate();
659 if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
668 Log.v(TAG, "onResume() End");
676 public void onPause()
679 Log.v(TAG, "onPause() Start");
684 if (liveViewControl != null)
686 liveViewControl.stopLiveView();
694 Log.v(TAG, "onPause() End");
702 public void updateStatusView(String message)
704 messageValue = message;
705 runOnUiThread(new Runnable()
708 * カメラの状態(ステータステキスト)を更新する
709 * (ステータステキストは、プライベート変数で保持して、書き換える)
714 if (statusArea != null)
716 statusArea.setText(messageValue);
717 statusArea.invalidate();
728 public void startLiveView()
730 ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
732 if (liveViewControl == null)
734 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
736 Log.v(TAG, "startLiveView() : liveViewControl is null.");
742 prepare(changeScene, interfaceProvider);
748 Context context = getContext();
751 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
752 liveViewControl.changeLiveViewSize(preferences.getString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE));
754 ILiveViewListener lvListener;
755 if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
757 lvListener = interfaceProvider.getRicohGr2Infterface().getLiveViewListener();
759 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
761 lvListener = interfaceProvider.getSonyInterface().getLiveViewListener();
763 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
765 lvListener = interfaceProvider.getFujiXInterface().getLiveViewListener();
767 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
769 lvListener = interfaceProvider.getPanasonicInterface().getLiveViewListener();
771 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
773 lvListener = interfaceProvider.getOlympusPenInterface().getLiveViewListener();
775 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
777 lvListener = interfaceProvider.getThetaInterface().getLiveViewListener();
779 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
781 lvListener = interfaceProvider.getCanonInterface().getLiveViewListener();
783 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
785 lvListener = interfaceProvider.getNikonInterface().getLiveViewListener();
787 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
789 interfaceProvider.getOlympusLiveViewListener().setOlympusLiveViewListener(liveViewListener);
790 lvListener = liveViewListener;
792 lvListener.setCameraLiveImageView(imageView);
793 liveViewControl.startLiveView();
796 liveViewControl.updateDigitalZoom();
798 // ズームが制御できない場合は、ボタンを消す
799 if (!zoomLensControl.canZoom())
801 final Activity activity = getActivity();
802 if (activity != null)
804 activity.runOnUiThread(new Runnable()
811 View zoomin = activity.findViewById(R.id.btn_zoomin);
814 zoomin.setVisibility(View.INVISIBLE);
816 View zoomout = activity.findViewById(R.id.btn_zoomout);
819 zoomout.setVisibility(View.INVISIBLE);
832 // パワーズームの設定 (初期化位置の設定)
833 zoomLensControl.moveInitialZoomPosition();
836 // 測光モードをスポットに切り替える (OPCのみ)
837 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
843 updateLiveViewScale(false);
857 public boolean isFocusLocked()
859 return (this.focusLocked);
866 private void setAEtoSpot()
870 IOlyCameraPropertyProvider propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
871 if (propertyProvider != null)
873 propertyProvider.setCameraPropertyValue(IOlyCameraProperty.AE, IOlyCameraProperty.AE_PINPOINT);
883 public void showFavoriteSettingDialog()
887 Log.v(TAG, "showFavoriteSettingDialog()");
889 LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
890 dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
891 dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterface()));
892 FragmentManager manager = getFragmentManager();
895 dialog.show(manager, "my_dialog");
905 public void showCameraStatusDialog()
909 // FUJI X用のステータス表示ダイアログを表示する
910 FragmentManager manager = getFragmentManager();
913 FujiXCameraStatusDialog.newInstance(interfaceProvider.getFujiXInterface()).show(manager, "statusDialog");
922 private void runOnUiThread(Runnable action)
924 Activity activity = getActivity();
925 if (activity == null)
929 activity.runOnUiThread(action);
933 public void updateDriveMode(String driveMode)
935 Log.v(TAG, "updateDriveMode() : " + driveMode);
939 public void updateAeLockState(boolean isAeLocked)
941 Log.v(TAG, "updateAeLockState() : " + isAeLocked);
945 public void updateCameraStatus(String message)
949 updateStatusView(message);
958 public void updateLevelGauge(String orientation, float roll, float pitch)
960 Log.v(TAG, "updateLevelGauge() : " + orientation + " roll : " + roll + " pitch : " + pitch);
964 public void updatedTakeMode(String mode)
966 Log.v(TAG, "updatedTakeMode() : " + mode);
970 public void updatedShutterSpeed(String tv)
972 Log.v(TAG, "updatedShutterSpeed() : " + tv);
976 public void updatedAperture(String av)
978 Log.v(TAG, "updatedAperture() : " + av);
982 public void updatedExposureCompensation(String xv)
984 Log.v(TAG, "updatedExposureCompensation() : " + xv);
988 public void updatedMeteringMode(String meteringMode)
990 Log.v(TAG, "updatedExposureCompensation() : " + meteringMode);
994 public void updatedWBMode(String wbMode)
996 Log.v(TAG, "updatedWBMode() : " + wbMode);
1000 public void updateRemainBattery(int percentage)
1002 Log.v(TAG, "updateRemainBattery() : " + percentage);
1006 public void updateFocusedStatus(final boolean focused, final boolean focusLocked)
1008 Log.v(TAG, "updateFocusedStatus() : f: " + focused + " fl: " + focusLocked);
1009 this.focusLocked = focusLocked;
1010 Activity activity = getActivity();
1011 if ((activity == null)||(focusIndicator == null)|| (focusIndicator.getVisibility() != View.VISIBLE))
1013 Log.v(TAG, "updateFocusedStatus() : INVISIBLE");
1019 activity.runOnUiThread(new Runnable() {
1024 Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_center_focus_strong_black_24dp, null);
1027 DrawableCompat.setTint(icon, Color.GREEN);
1028 focusIndicator.setImageDrawable(icon);
1033 Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_crop_free_black_24dp, null);
1036 int color = Color.BLACK;
1041 DrawableCompat.setTint(icon, color);
1042 focusIndicator.setImageDrawable(icon);
1045 focusIndicator.invalidate();
1051 e.printStackTrace();
1056 public void updateIsoSensitivity(String sv)
1058 Log.v(TAG, "updateIsoSensitivity() : " + sv);
1062 public void updateWarning(String warning)
1064 Log.v(TAG, "updateWarning() : " + warning);
1068 public void updateStorageStatus(String status)
1070 Log.v(TAG, "updateStorageStatus() : " + status);
1074 public void updateFocusLockIndicator(final boolean focused, final boolean focusLocked)
1076 updateFocusedStatus(focused, focusLocked);
1079 public boolean handleKeyDown(int keyCode, KeyEvent event)
1081 return (onClickTouchListener.onKey(null, keyCode, event));