Browse Source

- added tabs for local rss feeds

- changed the way rss feeds refreshes a bit (RssfeedsFragment calls refresh during onResume() rather than activity)
- RssfeedsFragment and RssitemsFragment now extends android.support.v4.app.Fragment
- (WIP) it's gonna crash because tab2 currently returns null
pull/526/head
Twig N 5 years ago
parent
commit
436b307a23
  1. 2
      app/build.gradle
  2. 66
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  3. 8
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java
  4. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java
  5. 22
      app/src/main/res/layout/activity_rssfeeds.xml
  6. 2
      app/src/main/res/values/strings.xml

2
app/build.gradle

@ -73,6 +73,8 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0' implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.getbase:floatingactionbutton:1.10.1' implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.nispok:snackbar:2.11.0' implementation 'com.nispok:snackbar:2.11.0'
implementation 'com.github.aegnor:rencode-java:cb628e824e' implementation 'com.github.aegnor:rencode-java:cb628e824e'

66
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -21,6 +21,12 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
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.text.TextUtils; import android.text.TextUtils;
@ -61,12 +67,56 @@ public class RssfeedsActivity extends AppCompatActivity {
protected List<RssfeedLoader> loaders; protected List<RssfeedLoader> loaders;
// Contained feeds and items fragments // Contained feeds and items fragments
@FragmentById(R.id.rssfeeds_fragment)
protected RssfeedsFragment fragmentFeeds; protected RssfeedsFragment fragmentFeeds;
@FragmentById(R.id.rssitems_fragment) @FragmentById(R.id.rssitems_fragment)
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@ViewById @ViewById
protected Toolbar rssfeedsToolbar; protected Toolbar rssfeedsToolbar;
@ViewById(R.id.rssfeeds_tabs)
protected TabLayout tabLayout;
@ViewById(R.id.rssfeeds_pager)
protected ViewPager viewPager;
protected static final int RSS_FEEDS_LOCAL = 0;
protected static final int RSS_FEEDS_REMOTE = 1;
class PagerAdapter extends FragmentPagerAdapter {
public PagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
if (position == RSS_FEEDS_LOCAL) {
fragment = fragmentFeeds;
}
else if (position == RSS_FEEDS_REMOTE) {
fragment = null;
}
return fragment;
}
@Override
public int getCount() {
return 2;
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case RSS_FEEDS_LOCAL:
return getString(R.string.navigation_rss_tabs_local);
case RSS_FEEDS_REMOTE:
return getString(R.string.navigation_rss_tabs_remote);
}
return super.getPageTitle(position);
}
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -82,6 +132,14 @@ public class RssfeedsActivity extends AppCompatActivity {
setSupportActionBar(rssfeedsToolbar); setSupportActionBar(rssfeedsToolbar);
getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(getString(R.string.rss_feeds))); getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(getString(R.string.rss_feeds)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
fragmentFeeds = RssfeedsFragment_.builder().build();
fragmentItems = RssitemsFragment_.builder().build();
PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(pagerAdapter);
tabLayout.setupWithViewPager(viewPager);
viewPager.setCurrentItem(0);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ -90,12 +148,6 @@ public class RssfeedsActivity extends AppCompatActivity {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
} }
@Override
protected void onResume() {
super.onResume();
refreshFeeds();
}
/** /**
* Reload the RSS feed settings and start loading all the feeds. To be called from contained fragments. * Reload the RSS feed settings and start loading all the feeds. To be called from contained fragments.
*/ */

8
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java

@ -16,7 +16,7 @@
*/ */
package org.transdroid.core.gui.rss; package org.transdroid.core.gui.rss;
import android.app.Fragment; import android.support.v4.app.Fragment;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -77,6 +77,12 @@ public class RssfeedsFragment extends Fragment {
MainSettingsActivity_.intent(getActivity()).start(); MainSettingsActivity_.intent(getActivity()).start();
} }
@Override
public void onResume() {
super.onResume();
this.refreshScreen();
}
@OptionsItem(R.id.action_refresh) @OptionsItem(R.id.action_refresh)
protected void refreshScreen() { protected void refreshScreen() {
((RssfeedsActivity) getActivity()).refreshFeeds(); ((RssfeedsActivity) getActivity()).refreshFeeds();

2
app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java

@ -17,13 +17,13 @@
package org.transdroid.core.gui.rss; package org.transdroid.core.gui.rss;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Fragment;
import android.app.SearchManager; import android.app.SearchManager;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.ActionMode; import android.view.ActionMode;

22
app/src/main/res/layout/activity_rssfeeds.xml

@ -32,12 +32,26 @@
style="@style/DefaultToolbarShadow" style="@style/DefaultToolbarShadow"
android:layout_below="@id/rssfeeds_toolbar" /> android:layout_below="@id/rssfeeds_toolbar" />
<fragment <android.support.v4.view.ViewPager
android:id="@+id/rssfeeds_fragment" android:id="@+id/rssfeeds_pager"
class="org.transdroid.core.gui.rss.RssfeedsFragment_"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@id/rssfeeds_toolbar" android:layout_below="@id/rssfeeds_toolbar"
tools:layout="@layout/fragment_rssfeeds" /> android:layout_marginTop="-2dp">
<android.support.design.widget.TabLayout
android:id="@+id/rssfeeds_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<!-- <fragment-->
<!-- android:id="@+id/rssfeeds_fragment"-->
<!-- class="org.transdroid.core.gui.rss.RssfeedsFragment_"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="-2dp"-->
<!-- tools:layout="@layout/fragment_rssfeeds" />-->
</android.support.v4.view.ViewPager>
</RelativeLayout> </RelativeLayout>

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

@ -99,6 +99,8 @@
<string name="navigation_invertselection">Invert selection</string> <string name="navigation_invertselection">Invert selection</string>
<string name="navigation_pickserver">Add torrent to&#8230;</string> <string name="navigation_pickserver">Add torrent to&#8230;</string>
<string name="navigation_url_hint" translatable="false">http://…</string> <string name="navigation_url_hint" translatable="false">http://…</string>
<string name="navigation_rss_tabs_local">RSS feeds</string>
<string name="navigation_rss_tabs_remote">Remote feeds</string>
<string name="status_status">STATUS: %1$s</string> <string name="status_status">STATUS: %1$s</string>
<string name="status_waiting">Waiting to check&#8230;</string> <string name="status_waiting">Waiting to check&#8230;</string>

Loading…
Cancel
Save