Browse Source

- removed supportsRemoteRssManagement() check in openRemoteRss()

- show/hide remote rss navigation drawer according to normal behaviour
- change nav drawer icon
- removed cruft code
- close drawer on filter selection
- init rssFeedItems
pull/313/head
twig 8 years ago
parent
commit
6d58d1186b
  1. 18
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  2. 238
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java
  3. 2
      app/src/main/java/org/transdroid/daemon/Utorrent/UtorrentAdapter.java
  4. 9
      app/src/main/res/drawable/ic_cloud_download.xml
  5. 2
      app/src/main/res/menu/activity_torrents_main.xml

18
app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java

@ -855,18 +855,16 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -855,18 +855,16 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
@OptionsItem(R.id.action_remoterss)
protected void openRemoteRss() {
if (Daemon.supportsRemoteRssManagement(currentConnection.getType())) {
ArrayList<RemoteRssChannel> rssFeedItems = ((UtorrentAdapter) (currentConnection)).getRemoteRssChannels();
ArrayList<RemoteRssChannel> rssFeedItems = ((UtorrentAdapter) (currentConnection)).getRemoteRssChannels();
if (rssFeedItems.size() == 0) {
return;
}
RemoteRssActivity_.intent(this)
.feeds(rssFeedItems)
.start()
;
if (rssFeedItems.size() == 0) {
return;
}
RemoteRssActivity_.intent(this)
.feeds(rssFeedItems)
.start()
;
}
@OptionsItem(R.id.action_help)

238
app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java

@ -17,12 +17,13 @@ @@ -17,12 +17,13 @@
package org.transdroid.core.gui.remoterss;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.LinearLayout;
import android.widget.ListView;
import org.androidannotations.annotations.AfterViews;
@ -39,7 +40,6 @@ import org.transdroid.core.app.settings.ApplicationSettings; @@ -39,7 +40,6 @@ import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.TorrentsActivity;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.remoterss.data.RemoteRssChannel;
import org.transdroid.core.gui.remoterss.data.RemoteRssItem;
@ -77,6 +77,11 @@ public class RemoteRssActivity extends AppCompatActivity { @@ -77,6 +77,11 @@ public class RemoteRssActivity extends AppCompatActivity {
private IDaemonAdapter currentConnection;
// Details view components
@ViewById
protected DrawerLayout drawerLayout;
@ViewById
protected LinearLayout drawerContainer;
@ViewById
protected Toolbar torrentsToolbar;
@ -105,6 +110,7 @@ public class RemoteRssActivity extends AppCompatActivity { @@ -105,6 +110,7 @@ public class RemoteRssActivity extends AppCompatActivity {
}
// Simple action bar with up, torrent name as title and refresh button
torrentsToolbar.setNavigationIcon(R.drawable.ic_action_drawer);
setSupportActionBar(torrentsToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(torrent.getName()));
@ -120,222 +126,26 @@ public class RemoteRssActivity extends AppCompatActivity { @@ -120,222 +126,26 @@ public class RemoteRssActivity extends AppCompatActivity {
showChannelFilters();
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
TorrentsActivity_.intent(this)
.flags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.start();
if (drawerLayout.isDrawerOpen(drawerContainer)) {
drawerLayout.closeDrawers();
} else {
drawerLayout.openDrawer(drawerContainer);
}
}
// @OptionsItem(R.id.action_refresh)
// public void refreshScreen() {
// fragmentRemoteRss.updateIsLoading(true, null);
// refreshTorrent();
// refreshTorrentDetails(torrent);
// refreshTorrentFiles(torrent);
// }
// @Background
// protected void refreshTorrent() {
// DaemonTaskResult result = RetrieveTask.create(currentConnection).execute(log);
// if (result instanceof RetrieveTaskSuccessResult) {
// onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(), ((RetrieveTaskSuccessResult) result).getLabels());
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, true);
// }
// }
//
// @Background
// public void refreshTorrentDetails(Torrent torrent) {
// if (!Daemon.supportsFineDetails(torrent.getDaemon())) {
// return;
// }
// DaemonTaskResult result = GetTorrentDetailsTask.create(currentConnection, torrent).execute(log);
// if (result instanceof GetTorrentDetailsTaskSuccessResult) {
// onTorrentDetailsRetrieved(torrent, ((GetTorrentDetailsTaskSuccessResult) result).getTorrentDetails());
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// public void refreshTorrentFiles(Torrent torrent) {
// if (!Daemon.supportsFileListing(torrent.getDaemon())) {
// return;
// }
// DaemonTaskResult result = GetFileListTask.create(currentConnection, torrent).execute(log);
// if (result instanceof GetFileListTaskSuccessResult) {
// onTorrentFilesRetrieved(torrent, ((GetFileListTaskSuccessResult) result).getFiles());
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void resumeTorrent(Torrent torrent) {
// torrent.mimicResume();
// DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void pauseTorrent(Torrent torrent) {
// torrent.mimicPause();
// DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void startTorrent(Torrent torrent, boolean forced) {
// torrent.mimicStart();
// DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void stopTorrent(Torrent torrent) {
// torrent.mimicStop();
// DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void removeTorrent(Torrent torrent, boolean withData) {
// DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// // Close the details activity (as the torrent is now removed)
// closeActivity(getString(withData ? R.string.result_removed_with_data : R.string.result_removed, torrent.getName()));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @UiThread
// protected void closeActivity(String closeText) {
// setResult(RESULT_OK, new Intent().putExtra("torrent_removed", true).putExtra("affected_torrent", torrent));
// finish();
// if (closeText != null) {
// SnackbarManager.show(Snackbar.with(this).text(closeText));
// }
// }
//
// @Background
// @Override
// public void updateLabel(Torrent torrent, String newLabel) {
// torrent.mimicNewLabel(newLabel);
// DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void forceRecheckTorrent(Torrent torrent) {
// torrent.mimicCheckingStatus();
// DaemonTaskResult result = ForceRecheckTask.create(currentConnection, torrent).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_recheckedstarted, torrent.getName()));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void updateTrackers(Torrent torrent, List<String> newTrackers) {
// DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void updateLocation(Torrent torrent, String newLocation) {
// DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @Background
// @Override
// public void updatePriority(Torrent torrent, List<TorrentFile> files, Priority priority) {
// DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority, new ArrayList<>(files)).execute(log);
// if (result instanceof DaemonTaskSuccessResult) {
// onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
// } else {
// onCommunicationError((DaemonTaskFailureResult) result, false);
// }
// }
//
// @UiThread
// protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
// // Set the activity result so the calling activity knows it needs to update its view
// setResult(RESULT_OK, new Intent().putExtra("torrent_updated", true).putExtra("affected_torrent", torrent));
// // Refresh the screen as well
// refreshTorrent();
// refreshTorrentDetails(torrent);
// SnackbarManager.show(Snackbar.with(this).text(successMessage));
// }
//
// @UiThread
// protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) {
// // Update the details fragment with the new fine details for the shown torrent
// fragmentDetails.updateTorrentDetails(torrent, torrentDetails);
// }
//
// @UiThread
// protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) {
// // Update the details fragment with the newly retrieved list of files
// fragmentDetails.updateTorrentFiles(torrent, new ArrayList<>(torrentFiles));
// }
//
// @UiThread
// protected void onCommunicationError(DaemonTaskFailureResult result, boolean isCritical) {
// log.i(this, result.getException().toString());
// String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
// fragmentDetails.updateIsLoading(false, isCritical ? error : null);
// SnackbarManager.show(Snackbar.with(this).text(getString(LocalTorrent.getResourceForDaemonException(result.getException())))
// .colorResource(R.color.red));
// }
//
// @UiThread
// protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) {
// // Update the details fragment accordingly
// fragmentDetails.updateIsLoading(false, null);
// fragmentDetails.perhapsUpdateTorrent(torrents);
// fragmentDetails.updateLabels(Label.convertToNavigationLabels(labels, getResources().getString(R.string.labels_unlabeled)));
// }
@Override
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(drawerContainer)) {
drawerLayout.closeDrawers();
} else {
finish();
}
}
protected void showRecentItems() {
if (recentItems == null) {
@ -389,6 +199,8 @@ public class RemoteRssActivity extends AppCompatActivity { @@ -389,6 +199,8 @@ public class RemoteRssActivity extends AppCompatActivity {
else {
fragmentRemoteRss.updateTorrentFiles(feeds.get(position -1).getItems());
}
drawerLayout.closeDrawers();
}
public IDaemonAdapter getCurrentConnection() {

2
app/src/main/java/org/transdroid/daemon/Utorrent/UtorrentAdapter.java

@ -117,7 +117,7 @@ public class UtorrentAdapter implements IDaemonAdapter { @@ -117,7 +117,7 @@ public class UtorrentAdapter implements IDaemonAdapter {
private DaemonSettings settings;
private DefaultHttpClient httpclient;
private static ArrayList<RemoteRssChannel> rssFeedItems;
private static ArrayList<RemoteRssChannel> rssFeedItems = new ArrayList<>();

9
app/src/main/res/drawable/ic_cloud_download.xml

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z"/>
</vector>

2
app/src/main/res/menu/activity_torrents_main.xml

@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_remoterss"
android:icon="@drawable/ic_action_rss"
android:icon="@drawable/ic_cloud_download"
android:title="@string/action_remoterss"
app:showAsAction="ifRoom" />
<item

Loading…
Cancel
Save