fix missing stuff for default_view_mode implementation in fragments

This commit is contained in:
Andrew Dolgov 2012-09-20 09:40:32 +04:00
parent 349dc9d797
commit cf39cea333
9 changed files with 93 additions and 33 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fox.ttrss"
android:versionCode="101"
android:versionName="0.8.0" >
android:versionCode="102"
android:versionName="0.8.1" >
<uses-sdk
android:minSdkVersion="8"

View File

@ -406,7 +406,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
if (list != null) {
FeedCategory cat = (FeedCategory)list.getItemAtPosition(position);
if ("ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
if (m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
m_prefs.getBoolean("browse_cats_like_feeds", false)) {
m_activity.openFeedArticles(new Feed(cat.id, cat.title, true));

View File

@ -244,9 +244,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
intent.putExtra("feed", feed);
intent.putExtra("article", new Article());
startActivityForResult(intent, 0);
} else {
}
}

View File

@ -255,16 +255,16 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
Feed feed = (Feed)list.getItemAtPosition(position);
if (feed.is_cat) {
FeedCategory cat = new FeedCategory();
cat.id = feed.id;
cat.title = feed.title;
if ("ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
if (m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
m_prefs.getBoolean("browse_cats_like_feeds", false)) {
m_activity.openFeedArticles(feed);
} else {
FeedCategory cat = new FeedCategory();
cat.id = feed.id;
cat.title = feed.title;
m_activity.onCatSelected(cat);
}
} else {

View File

@ -416,7 +416,7 @@ public class OfflineActivity extends CommonActivity {
OfflineArticlePager af = (OfflineArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
if (af != null) {
if (af != null && af.getSelectedArticleId() > 0) {
shareProvider.setShareIntent(getShareIntent(getArticleById(af.getSelectedArticleId())));
if (!isSmallScreen()) {
@ -516,6 +516,7 @@ public class OfflineActivity extends CommonActivity {
}
protected Intent getShareIntent(Cursor article) {
if (article != null) {
String title = article.getString(article.getColumnIndex("title"));
String link = article.getString(article.getColumnIndex("link"));
@ -526,6 +527,9 @@ public class OfflineActivity extends CommonActivity {
intent.putExtra(Intent.EXTRA_TEXT, link);
return intent;
} else {
return null;
}
}
protected void shareArticle(int articleId) {

View File

@ -110,10 +110,13 @@ public class OfflineArticlePager extends Fragment {
m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager());
m_cursor.moveToFirst();
int position = 0;
Log.d(TAG, "maId=" + m_articleId);
if (m_articleId != 0) {
if (m_cursor.moveToFirst()) {
while (!m_cursor.isLast()) {
if (m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID)) == m_articleId) {
position = m_cursor.getPosition();
@ -121,6 +124,16 @@ public class OfflineArticlePager extends Fragment {
}
m_cursor.moveToNext();
}
}
} else {
if (m_cursor.moveToFirst()) {
m_articleId = m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID));
m_listener.onArticleSelected(m_articleId, false);
Log.d(TAG, "maId=" + m_articleId);
}
}
ViewPager pager = (ViewPager) view.findViewById(R.id.article_pager);

View File

@ -87,6 +87,14 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
switch (item.getItemId()) {
case R.id.browse_articles:
if (true) {
int catId = getCatIdAtPosition(info.position);
if (catId != -10000) {
m_activity.openFeedArticles(catId, true);
}
}
return true;
case R.id.browse_headlines:
if (true) {
int catId = getCatIdAtPosition(info.position);
if (catId != -10000) {
@ -178,7 +186,14 @@ public class OfflineFeedCategoriesFragment extends Fragment implements OnItemCli
int feedId = (int) cursor.getLong(0);
Log.d(TAG, "clicked on feed " + feedId);
if (m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES")) &&
m_prefs.getBoolean("browse_cats_like_feeds", false)) {
m_activity.openFeedArticles(feedId, true);
} else {
m_activity.onCatSelected(feedId);
}
if (!m_activity.isSmallScreen())
m_selectedCatId = feedId;

View File

@ -86,6 +86,17 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
initMenu();
}
public void openFeedArticles(int feedId, boolean isCat) {
if (isSmallScreen()) {
Intent intent = new Intent(OfflineFeedsActivity.this, OfflineFeedsActivity.class);
intent.putExtra("feed", feedId);
intent.putExtra("isCat", isCat);
intent.putExtra("article", 0);
startActivityForResult(intent, 0);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {

View File

@ -61,6 +61,22 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
switch (item.getItemId()) {
case R.id.browse_articles:
if (true) {
int feedId = getFeedIdAtPosition(info.position);
if (feedId != -10000) {
m_activity.openFeedArticles(feedId, false);
}
}
return true;
case R.id.browse_headlines:
if (true) {
int feedId = getFeedIdAtPosition(info.position);
if (feedId != -10000) {
m_activity.onFeedSelected(feedId);
}
}
return true;
case R.id.catchup_feed:
int feedId = getFeedIdAtPosition(info.position);
if (feedId != -10000) {
@ -183,7 +199,11 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
int feedId = (int) cursor.getLong(0);
Log.d(TAG, "clicked on feed " + feedId);
if (!m_activity.isSmallScreen() && "ARTICLES".equals(m_prefs.getString("default_view_mode", "HEADLINES"))) {
m_activity.openFeedArticles(feedId, false);
} else {
m_activity.onFeedSelected(feedId);
}
if (!m_activity.isSmallScreen())
m_selectedFeedId = feedId;