Pentax DSLR Remote Control app.
Révision | 50220ef100ebfe37a572ed14daf2683eb9e61ac3 (tree) |
---|---|
l'heure | 2019-03-31 18:47:37 |
Auteur | MRSa <mrsa@myad...> |
Commiter | MRSa |
自動転送時、受信した画像とそのファイル名を表示するようにした。GR2で停止する問題への対策(検討...)
@@ -27,6 +27,7 @@ import android.widget.TextView; | ||
27 | 27 | |
28 | 28 | import net.osdn.gokigen.pkremote.camera.CameraInterfaceProvider; |
29 | 29 | import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider; |
30 | +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection; | |
30 | 31 | import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor; |
31 | 32 | import net.osdn.gokigen.pkremote.scene.CameraSceneUpdater; |
32 | 33 |
@@ -153,6 +154,27 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe | ||
153 | 154 | } |
154 | 155 | |
155 | 156 | /** |
157 | + * | |
158 | + */ | |
159 | + @Override | |
160 | + protected void onPause() | |
161 | + { | |
162 | + super.onPause(); | |
163 | + try | |
164 | + { | |
165 | + ICameraConnection connection = interfaceProvider.getCameraConnection(); | |
166 | + if (connection != null) | |
167 | + { | |
168 | + connection.stopWatchWifiStatus(this); | |
169 | + } | |
170 | + } | |
171 | + catch (Exception e) | |
172 | + { | |
173 | + e.printStackTrace(); | |
174 | + } | |
175 | + } | |
176 | + | |
177 | + /** | |
156 | 178 | * クラスの初期化 (instantiate) |
157 | 179 | */ |
158 | 180 | private void initializeClass() |
@@ -433,7 +433,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl | ||
433 | 433 | for (int fileIndex = 0; fileIndex < nofFiles; fileIndex++) |
434 | 434 | { |
435 | 435 | String fileName = filesArray.getString(fileIndex); |
436 | - Log.v(TAG, "FILE : " + fileName); | |
436 | + //Log.v(TAG, "FILE : " + fileName); | |
437 | 437 | ICameraContent cameraContent = new CameraContentInfo(cameraId, "sd1", dirName, fileName, new Date()); |
438 | 438 | cameraContent.setCapturedDate(getCameraContentDate(cameraContent)); |
439 | 439 | fileList.add(cameraContent); |
@@ -0,0 +1,8 @@ | ||
1 | +package net.osdn.gokigen.pkremote.playback; | |
2 | + | |
3 | +import android.net.Uri; | |
4 | + | |
5 | +public interface IContentDownloadNotify | |
6 | +{ | |
7 | + void downloadedImage(String contentInfo, Uri content); | |
8 | +} |
@@ -29,7 +29,6 @@ import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentsRecog | ||
29 | 29 | import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl; |
30 | 30 | import net.osdn.gokigen.pkremote.playback.detail.CameraContentEx; |
31 | 31 | import net.osdn.gokigen.pkremote.playback.detail.ImagePagerViewFragment; |
32 | -import net.osdn.gokigen.pkremote.playback.detail.MyContentDownloader; | |
33 | 32 | import net.osdn.gokigen.pkremote.playback.grid.ImageGridViewAdapter; |
34 | 33 | |
35 | 34 | import java.util.ArrayList; |
@@ -92,7 +91,7 @@ public class ImageGridViewFragment extends Fragment implements AdapterView.OnIte | ||
92 | 91 | Activity activity = getActivity(); |
93 | 92 | if (activity != null) |
94 | 93 | { |
95 | - this.contentDownloader = new MyContentDownloader(getActivity(), playbackControl); | |
94 | + this.contentDownloader = new MyContentDownloader(getActivity(), playbackControl, null); | |
96 | 95 | } |
97 | 96 | else |
98 | 97 | { |
@@ -541,7 +540,7 @@ public class ImageGridViewFragment extends Fragment implements AdapterView.OnIte | ||
541 | 540 | // activityが取れない時には終わる。 |
542 | 541 | return; |
543 | 542 | } |
544 | - this.contentDownloader = new MyContentDownloader(getActivity(), playbackControl); | |
543 | + this.contentDownloader = new MyContentDownloader(getActivity(), playbackControl, null); | |
545 | 544 | } |
546 | 545 | Thread thread = new Thread(new Runnable() |
547 | 546 | { |
@@ -1,4 +1,4 @@ | ||
1 | -package net.osdn.gokigen.pkremote.playback.detail; | |
1 | +package net.osdn.gokigen.pkremote.playback; | |
2 | 2 | import android.app.Activity; |
3 | 3 | import android.app.AlertDialog; |
4 | 4 | import android.app.ProgressDialog; |
@@ -28,6 +28,7 @@ import java.util.Calendar; | ||
28 | 28 | import java.util.Locale; |
29 | 29 | |
30 | 30 | import androidx.annotation.NonNull; |
31 | +import androidx.annotation.Nullable; | |
31 | 32 | import androidx.preference.PreferenceManager; |
32 | 33 | |
33 | 34 | /** |
@@ -39,6 +40,7 @@ public class MyContentDownloader implements IDownloadContentCallback | ||
39 | 40 | private final String TAG = toString(); |
40 | 41 | private final Activity activity; |
41 | 42 | private final IPlaybackControl playbackControl; |
43 | + private final IContentDownloadNotify receiver; | |
42 | 44 | private static final String RAW_SUFFIX_1 = ".DNG"; |
43 | 45 | private static final String RAW_SUFFIX_2 = ".ORF"; |
44 | 46 | private static final String RAW_SUFFIX_3 = ".PEF"; |
@@ -55,10 +57,11 @@ public class MyContentDownloader implements IDownloadContentCallback | ||
55 | 57 | * コンストラクタ |
56 | 58 | * |
57 | 59 | */ |
58 | - public MyContentDownloader(@NonNull Activity activity, @NonNull final IPlaybackControl playbackControl) | |
60 | + public MyContentDownloader(@NonNull Activity activity, @NonNull final IPlaybackControl playbackControl, @Nullable IContentDownloadNotify receiver) | |
59 | 61 | { |
60 | 62 | this.activity = activity; |
61 | 63 | this.playbackControl = playbackControl; |
64 | + this.receiver = receiver; | |
62 | 65 | } |
63 | 66 | |
64 | 67 | /** |
@@ -234,18 +237,29 @@ public class MyContentDownloader implements IDownloadContentCallback | ||
234 | 237 | final Uri content = resolver.insert(mediaValue, values); |
235 | 238 | try |
236 | 239 | { |
237 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); | |
238 | - if (preferences.getBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false)) | |
239 | - { | |
240 | 240 | activity.runOnUiThread(new Runnable() |
241 | 241 | { |
242 | 242 | @Override |
243 | 243 | public void run() |
244 | 244 | { |
245 | - shareContent(content, mimeType); | |
245 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); | |
246 | + if (preferences.getBoolean(IPreferencePropertyAccessor.SHARE_AFTER_SAVE, false)) | |
247 | + { | |
248 | + shareContent(content, mimeType); | |
249 | + } | |
250 | + try | |
251 | + { | |
252 | + if (receiver != null) | |
253 | + { | |
254 | + receiver.downloadedImage(targetFileName, content); | |
255 | + } | |
256 | + } | |
257 | + catch (Exception e) | |
258 | + { | |
259 | + e.printStackTrace(); | |
260 | + } | |
246 | 261 | } |
247 | 262 | }); |
248 | - } | |
249 | 263 | } |
250 | 264 | catch (Exception e) |
251 | 265 | { |
@@ -20,6 +20,7 @@ import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraFileInfo; | ||
20 | 20 | import net.osdn.gokigen.pkremote.camera.interfaces.playback.IContentInfoCallback; |
21 | 21 | import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback; |
22 | 22 | import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl; |
23 | +import net.osdn.gokigen.pkremote.playback.MyContentDownloader; | |
23 | 24 | |
24 | 25 | import java.text.SimpleDateFormat; |
25 | 26 | import java.util.Date; |
@@ -516,7 +517,7 @@ public class ImagePagerViewFragment extends Fragment | ||
516 | 517 | Thread thread = new Thread(new Runnable() { |
517 | 518 | @Override |
518 | 519 | public void run() { |
519 | - MyContentDownloader contentDownloader = new MyContentDownloader(activity, playbackControl); | |
520 | + MyContentDownloader contentDownloader = new MyContentDownloader(activity, playbackControl, null); | |
520 | 521 | CameraContentEx infoEx = contentList.get(contentIndex); |
521 | 522 | if (infoEx != null) |
522 | 523 | { |
@@ -2,6 +2,7 @@ package net.osdn.gokigen.pkremote.transfer; | ||
2 | 2 | |
3 | 3 | import android.content.Context; |
4 | 4 | import android.graphics.Bitmap; |
5 | +import android.net.Uri; | |
5 | 6 | import android.os.Bundle; |
6 | 7 | import android.os.Vibrator; |
7 | 8 | import android.util.Log; |
@@ -17,6 +18,7 @@ import android.widget.TextView; | ||
17 | 18 | |
18 | 19 | import net.osdn.gokigen.pkremote.R; |
19 | 20 | import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider; |
21 | +import net.osdn.gokigen.pkremote.playback.IContentDownloadNotify; | |
20 | 22 | |
21 | 23 | import androidx.annotation.NonNull; |
22 | 24 | import androidx.appcompat.app.AppCompatActivity; |
@@ -28,7 +30,7 @@ import static android.content.Context.VIBRATOR_SERVICE; | ||
28 | 30 | * 自動転送クラス |
29 | 31 | * |
30 | 32 | */ |
31 | -public class AutoTransferFragment extends Fragment implements View.OnClickListener, ITransferMessage | |
33 | +public class AutoTransferFragment extends Fragment implements View.OnClickListener, ITransferMessage, IContentDownloadNotify | |
32 | 34 | { |
33 | 35 | private final String TAG = this.toString(); |
34 | 36 |
@@ -39,6 +41,7 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
39 | 41 | private FileAutoTransferMain transferMain = null; |
40 | 42 | private View myView = null; |
41 | 43 | private boolean transferThreadIsRunning = false; |
44 | + private boolean startTransferReceived = false; | |
42 | 45 | |
43 | 46 | public static AutoTransferFragment newInstance(@NonNull AppCompatActivity context, @NonNull IInterfaceProvider provider) |
44 | 47 | { |
@@ -61,7 +64,7 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
61 | 64 | { |
62 | 65 | Log.v(TAG, "prepare()"); |
63 | 66 | this.activity = activity; |
64 | - transferMain = new FileAutoTransferMain(activity, interfaceProvider, this); | |
67 | + transferMain = new FileAutoTransferMain(activity, interfaceProvider, this, this); | |
65 | 68 | } |
66 | 69 | |
67 | 70 | /** |
@@ -169,6 +172,14 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
169 | 172 | } |
170 | 173 | try |
171 | 174 | { |
175 | + // とにかく転送スレッドを止める指示を出す | |
176 | + transferThreadIsRunning = false; | |
177 | + while (startTransferReceived) | |
178 | + { | |
179 | + // すでにコマンドは発行状態...終わるまで待つ | |
180 | + Thread.sleep(SLEEP_MS); | |
181 | + } | |
182 | + | |
172 | 183 | // STARTボタンを無効化してぶるぶるする... |
173 | 184 | controlButton(false); |
174 | 185 | Vibrator vibrator = (activity != null) ? (Vibrator) activity.getSystemService(VIBRATOR_SERVICE) : null; |
@@ -176,6 +187,11 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
176 | 187 | { |
177 | 188 | vibrator.vibrate(50); |
178 | 189 | } |
190 | + startTransferReceived = true; | |
191 | + | |
192 | + // 画像を初期データにする | |
193 | + ImageView imageView = activity.findViewById(R.id.image_view_area); | |
194 | + imageView.setImageResource(R.drawable.ic_satellite_grey_24dp); | |
179 | 195 | |
180 | 196 | // 画面上にある自動転送の設定を取得 |
181 | 197 | CheckBox raw = activity.findViewById(R.id.check_auto_download_raw); |
@@ -200,8 +216,8 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
200 | 216 | { |
201 | 217 | if (transferMain != null) |
202 | 218 | { |
203 | - // 現在時刻を取得する | |
204 | - long checkStartTime = System.currentTimeMillis(); | |
219 | + //// 現在時刻を取得する | |
220 | + //long checkStartTime = System.currentTimeMillis(); | |
205 | 221 | |
206 | 222 | // チェックして追加ファイルがあったらダウンロード |
207 | 223 | transferMain.checkFiles(); |
@@ -211,12 +227,15 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
211 | 227 | { |
212 | 228 | Thread.sleep(SLEEP_MS); |
213 | 229 | } |
214 | - long checkTime = Math.abs(System.currentTimeMillis() - checkStartTime); | |
215 | - if (checkTime < SLEEP_WAIT_MS) | |
216 | - { | |
217 | - // 画像数確認の時間が規定時間よりも短い場合は、しばらく待つ | |
218 | - Thread.sleep(SLEEP_WAIT_MS - checkTime); | |
219 | - } | |
230 | + //long checkTime = Math.abs(System.currentTimeMillis() - checkStartTime); | |
231 | + //if (checkTime < SLEEP_WAIT_MS) | |
232 | + //{ | |
233 | + // // 画像数確認の時間が規定時間よりも短い場合は、しばらく待つ | |
234 | + // Thread.sleep(SLEEP_WAIT_MS - checkTime); | |
235 | + //} | |
236 | + | |
237 | + // 一定時間しばらく待つ (急ぎすぎると、GR2の電源が落ちる... | |
238 | + Thread.sleep(SLEEP_WAIT_MS); | |
220 | 239 | } |
221 | 240 | //count++; |
222 | 241 | //Log.v(TAG, "TRANSFER LOOP : " + count); |
@@ -231,6 +250,7 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
231 | 250 | // 後処理... |
232 | 251 | transferMain.finish(); |
233 | 252 | } |
253 | + startTransferReceived = false; | |
234 | 254 | } |
235 | 255 | }); |
236 | 256 |
@@ -430,4 +450,35 @@ public class AutoTransferFragment extends Fragment implements View.OnClickListen | ||
430 | 450 | }); |
431 | 451 | } |
432 | 452 | } |
453 | + | |
454 | + // IContentDownloadNotify | |
455 | + @Override | |
456 | + public void downloadedImage(final String contentInfo, final Uri content) | |
457 | + { | |
458 | + if (activity != null) | |
459 | + { | |
460 | + activity.runOnUiThread(new Runnable() { | |
461 | + @Override | |
462 | + public void run() { | |
463 | + ImageView imageView = activity.findViewById(R.id.image_view_area); | |
464 | + TextView textView = activity.findViewById(R.id.image_view_information); | |
465 | + try | |
466 | + { | |
467 | + if ((imageView != null)&&(content != null)) | |
468 | + { | |
469 | + imageView.setImageURI(content); | |
470 | + } | |
471 | + if ((textView != null)&&(contentInfo != null)) | |
472 | + { | |
473 | + textView.setText(contentInfo); | |
474 | + } | |
475 | + } | |
476 | + catch (Throwable t) | |
477 | + { | |
478 | + t.printStackTrace(); | |
479 | + } | |
480 | + } | |
481 | + }); | |
482 | + } | |
483 | + } | |
433 | 484 | } |
@@ -6,7 +6,8 @@ import net.osdn.gokigen.pkremote.R; | ||
6 | 6 | import net.osdn.gokigen.pkremote.camera.interfaces.IInterfaceProvider; |
7 | 7 | import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent; |
8 | 8 | import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback; |
9 | -import net.osdn.gokigen.pkremote.playback.detail.MyContentDownloader; | |
9 | +import net.osdn.gokigen.pkremote.playback.IContentDownloadNotify; | |
10 | +import net.osdn.gokigen.pkremote.playback.MyContentDownloader; | |
10 | 11 | |
11 | 12 | import java.util.ArrayList; |
12 | 13 | import java.util.HashMap; |
@@ -36,12 +37,12 @@ class FileAutoTransferMain implements ICameraContentListCallback | ||
36 | 37 | private boolean isChecking = false; |
37 | 38 | |
38 | 39 | |
39 | - FileAutoTransferMain(@NonNull AppCompatActivity context, @NonNull IInterfaceProvider provider, @NonNull ITransferMessage messageInterface) | |
40 | + FileAutoTransferMain(@NonNull AppCompatActivity context, @NonNull IInterfaceProvider provider, @NonNull ITransferMessage messageInterface, @NonNull IContentDownloadNotify receiver) | |
40 | 41 | { |
41 | 42 | this.activity = context; |
42 | 43 | this.interfaceProvider = provider; |
43 | 44 | this.messageInterface = messageInterface; |
44 | - this.downloader = new MyContentDownloader(context, provider.getPlaybackControl()); | |
45 | + this.downloader = new MyContentDownloader(context, provider.getPlaybackControl(), receiver); | |
45 | 46 | this.contentHashMap = new HashMap<>(); |
46 | 47 | } |
47 | 48 |
@@ -92,6 +93,7 @@ class FileAutoTransferMain implements ICameraContentListCallback | ||
92 | 93 | try |
93 | 94 | { |
94 | 95 | Log.v(TAG, "CHECK FILE"); |
96 | + messageInterface.showInformation(activity.getString(R.string.get_image_list)); | |
95 | 97 | isChecking = true; |
96 | 98 | interfaceProvider.getPlaybackControl().getCameraContentList(this); |
97 | 99 | } |
@@ -206,6 +208,7 @@ class FileAutoTransferMain implements ICameraContentListCallback | ||
206 | 208 | Log.v(TAG, "RECEIVE CONTENT LIST"); |
207 | 209 | try |
208 | 210 | { |
211 | + messageInterface.showInformation(activity.getString(R.string.get_image_list_done)); | |
209 | 212 | if (firstContent) |
210 | 213 | { |
211 | 214 | baseContentList = contentList; |
@@ -259,14 +262,15 @@ class FileAutoTransferMain implements ICameraContentListCallback | ||
259 | 262 | e.printStackTrace(); |
260 | 263 | } |
261 | 264 | isChecking = false; |
265 | + Log.v(TAG, "CHECK FILE DONE."); | |
262 | 266 | } |
263 | 267 | |
264 | 268 | // ICameraContentListCallback |
265 | 269 | @Override |
266 | 270 | public void onErrorOccurred(Exception e) |
267 | 271 | { |
268 | - Log.v(TAG, "RECEIVE FAILURE..."); | |
269 | 272 | e.printStackTrace(); |
270 | 273 | isChecking = false; |
274 | + Log.v(TAG, "CHECK FILE DONE(WITH ERROR)."); | |
271 | 275 | } |
272 | 276 | } |
@@ -12,14 +12,10 @@ | ||
12 | 12 | android:layout_width="match_parent" |
13 | 13 | android:layout_height="wrap_content" |
14 | 14 | android:orientation="vertical"> |
15 | - | |
16 | - <ImageView | |
17 | - android:id="@+id/image_view_area" | |
18 | - android:layout_width="match_parent" | |
19 | - android:layout_height="160dp" | |
20 | - android:src="@null" | |
21 | - android:scaleType="fitCenter" | |
22 | - tools:ignore="ContentDescription" /> | |
15 | + <View | |
16 | + android:layout_width="fill_parent" | |
17 | + android:layout_height="1dp" | |
18 | + android:background="@android:color/darker_gray"/> | |
23 | 19 | |
24 | 20 | <TextView |
25 | 21 | android:id="@+id/image_view_information" |
@@ -31,11 +27,21 @@ | ||
31 | 27 | android:focusable="true" |
32 | 28 | android:text="@string/blank" |
33 | 29 | android:textColor="@color/background_dark" |
34 | - android:textSize="9pt" /> | |
30 | + android:textSize="8pt" /> | |
31 | + | |
32 | + <ImageView | |
33 | + android:id="@+id/image_view_area" | |
34 | + android:layout_width="match_parent" | |
35 | + android:layout_height="160dp" | |
36 | + android:layout_marginTop="2dp" | |
37 | + android:src="@null" | |
38 | + android:scaleType="fitCenter" | |
39 | + tools:ignore="ContentDescription" /> | |
35 | 40 | |
36 | 41 | <View |
37 | 42 | android:layout_width="fill_parent" |
38 | 43 | android:layout_height="1dp" |
44 | + android:layout_marginTop="2dp" | |
39 | 45 | android:background="@android:color/darker_gray"/> |
40 | 46 | |
41 | 47 | <LinearLayout |
@@ -184,5 +184,7 @@ | ||
184 | 184 | <string name="image_checking">撮影画像確認中…</string> |
185 | 185 | <string name="add_image_pics">追加画像 : </string> |
186 | 186 | <string name="image_download_done">転送終了</string> |
187 | + <string name="get_image_list">画像一覧取得中…</string> | |
188 | + <string name="get_image_list_done">画像一覧取得中…完了</string> | |
187 | 189 | |
188 | 190 | </resources> |
@@ -184,5 +184,6 @@ | ||
184 | 184 | <string name="image_checking">Image checking…</string> |
185 | 185 | <string name="add_image_pics">Detect Image : </string> |
186 | 186 | <string name="image_download_done">Transfer Finished.</string> |
187 | - | |
187 | + <string name="get_image_list">Get Image List…</string> | |
188 | + <string name="get_image_list_done">Get Image List…DONE.</string> | |
188 | 189 | </resources> |