diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 43562a87..66a38b00 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="102" + android:versionName="0.8.1" > 0) { shareProvider.setShareIntent(getShareIntent(getArticleById(af.getSelectedArticleId()))); if (!isSmallScreen()) { @@ -516,16 +516,20 @@ public class OfflineActivity extends CommonActivity { } protected Intent getShareIntent(Cursor article) { - String title = article.getString(article.getColumnIndex("title")); - String link = article.getString(article.getColumnIndex("link")); - - Intent intent = new Intent(Intent.ACTION_SEND); - - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_SUBJECT, title); - intent.putExtra(Intent.EXTRA_TEXT, link); - - return intent; + if (article != null) { + String title = article.getString(article.getColumnIndex("title")); + String link = article.getString(article.getColumnIndex("link")); + + Intent intent = new Intent(Intent.ACTION_SEND); + + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_SUBJECT, title); + intent.putExtra(Intent.EXTRA_TEXT, link); + + return intent; + } else { + return null; + } } protected void shareArticle(int articleId) { diff --git a/src/org/fox/ttrss/offline/OfflineArticlePager.java b/src/org/fox/ttrss/offline/OfflineArticlePager.java index 3faf3415..9f8ae0f4 100644 --- a/src/org/fox/ttrss/offline/OfflineArticlePager.java +++ b/src/org/fox/ttrss/offline/OfflineArticlePager.java @@ -110,18 +110,31 @@ public class OfflineArticlePager extends Fragment { m_adapter = new PagerAdapter(getActivity().getSupportFragmentManager()); - m_cursor.moveToFirst(); - int position = 0; - while (!m_cursor.isLast()) { - if (m_cursor.getInt(m_cursor.getColumnIndex(BaseColumns._ID)) == m_articleId) { - position = m_cursor.getPosition(); - break; - } - m_cursor.moveToNext(); + 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(); + break; + } + 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); pager.setAdapter(m_adapter); diff --git a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java index a5595681..e27c6e4b 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedCategoriesFragment.java @@ -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); - m_activity.onCatSelected(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; diff --git a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java index 35bf05b7..7813c807 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsActivity.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsActivity.java @@ -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()) { diff --git a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java index 7eadd373..7de6bbdd 100644 --- a/src/org/fox/ttrss/offline/OfflineFeedsFragment.java +++ b/src/org/fox/ttrss/offline/OfflineFeedsFragment.java @@ -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); - m_activity.onFeedSelected(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;