enable split actionbar
use shareprovider dropdown better use of actionbar title in various modes
This commit is contained in:
parent
0d9b127832
commit
b0002f903d
@ -14,6 +14,7 @@
|
||||
android:allowBackup="true"
|
||||
android:backupAgent="PrefsBackupAgent"
|
||||
android:hardwareAccelerated="true"
|
||||
uiOptions="splitActionBarWhenNarrow"
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name" >
|
||||
<activity
|
||||
|
@ -48,7 +48,7 @@
|
||||
android:id="@+id/search"
|
||||
android:actionViewClass="android.widget.SearchView"
|
||||
android:icon="@android:drawable/ic_menu_search"
|
||||
android:showAsAction="ifRoom"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:title="@string/search"/>
|
||||
|
||||
<item
|
||||
@ -96,7 +96,8 @@
|
||||
<item
|
||||
android:id="@+id/share_article"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:showAsAction="ifRoom"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:actionProviderClass="android.widget.ShareActionProvider"
|
||||
android:title="@string/share_article"/>
|
||||
|
||||
<item
|
||||
|
@ -34,7 +34,7 @@
|
||||
android:id="@+id/search"
|
||||
android:actionViewClass="android.widget.SearchView"
|
||||
android:icon="@android:drawable/ic_menu_search"
|
||||
android:showAsAction="ifRoom"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:title="@string/search"/>
|
||||
|
||||
<item
|
||||
@ -81,7 +81,8 @@
|
||||
<item
|
||||
android:id="@+id/share_article"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:showAsAction="ifRoom"
|
||||
android:showAsAction="ifRoom|collapseActionView"
|
||||
android:actionProviderClass="android.widget.ShareActionProvider"
|
||||
android:title="@string/share_article"/>
|
||||
|
||||
<item
|
||||
|
@ -38,6 +38,7 @@ import android.view.animation.AnimationUtils;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.ShareActionProvider;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -1176,13 +1177,20 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
}
|
||||
}
|
||||
|
||||
private Intent getShareIntent(Article article) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, article.title);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, article.title + " " + article.link);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
private void shareArticle(Article article) {
|
||||
if (article != null) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, article.title);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, article.title + " " + article.link);
|
||||
Intent intent = getShareIntent(article);
|
||||
|
||||
startActivity(Intent.createChooser(intent,
|
||||
getString(R.string.share_article)));
|
||||
@ -1313,11 +1321,31 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
||||
}
|
||||
|
||||
if (!m_compatMode) {
|
||||
|
||||
if (m_activeFeed != null) {
|
||||
getActionBar().setTitle(m_activeFeed.title);
|
||||
} else if (m_activeCategory != null) {
|
||||
getActionBar().setTitle(m_activeCategory.title);
|
||||
} else {
|
||||
getActionBar().setTitle(R.string.app_name);
|
||||
}
|
||||
|
||||
if (!m_smallScreenMode) {
|
||||
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeCategory != null);
|
||||
} else {
|
||||
getActionBar().setDisplayHomeAsUpEnabled(m_selectedArticle != null || m_activeFeed != null || m_activeCategory != null);
|
||||
getActionBar().setDisplayShowTitleEnabled(m_selectedArticle == null);
|
||||
}
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user