Browse Source

Properly show torrent action success result messages.

pull/11/head
Eric Kok 12 years ago
parent
commit
2fc1c75955
  1. 8
      core/res/values/strings.xml
  2. 2
      core/src/org/transdroid/core/app/settings/SettingsPersistence.java
  3. 27
      core/src/org/transdroid/core/gui/DetailsActivity.java
  4. 36
      core/src/org/transdroid/core/gui/TorrentsActivity.java

8
core/res/values/strings.xml

@ -90,12 +90,12 @@ @@ -90,12 +90,12 @@
<string name="result_removed">%1$s removed</string>
<string name="result_removed_with_data">%1$s removed and data deleted</string>
<string name="result_resumed">%1$s resumed (refreshing)</string>
<string name="result_stopped">%1$s stopped</string>
<string name="result_stopped">%1$s stopped (refreshing)</string>
<string name="result_started">%1$s started (refreshing)</string>
<string name="result_paused">%1$s paused</string>
<string name="result_paused_all">Torrents paused</string>
<string name="result_paused">%1$s paused (refreshing)</string>
<string name="result_paused_all">Torrents paused (refreshing)</string>
<string name="result_resumed_all">Torrents resumed (refreshing)</string>
<string name="result_stopped_all">Torrents stopped</string>
<string name="result_stopped_all">Torrents stopped (refreshing)</string>
<string name="result_started_all">Torrents started (refreshing)</string>
<string name="result_trackersupdated">Trackers updated</string>
<string name="result_labelset">Label set to \'%1$s\'</string>

2
core/src/org/transdroid/core/app/settings/SettingsPersistence.java

@ -194,7 +194,7 @@ public class SettingsPersistence { @@ -194,7 +194,7 @@ public class SettingsPersistence {
server.put("downloads_dir", prefs.getString("server_downloaddir_" + postfixi, null));
server.put("base_ftp_url", prefs.getString("server_ftpurl_" + postfixi, null));
server.put("ftp_password", prefs.getString("server_ftppass_" + postfixi, null));
server.put("server_timeout", prefs.getString("server_ftppass_" + postfixi, null));
server.put("server_timeout", prefs.getString("server_timeout_" + postfixi, null));
server.put("download_alarm", prefs.getBoolean("server_alarmfinished_" + postfixi, false));
server.put("new_torrent_alarm", prefs.getBoolean("server_alarmnew_" + postfixi, false));

27
core/src/org/transdroid/core/gui/DetailsActivity.java

@ -158,7 +158,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -158,7 +158,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
torrent.mimicResume();
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_resumed);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
@ -170,7 +170,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -170,7 +170,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
torrent.mimicPause();
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_paused);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
@ -182,7 +182,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -182,7 +182,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
torrent.mimicStart();
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_started);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
@ -194,7 +194,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -194,7 +194,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
torrent.mimicStop();
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_stopped);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
@ -205,8 +205,9 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -205,8 +205,9 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void removeTorrent(Torrent torrent, boolean withData) {
DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, withData ? R.string.result_removed_with_data
: R.string.result_removed);
onTaskSucceeded(
(DaemonTaskSuccessResult) result,
getString(withData ? R.string.result_removed_with_data : R.string.result_removed, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
@ -218,7 +219,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -218,7 +219,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
torrent.mimicNewLabel(newLabel);
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_labelset, newLabel);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
@ -229,7 +230,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -229,7 +230,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void updateTrackers(Torrent torrent, List<String> newTrackers) {
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_trackersupdated);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
@ -240,16 +241,18 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -240,16 +241,18 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void updateLocation(Torrent torrent, String newLocation) {
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_locationset, newLocation);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else {
onCommunicationError((DaemonTaskFailureResult) result);
}
}
@UiThread
protected void onTaskSucceeded(DaemonTaskSuccessResult result, int successMessageId, String... messageParams) {
Crouton.showText(this, getString(successMessageId, (Object[]) messageParams),
navigationHelper.CROUTON_INFO_STYLE);
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
// Refresh the screen as well
refreshTorrent();
refreshTorrentDetails(torrent);
Crouton.showText(this, successMessage, navigationHelper.CROUTON_INFO_STYLE);
}
@UiThread

36
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -20,16 +20,11 @@ import org.androidannotations.annotations.SystemService; @@ -20,16 +20,11 @@ import org.androidannotations.annotations.SystemService;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.log.*;
import org.transdroid.core.gui.navigation.*;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.search.BarcodeHelper;
import org.transdroid.core.gui.search.FilePickerHelper;
import org.transdroid.core.gui.search.UrlEntryDialog;
@ -584,7 +579,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -584,7 +579,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void addTorrentByUrl(String url, String title) {
DaemonTaskResult result = AddByUrlTask.create(currentConnection, url, title).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_added, title);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, title));
refreshTorrents();
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@ -595,7 +590,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -595,7 +590,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
protected void addTorrentByMagnetUrl(String url) {
DaemonTaskResult result = AddByMagnetUrlTask.create(currentConnection, url).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_added, "Torrent");
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, "Torrent"));
refreshTorrents();
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@ -606,7 +601,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -606,7 +601,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
protected void addTorrentByFile(String localFile, String title) {
DaemonTaskResult result = AddByFileTask.create(currentConnection, localFile).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_added, title);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, title));
refreshTorrents();
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
@ -656,7 +651,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -656,7 +651,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent.mimicResume();
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_resumed);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -668,7 +663,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -668,7 +663,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent.mimicPause();
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_paused);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -680,7 +675,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -680,7 +675,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent.mimicStart();
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_started);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -692,7 +687,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -692,7 +687,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent.mimicStop();
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_stopped);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -703,8 +698,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -703,8 +698,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void removeTorrent(Torrent torrent, boolean withData) {
DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, withData ? R.string.result_removed_with_data
: R.string.result_removed);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(withData ? R.string.result_removed_with_data
: R.string.result_removed));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -716,7 +711,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -716,7 +711,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent.mimicNewLabel(newLabel);
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_labelset, newLabel);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -727,7 +722,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -727,7 +722,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updateTrackers(Torrent torrent, List<String> newTrackers) {
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_trackersupdated);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
@ -738,16 +733,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -738,16 +733,17 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updateLocation(Torrent torrent, String newLocation) {
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute();
if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, R.string.result_locationset, newLocation);
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@UiThread
protected void onTaskSucceeded(DaemonTaskSuccessResult result, int successMessageId, String... messageParams) {
Crouton.showText(this, getString(successMessageId, (Object[]) messageParams),
navigationHelper.CROUTON_INFO_STYLE);
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
// Refresh the screen as well
refreshScreen();
Crouton.showText(this, successMessage, navigationHelper.CROUTON_INFO_STYLE);
}
@UiThread

Loading…
Cancel
Save