Browse Source

- removed remoterss/RemoteRssActivity.java

- removed activity_remoterss.xml
- removed menu item to RemoteRssActivity.java
pull/526/head
Twig N 5 years ago
parent
commit
226a9795b7
  1. 12
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  2. 256
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java
  3. 79
      app/src/main/res/layout/activity_remoterss.xml
  4. 5
      app/src/main/res/menu/activity_torrents_main.xml

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

@ -82,7 +82,6 @@ import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.RefreshableActivity; import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.navigation.StatusType; import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.remoterss.RemoteRssActivity_;
import org.transdroid.core.gui.rss.RssfeedsActivity_; import org.transdroid.core.gui.rss.RssfeedsActivity_;
import org.transdroid.core.gui.search.FilePickerHelper; import org.transdroid.core.gui.search.FilePickerHelper;
import org.transdroid.core.gui.search.UrlEntryDialog; import org.transdroid.core.gui.search.UrlEntryDialog;
@ -469,7 +468,6 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
filterSearch.setVisibility(View.GONE); filterSearch.setVisibility(View.GONE);
torrentsToolbar.getMenu().findItem(R.id.action_search).setVisible(false); torrentsToolbar.getMenu().findItem(R.id.action_search).setVisible(false);
torrentsToolbar.getMenu().findItem(R.id.action_rss).setVisible(false); torrentsToolbar.getMenu().findItem(R.id.action_rss).setVisible(false);
torrentsToolbar.getMenu().findItem(R.id.action_remoterss).setVisible(false);
torrentsToolbar.getMenu().findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); torrentsToolbar.getMenu().findItem(R.id.action_settings).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
torrentsToolbar.getMenu().findItem(R.id.action_help).setVisible(true); torrentsToolbar.getMenu().findItem(R.id.action_help).setVisible(true);
actionsToolbar.getMenu().findItem(R.id.action_enableturtle).setVisible(false); actionsToolbar.getMenu().findItem(R.id.action_enableturtle).setVisible(false);
@ -493,12 +491,10 @@ 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(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
@ -821,14 +817,6 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
MainSettingsActivity_.intent(this).start(); MainSettingsActivity_.intent(this).start();
} }
@OptionsItem(R.id.action_remoterss)
@Background
protected void openRemoteRss() {
// Passing the items over as a feed can overload the Intent size limit and crash without a stack trace.
// Loading the items can take a while so we don't want to load them here and again in the RemoteRssActivity.
RemoteRssActivity_.intent(this).start();
}
@OptionsItem(R.id.action_help) @OptionsItem(R.id.action_help)
protected void openHelp() { protected void openHelp() {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.transdroid.org/download/"))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.transdroid.org/download/")));

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

