diff --git a/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt b/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt index fb11f809225b..839474dc2f14 100644 --- a/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/localcontentmigration/UserFlagsProviderHelper.kt @@ -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, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index 520773af12f0..d434f5024f09 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -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: diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index a6884db857a2..50b27a4a7d78 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -260,9 +260,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, @@ -1309,7 +1306,7 @@ public void onPhotoPickerHidden() { @Override public void onPhotoPickerMediaChosen(@NonNull final List uriList) { mEditorPhotoPicker.hidePhotoPicker(); - mEditorMedia.onPhotoPickerMediaChosen(uriList); + mEditorMedia.addNewMediaItemsToEditorAsync(uriList, false); } /* @@ -2842,12 +2839,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; @@ -2861,18 +2852,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); @@ -3940,10 +3925,6 @@ public void syncPostObjectWithUiAndSaveIt(@Nullable OnPostUpdatedFromUIListener updateAndSavePostAsync(listener); } - @Override public void advertiseImageOptimization(@NonNull Function0 listener) { - WPMediaUtils.advertiseImageOptimization(this, listener::invoke); - } - @Override public void onMediaModelsCreatedFromOptimizedUris(@NonNull Map oldUriToMediaModels) { // no op - we're not doing any special handling on MediaModels in EditPostActivity diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt index 0edca25c46ee..658ad80e7bac 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMedia.kt @@ -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 @@ -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, @@ -95,20 +93,6 @@ class EditorMedia @Inject constructor( _uiState.value = AddingMediaIdle } - // region Adding new media to a post - fun advertiseImageOptimisationAndAddMedia(uriList: List) { - if (mediaUtilsWrapper.shouldAdvertiseImageOptimization()) { - editorMediaListener.advertiseImageOptimization { - addNewMediaItemsToEditorAsync( - uriList, - false - ) - } - } else { - addNewMediaItemsToEditorAsync(uriList, false) - } - } - fun addNewMediaToEditorAsync(mediaUri: Uri, freshlyTaken: Boolean) { addNewMediaItemsToEditorAsync(listOf(mediaUri), freshlyTaken) } @@ -145,15 +129,6 @@ class EditorMedia @Inject constructor( ) } } - - fun onPhotoPickerMediaChosen(uriList: List) { - val onlyVideos = uriList.all { mediaUtilsWrapper.isVideo(it.toString()) } - if (onlyVideos) { - addNewMediaItemsToEditorAsync(uriList, false) - } else { - advertiseImageOptimisationAndAddMedia(uriList) - } - } // endregion // region Add existing media to a post diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMediaListener.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMediaListener.kt index 4f40d9affda0..b597d9c3ea18 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMediaListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/media/EditorMediaListener.kt @@ -9,7 +9,6 @@ import org.wordpress.android.util.helpers.MediaFile interface EditorMediaListener { fun appendMediaFiles(mediaFiles: Map) fun syncPostObjectWithUiAndSaveIt(listener: OnPostUpdatedFromUIListener? = null) - fun advertiseImageOptimization(listener: () -> Unit) fun onMediaModelsCreatedFromOptimizedUris(oldUriToMediaFiles: Map) fun getImmutablePost(): PostImmutableModel fun showVideoDurationLimitWarning(fileName: String) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java index bfb0ae37d01a..eb9e37a9e514 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java @@ -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, @@ -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. diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stories/StoryComposerActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stories/StoryComposerActivity.kt index 4f6c7cdfa70e..50055bc6f87a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stories/StoryComposerActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stories/StoryComposerActivity.kt @@ -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 @@ -346,7 +345,7 @@ class StoryComposerActivity : ComposeLoopFrameActivity(), it.hasExtra(MediaPickerConstants.EXTRA_MEDIA_URIS) -> { data.getStringArrayExtra(MediaPickerConstants.EXTRA_MEDIA_URIS)?.let { val uriList: List = convertStringArrayIntoUrisList(it) - storyEditorMedia.onPhotoPickerMediaChosen(uriList) + storyEditorMedia.addNewMediaItemsToEditorAsync(uriList, false) } } it.hasExtra(MediaBrowserActivity.RESULT_IDS) -> { @@ -422,7 +421,7 @@ class StoryComposerActivity : ComposeLoopFrameActivity(), val uriList: List = convertStringArrayIntoUrisList(it) if (uriList.isNotEmpty()) { - storyEditorMedia.onPhotoPickerMediaChosen(uriList) + storyEditorMedia.addNewMediaItemsToEditorAsync(uriList, false) } } } @@ -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) { // no op - we're not doing any special handling while composing, only when saving in the UploadBridge } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryEditorMedia.kt b/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryEditorMedia.kt index 4a7dac9dd852..1a91710c5bc6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryEditorMedia.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryEditorMedia.kt @@ -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 @@ -55,20 +53,6 @@ class StoryEditorMedia @Inject constructor( _uiState.value = AddingMediaToStoryIdle } - // region Adding new media to a post - fun advertiseImageOptimisationAndAddMedia(uriList: List) { - if (mediaUtilsWrapper.shouldAdvertiseImageOptimization()) { - editorMediaListener.advertiseImageOptimization { - addNewMediaItemsToEditorAsync( - uriList, - false - ) - } - } else { - addNewMediaItemsToEditorAsync(uriList, false) - } - } - fun addNewMediaItemsToEditorAsync(uriList: List, freshlyTaken: Boolean) { launch { _uiState.value = if (uriList.size > 1) { @@ -90,15 +74,6 @@ class StoryEditorMedia @Inject constructor( _uiState.value = AddingMediaToStoryIdle } } - - fun onPhotoPickerMediaChosen(uriList: List) { - val onlyVideos = uriList.all { mediaUtilsWrapper.isVideo(it.toString()) } - if (onlyVideos) { - addNewMediaItemsToEditorAsync(uriList, false) - } else { - advertiseImageOptimisationAndAddMedia(uriList) - } - } // endregion fun addExistingMediaToEditorAsync(source: AddExistingMediaSource, mediaIdList: List) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryMediaSaveUploadBridge.kt b/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryMediaSaveUploadBridge.kt index cc84f6fad6d1..77c7c52fb953 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryMediaSaveUploadBridge.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stories/media/StoryMediaSaveUploadBridge.kt @@ -133,10 +133,6 @@ class StoryMediaSaveUploadBridge @Inject constructor( listener?.onPostUpdatedFromUI(null) } - override fun advertiseImageOptimization(listener: () -> Unit) { - // no op - } - override fun onMediaModelsCreatedFromOptimizedUris(oldUriToMediaFiles: Map) { // in order to support Story editing capabilities, we save a serialized version of the Story slides // after their composedFrameFiles have been processed. diff --git a/WordPress/src/main/java/org/wordpress/android/util/MediaUtilsWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/MediaUtilsWrapper.kt index 3ec86333c275..b906fbd95702 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/MediaUtilsWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/MediaUtilsWrapper.kt @@ -41,9 +41,6 @@ class MediaUtilsWrapper @Inject constructor(private val appContext: Context) { fun copyFileToAppStorage(imageUri: Uri, headers: Map? = 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? = diff --git a/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java b/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java index ef971cb663ec..f8eb64f1f5d7 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java @@ -6,10 +6,8 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.content.pm.PackageManager; import android.media.MediaScannerConnection; import android.net.Uri; -import android.os.Build; import android.os.Environment; import android.provider.MediaStore; import android.view.ViewConfiguration; @@ -19,7 +17,6 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.AlertDialog; -import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import com.google.android.material.dialog.MaterialAlertDialogBuilder; @@ -46,7 +43,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; public class WPMediaUtils { @@ -104,75 +100,6 @@ public static boolean isVideoOptimizationEnabled() { return AppPrefs.isVideoOptimize(); } - /** - * Check if we should advertise image optimization feature for the current site. - *

- * The following condition need to be all true: - * 1) Image optimization is ON on the site. - * 2) Didn't already ask to keep or disable the feature. - * 3) The user has granted storage access to the app. - * This is because we don't want to ask so much things to users the first time they try to add a picture to the app. - * - * @param context The context - * @return true if we should advertise the feature, false otherwise. - */ - public static boolean shouldAdvertiseImageOptimization(final Context context) { - boolean isPromoRequired = AppPrefs.isImageOptimizePromoRequired(); - if (!isPromoRequired) { - return false; - } - - // Check we can access storage before asking for optimizing image - boolean hasStoreAccess = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R - || ContextCompat.checkSelfPermission(context, - android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; - if (!hasStoreAccess) { - return false; - } - - // Check whether image optimization is enabled for the site - return AppPrefs.isImageOptimize(); - } - - public interface OnAdvertiseImageOptimizationListener { - void done(); - } - - public static void advertiseImageOptimization(final Context context, - final OnAdvertiseImageOptimizationListener listener) { - DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - String propertyValue = (which == DialogInterface.BUTTON_POSITIVE) ? "on" : "off"; - AnalyticsTracker.track(AnalyticsTracker.Stat.APP_SETTINGS_OPTIMIZE_IMAGES_POPUP_TAPPED, - Collections.singletonMap("option", propertyValue)); - - if (which == DialogInterface.BUTTON_NEGATIVE && AppPrefs.isImageOptimize()) { - AppPrefs.setImageOptimize(false); - } - - listener.done(); - } - }; - - DialogInterface.OnCancelListener onCancelListener = new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - listener.done(); - } - }; - - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context); - builder.setTitle(R.string.image_optimization_popup_title); - builder.setMessage(R.string.image_optimization_popup_desc); - builder.setPositiveButton(R.string.leave_on, onClickListener); - builder.setNegativeButton(R.string.turn_off, onClickListener); - builder.setOnCancelListener(onCancelListener); - builder.show(); - // Do not ask again - AppPrefs.setImageOptimizePromoRequired(false); - } - /** * Given a media error returns the error message to display on the UI. * diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index f7865454b8b2..32fe5037b220 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -2983,12 +2983,6 @@ Camera Microphone - - Yes, leave on - No, turn off - Keep optimizing images? - Image optimization shrinks images for faster uploading.\n\nThis option is enabled by default, but you can change it in the app settings at any time. - diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/editor/media/EditorMediaTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/editor/media/EditorMediaTest.kt index c081fceead0b..ac43eaf276c9 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/posts/editor/media/EditorMediaTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/editor/media/EditorMediaTest.kt @@ -1,6 +1,5 @@ package org.wordpress.android.ui.posts.editor.media -import android.net.Uri import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.UnconfinedTestDispatcher @@ -27,7 +26,6 @@ import org.wordpress.android.fluxc.store.MediaStore.FetchMediaListPayload import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.posts.editor.media.EditorMedia.AddMediaToPostUiState 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.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.analytics.AnalyticsUtilsWrapper @@ -36,38 +34,6 @@ import org.wordpress.android.viewmodel.helpers.ToastMessageHolder @ExperimentalCoroutinesApi class EditorMediaTest : BaseUnitTest() { - @Test - fun `advertiseImageOptimisationAndAddMedia shows dialog when shouldAdvertiseImageOptimization is true`() { - // Arrange - val editorMediaListener = mock() - val mediaUtilsWrapper = createMediaUtilsWrapper(shouldAdvertiseImageOptimization = true) - - // Act - createEditorMedia( - editorMediaListener = editorMediaListener, - mediaUtilsWrapper = mediaUtilsWrapper - ) - .advertiseImageOptimisationAndAddMedia(mock()) - // Assert - verify(editorMediaListener).advertiseImageOptimization(anyOrNull()) - } - - @Test - fun `advertiseImageOptimisationAndAddMedia does NOT show dialog when shouldAdvertiseImageOptimization is false`() { - // Arrange - val editorMediaListener = mock() - val mediaUtilsWrapper = createMediaUtilsWrapper(shouldAdvertiseImageOptimization = false) - - // Act - createEditorMedia( - editorMediaListener = editorMediaListener, - mediaUtilsWrapper = mediaUtilsWrapper - ) - .advertiseImageOptimisationAndAddMedia(mock()) - // Assert - verify(editorMediaListener, never()).advertiseImageOptimization(anyOrNull()) - } - @Test fun `addNewMediaItemsToEditorAsync emits AddingSingleMedia for a single uri`() = test { // Arrange @@ -142,45 +108,6 @@ class EditorMediaTest : BaseUnitTest() { ) } - @Test - fun `onPhotoPickerMediaChosen does NOT invoke shouldAdvertiseImageOptimization when only video files`() = - test { - // Arrange - val uris = listOf(VIDEO_URI, VIDEO_URI, VIDEO_URI, VIDEO_URI) - val editorMediaListener = mock() - - val mediaUtilsWrapper = createMediaUtilsWrapper() - - // Act - createEditorMedia( - mediaUtilsWrapper = mediaUtilsWrapper, - editorMediaListener = editorMediaListener - ) - .onPhotoPickerMediaChosen(uris) - // Assert - verify(editorMediaListener, never()).advertiseImageOptimization(anyOrNull()) - verify(mediaUtilsWrapper, never()).shouldAdvertiseImageOptimization() - } - - @Test - fun `onPhotoPickerMediaChosen invokes shouldAdvertiseImageOptimization when at least 1 image file`() = - test { - // Arrange - val uris = listOf(VIDEO_URI, VIDEO_URI, IMAGE_URI, VIDEO_URI) - val editorMediaListener = mock() - - val mediaUtilsWrapper = createMediaUtilsWrapper() - - // Act - createEditorMedia( - mediaUtilsWrapper = mediaUtilsWrapper, - editorMediaListener = editorMediaListener - ) - .onPhotoPickerMediaChosen(uris) - // Assert - verify(mediaUtilsWrapper).shouldAdvertiseImageOptimization() - } - @Test fun `addExistingMediaToEditorAsync passes mediaId to addExistingMediaToPostUseCase`() = test { @@ -332,8 +259,6 @@ class EditorMediaTest : BaseUnitTest() { } private companion object Fixtures { - private val VIDEO_URI = mock() - private val IMAGE_URI = mock() private const val MEDIA_MODEL_REMOTE_ID = 123L private const val MEDIA_MODEL_LOCAL_ID = 1 @@ -341,7 +266,6 @@ class EditorMediaTest : BaseUnitTest() { updateMediaModelUseCase: UpdateMediaModelUseCase = mock(), getMediaModelUseCase: GetMediaModelUseCase = createGetMediaModelUseCase(), dispatcher: Dispatcher = mock(), - mediaUtilsWrapper: MediaUtilsWrapper = createMediaUtilsWrapper(), networkUtilsWrapper: NetworkUtilsWrapper = mock(), addLocalMediaToPostUseCase: AddLocalMediaToPostUseCase = createAddLocalMediaToPostUseCase(), addExistingMediaToPostUseCase: AddExistingMediaToPostUseCase = mock(), @@ -358,7 +282,6 @@ class EditorMediaTest : BaseUnitTest() { updateMediaModelUseCase, getMediaModelUseCase, dispatcher, - mediaUtilsWrapper, networkUtilsWrapper, addLocalMediaToPostUseCase, addExistingMediaToPostUseCase, @@ -375,16 +298,6 @@ class EditorMediaTest : BaseUnitTest() { return editorMedia } - fun createMediaUtilsWrapper( - shouldAdvertiseImageOptimization: Boolean = false - ) = - mock { - on { shouldAdvertiseImageOptimization() } - .thenReturn(shouldAdvertiseImageOptimization) - on { isVideo(VIDEO_URI.toString()) }.thenReturn(true) - on { isVideo(IMAGE_URI.toString()) }.thenReturn(false) - } - fun createAddLocalMediaToPostUseCase(resultForAddNewMediaToEditorAsync: Boolean = true) = mock { onBlocking { diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stories/usecase/StoryEditorMediaTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stories/usecase/StoryEditorMediaTest.kt index 2bc45b71e985..90176998e575 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stories/usecase/StoryEditorMediaTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stories/usecase/StoryEditorMediaTest.kt @@ -1,6 +1,5 @@ package org.wordpress.android.ui.stories.usecase -import android.net.Uri import androidx.lifecycle.Observer import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.UnconfinedTestDispatcher @@ -23,43 +22,10 @@ import org.wordpress.android.ui.posts.editor.media.EditorMediaListener import org.wordpress.android.ui.stories.media.StoryEditorMedia import org.wordpress.android.ui.stories.media.StoryEditorMedia.AddMediaToStoryPostUiState import org.wordpress.android.ui.utils.UiString.UiStringRes -import org.wordpress.android.util.MediaUtilsWrapper import org.wordpress.android.viewmodel.Event @ExperimentalCoroutinesApi class StoryEditorMediaTest : BaseUnitTest() { - @Test - fun `advertiseImageOptimisationAndAddMedia shows dialog when shouldAdvertiseImageOptimization is true`() { - // Arrange - val editorMediaListener = mock() - val mediaUtilsWrapper = createMediaUtilsWrapper(shouldAdvertiseImageOptimization = true) - - // Act - createStoryEditorMedia( - editorMediaListener = editorMediaListener, - mediaUtilsWrapper = mediaUtilsWrapper - ).advertiseImageOptimisationAndAddMedia(mock()) - - // Assert - verify(editorMediaListener).advertiseImageOptimization(anyOrNull()) - } - - @Test - fun `advertiseImageOptimisationAndAddMedia does NOT show dialog when shouldAdvertiseImageOptimization is false`() { - // Arrange - val editorMediaListener = mock() - val mediaUtilsWrapper = createMediaUtilsWrapper(shouldAdvertiseImageOptimization = false) - - // Act - createStoryEditorMedia( - editorMediaListener = editorMediaListener, - mediaUtilsWrapper = mediaUtilsWrapper - ) - .advertiseImageOptimisationAndAddMedia(mock()) - // Assert - verify(editorMediaListener, never()).advertiseImageOptimization(anyOrNull()) - } - @Test fun `addNewMediaItemsToEditorAsync emits AddingSingleMedia for a single uri`() = test { // Arrange @@ -117,58 +83,14 @@ class StoryEditorMediaTest : BaseUnitTest() { verify(observer, never()).onChanged(captor.capture()) } - @Test - fun `onPhotoPickerMediaChosen does NOT invoke shouldAdvertiseImageOptimization when only video files`() = - test { - // Arrange - val uris = listOf(VIDEO_URI, VIDEO_URI, VIDEO_URI, VIDEO_URI) - val editorMediaListener = mock() - - val mediaUtilsWrapper = createMediaUtilsWrapper() - - // Act - createStoryEditorMedia( - mediaUtilsWrapper = mediaUtilsWrapper, - editorMediaListener = editorMediaListener - ) - .onPhotoPickerMediaChosen(uris) - // Assert - verify(editorMediaListener, never()).advertiseImageOptimization(anyOrNull()) - verify(mediaUtilsWrapper, never()).shouldAdvertiseImageOptimization() - } - - @Test - fun `onPhotoPickerMediaChosen invokes shouldAdvertiseImageOptimization when at least 1 image file`() = - test { - // Arrange - val uris = listOf(VIDEO_URI, VIDEO_URI, IMAGE_URI, VIDEO_URI) - val editorMediaListener = mock() - - val mediaUtilsWrapper = createMediaUtilsWrapper() - - // Act - createStoryEditorMedia( - mediaUtilsWrapper = mediaUtilsWrapper, - editorMediaListener = editorMediaListener - ) - .onPhotoPickerMediaChosen(uris) - // Assert - verify(mediaUtilsWrapper).shouldAdvertiseImageOptimization() - } - private companion object Fixtures { - private val VIDEO_URI = mock() - private val IMAGE_URI = mock() - fun createStoryEditorMedia( - mediaUtilsWrapper: MediaUtilsWrapper = createMediaUtilsWrapper(), addLocalMediaToPostUseCase: AddLocalMediaToPostUseCase = createAddLocalMediaToPostUseCase(), addExistingMediaToPostUseCase: AddExistingMediaToPostUseCase = mock(), siteModel: SiteModel = mock(), editorMediaListener: EditorMediaListener = mock() ): StoryEditorMedia { val editorMedia = StoryEditorMedia( - mediaUtilsWrapper, addLocalMediaToPostUseCase, addExistingMediaToPostUseCase, UnconfinedTestDispatcher() @@ -177,16 +99,6 @@ class StoryEditorMediaTest : BaseUnitTest() { return editorMedia } - fun createMediaUtilsWrapper( - shouldAdvertiseImageOptimization: Boolean = false - ) = - mock { - on { shouldAdvertiseImageOptimization() } - .thenReturn(shouldAdvertiseImageOptimization) - on { isVideo(VIDEO_URI.toString()) }.thenReturn(true) - on { isVideo(IMAGE_URI.toString()) }.thenReturn(false) - } - fun createAddLocalMediaToPostUseCase(resultForAddNewMediaToEditorAsync: Boolean = true) = mock { onBlocking { diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java index fbc2df7a413e..12ef44396989 100644 --- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java +++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTracker.java @@ -896,7 +896,6 @@ public enum Stat { APP_SETTINGS_VIDEO_OPTIMIZATION_CHANGED, APP_SETTINGS_MAX_VIDEO_SIZE_CHANGED, APP_SETTINGS_VIDEO_QUALITY_CHANGED, - APP_SETTINGS_OPTIMIZE_IMAGES_POPUP_TAPPED, PRIVACY_SETTINGS_OPENED, PRIVACY_SETTINGS_REPORT_CRASHES_TOGGLED, SHARING_BUTTONS_EDIT_SHARING_BUTTONS_CHANGED, diff --git a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java index 1ea594ddff90..6eeaa539722c 100644 --- a/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java +++ b/libs/analytics/src/main/java/org/wordpress/android/analytics/AnalyticsTrackerNosara.java @@ -2273,8 +2273,6 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) { return "app_settings_privacy_settings_tapped"; case APP_SETTINGS_OPEN_DEVICE_SETTINGS_TAPPED: return "app_settings_open_device_settings_tapped"; - case APP_SETTINGS_OPTIMIZE_IMAGES_POPUP_TAPPED: - return "app_settings_optimize_images_popup_tapped"; case APP_SETTINGS_MAX_IMAGE_SIZE_CHANGED: return "app_settings_max_image_size_changed"; case APP_SETTINGS_IMAGE_QUALITY_CHANGED: