import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl;
import net.osdn.gokigen.pkremote.playback.detail.CameraContentEx;
import net.osdn.gokigen.pkremote.playback.detail.ImagePagerViewFragment;
+import net.osdn.gokigen.pkremote.playback.detail.MyContentDownloader;
import net.osdn.gokigen.pkremote.playback.grid.ImageGridViewAdapter;
import java.util.ArrayList;
private static final String OLYMPUS_RAW_SUFFIX = ".orf";
private static final String PENTAX_RAW_PEF_SUFFIX = ".pef";
+ private MyContentDownloader contentDownloader;
private GridView gridView;
private IInterfaceProvider interfaceProvider;
private IPlaybackControl playbackControl;
this.interfaceProvider = interfaceProvider;
this.playbackControl = interfaceProvider.getPlaybackControl();
this.runMode = interfaceProvider.getCameraRunMode();
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ this.contentDownloader = new MyContentDownloader(getActivity(), playbackControl);
+ }
+ else
+ {
+ this.contentDownloader = null;
+ }
}
@Override
refresh();
return (true);
}
+ if (id == R.id.action_batch_download_original_size_raw)
+ {
+ // オリジナルサイズのダウンロード
+ startDownloadBatch(false);
+ return (true);
+ }
+ if (id == R.id.action_batch_download_640x480_raw)
+ {
+ // 小さいサイズのダウンロード
+ startDownloadBatch(true);
+ return (true);
+ }
+ if (id == R.id.action_select_all)
+ {
+ selectUnselectAll();
+ return (true);
+ }
return (super.onOptionsItemSelected(item));
}
// Threadで呼んではダメみたいだ...
runMode.changeRunMode(true);
}
-
+ try
+ {
+ // アクションバーは隠した状態に戻しておく
+ AppCompatActivity activity = (AppCompatActivity) getActivity();
+ if (activity != null)
+ {
+ ActionBar bar = activity.getSupportActionBar();
+ if (bar != null)
+ {
+ bar.hide();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ System.gc();
if (!executor.isShutdown())
{
executor.shutdownNow();
Log.v(TAG, "refreshImpl() end");
}
+
+ /**
+ * 全選択・全選択解除
+ *
+ */
+ private void selectUnselectAll()
+ {
+ if ((imageContentList == null)||(imageContentList.size() == 0))
+ {
+ // 選択されていない時は終わる。
+ return;
+ }
+
+ int nofSelected = 0;
+ for (CameraContentEx content : imageContentList)
+ {
+ if (content.isSelected())
+ {
+ nofSelected++;
+ }
+ }
+
+ // 全部選択されているときは全選択解除・そうでない時は全選択
+ boolean setSelected = (nofSelected != imageContentList.size());
+ for (CameraContentEx content : imageContentList)
+ {
+ content.setSelected(setSelected);
+ }
+
+ // グリッドビューの再描画
+ redrawGridView();
+ }
+
+
+ /**
+ * 一括ダウンロードの開始
+ *
+ * @param isSmall 小さいサイズ(JPEG)
+ */
+ private void startDownloadBatch(final boolean isSmall)
+ {
+ try
+ {
+ if ((imageContentList == null)||(imageContentList.size() == 0))
+ {
+ // 画像が選択されていない場合にはなにもしない。
+ return;
+ }
+
+ // 念のため、contentDownloader がなければ作る
+ if (contentDownloader == null)
+ {
+ Activity activity = getActivity();
+ if (activity == null)
+ {
+ // activityが取れない時には終わる。
+ return;
+ }
+ this.contentDownloader = new MyContentDownloader(getActivity(), playbackControl);
+ }
+ Thread thread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ // ダウンロード枚数を取得
+ int totalSize = 0;
+ for (CameraContentEx content : imageContentList)
+ {
+ if (content.isSelected())
+ {
+ totalSize++;
+ }
+ }
+ if (totalSize == 0)
+ {
+ // 画像が選択されていなかった...終了する
+ return;
+ }
+ int count = 1;
+ for (CameraContentEx content : imageContentList)
+ {
+ if (content.isSelected())
+ {
+ contentDownloader.startDownload(content.getFileInfo(), " (" + count + "/" + totalSize + ") ", null, isSmall);
+ count++;
+
+ // 画像の選択を落とす
+ content.setSelected(false);
+ }
+ }
+
+ // グリッドビューの再描画
+ redrawGridView();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ thread.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void redrawGridView()
+ {
+ // グリッドビューの再描画
+ Activity activity = getActivity();
+ if (activity != null)
+ {
+ getActivity().runOnUiThread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if (gridView != null)
+ {
+ gridView.invalidateViews();
+ }
+ }
+ });
+ }
+ }
+
private void runOnUiThread(Runnable action)
{
Activity activity = getActivity();
}
}
-
+ // AdapterView.OnItemLongClickListener
@Override
public boolean onItemLongClick(final AdapterView<?> parent, View view, int position, long id)
{
return (false);
}
-
// AdapterView.OnItemSelectedListener
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
if (infoEx != null)
{
ICameraContent fileInfo = infoEx.getFileInfo();
- contentDownloader.startDownload(fileInfo, (isRaw) ? infoEx.getRawSuffix() : null, isSmallSize);
+ contentDownloader.startDownload(fileInfo, "", (isRaw) ? infoEx.getRawSuffix() : null, isSmallSize);
}
}
});
package net.osdn.gokigen.pkremote.playback.detail;
-
-
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
-import android.widget.Toast;
+import android.view.View;
+
+import com.google.android.material.snackbar.Snackbar;
import net.osdn.gokigen.pkremote.R;
import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContent;
import java.util.Locale;
import androidx.annotation.NonNull;
-import androidx.appcompat.app.AlertDialog;
import androidx.preference.PreferenceManager;
/**
* コンテントのダウンロード
*
*/
-class MyContentDownloader implements IDownloadContentCallback
+public class MyContentDownloader implements IDownloadContentCallback
{
private final String TAG = toString();
private final Activity activity;
* コンストラクタ
*
*/
- MyContentDownloader(@NonNull Activity activity, @NonNull final IPlaybackControl playbackControl)
+ public MyContentDownloader(@NonNull Activity activity, @NonNull final IPlaybackControl playbackControl)
{
this.activity = activity;
this.playbackControl = playbackControl;
* ダウンロードの開始
*
*/
- void startDownload(final ICameraContent fileInfo, String replaceJpegSuffix, boolean isSmallSize)
+ public void startDownload(final ICameraContent fileInfo, final String appendTitle, String replaceJpegSuffix, boolean isSmallSize)
{
if (fileInfo == null)
{
if (targetFileName.toUpperCase().contains(RAW_SUFFIX_1))
{
mimeType = "image/x-adobe-dng";
+ isSmallSize = false;
}
else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_2))
{
mimeType = "image/x-olympus-orf";
+ isSmallSize = false;
}
else if (targetFileName.toUpperCase().contains(RAW_SUFFIX_3))
{
mimeType = "image/x-pentax-pef";
+ isSmallSize = false;
}
else if (targetFileName.toUpperCase().contains(MOVIE_SUFFIX))
{
mimeType = "video/mp4";
+ isSmallSize = false;
+ }
+ else
+ {
+ mimeType = "image/jpeg";
}
////// ダイアログの表示
@Override
public void run() {
downloadDialog = new ProgressDialog(activity);
- downloadDialog.setTitle(activity.getString(R.string.dialog_download_file_title));
+ downloadDialog.setTitle(activity.getString(R.string.dialog_download_file_title) + appendTitle);
downloadDialog.setMessage(activity.getString(R.string.dialog_download_message) + " " + targetFileName);
downloadDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
downloadDialog.setCancelable(false);
{
downloadDialog.dismiss();
}
- Toast.makeText(activity, activity.getString(R.string.download_control_save_success) + " " + targetFileName, Toast.LENGTH_SHORT).show();
+ View view = activity.findViewById(R.id.fragment1);
+ Snackbar.make(view, activity.getString(R.string.download_control_save_success) + " " + targetFileName, Snackbar.LENGTH_SHORT).show();
+ //Toast.makeText(activity, activity.getString(R.string.download_control_save_success) + " " + targetFileName, Toast.LENGTH_SHORT).show();
System.gc();
}
});
--- /dev/null
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:tint="#C0C0C0"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
+</vector>
xmlns:compat="http://schemas.android.com/apk/res-auto" >
<item
+ android:id="@+id/action_select_all"
+ compat:showAsAction="ifRoom"
+ android:icon="@drawable/ic_select_all_grey_24dp"
+ android:title="@string/action_select_all"
+ android:visible="true" />
+
+ <item
android:id="@+id/action_refresh"
compat:showAsAction="ifRoom"
- android:icon="@drawable/ic_refresh_black_24dp"
+ android:icon="@drawable/ic_refresh_grey_24dp"
android:title="@string/action_refresh"
android:visible="false" />
+ <item android:id="@+id/action_batch_download_with_raw"
+ compat:showAsAction="ifRoom"
+ android:icon="@drawable/ic_file_download_white_24dp"
+ android:title="@string/action_download"
+ android:visible="true" >
+ <menu>
+ <item
+ android:id="@+id/action_batch_download_original_size_raw"
+ compat:showAsAction="never"
+ android:title="@string/action_download_original_size"/>
+
+ <item
+ android:id="@+id/action_batch_download_640x480_raw"
+ compat:showAsAction="never"
+ android:title="@string/action_batch_download_640x480"/>
+
+ <!---->
+ <item
+ android:id="@+id/action_batch_download_raw"
+ compat:showAsAction="never"
+ android:visible="false"
+ android:title="@string/action_batch_download_raw"/>
+ <!---->
+ </menu>
+ </item>
+
<item
android:id="@+id/action_datetime_synchronize"
compat:showAsAction="ifRoom"
<string name="message_download_finished_pics_with_failure">Finished. # of Pics. : </string>
<string name="message_download_failure_count"> Failures : </string>
<string name="message_download_finished_but_failed">Download was failed… </string>
+
+ <string name="action_batch_download_640x480">Small Size(JPEG)</string>
+ <string name="action_batch_download_raw">Original Size(with RAW)</string>
+ <string name="action_select_all">Select All/Unselect All</string>
</resources>
android:title="@string/pref_use_gr2_special_command"
android:summary="@string/summary_use_gr2_special_command"
/>
-
+<!--
<CheckBoxPreference
android:key="pentax_capture_after_auto_focus"
android:title="@string/pref_pentax_capture_after_auto_focus"
android:summary="@string/summary_pentax_capture_after_auto_focus"
/>
+-->
</PreferenceCategory>
<PreferenceCategory