Repository navigation
Add @-mention support #2163
Add @-mention support #2163
Changes from all commits
82b609f
2cbc40a
4b76cff
0d04a82
ce88a8a
a0a3ec5
fae7dc6
41dbe0a
8446c5b
db492a3
7532fb4
58d372e
c06e7b6
411492e
8eb2c1b
65383b8
167a947
c9cfbb0
3ec3a90
1a57491
e49d01b
08f760f
5c7bea0
166cca2
4d923da
94cca3d
f145c1b
27411aa
f3552d1
4a0547e
5980b5e
7b1cc91
b33bbb0
76e43cb
db05178
f6346f6
a0df91e
1f5ee28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,9 @@ | |
| }, | ||
| "customGradient": { | ||
| "type": "string" | ||
| }, | ||
| "contentPosition": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,9 @@ | |
| }, | ||
| "customGradient": { | ||
| "type": "string" | ||
| }, | ||
| "contentPosition": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package org.wordpress.mobile.WPAndroidGlue; | ||
|
|
||
| import androidx.core.util.Consumer; | ||
|
|
||
| public interface AddMentionUtil { | ||
| void getMention(Consumer<String> onResult); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| import android.view.ViewGroup; | ||
| import android.widget.FrameLayout.LayoutParams; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
| import androidx.core.util.Consumer; | ||
| import androidx.fragment.app.Fragment; | ||
|
|
||
|
|
@@ -90,13 +91,16 @@ public class WPAndroidGlueCode { | |
| private CountDownLatch mGetContentCountDownLatch; | ||
| private WeakReference<View> mLastFocusedView = null; | ||
| private RequestExecutor mRequestExecutor; | ||
| private AddMentionUtil mAddMentionUtil; | ||
|
|
||
| private static final String PROP_NAME_INITIAL_DATA = "initialData"; | ||
| private static final String PROP_NAME_INITIAL_TITLE = "initialTitle"; | ||
| private static final String PROP_NAME_INITIAL_HTML_MODE_ENABLED = "initialHtmlModeEnabled"; | ||
| private static final String PROP_NAME_POST_TYPE = "postType"; | ||
| private static final String PROP_NAME_LOCALE = "locale"; | ||
| private static final String PROP_NAME_TRANSLATIONS = "translations"; | ||
| public static final String PROP_NAME_CAPABILITIES = "capabilities"; | ||
| public static final String PROP_NAME_CAPABILITIES_MENTIONS = "mentions"; | ||
|
|
||
| private static OkHttpHeaderInterceptor sAddCookiesInterceptor = new OkHttpHeaderInterceptor(); | ||
| private static OkHttpClient sOkHttpClient = new OkHttpClient.Builder().addInterceptor(sAddCookiesInterceptor).build(); | ||
|
|
@@ -330,6 +334,10 @@ public void requestMediaEditor(MediaUploadCallback mediaUploadCallback, String m | |
| public void logUserEvent(GutenbergUserEvent event, ReadableMap eventProperties) { | ||
| mOnLogGutenbergUserEventListener.onGutenbergUserEvent(event, eventProperties.toHashMap()); | ||
| } | ||
|
|
||
| @Override public void onAddMention(Consumer<String> onSuccess) { | ||
| mAddMentionUtil.getMention(onSuccess); | ||
| } | ||
| }, mIsDarkMode); | ||
|
|
||
| return Arrays.asList( | ||
|
|
@@ -352,17 +360,43 @@ private ImagePipelineConfig getImagePipelineConfig(OkHttpClient client) { | |
| } | ||
|
|
||
| @Deprecated | ||
| public void onCreateView(Context initContext, boolean htmlModeEnabled, | ||
| Application application, boolean isDebug, boolean buildGutenbergFromSource, | ||
| boolean isNewPost, String localeString, Bundle translations, int colorBackground, boolean isDarkMode) { | ||
| onCreateView(initContext, htmlModeEnabled, application, isDebug, buildGutenbergFromSource, "post", isNewPost | ||
| , localeString, translations, colorBackground, isDarkMode); | ||
| } | ||
|
|
||
| public void onCreateView(Context initContext, boolean htmlModeEnabled, | ||
| Application application, boolean isDebug, boolean buildGutenbergFromSource, | ||
| String postType, boolean isNewPost, String localeString, Bundle translations, | ||
| int colorBackground, boolean isDarkMode) { | ||
| public void onCreateView(Context initContext, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't see any reason to keep this deprecated, overloaded onCreateView. Introduced 09367d3 but I'm not sure it was ever used for anything, maybe just added to be safe in that initial change I linked. But no real need to "refactor" and remove that in combination with this change if there's a small risk it breaks something that I'm just not imagining, could be removed in a future clean up/refactor PR, so up to you.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had the exact same thought. I was very tempted to just remove it, but ended up deciding not to lump that change in with these changes. |
||
| boolean htmlModeEnabled, | ||
| Application application, | ||
| boolean isDebug, | ||
| boolean buildGutenbergFromSource, | ||
| boolean isNewPost, | ||
| String localeString, | ||
| Bundle translations, | ||
| int colorBackground, | ||
| boolean isDarkMode) { | ||
| onCreateView( | ||
| initContext, | ||
| htmlModeEnabled, | ||
| application, | ||
| isDebug, | ||
| buildGutenbergFromSource, | ||
| "post", | ||
| isNewPost, | ||
| localeString, | ||
| translations, | ||
| colorBackground, | ||
| isDarkMode, | ||
| null); | ||
| } | ||
|
|
||
| public void onCreateView(Context initContext, | ||
| boolean htmlModeEnabled, | ||
| Application application, | ||
| boolean isDebug, | ||
| boolean buildGutenbergFromSource, | ||
| String postType, | ||
| boolean isNewPost, | ||
| String localeString, | ||
| Bundle translations, | ||
| int colorBackground, | ||
| boolean isDarkMode, | ||
| @Nullable Boolean isSiteUsingWpComRestApi) { | ||
| mIsDarkMode = isDarkMode; | ||
| mReactRootView = new ReactRootView(new MutableContextWrapper(initContext)); | ||
| mReactRootView.setBackgroundColor(colorBackground); | ||
|
|
@@ -393,6 +427,12 @@ public void onCreateView(Context initContext, boolean htmlModeEnabled, | |
| initialProps.putString(PROP_NAME_LOCALE, localeString); | ||
| initialProps.putBundle(PROP_NAME_TRANSLATIONS, translations); | ||
|
|
||
| Bundle capabilities = new Bundle(); | ||
| if (isSiteUsingWpComRestApi != null) { | ||
| capabilities.putBoolean(PROP_NAME_CAPABILITIES_MENTIONS, isSiteUsingWpComRestApi); | ||
| } | ||
| initialProps.putBundle(PROP_NAME_CAPABILITIES, capabilities); | ||
|
|
||
| // The string here (e.g. "MyReactNativeApp") has to match | ||
| // the string in AppRegistry.registerComponent() in index.js | ||
| mReactRootView.setAppProperties(initialProps); | ||
|
|
@@ -407,6 +447,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener | |
| OnImageFullscreenPreviewListener onImageFullscreenPreviewListener, | ||
| OnMediaEditorListener onMediaEditorListener, | ||
| OnLogGutenbergUserEventListener onLogGutenbergUserEventListener, | ||
| AddMentionUtil addMentionUtil, | ||
| boolean isDarkMode) { | ||
|
|
||
| MutableContextWrapper contextWrapper = (MutableContextWrapper) mReactRootView.getContext(); | ||
|
|
@@ -420,6 +461,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener | |
| mOnImageFullscreenPreviewListener = onImageFullscreenPreviewListener; | ||
| mOnMediaEditorListener = onMediaEditorListener; | ||
| mOnLogGutenbergUserEventListener = onLogGutenbergUserEventListener; | ||
| mAddMentionUtil = addMentionUtil; | ||
|
|
||
| sAddCookiesInterceptor.setOnAuthHeaderRequestedListener(onAuthHeaderRequestedListener); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be in favor of "sergio" here for balance, but I guess the name "matt" get's special treatment around here ;-P