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;
133 imageView = view.findViewById(R.id.cameraLiveImageView);
134 if (interfaceInjector != null) {
135 interfaceInjector.injectDisplay(imageView, imageView, this);
137 Log.v(TAG, "interfaceInjector is NULL...");
139 if (onClickTouchListener == null) {
140 onClickTouchListener = new LiveViewClickTouchListener(this.getContext(), imageView, this, changeScene, interfaceProvider, this);
142 imageView.setOnClickListener(onClickTouchListener);
143 imageView.setOnTouchListener(onClickTouchListener);
144 imageView.setFocuslockIndicator(this);
147 setupCacheSeekBar(view, imageView);
150 view.setOnKeyListener(onClickTouchListener);
151 view.setFocusableInTouchMode(true);
153 boolean captureLv = true;
154 boolean captureRemote = false;
155 Activity activity = this.getActivity();
156 if (activity != null)
158 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
159 captureLv = preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true);
160 captureRemote = preferences.getBoolean(IPreferencePropertyAccessor.CAPTURE_ONLY_LIVE_VIEW, false);
163 ImageButton shutterButton = view.findViewById(R.id.shutter_button);
164 if ((!captureLv)&&(captureRemote))
167 shutterButton.setVisibility(View.INVISIBLE);
171 // シャッターボタンのクリックイベントを拾うよう設定
172 shutterButton.setOnClickListener(onClickTouchListener);
174 view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
175 view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
176 view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
177 view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
179 focusIndicator = view.findViewById(R.id.focus_indicator);
180 if (focusIndicator != null)
182 focusIndicator.setOnClickListener(onClickTouchListener);
184 manualFocus = view.findViewById(R.id.focusing_button);
185 changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
187 ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
189 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
191 view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
193 // OPCのときには、フォーカスインジケータのマークを消す。
194 if (focusIndicator != null)
196 focusIndicator.setVisibility(View.INVISIBLE);
199 // お気に入りボタン(とMFボタン)は、SONYモード, RICOH GR2モードのときには表示しない
200 final View favoriteButton = view.findViewById(R.id.show_favorite_settings_button);
201 final View propertyButton = view.findViewById(R.id.camera_property_settings_button);
202 if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY) {
203 if ((favoriteButton != null) && (manualFocus != null)) {
204 runOnUiThread(new Runnable() {
207 favoriteButton.setVisibility(View.INVISIBLE);
208 if (manualFocus != null) {
209 manualFocus.setVisibility(View.INVISIBLE);
211 propertyButton.setVisibility(View.VISIBLE); // 押すとAPI一覧に遷移
215 if (changeLiveViewScale != null) {
216 changeLiveViewScale.setVisibility(View.INVISIBLE);
218 if (focusIndicator != null) {
219 focusIndicator.setVisibility(View.VISIBLE);
221 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2) {
222 if ((favoriteButton != null) && (manualFocus != null)) {
223 runOnUiThread(new Runnable() {
226 favoriteButton.setVisibility(View.INVISIBLE);
227 if (manualFocus != null) {
228 manualFocus.setVisibility(View.INVISIBLE);
230 propertyButton.setVisibility(View.VISIBLE);
234 if (changeLiveViewScale != null) {
235 changeLiveViewScale.setVisibility(View.VISIBLE);
237 if (focusIndicator != null) {
238 focusIndicator.setVisibility(View.INVISIBLE);
240 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC) {
241 if ((favoriteButton != null) && (manualFocus != null)) {
242 runOnUiThread(new Runnable() {
245 favoriteButton.setVisibility(View.INVISIBLE);
246 if (manualFocus != null) {
247 manualFocus.setVisibility(View.INVISIBLE);
249 propertyButton.setVisibility(View.VISIBLE); // 押すとAPI一覧に遷移
253 if (changeLiveViewScale != null) {
254 changeLiveViewScale.setVisibility(View.INVISIBLE);
256 if (focusIndicator != null) {
257 focusIndicator.setVisibility(View.VISIBLE);
259 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X) {
260 if (favoriteButton != null) {
261 favoriteButton.setVisibility(View.VISIBLE);
262 favoriteButton.setOnClickListener(onClickTouchListener);
264 if (manualFocus != null) {
265 manualFocus.setVisibility(View.INVISIBLE);
267 if (changeLiveViewScale != null) {
268 changeLiveViewScale.setVisibility(View.INVISIBLE);
270 if (focusIndicator != null) {
271 focusIndicator.setVisibility(View.VISIBLE);
273 if (propertyButton != null) {
274 propertyButton.setOnClickListener(onClickTouchListener);
276 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS) {
277 if (manualFocus != null) {
278 manualFocus.setVisibility(View.INVISIBLE);
280 if (favoriteButton != null) {
281 favoriteButton.setVisibility(View.INVISIBLE);
282 //favoriteButton.setOnClickListener(onClickTouchListener);
284 if (focusIndicator != null) {
285 focusIndicator.setVisibility(View.VISIBLE);
287 if (propertyButton != null) {
288 propertyButton.setVisibility(View.VISIBLE);
289 propertyButton.setOnClickListener(onClickTouchListener);
291 if (changeLiveViewScale != null) {
292 changeLiveViewScale.setVisibility(View.INVISIBLE);
294 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA) {
295 if (favoriteButton != null) {
296 favoriteButton.setVisibility(View.VISIBLE);
297 favoriteButton.setOnClickListener(onClickTouchListener);
299 if (manualFocus != null) {
300 manualFocus.setVisibility(View.INVISIBLE);
302 if (changeLiveViewScale != null) {
303 changeLiveViewScale.setVisibility(View.INVISIBLE);
305 if (focusIndicator != null) {
306 focusIndicator.setVisibility(View.INVISIBLE);
308 if (propertyButton != null) {
309 propertyButton.setOnClickListener(onClickTouchListener);
311 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON) {
312 if (favoriteButton != null) {
313 favoriteButton.setVisibility(View.VISIBLE);
314 favoriteButton.setOnClickListener(onClickTouchListener);
316 if (manualFocus != null) {
317 manualFocus.setVisibility(View.INVISIBLE);
319 if (changeLiveViewScale != null) {
320 changeLiveViewScale.setVisibility(View.INVISIBLE);
322 if (focusIndicator != null) {
323 focusIndicator.setVisibility(View.VISIBLE);
325 if (propertyButton != null) {
326 propertyButton.setOnClickListener(onClickTouchListener);
328 } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON) {
329 if (favoriteButton != null) {
330 favoriteButton.setVisibility(View.VISIBLE);
331 favoriteButton.setOnClickListener(onClickTouchListener);
333 if (manualFocus != null) {
334 manualFocus.setVisibility(View.INVISIBLE);
336 if (changeLiveViewScale != null) {
337 changeLiveViewScale.setVisibility(View.INVISIBLE);
339 if (focusIndicator != null) {
340 focusIndicator.setVisibility(View.VISIBLE);
342 if (propertyButton != null) {
343 propertyButton.setOnClickListener(onClickTouchListener);
347 if (manualFocus != null) {
348 manualFocus.setOnClickListener(onClickTouchListener);
350 changedFocusingMode();
352 if (changeLiveViewScale != null) {
353 changeLiveViewScale.setOnClickListener(onClickTouchListener);
356 showGrid = view.findViewById(R.id.show_hide_grid_button);
357 showGrid.setOnClickListener(onClickTouchListener);
360 connectStatus = view.findViewById(R.id.connect_disconnect_button);
361 connectStatus.setOnClickListener(onClickTouchListener);
362 updateConnectionStatus(ICameraConnection.CameraConnectionStatus.UNKNOWN);
364 statusArea = view.findViewById(R.id.informationMessageTextView);
365 focalLengthArea = view.findViewById(R.id.focal_length_with_digital_zoom_view);
367 } catch (Exception e) {
374 private void setupCacheSeekBar(View view, CameraLiveImageView liveImageView)
376 SeekBar seekBar = view.findViewById(R.id.liveview_cache_seekbar);
381 SharedPreferences preference = android.preference.PreferenceManager.getDefaultSharedPreferences(getActivity());
382 if ((preference != null)&&(preference.getBoolean(IPreferencePropertyAccessor.CACHE_LIVEVIEW_PICTURES, false)))
384 seekBar.setVisibility(View.VISIBLE);
385 seekBar.setMax(SEEKBAR_MAX_SCALE);
386 seekBar.setOnSeekBarChangeListener(liveImageView);
390 seekBar.setVisibility(View.GONE);
403 private void prepare(IChangeScene sceneSelector, IInterfaceProvider interfaceProvider)
405 Log.v(TAG, "prepare()");
407 IDisplayInjector interfaceInjector;
408 ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
409 if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
411 interfaceInjector = interfaceProvider.getRicohGr2Infterface().getDisplayInjector();
413 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
415 interfaceInjector = interfaceProvider.getSonyInterface().getDisplayInjector();
417 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
419 interfaceInjector = interfaceProvider.getFujiXInterface().getDisplayInjector();
421 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
423 interfaceInjector = interfaceProvider.getPanasonicInterface().getDisplayInjector();
425 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
427 interfaceInjector = interfaceProvider.getOlympusPenInterface().getDisplayInjector();
429 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
431 interfaceInjector = interfaceProvider.getThetaInterface().getDisplayInjector();
433 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
435 interfaceInjector = interfaceProvider.getCanonInterface().getDisplayInjector();
437 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
439 interfaceInjector = interfaceProvider.getNikonInterface().getDisplayInjector();
441 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
443 interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
445 this.changeScene = sceneSelector;
446 this.interfaceProvider = interfaceProvider;
447 this.interfaceInjector = interfaceInjector;
449 if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
451 this.liveViewControl = interfaceProvider.getRicohGr2Infterface().getLiveViewControl();
452 this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
453 this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
455 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
457 this.liveViewControl = interfaceProvider.getSonyInterface().getSonyLiveViewControl();
458 this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
459 this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
461 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
463 this.liveViewControl = interfaceProvider.getFujiXInterface().getLiveViewControl();
464 this.zoomLensControl = interfaceProvider.getFujiXInterface().getZoomLensControl();
465 this.cameraInformation = interfaceProvider.getFujiXInterface().getCameraInformation();
467 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
469 this.liveViewControl = interfaceProvider.getPanasonicInterface().getPanasonicLiveViewControl();
470 this.zoomLensControl = interfaceProvider.getPanasonicInterface().getZoomLensControl();
471 this.cameraInformation = interfaceProvider.getPanasonicInterface().getCameraInformation();
473 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
475 this.liveViewControl = interfaceProvider.getOlympusPenInterface().getLiveViewControl();
476 this.zoomLensControl = interfaceProvider.getOlympusPenInterface().getZoomLensControl();
477 this.cameraInformation = interfaceProvider.getOlympusPenInterface().getCameraInformation();
479 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
481 this.liveViewControl = interfaceProvider.getThetaInterface().getLiveViewControl();
482 this.zoomLensControl = interfaceProvider.getThetaInterface().getZoomLensControl();
483 this.cameraInformation = interfaceProvider.getThetaInterface().getCameraInformation();
485 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
487 this.liveViewControl = interfaceProvider.getCanonInterface().getLiveViewControl();
488 this.zoomLensControl = interfaceProvider.getCanonInterface().getZoomLensControl();
489 this.cameraInformation = interfaceProvider.getCanonInterface().getCameraInformation();
491 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
493 this.liveViewControl = interfaceProvider.getNikonInterface().getLiveViewControl();
494 this.zoomLensControl = interfaceProvider.getNikonInterface().getZoomLensControl();
495 this.cameraInformation = interfaceProvider.getNikonInterface().getCameraInformation();
497 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
499 this.liveViewControl = interfaceProvider.getOlympusInterface().getLiveViewControl();
500 this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
501 this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
503 interfaceProvider.setUpdateReceiver(this);
511 public void updateConnectionStatus(ICameraConnection.CameraConnectionStatus connectionStatus)
515 currentConnectionStatus = connectionStatus;
516 runOnUiThread(new Runnable()
521 int id = R.drawable.ic_cloud_off_black_24dp;
522 if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTING)
524 id = R.drawable.ic_cloud_queue_black_24dp;
526 else if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
528 id = R.drawable.ic_cloud_done_black_24dp;
530 connectStatus.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
531 connectStatus.invalidate();
532 imageView.invalidate();
548 public void updateGridIcon()
552 int id = (imageView.isShowGrid()) ? R.drawable.ic_grid_off_black_24dp : R.drawable.ic_grid_on_black_24dp;
553 showGrid.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
554 showGrid.invalidate();
555 imageView.invalidate();
568 public void changedFocusingMode()
572 if ((cameraInformation == null)||(manualFocus == null))
576 runOnUiThread(new Runnable()
581 if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
583 manualFocus.setSelected(cameraInformation.isManualFocus());
584 manualFocus.invalidate();
596 public void updateLiveViewScale(boolean isChangeScale)
600 Log.v(TAG, "updateLiveViewScale() : " + isChangeScale);
603 liveViewControl.updateMagnifyingLiveViewScale(isChangeScale);
606 float scale = liveViewControl.getMagnifyingLiveViewScale();
607 final String datavalue = "LV: " + scale;
610 float digitalZoom = liveViewControl.getDigitalZoomScale();
611 final String digitalValue = (digitalZoom > 1.0f) ? "D x" + digitalZoom : "";
614 runOnUiThread(new Runnable()
619 changeLiveViewScale.setText(datavalue);
620 changeLiveViewScale.postInvalidate();
622 focalLengthArea.setText(digitalValue);
623 focalLengthArea.postInvalidate();
639 public void onStart()
642 Log.v(TAG, "onStart()");
650 public void onResume()
653 Log.v(TAG, "onResume() Start");
655 // 撮影モードかどうかを確認して、撮影モードではなかったら撮影モードに切り替える
656 if ((changeRunModeExecutor != null)&&(!changeRunModeExecutor.isRecordingMode()))
658 // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。
659 changeRunModeExecutor.changeRunMode(true);
663 camera.setCameraStatusListener(statusListener);
665 // 画面下部の表示エリアの用途を切り替える
666 setupLowerDisplayArea();
671 Context context = getContext();
674 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
676 // グリッド・フォーカスアシストの情報を戻す
677 boolean showGrid = preferences.getBoolean(IPreferencePropertyAccessor.SHOW_GRID_STATUS, false);
678 if ((imageView != null) && (imageView.isShowGrid() != showGrid)) {
679 imageView.toggleShowGridFrame();
680 imageView.postInvalidate();
683 if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
692 Log.v(TAG, "onResume() End");
700 public void onPause()
703 Log.v(TAG, "onPause() Start");
708 if (liveViewControl != null)
710 liveViewControl.stopLiveView();
718 Log.v(TAG, "onPause() End");
726 public void updateStatusView(String message)
728 messageValue = message;
729 runOnUiThread(new Runnable()
732 * カメラの状態(ステータステキスト)を更新する
733 * (ステータステキストは、プライベート変数で保持して、書き換える)
738 if (statusArea != null)
740 statusArea.setText(messageValue);
741 statusArea.invalidate();
752 public void startLiveView()
754 ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
756 if (liveViewControl == null)
758 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
760 Log.v(TAG, "startLiveView() : liveViewControl is null.");
766 prepare(changeScene, interfaceProvider);
772 Context context = getContext();
775 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
776 liveViewControl.changeLiveViewSize(preferences.getString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE));
778 ILiveViewListener lvListener;
779 if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
781 lvListener = interfaceProvider.getRicohGr2Infterface().getLiveViewListener();
783 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
785 lvListener = interfaceProvider.getSonyInterface().getLiveViewListener();
787 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
789 lvListener = interfaceProvider.getFujiXInterface().getLiveViewListener();
791 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
793 lvListener = interfaceProvider.getPanasonicInterface().getLiveViewListener();
795 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
797 lvListener = interfaceProvider.getOlympusPenInterface().getLiveViewListener();
799 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
801 lvListener = interfaceProvider.getThetaInterface().getLiveViewListener();
803 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.CANON)
805 lvListener = interfaceProvider.getCanonInterface().getLiveViewListener();
807 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.NIKON)
809 lvListener = interfaceProvider.getNikonInterface().getLiveViewListener();
811 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
813 interfaceProvider.getOlympusLiveViewListener().setOlympusLiveViewListener(liveViewListener);
814 lvListener = liveViewListener;
816 lvListener.setCameraLiveImageView(imageView);
817 liveViewControl.startLiveView();
820 liveViewControl.updateDigitalZoom();
822 // ズームが制御できない場合は、ボタンを消す
823 if (!zoomLensControl.canZoom())
825 final Activity activity = getActivity();
826 if (activity != null)
828 activity.runOnUiThread(new Runnable()
835 View zoomin = activity.findViewById(R.id.btn_zoomin);
838 zoomin.setVisibility(View.INVISIBLE);
840 View zoomout = activity.findViewById(R.id.btn_zoomout);
843 zoomout.setVisibility(View.INVISIBLE);
856 // パワーズームの設定 (初期化位置の設定)
857 zoomLensControl.moveInitialZoomPosition();
860 // 測光モードをスポットに切り替える (OPCのみ)
861 if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
867 updateLiveViewScale(false);
881 public boolean isFocusLocked()
883 return (this.focusLocked);
890 private void setAEtoSpot()
894 IOlyCameraPropertyProvider propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
895 if (propertyProvider != null)
897 propertyProvider.setCameraPropertyValue(IOlyCameraProperty.AE, IOlyCameraProperty.AE_PINPOINT);
907 public void showFavoriteSettingDialog()
911 Log.v(TAG, "showFavoriteSettingDialog()");
913 LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
914 dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
915 dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterface()));
916 FragmentManager manager = getFragmentManager();
919 dialog.show(manager, "my_dialog");
929 public void showCameraStatusDialog()
933 // FUJI X用のステータス表示ダイアログを表示する
934 FragmentManager manager = getFragmentManager();
937 FujiXCameraStatusDialog.newInstance(interfaceProvider.getFujiXInterface()).show(manager, "statusDialog");
946 private void runOnUiThread(Runnable action)
948 Activity activity = getActivity();
949 if (activity == null)
953 activity.runOnUiThread(action);
957 public void updateDriveMode(String driveMode)
959 Log.v(TAG, "updateDriveMode() : " + driveMode);
963 public void updateAeLockState(boolean isAeLocked)
965 Log.v(TAG, "updateAeLockState() : " + isAeLocked);
969 public void updateCameraStatus(String message)
973 updateStatusView(message);
982 public void updateLevelGauge(String orientation, float roll, float pitch)
984 Log.v(TAG, "updateLevelGauge() : " + orientation + " roll : " + roll + " pitch : " + pitch);
988 public void updatedTakeMode(String mode)
990 Log.v(TAG, "updatedTakeMode() : " + mode);
994 public void updatedShutterSpeed(String tv)
996 Log.v(TAG, "updatedShutterSpeed() : " + tv);
1000 public void updatedAperture(String av)
1002 Log.v(TAG, "updatedAperture() : " + av);
1006 public void updatedExposureCompensation(String xv)
1008 Log.v(TAG, "updatedExposureCompensation() : " + xv);
1012 public void updatedMeteringMode(String meteringMode)
1014 Log.v(TAG, "updatedExposureCompensation() : " + meteringMode);
1018 public void updatedWBMode(String wbMode)
1020 Log.v(TAG, "updatedWBMode() : " + wbMode);
1024 public void updateRemainBattery(int percentage)
1026 Log.v(TAG, "updateRemainBattery() : " + percentage);
1030 public void updateFocusedStatus(final boolean focused, final boolean focusLocked)
1032 Log.v(TAG, "updateFocusedStatus() : f: " + focused + " fl: " + focusLocked);
1033 this.focusLocked = focusLocked;
1034 Activity activity = getActivity();
1035 if ((activity == null)||(focusIndicator == null)|| (focusIndicator.getVisibility() != View.VISIBLE))
1037 Log.v(TAG, "updateFocusedStatus() : INVISIBLE");
1043 activity.runOnUiThread(new Runnable() {
1048 Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_center_focus_strong_black_24dp, null);
1051 DrawableCompat.setTint(icon, Color.GREEN);
1052 focusIndicator.setImageDrawable(icon);
1057 Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_crop_free_black_24dp, null);
1060 int color = Color.BLACK;
1065 DrawableCompat.setTint(icon, color);
1066 focusIndicator.setImageDrawable(icon);
1069 focusIndicator.invalidate();
1075 e.printStackTrace();
1080 public void updateIsoSensitivity(String sv)
1082 Log.v(TAG, "updateIsoSensitivity() : " + sv);
1086 public void updateWarning(String warning)
1088 Log.v(TAG, "updateWarning() : " + warning);
1092 public void updateStorageStatus(String status)
1094 Log.v(TAG, "updateStorageStatus() : " + status);
1098 public void updateFocusLockIndicator(final boolean focused, final boolean focusLocked)
1100 updateFocusedStatus(focused, focusLocked);
1103 public boolean handleKeyDown(int keyCode, KeyEvent event)
1105 return (onClickTouchListener.onKey(null, keyCode, event));