Added instagram story

main
h4h13 2020-02-02 23:09:16 +05:30
parent ddc1edfc82
commit 03fa8399dd
5 changed files with 6 additions and 25 deletions

View File

@ -91,7 +91,7 @@ class ShareInstagramStory : AbsBaseActivity() {
"Design", null
)
val uri = Uri.parse(path)
Share.shareFileToInstagram(
Share.shareStoryToSocial(
this@ShareInstagramStory,
uri
)

View File

@ -42,7 +42,7 @@ class SongShareDialog : DialogFragment() {
items = listOf(
getString(code.name.monkey.retromusic.R.string.the_audio_file),
"\u201C" + currentlyListening + "\u201D",
getString(R.string.social_instagram)
getString(R.string.social_stories)
)
) { _, index, _ ->
when (index) {

View File

@ -18,35 +18,16 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.core.app.ActivityCompat
import code.name.monkey.retromusic.R
/**
* Created by hemanths on 2020-02-02.
*/
object Share {
private const val INSTAGRAM_PACKAGE_NAME = "com.instagram.android"
private const val MEDIA_TYPE_JPEG = "jpg"
fun shareFileToInstagram(context: Context, uri: Uri) {
fun shareStoryToSocial(context: Context, uri: Uri) {
val feedIntent = Intent(Intent.ACTION_SEND)
feedIntent.type = "image/*"
feedIntent.putExtra(Intent.EXTRA_STREAM, uri)
feedIntent.setPackage(INSTAGRAM_PACKAGE_NAME)
feedIntent.putExtra("top_background_color", "#33FF33")
feedIntent.putExtra("bottom_background_color", "#FF00FF")
val storiesIntent = Intent("com.instagram.share.ADD_TO_STORY")
//storiesIntent.setDataAndType(uri, MEDIA_TYPE_JPEG)
storiesIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
storiesIntent.setPackage(INSTAGRAM_PACKAGE_NAME)
storiesIntent.type = MEDIA_TYPE_JPEG
storiesIntent.putExtra("top_background_color", "#33FF33")
storiesIntent.putExtra("bottom_background_color", "#0000FF")
storiesIntent.putExtra("content_url", "https://www.google.com")
val chooserIntent = Intent.createChooser(feedIntent, context.getString(R.string.social_instagram))
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, arrayOf(storiesIntent))
ActivityCompat.startActivity(context, chooserIntent, null)
ActivityCompat.startActivity(context, feedIntent, null)
}
}

View File

@ -126,7 +126,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp"
app:title="@string/social_instagram"
app:title="@string/social_stories"
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" />
</com.google.android.material.appbar.AppBarLayout>
</LinearLayout>

View File

@ -821,6 +821,6 @@
<string name="volume">Volume</string>
<string name="listeners_label">Listeners</string>
<string name="scrobbles_label">Scrobbles</string>
<string name="social_instagram">Instagram story</string>
<string name="social_stories">Share story</string>
<string name="share_to_stories">Share to Stories</string>
</resources>