From 91552322be3518e049bfe09c3a79f51b485b9b3e Mon Sep 17 00:00:00 2001 From: Kumaresan Rajeswaran Date: Sat, 11 Jul 2015 19:45:34 +0530 Subject: [PATCH] Fixing indent, improving delete logic --- .../transdroid/core/gui/ConfirmRemoveDialog.java | 7 +++++-- .../org/transdroid/core/gui/DetailsFragment.java | 2 +- .../org/transdroid/core/gui/TorrentsActivity.java | 14 +++++++------- .../org/transdroid/core/gui/TorrentsFragment.java | 2 +- .../core/gui/navigation/NavigationHelper.java | 2 -- .../gui/settings/PreferenceCompatActivity.java | 10 +++++----- app/src/main/res/menu/fragment_torrents_cab.xml | 2 +- app/src/main/res/values/strings.xml | 4 ++-- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/org/transdroid/core/gui/ConfirmRemoveDialog.java b/app/src/main/java/org/transdroid/core/gui/ConfirmRemoveDialog.java index 89aa3593..675a160e 100644 --- a/app/src/main/java/org/transdroid/core/gui/ConfirmRemoveDialog.java +++ b/app/src/main/java/org/transdroid/core/gui/ConfirmRemoveDialog.java @@ -6,6 +6,7 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import org.transdroid.R; +import org.transdroid.daemon.Daemon; import org.transdroid.daemon.Torrent; import java.util.List; @@ -13,7 +14,7 @@ import java.util.List; public class ConfirmRemoveDialog { /** - * Opens a dialog that confirms the removal of a torrent, along with an option for with deleting downloaded files + * Opens a dialog that confirms the removal of a torrent, along with an option for deleting downloaded files * @param activity The torrents activity from which the dialog is started (and which received the callback) * @param torrents List of torrents to be removed */ @@ -34,7 +35,9 @@ public class ConfirmRemoveDialog { @Override public void onClick(DialogInterface dialog, int which) { for (Torrent torrent : torrents) { - activity.removeTorrent(torrent, isRemoveDataChecked[0]); + boolean shouldRemoveData = isRemoveDataChecked[0] && + Daemon.supportsRemoveWithData(torrent.getDaemon()); + activity.removeTorrent(torrent, shouldRemoveData); } dialog.dismiss(); } diff --git a/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java b/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java index 66e220b2..b9dcdda8 100644 --- a/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/DetailsFragment.java @@ -391,7 +391,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @OptionsItem(resName = "action_remove") protected void removeTorrent() { - ConfirmRemoveDialog.startConfirmRemove((TorrentsActivity) getActivity(), Arrays.asList(torrent)); + ConfirmRemoveDialog.startConfirmRemove((TorrentsActivity) getActivity(), Arrays.asList(torrent)); } @OptionsItem(R.id.action_setlabel) diff --git a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java index 1b67e898..151d1345 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java @@ -238,13 +238,13 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE torrentsToolbar.addView(serverSelectionView); } actionsToolbar.addView(serverStatusView); -// actionsToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { -// @Override -// public boolean onMenuItemClick(MenuItem menuItem) { -// // Redirect to the classic activity implementation so we can use @OptionsItem methods -// return onOptionsItemSelected(menuItem); -// } -// }); + actionsToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem menuItem) { + // Redirect to the classic activity implementation so we can use @OptionsItem methods + return onOptionsItemSelected(menuItem); + } + }); setSupportActionBar(torrentsToolbar); // For direct menu item inflation by the contained fragments getSupportActionBar().setDisplayShowTitleEnabled(false); diff --git a/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java b/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java index 0e09c09e..9c9d28a7 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java @@ -340,7 +340,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener mode.finish(); return true; } else if (itemId == R.id.action_remove) { - ConfirmRemoveDialog.startConfirmRemove((TorrentsActivity) getActivity(), checked); + ConfirmRemoveDialog.startConfirmRemove((TorrentsActivity) getActivity(), checked); mode.finish(); return true; } else if (itemId == R.id.action_setlabel) { diff --git a/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java b/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java index 157d31cf..cf468199 100644 --- a/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java +++ b/app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java @@ -123,8 +123,6 @@ public class NavigationHelper { if (imageCache == null) { imageCache = ImageLoader.getInstance(); try { -// LruDiskCache diskCache = -// new LruDiskCache(context.getCacheDir(), null, new Md5FileNameGenerator(), 640000, 25); LruDiscCache diskCache = new LruDiscCache(context.getCacheDir(), null, new Md5FileNameGenerator(), 640000, 25); // @formatter:off Builder imageCacheBuilder = new Builder(context) diff --git a/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java b/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java index a2f3f8fb..f6b12ff9 100644 --- a/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java @@ -64,9 +64,9 @@ public class PreferenceCompatActivity extends PreferenceActivity implements AppC } - @Nullable - @Override - public ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback) { - return null; - } + @Nullable + @Override + public ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback) { + return null; + } } diff --git a/app/src/main/res/menu/fragment_torrents_cab.xml b/app/src/main/res/menu/fragment_torrents_cab.xml index 5445774f..db770f4c 100644 --- a/app/src/main/res/menu/fragment_torrents_cab.xml +++ b/app/src/main/res/menu/fragment_torrents_cab.xml @@ -39,7 +39,7 @@ app:showAsAction="always" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24263cf8..40ac8620 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -96,8 +96,8 @@ Select finished Invert selection Add torrent to… - Confirm torrent removal? - Also remove downloaded files? + Confirm torrent removal? + Also remove downloaded files? http://… STATUS: %1$s