From b0002f903dcde042bb5cad5dbc2fda522441ada2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 3 Feb 2012 14:24:14 +0300 Subject: enable split actionbar use shareprovider dropdown better use of actionbar title in various modes --- AndroidManifest.xml | 1 + res/menu/main_menu.xml | 5 ++-- res/menu/offline_menu.xml | 5 ++-- src/org/fox/ttrss/MainActivity.java | 38 +++++++++++++++++++++++---- src/org/fox/ttrss/OfflineActivity.java | 48 ++++++++++++++++++++++++++-------- 5 files changed, 77 insertions(+), 20 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index eda9b264..d017eb88 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -14,6 +14,7 @@ android:allowBackup="true" android:backupAgent="PrefsBackupAgent" android:hardwareAccelerated="true" + uiOptions="splitActionBarWhenNarrow" android:icon="@drawable/icon" android:label="@string/app_name" > = 14) { + ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider(); + + if (m_selectedArticle != null) { + Log.d(TAG, "setting up share provider"); + shareProvider.setShareIntent(getShareIntent(m_selectedArticle)); + } + } + } m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1); diff --git a/src/org/fox/ttrss/OfflineActivity.java b/src/org/fox/ttrss/OfflineActivity.java index ff157ab8..20faff2d 100644 --- a/src/org/fox/ttrss/OfflineActivity.java +++ b/src/org/fox/ttrss/OfflineActivity.java @@ -418,6 +418,29 @@ public class OfflineActivity extends FragmentActivity implements return c; } + private Cursor getFeedById(int feedId) { + Cursor c = getReadableDb().query("feeds", null, + BaseColumns._ID + "=?", + new String[] { String.valueOf(feedId) }, null, null, null); + + c.moveToFirst(); + + return c; + } + + private 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, title + " " + link); + + return intent; + } + private void shareArticle(int articleId) { Cursor article = getArticleById(articleId); @@ -429,20 +452,11 @@ public class OfflineActivity extends FragmentActivity implements } private void shareArticle(Cursor article) { - 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, title + " " + link); - + Intent intent = getShareIntent(article); + startActivity(Intent.createChooser(intent, getString(R.id.share_article))); - } } @@ -784,10 +798,22 @@ public class OfflineActivity extends FragmentActivity implements } if (!m_compatMode) { + + if (m_activeFeedId != 0) { + Cursor feed = getFeedById(m_activeFeedId); + + if (feed != null) { + getActionBar().setTitle(feed.getString(feed.getColumnIndex("title"))); + } + } else { + getActionBar().setTitle(R.string.app_name); + } + if (!m_smallScreenMode) { getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0); } else { getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticleId != 0 || m_activeFeedId != 0); + getActionBar().setDisplayShowTitleEnabled(m_selectedArticleId == 0); } } } -- cgit v1.2.3-54-g00ecf