Added instagram story
This commit is contained in:
parent
ddc1edfc82
commit
03fa8399dd
5 changed files with 6 additions and 25 deletions
|
@ -91,7 +91,7 @@ class ShareInstagramStory : AbsBaseActivity() {
|
||||||
"Design", null
|
"Design", null
|
||||||
)
|
)
|
||||||
val uri = Uri.parse(path)
|
val uri = Uri.parse(path)
|
||||||
Share.shareFileToInstagram(
|
Share.shareStoryToSocial(
|
||||||
this@ShareInstagramStory,
|
this@ShareInstagramStory,
|
||||||
uri
|
uri
|
||||||
)
|
)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SongShareDialog : DialogFragment() {
|
||||||
items = listOf(
|
items = listOf(
|
||||||
getString(code.name.monkey.retromusic.R.string.the_audio_file),
|
getString(code.name.monkey.retromusic.R.string.the_audio_file),
|
||||||
"\u201C" + currentlyListening + "\u201D",
|
"\u201C" + currentlyListening + "\u201D",
|
||||||
getString(R.string.social_instagram)
|
getString(R.string.social_stories)
|
||||||
)
|
)
|
||||||
) { _, index, _ ->
|
) { _, index, _ ->
|
||||||
when (index) {
|
when (index) {
|
||||||
|
|
|
@ -18,35 +18,16 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import code.name.monkey.retromusic.R
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hemanths on 2020-02-02.
|
* Created by hemanths on 2020-02-02.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
object Share {
|
object Share {
|
||||||
|
fun shareStoryToSocial(context: Context, uri: Uri) {
|
||||||
private const val INSTAGRAM_PACKAGE_NAME = "com.instagram.android"
|
|
||||||
private const val MEDIA_TYPE_JPEG = "jpg"
|
|
||||||
|
|
||||||
fun shareFileToInstagram(context: Context, uri: Uri) {
|
|
||||||
val feedIntent = Intent(Intent.ACTION_SEND)
|
val feedIntent = Intent(Intent.ACTION_SEND)
|
||||||
feedIntent.type = "image/*"
|
feedIntent.type = "image/*"
|
||||||
feedIntent.putExtra(Intent.EXTRA_STREAM, uri)
|
feedIntent.putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
feedIntent.setPackage(INSTAGRAM_PACKAGE_NAME)
|
ActivityCompat.startActivity(context, feedIntent, null)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -126,7 +126,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp"
|
app:navigationIcon="@drawable/ic_keyboard_backspace_black_24dp"
|
||||||
app:title="@string/social_instagram"
|
app:title="@string/social_stories"
|
||||||
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" />
|
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" />
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -821,6 +821,6 @@
|
||||||
<string name="volume">Volume</string>
|
<string name="volume">Volume</string>
|
||||||
<string name="listeners_label">Listeners</string>
|
<string name="listeners_label">Listeners</string>
|
||||||
<string name="scrobbles_label">Scrobbles</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>
|
<string name="share_to_stories">Share to Stories</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue