diff --git a/WordPress/src/main/java/org/wordpress/android/WordPressDB.java b/WordPress/src/main/java/org/wordpress/android/WordPressDB.java
index ae19f7529cf9..d9cde803df80 100755
--- a/WordPress/src/main/java/org/wordpress/android/WordPressDB.java
+++ b/WordPress/src/main/java/org/wordpress/android/WordPressDB.java
@@ -6,6 +6,7 @@
import org.wordpress.android.datasets.NotificationsTable;
import org.wordpress.android.datasets.PeopleTable;
+import org.wordpress.android.datasets.PublicizeTable;
import org.wordpress.android.datasets.SiteSettingsTable;
import org.wordpress.android.datasets.SuggestionTable;
import org.wordpress.android.models.SiteSettingsModel;
@@ -21,7 +22,7 @@
import java.io.OutputStream;
public class WordPressDB {
- private static final int DATABASE_VERSION = 65;
+ private static final int DATABASE_VERSION = 66;
// Warning if you rename DATABASE_NAME, that could break previous App backups (see: xml/backup_scheme.xml)
@@ -170,6 +171,9 @@ public WordPressDB(Context ctx) {
case 64:
// add site icon
mDb.execSQL(SiteSettingsModel.ADD_SITE_ICON);
+ case 65:
+ // add external users only to publicize services table
+ PublicizeTable.resetServicesTable(mDb);
}
mDb.setVersion(DATABASE_VERSION);
}
diff --git a/WordPress/src/main/java/org/wordpress/android/datasets/PublicizeTable.java b/WordPress/src/main/java/org/wordpress/android/datasets/PublicizeTable.java
index b4be318d1741..37c3f229527a 100644
--- a/WordPress/src/main/java/org/wordpress/android/datasets/PublicizeTable.java
+++ b/WordPress/src/main/java/org/wordpress/android/datasets/PublicizeTable.java
@@ -27,6 +27,7 @@ public static void createTables(SQLiteDatabase db) {
+ " connect_url TEXT NOT NULL,"
+ " is_jetpack_supported INTEGER DEFAULT 0,"
+ " is_multi_user_id_supported INTEGER DEFAULT 0,"
+ + " is_external_users_only INTEGER DEFAULT 0,"
+ " PRIMARY KEY (id))");
db.execSQL("CREATE TABLE IF NOT EXISTS " + CONNECTIONS_TABLE + " ("
@@ -55,13 +56,8 @@ private static SQLiteDatabase getWritableDb() {
return WordPress.wpDB.getDatabase();
}
- /*
- * for testing purposes - clears then recreates tables
- */
- public static void reset() {
- getWritableDb().execSQL("DROP TABLE IF EXISTS " + SERVICES_TABLE);
- getWritableDb().execSQL("DROP TABLE IF EXISTS " + CONNECTIONS_TABLE);
- createTables(getWritableDb());
+ public static void resetServicesTable(SQLiteDatabase db) {
+ db.execSQL("DROP TABLE IF EXISTS " + SERVICES_TABLE);
}
public static PublicizeService getService(String serviceId) {
@@ -111,8 +107,9 @@ public static void setServiceList(final PublicizeServiceList serviceList) {
+ " icon_url," // 5
+ " connect_url," // 6
+ " is_jetpack_supported," // 7
- + " is_multi_user_id_supported)" // 8
- + " VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)");
+ + " is_multi_user_id_supported," // 8
+ + " is_external_users_only)" // 9
+ + " VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)");
for (PublicizeService service : serviceList) {
stmt.bindString(1, service.getId());
stmt.bindString(2, service.getLabel());
@@ -122,6 +119,7 @@ public static void setServiceList(final PublicizeServiceList serviceList) {
stmt.bindString(6, service.getConnectUrl());
stmt.bindLong(7, SqlUtils.boolToSql(service.isJetpackSupported()));
stmt.bindLong(8, SqlUtils.boolToSql(service.isMultiExternalUserIdSupported()));
+ stmt.bindLong(9, SqlUtils.boolToSql(service.isExternalUsersOnly()));
stmt.executeInsert();
}
@@ -132,6 +130,11 @@ public static void setServiceList(final PublicizeServiceList serviceList) {
}
}
+ private static boolean getBooleanFromCursor(Cursor cursor, String columnName) {
+ int columnIndex = cursor.getColumnIndex(columnName);
+ return columnIndex != -1 && cursor.getInt(columnIndex) != 0;
+ }
+
private static PublicizeService getServiceFromCursor(Cursor c) {
PublicizeService service = new PublicizeService();
@@ -141,12 +144,23 @@ private static PublicizeService getServiceFromCursor(Cursor c) {
service.setGenericon(c.getString(c.getColumnIndex("genericon")));
service.setIconUrl(c.getString(c.getColumnIndex("icon_url")));
service.setConnectUrl(c.getString(c.getColumnIndex("connect_url")));
- service.setIsJetpackSupported(SqlUtils.sqlToBool(c.getColumnIndex("is_jetpack_supported")));
- service.setIsMultiExternalUserIdSupported(SqlUtils.sqlToBool(c.getColumnIndex("is_multi_user_id_supported")));
+ service.setIsJetpackSupported(getBooleanFromCursor(c, "is_jetpack_supported"));
+ service.setIsMultiExternalUserIdSupported(getBooleanFromCursor(c, "is_multi_user_id_supported"));
+ service.setIsExternalUsersOnly(getBooleanFromCursor(c, "is_external_users_only"));
return service;
}
+ public static boolean onlyExternalConnections(String serviceId) {
+ if (serviceId == null && serviceId.isEmpty()) {
+ return false;
+ }
+
+ String sql = "SELECT is_external_users_only FROM " + SERVICES_TABLE + " WHERE id=?";
+ String[] args = {serviceId};
+ return SqlUtils.boolForQuery(getReadableDb(), sql, args);
+ }
+
public static String getConnectUrlForService(String serviceId) {
if (TextUtils.isEmpty(serviceId)) {
return "";
diff --git a/WordPress/src/main/java/org/wordpress/android/models/PublicizeConnection.java b/WordPress/src/main/java/org/wordpress/android/models/PublicizeConnection.java
index 3f33d30548da..b509447d392b 100644
--- a/WordPress/src/main/java/org/wordpress/android/models/PublicizeConnection.java
+++ b/WordPress/src/main/java/org/wordpress/android/models/PublicizeConnection.java
@@ -20,6 +20,11 @@ public String toString() {
public String toString() {
return "broken";
}
+ },
+ MUST_DISCONNECT {
+ public String toString() {
+ return "must-disconnect";
+ }
}
}
@@ -126,6 +131,8 @@ public void setStatus(String status) {
public ConnectStatus getStatusEnum() {
if (getStatus().equalsIgnoreCase(ConnectStatus.BROKEN.toString())) {
return ConnectStatus.BROKEN;
+ } else if (getStatus().equalsIgnoreCase(ConnectStatus.MUST_DISCONNECT.toString())) {
+ return ConnectStatus.MUST_DISCONNECT;
} else {
return ConnectStatus.OK;
}
@@ -231,6 +238,16 @@ public static PublicizeConnection fromJson(JSONObject json) {
return connection;
}
+ public static void updateConnectionfromExternalJson(PublicizeConnection connection, JSONObject json) {
+ if (connection == null) {
+ return;
+ }
+
+ connection.mExternalId = json.optString("external_ID");
+ connection.mExternalName = json.optString("external_name");
+ connection.mExternalProfilePictureUrl = json.optString("external_profile_picture");
+ }
+
private static long[] getSitesArrayFromJson(JSONArray jsonArray) throws JSONException {
long[] sitesArray = new long[jsonArray.length()];
for (int i = 0; i < jsonArray.length(); i++) {
diff --git a/WordPress/src/main/java/org/wordpress/android/models/PublicizeService.java b/WordPress/src/main/java/org/wordpress/android/models/PublicizeService.java
index 76626dfbef81..c833490b071c 100644
--- a/WordPress/src/main/java/org/wordpress/android/models/PublicizeService.java
+++ b/WordPress/src/main/java/org/wordpress/android/models/PublicizeService.java
@@ -9,6 +9,7 @@ public class PublicizeService {
private String mGenericon;
private String mIconUrl;
private String mConnectUrl;
+ private boolean mIsExternalUsersOnly;
private boolean mIsJetpackSupported;
private boolean mIsMultiExternalUserIdSupported;
@@ -77,6 +78,14 @@ public void setIsMultiExternalUserIdSupported(boolean supported) {
mIsMultiExternalUserIdSupported = supported;
}
+ public boolean isExternalUsersOnly() {
+ return mIsExternalUsersOnly;
+ }
+
+ public void setIsExternalUsersOnly(boolean isExternalUsersOnly) {
+ mIsExternalUsersOnly = isExternalUsersOnly;
+ }
+
public boolean isSameAs(PublicizeService other) {
return other != null
&& other.getId().equals(this.getId())
@@ -85,6 +94,7 @@ public boolean isSameAs(PublicizeService other) {
&& other.getGenericon().equals(this.getGenericon())
&& other.getIconUrl().equals(this.getIconUrl())
&& other.getConnectUrl().equals(this.getConnectUrl())
+ && other.isExternalUsersOnly() == this.isExternalUsersOnly()
&& other.isJetpackSupported() == this.isJetpackSupported();
}
}
diff --git a/WordPress/src/main/java/org/wordpress/android/models/PublicizeServiceList.java b/WordPress/src/main/java/org/wordpress/android/models/PublicizeServiceList.java
index ecefd05a72cb..f56e2d2767b2 100644
--- a/WordPress/src/main/java/org/wordpress/android/models/PublicizeServiceList.java
+++ b/WordPress/src/main/java/org/wordpress/android/models/PublicizeServiceList.java
@@ -40,22 +40,22 @@ public boolean isSameAs(PublicizeServiceList otherList) {
/*
* passed JSON is the response from /meta/external-services?type=publicize
"services": {
- "facebook": {
- "ID": "facebook",
- "label": "Facebook",
- "type": "publicize",
- "description": "Publish your posts to your Facebook timeline or page.",
- "genericon": {
- "class": "facebook-alt",
- "unicode": "\\f203"
- },
- "icon": "http://i.wordpress.com/wp-content/admin-plugins/publicize/assets/publicize-fb-2x.png",
- "connect_URL": "https://public-api.wordpress.com/connect/?action=request
- &kr_nonce=b2c86a0cdb&nonce=94557d1529&for=connect&service=facebook&kr_blog_nonce=5e399375f1
- &magic=keyring&blog=52451191",
- "multiple_external_user_ID_support": true,
- "jetpack_support": true,
- "jetpack_module_required": "publicize"
+ "facebook":{
+ "ID":"facebook",
+ "label":"Facebook",
+ "type":"publicize",
+ "description":"Publish your posts to your Facebook timeline or page.",
+ "genericon":{
+ "class":"facebook-alt",
+ "unicode":"\\f203"
+ },
+ "icon":"http:\/\/i.wordpress.com\/wp-content\/admin-plugins\/publicize\/assets\/publicize-fb-2x.png",
+ "connect_URL":"https:\/\/public-api.wordpress.com\/connect\/?action=request&kr_nonce=a1e2ad2b80
+ &nonce=c4b69a25c1&for=connect&service=facebook&kr_blog_nonce=0ae2027be9&magic=keyring&blog=90298630",
+ "multiple_external_user_ID_support":true,
+ "external_users_only":true,
+ "jetpack_support":true,
+ "jetpack_module_required":"publicize"
},
...
*/
@@ -84,6 +84,7 @@ public static PublicizeServiceList fromJson(JSONObject json) {
service.setIsJetpackSupported(jsonService.optBoolean("jetpack_support"));
service.setIsMultiExternalUserIdSupported(jsonService.optBoolean("multiple_external_user_ID_support"));
+ service.setIsExternalUsersOnly(jsonService.optBoolean("external_users_only"));
JSONObject jsonGenericon = jsonService.optJSONObject("genericon");
if (jsonGenericon != null) {
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java
index 5d23dfb4600f..bd94b7108075 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java
@@ -19,8 +19,10 @@
import org.json.JSONObject;
import org.wordpress.android.R;
import org.wordpress.android.WordPress;
+import org.wordpress.android.datasets.PublicizeTable;
import org.wordpress.android.fluxc.model.SiteModel;
import org.wordpress.android.models.PublicizeConnection;
+import org.wordpress.android.models.PublicizeService;
import org.wordpress.android.util.ToastUtils;
import java.util.ArrayList;
@@ -104,8 +106,9 @@ public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
int keychainId = mNotConnectedAccounts.get(mSelectedIndex).connectionId;
String service = mNotConnectedAccounts.get(mSelectedIndex).getService();
+ String externalUserId = mNotConnectedAccounts.get(mSelectedIndex).getExternalId();
EventBus.getDefault().post(new PublicizeEvents.ActionAccountChosen(mSite.getSiteId(), keychainId,
- service));
+ service, externalUserId));
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@@ -145,12 +148,27 @@ private void addConnectionsToLists(String jsonString) {
JSONObject jsonObject = new JSONObject(jsonString);
JSONArray jsonArray = jsonObject.getJSONArray("connections");
for (int i = 0; i < jsonArray.length(); i++) {
- PublicizeConnection connection = PublicizeConnection.fromJson(jsonArray.getJSONObject(i));
+ JSONObject currentConnectionJson = jsonArray.getJSONObject(i);
+ PublicizeConnection connection = PublicizeConnection.fromJson(currentConnectionJson);
if (connection.getService().equals(mServiceId)) {
- if (connection.isInSite(mSite.getSiteId())) {
- mConnectedAccounts.add(connection);
- } else {
- mNotConnectedAccounts.add(connection);
+ PublicizeService service = PublicizeTable.getService(mServiceId);
+ if (service != null && !service.isExternalUsersOnly()) {
+ if (connection.isInSite(mSite.getSiteId())) {
+ mConnectedAccounts.add(connection);
+ } else {
+ mNotConnectedAccounts.add(connection);
+ }
+ }
+
+ JSONArray externalJsonArray = currentConnectionJson.getJSONArray("additional_external_users");
+ for (int j = 0; j < externalJsonArray.length(); j++) {
+ JSONObject currentExternalConnectionJson = externalJsonArray.getJSONObject(j);
+ PublicizeConnection.updateConnectionfromExternalJson(connection, currentExternalConnectionJson);
+ if (connection.isInSite(mSite.getSiteId())) {
+ mConnectedAccounts.add(connection);
+ } else {
+ mNotConnectedAccounts.add(connection);
+ }
}
}
}
@@ -160,6 +178,10 @@ private void addConnectionsToLists(String jsonString) {
}
private void configureConnectionName() {
+ if (mNotConnectedAccounts.isEmpty()) {
+ return;
+ }
+
PublicizeConnection connection = mNotConnectedAccounts.get(0);
if (connection != null) {
mConnectionName = connection.getLabel();
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java
index c3802f303970..613917010bc5 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java
@@ -41,7 +41,7 @@ public void onBindViewHolder(final ViewHolder holder, int position) {
final PublicizeConnection connection = mConnectionItems.get(position);
holder.mProfileImageView
.setImageUrl(connection.getExternalProfilePictureUrl(), WPNetworkImageView.ImageType.PHOTO);
- holder.mNameTextView.setText(connection.getExternalDisplayName());
+ holder.mNameTextView.setText(getName(connection));
holder.mRadioButton.setChecked(position == mSelectedPosition);
if (!mAreAccountsConnected) {
@@ -82,4 +82,14 @@ public ViewHolder(View view) {
public interface OnPublicizeAccountChooserListener {
void onAccountSelected(int selectedIndex);
}
+
+ private String getName(PublicizeConnection connection) {
+ String name = connection.getExternalName();
+
+ if (name.isEmpty()) {
+ name = connection.getExternalDisplayName();
+ }
+
+ return name;
+ }
}
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeActions.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeActions.java
index 9d99549be28c..e46e5875645d 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeActions.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeActions.java
@@ -93,7 +93,7 @@ public void onResponse(JSONObject jsonObject) {
.post(new PublicizeEvents.ActionRequestChooseAccount(siteId, serviceId, jsonObject));
} else {
long keyringConnectionId = parseServiceKeyringId(serviceId, currentUserId, jsonObject);
- connectStepTwo(siteId, keyringConnectionId, serviceId);
+ connectStepTwo(siteId, keyringConnectionId, serviceId, "");
}
}
};
@@ -113,7 +113,8 @@ public void onErrorResponse(VolleyError volleyError) {
* step two in creating a publicize connection: now that we have the keyring connection id,
* create the actual connection
*/
- public static void connectStepTwo(final long siteId, long keyringConnectionId, final String serviceId) {
+ public static void connectStepTwo(final long siteId, long keyringConnectionId,
+ final String serviceId, final String externalUserId) {
RestRequest.Listener listener = new RestRequest.Listener() {
@Override
public void onResponse(JSONObject jsonObject) {
@@ -133,27 +134,40 @@ public void onErrorResponse(VolleyError volleyError) {
Map params = new HashMap<>();
params.put("keyring_connection_ID", Long.toString(keyringConnectionId));
+ if (!externalUserId.isEmpty()) {
+ params.put("external_user_ID", externalUserId);
+ }
String path = String.format(Locale.ROOT, "/sites/%d/publicize-connections/new", siteId);
WordPress.getRestClientUtilsV1_1().post(path, params, null, listener, errorListener);
}
private static boolean shouldShowChooserDialog(long siteId, String serviceId, JSONObject jsonObject) {
JSONArray jsonConnectionList = jsonObject.optJSONArray("connections");
+
if (jsonConnectionList == null || jsonConnectionList.length() <= 1) {
return false;
}
int totalAccounts = 0;
+ int totalExternalAccounts = 0;
try {
for (int i = 0; i < jsonConnectionList.length(); i++) {
JSONObject connectionObject = jsonConnectionList.getJSONObject(i);
PublicizeConnection publicizeConnection = PublicizeConnection.fromJson(connectionObject);
if (publicizeConnection.getService().equals(serviceId) && !publicizeConnection.isInSite(siteId)) {
totalAccounts++;
+ JSONArray externalJsonArray = connectionObject.getJSONArray("additional_external_users");
+ for (int j = 0; j < externalJsonArray.length(); j++) {
+ totalExternalAccounts++;
+ }
}
}
- return totalAccounts > 0;
+ if (PublicizeTable.onlyExternalConnections(serviceId)) {
+ return totalExternalAccounts > 0;
+ } else {
+ return totalAccounts > 0 || totalExternalAccounts > 0;
+ }
} catch (JSONException e) {
return false;
}
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeConstants.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeConstants.java
index 23a5e1620afe..8382f3a029c5 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeConstants.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeConstants.java
@@ -6,6 +6,7 @@ public class PublicizeConstants {
public static final String ARG_CONNECTION_ARRAY_JSON = "connection_array_json";
public static final String GOOGLE_PLUS_ID = "google_plus";
+ public static final String FACEBOOK_ID = "facebook";
public enum ConnectAction {
CONNECT,
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java
index baa4aaa530d3..dd5d8484b703 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java
@@ -5,6 +5,7 @@
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -14,6 +15,7 @@
import org.wordpress.android.fluxc.model.SiteModel;
import org.wordpress.android.fluxc.store.AccountStore;
import org.wordpress.android.models.PublicizeService;
+import org.wordpress.android.ui.WPWebViewActivity;
import org.wordpress.android.ui.publicize.PublicizeConstants.ConnectAction;
import org.wordpress.android.ui.publicize.adapters.PublicizeConnectionAdapter;
import org.wordpress.android.util.ToastUtils;
@@ -22,6 +24,8 @@
public class PublicizeDetailFragment extends PublicizeBaseFragment
implements PublicizeConnectionAdapter.OnAdapterLoadedListener {
+ public static final String FACEBOOK_SHARING_CHANGE_BLOG_POST =
+ "https://en.blog.wordpress.com/2018/07/23/sharing-options-from-wordpress-com-to-facebook-are-changing/";
private SiteModel mSite;
private String mServiceId;
@@ -116,6 +120,22 @@ public void loadData() {
String description = String.format(getString(R.string.connection_service_description), mService.getLabel());
TextView txtDescription = (TextView) mServiceCardView.findViewById(R.id.text_description);
txtDescription.setText(description);
+
+ if (mService.getId().equals(PublicizeConstants.FACEBOOK_ID)) {
+ String noticeText = getString(R.string.connection_service_facebook_notice);
+ TextView txtNotice = (TextView) mServiceCardView.findViewById(R.id.text_description_notice);
+ txtNotice.setText(noticeText);
+ txtNotice.setVisibility(View.VISIBLE);
+
+ TextView learnMoreButton = (TextView) mServiceCardView.findViewById(R.id.learn_more_button);
+ learnMoreButton.setOnClickListener(new OnClickListener() {
+ @Override public void onClick(View v) {
+ WPWebViewActivity.openURL(getActivity(),
+ FACEBOOK_SHARING_CHANGE_BLOG_POST);
+ }
+ });
+ learnMoreButton.setVisibility(View.VISIBLE);
+ }
}
long currentUserId = mAccountStore.getAccount().getUserId();
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeEvents.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeEvents.java
index 847c82706dfb..d3b9b522dd80 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeEvents.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeEvents.java
@@ -42,11 +42,13 @@ public static class ActionAccountChosen {
private long mSiteId;
private int mKeychainId;
private String mService;
+ private String mExternalUserId;
- public ActionAccountChosen(long siteId, int keychainId, String service) {
+ public ActionAccountChosen(long siteId, int keychainId, String service, String externalUserId) {
mSiteId = siteId;
mKeychainId = keychainId;
mService = service;
+ mExternalUserId = externalUserId;
}
public long getSiteId() {
@@ -60,6 +62,10 @@ public int getKeychainId() {
public String getService() {
return mService;
}
+
+ public String getExternalUserId() {
+ return mExternalUserId;
+ }
}
public static class ActionRequestChooseAccount {
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java
index 28aa5ddd2afd..6298a6a2ede1 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java
@@ -323,7 +323,8 @@ public void onEventMainThread(PublicizeEvents.ActionAccountChosen event) {
return;
}
- PublicizeActions.connectStepTwo(event.getSiteId(), event.getKeychainId(), event.getService());
+ PublicizeActions.connectStepTwo(event.getSiteId(), event.getKeychainId(),
+ event.getService(), event.getExternalUserId());
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage(getString(R.string.connecting_account));
mProgressDialog.show();
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeServiceAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeServiceAdapter.java
index 072ab709702f..472497d24e23 100644
--- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeServiceAdapter.java
+++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeServiceAdapter.java
@@ -25,24 +25,20 @@
import java.util.Comparator;
public class PublicizeServiceAdapter extends RecyclerView.Adapter {
- public interface OnAdapterLoadedListener {
- void onAdapterLoaded(boolean isEmpty);
- }
-
- public interface OnServiceClickListener {
- void onServiceClicked(PublicizeService service);
- }
-
private final PublicizeServiceList mServices = new PublicizeServiceList();
private final PublicizeConnectionList mConnections = new PublicizeConnectionList();
-
private final long mSiteId;
private final int mBlavatarSz;
private final ColorFilter mGrayScaleFilter;
private final long mCurrentUserId;
-
private OnAdapterLoadedListener mAdapterLoadedListener;
private OnServiceClickListener mServiceClickListener;
+ private boolean mShouldHideGPlus;
+
+ /*
+ * AsyncTask to load services
+ */
+ private boolean mIsTaskRunning = false;
public PublicizeServiceAdapter(Context context, long siteId, long currentUserId) {
super();
@@ -50,6 +46,7 @@ public PublicizeServiceAdapter(Context context, long siteId, long currentUserId)
mSiteId = siteId;
mBlavatarSz = context.getResources().getDimensionPixelSize(R.dimen.blavatar_sz_small);
mCurrentUserId = currentUserId;
+ mShouldHideGPlus = true;
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
@@ -138,6 +135,20 @@ public void onClick(View v) {
});
}
+ private boolean isHiddenService(PublicizeService service) {
+ boolean shouldHideGooglePlus = service.getId().equals(PublicizeConstants.GOOGLE_PLUS_ID) && mShouldHideGPlus;
+
+ return shouldHideGooglePlus;
+ }
+
+ public interface OnAdapterLoadedListener {
+ void onAdapterLoaded(boolean isEmpty);
+ }
+
+ public interface OnServiceClickListener {
+ void onServiceClicked(PublicizeService service);
+ }
+
class SharingViewHolder extends RecyclerView.ViewHolder {
private final TextView mTxtService;
private final TextView mTxtUser;
@@ -153,11 +164,6 @@ class SharingViewHolder extends RecyclerView.ViewHolder {
}
}
- /*
- * AsyncTask to load services
- */
- private boolean mIsTaskRunning = false;
-
private class LoadServicesTask extends AsyncTask {
private final PublicizeServiceList mTmpServices = new PublicizeServiceList();
private final PublicizeConnectionList mTmpConnections = new PublicizeConnectionList();
@@ -174,21 +180,17 @@ protected void onCancelled() {
@Override
protected Boolean doInBackground(Void... params) {
- // G+ no longers supports authentication via a WebView, so we hide it here unless the
- // user already has a connection
- boolean hideGPlus = true;
-
PublicizeConnectionList connections = PublicizeTable.getConnectionsForSite(mSiteId);
for (PublicizeConnection connection : connections) {
if (connection.getService().equals(PublicizeConstants.GOOGLE_PLUS_ID)) {
- hideGPlus = false;
+ mShouldHideGPlus = false;
}
mTmpConnections.add(connection);
}
PublicizeServiceList services = PublicizeTable.getServiceList();
for (PublicizeService service : services) {
- if (!service.getId().equals(PublicizeConstants.GOOGLE_PLUS_ID) || !hideGPlus) {
+ if (!isHiddenService(service)) {
mTmpServices.add(service);
}
}
diff --git a/WordPress/src/main/res/layout/publicize_detail_fragment.xml b/WordPress/src/main/res/layout/publicize_detail_fragment.xml
index 09c031cd744f..851e573523b3 100644
--- a/WordPress/src/main/res/layout/publicize_detail_fragment.xml
+++ b/WordPress/src/main/res/layout/publicize_detail_fragment.xml
@@ -98,6 +98,39 @@
android:layout_marginEnd="@dimen/margin_extra_large"
android:layout_marginStart="@dimen/margin_extra_large"/>
+
+
+
+
Connected accounts
Publicize to %s
Connect to automatically share your blog posts to %s.
+ As of August 1, 2018, Facebook no longer allows direct sharing of posts to Facebook Profiles. Connections to Facebook Pages remain unchanged.
Connect
Disconnect
Reconnect