OPC(Olympus Air)用望遠鏡アプリ。
Revisión | 3bad82ca99b4e86e6c6060621ddb2d9c0858c504 (tree) |
---|---|
Tiempo | 2020-12-11 00:00:48 |
Autor | MRSa <mrsa@myad...> |
Commiter | MRSa |
Canonの通信先IPを変更できるようにする。
@@ -1,9 +1,11 @@ | ||
1 | 1 | package net.osdn.gokigen.a01d.camera.canon.wrapper; |
2 | 2 | |
3 | 3 | import android.app.Activity; |
4 | +import android.content.SharedPreferences; | |
4 | 5 | import android.util.Log; |
5 | 6 | |
6 | 7 | import androidx.annotation.NonNull; |
8 | +import androidx.preference.PreferenceManager; | |
7 | 9 | |
8 | 10 | import net.osdn.gokigen.a01d.IInformationReceiver; |
9 | 11 | import net.osdn.gokigen.a01d.camera.ICameraConnection; |
@@ -36,6 +38,7 @@ import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay; | ||
36 | 38 | import net.osdn.gokigen.a01d.liveview.ICameraStatusUpdateNotify; |
37 | 39 | import net.osdn.gokigen.a01d.liveview.IIndicatorControl; |
38 | 40 | import net.osdn.gokigen.a01d.liveview.liveviewlistener.ILiveViewListener; |
41 | +import net.osdn.gokigen.a01d.preference.IPreferencePropertyAccessor; | |
39 | 42 | |
40 | 43 | public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplayInjector |
41 | 44 | { |
@@ -44,34 +47,51 @@ public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay | ||
44 | 47 | private static final int ASYNC_RESPONSE_PORT = 15741; // ?? |
45 | 48 | private static final int CONTROL_PORT = 15740; |
46 | 49 | private static final int EVENT_PORT = 15740; |
47 | - private static final String CAMERA_IP = "192.168.0.1"; | |
50 | + //private static final String CAMERA_IP = "192.168.0.1"; | |
48 | 51 | |
49 | 52 | private final Activity activity; |
50 | - private final PtpIpRunMode runmode; | |
53 | + private final PtpIpRunMode runMode; | |
51 | 54 | private final CanonCameraInformation cameraInformation; |
52 | 55 | private CanonCaptureControl captureControl; |
53 | 56 | private CanonFocusingControl focusingControl; |
54 | - private CanonConnection canonConnection; | |
55 | - private PtpIpCommandPublisher commandPublisher; | |
56 | - private CanonLiveViewControl liveViewControl; | |
57 | - private PtpIpAsyncResponseReceiver asyncReceiver; | |
58 | - private CanonZoomLensControl zoomControl; | |
59 | - private CanonStatusChecker statusChecker; | |
60 | - private ICameraStatusUpdateNotify statusListener; | |
61 | - private IInformationReceiver informationReceiver; | |
57 | + private final CanonConnection canonConnection; | |
58 | + private final PtpIpCommandPublisher commandPublisher; | |
59 | + private final CanonLiveViewControl liveViewControl; | |
60 | + private final PtpIpAsyncResponseReceiver asyncReceiver; | |
61 | + private final CanonZoomLensControl zoomControl; | |
62 | + private final CanonStatusChecker statusChecker; | |
63 | + private final ICameraStatusUpdateNotify statusListener; | |
64 | + private final IInformationReceiver informationReceiver; | |
62 | 65 | |
63 | 66 | public CanonInterfaceProvider(@NonNull Activity context, @NonNull ICameraStatusReceiver provider, @NonNull ICameraStatusUpdateNotify statusListener, @NonNull IInformationReceiver informationReceiver) |
64 | 67 | { |
65 | 68 | this.activity = context; |
66 | - commandPublisher = new PtpIpCommandPublisher(CAMERA_IP, CONTROL_PORT, false, false); | |
69 | + | |
70 | + String ipAddress; | |
71 | + try | |
72 | + { | |
73 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); | |
74 | + ipAddress = preferences.getString(IPreferencePropertyAccessor.CANON_HOST_IP, IPreferencePropertyAccessor.CANON_HOST_IP_DEFAULT_VALUE); | |
75 | + if (ipAddress == null) | |
76 | + { | |
77 | + ipAddress = "192.168.0.1"; | |
78 | + } | |
79 | + } | |
80 | + catch (Exception e) | |
81 | + { | |
82 | + e.printStackTrace(); | |
83 | + ipAddress = "192.168.0.1"; | |
84 | + } | |
85 | + Log.v(TAG, " Canon IP : " + ipAddress); | |
86 | + commandPublisher = new PtpIpCommandPublisher(ipAddress, CONTROL_PORT, false, false); | |
67 | 87 | liveViewControl = new CanonLiveViewControl(context, this, 10); // |
68 | - asyncReceiver = new PtpIpAsyncResponseReceiver(CAMERA_IP, ASYNC_RESPONSE_PORT); | |
69 | - statusChecker = new CanonStatusChecker(context, commandPublisher, CAMERA_IP, EVENT_PORT); | |
88 | + asyncReceiver = new PtpIpAsyncResponseReceiver(ipAddress, ASYNC_RESPONSE_PORT); | |
89 | + statusChecker = new CanonStatusChecker(context, commandPublisher, ipAddress, EVENT_PORT); | |
70 | 90 | canonConnection = new CanonConnection(context, provider, this, statusChecker); |
71 | 91 | cameraInformation = new CanonCameraInformation(); |
72 | 92 | zoomControl = new CanonZoomLensControl(context, commandPublisher); |
73 | 93 | this.statusListener = statusListener; |
74 | - this.runmode = new PtpIpRunMode(); | |
94 | + this.runMode = new PtpIpRunMode(); | |
75 | 95 | this.informationReceiver = informationReceiver; |
76 | 96 | } |
77 | 97 |
@@ -134,7 +154,7 @@ public class CanonInterfaceProvider implements IPtpIpInterfaceProvider, IDisplay | ||
134 | 154 | @Override |
135 | 155 | public IPtpIpRunModeHolder getRunModeHolder() |
136 | 156 | { |
137 | - return (runmode); | |
157 | + return (runMode); | |
138 | 158 | } |
139 | 159 | |
140 | 160 | @Override |
@@ -116,6 +116,10 @@ public interface IPreferencePropertyAccessor | ||
116 | 116 | |
117 | 117 | String SAVE_LOCAL_LOCATION = "save_local_location"; |
118 | 118 | boolean SAVE_LOCAL_LOCATION_DEFAULT_VALUE = false; |
119 | + | |
120 | + String CANON_HOST_IP = "canon_host_ip"; | |
121 | + String CANON_HOST_IP_DEFAULT_VALUE = "192.168.0.1"; | |
122 | + | |
119 | 123 | /* |
120 | 124 | int CHOICE_SPLASH_SCREEN = 10; |
121 | 125 |
@@ -133,6 +133,9 @@ public class CanonPreferenceFragment extends PreferenceFragmentCompat implements | ||
133 | 133 | if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) { |
134 | 134 | editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE); |
135 | 135 | } |
136 | + if (!items.containsKey(IPreferencePropertyAccessor.CANON_HOST_IP)) { | |
137 | + editor.putString(IPreferencePropertyAccessor.CANON_HOST_IP, IPreferencePropertyAccessor.CANON_HOST_IP_DEFAULT_VALUE); | |
138 | + } | |
136 | 139 | editor.apply(); |
137 | 140 | } |
138 | 141 | catch (Exception e) |
@@ -340,4 +340,7 @@ | ||
340 | 340 | <string name="pref_save_local_location">ライブビュー画像をアプリ固有領域に保存</string> |
341 | 341 | <string name="pref_summary_save_local_location">ライブビューイメージの保存先をアプリ固有領域にします。</string> |
342 | 342 | |
343 | + <string name="pref_canon_host_ip">カメラIPアドレス</string> | |
344 | + <string name="pref_summary_canon_host_ip">通常、変更は不要です (初期値:192.168.0.1)</string> | |
345 | + | |
343 | 346 | </resources> |
@@ -345,4 +345,7 @@ | ||
345 | 345 | <string name="pref_save_local_location">Save local location(Liveview Image)</string> |
346 | 346 | <string name="pref_summary_save_local_location">The liveview image saves in application local location.</string> |
347 | 347 | |
348 | + <string name="pref_canon_host_ip">Camera IP Address</string> | |
349 | + <string name="pref_summary_canon_host_ip">default: 192.168.0.1 </string> | |
350 | + | |
348 | 351 | </resources> |
@@ -47,6 +47,12 @@ | ||
47 | 47 | android:title="@string/pref_canon_focus_xy" |
48 | 48 | android:defaultValue="6000,4000" |
49 | 49 | android:summary="@string/pref_summary_canon_focus_xy" /> |
50 | + | |
51 | + <EditTextPreference | |
52 | + android:key="canon_host_ip" | |
53 | + android:title="@string/pref_canon_host_ip" | |
54 | + android:defaultValue="192.168.0.1" | |
55 | + android:summary="@string/pref_summary_canon_host_ip" /> | |
50 | 56 | <!-- |
51 | 57 | <CheckBoxPreference |
52 | 58 | android:key="capture_both_camera_and_live_view" |