Skip to content

Commit

Permalink
Merge pull request #20058 from wordpress-mobile/merge/24.1-rc-3-to-trunk
Browse files Browse the repository at this point in the history
Merge 24.1-rc-3 to trunk
  • Loading branch information
oguzkocer authored Jan 26, 2024
2 parents 9796d17 + 8048b80 commit f8a6a7c
Show file tree
Hide file tree
Showing 69 changed files with 133 additions and 445 deletions.
5 changes: 5 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
24.1
-----
* [**] Disabled the ability of creating new Story posts. [#20014]
* [**] Disable Story block [https://github.com/wordpress-mobile/WordPress-Android/pull/20005]

24.0.2
-----
* [**] Fix Aztec editor crash when losing or gaining network connectivity [https://github.com/wordpress-mobile/WordPress-Android/pull/20053]

24.0.1
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class UserFlagsProviderHelper @Inject constructor(
DeletablePrefKey.RECENTLY_PICKED_SITE_IDS.name,
UndeletablePrefKey.THEME_IMAGE_SIZE_WIDTH.name,
UndeletablePrefKey.BOOKMARKS_SAVED_LOCALLY_DIALOG_SHOWN.name,
UndeletablePrefKey.IMAGE_OPTIMIZE_PROMO_REQUIRED.name,
UndeletablePrefKey.SWIPE_TO_NAVIGATE_NOTIFICATIONS.name,
UndeletablePrefKey.SWIPE_TO_NAVIGATE_READER.name,
UndeletablePrefKey.SHOULD_SHOW_STORIES_INTRO.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,24 +508,14 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
case RequestCodes.PICTURE_LIBRARY:
case RequestCodes.VIDEO_LIBRARY:
case RequestCodes.AUDIO_LIBRARY:
handlePickerResult(data, resultCode);
break;
case RequestCodes.FILE_LIBRARY:
if (resultCode == Activity.RESULT_OK && data != null) {
if (WPMediaUtils.shouldAdvertiseImageOptimization(this)) {
WPMediaUtils.advertiseImageOptimization(this, () -> handlePickerResult(data, resultCode));
} else {
handlePickerResult(data, resultCode);
}
handlePickerResult(data, resultCode);
}
break;
case RequestCodes.TAKE_PHOTO:
if (resultCode == Activity.RESULT_OK) {
if (WPMediaUtils.shouldAdvertiseImageOptimization(this)) {
WPMediaUtils.advertiseImageOptimization(this, this::addLastTakenPicture);
} else {
addLastTakenPicture();
}
addLastTakenPicture();
}
break;
case RequestCodes.TAKE_VIDEO:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.wordpress.android.editor.EditorMediaUtils;
import org.wordpress.android.editor.EditorThemeUpdateListener;
import org.wordpress.android.editor.ExceptionLogger;
import org.wordpress.android.editor.gutenberg.GutenbergNetworkConnectionListener;
import org.wordpress.android.editor.savedinstance.SavedInstanceDatabase;
import org.wordpress.android.editor.gutenberg.DialogVisibility;
import org.wordpress.android.editor.gutenberg.GutenbergEditorFragment;
Expand Down Expand Up @@ -260,9 +261,6 @@
import static org.wordpress.android.imageeditor.preview.PreviewImageFragment.PREVIEW_IMAGE_REDUCED_SIZE_FACTOR;
import static org.wordpress.android.ui.history.HistoryDetailContainerFragment.KEY_REVISION;

import kotlin.Unit;
import kotlin.jvm.functions.Function0;

public class EditPostActivity extends LocaleAwareActivity implements
EditorFragmentActivity,
EditorImageSettingsListener,
Expand Down Expand Up @@ -1309,7 +1307,7 @@ public void onPhotoPickerHidden() {
@Override
public void onPhotoPickerMediaChosen(@NonNull final List<? extends Uri> uriList) {
mEditorPhotoPicker.hidePhotoPicker();
mEditorMedia.onPhotoPickerMediaChosen(uriList);
mEditorMedia.addNewMediaItemsToEditorAsync(uriList, false);
}

/*
Expand Down Expand Up @@ -2840,12 +2838,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
// handleMediaPickerResult -> addExistingMediaToEditorAndSave
break;
case RequestCodes.PHOTO_PICKER:
if (WPMediaUtils.shouldAdvertiseImageOptimization(this)) {
WPMediaUtils.advertiseImageOptimization(this, () -> handlePhotoPickerResult(data));
} else {
handlePhotoPickerResult(data);
}
break;
case RequestCodes.STOCK_MEDIA_PICKER_SINGLE_SELECT:
handlePhotoPickerResult(data);
break;
Expand All @@ -2859,18 +2851,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
break;
case RequestCodes.MEDIA_LIBRARY:
case RequestCodes.PICTURE_LIBRARY:
mEditorMedia.advertiseImageOptimisationAndAddMedia(WPMediaUtils.retrieveMediaUris(data));
break;
case RequestCodes.TAKE_PHOTO:
if (WPMediaUtils.shouldAdvertiseImageOptimization(this)) {
WPMediaUtils.advertiseImageOptimization(this, this::addLastTakenPicture);
} else {
addLastTakenPicture();
}
break;
case RequestCodes.VIDEO_LIBRARY:
mEditorMedia.addNewMediaItemsToEditorAsync(WPMediaUtils.retrieveMediaUris(data), false);
break;
case RequestCodes.TAKE_PHOTO:
addLastTakenPicture();
break;
case RequestCodes.TAKE_VIDEO:
Uri videoUri = data.getData();
mEditorMedia.addNewMediaToEditorAsync(videoUri, true);
Expand Down Expand Up @@ -3850,6 +3836,8 @@ public void onEventMainThread(UploadService.UploadMediaRetryEvent event) {

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(ConnectionChangeReceiver.ConnectionChangeEvent event) {
if (!(mEditorFragment instanceof GutenbergNetworkConnectionListener)) return;

((GutenbergEditorFragment) mEditorFragment).onConnectionStatusChange(event.isConnected());
}

Expand Down Expand Up @@ -3938,10 +3926,6 @@ public void syncPostObjectWithUiAndSaveIt(@Nullable OnPostUpdatedFromUIListener
updateAndSavePostAsync(listener);
}

@Override public void advertiseImageOptimization(@NonNull Function0<Unit> listener) {
WPMediaUtils.advertiseImageOptimization(this, listener::invoke);
}

@Override
public void onMediaModelsCreatedFromOptimizedUris(@NonNull Map<Uri, ? extends MediaModel> oldUriToMediaModels) {
// no op - we're not doing any special handling on MediaModels in EditPostActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import org.wordpress.android.ui.posts.editor.media.EditorMedia.AddMediaToPostUiS
import org.wordpress.android.ui.posts.editor.media.EditorMedia.AddMediaToPostUiState.AddingSingleMedia
import org.wordpress.android.ui.uploads.UploadService
import org.wordpress.android.ui.utils.UiString.UiStringRes
import org.wordpress.android.util.MediaUtilsWrapper
import org.wordpress.android.util.NetworkUtilsWrapper
import org.wordpress.android.util.StringUtils
import org.wordpress.android.util.ToastUtils.Duration
Expand All @@ -52,7 +51,6 @@ class EditorMedia @Inject constructor(
private val updateMediaModelUseCase: UpdateMediaModelUseCase,
private val getMediaModelUseCase: GetMediaModelUseCase,
private val dispatcher: Dispatcher,
private val mediaUtilsWrapper: MediaUtilsWrapper,
private val networkUtilsWrapper: NetworkUtilsWrapper,
private val addLocalMediaToPostUseCase: AddLocalMediaToPostUseCase,
private val addExistingMediaToPostUseCase: AddExistingMediaToPostUseCase,
Expand Down Expand Up @@ -95,20 +93,6 @@ class EditorMedia @Inject constructor(
_uiState.value = AddingMediaIdle
}

// region Adding new media to a post
fun advertiseImageOptimisationAndAddMedia(uriList: List<Uri>) {
if (mediaUtilsWrapper.shouldAdvertiseImageOptimization()) {
editorMediaListener.advertiseImageOptimization {
addNewMediaItemsToEditorAsync(
uriList,
false
)
}
} else {
addNewMediaItemsToEditorAsync(uriList, false)
}
}

fun addNewMediaToEditorAsync(mediaUri: Uri, freshlyTaken: Boolean) {
addNewMediaItemsToEditorAsync(listOf(mediaUri), freshlyTaken)
}
Expand Down Expand Up @@ -145,15 +129,6 @@ class EditorMedia @Inject constructor(
)
}
}

fun onPhotoPickerMediaChosen(uriList: List<Uri>) {
val onlyVideos = uriList.all { mediaUtilsWrapper.isVideo(it.toString()) }
if (onlyVideos) {
addNewMediaItemsToEditorAsync(uriList, false)
} else {
advertiseImageOptimisationAndAddMedia(uriList)
}
}
// endregion

// region Add existing media to a post
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.wordpress.android.util.helpers.MediaFile
interface EditorMediaListener {
fun appendMediaFiles(mediaFiles: Map<String, MediaFile>)
fun syncPostObjectWithUiAndSaveIt(listener: OnPostUpdatedFromUIListener? = null)
fun advertiseImageOptimization(listener: () -> Unit)
fun onMediaModelsCreatedFromOptimizedUris(oldUriToMediaFiles: Map<Uri, MediaModel>)
fun getImmutablePost(): PostImmutableModel
fun showVideoDurationLimitWarning(fileName: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,6 @@ public enum UndeletablePrefKey implements PrefKey {

BOOKMARKS_SAVED_LOCALLY_DIALOG_SHOWN,

// When we need to show the new image optimize promo dialog
IMAGE_OPTIMIZE_PROMO_REQUIRED,

// When we need to show the snackbar indicating how notifications can be navigated through
SWIPE_TO_NAVIGATE_NOTIFICATIONS,

Expand Down Expand Up @@ -603,14 +600,6 @@ public static void setBookmarksSavedLocallyDialogShown() {
setBoolean(UndeletablePrefKey.BOOKMARKS_SAVED_LOCALLY_DIALOG_SHOWN, false);
}

public static boolean isImageOptimizePromoRequired() {
return getBoolean(UndeletablePrefKey.IMAGE_OPTIMIZE_PROMO_REQUIRED, true);
}

public static void setImageOptimizePromoRequired(boolean required) {
setBoolean(UndeletablePrefKey.IMAGE_OPTIMIZE_PROMO_REQUIRED, required);
}

/**
* This method should only be used by specific client classes that need access to the persisted selected site
* instance due to the fact that the in-memory selected site instance might not be yet available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ import org.wordpress.android.util.ListUtils
import org.wordpress.android.util.MediaUtils
import org.wordpress.android.util.ToastUtils
import org.wordpress.android.util.ToastUtils.Duration.LONG
import org.wordpress.android.util.WPMediaUtils
import org.wordpress.android.util.WPPermissionUtils
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
import org.wordpress.android.util.analytics.AnalyticsUtilsWrapper
Expand Down Expand Up @@ -346,7 +345,7 @@ class StoryComposerActivity : ComposeLoopFrameActivity(),
it.hasExtra(MediaPickerConstants.EXTRA_MEDIA_URIS) -> {
data.getStringArrayExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)?.let {
val uriList: List<Uri> = convertStringArrayIntoUrisList(it)
storyEditorMedia.onPhotoPickerMediaChosen(uriList)
storyEditorMedia.addNewMediaItemsToEditorAsync(uriList, false)
}
}
it.hasExtra(MediaBrowserActivity.RESULT_IDS) -> {
Expand Down Expand Up @@ -422,7 +421,7 @@ class StoryComposerActivity : ComposeLoopFrameActivity(),
val uriList: List<Uri> = convertStringArrayIntoUrisList(it)

if (uriList.isNotEmpty()) {
storyEditorMedia.onPhotoPickerMediaChosen(uriList)
storyEditorMedia.addNewMediaItemsToEditorAsync(uriList, false)
}
}
}
Expand Down Expand Up @@ -488,10 +487,6 @@ class StoryComposerActivity : ComposeLoopFrameActivity(),
listener?.onPostUpdatedFromUI(null)
}

override fun advertiseImageOptimization(listener: () -> Unit) {
WPMediaUtils.advertiseImageOptimization(this) { listener.invoke() }
}

override fun onMediaModelsCreatedFromOptimizedUris(oldUriToMediaFiles: Map<Uri, MediaModel>) {
// no op - we're not doing any special handling while composing, only when saving in the UploadBridge
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import org.wordpress.android.ui.stories.media.StoryEditorMedia.AddMediaToStoryPo
import org.wordpress.android.ui.stories.media.StoryEditorMedia.AddMediaToStoryPostUiState.AddingMultipleMediaToStory
import org.wordpress.android.ui.stories.media.StoryEditorMedia.AddMediaToStoryPostUiState.AddingSingleMediaToStory
import org.wordpress.android.ui.utils.UiString.UiStringRes
import org.wordpress.android.util.MediaUtilsWrapper
import org.wordpress.android.viewmodel.Event
import javax.inject.Inject
import javax.inject.Named
import kotlin.coroutines.CoroutineContext

class StoryEditorMedia @Inject constructor(
private val mediaUtilsWrapper: MediaUtilsWrapper,
private val addLocalMediaToPostUseCase: AddLocalMediaToPostUseCase,
private val addExistingMediaToPostUseCase: AddExistingMediaToPostUseCase,
@Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher
Expand All @@ -55,20 +53,6 @@ class StoryEditorMedia @Inject constructor(
_uiState.value = AddingMediaToStoryIdle
}

// region Adding new media to a post
fun advertiseImageOptimisationAndAddMedia(uriList: List<Uri>) {
if (mediaUtilsWrapper.shouldAdvertiseImageOptimization()) {
editorMediaListener.advertiseImageOptimization {
addNewMediaItemsToEditorAsync(
uriList,
false
)
}
} else {
addNewMediaItemsToEditorAsync(uriList, false)
}
}

fun addNewMediaItemsToEditorAsync(uriList: List<Uri>, freshlyTaken: Boolean) {
launch {
_uiState.value = if (uriList.size > 1) {
Expand All @@ -90,15 +74,6 @@ class StoryEditorMedia @Inject constructor(
_uiState.value = AddingMediaToStoryIdle
}
}

fun onPhotoPickerMediaChosen(uriList: List<Uri>) {
val onlyVideos = uriList.all { mediaUtilsWrapper.isVideo(it.toString()) }
if (onlyVideos) {
addNewMediaItemsToEditorAsync(uriList, false)
} else {
advertiseImageOptimisationAndAddMedia(uriList)
}
}
// endregion

fun addExistingMediaToEditorAsync(source: AddExistingMediaSource, mediaIdList: List<Long>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ class StoryMediaSaveUploadBridge @Inject constructor(
listener?.onPostUpdatedFromUI(null)
}

override fun advertiseImageOptimization(listener: () -> Unit) {
// no op
}

override fun onMediaModelsCreatedFromOptimizedUris(oldUriToMediaFiles: Map<Uri, MediaModel>) {
// in order to support Story editing capabilities, we save a serialized version of the Story slides
// after their composedFrameFiles have been processed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class MediaUtilsWrapper @Inject constructor(private val appContext: Context) {
fun copyFileToAppStorage(imageUri: Uri, headers: Map<String, String>? = null): Uri? =
MediaUtils.downloadExternalMedia(appContext, imageUri, headers)

fun shouldAdvertiseImageOptimization(): Boolean =
WPMediaUtils.shouldAdvertiseImageOptimization(appContext)

fun getMimeType(uri: Uri): String? = appContext.contentResolver.getType(uri)

fun getVideoThumbnail(videoPath: String, headers: Map<String, String>): String? =
Expand Down
Loading

0 comments on commit f8a6a7c

Please sign in to comment.