Fix issue #57 - Allow to share channel and account links

This commit is contained in:
Thomas 2020-11-08 10:43:27 +01:00
parent b61b6868a6
commit fe3546e282
3 changed files with 28 additions and 0 deletions

View File

@ -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 <http://www.gnu.org/licenses>. */
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);
}

View File

@ -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);
}

View File

@ -11,4 +11,9 @@
android:icon="@drawable/ic_baseline_report_24"
android:title="@string/report"
app:showAsAction="never" />
<item
android:id="@+id/action_share"
android:icon="@drawable/ic_baseline_share_24"
android:title="@string/share"
app:showAsAction="never" />
</menu>