Browse Source

- added Daemon.supportsRemoteRssManagement()

- toggle menu visibility depending on version and connectivity
- renamed action_testing/openTesting() to action_remoterss/openRemoteRss()
- use Daemon.supportsRemoteRssManagement() instead of instanceof UtorrentAdapter
- display list of feeds in swipe menu
- UTorrentRssFeed now implements SimpleListItem
pull/313/head
twig 9 years ago
parent
commit
46c606610e
  1. 8
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  2. 13
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java
  3. 3
      app/src/main/java/org/transdroid/daemon/Daemon.java
  4. 8
      app/src/main/java/org/transdroid/daemon/Utorrent/data/UTorrentRssFeed.java
  5. 11
      app/src/main/res/menu/activity_torrents_main.xml
  6. 1
      app/src/main/res/values/strings.xml

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

@ -494,10 +494,12 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
filtersList.setVisibility(View.VISIBLE); filtersList.setVisibility(View.VISIBLE);
filterSearch.setVisibility(View.VISIBLE); filterSearch.setVisibility(View.VISIBLE);
boolean addByFile = Daemon.supportsAddByFile(currentConnection.getType()); boolean addByFile = Daemon.supportsAddByFile(currentConnection.getType());
boolean hasRemoteRss = Daemon.supportsRemoteRssManagement(currentConnection.getType());
addmenuFileButton.setVisibility(addByFile ? View.VISIBLE : View.GONE); addmenuFileButton.setVisibility(addByFile ? View.VISIBLE : View.GONE);
// Primary toolbar menu // Primary toolbar menu
torrentsToolbar.getMenu().findItem(R.id.action_search).setVisible(navigationHelper.enableSearchUi()); torrentsToolbar.getMenu().findItem(R.id.action_search).setVisible(navigationHelper.enableSearchUi());
torrentsToolbar.getMenu().findItem(R.id.action_rss).setVisible(navigationHelper.enableRssUi()); torrentsToolbar.getMenu().findItem(R.id.action_rss).setVisible(navigationHelper.enableRssUi());
torrentsToolbar.getMenu().findItem(R.id.action_remoterss).setVisible(navigationHelper.enableRssUi() && hasRemoteRss);
torrentsToolbar.getMenu().findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); torrentsToolbar.getMenu().findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
torrentsToolbar.getMenu().findItem(R.id.action_help).setVisible(false); torrentsToolbar.getMenu().findItem(R.id.action_help).setVisible(false);
// Secondary toolbar menu // Secondary toolbar menu
@ -850,9 +852,9 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
MainSettingsActivity_.intent(this).start(); MainSettingsActivity_.intent(this).start();
} }
@OptionsItem(R.id.action_testing) @OptionsItem(R.id.action_remoterss)
protected void openTesting() { protected void openRemoteRss() {
if (currentConnection instanceof UtorrentAdapter) { if (Daemon.supportsRemoteRssManagement(currentConnection.getType())) {
ArrayList<UTorrentRssFeed> rssFeedItems = ((UtorrentAdapter) (currentConnection)).getRemoteRssFeeds(); ArrayList<UTorrentRssFeed> rssFeedItems = ((UtorrentAdapter) (currentConnection)).getRemoteRssFeeds();
RemoteRssActivity_.intent(this) RemoteRssActivity_.intent(this)

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

@ -22,12 +22,14 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.widget.ListView;
import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra; import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.FragmentById; import org.androidannotations.annotations.FragmentById;
import org.androidannotations.annotations.InstanceState; import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu; import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
@ -35,6 +37,7 @@ import org.transdroid.R;
import org.transdroid.core.app.settings.SystemSettings_; import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.TorrentsActivity; import org.transdroid.core.gui.TorrentsActivity;
import org.transdroid.core.gui.TorrentsActivity_; import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.daemon.Utorrent.data.UTorrentRssFeed; import org.transdroid.daemon.Utorrent.data.UTorrentRssFeed;
import java.util.ArrayList; import java.util.ArrayList;
@ -59,6 +62,9 @@ public class RemoteRssActivity extends AppCompatActivity {
@ViewById @ViewById
protected Toolbar torrentsToolbar; protected Toolbar torrentsToolbar;
@ViewById
protected ListView drawerList;
@FragmentById(R.id.remoterss_fragment) @FragmentById(R.id.remoterss_fragment)
protected RemoteRssFragment fragmentRemoteRss; protected RemoteRssFragment fragmentRemoteRss;
@ -96,6 +102,8 @@ public class RemoteRssActivity extends AppCompatActivity {
// TODO: show all items // TODO: show all items
fragmentRemoteRss.updateTorrentFiles(feeds.get(0).files); fragmentRemoteRss.updateTorrentFiles(feeds.get(0).files);
drawerList.setAdapter(new SimpleListItemAdapter(this, feeds));
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ -314,4 +322,9 @@ public class RemoteRssActivity extends AppCompatActivity {
// fragmentDetails.perhapsUpdateTorrent(torrents); // fragmentDetails.perhapsUpdateTorrent(torrents);
// fragmentDetails.updateLabels(Label.convertToNavigationLabels(labels, getResources().getString(R.string.labels_unlabeled))); // fragmentDetails.updateLabels(Label.convertToNavigationLabels(labels, getResources().getString(R.string.labels_unlabeled)));
// } // }
@ItemClick(R.id.drawer_list)
protected void onFeedSelected(int position) {
fragmentRemoteRss.updateTorrentFiles(feeds.get(position).files);
}
} }

3
app/src/main/java/org/transdroid/daemon/Daemon.java

@ -375,4 +375,7 @@ public enum Daemon {
return type == Deluge || type == Aria2; return type == Deluge || type == Aria2;
} }
public static boolean supportsRemoteRssManagement(Daemon type) {
return type == uTorrent;
}
} }

8
app/src/main/java/org/transdroid/daemon/Utorrent/data/UTorrentRssFeed.java

@ -6,6 +6,7 @@ import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.transdroid.core.gui.lists.SimpleListItem;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -13,7 +14,7 @@ import java.util.List;
/** /**
* Created by twig on 29/05/2016. * Created by twig on 29/05/2016.
*/ */
public class UTorrentRssFeed implements Parcelable { public class UTorrentRssFeed implements Parcelable, SimpleListItem {
/** /**
* [ * [
* 1, // id? * 1, // id?
@ -166,4 +167,9 @@ public class UTorrentRssFeed implements Parcelable {
return new UTorrentRssFeed[size]; return new UTorrentRssFeed[size];
} }
}; };
@Override
public String getName() {
return feedAlias;
}
} }

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

@ -28,6 +28,11 @@
android:icon="@drawable/ic_action_rss" android:icon="@drawable/ic_action_rss"
android:title="@string/action_rss" android:title="@string/action_rss"
app:showAsAction="ifRoom" /> app:showAsAction="ifRoom" />
<item
android:id="@+id/action_remoterss"
android:icon="@drawable/ic_action_rss"
android:title="@string/action_remoterss"
app:showAsAction="ifRoom" />
<item <item
android:id="@+id/action_help" android:id="@+id/action_help"
android:title="@string/action_help" android:title="@string/action_help"
@ -36,10 +41,4 @@
android:id="@+id/action_settings" android:id="@+id/action_settings"
android:title="@string/action_settings" android:title="@string/action_settings"
app:showAsAction="always" /> app:showAsAction="always" />
<item
android:id="@+id/action_testing"
android:title="testing"
app:showAsAction="always" />
</menu> </menu>

1
app/src/main/res/values/strings.xml

@ -25,6 +25,7 @@
<string name="action_search">Search</string> <string name="action_search">Search</string>
<string name="action_refresh">Refresh</string> <string name="action_refresh">Refresh</string>
<string name="action_rss">RSS</string> <string name="action_rss">RSS</string>
<string name="action_remoterss">Server RSS</string>
<string name="action_enableturtle">Enable turtle mode</string> <string name="action_enableturtle">Enable turtle mode</string>
<string name="action_disableturtle">Disable turtle mode</string> <string name="action_disableturtle">Disable turtle mode</string>
<string name="action_sort">Sort list</string> <string name="action_sort">Sort list</string>

Loading…
Cancel
Save