OSDN Git Service

内部整理中。
[gokigen/A01c.git] / wear / src / main / java / jp / sfjp / gokigen / a01c / MainActivity.java
1 package jp.sfjp.gokigen.a01c;
2
3 import android.content.Intent;
4 import android.content.SharedPreferences;
5 import android.graphics.Color;
6 import android.graphics.drawable.Drawable;
7 import android.os.Bundle;
8 import android.os.PowerManager;
9 import android.os.Vibrator;
10 import android.preference.PreferenceManager;
11 import android.provider.Settings;
12 import android.util.Log;
13 import android.widget.ImageButton;
14 import android.widget.TextView;
15 import android.Manifest;
16 import android.content.pm.PackageManager;
17
18 import androidx.appcompat.app.AppCompatActivity;
19 import androidx.core.app.ActivityCompat;
20 import androidx.core.content.ContextCompat;
21
22 import jp.sfjp.gokigen.a01c.liveview.CameraLiveImageView;
23 import jp.sfjp.gokigen.a01c.liveview.CameraLiveViewListenerImpl;
24 import jp.sfjp.gokigen.a01c.liveview.dialog.FavoriteSettingSelectionDialog;
25 import jp.sfjp.gokigen.a01c.liveview.dialog.IDialogDismissedNotifier;
26 import jp.sfjp.gokigen.a01c.olycamerawrapper.dispatcher.FeatureDispatcher;
27 import jp.sfjp.gokigen.a01c.liveview.ICameraStatusReceiver;
28 import jp.sfjp.gokigen.a01c.liveview.IMessageDrawer;
29 import jp.sfjp.gokigen.a01c.liveview.OlyCameraLiveViewOnTouchListener;
30 import jp.sfjp.gokigen.a01c.olycamerawrapper.IOlyCameraCoordinator;
31 import jp.sfjp.gokigen.a01c.olycamerawrapper.OlyCameraCoordinator;
32 import jp.sfjp.gokigen.a01c.preference.IPreferenceCameraPropertyAccessor;
33
34 /**
35  *   メインのActivity
36  *
37  */
38 public class MainActivity extends AppCompatActivity implements  IChangeScene, IShowInformation, ICameraStatusReceiver, IDialogDismissedNotifier
39 {
40     private final String TAG = toString();
41     static final int REQUEST_NEED_PERMISSIONS = 1010;
42     //static final int COMMAND_MY_PROPERTY = 0x00000100;
43
44     private PowerManager powerManager = null;
45     private CameraLiveImageView liveView = null;
46     private IOlyCameraCoordinator coordinator = null;
47     private IMessageDrawer messageDrawer = null;
48     private OlyCameraLiveViewOnTouchListener listener = null;
49     private FavoriteSettingSelectionDialog selectionDialog = null;
50     private Vibrator vibrator = null;
51     private boolean cameraDisconnectedHappened = false;
52     //private boolean ambientMode = false;
53
54     /**
55      *
56      */
57     @Override
58     protected void onCreate(Bundle savedInstanceState)
59     {
60         super.onCreate(savedInstanceState);
61         Log.v(TAG, "onCreate()");
62
63         // Ambientモードを許してみる...
64         //setAmbientEnabled();
65
66         //  画面全体の設定
67         setContentView(R.layout.activity_main);
68
69         // WiFIアクセス権のオプトイン
70         if ((ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED)||
71                 (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED)||
72                 (ContextCompat.checkSelfPermission(this, Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED)||
73                 (ContextCompat.checkSelfPermission(this, Manifest.permission.CHANGE_NETWORK_STATE) != PackageManager.PERMISSION_GRANTED)||
74                 (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_SETTINGS) != PackageManager.PERMISSION_GRANTED)||
75                 (ContextCompat.checkSelfPermission(this, Manifest.permission.WAKE_LOCK) != PackageManager.PERMISSION_GRANTED)||
76                 (ContextCompat.checkSelfPermission(this, Manifest.permission.VIBRATE) != PackageManager.PERMISSION_GRANTED)||
77                 (ContextCompat.checkSelfPermission(this, Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED))
78         {
79             ActivityCompat.requestPermissions(this,
80                     new String[]{
81                             Manifest.permission.ACCESS_NETWORK_STATE,
82                             Manifest.permission.ACCESS_WIFI_STATE,
83                             Manifest.permission.CHANGE_WIFI_STATE,
84                             Manifest.permission.CHANGE_NETWORK_STATE,
85                             Manifest.permission.WRITE_SETTINGS,
86                             Manifest.permission.WAKE_LOCK,
87                             Manifest.permission.INTERNET,
88                     },
89                     REQUEST_NEED_PERMISSIONS);
90         }
91
92         try
93         {
94             if (!hasGps())
95             {
96                 // GPS機能が搭載されていない場合...
97                 Log.d(TAG, "This hardware doesn't have GPS.");
98                 // Fall back to functionality that does not use location or
99                 // warn the user that location function is not available.
100             }
101
102             // バイブレータをつかまえる
103             vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
104
105             // パワーマネージャをつかまえる
106             powerManager = (PowerManager) getSystemService(POWER_SERVICE);
107
108             setupCameraCoordinator();
109             setupInitialButtonIcons();
110             setupActionListener();
111         }
112         catch (Exception e)
113         {
114             e.printStackTrace();
115         }
116     }
117
118     /**
119      *
120      */
121     @Override
122     protected void onResume()
123     {
124         super.onResume();
125         Log.v(TAG, "onResume()");
126     }
127
128     /**
129      *
130      */
131     @Override
132     protected void onPause()
133     {
134         super.onPause();
135         Log.v(TAG, "onPause()");
136     }
137
138     /**
139      *
140      *
141      */
142     @Override
143     public void onStart()
144     {
145         super.onStart();
146         Log.v(TAG, "onStart()");
147     }
148
149     /**
150      *
151      *
152      */
153     @Override
154     public void onStop()
155     {
156         super.onStop();
157         Log.v(TAG, "onStop()");
158         exitApplication();
159     }
160
161 /*
162      @Override
163      public void onEnterAmbient(Bundle ambientDetails)
164      {
165          super.onEnterAmbient(ambientDetails);
166          Log.v(TAG, "onEnterAmbient()");
167          ambientMode =true;
168      }
169
170     @Override
171     public void onExitAmbient()
172     {
173         super.onExitAmbient();
174         Log.v(TAG, "onExitAmbient()");
175         ambientMode = false;
176     }
177
178     @Override
179     public void onUpdateAmbient()
180     {
181         super.onUpdateAmbient();
182         Log.v(TAG, "onUpdateAmbient()");
183     }
184 */
185
186     /**
187      *   ボタンが押された、画面がタッチされた、、は、リスナクラスで処理するよう紐づける
188      *
189      */
190     private void setupActionListener()
191     {
192         try
193         {
194             final ImageButton btn1 = findViewById(R.id.btn_1);
195             btn1.setOnClickListener(listener);
196             btn1.setOnLongClickListener(listener);
197
198             final ImageButton btn2 = findViewById(R.id.btn_2);
199             btn2.setOnClickListener(listener);
200             btn2.setOnLongClickListener(listener);
201
202             final ImageButton btn3 = findViewById(R.id.btn_3);
203             btn3.setOnClickListener(listener);
204             btn3.setOnLongClickListener(listener);
205
206             final ImageButton btn4 = findViewById(R.id.btn_4);
207             btn4.setOnClickListener(listener);
208             btn4.setOnLongClickListener(listener);
209
210             final ImageButton btn5 = findViewById(R.id.btn_5);
211             btn5.setOnClickListener(listener);
212             btn5.setOnLongClickListener(listener);
213
214             final ImageButton btn6 = findViewById(R.id.btn_6);
215             btn6.setOnClickListener(listener);
216             btn6.setOnLongClickListener(listener);
217
218             final TextView textArea1 = findViewById(R.id.text_1);
219             textArea1.setOnClickListener(listener);
220             textArea1.setOnLongClickListener(listener);
221
222             final TextView textArea2 = findViewById(R.id.text_2);
223             textArea2.setOnClickListener(listener);
224             textArea2.setOnLongClickListener(listener);
225
226             final TextView textArea3 = findViewById(R.id.text_3);
227             textArea3.setOnClickListener(listener);
228             textArea3.setOnLongClickListener(listener);
229
230             final TextView textArea4 = findViewById(R.id.text_4);
231             textArea4.setOnClickListener(listener);
232             textArea4.setOnLongClickListener(listener);
233
234             if (liveView == null)
235             {
236                 liveView = findViewById(R.id.liveview);
237             }
238             liveView.setOnTouchListener(listener);
239             messageDrawer = liveView.getMessageDrawer();
240             messageDrawer.setLevelGauge(coordinator.getLevelGauge());
241         }
242         catch (Exception e)
243         {
244             e.printStackTrace();
245         }
246     }
247
248     /**
249      *   ボタンアイコンの初期設定
250      *
251      */
252     private void setupInitialButtonIcons()
253     {
254         try
255         {
256             if (coordinator != null)
257             {
258                 int resId;
259                 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
260                 if (preferences.getBoolean(IPreferenceCameraPropertyAccessor.SHOW_GRID_STATUS, true)) {
261                     // ボタンをGrid OFFアイコンにする
262                     resId = R.drawable.btn_ic_grid_off;
263                 } else {
264                     // ボタンをGrid ONアイコンにする
265                     resId = R.drawable.btn_ic_grid_on;
266                 }
267                 setButtonDrawable(IShowInformation.BUTTON_1, resId);
268             }
269         }
270         catch (Exception e)
271         {
272             e.printStackTrace();
273         }
274     }
275
276     /**
277      *   Intentを使ってWiFi設定画面を開く
278      *
279      */
280     private boolean launchWifiSettingScreen()
281     {
282         Log.v(TAG, "launchWifiSettingScreen()");
283         try
284         {
285             // Wifi 設定画面を表示する... (SONY Smart Watch 3では開かないけど...)
286             startActivity(new Intent("com.google.android.clockwork.settings.connectivity.wifi.ADD_NETWORK_SETTINGS"));
287             return (true);
288         }
289         catch (Exception ex)
290         {
291             try
292             {
293                 Log.v(TAG, "launchWifiSettingScreen() : ACTION_WIFI_SETTINGS");
294                 startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
295                 return (true);
296             }
297             catch (Exception e)
298             {
299                 Log.v(TAG, "android.content.ActivityNotFoundException... " + "com.google.android.clockwork.settings.connectivity.wifi.ADD_NETWORK_SETTINGS");
300                 try
301                 {
302                     // SONY Smart Watch 3で開く場合のIntent...
303                     Intent intent = new Intent("com.google.android.clockwork.settings.connectivity.wifi.ADD_NETWORK_SETTINGS");
304                     intent.setClassName("com.google.android.apps.wearable.settings", "com.google.android.clockwork.settings.wifi.WifiSettingsActivity");
305                     startActivity(intent);
306                     return (true);
307                 }
308                 catch (Exception ex2)
309                 {
310                     try
311                     {
312                         // Wifi 設定画面を表示する...普通のAndroidの場合
313                         startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
314                         return (true);
315                     }
316                     catch (Exception ee)
317                     {
318                         ee.printStackTrace();
319                         try
320                         {
321                             // LG G Watch Rで開く場合のIntent...
322                             Intent intent = new Intent("android.intent.action.MAIN");
323                             intent.setClassName("com.google.android.apps.wearable.settings", "com.google.android.clockwork.settings.MainSettingsActivity");
324                             startActivity(intent);
325                             return (true);
326                         }
327                         catch (android.content.ActivityNotFoundException ex3)
328                         {
329                             ex3.printStackTrace();
330                         }
331                     }
332                 }
333             }
334         }
335         return (false);
336     }
337
338     /**
339      *   Olympus Cameraクラスとのやりとりをするクラスを準備する
340      *   (カメラとの接続も、ここでスレッドを起こして開始する)
341      */
342     private void setupCameraCoordinator()
343     {
344         try
345         {
346             if (liveView == null) {
347                 liveView = findViewById(R.id.liveview);
348             }
349             coordinator = null;
350             coordinator = new OlyCameraCoordinator(this, liveView, this, this);
351             coordinator.setLiveViewListener(new CameraLiveViewListenerImpl(liveView));
352             listener = new OlyCameraLiveViewOnTouchListener(this, new FeatureDispatcher(this, this, coordinator, liveView), this);
353             selectionDialog = new FavoriteSettingSelectionDialog(this, coordinator.getCameraPropertyLoadSaveOperations(), this);
354             connectToCamera();
355         }
356         catch (Exception e)
357         {
358             e.printStackTrace();
359         }
360     }
361
362     /**
363      *   カメラと接続する
364      *
365      */
366     private void connectToCamera()
367     {
368         Thread thread = new Thread(new Runnable()
369         {
370             @Override
371             public void run()
372             {
373                 coordinator.getConnectionInterface().connect();
374             }
375         });
376         try
377         {
378             thread.start();
379         }
380         catch (Exception e)
381         {
382             e.printStackTrace();
383         }
384     }
385
386     /**
387      *   カメラの電源をOFFいして、アプリを抜ける処理
388      *
389      */
390     @Override
391     public void exitApplication()
392     {
393         try
394         {
395             Log.v(TAG, "exitApplication()");
396 /*
397             if (ambientMode)
398             {
399                 // アンビエントモードの時(≒自分でアプリを終了しなかったとき)は、何もしない
400                 // (接続したままとする)
401                 Log.v(TAG, "keep liveview.");
402                 return;
403             }
404 */
405
406             // パワーマネージャを確認し、interactive modeではない場合は、ライブビューも止めず、カメラの電源も切らない
407             if ((powerManager != null) && (!powerManager.isInteractive()))
408             {
409                 Log.v(TAG, "not interactive, keep liveview.");
410                 return;
411             }
412
413             // ライブビューを停止させる
414             coordinator.stopLiveView();
415
416             //  パラメータを確認し、カメラの電源を切る
417             if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IPreferenceCameraPropertyAccessor.EXIT_APPLICATION_WITH_DISCONNECT, true))
418             {
419                 Log.v(TAG, "Shutdown camera...");
420
421                 // カメラの電源をOFFにする
422                 coordinator.getConnectionInterface().disconnect(true);
423             }
424             //finish();
425             //finishAndRemoveTask();
426             //android.os.Process.killProcess(android.os.Process.myPid());
427         }
428         catch (Exception e)
429         {
430             e.printStackTrace();
431         }
432     }
433
434     /**
435      *   接続機能を確認する
436      */
437     @Override
438     public boolean checkConnectionFeature(int id)
439     {
440         boolean ret = false;
441         if (id == 0)
442         {
443             // Wifi 設定画面を開く
444             ret = launchWifiSettingScreen();
445         }
446         return (ret);
447     }
448
449     /**
450      *   画面をタッチした場所を受信する
451      *
452      * @param posX  X座標位置 (0.0f - 1.0f)
453      * @param posY  Y座標位置 (0.0f - 1.0f)
454      * @return true / false
455      */
456     @Override
457     public boolean touchedPosition(float posX, float posY)
458     {
459         Log.v(TAG, "touchedPosition (" + posX + ", " + posY);
460         return ((liveView != null)&&(liveView.touchedPosition(posX, posY)));
461     }
462
463     /**
464      *   接続状態を見る or 再接続する
465      */
466     @Override
467     public boolean showConnectionStatus()
468     {
469         try
470         {
471             if ((listener.isEnabledOperation() == IShowInformation.operation.ONLY_CONNECT) && (cameraDisconnectedHappened)) {
472                 // カメラが切断されたとき、再接続を指示する
473                 connectToCamera();
474                 cameraDisconnectedHappened = false;
475                 return (true);
476             }
477         }
478         catch (Exception e)
479         {
480             e.printStackTrace();
481         }
482         return (false);
483     }
484
485     /**
486      *
487      */
488     @Override
489     public void onStatusNotify(String message)
490     {
491         setMessage(IShowInformation.AREA_C, Color.WHITE, message);
492     }
493
494     /**
495      *
496      */
497     @Override
498     public void onCameraConnected()
499     {
500         Log.v(TAG, "onCameraConnected()");
501         try
502         {
503             // ライブビューの開始 & タッチ/ボタンの操作を可能にする
504             coordinator.startLiveView();
505             coordinator.setRecViewMode(false);
506             listener.setEnableOperation(operation.ENABLE);
507             setMessage(IShowInformation.AREA_C, Color.WHITE, "");
508             coordinator.updateStatusAll();
509         }
510         catch (Exception e)
511         {
512             e.printStackTrace();
513         }
514     }
515
516     /**
517      *   カメラとの接続が切れたとき...何もしない
518      *
519      */
520     @Override
521     public void onCameraDisconnected()
522     {
523         Log.v(TAG, "onCameraDisconnected()");
524         try
525         {
526             setMessage(IShowInformation.AREA_C, Color.YELLOW, getString(R.string.camera_disconnected));
527             listener.setEnableOperation(operation.ONLY_CONNECT);
528             cameraDisconnectedHappened = true;
529         }
530         catch (Exception e)
531         {
532             e.printStackTrace();
533         }
534     }
535
536     /**
537      *  カメラに例外発生
538      */
539     @Override
540     public void onCameraOccursException(String message, Exception e)
541     {
542         Log.v(TAG, "onCameraOccursException()");
543         try
544         {
545             setMessage(IShowInformation.AREA_C, Color.YELLOW, message);
546             listener.setEnableOperation(operation.ONLY_CONNECT);
547             cameraDisconnectedHappened = true;
548         }
549         catch (Exception ee)
550         {
551             e.printStackTrace();
552             ee.printStackTrace();
553         }
554     }
555
556     /**s
557      *   メッセージの表示
558      *
559      * @param area    表示エリア (AREA_1 ~ AREA_6, AREA_C)
560      * @param color  表示色
561      * @param message 表示するメッセージ
562      */
563     @Override
564     public void setMessage(final int area, final int color, final String message)
565     {
566         int id = 0;
567         switch (area)
568         {
569             case IShowInformation.AREA_1:
570                 id = R.id.text_1;
571                 break;
572             case IShowInformation.AREA_2:
573                 id = R.id.text_2;
574                 break;
575             case IShowInformation.AREA_3:
576                 id = R.id.text_3;
577                 break;
578             case IShowInformation.AREA_4:
579                 id = R.id.text_4;
580                 break;
581             case IShowInformation.AREA_NONE:
582             default:
583                 // unknown
584                 break;
585         }
586         if (messageDrawer != null)
587         {
588             if (area == IShowInformation.AREA_C)
589             {
590                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.CENTER, color, IMessageDrawer.SIZE_LARGE, message);
591                 return;
592             }
593             if (area == IShowInformation.AREA_5)
594             {
595                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.UPLEFT, color, IMessageDrawer.SIZE_STD, message);
596                 return;
597             }
598             if (area == IShowInformation.AREA_6)
599             {
600                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.LOWLEFT, color, IMessageDrawer.SIZE_STD, message);
601                 return;
602             }
603             if (area == IShowInformation.AREA_7)
604             {
605                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.UPRIGHT, color, IMessageDrawer.SIZE_STD, message);
606                 return;
607             }
608             if (area == IShowInformation.AREA_8)
609             {
610                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.LOWRIGHT, color, IMessageDrawer.SIZE_STD, message);
611                 return;
612             }
613             if (area == IShowInformation.AREA_9)
614             {
615                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.UPCENTER, color, IMessageDrawer.SIZE_STD, message);
616                 return;
617             }
618             if (area == IShowInformation.AREA_A)
619             {
620                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.LOWCENTER, color, IMessageDrawer.SIZE_STD, message);
621                 return;
622             }
623             if (area == IShowInformation.AREA_B)
624             {
625                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.CENTERLEFT, color, IMessageDrawer.SIZE_STD, message);
626                 return;
627             }
628             if (area == IShowInformation.AREA_D)
629             {
630                 messageDrawer.setMessageToShow(IMessageDrawer.MessageArea.CENTERRIGHT, color, IMessageDrawer.SIZE_STD, message);
631                 return;
632             }
633
634             if (id == 0)
635             {
636                 // 描画エリアが不定の場合...
637                 return;
638             }
639         }
640
641         final int areaId = id;
642         runOnUiThread(new Runnable()
643         {
644              @Override
645              public void run()
646              {
647                  final TextView textArea = findViewById(areaId);
648                  if (textArea != null)
649                  {
650                      textArea.setTextColor(color);
651                      textArea.setText(message);
652                      textArea.invalidate();
653                  }
654              }
655         });
656     }
657
658     /**
659      *   ボタンの表示イメージを変更する
660      *
661      * @param button  ボタンの場所
662      * @param labelId 変更する内容
663      */
664     @Override
665     public void setButtonDrawable(final int button, final int labelId)
666     {
667         int id;
668         switch (button)
669         {
670             case IShowInformation.BUTTON_1:
671                 id = R.id.btn_1;
672                 break;
673             case IShowInformation.BUTTON_2:
674                 id = R.id.btn_2;
675                 break;
676             case IShowInformation.BUTTON_3:
677                 id = R.id.btn_3;
678                 break;
679             case IShowInformation.BUTTON_4:
680                 id = R.id.btn_4;
681                 break;
682             case IShowInformation.BUTTON_5:
683                 id = R.id.btn_5;
684                 break;
685             case IShowInformation.BUTTON_6:
686             default:
687                 id = R.id.btn_6;
688                 break;
689         }
690
691         final int areaId = id;
692         runOnUiThread(new Runnable()
693         {
694             @Override
695             public void run()
696             {
697                 try
698                 {
699                     final ImageButton button = findViewById(areaId);
700                     final Drawable drawTarget = ContextCompat.getDrawable(getApplicationContext(), labelId);
701                     if (button != null)
702                     {
703                         button.setImageDrawable(drawTarget);
704                         button.invalidate();
705                     }
706                 }
707                 catch (Exception e)
708                 {
709                     e.printStackTrace();
710                 }
711             }
712         });
713     }
714
715     /**
716      *
717      * @return true GPS搭載, false GPS非搭載
718      */
719     private boolean hasGps()
720     {
721         return (getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS));
722     }
723
724     /**
725      *
726      *
727      */
728     @Override
729     public void vibrate(final int vibratePattern)
730     {
731         try
732         {
733             if ((vibrator == null)||(!vibrator.hasVibrator()))
734             {
735                 return;
736             }
737
738             Thread thread = new Thread(new Runnable() {
739                 @Override
740                 public void run() {
741                     switch (vibratePattern)
742                     {
743                         case IShowInformation.VIBRATE_PATTERN_SIMPLE_LONGLONG:
744                             vibrator.vibrate(300);
745                             break;
746                         case IShowInformation.VIBRATE_PATTERN_SIMPLE_LONG:
747                             vibrator.vibrate(150);
748                             break;
749                         case IShowInformation.VIBRATE_PATTERN_SIMPLE_MIDDLE:
750                             vibrator.vibrate(80);
751                             break;
752                         case IShowInformation.VIBRATE_PATTERN_SIMPLE_SHORT:
753                             vibrator.vibrate(30);
754                             break;
755                         case IShowInformation.VIBRATE_PATTERN_SHORT_DOUBLE:
756                             long[] pattern = { 10, 35, 30, 35, 0 };
757                             vibrator.vibrate(pattern, -1);
758                             break;
759                         case IShowInformation.VIBRATE_PATTERN_NONE:
760                         default:
761                             // ぶるぶるしない
762                             break;
763                     }
764                 }
765             });
766             thread.start();
767         }
768         catch (Exception e)
769         {
770             e.printStackTrace();
771         }
772     }
773
774     @Override
775     public void setEnabledOperation(IShowInformation.operation operation)
776     {
777         if (listener != null)
778         {
779             listener.setEnableOperation(operation);
780         }
781     }
782
783     /**
784      *   「お気に入り設定」表示画面を開く
785      *
786      */
787     @Override
788     public void showFavoriteSettingsDialog()
789     {
790         if ((liveView != null)&&(listener != null)&&(listener.isEnabledOperation() != operation.ONLY_CONNECT))
791         {
792             listener.setEnableOperation(operation.ENABLE_ONLY_TOUCHED_POSITION);
793             liveView.showDialog(selectionDialog);
794         }
795     }
796
797     /**
798      *   「お気に入り設定」表示画面を閉じる
799      *
800      */
801     @Override
802     public void dialogDismissed(boolean isExecuted)
803     {
804         try
805         {
806             if ((liveView != null) && (listener != null))
807             {
808                 liveView.hideDialog();
809                 listener.setEnableOperation(operation.ENABLE);
810
811             }
812         }
813         catch (Exception e)
814         {
815             e.printStackTrace();
816         }
817     }
818 }