Created
January 26, 2015 09:42
-
-
Save noln/77503c4d6734429220ee to your computer and use it in GitHub Desktop.
This file contains 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 characters
/* | |
First-off, huge thanks both Fenix and Buffer teams for the apps, I use them both | |
every day, and think they're brilliant! The only issue I have is that they don't | |
currently like to talk to eachother...if they did? That would be great! | |
Here's my analysis on why they currently don't: | |
******************************************************************************** | |
I ran an emulator to compare the outputs of the official Twitter App for | |
Android and Fenix to compare how the two send data via share intents. The | |
problem is due to what is supplied in Intent.EXTRA_TEXT when the Tweet is | |
shared, as Buffer accepts the Tweet find from the official Twitter app fine. | |
** In both cases here I used the "Share" option, not "Share link to Tweet". | |
** I used this tweet for the examples: https://twitter.com/fenix_app/status/559605018375249920 | |
The official Twitter app sends these extras with the share intent: | |
Key: android.intent.extra.TEXT | |
Value: Check out @fenix_app's Tweet: https://twitter.com/fenix_app/status/559605018375249920?s=09 | |
Key: tweet_id | |
Value: 559605018375249920 | |
Fenix sends these extras with the share intent: | |
Key: android.support.v4.app.EXTRA_CALLING_PACKAGE | |
Value: it.mvilla.android.fenix | |
Key: android.support.v4.app.EXTRA_CALLING_ACTIVITY | |
Value: (ComponentInfo) ComponentInfo{it.mvilla.android.fenix/it.mvilla.android.fenix.ui.activity.TweetActivity} | |
Key: android.intent.extra.SUBJECT | |
Value: Tweet from @fenix_app | |
Key: android.intent.extra.TEXT | |
Value: @nolnefm @buffer I'm not sure how that's a Fenix issue - how can I fix it? | |
******************************************************************************** | |
So what I reckon is going on (without having access to either codebase obv!) is | |
that Buffer parses the username from the "android.intent.extra.SUBJECT" extra, | |
and just puts "RT " infront of it. | |
******************************************************************************** | |
[POTENTIAL SOLUTIONS] | |
So there are two potential fixes that I can see, EITHER: | |
1. Fenix switches to providing the link to a Tweet in the same way | |
that the Twitter for Android official app does, which is what I did | |
in this example: | |
*/ | |
/** This method takes the current "Share link to Tweet" intent from | |
* Fenix, chops up the string to get the username, then builds | |
* another string which is of the same format as that shared by the | |
* official Twitter app. | |
* | |
* The resulting string is then passed to Buffer. | |
*/ | |
private void handleSendText(Intent intent){ | |
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); | |
if (sharedText != null) { | |
StringBuilder sb = new StringBuilder(); | |
// Make a string in the format that Buffer can swallow. | |
sb.append("Check out @"); | |
sb.append(sharedText.split("/")[3]); // Get the Twitter username from the URL. | |
sb.append("'s Tweet: "); | |
sb.append(sharedText); // Include the URL. | |
sb.append("?s=09"); // Add this to the end. Because... ?! | |
// Punt it over. | |
sendIntentToBuffer(sb.toString()); | |
// Close the app. | |
finish(); | |
} | |
} | |
/** This method takes the string that was created and passes it to Buffer. */ | |
private void sendIntentToBuffer(String s){ | |
Intent shareIntent = new Intent(); | |
shareIntent.setAction(Intent.ACTION_SEND); | |
shareIntent.putExtra(Intent.EXTRA_TEXT, s); | |
shareIntent.setType("text/plain"); | |
startActivity(shareIntent); | |
} | |
/* | |
The required URL is already in the Fenix app, as that's what's shared | |
when "Share link to Tweet" is selected. | |
* Or | |
2. Fenix includes the "tweet_id" extra, and Buffer pulls the content | |
directly from that. | |
Either way I believe that the Buffer app requires the Tweet ID value in order | |
to form up a proper buffered Tweet, which Fenix does not currently provide. This | |
is why I'm calling it a Fenix issue rather than a Buffer one at this time. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment