Skip to content

Commit 2cbc2cf

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/people-management-sync
2 parents 80c9d64 + 7558982 commit 2cbc2cf

File tree

27 files changed

+521
-124
lines changed

27 files changed

+521
-124
lines changed

WordPress/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
maven { url 'https://maven.fabric.io/public' }
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:2.0.0'
7+
classpath 'com.android.tools.build:gradle:2.1.0'
88
classpath 'io.fabric.tools:gradle:1.+'
99
}
1010
}
@@ -13,6 +13,7 @@ repositories {
1313
jcenter()
1414
maven { url 'http://wordpress-mobile.github.io/WordPress-Android' }
1515
maven { url 'https://maven.fabric.io/public' }
16+
maven { url 'http://dl.bintray.com/optimizely/optimizely' }
1617
}
1718

1819
apply plugin: 'com.android.application'
@@ -75,6 +76,10 @@ dependencies {
7576
transitive = true;
7677
}
7778

79+
compile('com.optimizely:optimizely:+@aar') {
80+
transitive = true
81+
}
82+
7883
// Provided by maven central
7984
compile ('org.wordpress:mediapicker:1.2.4') {
8085
exclude group:'com.android.support'

WordPress/gradle.properties-example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ wp.oauth.redirect_uri = http://android.wordpress.org/
44
wp.gcm.id = wordpress
55
wp.db_secret = wordpress
66
wp.mixpanel_token = wordpress
7+
wp.optimizely_token = wordpress
78
wp.simperium.app_secret = wordpress
89
wp.simperium.app_name = wordpress
910
wp.helpshift.api.key = wordpress

WordPress/lint.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<warning path="src/main/res/values/reader_styles.xml" />
99
<warning path="src/main/res/values/styles.xml" />
1010
</issue>
11+
<issue id="InvalidPackage">
12+
<ignore regexp="okio-1.6.0.jar" />
13+
</issue>
1114

1215
<issue id="HardcodedText" severity="error" />
1316
<issue id="IconDuplicates" severity="error" />

WordPress/src/main/java/org/wordpress/android/models/Comment.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.wordpress.android.models;
22

33
import android.content.Context;
4+
import android.text.Spanned;
45
import android.text.TextUtils;
56

67
import org.json.JSONObject;
@@ -182,11 +183,12 @@ public java.util.Date getDatePublished() {
182183
return dtPublished;
183184
}
184185

185-
private transient String unescapedCommentText;
186-
public String getUnescapedCommentText() {
187-
if (unescapedCommentText == null)
188-
unescapedCommentText = StringUtils.unescapeHTML(getCommentText()).trim();
189-
return unescapedCommentText;
186+
private transient Spanned unescapedCommentWithDrawables;
187+
public void setUnescapedCommentWithDrawables(Spanned spanned){
188+
unescapedCommentWithDrawables = spanned;
189+
}
190+
public Spanned getUnescapedCommentTextWithDrawables() {
191+
return unescapedCommentWithDrawables;
190192
}
191193

192194
private transient String unescapedPostTitle;
@@ -238,4 +240,5 @@ public boolean willTrashingPermanentlyDelete(){
238240
CommentStatus status = getStatusEnum();
239241
return CommentStatus.TRASH.equals(status) || CommentStatus.SPAM.equals(status);
240242
}
243+
241244
}

WordPress/src/main/java/org/wordpress/android/models/ReaderTag.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,12 @@ public String getLabel() {
180180
}
181181

182182
@Override
183-
public boolean equals(Object tag){
184-
if (tag == null) return false;
185-
186-
if (!ReaderTag.class.isAssignableFrom(tag.getClass())) return false;
187-
188-
return getLabel().equals(((ReaderTag) tag).getLabel());
183+
public boolean equals(Object object){
184+
if (object instanceof ReaderTag) {
185+
ReaderTag tag = (ReaderTag) object;
186+
return (tag.tagType == this.tagType && tag.getLabel().equals(this.getLabel()));
187+
} else {
188+
return false;
189+
}
189190
}
190191
}

WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
import android.content.Intent;
55
import android.os.Bundle;
66

7+
import com.optimizely.Optimizely;
8+
9+
import org.wordpress.android.BuildConfig;
710
import org.wordpress.android.R;
811
import org.wordpress.android.WordPress;
912
import org.wordpress.android.ui.main.WPMainActivity;
1013
import org.wordpress.android.util.ProfilingUtils;
1114
import org.wordpress.android.util.ToastUtils;
15+
import org.wordpress.android.util.WPOptimizelyEventListener;
1216

1317
public class WPLaunchActivity extends Activity {
1418

@@ -30,9 +34,16 @@ protected void onCreate(Bundle savedInstanceState) {
3034
return;
3135
}
3236

37+
configureOptimizely();
38+
3339
Intent intent = new Intent(this, WPMainActivity.class);
3440
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
3541
startActivity(intent);
3642
finish();
3743
}
44+
45+
private void configureOptimizely() {
46+
Optimizely.addOptimizelyEventListener(new WPOptimizelyEventListener());
47+
Optimizely.startOptimizelyWithAPIToken(BuildConfig.OPTIMIZELY_TOKEN, getApplication());
48+
}
3849
}

