Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add share to swipe option #1264

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ private int getLayoutId(String action) {
case "0": return R.attr.openinbrowserDrawable;
case "1": return R.attr.starredDrawable;
case "2": return R.attr.markasreadDrawable;
case "3": return R.attr.shareDrawable;
default:
Log.e(TAG, "Invalid option saved to prefs. This should not happen");
return Integer.MAX_VALUE;
Expand Down Expand Up @@ -630,6 +631,17 @@ public void onSwiped(@NonNull final RecyclerView.ViewHolder viewHolder, final in
case "2": // Read
adapter.toggleReadStateOfItem((RssItemViewHolder) viewHolder);
break;
case "3": // Share
RssItem rssItem = ((RssItemViewHolder) viewHolder).getRssItem();
String title = rssItem.getTitle();
String content = rssItem.getLink();

Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_SUBJECT, title);
share.putExtra(Intent.EXTRA_TEXT, content);
startActivity(Intent.createChooser(share, "Share Item"));
break;
default:
Log.e(TAG, "Swipe preferences has an invalid value");
break;
Expand Down
8 changes: 8 additions & 0 deletions News-Android-App/src/main/res/drawable/ic_share_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFF" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
15 changes: 15 additions & 0 deletions News-Android-App/src/main/res/drawable/swipe_share.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<selector>
<item android:state_above_anchor="false"><color android:color="@color/swipeBackground" /></item>
<item android:state_above_anchor="true"><color android:color="@color/tertiary" /></item>
</selector>
</item>
<item
android:left="5dp"
android:right="5dp"
android:drawable="@drawable/ic_share_white"
android:gravity="center">
</item>
</layer-list>
2 changes: 2 additions & 0 deletions News-Android-App/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<attr name="openinbrowserDrawable" format="reference" />
<attr name="markasreadDrawable" format="reference" />

<attr name="shareDrawable" format="reference" />

<attr name="news_detail_background_color" format="color" />

<attr name="primaryTextColor" format="color" />
Expand Down
2 changes: 2 additions & 0 deletions News-Android-App/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@
<item>@string/action_openInBrowser</item>
<item>@string/action_starred</item>
<item>@string/action_read</item>
<item>@string/action_Share</item>
</string-array>
<string-array name="pref_general_swipe_action_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>

<string name="pref_rename_action_swipe_right">Action when swiping right</string>
Expand Down
2 changes: 2 additions & 0 deletions News-Android-App/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<item name="unstarredColor">@color/unstarredColor</item>
<item name="markasreadDrawable">@drawable/swipe_markasread</item>
<item name="openinbrowserDrawable">@drawable/swipe_openinbrowser</item>
<item name="shareDrawable">@drawable/swipe_share</item>

<item name="starredDrawable">@drawable/swipe_setstarred</item>

<item name="news_detail_background_color">@color/news_detail_background_color</item>
Expand Down