OSDN Git Service

若干整理。
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / A01dMain.java
1 package net.osdn.gokigen.a01d;
2
3 import android.Manifest;
4 import android.content.SharedPreferences;
5 import android.content.pm.PackageManager;
6 import android.graphics.Color;
7 import android.graphics.Typeface;
8 import android.os.Bundle;
9 import android.util.Log;
10 import android.view.KeyEvent;
11 import android.view.WindowManager;
12 import android.widget.TextView;
13
14 import net.osdn.gokigen.a01d.camera.CameraInterfaceProvider;
15 import net.osdn.gokigen.a01d.camera.IInterfaceProvider;
16 import net.osdn.gokigen.a01d.camera.fujix.cameraproperty.FujiXCameraCommandSendDialog;
17 import net.osdn.gokigen.a01d.camera.olympus.cameraproperty.OlyCameraPropertyListFragment;
18 import net.osdn.gokigen.a01d.camera.ICameraStatusReceiver;
19 import net.osdn.gokigen.a01d.camera.ICameraConnection;
20 import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
21 import net.osdn.gokigen.a01d.camera.utils.SimpleHttpSendCommandDialog;
22 import net.osdn.gokigen.a01d.camera.panasonic.operation.PanasonicSendCommandDialog;
23 import net.osdn.gokigen.a01d.camera.ricohgr2.operation.RicohGr2SendCommandDialog;
24 import net.osdn.gokigen.a01d.camera.sony.cameraproperty.SonyCameraApiListFragment;
25 import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
26 import net.osdn.gokigen.a01d.liveview.LiveViewFragment;
27 import net.osdn.gokigen.a01d.logcat.LogCatFragment;
28 import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor;
29 import net.osdn.gokigen.a01d.preference.fujix.FujiXPreferenceFragment;
30 import net.osdn.gokigen.a01d.preference.olympus.PreferenceFragment;
31 import net.osdn.gokigen.a01d.preference.panasonic.PanasonicPreferenceFragment;
32 import net.osdn.gokigen.a01d.preference.olympuspen.OlympusPreferenceFragment;
33 import net.osdn.gokigen.a01d.preference.ricohgr2.RicohGr2PreferenceFragment;
34 import net.osdn.gokigen.a01d.preference.sony.SonyPreferenceFragment;
35 import net.osdn.gokigen.a01d.preference.theta.ThetaPreferenceFragment;
36
37 import androidx.annotation.NonNull;
38 import androidx.appcompat.app.ActionBar;
39 import androidx.appcompat.app.AppCompatActivity;
40 import androidx.core.app.ActivityCompat;
41 import androidx.core.content.ContextCompat;
42 import androidx.fragment.app.FragmentTransaction;
43 import androidx.preference.PreferenceFragmentCompat;
44 import androidx.preference.PreferenceManager;
45
46 import java.util.HashMap;
47 import java.util.Map;
48
49 /**
50  *   A01d ;
51  *
52  */
53 public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene, ICameraPowerOn.PowerOnCameraCallback, IInformationReceiver
54 {
55     private final String TAG = toString();
56     private IInterfaceProvider interfaceProvider = null;
57     private IStatusViewDrawer statusViewDrawer = null;
58
59     private PreferenceFragmentCompat preferenceFragment = null;
60     private OlyCameraPropertyListFragment propertyListFragment = null;
61     private SonyCameraApiListFragment sonyApiListFragmentSony = null;
62     private LogCatFragment logCatFragment = null;
63     private LiveViewFragment liveViewFragment = null;
64
65     @Override
66     protected void onCreate(Bundle savedInstanceState)
67     {
68         final int REQUEST_NEED_PERMISSIONS = 1010;
69
70         super.onCreate(savedInstanceState);
71 /*
72         try {
73             // 全画面表示...
74             if (Build.VERSION.SDK_INT >= 19)
75             {
76                 View decor = this.getWindow().getDecorView();
77                 decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
78             } else {
79                 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
80             }
81         }
82         catch (Exception e)
83         {
84             e.printStackTrace();
85         }
86 */
87         setContentView(R.layout.activity_a01d_main);
88
89         ActionBar bar = getSupportActionBar();
90         if (bar != null) {
91             // タイトルバーは表示しない
92             bar.hide();
93         }
94         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
95
96         // 外部メモリアクセス権のオプトイン
97         if ((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ||
98                 (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) ||
99                 (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_MEDIA_LOCATION) != PackageManager.PERMISSION_GRANTED) ||
100                 (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED) ||
101                 (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED) ||
102                 (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED) ||
103                 (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) != PackageManager.PERMISSION_GRANTED) ||
104                 (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) ||
105                 (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED)) {
106             ActivityCompat.requestPermissions(this,
107                     new String[]{
108                             Manifest.permission.WRITE_EXTERNAL_STORAGE,
109                             Manifest.permission.READ_EXTERNAL_STORAGE,
110                             Manifest.permission.ACCESS_MEDIA_LOCATION,
111                             Manifest.permission.ACCESS_NETWORK_STATE,
112                             Manifest.permission.ACCESS_WIFI_STATE,
113                             Manifest.permission.BLUETOOTH,
114                             Manifest.permission.BLUETOOTH_ADMIN,
115                             Manifest.permission.ACCESS_COARSE_LOCATION,
116                             Manifest.permission.INTERNET,
117                     },
118                     REQUEST_NEED_PERMISSIONS);
119         }
120         initializeClass();
121         initializeFragment();
122         onReadyClass();
123     }
124
125     /**
126      *   なぜか、onReadyClass() が有効ではなさそうなので...
127      *
128      */
129     @Override
130     public void onRequestPermissionsResult(int requestCode, @NonNull String[]  permissions, @NonNull int[] grantResults)
131     {
132         super.onRequestPermissionsResult(requestCode, permissions, grantResults);
133         onReadyClass();
134     }
135
136     /**
137      * クラスの初期化
138      */
139     private void initializeClass()
140     {
141         try
142         {
143             interfaceProvider = new CameraInterfaceProvider(this, this);
144         }
145         catch (Exception e)
146         {
147             e.printStackTrace();
148         }
149     }
150
151     /**
152      * 初期化終了時の処理
153      */
154     private void onReadyClass()
155     {
156         if (isBlePowerOn())
157         {
158             // BLEでPower ONは、OPCのみ対応
159             if (interfaceProvider.getCammeraConnectionMethod() == ICameraConnection.CameraConnectionMethod.OPC)
160             {
161                 // BLEでカメラの電源をONにする設定だった時
162                 try
163                 {
164                     // カメラの電源ONクラスを呼び出しておく (電源ONができたら、コールバックをもらう)
165                     interfaceProvider.getOlympusInterface().getCameraPowerOn().wakeup(this);
166                 }
167                 catch (Exception e)
168                 {
169                     e.printStackTrace();
170                 }
171             }
172         }
173         else if (isAutoConnectCamera())
174         {
175             // 自動接続の指示があったとき
176             changeCameraConnection();
177         }
178     }
179
180     /**
181      * フラグメントの初期化
182      */
183     private void initializeFragment()
184     {
185         try
186         {
187             //if (liveViewFragment == null)
188             {
189                 liveViewFragment = LiveViewFragment.newInstance(this, interfaceProvider);
190             }
191             statusViewDrawer = liveViewFragment;
192             liveViewFragment.setRetainInstance(true);
193             FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
194             transaction.replace(R.id.fragment1, liveViewFragment);
195             transaction.commitAllowingStateLoss();
196         }
197         catch (Exception e)
198         {
199             e.printStackTrace();
200         }
201     }
202
203     /**
204      *
205      */
206     @Override
207     protected void onPause()
208     {
209         super.onPause();
210         try
211         {
212             ICameraConnection.CameraConnectionMethod method = interfaceProvider.getCammeraConnectionMethod();
213             ICameraConnection connection = getCameraConnection(method);
214             if (connection != null)
215             {
216                 connection.stopWatchWifiStatus(this);
217             }
218         }
219         catch (Exception e)
220         {
221             e.printStackTrace();
222         }
223     }
224
225     /**
226      * カメラのプロパティ一覧画面を開く
227      * (カメラと接続中のときのみ、接続方式が Olympusのときのみ)
228      */
229     @Override
230     public void changeSceneToCameraPropertyList()
231     {
232         try
233         {
234             ICameraConnection.CameraConnectionMethod method = interfaceProvider.getCammeraConnectionMethod();
235             ICameraConnection connection = getCameraConnection(method);
236             if (method == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
237             {
238                 try
239                 {
240                     // Ricohの場合は、コマンド送信ダイアログを表示する
241                     RicohGr2SendCommandDialog.newInstance().show(getSupportFragmentManager(), "RicohGr2SendCommandDialog");
242                 }
243                 catch (Exception e)
244                 {
245                     e.printStackTrace();
246                 }
247             }
248             else if (method == ICameraConnection.CameraConnectionMethod.SONY)
249             {
250                 // SONYの場合は、API一覧画面へ遷移させる
251                 changeSceneToApiList();
252             }
253             else if (method == ICameraConnection.CameraConnectionMethod.PANASONIC)
254             {
255                 try
256                 {
257                     // Panasonicの場合は、コマンド送信ダイアログを表示する
258                     PanasonicSendCommandDialog.newInstance(interfaceProvider.getPanasonicInterface()).show(getSupportFragmentManager(), "panasonicSendCommandDialog");
259                 }
260                 catch (Exception e)
261                 {
262                     e.printStackTrace();
263                 }
264             }
265             else if (method == ICameraConnection.CameraConnectionMethod.FUJI_X)
266             {
267                 try
268                 {
269                     // FUJI X Seriesの場合は、コマンド送信ダイアログを表示する
270                     FujiXCameraCommandSendDialog.newInstance(interfaceProvider.getFujiXInterface()).show(getSupportFragmentManager(), "sendCommandDialog");
271                 }
272                 catch (Exception e)
273                 {
274                     e.printStackTrace();
275                 }
276             }
277             else if (method == ICameraConnection.CameraConnectionMethod.OLYMPUS)
278             {
279                 try
280                 {
281                     Map<String, String> headerMap = new HashMap<>();
282                     headerMap.put("User-Agent", "OlympusCameraKit"); // "OI.Share"
283                     headerMap.put("X-Protocol", "OlympusCameraKit"); // "OI.Share"
284
285                     // Olympus Penの場合は、コマンド送信ダイアログを表示する
286                     SimpleHttpSendCommandDialog.newInstance("http://192.168.0.10/", interfaceProvider.getOlympusPenInterface().getLiveViewControl(), headerMap).show(getSupportFragmentManager(), "olympusPenSendCommandDialog");
287                 }
288                 catch (Exception e)
289                 {
290                     e.printStackTrace();
291                 }
292             }
293             else if (method == ICameraConnection.CameraConnectionMethod.THETA)
294             {
295                 try
296                 {
297                     // THETA の場合は、HTTPコマンド送信ダイアログを表示する
298                     SimpleHttpSendCommandDialog.newInstance("http://192.168.1.1/", null, null).show(getSupportFragmentManager(), "thetaSendCommandDialog");
299                 }
300                 catch (Exception e)
301                 {
302                     e.printStackTrace();
303                 }
304             }
305             else
306             {
307                 // OPC カメラの場合...
308                 if (connection != null)
309                 {
310                     ICameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
311                     if (status == ICameraConnection.CameraConnectionStatus.CONNECTED)
312                     {
313                         if (propertyListFragment == null)
314                         {
315                             propertyListFragment = OlyCameraPropertyListFragment.newInstance(this, interfaceProvider.getOlympusInterface().getCameraPropertyProvider());
316                         }
317                         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
318                         transaction.replace(R.id.fragment1, propertyListFragment);
319                         // backstackに追加
320                         transaction.addToBackStack(null);
321                         transaction.commit();
322                     }
323                 }
324             }
325         }
326         catch (Exception e)
327         {
328             e.printStackTrace();
329         }
330     }
331
332     /**
333      *   設定画面を開く
334      *
335      */
336     @Override
337     public void changeSceneToConfiguration()
338     {
339         try
340         {
341             if (preferenceFragment == null)
342             {
343                 try
344                 {
345                     ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
346                     if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2) {
347                         preferenceFragment = RicohGr2PreferenceFragment.newInstance(this, this);
348                     } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY) {
349                         preferenceFragment = SonyPreferenceFragment.newInstance(this, this);
350                     } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC) {
351                         preferenceFragment = PanasonicPreferenceFragment.newInstance(this, this);
352                     } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS) {
353                         preferenceFragment = OlympusPreferenceFragment.newInstance(this, this);
354                     } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X) {
355                         preferenceFragment = FujiXPreferenceFragment.newInstance(this, this);
356                     } else if (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA) {
357                         preferenceFragment = ThetaPreferenceFragment.newInstance(this, this);
358                     } else //  if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
359                     {
360                         preferenceFragment = PreferenceFragment.newInstance(this, interfaceProvider, this);
361                     }
362                 }
363                 catch (Exception e)
364                 {
365                     e.printStackTrace();
366                     preferenceFragment = SonyPreferenceFragment.newInstance(this, this);
367                 }
368             }
369
370             FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
371             transaction.replace(R.id.fragment1, preferenceFragment);
372             // backstackに追加
373             transaction.addToBackStack(null);
374             transaction.commit();
375         }
376         catch (Exception e)
377         {
378             e.printStackTrace();
379         }
380     }
381
382     /**
383      *   デバッグ情報画面を開く
384      *
385      */
386     @Override
387     public void changeSceneToDebugInformation()
388     {
389         if (logCatFragment == null)
390         {
391             logCatFragment = LogCatFragment.newInstance();
392         }
393         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
394         transaction.replace(R.id.fragment1, logCatFragment);
395         // backstackに追加
396         transaction.addToBackStack(null);
397         transaction.commit();
398     }
399
400     /**
401      *   SonyのAPI List画面を開く
402      *
403      */
404     @Override
405     public void changeSceneToApiList()
406     {
407         if (sonyApiListFragmentSony == null)
408         {
409             sonyApiListFragmentSony = SonyCameraApiListFragment.newInstance(interfaceProvider);
410         }
411         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
412         transaction.replace(R.id.fragment1, sonyApiListFragmentSony);
413         // backstackに追加
414         transaction.addToBackStack(null);
415         transaction.commit();
416     }
417
418     /**
419      *   カメラとの接続・切断のシーケンス
420      */
421     @Override
422     public void changeCameraConnection()
423     {
424         if (interfaceProvider == null)
425         {
426             Log.v(TAG, "changeCameraConnection() : interfaceProvider is NULL");
427             return;
428         }
429         try
430         {
431             ICameraConnection connection = getCameraConnection(interfaceProvider.getCammeraConnectionMethod());
432             if (connection != null)
433             {
434                 ICameraConnection.CameraConnectionStatus status = connection.getConnectionStatus();
435                 if (status == ICameraConnection.CameraConnectionStatus.CONNECTED)
436                 {
437                     // 接続中のときには切断する
438                     connection.disconnect(false);
439                     return;
440                 }
441                 // 接続中でない時は、接続中にする
442                 connection.startWatchWifiStatus(this);
443             }
444         }
445         catch (Exception e)
446         {
447             e.printStackTrace();
448         }
449     }
450
451     /**
452      * アプリを抜ける
453      */
454     @Override
455     public void exitApplication()
456     {
457         Log.v(TAG, "exitApplication()");
458         try
459         {
460             ICameraConnection connection = getCameraConnection(interfaceProvider.getCammeraConnectionMethod());
461             if (connection != null)
462             {
463                 connection.disconnect(true);
464             }
465             finish();
466         }
467         catch (Exception e)
468         {
469             e.printStackTrace();
470         }
471     }
472
473     /**
474      *
475      *
476      */
477     @Override
478     public void onStatusNotify(String message)
479     {
480         Log.v(TAG, " CONNECTION MESSAGE : " + message);
481         try
482         {
483             if (statusViewDrawer != null)
484             {
485                 statusViewDrawer.updateStatusView(message);
486                 ICameraConnection connection = getCameraConnection(interfaceProvider.getCammeraConnectionMethod());
487                 if (connection != null)
488                 {
489                     statusViewDrawer.updateConnectionStatus(connection.getConnectionStatus());
490                 }
491             }
492         }
493         catch (Exception e)
494         {
495             e.printStackTrace();
496         }
497     }
498
499     /**
500      *
501      *
502      */
503     @Override
504     public void onCameraConnected()
505     {
506         Log.v(TAG, "onCameraConnected()");
507
508         try
509         {
510             ICameraConnection connection = getCameraConnection(interfaceProvider.getCammeraConnectionMethod());
511             if (connection != null)
512             {
513                 // クラス構造をミスった...のでこんなところで、無理やりステータスを更新する
514                 connection.forceUpdateConnectionStatus(ICameraConnection.CameraConnectionStatus.CONNECTED);
515             }
516             if (statusViewDrawer != null)
517             {
518                 statusViewDrawer.updateConnectionStatus(ICameraConnection.CameraConnectionStatus.CONNECTED);
519
520                 // ライブビューの開始...
521                 statusViewDrawer.startLiveView();
522             }
523         }
524         catch (Exception e)
525         {
526             e.printStackTrace();
527         }
528     }
529
530     /**
531      *
532      *
533      */
534     @Override
535     public void onCameraDisconnected()
536     {
537         Log.v(TAG, "onCameraDisconnected()");
538         if (statusViewDrawer != null)
539         {
540             statusViewDrawer.updateStatusView(getString(R.string.camera_disconnected));
541             statusViewDrawer.updateConnectionStatus(ICameraConnection.CameraConnectionStatus.DISCONNECTED);
542         }
543     }
544
545     /**
546      *
547      *
548      */
549     @Override
550     public void onCameraOccursException(String message, Exception e)
551     {
552         Log.v(TAG, "onCameraOccursException() " + message);
553         try
554         {
555             e.printStackTrace();
556             ICameraConnection connection = getCameraConnection(interfaceProvider.getCammeraConnectionMethod());
557             if (connection != null)
558             {
559                 connection.alertConnectingFailed(message + " " + e.getLocalizedMessage());
560             }
561             if (statusViewDrawer != null)
562             {
563                 statusViewDrawer.updateStatusView(message);
564                 if (connection != null)
565                 {
566                     statusViewDrawer.updateConnectionStatus(connection.getConnectionStatus());
567                 }
568             }
569         }
570         catch (Exception ee)
571         {
572             ee.printStackTrace();
573         }
574     }
575
576     /**
577      *   BLE経由でカメラの電源を入れるかどうか
578      *
579      */
580     private boolean isBlePowerOn()
581     {
582         boolean ret = false;
583         try
584         {
585             if (interfaceProvider.getCammeraConnectionMethod() == ICameraConnection.CameraConnectionMethod.OPC)
586             {
587                 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
588                 ret = preferences.getBoolean(IPreferencePropertyAccessor.BLE_POWER_ON, false);
589                 // Log.v(TAG, "isBlePowerOn() : " + ret);
590             }
591         }
592         catch (Exception e)
593         {
594             e.printStackTrace();
595         }
596         return (ret);
597     }
598
599     /**
600      *    カメラへの自動接続を行うかどうか
601      *
602      */
603     private boolean isAutoConnectCamera()
604     {
605         boolean ret = true;
606         try
607         {
608             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
609             ret = preferences.getBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
610             // Log.v(TAG, "isAutoConnectCamera() : " + ret);
611         }
612         catch (Exception e)
613         {
614             e.printStackTrace();
615         }
616         return (ret);
617     }
618
619     /**
620      *
621      *
622      *
623      */
624     private ICameraConnection getCameraConnection(ICameraConnection.CameraConnectionMethod connectionMethod)
625     {
626         ICameraConnection connection;
627         if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
628         {
629             connection = interfaceProvider.getRicohGr2Infterface().getRicohGr2CameraConnection();
630         }
631         else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
632         {
633             connection = interfaceProvider.getSonyInterface().getSonyCameraConnection();
634         }
635         else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.PANASONIC)
636         {
637             connection = interfaceProvider.getPanasonicInterface().getPanasonicCameraConnection();
638         }
639         else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.FUJI_X)
640         {
641             connection = interfaceProvider.getFujiXInterface().getFujiXCameraConnection();
642         }
643         else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.OLYMPUS)
644         {
645             connection = interfaceProvider.getOlympusPenInterface().getOlyCameraConnection();
646         }
647         else if  (connectionMethod == ICameraConnection.CameraConnectionMethod.THETA)
648         {
649             connection = interfaceProvider.getThetaInterface().getCameraConnection();
650         }
651         else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
652         {
653             connection = interfaceProvider.getOlympusInterface().getOlyCameraConnection();
654         }
655         return (connection);
656     }
657
658     /**
659      *   カメラへのBLE接続指示が完了したとき
660      *
661      * @param isExecuted  true : BLEで起動した, false : 起動していない、その他
662      */
663     @Override
664     public void wakeupExecuted(boolean isExecuted)
665     {
666         Log.v(TAG, "wakeupExecuted() : " + isExecuted);
667         if (isAutoConnectCamera())
668         {
669             // カメラへ自動接続する設定だった場合、カメラへWiFi接続する (BLEで起動しなくても)
670             changeCameraConnection();
671         }
672     }
673
674
675     @Override
676     public boolean onKeyDown(int keyCode, KeyEvent event)
677     {
678         Log.v(TAG, "onKeyDown()" + " " + keyCode);
679         try
680         {
681             if ((event.getAction() == KeyEvent.ACTION_DOWN)&&
682                     ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)||(keyCode == KeyEvent.KEYCODE_CAMERA)))
683             {
684                 if (liveViewFragment != null)
685                 {
686                     return (liveViewFragment.handleKeyDown(keyCode, event));
687                 }
688             }
689         }
690         catch (Exception e)
691         {
692             e.printStackTrace();
693         }
694         return (super.onKeyDown(keyCode, event));
695     }
696
697     @Override
698     public void updateMessage(final String message, final boolean isBold, final boolean isColor, final int color)
699     {
700         Log.v(TAG, " updateMessage() : " + message);
701 /*
702         try {
703             final TextView messageArea = findViewById(R.id.message);
704             runOnUiThread(new Runnable() {
705                 @Override
706                 public void run() {
707                     try {
708                         if ((messageArea != null) && (message != null))
709                         {
710                             messageArea.setText(message);
711                             if (isBold)
712                             {
713                                 messageArea.setTypeface(Typeface.DEFAULT_BOLD);
714                             }
715                             if (isColor)
716                             {
717                                 messageArea.setTextColor(color);
718                             }
719                             else
720                             {
721                                 messageArea.setTextColor(Color.DKGRAY);
722                             }
723                             messageArea.invalidate();
724                         }
725                     }
726                     catch (Exception e)
727                     {
728                         e.printStackTrace();
729                     }
730                 }
731             });
732         }
733         catch (Exception e)
734         {
735             e.printStackTrace();
736         }
737 */
738     }
739 }