OSDN Git Service

とりあえず、Power Shot Zoomから画像をダウンロードできるところまで。
[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         editor.apply();
209     }
210
211     /**
212      *
213      *
214      */
215     @Override
216     public void onCreatePreferences(Bundle savedInstanceState, String rootKey)
217     {
218         Log.v(TAG, "onCreatePreferences()");
219
220         //super.onCreate(savedInstanceState);
221         addPreferencesFromResource(R.xml.preferences_opc);
222
223         {
224             final HashMap<String, String> sizeTable = new HashMap<>();
225             sizeTable.put("QVGA", "(320x240)");
226             sizeTable.put("VGA", "(640x480)");
227             sizeTable.put("SVGA", "(800x600)");
228             sizeTable.put("XGA", "(1024x768)");
229             sizeTable.put("QUAD_VGA", "(1280x960)");
230
231             ListPreference liveViewQuality = (ListPreference) findPreference(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY);
232             liveViewQuality.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
233                 @Override
234                 public boolean onPreferenceChange(Preference preference, Object newValue) {
235                     String key = (String) newValue;
236                     preference.setSummary(newValue + " " + sizeTable.get(key));
237                     return (true);
238                 }
239             });
240             liveViewQuality.setSummary(liveViewQuality.getValue() + " " + sizeTable.get(liveViewQuality.getValue()));
241
242             ListPreference connectionMethod = (ListPreference) findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD);
243             connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
244                 @Override
245                 public boolean onPreferenceChange(Preference preference, Object newValue) {
246                     preference.setSummary(newValue + " ");
247                     return (true);
248                 }
249             });
250             connectionMethod.setSummary(connectionMethod.getValue() + " ");
251
252             ListPreference smallPictureSize = (ListPreference) findPreference(IPreferencePropertyAccessor.SMALL_PICTURE_SIZE);
253             smallPictureSize.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
254                 @Override
255                 public boolean onPreferenceChange(Preference preference, Object newValue) {
256                     preference.setSummary(newValue + " ");
257                     return (true);
258                 }
259             });
260             smallPictureSize.setSummary(smallPictureSize.getValue() + " ");
261         }
262         findPreference(EXIT_APPLICATION).setOnPreferenceClickListener(powerOffController);
263         findPreference(DEBUG_INFO).setOnPreferenceClickListener(logCatViewer);
264         findPreference(WIFI_SETTINGS).setOnPreferenceClickListener(this);
265     }
266
267     /**
268      * ハードウェアのサマリ情報を取得し設定する
269      */
270     private void setHardwareSummary()
271     {
272         // レンズ状態
273         findPreference("lens_status").setSummary(hardwareStatusInterface.getLensMountStatus());
274
275         // メディア状態
276         findPreference("media_status").setSummary(hardwareStatusInterface.getMediaMountStatus());
277
278         // 焦点距離
279         String focalLength;
280         float minLength = hardwareStatusInterface.getMinimumFocalLength();
281         float maxLength = hardwareStatusInterface.getMaximumFocalLength();
282         float actualLength = hardwareStatusInterface.getActualFocalLength();
283         if (minLength == maxLength)
284         {
285             focalLength = String.format(Locale.ENGLISH, "%3.0fmm", actualLength);
286         }
287         else
288         {
289             focalLength = String.format(Locale.ENGLISH, "%3.0fmm - %3.0fmm (%3.0fmm)", minLength, maxLength, actualLength);
290         }
291         findPreference("focal_length").setSummary(focalLength);
292
293         // カメラのバージョン
294         try
295         {
296             Map<String, Object> hardwareInformation = hardwareStatusInterface.inquireHardwareInformation();
297             findPreference("camera_version").setSummary((String) hardwareInformation.get(OLYCamera.HARDWARE_INFORMATION_CAMERA_FIRMWARE_VERSION_KEY));
298
299             // 取得した一覧はログに出力する。)
300             Log.v(TAG, "- - - - - - - - - -");
301             for (Map.Entry<String, Object> entry : hardwareInformation.entrySet())
302             {
303                 String value = (String) entry.getValue();
304                 Log.v(TAG, entry.getKey() + " : " + value);
305             }
306             Log.v(TAG, "- - - - - - - - - -");
307         }
308         catch (Exception e)
309         {
310             findPreference("camera_version").setSummary("Unknown");
311             e.printStackTrace();
312         }
313     }
314
315     /**
316      *
317      *
318      */
319     private void setCameraProperty(String name, String value)
320     {
321         try
322         {
323             String propertyValue = "<" + name + "/" + value + ">";
324             Log.v(TAG, "setCameraProperty() : " + propertyValue);
325             propertyInterface.setCameraPropertyValue(name, propertyValue);
326         }
327         catch (Exception e)
328         {
329             e.printStackTrace();
330         }
331     }
332
333     /**
334      *
335      *
336      */
337     @Override
338     public void onResume()
339     {
340         super.onResume();
341         Log.v(TAG, "onResume() Start");
342
343         // 撮影モードかどうかを確認して、撮影モードではなかったら撮影モードに切り替える
344         if ((changeRunModeExecutor != null) && (!changeRunModeExecutor.isRecordingMode()))
345         {
346             // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。
347             changeRunModeExecutor.changeRunMode(true);
348         }
349         synchronizeCameraProperties(true);
350         Log.v(TAG, "onResume() End");
351
352     }
353
354     /**
355      *
356      *
357      */
358     @Override
359     public void onPause()
360     {
361         super.onPause();
362         Log.v(TAG, "onPause() Start");
363
364         // Preference変更のリスナを解除
365         preferences.unregisterOnSharedPreferenceChangeListener(this);
366
367         Log.v(TAG, "onPause() End");
368     }
369
370     /**
371      * カメラプロパティとPreferenceとの同期処理を実行
372      */
373     private void synchronizeCameraProperties(boolean isPropertyLoad)
374     {
375         // 実行中ダイアログを取得する
376         busyDialog = new ProgressDialog(getActivity());
377         busyDialog.setTitle(getString(R.string.dialog_title_loading_properties));
378         busyDialog.setMessage(getString(R.string.dialog_message_loading_properties));
379         busyDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
380         busyDialog.setCancelable(false);
381         busyDialog.show();
382
383         // データ読み込み処理(別スレッドで実行)
384         if (isPropertyLoad)
385         {
386             new Thread(opcPreferenceSynchronizer).start();
387         }
388     }
389
390     /**
391      * Preferenceが更新された時に呼び出される処理
392      *
393      * @param sharedPreferences sharedPreferences
394      * @param key               変更されたキー
395      */
396     @Override
397     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
398     {
399         Log.v(TAG, "onSharedPreferenceChanged() : " + key);
400         String propertyValue;
401         boolean value;
402         if (key != null)
403         {
404             switch (key)
405             {
406                 case IPreferencePropertyAccessor.RAW:
407                     value = preferences.getBoolean(key, true);
408                     setBooleanPreference(key, key, value);
409                     propertyValue = (value) ? "ON" : "OFF";
410                     setCameraProperty(IOlyCameraProperty.RAW, propertyValue);
411                     break;
412
413                 case IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA:
414                     value = preferences.getBoolean(key, true);
415                     Log.v(TAG, " " + key + " , " + value);
416                     break;
417
418                 case IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW:
419                     value = preferences.getBoolean(key, true);
420                     Log.v(TAG, " " + key + " , " + value);
421                     break;
422
423                 case IPreferencePropertyAccessor.SHARE_AFTER_SAVE:
424                     value = preferences.getBoolean(key, false);
425                     Log.v(TAG, " " + key + " , " + value);
426                     break;
427
428                 case IPreferencePropertyAccessor.USE_PLAYBACK_MENU:
429                     value = preferences.getBoolean(key, true);
430                     Log.v(TAG, " " + key + " , " + value);
431                     break;
432
433                 default:
434                     String strValue = preferences.getString(key, "");
435                     setListPreference(key, key, strValue);
436                     String propertyKey = convertKeyFromPreferenceToCameraPropertyKey(key);
437                     if (propertyKey != null)
438                     {
439                         setCameraProperty(propertyKey, strValue);
440                     }
441                     break;
442             }
443         }
444     }
445
446     /**
447      * ListPreference の表示データを設定
448      *
449      * @param pref_key     Preference(表示)のキー
450      * @param key          Preference(データ)のキー
451      * @param defaultValue Preferenceのデフォルト値
452      */
453     private void setListPreference(String pref_key, String key, String defaultValue)
454     {
455         ListPreference pref;
456         pref = (ListPreference) findPreference(pref_key);
457         String value = preferences.getString(key, defaultValue);
458         if (pref != null)
459         {
460             pref.setValue(value);
461             pref.setSummary(value);
462         }
463     }
464
465     /**
466      * BooleanPreference の表示データを設定
467      *
468      * @param pref_key     Preference(表示)のキー
469      * @param key          Preference(データ)のキー
470      * @param defaultValue Preferenceのデフォルト値
471      */
472     private void setBooleanPreference(String pref_key, String key, boolean defaultValue)
473     {
474         CheckBoxPreference pref = (CheckBoxPreference) findPreference(pref_key);
475         if (pref != null)
476         {
477             boolean value = preferences.getBoolean(key, defaultValue);
478             pref.setChecked(value);
479         }
480     }
481
482     /**
483      *
484      *
485      */
486     private String convertKeyFromPreferenceToCameraPropertyKey(String key)
487     {
488         String target = null;
489         if (key == null)
490         {
491             return (null);
492         }
493         switch (key)
494         {
495             case IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL:
496                 target = IOlyCameraProperty.SOUND_VOLUME_LEVEL;
497                 break;
498
499             default:
500                 // target == null
501                 break;
502         }
503         return (target);
504     }
505
506     /**
507      * カメラプロパティの同期処理終了通知
508      */
509     @Override
510     public void synchronizedProperty()
511     {
512         FragmentActivity activity = getActivity();
513         if (activity == null)
514         {
515             try
516             {
517                 busyDialog.dismiss();
518                 busyDialog = null;
519             }
520             catch (Exception e)
521             {
522                 e.printStackTrace();
523             }
524             return;
525         }
526         activity.runOnUiThread(new Runnable() {
527             @Override
528             public void run() {
529                 try {
530                     // Preferenceの画面に反映させる
531                     setListPreference(IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL, IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL, IPreferencePropertyAccessor.SOUND_VOLUME_LEVEL_DEFAULT_VALUE);
532                     setBooleanPreference(IPreferencePropertyAccessor.RAW, IPreferencePropertyAccessor.RAW, true);
533                     setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true);
534                     setBooleanPreference(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false);
535
536                     // カメラキットのバージョン
537                     findPreference(IPreferencePropertyAccessor.CAMERAKIT_VERSION).setSummary(OLYCamera.getVersion());
538                     if (hardwareStatusInterface != null)
539                     {
540                         // その他のハードウェア情報の情報設定
541                         setHardwareSummary();
542                     }
543
544                     // 実行中ダイアログを消す
545                     busyDialog.dismiss();
546                     busyDialog = null;
547                 }
548                 catch (Exception e)
549                 {
550                     e.printStackTrace();
551                 }
552             }
553         });
554     }
555
556     @Override
557     public boolean onPreferenceClick(Preference preference)
558     {
559         try
560         {
561             String preferenceKey = preference.getKey();
562             if (preferenceKey.contains(WIFI_SETTINGS))
563             {
564                 // Wifi 設定画面を表示する
565                 Log.v(TAG, " onPreferenceClick : " + preferenceKey);
566                 if (context != null)
567                 {
568                     context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
569                 }
570             }
571             return (true);
572         }
573         catch (Exception e)
574         {
575             e.printStackTrace();
576         }
577         return (false);
578     }
579 }