From fe3546e282532f5c6aa0b3594708be953f3d3d5a Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 8 Nov 2020 10:43:27 +0100 Subject: [PATCH] Fix issue #57 - Allow to share channel and account links --- .../app/fedilab/fedilabtube/ShowAccountActivity.java | 12 ++++++++++++ .../app/fedilab/fedilabtube/ShowChannelActivity.java | 11 +++++++++++ app/src/main/res/menu/main_account.xml | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java b/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java index f90007b..df19899 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/ShowAccountActivity.java @@ -14,6 +14,7 @@ package app.fedilab.fedilabtube; * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see . */ +import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.text.Html; @@ -133,6 +134,17 @@ public class ShowAccountActivity extends AppCompatActivity { }); AlertDialog alertDialog = dialogBuilder.create(); alertDialog.show(); + }else if( item.getItemId() == R.id.action_share && account != null) { + Intent sendIntent = new Intent(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.shared_via)); + String extra_text = account.getUrl(); + sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text); + sendIntent.setType("text/plain"); + try { + startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with))); + } catch (Exception e) { + Toasty.error(ShowAccountActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show(); + } } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java b/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java index b765b0a..74c765e 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java +++ b/app/src/main/java/app/fedilab/fedilabtube/ShowChannelActivity.java @@ -159,6 +159,17 @@ public class ShowChannelActivity extends AppCompatActivity { }); androidx.appcompat.app.AlertDialog alertDialog = dialogBuilder.create(); alertDialog.show(); + } else if( item.getItemId() == R.id.action_share && channel != null) { + Intent sendIntent = new Intent(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.shared_via)); + String extra_text = channel.getUrl(); + sendIntent.putExtra(Intent.EXTRA_TEXT, extra_text); + sendIntent.setType("text/plain"); + try { + startActivity(Intent.createChooser(sendIntent, getString(R.string.share_with))); + } catch (Exception e) { + Toasty.error(ShowChannelActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show(); + } } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/res/menu/main_account.xml b/app/src/main/res/menu/main_account.xml index 5067442..46c1057 100644 --- a/app/src/main/res/menu/main_account.xml +++ b/app/src/main/res/menu/main_account.xml @@ -11,4 +11,9 @@ android:icon="@drawable/ic_baseline_report_24" android:title="@string/report" app:showAsAction="never" /> +