• R/O
  • HTTP
  • SSH
  • HTTPS

PKRemote: Commit

Pentax DSLR Remote Control app.


Commit MetaInfo

Revisión429f268e80e4ce1765fe9eee714da01f58a4918d (tree)
Tiempo2019-12-04 00:38:12
AutorMRSa <mrsa@myad...>
CommiterMRSa

Log Message

Nikon用に受信待ち時間を設定できるようにした。

Cambiar Resumen

Diferencia

--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonFullImageReceiver.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonFullImageReceiver.java
@@ -1,6 +1,5 @@
11 package net.osdn.gokigen.pkremote.camera.vendor.nikon.wrapper.playback;
22
3-import android.app.Activity;
43 import android.util.Log;
54
65 import androidx.annotation.NonNull;
@@ -19,23 +18,22 @@ public class NikonFullImageReceiver implements IPtpIpCommandCallback
1918 {
2019 private static final String TAG = NikonFullImageReceiver.class.getSimpleName();
2120
22- private final Activity activity;
2321 private final IPtpIpCommandPublisher publisher;
2422 private IDownloadContentCallback callback = null;
2523
2624 private boolean isReceiveMulti = true;
2725 private int objectId = 0;
28-
26+ private int delayMs;
2927 private int received_total_bytes = 0;
3028 private int received_remain_bytes = 0;
3129
3230 private int target_image_size = 0;
3331 private boolean receivedFirstData = false;
3432
35- NikonFullImageReceiver(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher)
33+ NikonFullImageReceiver(@NonNull IPtpIpCommandPublisher publisher, int delayMs)
3634 {
37- this.activity = activity;
3835 this.publisher = publisher;
36+ this.delayMs = delayMs;
3937 }
4038
4139 void issueCommand(int objectId, int imageSize, IDownloadContentCallback callback)
@@ -53,7 +51,7 @@ public class NikonFullImageReceiver implements IPtpIpCommandCallback
5351 this.receivedFirstData = false;
5452
5553 Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
56- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, 75, true, 0, 0x101b, 12, objectId, 0, imageSize, 0)); // GetPartialObject (0x101b)
54+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, delayMs, true, 0, 0x101b, 12, objectId, 0, imageSize, 0)); // GetPartialObject (0x101b)
5755 }
5856
5957 @Override
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonImageObjectReceiver.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonImageObjectReceiver.java
@@ -21,13 +21,15 @@ public class NikonImageObjectReceiver implements IPtpIpCommandCallback, NikonSto
2121 {
2222 private final String TAG = toString();
2323 private final NikonInterfaceProvider provider;
24+ private final int delayMs;
2425 private boolean isDumpLog = true;
2526 private ICameraContentListCallback callback = null;
2627 private SparseArray<NikonStorageContentHolder> storageIdList;
2728
28- NikonImageObjectReceiver(NikonInterfaceProvider provider)
29+ NikonImageObjectReceiver(NikonInterfaceProvider provider, int delayMs)
2930 {
3031 this.provider = provider;
32+ this.delayMs = delayMs;
3133 this.storageIdList = new SparseArray<>();
3234 }
3335
@@ -50,7 +52,7 @@ public class NikonImageObjectReceiver implements IPtpIpCommandCallback, NikonSto
5052 ((int) rx_body[readPosition + 1] << 8) +
5153 ((int) rx_body[readPosition + 2] << 16) +
5254 ((int) rx_body[readPosition + 3] << 24);
53- storageIdList.append(storageId, new NikonStorageContentHolder(provider, storageId, this));
55+ storageIdList.append(storageId, new NikonStorageContentHolder(provider, storageId, this, delayMs));
5456 readPosition = readPosition + 4;
5557 }
5658 Log.v(TAG, " NOF STORAGE IDs : " + storageIdList.size() + " ");
@@ -189,7 +191,7 @@ public class NikonImageObjectReceiver implements IPtpIpCommandCallback, NikonSto
189191 if (publisher != null)
190192 {
191193 // オブジェクト一覧をクリアする
192- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_ID, 50, isDumpLog, 0, 0x1004, 0, 0, 0, 0, 0)); // GetStorageIDs
194+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_ID, delayMs, isDumpLog, 0, 0x1004, 0, 0, 0, 0, 0)); // GetStorageIDs
193195 this.callback = callback;
194196 }
195197 }
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonPlaybackControl.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonPlaybackControl.java
@@ -5,12 +5,10 @@ import android.content.SharedPreferences;
55 import android.graphics.Color;
66 import android.util.Log;
77
8-import androidx.annotation.NonNull;
98 import androidx.preference.PreferenceManager;
109
1110 import net.osdn.gokigen.pkremote.IInformationReceiver;
1211 import net.osdn.gokigen.pkremote.R;
13-import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
1412 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback;
1513 import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraFileInfo;
1614 import net.osdn.gokigen.pkremote.camera.interfaces.playback.IContentInfoCallback;
@@ -40,35 +38,44 @@ public class NikonPlaybackControl implements IPlaybackControl
4038 private final Activity activity;
4139 private final NikonInterfaceProvider provider;
4240 private final NikonFullImageReceiver fullImageReceiver;
43- //private final NikonSmallImageReceiver smallImageReciever;
44- // private String raw_suffix = "NEF";
41+ private int delayMs = 50;
42+ private final NikonSmallImageReceiver smallImageReciever;
4543 private boolean use_screennail_image = false;
4644 private NikonImageObjectReceiver nikonImageObjectReceiver;
4745
4846 public NikonPlaybackControl(Activity activity, NikonInterfaceProvider provider)
4947 {
50- this.activity = activity;
51- this.provider = provider;
52- nikonImageObjectReceiver = new NikonImageObjectReceiver(provider);
53- this.fullImageReceiver = new NikonFullImageReceiver(activity, provider.getCommandPublisher());
54- //this.smallImageReciever = new NikonSmallImageReceiver(activity, provider.getCommandPublisher());
55-
5648 try
5749 {
5850 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
59- //raw_suffix = preferences.getString(IPreferencePropertyAccessor.CANON_RAW_SUFFIX, IPreferencePropertyAccessor.CANON_RAW_SUFFIX_DEFAULT_VALUE);
6051 use_screennail_image = preferences.getBoolean(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, false);
52+
53+ try
54+ {
55+ delayMs = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT, IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT_DEFAULT_VALUE));
56+ }
57+ catch (Exception ee)
58+ {
59+ delayMs = 50;
60+ ee.printStackTrace();
61+ }
6162 }
6263 catch (Exception e)
6364 {
6465 e.printStackTrace();
6566 }
67+
68+ this.activity = activity;
69+ this.provider = provider;
70+ nikonImageObjectReceiver = new NikonImageObjectReceiver(provider, delayMs);
71+ this.fullImageReceiver = new NikonFullImageReceiver(provider.getCommandPublisher(), delayMs);
72+ this.smallImageReciever = new NikonSmallImageReceiver(provider.getCommandPublisher(), delayMs);
73+
6674 }
6775
6876 @Override
6977 public String getRawFileSuffix()
7078 {
71- //return (raw_suffix);
7279 return ("NEF");
7380 }
7481
@@ -124,7 +131,7 @@ public class NikonPlaybackControl implements IPlaybackControl
124131 }
125132
126133 // 画像を取得する
127- publisher.enqueueCommand(new PtpIpCommandGeneric(new NikonScreennailImageReceiver(activity, callback), objectId, 75, false, 0, 0x90c4, 4, objectId, 0, 0, 0));
134+ publisher.enqueueCommand(new PtpIpCommandGeneric(new NikonScreennailImageReceiver(activity, callback), objectId, delayMs, false, 0, 0x90c4, 4, objectId, 0, 0, 0));
128135 }
129136 }
130137 catch (Exception e)
@@ -172,7 +179,7 @@ public class NikonPlaybackControl implements IPlaybackControl
172179 }
173180
174181 // Log.v(TAG, "downloadContentThumbnail() " + indexStr + " [" + objectId + "] (" + storageId + ")");
175- publisher.enqueueCommand(new PtpIpCommandGeneric(new PtpIpThumbnailImageReceiver(activity, callback), objectId, 75, false, 0, 0x100a, 4, objectId, 0, 0, 0)); // getThumb
182+ publisher.enqueueCommand(new PtpIpCommandGeneric(new PtpIpThumbnailImageReceiver(activity, callback), objectId, delayMs, false, 0, 0x100a, 4, objectId, 0, 0, 0)); // getThumb
176183 }
177184 }
178185 catch (Exception e)
@@ -256,8 +263,8 @@ public class NikonPlaybackControl implements IPlaybackControl
256263 if (isSmallSize)
257264 {
258265 // スモールサイズの画像取得コマンド(シーケンス)を発行する
259- //smallImageReciever.issueCommand(content.getObjectId(), callback);
260- fullImageReceiver.issueCommand(content.getObjectId(), content.getOriginalSize(), callback);
266+ smallImageReciever.issueCommand(content.getObjectId(), callback);
267+ //fullImageReceiver.issueCommand(content.getObjectId(), content.getOriginalSize(), callback);
261268 }
262269 else
263270 {
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonSmallImageReceiver.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonSmallImageReceiver.java
@@ -1,6 +1,5 @@
11 package net.osdn.gokigen.pkremote.camera.vendor.nikon.wrapper.playback;
22
3-import android.app.Activity;
43 import android.util.Log;
54
65 import androidx.annotation.NonNull;
@@ -19,7 +18,6 @@ public class NikonSmallImageReceiver implements IPtpIpCommandCallback
1918 {
2019 private static final String TAG = NikonFullImageReceiver.class.getSimpleName();
2120
22- private final Activity activity;
2321 private final IPtpIpCommandPublisher publisher;
2422 private IDownloadContentCallback callback = null;
2523
@@ -31,11 +29,12 @@ public class NikonSmallImageReceiver implements IPtpIpCommandCallback
3129
3230 private int target_image_size = 0;
3331 private boolean receivedFirstData = false;
32+ private int delayMs;
3433
35- NikonSmallImageReceiver(@NonNull Activity activity, @NonNull IPtpIpCommandPublisher publisher)
34+ NikonSmallImageReceiver(@NonNull IPtpIpCommandPublisher publisher, int delayMs)
3635 {
37- this.activity = activity;
3836 this.publisher = publisher;
37+ this.delayMs = delayMs;
3938 }
4039
4140 void issueCommand(int objectId, IDownloadContentCallback callback)
@@ -52,7 +51,7 @@ public class NikonSmallImageReceiver implements IPtpIpCommandCallback
5251 this.receivedFirstData = false;
5352 //Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
5453 //publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, true, 0, 0x101b, 12, objectId, 0, imageSize)); // GetPartialObject 0x101b
55- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, 75, true, 0, 0x90c4, 4, objectId, 0, 0, 0)); // GetLargeThumb
54+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, delayMs, true, 0, 0x90c4, 4, objectId, 0, 0, 0)); // GetLargeThumb
5655 }
5756
5857 @Override
--- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonStorageContentHolder.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonStorageContentHolder.java
@@ -26,14 +26,16 @@ public class NikonStorageContentHolder implements IPtpIpCommandCallback
2626 private boolean isDumpLog = false;
2727 private int subDirectoryCount = 0;
2828 private int receivedDirectoryCount = 0;
29+ private int delayMs;
2930 private boolean isObjectReceived = false;
3031 private SparseArray<NikonImageContentInfo> imageObjectList;
3132
32- NikonStorageContentHolder(@NonNull NikonInterfaceProvider provider, int storageId, @NonNull ImageObjectReceivedCallback callback)
33+ NikonStorageContentHolder(@NonNull NikonInterfaceProvider provider, int storageId, @NonNull ImageObjectReceivedCallback callback, int delayMs)
3334 {
3435 this.provider = provider;
3536 this.storageId = storageId;
3637 this.callback = callback;
38+ this.delayMs = delayMs;
3739 this.imageObjectList = new SparseArray<>();
3840 }
3941
@@ -43,7 +45,7 @@ public class NikonStorageContentHolder implements IPtpIpCommandCallback
4345 {
4446 isObjectReceived = false;
4547 IPtpIpCommandPublisher publisher = provider.getCommandPublisher();
46- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE1, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00003001, 0xffffffff, 0));
48+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE1, delayMs, isDumpLog, 0, 0x1007, 12, storageId, 0x00003001, 0xffffffff, 0));
4749 imageObjectList.clear();
4850 }
4951 catch (Exception e)
@@ -96,7 +98,7 @@ public class NikonStorageContentHolder implements IPtpIpCommandCallback
9698 for (int subDirectory : directoriesList)
9799 {
98100 Log.v(TAG, " STORAGE ID : " + storageId + " DIRECTORY ID : " + subDirectory);
99- publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE2, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0)); //
101+ publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE2, delayMs, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0)); //
100102 }
101103 return;
102104 }
@@ -139,7 +141,7 @@ public class NikonStorageContentHolder implements IPtpIpCommandCallback
139141 public boolean isReceiveMulti() {
140142 return false;
141143 }
142- }, GET_STORAGE_HANDLE3, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0));
144+ }, GET_STORAGE_HANDLE3, delayMs, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0));
143145
144146 /*
145147 // ストレージ名称。。。ここでは利用できない
--- a/app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java
@@ -109,6 +109,10 @@ public interface IPreferencePropertyAccessor
109109 String NIKON_CAMERA_IP_ADDRESS = "nikon_host_ip";
110110 String NIKON_CAMERA_IP_ADDRESS_DEFAULT_VALUE = "192.168.1.1";
111111
112+ String NIKON_RECEIVE_WAIT = "nikon_receive_wait";
113+ String NIKON_RECEIVE_WAIT_DEFAULT_VALUE = "50";
114+
115+
112116 /*
113117 //String GR2_DISPLAY_MODE = "gr2_display_mode";
114118 //String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0";
--- a/app/src/main/java/net/osdn/gokigen/pkremote/preference/nikon/NikonPreferenceFragment.java
+++ b/app/src/main/java/net/osdn/gokigen/pkremote/preference/nikon/NikonPreferenceFragment.java
@@ -129,6 +129,9 @@ public class NikonPreferenceFragment extends PreferenceFragmentCompat implement
129129 if (!items.containsKey(IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS)) {
130130 editor.putString(IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS, IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS_DEFAULT_VALUE);
131131 }
132+ if (!items.containsKey(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT)) {
133+ editor.putString(IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT, IPreferencePropertyAccessor.NIKON_RECEIVE_WAIT_DEFAULT_VALUE);
134+ }
132135 if (!items.containsKey(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL)) {
133136 editor.putBoolean(IPreferencePropertyAccessor.NIKON_USE_SCREENNAIL_AS_SMALL, false);
134137 }
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -325,4 +325,7 @@
325325 <string name="pref_wifi_settings">WiFi設定</string>
326326 <string name="pref_summary_wifi_settings"> </string>
327327
328+ <string name="pref_nikon_receive_wait">応答受信待ち時間</string>
329+ <string name="pref_summary_nikon_receive_wait">カメラからの応答待ち時間(単位:ms)</string>
330+
328331 </resources>
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -326,4 +326,7 @@
326326 <string name="pref_wifi_settings">WIFI Settings</string>
327327 <string name="pref_summary_wifi_settings"> </string>
328328
329+ <string name="pref_nikon_receive_wait">Receive reply wait(ms)</string>
330+ <string name="pref_summary_nikon_receive_wait"> </string>
331+
329332 </resources>
--- a/app/src/main/res/xml/preferences_nikon.xml
+++ b/app/src/main/res/xml/preferences_nikon.xml
@@ -35,6 +35,13 @@
3535 android:title="@string/pref_nikon_host_ip"
3636 android:defaultValue="192.168.1.1"
3737 android:summary="@string/pref_summary_nikon_host_ip" />
38+
39+ <EditTextPreference
40+ android:key="nikon_receive_wait"
41+ android:title="@string/pref_nikon_receive_wait"
42+ android:defaultValue="50"
43+ android:summary="@string/pref_summary_nikon_receive_wait" />
44+
3845 <!--
3946 <CheckBoxPreference
4047 android:key="ble_wifi_on"
Show on old repository browser