Browse Source

Fix RSS feeds screen UI and hide/show setting button.

pull/11/head
Eric Kok 11 years ago
parent
commit
3ec502f4ed
  1. 2
      core/src/org/transdroid/core/gui/navigation/NavigationHelper.java
  2. 36
      core/src/org/transdroid/core/gui/rss/RssfeedsActivity.java
  3. 3
      core/src/org/transdroid/core/gui/rss/RssfeedsFragment.java
  4. 4
      core/src/org/transdroid/core/gui/rss/RssitemsActivity.java

2
core/src/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -124,6 +124,8 @@ public class NavigationHelper {
* input string will be displayed using the Roboto Condensed font (if the OS has this) * input string will be displayed using the Roboto Condensed font (if the OS has this)
*/ */
public static SpannableString buildCondensedFontString(String string) { public static SpannableString buildCondensedFontString(String string) {
if (string == null)
return null;
SpannableString s = new SpannableString(string); SpannableString s = new SpannableString(string);
s.setSpan(new TypefaceSpan("sans-serif-condensed"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); s.setSpan(new TypefaceSpan("sans-serif-condensed"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return s; return s;

36
core/src/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -21,8 +21,10 @@ import org.transdroid.core.rssparser.RssParser;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
@ -119,24 +121,26 @@ public class RssfeedsActivity extends SherlockFragmentActivity {
} }
/** /**
* Opens an RSS feed in the dedicated fragment (if there was space in the UI) or a new {@link RssitemsActivity}. * Opens an RSS feed in the dedicated fragment (if there was space in the UI) or a new {@link RssitemsActivity}.
* Optionally this also registers in the user preferences that the feed was now viewed, so that in the future the * Optionally this also registers in the user preferences that the feed was now viewed, so that in the future the
* new items can be properly marked. * new items can be properly marked.
* @param loader The RSS feed loader (with settings and the loaded content channel) to show * @param loader The RSS feed loader (with settings and the loaded content channel) to show
* @param markAsViewedNow True if the user settings should be updated to reflect this feed's last viewed date; false otherwise * @param markAsViewedNow True if the user settings should be updated to reflect this feed's last viewed date; false
* otherwise
*/ */
public void openRssfeed(RssfeedLoader loader, boolean markAsViewedNow) { public void openRssfeed(RssfeedLoader loader, boolean markAsViewedNow) {
// The RSS feed content was loaded and can now be shown in the dedicated fragment or a new activity // The RSS feed content was loaded and can now be shown in the dedicated fragment or a new activity
if (fragmentItems != null) { if (fragmentItems != null) {
// If desired, update the lastViewedDate of this feed in the user setting; this won't be loaded until the RSS // If desired, update the lastViewedDate of this feed in the user setting; this won't be loaded until the
// RSS
// feeds screen in opened again. // feeds screen in opened again.
if (!loader.hasError() && loader.getChannel() != null && markAsViewedNow) { if (!loader.hasError() && loader.getChannel() != null && markAsViewedNow) {
applicationSettings.setRssfeedLastViewer(loader.getSetting().getOrder(), new Date()); applicationSettings.setRssfeedLastViewer(loader.getSetting().getOrder(), new Date());
} }
fragmentItems.update(loader.getChannel(), loader.hasError()); fragmentItems.update(loader.getChannel(), loader.hasError());
} else { } else {
// Error message or not yet loaded? Show a toast message instead of opening the items activity // Error message or not yet loaded? Show a toast message instead of opening the items activity
@ -148,17 +152,25 @@ public class RssfeedsActivity extends SherlockFragmentActivity {
Crouton.showText(this, R.string.rss_notloaded, NavigationHelper.CROUTON_INFO_STYLE); Crouton.showText(this, R.string.rss_notloaded, NavigationHelper.CROUTON_INFO_STYLE);
return; return;
} }
// If desired, update the lastViewedDate of this feed in the user setting; this won't be loaded until the RSS // If desired, update the lastViewedDate of this feed in the user setting; this won't be loaded until the
// RSS
// feeds screen in opened again // feeds screen in opened again
if (markAsViewedNow) { if (markAsViewedNow) {
applicationSettings.setRssfeedLastViewer(loader.getSetting().getOrder(), new Date()); applicationSettings.setRssfeedLastViewer(loader.getSetting().getOrder(), new Date());
} }
RssitemsActivity_.intent(this).rssfeed(loader.getChannel()).start(); String name = loader.getChannel().getTitle();
if (TextUtils.isEmpty(name))
name = loader.getSetting().getName();
if (TextUtils.isEmpty(name) && !TextUtils.isEmpty(loader.getSetting().getUrl())) {
String host = Uri.parse(loader.getSetting().getUrl()).getHost();
name = host;
}
RssitemsActivity_.intent(this).rssfeed(loader.getChannel()).rssfeedName(name).start();
} }
} }
} }

3
core/src/org/transdroid/core/gui/rss/RssfeedsFragment.java

@ -53,7 +53,8 @@ public class RssfeedsFragment extends SherlockFragment {
public void onPrepareOptionsMenu(Menu menu) { public void onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu); super.onPrepareOptionsMenu(menu);
menu.findItem(R.id.action_settings).setShowAsAction( menu.findItem(R.id.action_settings).setShowAsAction(
rssfeedsAdapter.getCount() == 0 ? MenuItem.SHOW_AS_ACTION_ALWAYS : MenuItem.SHOW_AS_ACTION_NEVER); rssfeedsAdapter == null || rssfeedsAdapter.getCount() == 0 ? MenuItem.SHOW_AS_ACTION_ALWAYS
: MenuItem.SHOW_AS_ACTION_NEVER);
} }
@OptionsItem(resName = "action_settings") @OptionsItem(resName = "action_settings")

4
core/src/org/transdroid/core/gui/rss/RssitemsActivity.java

@ -23,6 +23,8 @@ public class RssitemsActivity extends SherlockFragmentActivity {
@Extra @Extra
protected Channel rssfeed = null; protected Channel rssfeed = null;
@Extra
protected String rssfeedName;
@FragmentById(resName = "rssitems_list") @FragmentById(resName = "rssitems_list")
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@ -48,7 +50,7 @@ public class RssitemsActivity extends SherlockFragmentActivity {
// Simple action bar with up button and torrent name as title // Simple action bar with up button and torrent name as title
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(rssfeed.getTitle())); getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(rssfeedName));
// Get the intent extras and show them to the already loaded fragment // Get the intent extras and show them to the already loaded fragment
fragmentItems.update(rssfeed, false); fragmentItems.update(rssfeed, false);

Loading…
Cancel
Save