diff --git a/res/layout/add_to_favorite.xml b/res/layout/add_to_favorite.xml index 708690a1c..5e5cce3a1 100644 --- a/res/layout/add_to_favorite.xml +++ b/res/layout/add_to_favorite.xml @@ -28,7 +28,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/res/layout/dialog_message_checkbox.xml b/res/layout/dialog_message_checkbox.xml new file mode 100644 index 000000000..fe57c9cf5 --- /dev/null +++ b/res/layout/dialog_message_checkbox.xml @@ -0,0 +1,36 @@ + + + + + + + + + diff --git a/res/layout/download_list_item.xml b/res/layout/download_list_item.xml index a801c50d3..dd06bb002 100644 --- a/res/layout/download_list_item.xml +++ b/res/layout/download_list_item.xml @@ -74,7 +74,7 @@ android:layout_marginRight="16dp" android:layout_marginTop="10dp" /> - - - - - - - - - @@ -143,6 +117,16 @@ android:layout_weight="1" android:text="@string/detail" /> + + diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 99b4cbef0..f204e1f09 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -105,6 +105,7 @@ 下载失败 %d 项 下载成功 %d, 下载失败 %d 下载成功 %d 项, 下载失败 %d 项 + 该下载项将被删除 网络错误 diff --git a/res/values/ids.xml b/res/values/ids.xml index 55ef759ae..37f3a10b1 100644 --- a/res/values/ids.xml +++ b/res/values/ids.xml @@ -19,5 +19,6 @@ + \ No newline at end of file diff --git a/src/com/hippo/ehviewer/ui/DownloadActivity.java b/src/com/hippo/ehviewer/ui/DownloadActivity.java index 4979d2e06..941242663 100644 --- a/src/com/hippo/ehviewer/ui/DownloadActivity.java +++ b/src/com/hippo/ehviewer/ui/DownloadActivity.java @@ -18,6 +18,7 @@ package com.hippo.ehviewer.ui; import java.util.List; +import android.annotation.SuppressLint; import android.app.ActionBar; import android.content.BroadcastReceiver; import android.content.Context; @@ -33,6 +34,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; +import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; @@ -216,10 +218,8 @@ public class DownloadActivity extends AbsActivity { View read = convertView.findViewById(R.id.read); TextView action = (TextView)convertView.findViewById(R.id.action); - View delete1 = convertView.findViewById(R.id.delete1); - View delete2 = convertView.findViewById(R.id.delete2); View detail = convertView.findViewById(R.id.detail); - + View delete = convertView.findViewById(R.id.delete); read.setOnClickListener(new View.OnClickListener() { @Override @@ -231,8 +231,7 @@ public class DownloadActivity extends AbsActivity { startActivity(intent); } }); - delete1.setOnClickListener(new Delete1Action(di)); - delete2.setOnClickListener(new Delete2Action(di)); + delete.setOnClickListener(new DeleteAction(di)); detail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -309,46 +308,30 @@ public class DownloadActivity extends AbsActivity { } } - private class Delete1Action implements View.OnClickListener { + private class DeleteAction implements View.OnClickListener { + + private static final String KEY_INCLUDE_PIC = "include_pic"; + public DownloadInfo mDownloadInfo; - public Delete1Action(DownloadInfo di) { + public DeleteAction(DownloadInfo di) { mDownloadInfo = di; } @Override + @SuppressLint("InflateParams") public void onClick(View v) { + final View view = LayoutInflater.from(DownloadActivity.this).inflate( + R.layout.dialog_message_checkbox, null); + final TextView message = (TextView) view.findViewById(R.id.message); + final CheckBox cb = (CheckBox) view.findViewById(R.id.checkbox); + message.setText(R.string.delete_item); + cb.setText("包括图片"); + cb.setChecked(Config.getBoolean(KEY_INCLUDE_PIC, false)); + new MaterialAlertDialog.Builder(DownloadActivity.this).setTitle(R.string.attention) - .setMessage(R.string.delete) - .setPositiveButton(android.R.string.ok) - .setNegativeButton(android.R.string.cancel) - .setButtonListener(new MaterialAlertDialog.OnClickListener() { - @Override - public boolean onClick(MaterialAlertDialog dialog, int which) { - if (which == MaterialAlertDialog.POSITIVE) { - Intent it = new Intent(DownloadActivity.this, DownloadService.class); - startService(it); - mServiceConn.getService().delete(mDownloadInfo); - } - return true; - } - }).show(); - } - } - - private class Delete2Action implements View.OnClickListener { - public DownloadInfo mDownloadInfo; - - public Delete2Action(DownloadInfo di) { - mDownloadInfo = di; - } - - @Override - public void onClick(View v) { - new MaterialAlertDialog.Builder(DownloadActivity.this).setTitle(R.string.attention) - .setMessage(R.string.delete2) - .setPositiveButton(android.R.string.ok) - .setNegativeButton(android.R.string.cancel) + .setView(view, true) + .setDefaultButton(MaterialAlertDialog.POSITIVE | MaterialAlertDialog.NEGATIVE) .setButtonListener(new MaterialAlertDialog.OnClickListener() { @Override public boolean onClick(MaterialAlertDialog dialog, int which) { @@ -357,8 +340,12 @@ public class DownloadActivity extends AbsActivity { startService(it); mServiceConn.getService().delete(mDownloadInfo); // Delete dir - GalleryInfo gi = mDownloadInfo.galleryInfo; - Utils.deleteDirInThread(EhUtils.getGalleryDir(gi.gid, gi.title)); + if (cb.isChecked()) { + GalleryInfo gi = mDownloadInfo.galleryInfo; + Utils.deleteDirInThread(EhUtils.getGalleryDir(gi.gid, gi.title)); + } + // Remember delete choice + Config.setBoolean(KEY_INCLUDE_PIC, cb.isChecked()); } return true; }