2013-04-21 13:01:26 +00:00
|
|
|
package org.fox.ttrss;
|
|
|
|
|
2013-10-16 08:38:18 +00:00
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
import java.util.Date;
|
2013-11-27 14:58:25 +00:00
|
|
|
import java.util.HashMap;
|
2013-04-21 13:01:26 +00:00
|
|
|
|
|
|
|
import org.fox.ttrss.types.Article;
|
|
|
|
import org.fox.ttrss.types.ArticleList;
|
|
|
|
import org.fox.ttrss.types.Feed;
|
|
|
|
import org.fox.ttrss.types.FeedCategory;
|
|
|
|
import org.fox.ttrss.util.AppRater;
|
|
|
|
|
|
|
|
import android.animation.ObjectAnimator;
|
|
|
|
import android.annotation.SuppressLint;
|
2013-10-17 06:37:32 +00:00
|
|
|
import android.content.ComponentName;
|
2013-04-21 13:01:26 +00:00
|
|
|
import android.content.Intent;
|
2013-10-17 06:37:32 +00:00
|
|
|
import android.content.Intent.ShortcutIconResource;
|
2013-04-21 13:01:26 +00:00
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Handler;
|
2013-10-17 06:37:32 +00:00
|
|
|
import android.os.Parcelable;
|
2013-04-21 13:01:26 +00:00
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
2013-10-16 08:42:58 +00:00
|
|
|
import com.actionbarsherlock.view.MenuItem;
|
2013-11-27 14:58:25 +00:00
|
|
|
import com.google.gson.JsonElement;
|
2013-10-16 08:42:58 +00:00
|
|
|
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
|
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
public class FeedsActivity extends OnlineActivity implements HeadlinesEventListener {
|
|
|
|
private final String TAG = this.getClass().getSimpleName();
|
|
|
|
|
|
|
|
private static final int HEADLINES_REQUEST = 1;
|
|
|
|
|
|
|
|
protected SharedPreferences m_prefs;
|
|
|
|
protected long m_lastRefresh = 0;
|
|
|
|
|
|
|
|
private boolean m_actionbarUpEnabled = false;
|
2013-05-18 10:27:04 +00:00
|
|
|
private int m_actionbarRevertDepth = 0;
|
2013-05-28 06:21:01 +00:00
|
|
|
private SlidingMenu m_slidingMenu;
|
2013-05-28 11:47:44 +00:00
|
|
|
private boolean m_feedIsSelected = false;
|
2013-11-15 11:38:23 +00:00
|
|
|
private boolean m_feedWasSelected = false;
|
2013-04-21 13:01:26 +00:00
|
|
|
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
m_prefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext());
|
|
|
|
|
|
|
|
setAppTheme(m_prefs);
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2013-05-28 08:39:31 +00:00
|
|
|
setContentView(R.layout.headlines);
|
2013-05-28 11:47:44 +00:00
|
|
|
setSmallScreen(findViewById(R.id.sw600dp_anchor) == null &&
|
|
|
|
findViewById(R.id.sw600dp_port_anchor) == null);
|
2013-11-15 11:38:23 +00:00
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
GlobalState.getInstance().load(savedInstanceState);
|
2013-10-16 08:38:18 +00:00
|
|
|
|
2013-05-28 11:47:44 +00:00
|
|
|
if (isSmallScreen() || findViewById(R.id.sw600dp_port_anchor) != null) {
|
2013-05-28 06:21:01 +00:00
|
|
|
m_slidingMenu = new SlidingMenu(this);
|
2013-05-28 11:47:44 +00:00
|
|
|
|
2013-11-15 11:38:23 +00:00
|
|
|
/* if (findViewById(R.id.sw600dp_port_anchor) != null) {
|
2013-05-28 11:47:44 +00:00
|
|
|
m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3);
|
2013-11-15 11:38:23 +00:00
|
|
|
} */
|
2013-05-28 11:47:44 +00:00
|
|
|
|
2013-05-28 06:21:01 +00:00
|
|
|
m_slidingMenu.setMode(SlidingMenu.LEFT);
|
|
|
|
m_slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
|
|
|
|
m_slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
|
|
|
|
m_slidingMenu.setMenu(R.layout.feeds);
|
2013-05-28 11:47:44 +00:00
|
|
|
m_slidingMenu.setSlidingEnabled(true);
|
2013-10-20 06:05:33 +00:00
|
|
|
|
|
|
|
m_slidingMenu.setOnClosedListener(new SlidingMenu.OnClosedListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClosed() {
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
m_actionbarUpEnabled = true;
|
|
|
|
m_feedIsSelected = true;
|
2013-11-21 05:46:27 +00:00
|
|
|
|
|
|
|
initMenu();
|
2013-10-20 06:05:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-05-28 06:21:01 +00:00
|
|
|
m_slidingMenu.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onOpened() {
|
|
|
|
if (m_actionbarRevertDepth == 0) {
|
|
|
|
m_actionbarUpEnabled = false;
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
2013-10-16 09:29:40 +00:00
|
|
|
refresh(false);
|
2013-05-28 06:21:01 +00:00
|
|
|
}
|
2013-05-28 15:59:33 +00:00
|
|
|
|
|
|
|
m_feedIsSelected = false;
|
|
|
|
initMenu();
|
2013-05-28 06:21:01 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
if (savedInstanceState == null) {
|
2013-05-28 06:21:01 +00:00
|
|
|
if (m_slidingMenu != null)
|
|
|
|
m_slidingMenu.showMenu();
|
2013-04-21 13:01:26 +00:00
|
|
|
|
2013-10-17 07:00:07 +00:00
|
|
|
Intent i = getIntent();
|
|
|
|
boolean shortcutMode = i.getBooleanExtra("shortcut_mode", false);
|
|
|
|
|
|
|
|
Log.d(TAG, "is_shortcut_mode: " + shortcutMode);
|
|
|
|
|
|
|
|
if (shortcutMode) {
|
|
|
|
int feedId = i.getIntExtra("feed_id", 0);
|
|
|
|
boolean isCat = i.getBooleanExtra("feed_is_cat", false);
|
|
|
|
String feedTitle = i.getStringExtra("feed_title");
|
|
|
|
|
|
|
|
Feed tmpFeed = new Feed(feedId, feedTitle, isCat);
|
|
|
|
|
|
|
|
onFeedSelected(tmpFeed);
|
|
|
|
}
|
|
|
|
|
2013-10-16 11:11:44 +00:00
|
|
|
m_pullToRefreshAttacher.setRefreshing(true);
|
|
|
|
|
2013-05-28 09:17:02 +00:00
|
|
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
2013-10-16 11:11:44 +00:00
|
|
|
|
2013-05-28 09:17:02 +00:00
|
|
|
if (m_prefs.getBoolean("enable_cats", false)) {
|
|
|
|
ft.replace(R.id.feeds_fragment, new FeedCategoriesFragment(), FRAG_CATS);
|
|
|
|
} else {
|
|
|
|
ft.replace(R.id.feeds_fragment, new FeedsFragment(), FRAG_FEEDS);
|
|
|
|
}
|
|
|
|
|
|
|
|
ft.commit();
|
2013-04-21 13:01:26 +00:00
|
|
|
|
2013-11-21 05:39:43 +00:00
|
|
|
if (!isAmazonDevice()) {
|
|
|
|
AppRater.appLaunched(this);
|
|
|
|
checkTrial(true);
|
|
|
|
}
|
2013-05-28 09:17:02 +00:00
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
} else { // savedInstanceState != null
|
|
|
|
m_actionbarUpEnabled = savedInstanceState.getBoolean("actionbarUpEnabled");
|
2013-05-18 10:27:04 +00:00
|
|
|
m_actionbarRevertDepth = savedInstanceState.getInt("actionbarRevertDepth");
|
2013-05-28 11:47:44 +00:00
|
|
|
m_feedIsSelected = savedInstanceState.getBoolean("feedIsSelected");
|
2013-11-15 11:38:23 +00:00
|
|
|
m_feedWasSelected = savedInstanceState.getBoolean("feedWasSelected");
|
2013-04-21 13:01:26 +00:00
|
|
|
|
2013-11-15 11:38:23 +00:00
|
|
|
if (findViewById(R.id.sw600dp_port_anchor) != null && m_feedWasSelected && m_slidingMenu != null) {
|
|
|
|
m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3);
|
|
|
|
}
|
|
|
|
|
2013-05-28 15:50:08 +00:00
|
|
|
if (m_slidingMenu != null && m_feedIsSelected == false) {
|
2013-05-28 06:21:01 +00:00
|
|
|
m_slidingMenu.showMenu();
|
2013-05-28 15:50:08 +00:00
|
|
|
} else if (m_slidingMenu != null) {
|
|
|
|
m_actionbarUpEnabled = true;
|
|
|
|
} else {
|
|
|
|
m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_actionbarUpEnabled) {
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
}
|
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
if (!isSmallScreen()) {
|
|
|
|
// temporary hack because FeedsActivity doesn't track whether active feed is open
|
|
|
|
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
2013-05-28 11:47:44 +00:00
|
|
|
|
|
|
|
if (container != null)
|
|
|
|
container.setWeightSum(3f);
|
2013-04-21 13:01:26 +00:00
|
|
|
}
|
2013-11-15 11:38:23 +00:00
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-28 11:47:44 +00:00
|
|
|
/* if (!isCompatMode() && !isSmallScreen()) {
|
2013-04-21 13:01:26 +00:00
|
|
|
((ViewGroup)findViewById(R.id.headlines_fragment)).setLayoutTransition(new LayoutTransition());
|
|
|
|
((ViewGroup)findViewById(R.id.feeds_fragment)).setLayoutTransition(new LayoutTransition());
|
2013-05-28 11:47:44 +00:00
|
|
|
} */
|
2013-04-21 13:01:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void initMenu() {
|
|
|
|
super.initMenu();
|
|
|
|
|
|
|
|
if (m_menu != null && getSessionId() != null) {
|
|
|
|
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
|
|
|
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
|
|
|
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
|
|
|
|
2013-05-28 06:21:01 +00:00
|
|
|
if (m_slidingMenu != null) {
|
|
|
|
m_menu.setGroupVisible(R.id.menu_group_feeds, m_slidingMenu.isMenuShowing());
|
|
|
|
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded() && !m_slidingMenu.isMenuShowing());
|
|
|
|
} else {
|
|
|
|
m_menu.setGroupVisible(R.id.menu_group_feeds, (ff != null && ff.isAdded()) || (cf != null && cf.isAdded()));
|
|
|
|
m_menu.setGroupVisible(R.id.menu_group_headlines, hf != null && hf.isAdded());
|
|
|
|
|
|
|
|
m_menu.findItem(R.id.update_headlines).setVisible(false);
|
|
|
|
}
|
2013-04-21 13:01:26 +00:00
|
|
|
|
|
|
|
MenuItem item = m_menu.findItem(R.id.show_feeds);
|
|
|
|
|
|
|
|
if (getUnreadOnly()) {
|
|
|
|
item.setTitle(R.string.menu_all_feeds);
|
|
|
|
} else {
|
|
|
|
item.setTitle(R.string.menu_unread_feeds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onFeedSelected(Feed feed) {
|
|
|
|
GlobalState.getInstance().m_loadedArticles.clear();
|
2013-10-16 11:11:44 +00:00
|
|
|
m_pullToRefreshAttacher.setRefreshing(true);
|
2013-04-21 13:01:26 +00:00
|
|
|
|
|
|
|
FragmentTransaction ft = getSupportFragmentManager()
|
|
|
|
.beginTransaction();
|
|
|
|
|
|
|
|
ft.replace(R.id.headlines_fragment, new LoadingFragment(), null);
|
|
|
|
ft.commit();
|
|
|
|
|
2013-05-28 06:21:01 +00:00
|
|
|
if (!isCompatMode() && !isSmallScreen()) {
|
2013-04-21 13:01:26 +00:00
|
|
|
LinearLayout container = (LinearLayout) findViewById(R.id.fragment_container);
|
2013-05-28 11:47:44 +00:00
|
|
|
if (container != null) {
|
|
|
|
float wSum = container.getWeightSum();
|
|
|
|
if (wSum <= 2.0f) {
|
|
|
|
ObjectAnimator anim = ObjectAnimator.ofFloat(container, "weightSum", wSum, 3.0f);
|
|
|
|
anim.setDuration(200);
|
|
|
|
anim.start();
|
|
|
|
}
|
2013-04-21 13:01:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
final Feed fFeed = feed;
|
|
|
|
|
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
FragmentTransaction ft = getSupportFragmentManager()
|
|
|
|
.beginTransaction();
|
|
|
|
|
2013-04-26 09:16:53 +00:00
|
|
|
HeadlinesFragment hf = new HeadlinesFragment();
|
|
|
|
hf.initialize(fFeed);
|
2013-04-21 13:01:26 +00:00
|
|
|
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
|
|
|
|
|
|
|
ft.commit();
|
2013-05-28 11:47:44 +00:00
|
|
|
|
|
|
|
m_feedIsSelected = true;
|
2013-11-15 11:38:23 +00:00
|
|
|
m_feedWasSelected = true;
|
2013-05-28 06:21:01 +00:00
|
|
|
|
2013-11-15 11:38:23 +00:00
|
|
|
if (m_slidingMenu != null) {
|
|
|
|
if (findViewById(R.id.sw600dp_port_anchor) != null) {
|
|
|
|
m_slidingMenu.setBehindWidth(getScreenWidthInPixel() * 2/3);
|
|
|
|
}
|
|
|
|
|
2013-05-28 06:21:01 +00:00
|
|
|
m_slidingMenu.showContent();
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
m_actionbarUpEnabled = true;
|
2013-11-15 11:38:23 +00:00
|
|
|
|
2013-05-28 06:21:01 +00:00
|
|
|
}
|
2013-04-21 13:01:26 +00:00
|
|
|
}
|
|
|
|
}, 10);
|
|
|
|
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
if (date.getTime() - m_lastRefresh > 10000) {
|
|
|
|
m_lastRefresh = date.getTime();
|
|
|
|
refresh(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onCatSelected(FeedCategory cat, boolean openAsFeed) {
|
2013-05-18 10:27:04 +00:00
|
|
|
FeedCategoriesFragment fc = (FeedCategoriesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
|
|
|
|
2013-10-16 11:11:44 +00:00
|
|
|
m_pullToRefreshAttacher.setRefreshing(true);
|
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
if (!openAsFeed) {
|
|
|
|
|
2013-05-28 09:17:02 +00:00
|
|
|
if (fc != null) {
|
|
|
|
fc.setSelectedCategory(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
FragmentTransaction ft = getSupportFragmentManager()
|
|
|
|
.beginTransaction();
|
2013-05-18 10:27:04 +00:00
|
|
|
|
2013-05-28 09:17:02 +00:00
|
|
|
FeedsFragment ff = new FeedsFragment();
|
|
|
|
ff.initialize(cat);
|
|
|
|
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
|
2013-04-21 13:01:26 +00:00
|
|
|
|
2013-05-28 09:17:02 +00:00
|
|
|
ft.addToBackStack(null);
|
|
|
|
ft.commit();
|
|
|
|
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
m_actionbarUpEnabled = true;
|
|
|
|
m_actionbarRevertDepth = m_actionbarRevertDepth + 1;
|
2013-04-21 13:01:26 +00:00
|
|
|
|
|
|
|
} else {
|
2013-05-18 10:27:04 +00:00
|
|
|
|
|
|
|
if (fc != null) {
|
|
|
|
fc.setSelectedCategory(cat);
|
|
|
|
}
|
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
Feed feed = new Feed(cat.id, cat.title, true);
|
|
|
|
onFeedSelected(feed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onCatSelected(FeedCategory cat) {
|
|
|
|
onCatSelected(cat, m_prefs.getBoolean("browse_cats_like_feeds", false));
|
|
|
|
}
|
|
|
|
|
2013-05-28 06:21:01 +00:00
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
2013-05-28 06:38:59 +00:00
|
|
|
if (m_actionbarRevertDepth > 0) {
|
|
|
|
|
2013-05-28 15:59:33 +00:00
|
|
|
if (m_feedIsSelected && m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
|
|
|
|
m_slidingMenu.showMenu();
|
|
|
|
} else {
|
|
|
|
m_actionbarRevertDepth = m_actionbarRevertDepth - 1;
|
|
|
|
m_actionbarUpEnabled = m_actionbarRevertDepth > 0;
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(m_actionbarUpEnabled);
|
2013-05-28 06:38:59 +00:00
|
|
|
|
2013-05-28 15:59:33 +00:00
|
|
|
onBackPressed();
|
|
|
|
}
|
2013-05-28 06:38:59 +00:00
|
|
|
} else if (m_slidingMenu != null && !m_slidingMenu.isMenuShowing()) {
|
2013-05-28 06:21:01 +00:00
|
|
|
m_slidingMenu.showMenu();
|
|
|
|
} else {
|
|
|
|
super.onBackPressed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
2013-05-18 10:27:04 +00:00
|
|
|
case android.R.id.home:
|
2013-05-28 15:59:33 +00:00
|
|
|
if (m_actionbarUpEnabled)
|
|
|
|
onBackPressed();
|
2013-05-18 10:27:04 +00:00
|
|
|
return true;
|
2013-04-21 13:01:26 +00:00
|
|
|
case R.id.show_feeds:
|
|
|
|
setUnreadOnly(!getUnreadOnly());
|
|
|
|
initMenu();
|
|
|
|
refresh();
|
|
|
|
return true;
|
|
|
|
case R.id.update_feeds:
|
2013-10-16 09:29:40 +00:00
|
|
|
m_pullToRefreshAttacher.setRefreshing(true);
|
2013-04-21 13:01:26 +00:00
|
|
|
refresh();
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
Log.d(TAG, "onOptionsItemSelected, unhandled id=" + item.getItemId());
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void loginSuccess(boolean refresh) {
|
|
|
|
setLoadingStatus(R.string.blank, false);
|
2013-05-28 06:21:01 +00:00
|
|
|
//findViewById(R.id.loading_container).setVisibility(View.GONE);
|
2013-04-21 13:01:26 +00:00
|
|
|
initMenu();
|
|
|
|
|
|
|
|
if (refresh) refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSaveInstanceState(Bundle out) {
|
|
|
|
super.onSaveInstanceState(out);
|
|
|
|
|
|
|
|
out.putBoolean("actionbarUpEnabled", m_actionbarUpEnabled);
|
2013-05-18 10:27:04 +00:00
|
|
|
out.putInt("actionbarRevertDepth", m_actionbarRevertDepth);
|
2013-05-28 11:47:44 +00:00
|
|
|
out.putBoolean("feedIsSelected", m_feedIsSelected);
|
2013-11-15 11:38:23 +00:00
|
|
|
out.putBoolean("feedWasSelected", m_feedWasSelected);
|
2013-04-21 13:01:26 +00:00
|
|
|
|
2013-05-28 11:47:44 +00:00
|
|
|
//if (m_slidingMenu != null )
|
|
|
|
// out.putBoolean("slidingMenuVisible", m_slidingMenu.isMenuShowing());
|
2013-05-28 06:21:01 +00:00
|
|
|
|
2013-04-21 13:01:26 +00:00
|
|
|
GlobalState.getInstance().save(out);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
initMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onArticleListSelectionChange(ArticleList m_selectedArticles) {
|
|
|
|
initMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void openFeedArticles(Feed feed) {
|
2013-05-28 09:17:02 +00:00
|
|
|
GlobalState.getInstance().m_loadedArticles.clear();
|
|
|
|
|
|
|
|
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
|
|
|
intent.putExtra("feed", feed);
|
|
|
|
intent.putExtra("article", (Article)null);
|
|
|
|
intent.putExtra("searchQuery", (String)null);
|
|
|
|
|
|
|
|
startActivityForResult(intent, HEADLINES_REQUEST);
|
|
|
|
overridePendingTransition(R.anim.right_slide_in, 0);
|
2013-04-21 13:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onArticleSelected(Article article, boolean open) {
|
|
|
|
if (article.unread) {
|
|
|
|
article.unread = false;
|
|
|
|
saveArticleUnread(article);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (open) {
|
|
|
|
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
|
|
|
|
2013-05-28 09:17:02 +00:00
|
|
|
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
|
|
|
intent.putExtra("feed", hf.getFeed());
|
|
|
|
intent.putExtra("article", article);
|
|
|
|
intent.putExtra("searchQuery", hf.getSearchQuery());
|
|
|
|
|
|
|
|
startActivityForResult(intent, HEADLINES_REQUEST);
|
|
|
|
overridePendingTransition(R.anim.right_slide_in, 0);
|
2013-04-21 13:01:26 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
initMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onArticleSelected(Article article) {
|
|
|
|
onArticleSelected(article, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void catchupFeed(final Feed feed) {
|
|
|
|
super.catchupFeed(feed);
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onHeadlinesLoaded(boolean appended) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (requestCode == HEADLINES_REQUEST) {
|
|
|
|
GlobalState.getInstance().m_activeArticle = null;
|
|
|
|
}
|
|
|
|
}
|
2013-10-17 06:37:32 +00:00
|
|
|
|
|
|
|
public void createFeedShortcut(Feed feed) {
|
2013-10-17 07:00:07 +00:00
|
|
|
final Intent shortcutIntent = new Intent(this, FeedsActivity.class);
|
2013-10-17 06:37:32 +00:00
|
|
|
shortcutIntent.putExtra("feed_id", feed.id);
|
|
|
|
shortcutIntent.putExtra("feed_is_cat", feed.is_cat);
|
|
|
|
shortcutIntent.putExtra("feed_title", feed.title);
|
|
|
|
shortcutIntent.putExtra("shortcut_mode", true);
|
|
|
|
|
|
|
|
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
|
|
|
|
|
|
|
|
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, feed.title);
|
|
|
|
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
|
|
|
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
|
|
|
|
intent.putExtra("duplicate", false);
|
|
|
|
|
|
|
|
sendBroadcast(intent);
|
|
|
|
|
|
|
|
toast(R.string.shortcut_has_been_placed_on_the_home_screen);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void createCategoryShortcut(FeedCategory cat) {
|
|
|
|
createFeedShortcut(new Feed(cat.id, cat.title, true));
|
|
|
|
}
|
2013-11-27 14:58:25 +00:00
|
|
|
|
|
|
|
public void unsubscribeFeed(final Feed feed) {
|
|
|
|
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
|
|
|
protected void onPostExecute(JsonElement result) {
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
HashMap<String, String> map = new HashMap<String, String>() {
|
|
|
|
{
|
|
|
|
put("sid", getSessionId());
|
|
|
|
put("op", "unsubscribeFeed");
|
|
|
|
put("feed_id", String.valueOf(feed.id));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
req.execute(map);
|
|
|
|
|
|
|
|
}
|
2013-04-21 13:01:26 +00:00
|
|
|
}
|