OSDN Git Service

Visionkids で、カメラIPアドレスを自動で設定できるようにした。
[gokigen/PKRemote.git] / app / src / main / java / net / osdn / gokigen / pkremote / preference / olympus / OpcPreferenceFragment.java
1 package net.osdn.gokigen.pkremote.preference.olympus;
2
3
4 import android.app.ProgressDialog;
5 import android.content.Context;
6 import android.content.Intent;
7 import android.content.SharedPreferences;
8 import android.os.Bundle;
9 import android.provider.Settings;
10 import android.util.Log;
11
12 import net.osdn.gokigen.pkremote.R;
13 import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider;
14 import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode;
15 import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus;
16 import net.osdn.gokigen.pkremote.camera.vendor.olympus.operation.CameraPowerOff;
17 import net.osdn.gokigen.pkremote.camera.vendor.olympus.wrapper.property.IOlyCameraProperty;
18 import net.osdn.gokigen.pkremote.camera.vendor.olympus.wrapper.property.IOlyCameraPropertyProvider;
19 import net.osdn.gokigen.pkremote.logcat.LogCatViewer;
20 import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor;
21 import net.osdn.gokigen.pkremote.scene.IChangeScene;
22
23 import java.util.HashMap;
24 import java.util.Locale;
25 import java.util.Map;
26
27 import androidx.annotation.NonNull;
28 import androidx.appcompat.app.AppCompatActivity;
29 import androidx.fragment.app.FragmentActivity;
30 import androidx.preference.CheckBoxPreference;
31 import androidx.preference.ListPreference;
32 import androidx.preference.Preference;
33 import androidx.preference.PreferenceFragmentCompat;
34 import androidx.preference.PreferenceManager;
35 import jp.co.olympus.camerakit.OLYCamera;
36
37 import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.DEBUG_INFO;
38 import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.EXIT_APPLICATION;
39 import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.WIFI_SETTINGS;
40
41 /**
42  *   SettingFragment
43  *
44  */
45 public class OpcPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, OpcPreferenceSynchronizer.IPropertySynchronizeCallback, Preference.OnPreferenceClickListener
46 {
47     private final String TAG = toString();
48     private AppCompatActivity context = null;
49     private IOlyCameraPropertyProvider propertyInterface = null;
50     private ICameraHardwareStatus hardwareStatusInterface = null;
51     private ICameraRunMode changeRunModeExecutor = null;
52     private CameraPowerOff powerOffController = null;
53     private LogCatViewer logCatViewer = null;
54     private SharedPreferences preferences = null;
55     private ProgressDialog busyDialog = null;
56     private OpcPreferenceSynchronizer opcPreferenceSynchronizer = null;
57
58
59     public static OpcPreferenceFragment newInstance(@NonNull AppCompatActivity context, @NonNull IInterfaceProvider factory, @NonNull IChangeScene changeScene)
60     {
61         OpcPreferenceFragment instance = new OpcPreferenceFragment();
62         instance.setInterface(context, factory, changeScene);
63
64         // パラメータはBundleにまとめておく
65         Bundle arguments = new Bundle();
66         //arguments.putString("title", title);
67         //arguments.putString("message", message);
68         instance.setArguments(arguments);
69
70         return (instance);
71     }
72
73     /**
74      *
75      *
76      */
77     private void setInterface(@NonNull AppCompatActivity context, @NonNull IInterfaceProvider factory, @NonNull IChangeScene changeScene)
78     {
79         Log.v(TAG, "setInterface()");
80         this.propertyInterface = factory.getOlympusInterfaceProvider().getCameraPropertyProvider();
81         this.changeRunModeExecutor = factory.getCameraRunMode();
82         hardwareStatusInterface = factory.getHardwareStatus();
83         powerOffController = new CameraPowerOff(context, changeScene);
84         powerOffController.prepare();
85         logCatViewer = new LogCatViewer(changeScene);
86         logCatViewer.prepare();
87
88         this.context = context;
89     }
90
91     /**
92      *
93      *
94      */
95     @Override
96     public void onAttach(Context activity)
97     {
98         super.onAttach(activity);
99         Log.v(TAG, "onAttach()");
100
101         // Preference をつかまえる
102         preferences = PreferenceManager.getDefaultSharedPreferences(activity);
103         if (opcPreferenceSynchronizer == null)
104         {
105             opcPreferenceSynchronizer = new OpcPreferenceSynchronizer(this.propertyInterface, preferences, this);
106         }
107
108         // Preference を初期設定する
109         initializePreferences();
110
111         preferences.registerOnSharedPreferenceChangeListener(this);
112     }
113
114     /**
115      * Preferenceの初期化...
116      */
117     private void initializePreferences()
118     {
119         Map<String, ?> items = preferences.getAll();
120         SharedPreferences.Editor editor = preferences.edit();
121
122         if (!items.containsKey(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY))
123         {
124             editor.putString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE);
125         }
126         if (!items.containsKey(IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL))
127         {
128             editor.putString(IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL, IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL_DEFAULT_VALUE);
129         }
130         if (!items.containsKey(IPreferencePropertyAccessor.RAW))
131         {
132             editor.putBoolean(IPreferencePropertyAccessor.RAW, true);
133         }
134         if (!items.containsKey(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA))
135         {
136             editor.putBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
137         }
138         if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW))
139         {
140             editor.putBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true);
141         }
142         if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD))
143         {
144             editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE);
145         }
146         if (!items.containsKey(IPreferencePropertyAccessor.SHARE_AFTER_SAVE)) {
147             editor.putBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
148         }
149         if (!items.containsKey(IPreferencePropertyAccessor.USE_PLAYBACK_MENU)) {
150             editor.putBoolean(IPreferencePropertyAccessor.USE_PLAYBACK_MENU, true);
151         }
152         if (!items.containsKey(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW)) {
153             editor.putBoolean(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, true);
154         }
155         if (!items.containsKey(IPreferencePropertyAccessor.GR2_LCD_SLEEP)) {
156             editor.putBoolean(IPreferencePropertyAccessor.GR2_LCD_SLEEP, false);
157         }
158         if (!items.containsKey(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND)) {
159             editor.putBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
160         }
161         if (!items.containsKey(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF)) {
162             editor.putBoolean(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF, false);
163         }
164         if (!items.containsKey(IPreferencePropertyAccessor.SMALL_PICTURE_SIZE)) {
165             editor.putString(IPreferencePropertyAccessor.SMALL_PICTURE_SIZE, IPreferencePropertyAccessor.SMALL_PICTURE_SIZE_DEFAULT_VALUE);
166         }
167         if (!items.containsKey(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE)) {
168             editor.putString(IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE, IPreferencePropertyAccessor.PEN_SMALL_PICTURE_SIZE_DEFAULT_VALUE);
169         }
170         if (!items.containsKey(IPreferencePropertyAccessor.GET_SMALL_PICTURE_AS_VGA))
171         {
172             editor.putBoolean(IPreferencePropertyAccessor.GET_SMALL_PICTURE_AS_VGA, false);
173         }
174         if (!items.containsKey(IPreferencePropertyAccessor.USE_SMARTPHONE_TRANSFER_MODE))
175         {
176             editor.putBoolean(IPreferencePropertyAccessor.USE_SMARTPHONE_TRANSFER_MODE, false);
177         }
178         if (!items.containsKey(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT))
179         {
180             editor.putString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE);
181         }
182         if (!items.containsKey(IPreferencePropertyAccessor.USE_OSC_THETA_V21))
183         {
184             editor.putBoolean(IPreferencePropertyAccessor.USE_OSC_THETA_V21, false);
185         }
186         if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_HOST_IP))
187         {
188             editor.putString(IPreferencePropertyAccessor.PIXPRO_HOST_IP, IPreferencePropertyAccessor.PIXPRO_HOST_IP_DEFAULT_VALUE);
189         }
190         if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT))
191         {
192             editor.putString(IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT, IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT_DEFAULT_VALUE);
193         }
194         if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT))
195         {
196             editor.putString(IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.PIXPRO_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE);
197         }
198         if (!items.containsKey(IPreferencePropertyAccessor.THUMBNAIL_IMAGE_CACHE_SIZE))
199         {
200             editor.putString(IPreferencePropertyAccessor.THUMBNAIL_IMAGE_CACHE_SIZE, IPreferencePropertyAccessor.THUMBNAIL_IMAGE_CACHE_SIZE_DEFAULT_VALUE);
201         }
202         if (!items.containsKey(IPreferencePropertyAccessor.CANON_HOST_IP)) {
203             editor.putString(IPreferencePropertyAccessor.CANON_HOST_IP, IPreferencePropertyAccessor.CANON_HOST_IP_DEFAULT_VALUE);
204         }
205         if (!items.containsKey(IPreferencePropertyAccessor.CANON_CONNECTION_SEQUENCE)) {
206             editor.putString(IPreferencePropertyAccessor.CANON_CONNECTION_SEQUENCE, IPreferencePropertyAccessor.CANON_CONNECTION_SEQUENCE_DEFAULT_VALUE);
207         }
208         if (!items.containsKey(IPreferencePropertyAccessor.CANON_SMALL_PICTURE_TYPE)) {
209             editor.putString(IPreferencePropertyAccessor.CANON_SMALL_PICTURE_TYPE, IPreferencePropertyAccessor.CANON_SMALL_PICTURE_TYPE_DEFAULT_VALUE);
210         }
211         if (!items.containsKey(IPreferencePropertyAccessor.VISIONKIDS_HOST_IP)) {
212             editor.putString(IPreferencePropertyAccessor.VISIONKIDS_HOST_IP, IPreferencePropertyAccessor.VISIONKIDS_HOST_IP_DEFAULT_VALUE);
213         }
214         if (!items.containsKey(IPreferencePropertyAccessor.VISIONKIDS_FTP_USER)) {
215             editor.putString(IPreferencePropertyAccessor.VISIONKIDS_FTP_USER, IPreferencePropertyAccessor.VISIONKIDS_FTP_USER_DEFAULT_VALUE);
216         }
217         if (!items.containsKey(IPreferencePropertyAccessor.VISIONKIDS_FTP_PASS)) {
218             editor.putString(IPreferencePropertyAccessor.VISIONKIDS_FTP_PASS, IPreferencePropertyAccessor.VISIONKIDS_FTP_PASS_DEFAULT_VALUE);
219         }
220         if (!items.containsKey(IPreferencePropertyAccessor.VISIONKIDS_LIST_TIMEOUT)) {
221             editor.putString(IPreferencePropertyAccessor.VISIONKIDS_LIST_TIMEOUT, IPreferencePropertyAccessor.VISIONKIDS_LIST_TIMEOUT_DEFAULT_VALUE);
222         }
223         if (!items.containsKey(IPreferencePropertyAccessor.VISIONKIDS_AUTO_SET_HOST_IP))
224         {
225             editor.putBoolean(IPreferencePropertyAccessor.VISIONKIDS_AUTO_SET_HOST_IP, true);
226         }
227         editor.apply();
228     }
229
230     /**
231      *
232      *
233      */
234     @Override
235     public void onCreatePreferences(Bundle savedInstanceState, String rootKey)
236     {
237         Log.v(TAG, "onCreatePreferences()");
238
239         //super.onCreate(savedInstanceState);
240         addPreferencesFromResource(R.xml.preferences_opc);
241
242         {
243             final HashMap<String, String> sizeTable = new HashMap<>();
244             sizeTable.put("QVGA", "(320x240)");
245             sizeTable.put("VGA", "(640x480)");
246             sizeTable.put("SVGA", "(800x600)");
247             sizeTable.put("XGA", "(1024x768)");
248             sizeTable.put("QUAD_VGA", "(1280x960)");
249
250             ListPreference liveViewQuality = (ListPreference) findPreference(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY);
251             liveViewQuality.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
252                 @Override
253                 public boolean onPreferenceChange(Preference preference, Object newValue) {
254                     String key = (String) newValue;
255                     preference.setSummary(newValue + " " + sizeTable.get(key));
256                     return (true);
257                 }
258             });
259             liveViewQuality.setSummary(liveViewQuality.getValue() + " " + sizeTable.get(liveViewQuality.getValue()));
260
261             ListPreference connectionMethod = (ListPreference) findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD);
262             connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
263                 @Override
264                 public boolean onPreferenceChange(Preference preference, Object newValue) {
265                     preference.setSummary(newValue + " ");
266                     return (true);
267                 }
268             });
269             connectionMethod.setSummary(connectionMethod.getValue() + " ");
270
271             ListPreference smallPictureSize = (ListPreference) findPreference(IPreferencePropertyAccessor.SMALL_PICTURE_SIZE);
272             smallPictureSize.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
273                 @Override
274                 public boolean onPreferenceChange(Preference preference, Object newValue) {
275                     preference.setSummary(newValue + " ");
276                     return (true);
277                 }
278             });
279             smallPictureSize.setSummary(smallPictureSize.getValue() + " ");
280         }
281         findPreference(EXIT_APPLICATION).setOnPreferenceClickListener(powerOffController);
282         findPreference(DEBUG_INFO).setOnPreferenceClickListener(logCatViewer);
283         findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
284     }
285
286     /**
287      * ハードウェアのサマリ情報を取得し設定する
288      */
289     private void setHardwareSummary()
290     {
291         // レンズ状態
292         findPreference("lens_status").setSummary(hardwareStatusInterface.getLensMountStatus());
293
294         // メディア状態
295         findPreference("media_status").setSummary(hardwareStatusInterface.getMediaMountStatus());
296
297         // 焦点距離
298         String focalLength;
299         float minLength = hardwareStatusInterface.getMinimumFocalLength();
300         float maxLength = hardwareStatusInterface.getMaximumFocalLength();
301         float actualLength = hardwareStatusInterface.getActualFocalLength();
302         if (minLength == maxLength)
303         {
304             focalLength = String.format(Locale.ENGLISH, "%3.0fmm", actualLength);
305         }
306         else
307         {
308             focalLength = String.format(Locale.ENGLISH, "%3.0fmm - %3.0fmm (%3.0fmm)", minLength, maxLength, actualLength);
309         }
310         findPreference("focal_length").setSummary(focalLength);
311
312         // カメラのバージョン
313         try
314         {
315             Map<String, Object> hardwareInformation = hardwareStatusInterface.inquireHardwareInformation();
316             findPreference("camera_version").setSummary((String) hardwareInformation.get(OLYCamera.HARDWARE_INFORMATION_CAMERA_FIRMWARE_VERSION_KEY));
317
318             // 取得した一覧はログに出力する。)
319             Log.v(TAG, "- - - - - - - - - -");
320             for (Map.Entry<String, Object> entry : hardwareInformation.entrySet())
321             {
322                 String value = (String) entry.getValue();
323                 Log.v(TAG, entry.getKey() + " : " + value);
324             }
325             Log.v(TAG, "- - - - - - - - - -");
326         }
327         catch (Exception e)
328         {
329             findPreference("camera_version").setSummary("Unknown");
330             e.printStackTrace();
331         }
332     }
333
334     /**
335      *
336      *
337      */
338     private void setCameraProperty(String name, String value)
339     {
340         try
341         {
342             String propertyValue = "<" + name + "/" + value + ">";
343             Log.v(TAG, "setCameraProperty() : " + propertyValue);
344             propertyInterface.setCameraPropertyValue(name, propertyValue);
345         }
346         catch (Exception e)
347         {
348             e.printStackTrace();
349         }
350     }
351
352     /**
353      *
354      *
355      */
356     @Override
357     public void onResume()
358     {
359         super.onResume();
360         Log.v(TAG, "onResume() Start");
361
362         // 撮影モードかどうかを確認して、撮影モードではなかったら撮影モードに切り替える
363         if ((changeRunModeExecutor != null) && (!changeRunModeExecutor.isRecordingMode()))
364         {
365             // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。
366             changeRunModeExecutor.changeRunMode(true);
367         }
368         synchronizeCameraProperties(true);
369         Log.v(TAG, "onResume() End");
370
371     }
372
373     /**
374      *
375      *
376      */
377     @Override
378     public void onPause()
379     {
380         super.onPause();
381         Log.v(TAG, "onPause() Start");
382
383         // Preference変更のリスナを解除
384         preferences.unregisterOnSharedPreferenceChangeListener(this);
385
386         Log.v(TAG, "onPause() End");
387     }
388
389     /**
390      * カメラプロパティとPreferenceとの同期処理を実行
391      */
392     private void synchronizeCameraProperties(boolean isPropertyLoad)
393     {
394         // 実行中ダイアログを取得する
395         busyDialog = new ProgressDialog(getActivity());
396         busyDialog.setTitle(getString(R.string.dialog_title_loading_properties));
397         busyDialog.setMessage(getString(R.string.dialog_message_loading_properties));
398         busyDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
399         busyDialog.setCancelable(false);
400         busyDialog.show();
401
402         // データ読み込み処理(別スレッドで実行)
403         if (isPropertyLoad)
404         {
405             new Thread(opcPreferenceSynchronizer).start();
406         }
407     }
408
409     /**
410      * Preferenceが更新された時に呼び出される処理
411      *
412      * @param sharedPreferences sharedPreferences
413      * @param key               変更されたキー
414      */
415     @Override
416     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
417     {
418         Log.v(TAG, "onSharedPreferenceChanged() : " + key);
419         String propertyValue;
420         boolean value;
421         if (key != null)
422         {
423             switch (key)
424             {
425                 case IPreferencePropertyAccessor.RAW:
426                     value = preferences.getBoolean(key, true);
427                     setBooleanPreference(key, key, value);
428                     propertyValue = (value) ? "ON" : "OFF";
429                     setCameraProperty(IOlyCameraProperty.RAW, propertyValue);
430                     break;
431
432                 case IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA:
433                     value = preferences.getBoolean(key, true);
434                     Log.v(TAG, " " + key + " , " + value);
435                     break;
436
437                 case IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW:
438                     value = preferences.getBoolean(key, true);
439                     Log.v(TAG, " " + key + " , " + value);
440                     break;
441
442                 case IPreferencePropertyAccessor.SHARE_AFTER_SAVE:
443                     value = preferences.getBoolean(key, false);
444                     Log.v(TAG, " " + key + " , " + value);
445                     break;
446
447                 case IPreferencePropertyAccessor.USE_PLAYBACK_MENU:
448                     value = preferences.getBoolean(key, true);
449                     Log.v(TAG, " " + key + " , " + value);
450                     break;
451
452                 default:
453                     String strValue = preferences.getString(key, "");
454                     setListPreference(key, key, strValue);
455                     String propertyKey = convertKeyFromPreferenceToCameraPropertyKey(key);
456                     if (propertyKey != null)
457                     {
458                         setCameraProperty(propertyKey, strValue);
459                     }
460                     break;
461             }
462         }
463     }
464
465     /**
466      * ListPreference の表示データを設定
467      *
468      * @param pref_key     Preference(表示)のキー
469      * @param key          Preference(データ)のキー
470      * @param defaultValue Preferenceのデフォルト値
471      */
472     private void setListPreference(String pref_key, String key, String defaultValue)
473     {
474         ListPreference pref;
475         pref = (ListPreference) findPreference(pref_key);
476         String value = preferences.getString(key, defaultValue);
477         if (pref != null)
478         {
479             pref.setValue(value);
480             pref.setSummary(value);
481         }
482     }
483
484     /**
485      * BooleanPreference の表示データを設定
486      *
487      * @param pref_key     Preference(表示)のキー
488      * @param key          Preference(データ)のキー
489      * @param defaultValue Preferenceのデフォルト値
490      */
491     private void setBooleanPreference(String pref_key, String key, boolean defaultValue)
492     {
493         CheckBoxPreference pref = (CheckBoxPreference) findPreference(pref_key);
494         if (pref != null)
495         {
496             boolean value = preferences.getBoolean(key, defaultValue);
497             pref.setChecked(value);
498         }
499     }
500
501     /**
502      *
503      *
504      */
505     private String convertKeyFromPreferenceToCameraPropertyKey(String key)
506     {
507         String target = null;
508         if (key == null)
509         {
510             return (null);
511         }
512         switch (key)
513         {
514             case IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL:
515                 target = IOlyCameraProperty.SOUND_VOLUME_LEVEL;
516                 break;
517
518             default:
519                 // target == null
520                 break;
521         }
522         return (target);
523     }
524
525     /**
526      * カメラプロパティの同期処理終了通知
527      */
528     @Override
529     public void synchronizedProperty()
530     {
531         FragmentActivity activity = getActivity();
532         if (activity == null)
533         {
534             try
535             {
536                 busyDialog.dismiss();
537                 busyDialog = null;
538             }
539             catch (Exception e)
540             {
541                 e.printStackTrace();
542             }
543             return;
544         }
545         activity.runOnUiThread(new Runnable() {
546             @Override
547             public void run() {
548                 try {
549                     // Preferenceの画面に反映させる
550                     setListPreference(IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL, IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL, IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL_DEFAULT_VALUE);
551                     setBooleanPreference(IPreferencePropertyAccessor.RAW, IPreferencePropertyAccessor.RAW, true);
552                     setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
553                     setBooleanPreference(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
554
555                     // カメラキットのバージョン
556                     findPreference(IPreferencePropertyAccessor.CAMERAKIT_VERSION).setSummary(OLYCamera.getVersion());
557                     if (hardwareStatusInterface != null)
558                     {
559                         // その他のハードウェア情報の情報設定
560                         setHardwareSummary();
561                     }
562
563                     // 実行中ダイアログを消す
564                     busyDialog.dismiss();
565                     busyDialog = null;
566                 }
567                 catch (Exception e)
568                 {
569                     e.printStackTrace();
570                 }
571             }
572         });
573     }
574
575     @Override
576     public boolean onPreferenceClick(Preference preference)
577     {
578         try
579         {
580             String preferenceKey = preference.getKey();
581             if (preferenceKey.contains(WIFI_SETTINGS))
582             {
583                 // Wifi 設定画面を表示する
584                 Log.v(TAG, " onPreferenceClick : " + preferenceKey);
585                 if (context != null)
586                 {
587                     context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
588                 }
589             }
590             return (true);
591         }
592         catch (Exception e)
593         {
594             e.printStackTrace();
595         }
596         return (false);
597     }
598 }