WordPress/src/main/java/org/wordpress/android/ui/accounts/SignInFragment.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
4242
import com.google.android.gms.common.api.ResultCallback;
4343
import com.google.android.gms.common.api.Status;
44+
import com.optimizely.Optimizely;
45+
import com.optimizely.Variable.LiveVariable;
4446
import com.wordpress.rest.RestRequest;
4547

4648
import org.json.JSONException;
@@ -86,6 +88,7 @@
8688

8789
public class SignInFragment extends AbstractFragment implements TextWatcher, ConnectionCallbacks,
8890
OnConnectionFailedListener {
91+
private static LiveVariable<Boolean> isNotOnWordPressComVariable = Optimizely.booleanForKey("isNotOnWordPressCom", false);
8992
private static final String DOT_COM_BASE_URL = "https://wordpress.com";
9093
private static final String FORGOT_PASSWORD_RELATIVE_URL = "/wp-login.php?action=lostpassword";
9194
private static final int WPCOM_ERRONEOUS_LOGIN_THRESHOLD = 3;
@@ -171,6 +174,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
171174
mCreateAccountButton = (WPTextView) rootView.findViewById(R.id.nux_create_account_button);
172175
mCreateAccountButton.setOnClickListener(mCreateAccountListener);
173176
mAddSelfHostedButton = (WPTextView) rootView.findViewById(R.id.nux_add_selfhosted_button);
177+
setDotComAddSelfHostedButtonText();
174178
mAddSelfHostedButton.setOnClickListener(new OnClickListener() {
175179
@Override
176180
public void onClick(View v) {
@@ -224,7 +228,6 @@ public void onClick(View v) {
224228
initInfoButtons(rootView);
225229
moveBottomButtons();
226230
initSmartLockForPasswords();
227-
228231
return rootView;
229232
}
230233

@@ -240,7 +243,15 @@ private void toggleSignInMode(){
240243

241244
private void showDotComSignInForm(){
242245
mUrlButtonLayout.setVisibility(View.GONE);
243-
mAddSelfHostedButton.setText(getString(R.string.nux_add_selfhosted_blog));
246+
setDotComAddSelfHostedButtonText();
247+
}
248+
249+
private void setDotComAddSelfHostedButtonText() {
250+
if (isNotOnWordPressComVariable.get()) {
251+
mAddSelfHostedButton.setText(R.string.not_on_wordpress_com);
252+
} else {
253+
mAddSelfHostedButton.setText(getString(R.string.nux_add_selfhosted_blog));
254+
}
244255
}
245256

246257
private void showSelfHostedSignInForm(){
@@ -310,7 +321,9 @@ private void initSmartLockForPasswords() {
310321
}
311322

312323
public void smartLockAutoFill() {
313-
if (!isGooglePlayServicesAvailable() || mCredentialsClient == null) {
324+
// We don't want to autofill username and password fields if self hosted has been selected (pre-selected or
325+
// user selected).
326+
if (!isGooglePlayServicesAvailable() || mCredentialsClient == null || mSelfHosted) {
314327
return;
315328
}
316329
CredentialRequest credentialRequest = new CredentialRequest.Builder()

WordPress/src/main/java/org/wordpress/android/ui/comments/CommentAdapter.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package org.wordpress.android.ui.comments;
22

33
import android.content.Context;
4+
import android.graphics.Bitmap;
5+
import android.graphics.BitmapFactory;
6+
import android.graphics.drawable.BitmapDrawable;
7+
import android.graphics.drawable.Drawable;
48
import android.os.AsyncTask;
59
import android.support.v7.widget.RecyclerView;
610
import android.text.Html;
11+
import android.text.Spanned;
712
import android.view.LayoutInflater;
813
import android.view.View;
914
import android.view.ViewGroup;
@@ -19,8 +24,13 @@
1924
import org.wordpress.android.util.AniUtils;
2025
import org.wordpress.android.util.AppLog;
2126
import org.wordpress.android.util.DateTimeUtils;
27+
import org.wordpress.android.util.ImageUtils;
28+
import org.wordpress.android.util.StringUtils;
29+
import org.wordpress.android.util.WPHtml;
2230
import org.wordpress.android.widgets.WPNetworkImageView;
2331

32+
import java.io.IOException;
33+
import java.net.URL;
2434
import java.util.ArrayList;
2535
import java.util.HashSet;
2636
import java.util.List;
@@ -44,6 +54,7 @@ interface OnCommentPressedListener {
4454
}
4555

4656
private final LayoutInflater mInflater;
57+
private final Context mContext;
4758

4859
private final CommentList mComments = new CommentList();
4960
private final HashSet<Integer> mSelectedPositions = new HashSet<>();
@@ -110,6 +121,7 @@ public boolean onLongClick(View v) {
110121

111122
CommentAdapter(Context context, int localBlogId) {
112123
mInflater = LayoutInflater.from(context);
124+
mContext = context;
113125

114126
mLocalBlogId = localBlogId;
115127

@@ -163,7 +175,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
163175
}
164176

165177
holder.txtTitle.setText(Html.fromHtml(comment.getFormattedTitle()));
166-
holder.txtComment.setText(comment.getUnescapedCommentText());
178+
holder.txtComment.setText(comment.getUnescapedCommentTextWithDrawables());
167179
holder.txtDate.setText(DateTimeUtils.javaDateToTimeSpan(comment.getDatePublished()));
168180

169181
// status is only shown for comments that haven't been approved
@@ -416,10 +428,14 @@ protected Boolean doInBackground(Void... params) {
416428
// pre-calc transient values so they're cached prior to display
417429
for (Comment comment: tmpComments) {
418430
comment.getDatePublished();
419-
comment.getUnescapedCommentText();
420431
comment.getUnescapedPostTitle();
421432
comment.getAvatarForDisplay(mAvatarSz);
422433
comment.getFormattedTitle();
434+
435+
String content = StringUtils.notNullStr(comment.getCommentText());
436+
//to load images embedded within comments, pass an ImageGetter to WPHtml.fromHtml()
437+
Spanned spanned = WPHtml.fromHtml(content, null, null, mContext, null, 0);
438+
comment.setUnescapedCommentWithDrawables(spanned);
423439
}
424440

425441
return true;
@@ -439,4 +455,5 @@ protected void onPostExecute(Boolean result) {
439455
mIsLoadTaskRunning = false;
440456
}
441457
}
458+
442459
}

0 commit comments

Comments
 (0)