Last active
December 16, 2015 15:49
-
-
Save FokkeZB/5458506 to your computer and use it in GitHub Desktop.
Revisions
-
FokkeZB revised this gist
Oct 2, 2013 . 4 changed files with 5 additions and 284 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,3 @@ # Sharing Moved to: https://github.com/FokkeZB/UTiL/tree/master/share This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1 @@ // Check https://github.com/FokkeZB/UTiL/tree/master/share This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,233 +1 @@ // Check https://github.com/FokkeZB/UTiL/tree/master/share This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1 @@ <!-- Check https://github.com/FokkeZB/UTiL/tree/master/share --> -
FokkeZB revised this gist
May 6, 2013 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,7 @@ It will be extended further over time with more options and fallbacks. # TODO * Apply `customIcons` to optionDialog fallback as well * Add Twitter URL schemes and web-intent fallbacks * Translate activityView options to optionDialog fallbacks # NOTES * There is a [known problem](https://github.com/viezel/TiSocial.Framework/issues/41) with iOS5 Twitter not using the image. -
FokkeZB revised this gist
May 6, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,8 @@ btn.addEventListener('click', function () { description: 'Alternative text used in Facebook feed-dialog', url: 'http://url.to.share', caption: 'Caption for the URL, used in Facebook feed-dialog', image: '/images/image.png', // Can be local path, URL, File or Blob image_url: 'http://url.to.share/image.png', // If 'image' is not an URL, you can specify one here for like Facebook only works with an URL // Applied to activityView (https://github.com/viezel/TiSocial.Framework#socialactivityview) removeIcons: 'print,sms', -
FokkeZB revised this gist
May 6, 2013 . 2 changed files with 46 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,5 +5,4 @@ It will be extended further over time with more options and fallbacks. # TODO * Apply `customIcons` to optionDialog fallback as well * Add Twitter URL schemes and web-intent fallbacks * Translate activityView options to optionDialog fallbacks This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,22 +9,32 @@ if (ios) { var facebook_appid, facebook; function share(args) { if (args.image) { if (typeof args.image === 'object') { if (args.image.resolve) { args.image_blob = args.image; args.image = args.image_blob.resolve(); } else if (args.image.nativePath) { args.image_blob = args.image; args.image = args.image_blob.nativePath; } else { delete args.image; } } else if (args.image.indexOf('://') > 0) { args.image_url = args.image; } } if (args.image_url && !args.image) { args.image = args.image_url; } if (ios && Social.isActivityViewSupported()) { if (ipad) { @@ -59,8 +69,8 @@ function share(args) { intent.putExtra(Ti.Android.EXTRA_SUBJECT, args.description || args.text); } if (args.image_blob) { intent.putExtraUri(Ti.Android.EXTRA_STREAM, args.image_blob); } var share = Ti.Android.createIntentChooser(intent, args.titleid ? L(args.titleid, args.title || 'Share') : (args.title || 'Share')); @@ -113,13 +123,15 @@ function share(args) { if (options[e.index] === 'Twitter') { if (ios && Social.isTwitterSupported()) { // Twitter SDK does not support both URL and image: https://github.com/viezel/TiSocial.Framework/issues/41 Social.twitter({ text: (args.url && args.image) ? (args.text ? args.text + ' ' + args.url : args.url) : args.text, image: args.image_url, url: args.image ? null : args.url }); } } else if (options[e.index] === 'Facebook') { if (ios && Social.isFacebookSupported()) { @@ -138,7 +150,7 @@ function share(args) { return; } if (_cmpVersion(Ti.version, '3.1.0') >= 0) { facebook = require('facebook'); facebook.appid = facebook_appid; } else { @@ -151,7 +163,7 @@ function share(args) { link: args.url, caption: args.caption, description: args.description || args.text, picture: args.image_url }, function (e) { return; }); @@ -161,7 +173,7 @@ function share(args) { link: args.url, caption: args.caption, description: args.description || args.text, picture: args.image_url }, function (e) { return; }); @@ -175,8 +187,8 @@ function share(args) { messageBody: args.body || args.text + "<br /><br />" + args.url, }); if (args.image_blob) { emailDialog.addAttachment(args.image_blob); } emailDialog.open(); @@ -199,21 +211,23 @@ function share(args) { return; } function _cmpVersion(a, b) { var i, cmp, len, re = /(\.0)+[^\.]*$/; a = (a + '').replace(re, '').split('.'); b = (b + '').replace(re, '').split('.'); len = Math.min(a.length, b.length); for( i = 0; i < len; i++ ) { cmp = parseInt(a[i], 10) - parseInt(b[i], 10); if( cmp !== 0 ) { return cmp; } } return a.length - b.length; } if (typeof exports !== 'undefined') { if (typeof module !== 'undefined' && module.exports) { exports = module.exports = share; } exports.share = share; } -
FokkeZB revised this gist
Apr 29, 2013 . 2 changed files with 85 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,5 @@ It will be extended further over time with more options and fallbacks. # TODO * Apply `customIcons` to optionDialog fallback as well * Add Twitter URL schemes and web-intent fallbacks * Add app-rate option * Translate activityView options to optionDialog fallbacks This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ var ios = (Ti.Platform.name === 'iPhone OS'), android = (Ti.Platform.name === 'android'), ipad = (ios && Ti.Platform.osname === 'ipad'); if (ios) { var Social = require('dk.napp.social'); @@ -8,6 +9,21 @@ if (ios) { var facebook_appid, facebook; function share(args) { if (args.image && typeof args.image === 'object') { if (args.image.resolve) { args.blob = args.image; args.image = args.blob.resolve(); } else if (args.image.nativePath) { args.blob = args.image; args.image = args.blob.nativePath; } else { delete args.image; } } if (ios && Social.isActivityViewSupported()) { @@ -24,13 +40,37 @@ function share(args) { text: args.url ? (args.text ? args.text + ' ' + args.url : args.url) : args.text, image: args.image, removeIcons: args.removeIcons }, args.customIcons); } return; } if (android) { var intent = Ti.Android.createIntent({ action: Ti.Android.ACTION_SEND }); if (args.text) { intent.putExtra(Ti.Android.EXTRA_TEXT, args.text); } if (args.text || args.description) { intent.putExtra(Ti.Android.EXTRA_SUBJECT, args.description || args.text); } if (args.blob) { intent.putExtraUri(Ti.Android.EXTRA_STREAM, args.blob); } var share = Ti.Android.createIntentChooser(intent, args.titleid ? L(args.titleid, args.title || 'Share') : (args.title || 'Share')); Ti.Android.currentActivity.startActivity(share); return; } var options = ['Twitter', 'Facebook', L('Mail'), L('Cancel')]; if (args.removeIcons && typeof args.removeIcons === 'string') { var removeIcons = args.removeIcons.split(','); @@ -44,6 +84,11 @@ function share(args) { if (removeFacebook >= 0) { options.splice(removeFacebook, 1); } var removeMail = removeIcons.indexOf('mail'); if (removeMail >= 0) { options.splice(removeMail, 1); } } if (options.length === 1) { @@ -60,6 +105,10 @@ function share(args) { }); dialog.addEventListener('click', function (e) { if (e.index === e.source.cancel) { return; } if (options[e.index] === 'Twitter') { @@ -89,7 +138,7 @@ function share(args) { return; } if (_minVersion('3.1.0')) { facebook = require('facebook'); facebook.appid = facebook_appid; } else { @@ -118,6 +167,19 @@ function share(args) { }); } } } else if (options[e.index] === L('Mail')) { var emailDialog = Ti.UI.createEmailDialog({ subject: args.description || args.text, html: true, messageBody: args.body || args.text + "<br /><br />" + args.url, }); if (args.blob) { emailDialog.addAttachment(args.blob); } emailDialog.open(); } return; @@ -137,4 +199,21 @@ function share(args) { return; } function _minVersion(a) { var i, cmp, len, re = /(\.0)+[^\.]*$/; a = (a + '').replace(re, '').split('.'); b = (Ti.version + '').replace(re, '').split('.'); len = Math.min(a.length, b.length); for( i = 0; i < len; i++ ) { cmp = parseInt(a[i], 10) - parseInt(b[i], 10); if (cmp !== 0 ) { return cmp < 0; } } return (a.length - b.length) <= 0; } exports.share = share; -
FokkeZB revised this gist
Apr 25, 2013 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,10 @@ I use this `share.js` library for sharing in apps. It will be extended further over time with more options and fallbacks. # TODO * Apply `customIcons` to optionDialog fallback as well * Add Twitter URL schemes and web-intent fallbacks * Add Android intents fallbacks * Add app-rate option * Translate activityView options to optionDialog fallbacks -
FokkeZB created this gist
Apr 25, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ I use this `share.js` library for sharing in apps. Will be extended further over time with more options and fallbacks (e.g. intents). # TODO * Apply `customIcons` to optionDialog fallback as well * Add Twitter URL schemes and web-intent fallbacks * Add Android intents fallbacks This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ var btn = Ti.UI.createButton({ title: 'Share' }); btn.addEventListener('click', function () { require('share').share({ text: 'Text to share', description: 'Alternative text used in Facebook feed-dialog', url: 'http://url.to.share', caption: 'Caption for the URL, used in Facebook feed-dialog', image: 'http://url.to.share/image.png', // Can be local path too // Applied to activityView (https://github.com/viezel/TiSocial.Framework#socialactivityview) removeIcons: 'print,sms', customIcons: [ { title:"Custom Share", type:"hello.world", image:"pin.png" }, ], // Applied to iPad activityPopover (first only) and optionDialog view: btn, rect: undefined, animated: undefined, // Applied to optionDialog title: 'Share this item', titleid: undefined, androidView: undefined, tizenView: undefined }); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,140 @@ var ios = (Ti.Platform.name === 'iPhone OS'); var ipad = (ios && Ti.Platform.osname === 'ipad'); if (ios) { var Social = require('dk.napp.social'); } var facebook_appid, facebook; function share(args) { if (ios && Social.isActivityViewSupported()) { if (ipad) { Social.activityPopover({ text: args.url ? (args.text ? args.text + ' ' + args.url : args.url) : args.text, image: args.image, removeIcons: args.removeIcons, view: args.view }); } else { Social.activityView({ text: args.url ? (args.text ? args.text + ' ' + args.url : args.url) : args.text, image: args.image, removeIcons: args.removeIcons }); } return; } var options = ['Twitter', 'Facebook', L('Cancel')]; if (args.removeIcons && typeof args.removeIcons === 'string') { var removeIcons = args.removeIcons.split(','); var removeTwitter = removeIcons.indexOf('twitter'); if (removeTwitter >= 0) { options.splice(removeTwitter, 1); } var removeFacebook = removeIcons.indexOf('facebook'); if (removeFacebook >= 0) { options.splice(removeFacebook, 1); } } if (options.length === 1) { return; } var dialog = Ti.UI.createOptionDialog({ cancel: options.length - 1, options: options, title: args.title, titleid: args.titleid, androidView: args.androidView, tizenView: args.tizenView }); dialog.addEventListener('click', function (e) { if (options[e.index] === 'Twitter') { if (ios && Social.isTwitterSupported()) { Social.twitter({ text: args.text, image: args.image, url: args.url }); } } else if (options[e.index] === 'Facebook') { if (ios && Social.isFacebookSupported()) { Social.facebook({ text: args.text, image: args.image, url: args.url }); } else if (facebook_appid !== false) { if (!facebook_appid) { facebook_appid = Ti.App.Properties.getString('ti.facebook.appid', false); if (facebook_appid === false) { return; } if (Ti.version >= '3.1.0') { facebook = require('facebook'); facebook.appid = facebook_appid; } else { Ti.Facebook.appid = facebook_appid; } } if (facebook) { facebook.dialog('feed', { link: args.url, caption: args.caption, description: args.description || args.text, picture: args.image }, function (e) { return; }); } else { Ti.Facebook.dialog('feed', { link: args.url, caption: args.caption, description: args.description || args.text, picture: args.image }, function (e) { return; }); } } } return; }); if (ipad) { dialog.show({ animated: args.animated, rect: args.rect, view: args.view }); } else { dialog.show(); } return; } exports.share = share; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <property name="ti.facebook.appid">123456789</property> <modules> <module platform="android">facebook</module> <module platform="iphone">facebook</module> <module platform="iphone">dk.napp.social</module> </modules>