OSDN Git Service

FUJI X対応準備。
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / liveview / LiveViewFragment.java
1 package net.osdn.gokigen.a01d.liveview;
2
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.LayoutInflater;
11 import android.view.View;
12 import android.view.ViewGroup;
13 import android.widget.Button;
14 import android.widget.ImageButton;
15 import android.widget.ImageView;
16 import android.widget.TextView;
17
18 import net.osdn.gokigen.a01d.IChangeScene;
19 import net.osdn.gokigen.a01d.R;
20 import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
21 import net.osdn.gokigen.a01d.camera.IDisplayInjector;
22 import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveCameraProperties;
23 import net.osdn.gokigen.a01d.camera.olympus.myolycameraprops.LoadSaveMyCameraPropertyDialog;
24 import net.osdn.gokigen.a01d.camera.IZoomLensControl;
25 import net.osdn.gokigen.a01d.camera.ICameraInformation;
26 import net.osdn.gokigen.a01d.camera.IFocusingModeNotify;
27 import net.osdn.gokigen.a01d.camera.ILiveViewControl;
28 import net.osdn.gokigen.a01d.camera.ICameraConnection;
29 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraProperty;
30 import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
31 import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener;
32 import net.osdn.gokigen.a01d.liveview.liveviewlistener.OlympusCameraLiveViewListenerImpl;
33 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
34
35 import androidx.annotation.NonNull;
36 import androidx.core.content.res.ResourcesCompat;
37 import androidx.core.graphics.drawable.DrawableCompat;
38 import androidx.fragment.app.Fragment;
39 import androidx.fragment.app.FragmentManager;
40 import androidx.preference.PreferenceManager;
41
42 /**
43  *  撮影用ライブビュー画面
44  *
45  */
46 public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker, ICameraStatusUpdateNotify, IFocusLockIndicator
47 {
48     private final String TAG = this.toString();
49     private static final int COMMAND_MY_PROPERTY = 0x00000100;
50
51     private ILiveViewControl liveViewControl = null;
52     private IZoomLensControl zoomLensControl = null;
53     private IInterfaceProvider interfaceProvider = null;
54     private IDisplayInjector interfaceInjector = null;
55     private OlympusCameraLiveViewListenerImpl liveViewListener = null;
56     private IChangeScene changeScene = null;
57     private ICameraInformation cameraInformation = null;
58     private LiveViewClickTouchListener onClickTouchListener = null;
59
60     private TextView statusArea = null;
61     private TextView focalLengthArea = null;
62     private CameraLiveImageView imageView = null;
63
64     private ImageView manualFocus = null;
65     private ImageView focusIndicator = null;
66     private ImageButton showGrid = null;
67     private ImageButton connectStatus = null;
68     private Button changeLiveViewScale = null;
69
70     private boolean imageViewCreated = false;
71     private View myView = null;
72     private String messageValue = "";
73     private boolean focusLocked = false;
74
75     private ICameraConnection.CameraConnectionStatus currentConnectionStatus =  ICameraConnection.CameraConnectionStatus.UNKNOWN;
76
77     public static LiveViewFragment newInstance(IChangeScene sceneSelector, @NonNull IInterfaceProvider provider)
78     {
79         LiveViewFragment instance = new LiveViewFragment();
80         instance.prepare(sceneSelector, provider);
81
82         // パラメータはBundleにまとめておく
83         Bundle arguments = new Bundle();
84         //arguments.putString("title", title);
85         //arguments.putString("message", message);
86         instance.setArguments(arguments);
87
88         return (instance);
89     }
90
91     /**
92      *
93      *
94      */
95     @Override
96     public void onCreate(Bundle savedInstanceState)
97     {
98         super.onCreate(savedInstanceState);
99         Log.v(TAG, "onCreate()");
100         if (liveViewListener == null)
101         {
102             liveViewListener = new OlympusCameraLiveViewListenerImpl();
103         }
104     }
105
106     /**
107      *
108      *
109      */
110     @Override
111     public void onAttach(Context context)
112     {
113         super.onAttach(context);
114         Log.v(TAG, "onAttach()");
115     }
116
117     /**
118      *
119      *
120      */
121     @Override
122     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
123     {
124         super.onCreateView(inflater, container, savedInstanceState);
125
126         Log.v(TAG, "onCreateView()");
127         if ((imageViewCreated)&&(myView != null))
128         {
129             // Viewを再利用。。。
130             Log.v(TAG, "onCreateView() : called again, so do nothing... : " + myView);
131             return (myView);
132         }
133
134         View view = inflater.inflate(R.layout.fragment_live_view, container, false);
135         myView = view;
136         imageViewCreated = true;
137         try
138         {
139             imageView = view.findViewById(R.id.cameraLiveImageView);
140             if (interfaceInjector != null)
141             {
142                 interfaceInjector.injectDisplay(imageView, imageView, this);
143             }
144             else
145             {
146                 Log.v(TAG, "interfaceInjector is NULL...");
147             }
148             if (onClickTouchListener == null)
149             {
150                 onClickTouchListener = new LiveViewClickTouchListener(this.getContext(), imageView, this, changeScene, interfaceProvider, this);
151             }
152             imageView.setOnClickListener(onClickTouchListener);
153             imageView.setOnTouchListener(onClickTouchListener);
154             imageView.setFocuslockIndicator(this);
155
156             view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
157             view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
158             view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
159             view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
160             view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
161
162             focusIndicator =  view.findViewById(R.id.focus_indicator);
163             if (focusIndicator != null)
164             {
165                 focusIndicator.setOnClickListener(onClickTouchListener);
166             }
167             manualFocus = view.findViewById(R.id.focusing_button);
168             changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
169
170             ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
171
172             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
173             {
174                 view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
175
176                 // OPCのときには、フォーカスインジケータのマークを消す。
177                 if (focusIndicator != null)
178                 {
179                     focusIndicator.setVisibility(View.INVISIBLE);
180                 }
181             }
182             else
183             {
184                 // お気に入りボタン(とMFボタン)は、SONYモード, RICOH GR2モードのときには表示しない
185                 final View favoriteButton = view.findViewById(R.id.show_favorite_settings_button);
186                 final View propertyButton = view.findViewById(R.id.camera_property_settings_button);
187                 if ((favoriteButton != null)&&(manualFocus != null))
188                 {
189                     runOnUiThread(new Runnable()
190                     {
191                         @Override
192                         public void run()
193                         {
194                             favoriteButton.setVisibility(View.INVISIBLE);
195                             if (manualFocus != null)
196                             {
197                                 manualFocus.setVisibility(View.INVISIBLE);
198                             }
199                             propertyButton.setVisibility(View.INVISIBLE);
200                         }
201                     });
202                 }
203                 if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
204                 {
205                     if (changeLiveViewScale != null)
206                     {
207                         changeLiveViewScale.setVisibility(View.INVISIBLE);
208                     }
209                     if (focusIndicator != null)
210                     {
211                         focusIndicator.setVisibility(View.VISIBLE);
212                     }
213                 }
214                 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
215                 {
216                     if (changeLiveViewScale != null)
217                     {
218                         changeLiveViewScale.setVisibility(View.VISIBLE);
219                     }
220                     if (focusIndicator != null)
221                     {
222                         focusIndicator.setVisibility(View.INVISIBLE);
223                     }
224                 }
225                 else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
226                 {
227                     if (changeLiveViewScale != null)
228                     {
229                         changeLiveViewScale.setVisibility(View.INVISIBLE);
230                     }
231                     if (focusIndicator != null)
232                     {
233                         focusIndicator.setVisibility(View.VISIBLE);
234                     }
235                 }
236             }
237
238             if (manualFocus != null)
239             {
240                 manualFocus.setOnClickListener(onClickTouchListener);
241             }
242             changedFocusingMode();
243
244             if (changeLiveViewScale != null)
245             {
246                 changeLiveViewScale.setOnClickListener(onClickTouchListener);
247             }
248
249             showGrid = view.findViewById(R.id.show_hide_grid_button);
250             showGrid.setOnClickListener(onClickTouchListener);
251             updateGridIcon();
252
253             connectStatus = view.findViewById(R.id.connect_disconnect_button);
254             connectStatus.setOnClickListener(onClickTouchListener);
255             updateConnectionStatus(ICameraConnection.CameraConnectionStatus.UNKNOWN);
256
257             statusArea = view.findViewById(R.id.informationMessageTextView);
258             focalLengthArea = view.findViewById(R.id.focal_length_with_digital_zoom_view);
259
260         }
261         catch (Exception e)
262         {
263             e.printStackTrace();
264         }
265
266         return (view);
267     }
268
269     /**
270      *
271      */
272     private void prepare(IChangeScene sceneSelector, IInterfaceProvider interfaceProvider)
273     {
274         Log.v(TAG, "prepare()");
275
276         IDisplayInjector interfaceInjector;
277         ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
278         if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
279         {
280             interfaceInjector = interfaceProvider.getRicohGr2Infterface().getDisplayInjector();
281         }
282         else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
283         {
284             interfaceInjector = interfaceProvider.getSonyInterface().getDisplayInjector();
285         }
286         else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
287         {
288             // TODO: FUJI_X に変更
289             interfaceInjector = interfaceProvider.getSonyInterface().getDisplayInjector();
290         }
291         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
292         {
293             interfaceInjector = interfaceProvider.getOlympusInterface().getDisplayInjector();
294         }
295         this.changeScene = sceneSelector;
296         this.interfaceProvider = interfaceProvider;
297         this.interfaceInjector = interfaceInjector;
298
299         if  (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
300         {
301             this.liveViewControl = interfaceProvider.getRicohGr2Infterface().getLiveViewControl();
302             this.zoomLensControl = interfaceProvider.getRicohGr2Infterface().getZoomLensControl();
303             this.cameraInformation = interfaceProvider.getRicohGr2Infterface().getCameraInformation();
304         }
305         else  if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
306         {
307             this.liveViewControl = interfaceProvider.getSonyInterface().getSonyLiveViewControl();
308             this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
309             this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
310         }
311         else  if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
312         {
313             // TODO: FUJI_X に変更
314             this.liveViewControl = interfaceProvider.getSonyInterface().getSonyLiveViewControl();
315             this.zoomLensControl = interfaceProvider.getSonyInterface().getZoomLensControl();
316             this.cameraInformation = interfaceProvider.getSonyInterface().getCameraInformation();
317         }
318         else //  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
319         {
320             this.liveViewControl = interfaceProvider.getOlympusInterface().getLiveViewControl();
321             this.zoomLensControl = interfaceProvider.getOlympusInterface().getZoomLensControl();
322             this.cameraInformation = interfaceProvider.getOlympusInterface().getCameraInformation();
323         }
324         interfaceProvider.setUpdateReceiver(this);
325     }
326
327     /**
328      *  カメラとの接続状態の更新
329      *
330      */
331     @Override
332     public void updateConnectionStatus(ICameraConnection.CameraConnectionStatus connectionStatus)
333     {
334         try
335         {
336             currentConnectionStatus = connectionStatus;
337             runOnUiThread(new Runnable()
338             {
339                 @Override
340                 public void run()
341                 {
342                     int id = R.drawable.ic_cloud_off_black_24dp;
343                     if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTING)
344                     {
345                         id = R.drawable.ic_cloud_queue_black_24dp;
346                     }
347                     else if  (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
348                     {
349                         id = R.drawable.ic_cloud_done_black_24dp;
350                     }
351                     connectStatus.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
352                     connectStatus.invalidate();
353                     imageView.invalidate();
354                 }
355             });
356
357         }
358         catch (Exception e)
359         {
360             e.printStackTrace();
361         }
362     }
363
364     /**
365      *  グリッドの表示・非表示の更新
366      *
367      */
368     @Override
369     public void updateGridIcon()
370     {
371         try
372         {
373             int id = (imageView.isShowGrid()) ? R.drawable.ic_grid_off_black_24dp : R.drawable.ic_grid_on_black_24dp;
374             showGrid.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
375             showGrid.invalidate();
376             imageView.invalidate();
377         }
378         catch (Exception e)
379         {
380             e.printStackTrace();
381         }
382     }
383
384     /**
385      *   AF/MFの表示を更新する
386      *
387      */
388     @Override
389     public void changedFocusingMode()
390     {
391         try
392         {
393             if ((cameraInformation == null)||(manualFocus == null))
394             {
395                 return;
396             }
397             runOnUiThread(new Runnable()
398             {
399                 @Override
400                 public void run()
401                 {
402                     if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
403                     {
404                         manualFocus.setSelected(cameraInformation.isManualFocus());
405                         manualFocus.invalidate();
406                     }
407                 }
408             });
409         }
410         catch (Exception e)
411         {
412             e.printStackTrace();
413         }
414     }
415
416     @Override
417     public void updateLiveViewScale(boolean isChangeScale)
418     {
419         try
420         {
421             Log.v(TAG, "updateLiveViewScale() : " + isChangeScale);
422
423             // ライブビューの倍率設定
424             liveViewControl.updateMagnifyingLiveViewScale(isChangeScale);
425
426             // ボタンの文字を更新する
427             float scale = liveViewControl.getMagnifyingLiveViewScale();
428             final String datavalue = "LV: " + scale;
429
430             // デジタルズームの倍率を表示する
431             float digitalZoom = liveViewControl.getDigitalZoomScale();
432             final String digitalValue = (digitalZoom > 1.0f) ? "D x" + digitalZoom : "";
433
434             // 更新自体は、UIスレッドで行う
435             runOnUiThread(new Runnable()
436             {
437                 @Override
438                 public void run()
439                 {
440                     changeLiveViewScale.setText(datavalue);
441                     changeLiveViewScale.postInvalidate();
442
443                     focalLengthArea.setText(digitalValue);
444                     focalLengthArea.postInvalidate();
445                 }
446             });
447         }
448         catch (Exception e)
449         {
450             e.printStackTrace();
451         }
452     }
453
454     /**
455      *
456      *
457      *
458      */
459     @Override
460     public void onStart()
461     {
462         super.onStart();
463         Log.v(TAG, "onStart()");
464     }
465
466     /**
467      *
468      *
469      */
470     @Override
471     public void onResume()
472     {
473         super.onResume();
474         Log.v(TAG, "onResume() Start");
475 /*
476         // 撮影モードかどうかを確認して、撮影モードではなかったら撮影モードに切り替える
477         if ((changeRunModeExecutor != null)&&(!changeRunModeExecutor.isRecordingMode()))
478         {
479             // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。
480             changeRunModeExecutor.changeRunMode(true);
481         }
482
483         // ステータスの変更を通知してもらう
484         camera.setCameraStatusListener(statusListener);
485
486         // 画面下部の表示エリアの用途を切り替える
487         setupLowerDisplayArea();
488 */
489         // propertyを取得
490         try
491         {
492             Context context = getContext();
493             if (context != null)
494             {
495                 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
496
497                 // グリッド・フォーカスアシストの情報を戻す
498                 boolean showGrid = preferences.getBoolean(IPreferencePropertyAccessor.SHOW_GRID_STATUS, false);
499                 if ((imageView != null) && (imageView.isShowGrid() != showGrid)) {
500                     imageView.toggleShowGridFrame();
501                     imageView.postInvalidate();
502                 }
503             }
504             if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
505             {
506                 startLiveView();
507             }
508         }
509         catch (Exception e)
510         {
511             e.printStackTrace();
512         }
513         Log.v(TAG, "onResume() End");
514     }
515
516     /**
517      *
518      *
519      */
520     @Override
521     public void onPause()
522     {
523         super.onPause();
524         Log.v(TAG, "onPause() Start");
525
526         // ライブビューの停止
527         try
528         {
529             liveViewControl.stopLiveView();
530         }
531         catch (Exception e)
532         {
533             e.printStackTrace();
534         }
535
536         Log.v(TAG, "onPause() End");
537     }
538
539     /**
540      *   表示エリアに文字を表示する
541      *
542      */
543     @Override
544     public void updateStatusView(String message)
545     {
546         messageValue = message;
547         runOnUiThread(new Runnable()
548         {
549             /**
550              * カメラの状態(ステータステキスト)を更新する
551              * (ステータステキストは、プライベート変数で保持して、書き換える)
552              */
553             @Override
554             public void run()
555             {
556                 if (statusArea != null)
557                 {
558                     statusArea.setText(messageValue);
559                     statusArea.invalidate();
560                 }
561             }
562         });
563     }
564
565     /**
566      *   ライブビューの開始
567      *
568      */
569     @Override
570     public void startLiveView()
571     {
572         ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
573
574         if (liveViewControl == null)
575         {
576             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
577             {
578                 Log.v(TAG, "startLiveView() : liveViewControl is null.");
579                 return;
580             }
581             else
582             {
583                 // ダミー
584                 prepare(changeScene, interfaceProvider);
585             }
586         }
587         try
588         {
589             // ライブビューの開始
590             Context context = getContext();
591             if (context != null)
592             {
593                 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
594                 liveViewControl.changeLiveViewSize(preferences.getString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE));
595             }
596             ILiveViewListener lvListener;
597             if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
598             {
599                 lvListener = interfaceProvider.getRicohGr2Infterface().getLiveViewListener();
600             }
601             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
602             {
603                 lvListener = interfaceProvider.getSonyInterface().getLiveViewListener();
604             }
605             else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
606             {
607                 // TODO: FUJI_X に変更
608                 lvListener = interfaceProvider.getSonyInterface().getLiveViewListener();
609             }
610             else  // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
611             {
612                 interfaceProvider.getOlympusLiveViewListener().setOlympusLiveViewListener(liveViewListener);
613                 lvListener = liveViewListener;
614             }
615             lvListener.setCameraLiveImageView(imageView);
616             liveViewControl.startLiveView();
617
618             // デジタルズームの設定
619             liveViewControl.updateDigitalZoom();
620
621             // ズームが制御できない場合は、ボタンを消す
622             if (!zoomLensControl.canZoom())
623             {
624                 final Activity activity  = getActivity();
625                 if (activity != null)
626                 {
627                     activity.runOnUiThread(new Runnable()
628                     {
629                         @Override
630                         public void run()
631                         {
632                             activity.findViewById(R.id.btn_zoomin).setVisibility(View.INVISIBLE);
633                             activity.findViewById(R.id.btn_zoomout).setVisibility(View.INVISIBLE);
634                         }
635                     });
636                 }
637             }
638             else
639             {
640                 // パワーズームの設定 (初期化位置の設定)
641                 zoomLensControl.moveInitialZoomPosition();
642             }
643
644             // 測光モードをスポットに切り替える (OPCのみ)
645             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
646             {
647                 setAEtoSpot();
648             }
649
650             // ライブビューの倍率設定
651             updateLiveViewScale(false);
652         }
653         catch (Exception e)
654         {
655             e.printStackTrace();
656         }
657     }
658
659
660     /**
661      *   フォーカスロック中かどうか
662      *
663      */
664     @Override
665     public boolean isFocusLocked()
666     {
667         return (this.focusLocked);
668     }
669
670     /**
671      *    測光モードをスポットに切り替える
672      *
673      */
674     private void setAEtoSpot()
675     {
676         try
677         {
678             IOlyCameraPropertyProvider propertyProvider = interfaceProvider.getOlympusInterface().getCameraPropertyProvider();
679             if (propertyProvider != null)
680             {
681                 propertyProvider.setCameraPropertyValue(IOlyCameraProperty.AE, IOlyCameraProperty.AE_PINPOINT);
682             }
683         }
684         catch (Exception e)
685         {
686             e.printStackTrace();
687         }
688     }
689
690     @Override
691     public void showFavoriteSettingDialog()
692     {
693         try
694         {
695             Log.v(TAG, "showFavoriteSettingDialog()");
696
697             LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
698             dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
699             dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterface()));
700             FragmentManager manager = getFragmentManager();
701             if (manager != null)
702             {
703                 dialog.show(manager, "my_dialog");
704             }
705         }
706         catch (Exception e)
707         {
708             e.printStackTrace();
709         }
710     }
711
712     private void runOnUiThread(Runnable action)
713     {
714         Activity activity = getActivity();
715         if (activity == null)
716         {
717             return;
718         }
719         activity.runOnUiThread(action);
720     }
721
722     @Override
723     public void updateDriveMode(String driveMode)
724     {
725         Log.v(TAG, "updateDriveMode() : " + driveMode);
726     }
727
728     @Override
729     public void updateAeLockState(boolean isAeLocked)
730     {
731         Log.v(TAG, "updateAeLockState() : " + isAeLocked);
732     }
733
734     @Override
735     public void updateCameraStatus(String message)
736     {
737         Log.v(TAG, "updateCameraStatus() : " + message);
738     }
739
740     @Override
741     public void updateLevelGauge(String orientation, float roll, float pitch)
742     {
743         Log.v(TAG, "updateLevelGauge() : " + orientation + " roll : " + roll + "  pitch : " + pitch);
744     }
745
746     @Override
747     public void updatedTakeMode(String mode)
748     {
749         Log.v(TAG, "updatedTakeMode() : " + mode);
750     }
751
752     @Override
753     public void updatedShutterSpeed(String tv)
754     {
755         Log.v(TAG, "updatedShutterSpeed() : " + tv);
756     }
757
758     @Override
759     public void updatedAperture(String av)
760     {
761         Log.v(TAG, "updatedAperture() : " + av);
762     }
763
764     @Override
765     public void updatedExposureCompensation(String xv)
766     {
767         Log.v(TAG, "updatedExposureCompensation() : " + xv);
768     }
769
770     @Override
771     public void updatedMeteringMode(String meteringMode)
772     {
773         Log.v(TAG, "updatedExposureCompensation() : " + meteringMode);
774     }
775
776     @Override
777     public void updatedWBMode(String wbMode)
778     {
779         Log.v(TAG, "updatedWBMode() : " + wbMode);
780     }
781
782     @Override
783     public void updateRemainBattery(int percentage)
784     {
785         Log.v(TAG, "updateRemainBattery() : " + percentage);
786     }
787
788     @Override
789     public void updateFocusedStatus(final boolean focused, final boolean focusLocked)
790     {
791         Log.v(TAG, "updateFocusedStatus() : f: " + focused + " fl: " + focusLocked);
792         this.focusLocked = focusLocked;
793         Activity activity = getActivity();
794         if ((activity == null)||(focusIndicator == null)|| (focusIndicator.getVisibility() != View.VISIBLE))
795         {
796             Log.v(TAG, "updateFocusedStatus() : INVISIBLE");
797             return;
798         }
799
800         try
801         {
802             activity.runOnUiThread(new Runnable() {
803                 @Override
804                 public void run() {
805                     if (focused)
806                     {
807                         Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_center_focus_strong_black_24dp, null);
808                         if (icon != null)
809                         {
810                             DrawableCompat.setTint(icon, Color.GREEN);
811                             focusIndicator.setImageDrawable(icon);
812                         }
813                     }
814                     else
815                     {
816                         Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_crop_free_black_24dp, null);
817                         if (icon != null)
818                         {
819                             int color = Color.BLACK;
820                             if (focusLocked)
821                             {
822                                 color = Color.RED;
823                             }
824                             DrawableCompat.setTint(icon, color);
825                             focusIndicator.setImageDrawable(icon);
826                         }
827                     }
828                     focusIndicator.invalidate();
829                 }
830             });
831         }
832         catch (Exception e)
833         {
834             e.printStackTrace();
835         }
836     }
837
838     @Override
839     public void updateIsoSensitivity(String sv)
840     {
841         Log.v(TAG, "updateIsoSensitivity() : " + sv);
842     }
843
844     @Override
845     public void updateWarning(String warning)
846     {
847         Log.v(TAG, "updateWarning() : " + warning);
848     }
849
850     @Override
851     public void updateStorageStatus(String status)
852     {
853         Log.v(TAG, "updateStorageStatus() : " + status);
854     }
855
856     @Override
857     public void updateFocusLockIndicator(final boolean focused, final boolean focusLocked)
858     {
859         updateFocusedStatus(focused, focusLocked);
860     }
861 }