Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
James Duffy committed Sep 17, 2013
2 parents 598d72f + cf0f76f commit 000a98a
Show file tree
Hide file tree
Showing 13 changed files with 199 additions and 51 deletions.
4 changes: 2 additions & 2 deletions android/clientbeta/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tweetlanes.android.beta"
android:versionCode="8"
android:versionName="1.2.1_b2">
android:versionCode="51"
android:versionName="1.2.1_b5">



Expand Down
13 changes: 12 additions & 1 deletion android/libraries/SocialNetLib/src/com/twitter/Autolink.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public Autolink() {
extractor.setExtractURLWithoutProtocol(false);
}

public void setExtractURLWithoutProtocol(boolean newValue){
extractor.setExtractURLWithoutProtocol(newValue);
}

String escapeBrackets(String text) {
int len = text.length();
if (len == 0) return text;
Expand Down Expand Up @@ -179,7 +183,14 @@ void linkToURL(Entity entity, String text, StringBuilder builder,
linkText = linkText.replaceAll("^https?://", "").replaceAll("^www.", "");

Map<String, String> attrs = new LinkedHashMap<String, String>();
attrs.put("href", url.toString());

if(urlEntity != null && urlEntity.getExpandedURL() != null){
attrs.put("href", urlEntity.getExpandedURL());
}
else
{
attrs.put("href", url.toString());
}

linkToText(entity, linkText, attrs, builder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.text.ParseException;
import java.util.Date;

import twitter4j.URLEntity;

public class AdnPost {

public long mId;
Expand All @@ -34,6 +36,7 @@ public class AdnPost {
public boolean mIsFavorited;
public AdnUser mOriginalAuthor;
public AdnMedia mEmbeddedMedia;
public URLEntity[] mUrls;

public AdnPost() {
}
Expand Down Expand Up @@ -113,6 +116,17 @@ public AdnPost(String jsonAsString) {
}
}
}
if (entities.has("links")) {
JSONArray jsonArray = entities.getJSONArray("links");
mUrls = new URLEntity[jsonArray.length()];
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject link = jsonArray.getJSONObject(i);
if (link.has("text") && link.has("url")) {
URLEntity url = new AdnUrl(link.getString("text"),link.getString("url"));
mUrls[i] = url;
}
}
}
}

if (object.has("annotations")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.appdotnet4j.model;

import twitter4j.URLEntity;

public class AdnUrl implements URLEntity {

private String text;
private String url;

public AdnUrl(String text, String url){
this.text = text;
this.url = url;
}

@Override
public String getText() {
return text;
}

@Override
public String getURL() {
return url;
}

@Override
public String getExpandedURL() {
return url;
}

@Override
public String getDisplayURL() {
return text;
}

@Override
public int getStart() {
return 0;
}

@Override
public int getEnd() {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ private AdnUsers getUsers(String path, ParameterMap params) {
*
*/
public AdnPost getAdnPost(long id) {
String postString = doGet("/stream/0/posts/" + id, null);
ParameterMap params = new ParameterMap();
params.add("include_post_annotations", "1");
String postString = doGet("/stream/0/posts/" + id, params);
if (postString != null) {
return new AdnPost(postString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@
public class TwitterUtil {

private static Autolink mAutoLink;
private static boolean mAllowReInit = true;

private static void initCommon() {

if (mAutoLink == null) {
mAutoLink = new Autolink();
if(mAllowReInit)
{
if (mAutoLink == null) {
mAutoLink = new Autolink();
}

mAutoLink.setExtractURLWithoutProtocol(false);
}
}

Expand Down Expand Up @@ -68,7 +74,14 @@ public static String getStatusMarkup(Status status) {
*/
public static String getStatusMarkup(AdnPost post) {

return getStatusMarkup(post.mText, null, null);
initCommon();
mAutoLink.setExtractURLWithoutProtocol(true);
mAllowReInit = false;

String statusMarkup = getStatusMarkup(post.mText, null, post.mUrls);
mAllowReInit = true;

return statusMarkup;
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<TextView
android:id="@+id/accountScreenName"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="ScreenName"
android:textSize="@dimen/account_row_size"
Expand Down
2 changes: 2 additions & 0 deletions android/libraries/TweetLanesCore/res/xml/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<change>Fix - Profile URL is now expanded from a t.co</change>
<change>Fix - Close several leaks dealing with the image loader</change>
<change>Fix - Significantly reduce overdraw in lists containing tweets</change>
<change>Fix - Force close when switching accounts</change>
<change>Fix - New tweet count on close and re-open</change>
<change>Other - Large codebase tidy-up - hopefully small improvement to performance, size and reliability</change>
</release>
<release version="1.2.0" versioncode="49">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ protected void onDestroy() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(
mRestartAppReceiver);

clearCompose();
super.onDestroy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ App getApp() {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setTheme(AppSettings.get().getCurrentThemeStyle());

if (Constant.ENABLE_CRASH_TRACKING) {
Crittercism.init(getApplicationContext(),
ConsumerKeyConstants.CRITTERCISM_APP_ID);
}

setTheme(AppSettings.get().getCurrentThemeStyle());
// LocalBroadcastManager.getInstance(this).registerReceiver(mOAuthLoginStateChangeReceiver,
// new IntentFilter("" + SystemEvent.OAuthLoginStateChange));
}
Expand Down Expand Up @@ -89,43 +88,40 @@ void jumpToNext() {
Uri uriData = getIntent().getData();
if (uriData != null) {
String host = uriData.getHost();
boolean urlValid = false;
finish();


if(uriData.getPath().contains("/status/") || uriData.getPath().contains("/post/"))
{
String statusId = "";

finish();

if (host.contains("twitter")) {
boolean nextPartStatus = false;
for (String uriPart : uriData.getPathSegments()){
if(nextPartStatus==true){
statusId = uriPart;
break;
}
if(uriPart.toLowerCase().equals("status")){
nextPartStatus = true;
}
}
if (getApp().getCurrentAccount().getSocialNetType() != SocialNetConstant.Type.Twitter) {
changeToFirstAccountOfType(SocialNetConstant.Type.Twitter);
}
if (host.contains("twitter")) {
if (getApp().getCurrentAccount().getSocialNetType() != SocialNetConstant.Type.Twitter) {
changeToFirstAccountOfType(SocialNetConstant.Type.Twitter);
}
else if (host.contains("app.net")) {
statusId = uriData.getLastPathSegment();

if (getApp().getCurrentAccount().getSocialNetType() != SocialNetConstant.Type.Appdotnet) {
changeToFirstAccountOfType(SocialNetConstant.Type.Appdotnet);
}
if(uriData.getPath().contains("/status/"))
{
String statusId = getUriPartAfterText(uriData, "status");
startTweetSpotlight(statusId);
urlValid = true;
}
}
else if (host.contains("app.net")) {
if (getApp().getCurrentAccount().getSocialNetType() != SocialNetConstant.Type.Appdotnet) {
changeToFirstAccountOfType(SocialNetConstant.Type.Appdotnet);
}

startTweetSpotlight(statusId);
if(uriData.getPath().contains("/post/"))
{
String statusId = getUriPartAfterText(uriData, "post");
startTweetSpotlight(statusId);
urlValid = true;
}
}
else

if(!urlValid)
{
Toast.makeText(getApplicationContext(), getString(R.string.unknown_intent),
Constant.DEFAULT_TOAST_DISPLAY_TIME).show();

startHomeActivity("");
}
}
else if (mLastStartedClass != HomeActivity.class) {
Expand Down Expand Up @@ -153,6 +149,21 @@ else if (mLastStartedClass != HomeActivity.class) {

}

private String getUriPartAfterText(Uri uriData, String partBefore)
{
boolean nextPartStatus = false;
for (String uriPart : uriData.getPathSegments()){
if(nextPartStatus==true){
return uriPart;
}
if(uriPart.toLowerCase().equals(partBefore)){
nextPartStatus = true;
}
}

return "";
}

private void changeToFirstAccountOfType(SocialNetConstant.Type socialNetType) {
for (AccountDescriptor account : getApp().getAccounts()) {
if (account.getSocialNetType() == socialNetType) {
Expand All @@ -169,4 +180,21 @@ private void startTweetSpotlight(String statusId) {
overridePendingTransition(0, 0);
startActivity(tweetSpotlightIntent);
}

private void startHomeActivity(String composeText) {
Intent tweetSpotlightIntent = new Intent(this, HomeActivity.class);
if(!composeText.isEmpty()){
tweetSpotlightIntent.putExtra("composeText", composeText);
}
overridePendingTransition(0, 0);
startActivity(tweetSpotlightIntent);
}

private void startProfileSpotlight(String userName) {
Intent tweetSpotlightIntent = new Intent(this, ProfileActivity.class);
tweetSpotlightIntent.putExtra("userScreenName", userName);
tweetSpotlightIntent.putExtra("clearCompose", "true");
overridePendingTransition(0, 0);
startActivity(tweetSpotlightIntent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,17 @@ void onCreateHandleIntents() {
boolean turnSoftKeyboardOff = true;

Intent intent = getIntent();

Bundle extras = intent.getExtras();
if (extras != null) {
String composeText = extras.getString("composeText");
if(composeText!= null && !composeText.isEmpty()){
beginShareStatus(composeText);
}
}

if (intent.getAction() == Intent.ACTION_SEND) {

Bundle extras = intent.getExtras();
String type = intent.getType();
if (type.equals("text/plain")) {

Expand Down Expand Up @@ -545,6 +553,7 @@ private void showAccount(AccountDescriptor selectedAccount, Constant.LaneType la
clearFragmentsCache();

app.setCurrentAccount(selectedAccount.getId());
mHomeLaneAdapter.notifyDataSetChanged();

// From http://stackoverflow.com/a/3419987/328679
Intent intent = getIntent();
Expand Down
Loading

0 comments on commit 000a98a

Please sign in to comment.