/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent.<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @param isGrid If the share intent BottomSheet should be grid styled * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ public static DialogFragment createShareBottomSheet(Context context, Intent intent, String shareTitle, boolean isGrid) { return createShareBottomSheet(context, intent, shareTitle, isGrid, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent.<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @param isGrid If the share intent BottomSheet should be grid styled * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ public static DialogFragment createShareBottomSheet(Context context, Intent intent, String shareTitle, boolean isGrid) { return createShareBottomSheet(context, intent, shareTitle, isGrid, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent. This will be List styled by default.<br> * If grid style is desired, use {@link #createShareBottomSheet(Context, Intent, String, boolean)}<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, String shareTitle) { return createShareBottomSheet(context, intent, shareTitle, false, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent. This will be List styled by default.<br> * If grid style is desired, use {@link #createShareBottomSheet(Context, Intent, String, boolean)}<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, String shareTitle) { return createShareBottomSheet(context, intent, shareTitle, false, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent.<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title string resource for the share intent * @param isGrid If the share intent BottomSheet should be grid styled * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, @StringRes int shareTitle, boolean isGrid) { return createShareBottomSheet(context, intent, context.getString(shareTitle), isGrid, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent. This will be list styled by default.<br> * If grid style is desired, use {@link #createShareBottomSheet(Context, Intent, String, boolean)}<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, @StringRes int shareTitle) { return createShareBottomSheet(context, intent, context.getString(shareTitle), false, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent. This will be list styled by default.<br> * If grid style is desired, use {@link #createShareBottomSheet(Context, Intent, String, boolean)}<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, @StringRes int shareTitle) { return createShareBottomSheet(context, intent, context.getString(shareTitle), false, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent.<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title string resource for the share intent * @param isGrid If the share intent BottomSheet should be grid styled * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, @StringRes int shareTitle, boolean isGrid) { return createShareBottomSheet(context, intent, context.getString(shareTitle), isGrid, null, null); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent.<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @param isGrid If the share intent BottomSheet should be grid styled * @param appsFilter If provided share will be limited to contained packaged names * @param toExclude If provided, share will exclude the given package names * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, @StringRes int shareTitle, boolean isGrid, @Nullable Set<String> appsFilter, @Nullable Set<String> toExclude) { return createShareBottomSheet(context, intent, context.getString(shareTitle), isGrid, appsFilter, toExclude); }
/** * Returns a {@link BottomSheetMenuDialogFragment} to be used as a share intent like Android 5.x+ Share Intent.<p> * An example of an intent to pass is sharing some form of text:<br> * Intent intent = new Intent(Intent.ACTION_SEND);<br> * intent.setType("text/*");<br> * intent.putExtra(Intent.EXTRA_TEXT, "Some text to share");<br> * BottomSheet bottomSheet = BottomSheet.createShareBottomSheet(this, intent, "Share");<br> * if (bottomSheet != null) bottomSheet.show();<br> * * @param context App context * @param intent Intent to get apps for * @param shareTitle The optional title for the share intent * @param isGrid If the share intent BottomSheet should be grid styled * @param appsFilter If provided share will be limited to contained packaged names * @param toExclude If provided, share will exclude the given package names * @return A {@link BottomSheetMenuDialogFragment} with the apps that can handle the share intent. NULL maybe returned if no * apps can handle the share intent */ @Nullable public static DialogFragment createShareBottomSheet(Context context, Intent intent, @StringRes int shareTitle, boolean isGrid, @Nullable Set<String> appsFilter, @Nullable Set<String> toExclude) { return createShareBottomSheet(context, intent, context.getString(shareTitle), isGrid, appsFilter, toExclude); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.share: Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/*"); intent.putExtra(Intent.EXTRA_TEXT, "Hey, check out the BottomSheet library https://github.com/Kennyc1012/BottomSheet"); DialogFragment bottomSheet = BottomSheetMenuDialogFragment.createShareBottomSheet(getApplicationContext(), intent, "Share"); if (bottomSheet != null) bottomSheet.show(getSupportFragmentManager(), null); return true; } return super.onOptionsItemSelected(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.share: Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/*"); intent.putExtra(Intent.EXTRA_TEXT, "Hey, check out the BottomSheet library https://github.com/Kennyc1012/BottomSheet"); DialogFragment bottomSheet = BottomSheetMenuDialogFragment.createShareBottomSheet(getApplicationContext(), intent, "Share"); if (bottomSheet != null) bottomSheet.show(getSupportFragmentManager(), null); return true; } return super.onOptionsItemSelected(item); }