use separate activities for views in small screen mode
This commit is contained in:
parent
aac3d4b488
commit
4f8cc7aeeb
@ -180,8 +180,6 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
|||||||
refresh(false);
|
refresh(false);
|
||||||
|
|
||||||
m_activity.initMenu();
|
m_activity.initMenu();
|
||||||
m_activity.setTitle(R.string.app_name);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,7 +43,43 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
|
|
||||||
setSmallScreen(findViewById(R.id.headlines_fragment) == null);
|
setSmallScreen(findViewById(R.id.headlines_fragment) == null);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
Intent intent = getIntent();
|
||||||
|
|
||||||
|
if (intent.getParcelableExtra("feed") != null || intent.getParcelableExtra("category") != null ||
|
||||||
|
intent.getParcelableExtra("article") != null) {
|
||||||
|
|
||||||
|
Feed feed = (Feed) intent.getParcelableExtra("feed");
|
||||||
|
FeedCategory cat = (FeedCategory) intent.getParcelableExtra("category");
|
||||||
|
Article article = (Article) intent.getParcelableExtra("article");
|
||||||
|
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
|
if (feed != null) {
|
||||||
|
HeadlinesFragment hf = new HeadlinesFragment(feed);
|
||||||
|
ft.replace(R.id.feeds_fragment, hf, FRAG_HEADLINES);
|
||||||
|
|
||||||
|
setTitle(feed.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cat != null) {
|
||||||
|
FeedsFragment ff = new FeedsFragment(cat);
|
||||||
|
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
|
||||||
|
|
||||||
|
setTitle(cat.title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (article != null) {
|
||||||
|
Article original = TinyApplication.getInstance().m_loadedArticles.findById(article.id);
|
||||||
|
|
||||||
|
ArticlePager ap = new ArticlePager(original != null ? original : article);
|
||||||
|
ft.replace(R.id.feeds_fragment, ap, FRAG_ARTICLE);
|
||||||
|
|
||||||
|
setTitle(intent.getStringExtra("feedTitle"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ft.commit();
|
||||||
|
|
||||||
|
} else if (savedInstanceState == null) {
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
if (m_prefs.getBoolean("enable_cats", false)) {
|
if (m_prefs.getBoolean("enable_cats", false)) {
|
||||||
@ -52,15 +88,8 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
ft.replace(R.id.feeds_fragment, new FeedsFragment(), FRAG_FEEDS);
|
ft.replace(R.id.feeds_fragment, new FeedsFragment(), FRAG_FEEDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
ft.commit();
|
|
||||||
} /* else if (isSmallScreen()) {
|
|
||||||
Fragment frag = getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
|
||||||
if (frag != null) {
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
|
||||||
ft.remove(frag);
|
|
||||||
ft.commit();
|
ft.commit();
|
||||||
}
|
}
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -97,12 +126,20 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
|
|
||||||
TinyApplication.getInstance().m_loadedArticles.clear();
|
TinyApplication.getInstance().m_loadedArticles.clear();
|
||||||
|
|
||||||
HeadlinesFragment hf = new HeadlinesFragment(feed);
|
|
||||||
|
|
||||||
if (isSmallScreen()) {
|
if (isSmallScreen()) {
|
||||||
ft.replace(R.id.feeds_fragment, hf, FRAG_HEADLINES);
|
|
||||||
ft.addToBackStack(null);
|
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||||
|
intent.putExtra("sessionId", m_sessionId);
|
||||||
|
intent.putExtra("apiLevel", m_apiLevel);
|
||||||
|
intent.putExtra("feed", feed);
|
||||||
|
|
||||||
|
startActivityForResult(intent, 0);
|
||||||
|
|
||||||
|
//HeadlinesFragment hf = new HeadlinesFragment(feed);
|
||||||
|
//ft.replace(R.id.feeds_fragment, hf, FRAG_HEADLINES);
|
||||||
|
//ft.addToBackStack(null);
|
||||||
} else {
|
} else {
|
||||||
|
HeadlinesFragment hf = new HeadlinesFragment(feed);
|
||||||
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
|
||||||
}
|
}
|
||||||
ft.commit();
|
ft.commit();
|
||||||
@ -114,9 +151,20 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
.beginTransaction();
|
.beginTransaction();
|
||||||
|
|
||||||
if (!openAsFeed) {
|
if (!openAsFeed) {
|
||||||
FeedsFragment ff = new FeedsFragment(cat);
|
|
||||||
|
|
||||||
|
if (isSmallScreen()) {
|
||||||
|
|
||||||
|
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||||
|
intent.putExtra("sessionId", m_sessionId);
|
||||||
|
intent.putExtra("apiLevel", m_apiLevel);
|
||||||
|
intent.putExtra("category", cat);
|
||||||
|
|
||||||
|
startActivityForResult(intent, 0);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
FeedsFragment ff = new FeedsFragment(cat);
|
||||||
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
|
ft.replace(R.id.feeds_fragment, ff, FRAG_FEEDS);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Feed feed = new Feed(cat.id, cat.title, true);
|
Feed feed = new Feed(cat.id, cat.title, true);
|
||||||
onFeedSelected(feed);
|
onFeedSelected(feed);
|
||||||
@ -199,39 +247,32 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
if (isSmallScreen()) {
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager()
|
|
||||||
.beginTransaction();
|
|
||||||
|
|
||||||
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
|
||||||
Fragment frag = new ArticlePager(article);
|
if (isSmallScreen()) {
|
||||||
|
|
||||||
|
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||||
|
intent.putExtra("sessionId", m_sessionId);
|
||||||
|
intent.putExtra("apiLevel", m_apiLevel);
|
||||||
|
|
||||||
|
intent.putExtra("feedTitle", hf.getFeed().title);
|
||||||
|
intent.putExtra("article", article);
|
||||||
|
|
||||||
|
startActivityForResult(intent, 0);
|
||||||
|
|
||||||
ft.replace(R.id.feeds_fragment, frag, FRAG_ARTICLE);
|
|
||||||
ft.addToBackStack(null);
|
|
||||||
|
|
||||||
ft.commit();
|
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
intent.putExtra("sessionId", m_sessionId);
|
||||||
intent.putExtra("apiLevel", m_apiLevel);
|
intent.putExtra("apiLevel", m_apiLevel);
|
||||||
|
|
||||||
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
|
||||||
|
|
||||||
intent.putExtra("feed", hf.getFeed());
|
intent.putExtra("feed", hf.getFeed());
|
||||||
intent.putParcelableArrayListExtra("articles", hf.getAllArticles());
|
|
||||||
intent.putExtra("activeArticle", article);
|
|
||||||
intent.putExtra("article", article);
|
intent.putExtra("article", article);
|
||||||
|
|
||||||
//intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
|
||||||
|
|
||||||
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
initMenu();
|
initMenu();
|
||||||
/* HeadlinesFragment hf = (HeadlinesFragment) getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
|
||||||
if (hf != null) hf.setActiveArticle(article); */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,6 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
refresh(false);
|
refresh(false);
|
||||||
|
|
||||||
m_activity.initMenu();
|
m_activity.initMenu();
|
||||||
m_activity.setTitle(R.string.app_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,10 +49,9 @@ private final String TAG = this.getClass().getSimpleName();
|
|||||||
|
|
||||||
if (i.getExtras() != null) {
|
if (i.getExtras() != null) {
|
||||||
Feed feed = i.getParcelableExtra("feed");
|
Feed feed = i.getParcelableExtra("feed");
|
||||||
Article activeArticle = i.getParcelableExtra("activeArticle");
|
|
||||||
Article article = i.getParcelableExtra("article");
|
Article article = i.getParcelableExtra("article");
|
||||||
|
|
||||||
HeadlinesFragment hf = new HeadlinesFragment(feed, activeArticle);
|
HeadlinesFragment hf = new HeadlinesFragment(feed, article);
|
||||||
ArticlePager af = new ArticlePager(hf.getArticleById(article.id));
|
ArticlePager af = new ArticlePager(hf.getArticleById(article.id));
|
||||||
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
@ -61,6 +60,8 @@ private final String TAG = this.getClass().getSimpleName();
|
|||||||
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
|
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
|
||||||
|
|
||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
|
setTitle(feed.title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
notifyUpdated();
|
notifyUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_activity.setTitle(m_feed.title);
|
|
||||||
m_activity.initMenu();
|
m_activity.initMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.fox.ttrss;
|
package org.fox.ttrss;
|
||||||
|
|
||||||
|
import org.fox.ttrss.types.Article;
|
||||||
import org.fox.ttrss.types.ArticleList;
|
import org.fox.ttrss.types.ArticleList;
|
||||||
import org.fox.ttrss.types.Feed;
|
import org.fox.ttrss.types.Feed;
|
||||||
|
|
||||||
|
@ -21,6 +21,14 @@ public class ArticleList extends ArrayList<Article> implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Article findById(int id) {
|
||||||
|
for (Article a : this) {
|
||||||
|
if (a.id == id)
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void readFromParcel(Parcel in) {
|
public void readFromParcel(Parcel in) {
|
||||||
int length = in.readInt();
|
int length = in.readInt();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user