@ -1,256 +0,0 @@
/*
* Copyright 2010-2018 Eric Kok et al.
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.gui.remoterss;
import android.annotation.TargetApi;
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 com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.enums.SnackbarType;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.FragmentById;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick;
import org.androidannotations.annotations.NonConfigurationInstance;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
import org.transdroid.R;
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.lists.LocalTorrent;
import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.remoterss.data.RemoteRssChannel;
import org.transdroid.core.gui.remoterss.data.RemoteRssItem;
import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier;
import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.IDaemonAdapter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
/**
* An activity that displays a list of {@link RemoteRssItem}s via an instance of {@link RemoteRssFragment}.
* The activity manages the drawer to filter items by the feed they came through.
*
* By default it displays the latest items within the last month.
*
* @author Twig Nguyen
*/
@EActivity(R.layout.activity_remoterss)
public class RemoteRssActivity extends AppCompatActivity {
// @NonConfigurationInstance
// protected ArrayList<RemoteRssChannel> feeds;
// @InstanceState
// protected int selectedFilter;
// @NonConfigurationInstance
// protected ArrayList<RemoteRssItem> recentItems;
// Server connection
@Bean
protected ApplicationSettings applicationSettings;
@Bean
protected Log log;
// @Bean
// protected ConnectivityHelper connectivityHelper;
// private IDaemonAdapter currentConnection;
// Details view components
@ViewById
protected DrawerLayout drawerLayout;
@ViewById
protected LinearLayout drawerContainer;
@ViewById
protected Toolbar torrentsToolbar;
@ViewById
protected ListView drawerList;
@FragmentById(R.id.remoterss_fragment)
protected RemoteRssFragment fragmentRemoteRss;
@Override
public void onCreate(Bundle savedInstanceState) {
// Set the theme according to the user preference
if (SystemSettings_.getInstance_(this).useDarkTheme()) {
setTheme(R.style.TransdroidTheme_Dark);
}
super.onCreate(savedInstanceState);
}
@AfterViews
protected void init() {
// Simple action bar with up, torrent name as title and refresh button
torrentsToolbar.setNavigationIcon(R.drawable.ic_action_drawer);
setSupportActionBar(torrentsToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// // Connect to the last used server
// ServerSetting lastUsed = applicationSettings.getLastUsedServer();
// currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
//
// if (feeds != null) {
// // Called from a configuration change. No need to load anything from server
// showChannelFilters();
// fragmentRemoteRss.updateRemoteItems(
// selectedFilter == 0 ? recentItems : feeds.get(selectedFilter - 1).getItems(),
// false /* allow android to restore scroll position */ );
// } else {
// loadFeeds();
// }
}
// @Background
// protected void loadFeeds() {
// try {
// fragmentRemoteRss.setRefreshing(true);
// feeds = ((RemoteRssSupplier) (currentConnection)).getRemoteRssChannels(log);
// fragmentRemoteRss.setRefreshing(false);
// } catch (DaemonException e) {
// onCommunicationError(e);
// }
//
// recentItems = new ArrayList<>();
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.MONTH, -1);
// Date oneMonthAgo = calendar.getTime();
//
// for (RemoteRssChannel feed : feeds) {
// for (RemoteRssItem item : feed.getItems()) {
// if (item.getTimestamp().after(oneMonthAgo)) {
// recentItems.add(item);
// }
// }
// }
// // Sort by -newest
// Collections.sort(recentItems, new Comparator<RemoteRssItem>() {
// @Override
// public int compare(RemoteRssItem lhs, RemoteRssItem rhs) {
// return rhs.getTimestamp().compareTo(lhs.getTimestamp());
// }
// });
//
// afterLoadFeeds();
// }
// @UiThread
// protected void afterLoadFeeds() {
// // We need to wrap these calls in a @UiThread rather than make them each a @UiThread themselves
// // because they need to run sequentially in a configuration change scenario in order for Android
// // to maintain scroll position on the fragment adapter.
// showChannelFilters();
// onFeedSelected(selectedFilter);
// }
// @UiThread
// protected void onCommunicationError(DaemonException daemonException) {
// //noinspection ThrowableResultOfMethodCallIgnored
// log.i(this, daemonException.toString());
// String error = getString(LocalTorrent.getResourceForDaemonException(daemonException));
// SnackbarManager.show(Snackbar.with(this).text(error).colorResource(R.color.red).type(SnackbarType.MULTI_LINE));
// }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {
if (drawerLayout.isDrawerOpen(drawerContainer)) {
drawerLayout.closeDrawers();
} else {
drawerLayout.openDrawer(drawerContainer);
}
}
@Override
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(drawerContainer)) {
drawerLayout.closeDrawers();
} else {
finish();
}
}
private void showChannelFilters() {
// List<RemoteRssChannel> feedLabels = new ArrayList<>(feeds.size() +1);
// feedLabels.add(new RemoteRssChannel() {
// @Override
// public String getName() {
// return getString(R.string.remoterss_filter_allrecent);
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// }
// });
// feedLabels.addAll(feeds);
//
// drawerList.setAdapter(new SimpleListItemAdapter(this, feedLabels));
}
// @ItemClick(R.id.drawer_list)
// protected void onFeedSelected(int position) {
// selectedFilter = position;
// fragmentRemoteRss.updateRemoteItems(position == 0 ? recentItems : feeds.get(position - 1).getItems(), true);
//
// RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(position);
// getSupportActionBar().setSubtitle(channel.getName());
//
// drawerLayout.closeDrawers();
// }
// public IDaemonAdapter getCurrentConnection() {
// return currentConnection;
// }
// public RemoteRssChannel getChannel(String name) {
// for (RemoteRssChannel feed : feeds) {
// if (feed.getName().equals(name)) {
// return feed;
// }
// }
// return null;
// }
// @Override
// public void refreshScreen() {
// loadFeeds();
// }
}

79
app/src/main/res/layout/activity_remoterss.xml

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-2018 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- This layout is for phones in portrait and shows the remote RSS items list with the filters as navigation drawer. -->
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".core.gui.remoterss.RemoteRssActivity_">
<!-- The main content view -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/torrents_toolbar"
style="@style/DefaultToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize" />
<fragment
android:id="@+id/remoterss_fragment"
class="org.transdroid.core.gui.remoterss.RemoteRssFragment_"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/torrents_toolbar"
tools:layout="@layout/fragment_torrents" />
<View
style="@style/DefaultToolbarShadow"
android:layout_below="@id/torrents_toolbar" />
<View
style="@style/SplitToolbarShadow"
/>
</RelativeLayout>
<!-- The navigation drawer -->
<LinearLayout
android:id="@+id/drawer_container"
android:layout_width="@dimen/ui_filters_list"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/drawer_background"
android:orientation="vertical">
<ListView
android:id="@+id/drawer_list"
android:layout_width="@dimen/ui_filters_list"
android:layout_height="0dp"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:divider="@null"
tools:listitem="@layout/list_item_filter" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>

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

@ -28,11 +28,6 @@
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_cloud_download"
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"

Loading…
Cancel
Save