Skip to content

Commit

Permalink
Merge pull request #13590 from wordpress-mobile/merge/release-16.3-in…
Browse files Browse the repository at this point in the history
…to-develop

Merge/release 16.3 into develop
  • Loading branch information
loremattei authored Dec 14, 2020
2 parents 536cf0c + e3b3138 commit 146a442
Show file tree
Hide file tree
Showing 92 changed files with 3,001 additions and 2,386 deletions.
8 changes: 4 additions & 4 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ android {
if (project.hasProperty("versionName")) {
versionName project.property("versionName")
} else {
versionName "alpha-261"
versionName "alpha-262"
}
versionCode 965
versionCode 967
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion

Expand Down Expand Up @@ -98,9 +98,9 @@ android {
dimension "buildType"
// Only set the release version if one isn't provided
if (!project.hasProperty("versionName")) {
versionName "16.3-rc-2"
versionName "16.3"
}
versionCode 964
versionCode 968
buildConfigField "boolean", "ME_ACTIVITY_AVAILABLE", "false"
buildConfigField "boolean", "TENOR_AVAILABLE", "false"
buildConfigField "long", "REMOTE_CONFIG_FETCH_INTERVAL", "3600"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,7 @@ private void doMediaIdsSelected(ArrayList<Long> mediaIds, @NonNull PhotoPickerMe
if (mediaIds != null && mediaIds.size() > 0) {
if (mBrowserType == MediaBrowserType.WP_STORIES_MEDIA_PICKER) {
// TODO WPSTORIES add TRACKS (see how it's tracked below? maybe do along the same lines)
Intent data = new Intent()
.putExtra(MediaBrowserActivity.RESULT_IDS, ListUtils.toLongArray(mediaIds))
.putExtra(ARG_BROWSER_TYPE, mBrowserType)
.putExtra(MediaPickerConstants.EXTRA_MEDIA_SOURCE, source.name());
setResult(RESULT_OK, data);
finish();
getPickerFragment().mediaIdsSelectedFromWPMediaPicker(mediaIds);
} else {
// if user chose a featured image, track image picked event
if (mBrowserType == MediaBrowserType.FEATURED_IMAGE_PICKER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ class PhotoPickerFragment : Fragment() {
viewModel.urisSelectedFromSystemPicker(uris.map { UriWrapper(it) })
}

fun mediaIdsSelectedFromWPMediaPicker(mediaIds: List<Long>) {
viewModel.mediaIdsSelectedFromWPMediaPicker(mediaIds)
}

companion object {
private const val KEY_LAST_TAPPED_ICON = "last_tapped_icon"
private const val KEY_SELECTED_POSITIONS = "selected_positions"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wordpress.android.ui.photopicker

import android.Manifest.permission
import android.net.Uri
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import kotlinx.coroutines.CoroutineDispatcher
Expand Down Expand Up @@ -41,6 +42,7 @@ import org.wordpress.android.ui.photopicker.PhotoPickerViewModel.BottomBarUiMode
import org.wordpress.android.ui.photopicker.PhotoPickerViewModel.BottomBarUiModel.BottomBar.NONE
import org.wordpress.android.ui.photopicker.PhotoPickerViewModel.PopupMenuUiModel.PopupMenuItem
import org.wordpress.android.ui.posts.editor.media.CopyMediaToAppStorageUseCase
import org.wordpress.android.ui.posts.editor.media.GetMediaModelUseCase
import org.wordpress.android.ui.utils.UiString
import org.wordpress.android.ui.utils.UiString.UiStringRes
import org.wordpress.android.ui.utils.UiString.UiStringText
Expand Down Expand Up @@ -75,7 +77,8 @@ class PhotoPickerViewModel @Inject constructor(
private val permissionsHandler: PermissionsHandler,
private val tenorFeatureConfig: TenorFeatureConfig,
private val resourceProvider: ResourceProvider,
private val copyMediaToAppStorageUseCase: CopyMediaToAppStorageUseCase
private val copyMediaToAppStorageUseCase: CopyMediaToAppStorageUseCase,
private val getMediaModelUseCase: GetMediaModelUseCase
) : ScopedViewModel(mainDispatcher) {
private val _navigateToPreview = MutableLiveData<Event<UriWrapper>>()
private val _onInsert = MutableLiveData<Event<List<UriWrapper>>>()
Expand Down Expand Up @@ -478,6 +481,18 @@ class PhotoPickerViewModel @Inject constructor(
}

fun urisSelectedFromSystemPicker(uris: List<UriWrapper>) {
copySelectedUrisLocally(uris)
}

fun mediaIdsSelectedFromWPMediaPicker(mediaIds: List<Long>) {
launch {
val mediaModels = getMediaModelUseCase
.loadMediaByRemoteId(requireNotNull(site), mediaIds)
copySelectedUrisLocally(mediaModels.map { UriWrapper(Uri.parse(it.url)) })
}
}

fun copySelectedUrisLocally(uris: List<UriWrapper>) {
launch {
_showProgressDialog.value = ProgressDialogUiModel.Visible(R.string.uploading_title) {
_showProgressDialog.postValue(ProgressDialogUiModel.Hidden)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,12 +1322,34 @@ private boolean handleBackPressed() {
} else if (mEditorPhotoPicker.isPhotoPickerShowing()) {
mEditorPhotoPicker.hidePhotoPicker();
} else {
savePostAndOptionallyFinish(true, false);
performWhenNoStoriesBeingSaved(new DoWhenNoStoriesBeingSavedCallback() {
@Override public void doWhenNoStoriesBeingSaved() {
savePostAndOptionallyFinish(true, false);
}
});
}

return true;
}

interface DoWhenNoStoriesBeingSavedCallback {
void doWhenNoStoriesBeingSaved();
}

private void performWhenNoStoriesBeingSaved(DoWhenNoStoriesBeingSavedCallback callback) {
if (mWPStoriesFeatureConfig.isEnabled()) {
if (mStoriesEventListener.getStoriesSavingInProgress().isEmpty()) {
callback.doWhenNoStoriesBeingSaved();
} else {
// Oops! A story is still being saved, let's wait
ToastUtils.showToast(EditPostActivity.this,
getString(R.string.toast_edit_story_update_in_progress_title));
}
} else {
callback.doWhenNoStoriesBeingSaved();
}
}

private RemotePreviewLogicHelper.RemotePreviewHelperFunctions getEditPostActivityStrategyFunctions() {
return new RemotePreviewLogicHelper.RemotePreviewHelperFunctions() {
@Override
Expand Down Expand Up @@ -1499,7 +1521,7 @@ private boolean performSecondaryAction() {
case PUBLISH_NOW:
mAnalyticsTrackerWrapper.track(Stat.EDITOR_POST_PUBLISH_TAPPED);
mPublishPostImmediatelyUseCase.updatePostToPublishImmediately(mEditPostRepository, mIsNewPost);
showPrepublishingNudgeBottomSheet();
checkNoStorySaveOperationInProgressAndShowPrepublishingNudgeBottomSheet();
return true;
case NONE:
throw new IllegalStateException("Switch in `secondaryAction` shouldn't go through the NONE case");
Expand Down Expand Up @@ -1611,12 +1633,12 @@ private void performPrimaryAction() {
switch (getPrimaryAction()) {
case PUBLISH_NOW:
mAnalyticsTrackerWrapper.track(Stat.EDITOR_POST_PUBLISH_TAPPED);
showPrepublishingNudgeBottomSheet();
checkNoStorySaveOperationInProgressAndShowPrepublishingNudgeBottomSheet();
return;
case UPDATE:
case SCHEDULE:
case SUBMIT_FOR_REVIEW:
showPrepublishingNudgeBottomSheet();
checkNoStorySaveOperationInProgressAndShowPrepublishingNudgeBottomSheet();
return;
case SAVE:
uploadPost(false);
Expand Down Expand Up @@ -2014,6 +2036,14 @@ private void setupPrepublishingBottomSheetRunnable() {
};
}

private void checkNoStorySaveOperationInProgressAndShowPrepublishingNudgeBottomSheet() {
performWhenNoStoriesBeingSaved(new DoWhenNoStoriesBeingSavedCallback() {
@Override public void doWhenNoStoriesBeingSaved() {
showPrepublishingNudgeBottomSheet();
}
});
}

private void showPrepublishingNudgeBottomSheet() {
mViewPager.setCurrentItem(PAGE_CONTENT);
ActivityUtils.hideKeyboard(this);
Expand Down Expand Up @@ -2306,7 +2336,7 @@ private GutenbergPropsBuilder getGutenbergPropsBuilder() {
boolean unsupportedBlockEditorSwitch = !mIsJetpackSsoEnabled && "gutenberg".equals(mSite.getWebEditor());

return new GutenbergPropsBuilder(
mWPStoriesFeatureConfig.isEnabled(),
mWPStoriesFeatureConfig.isEnabled() && SiteUtils.supportsStoriesFeature(mSite),
enableMentions,
isUnsupportedBlockEditorEnabled,
unsupportedBlockEditorSwitch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import com.wordpress.stories.compose.frame.StorySaveEvents.FrameSaveCompleted
import com.wordpress.stories.compose.frame.StorySaveEvents.FrameSaveFailed
import com.wordpress.stories.compose.frame.StorySaveEvents.FrameSaveProgress
import com.wordpress.stories.compose.frame.StorySaveEvents.FrameSaveStart
import com.wordpress.stories.compose.frame.StorySaveEvents.StorySaveProcessStart
import com.wordpress.stories.compose.frame.StorySaveEvents.StorySaveResult
import com.wordpress.stories.compose.story.StoryIndex
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.wordpress.android.R
Expand Down Expand Up @@ -58,6 +60,8 @@ class StoriesEventListener @Inject constructor(
private lateinit var site: SiteModel
private lateinit var editPostRepository: EditPostRepository
private var storySaveMediaListener: StorySaveMediaListener? = null
var storiesSavingInProgress = HashSet<StoryIndex>()
private set

@OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
private fun onCreate() {
Expand Down Expand Up @@ -168,6 +172,7 @@ class StoriesEventListener @Inject constructor(

@Subscribe(threadMode = ThreadMode.MAIN)
fun onStorySaveProcessFinished(event: StorySaveResult) {
storiesSavingInProgress.remove(event.storyIndex)
if (!lifecycle.currentState.isAtLeast(CREATED)) {
return
}
Expand All @@ -179,6 +184,11 @@ class StoriesEventListener @Inject constructor(
}
}

@Subscribe(threadMode = ThreadMode.MAIN)
fun onStorySaveStart(event: StorySaveProcessStart) {
storiesSavingInProgress.add(event.storyIndex)
}

// Editor load / cancel events
fun onRequestMediaFilesEditorLoad(
activity: Activity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ class SaveStoryGutenbergBlockUseCase @Inject constructor(
while (storyBlockStartIndex > -1 && storyBlockStartIndex < content.length) {
storyBlockStartIndex = content.indexOf(HEADING_START, storyBlockStartIndex)
if (storyBlockStartIndex > -1) {
val storyBlockEndIndex = content.indexOf(HEADING_END, storyBlockStartIndex)
val jsonString: String = content.substring(
storyBlockStartIndex + HEADING_START.length,
content.indexOf(HEADING_END))
storyBlockEndIndex)
content = listener.doWithMediaFilesJson(content, jsonString)
storyBlockStartIndex += HEADING_START.length
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class StoriesIntroViewModel @Inject constructor(
}

companion object {
private const val STORY_URL_1 = "https://wpstories.wordpress.com/2020/10/12/patagonia-2/"
private const val STORY_URL_2 = "https://wpstories.wordpress.com/2020/10/12/hiking-in-the-southwest/"
private const val STORY_URL_1 = "https://wpstories.wordpress.com/2020/12/02/story-demo-01/"
private const val STORY_URL_2 = "https://wpstories.wordpress.com/2020/12/02/story-demo-02/"
private const val STORY_FULLSCREEN_URL_PARAMS = "?wp-story-load-in-fullscreen=true&wp-story-play-on-load=true"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified WordPress/src/main/res/drawable-hdpi/stories_intro_cover_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified WordPress/src/main/res/drawable-xhdpi/stories_intro_cover_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified WordPress/src/main/res/drawable-xhdpi/stories_intro_cover_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 146a442

Please sign in to comment.