add copy article text to combined mode article context menu (refs #437)

This commit is contained in:
Andrew Dolgov 2012-03-12 12:02:46 +03:00
parent bca4979935
commit bbb4b2c36e
4 changed files with 35 additions and 14 deletions

View File

@ -6,7 +6,7 @@
android:title="@string/share_article"/> android:title="@string/share_article"/>
<item <item
android:id="@+id/article_link_save" android:id="@+id/article_link_copy"
android:showAsAction="" android:showAsAction=""
android:title="@string/article_link_copy"/> android:title="@string/article_link_copy"/>

View File

@ -22,6 +22,11 @@
android:showAsAction="" android:showAsAction=""
android:title="@string/share_article"/> android:title="@string/share_article"/>
<item
android:id="@+id/article_link_copy"
android:showAsAction=""
android:title="@string/article_link_copy"/>
<item <item
android:id="@+id/catchup_above" android:id="@+id/catchup_above"
android:showAsAction="" android:showAsAction=""

View File

@ -1818,20 +1818,30 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
.findFragmentById(R.id.cats_fragment); .findFragmentById(R.id.cats_fragment);
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.article_link_save: case R.id.article_link_copy:
if (true) {
Article article = null;
if (m_selectedArticle != null) { if (m_selectedArticle != null) {
article = m_selectedArticle;
} else if (info != null) {
article = hf.getArticleAtPosition(info.position);
}
if (article != null) {
if (android.os.Build.VERSION.SDK_INT < 11) { if (android.os.Build.VERSION.SDK_INT < 11) {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(m_selectedArticle.link); clipboard.setText(article.link);
} else { } else {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(m_selectedArticle.link); clipboard.setText(article.link);
} }
Toast toast = Toast.makeText(MainActivity.this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT); Toast toast = Toast.makeText(MainActivity.this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT);
toast.show(); toast.show();
} }
}
return true; return true;
case R.id.article_link_share: case R.id.article_link_share:
if (m_selectedArticle != null) { if (m_selectedArticle != null) {

View File

@ -854,9 +854,15 @@ public class OfflineActivity extends FragmentActivity implements
.findFragmentById(R.id.feeds_fragment); .findFragmentById(R.id.feeds_fragment);
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.article_link_save: case R.id.article_link_copy:
if (m_selectedArticleId != 0) { if (m_selectedArticleId != 0) {
Cursor article = getArticleById(m_selectedArticleId); Cursor article = null;
if (m_selectedArticleId != 0) {
article = getArticleById(m_selectedArticleId);
} else if (info != null) {
article = hf.getArticleAtPosition(info.position);
}
if (article != null) { if (article != null) {
if (android.os.Build.VERSION.SDK_INT < 11) { if (android.os.Build.VERSION.SDK_INT < 11) {