Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stock media source to media picker #13009

Merged
merged 34 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2783b0b
Add stock media source
planarvoid Sep 11, 2020
ffce8b6
Remove get method and add stock media source
planarvoid Sep 14, 2020
b5d2a4a
Merge branch 'develop' into feature/12641-add-pexel-source-to-media-p…
planarvoid Sep 22, 2020
60787cd
Update stock media data source with the latest fluxC version
planarvoid Sep 22, 2020
deb749f
Merge branch 'develop' into feature/12641-add-pexel-source-to-media-p…
planarvoid Sep 23, 2020
51e9405
Add progress dialog when stock media are being uploaded
planarvoid Sep 23, 2020
c775161
Update fluxC version
planarvoid Sep 23, 2020
da276cd
Merge branch 'feature/remove-browser-type-from-media-picker' into fea…
planarvoid Sep 23, 2020
89decc7
Handle featured image upload
planarvoid Sep 23, 2020
e6ee121
Move local media tracking to the DeviceListBuilder.kt
planarvoid Sep 24, 2020
81a6b28
Remove unused NoChange state from media source
planarvoid Sep 24, 2020
05175a6
Remove unused stock media upload from MediaPickerActivity.kt
planarvoid Sep 24, 2020
383b52b
Add default search view flag to MediaPickerSetup.kt
planarvoid Sep 24, 2020
8dfa569
Add default search view and multiple selection flags to MediaPickerLa…
planarvoid Sep 24, 2020
0fc2160
Fix logic to show and select stock media
planarvoid Sep 24, 2020
290cb39
Update FluxC version
planarvoid Sep 24, 2020
cf69095
Fix lint issues
planarvoid Sep 24, 2020
4cdac47
Fix lint error
planarvoid Sep 24, 2020
86b7b38
Fix unit tests
planarvoid Sep 24, 2020
e8dfdc4
Add tests for StockMediaDataSource.kt
planarvoid Sep 24, 2020
28fdaec
Merge branch 'feature/remove-browser-type-from-media-picker' into fea…
planarvoid Sep 30, 2020
5f5675d
Extract insert logic into Insert use cases
planarvoid Sep 30, 2020
0ca85ac
Fix lint issue
planarvoid Sep 30, 2020
6173e28
Merge branch 'develop' into feature/12641-add-pexel-source-to-media-p…
planarvoid Oct 5, 2020
6798937
Fix crash when switching to empty list from a list of results
planarvoid Oct 5, 2020
14ed77b
Fix dialog leaking the activity context
planarvoid Oct 5, 2020
13c5c77
Fix lint error
planarvoid Oct 5, 2020
29a548a
Only show progress dialog when an item takes longer to load
planarvoid Oct 6, 2020
352e446
Add support for snackbar errors to media picker
planarvoid Oct 6, 2020
071c9dc
Fix unit test
planarvoid Oct 6, 2020
ae3a21c
Ask for both write and read storage permissions in the media picker
planarvoid Oct 6, 2020
a18a2a4
Fix test
planarvoid Oct 6, 2020
4e8108e
Merge branch 'develop' into feature/12641-add-pexel-source-to-media-p…
planarvoid Oct 7, 2020
c9e70a8
Update fluxc
planarvoid Oct 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ private static Intent createShowPhotoPickerIntent(Context context,
return intent;
}

/**
* Use {@link org.wordpress.android.ui.photopicker.MediaPickerLauncher::showStockMediaPickerForResult} instead
*/
@Deprecated
public static void showStockMediaPickerForResult(Activity activity,
@NonNull SiteModel site,
int requestCode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ private void doAddMediaItemClicked(@NonNull AddMenuItem item) {
mMediaPickerLauncher.showFilePicker(this);
break;
case ITEM_CHOOSE_STOCK_MEDIA:
ActivityLauncher.showStockMediaPickerForResult(this,
mSite, RequestCodes.STOCK_MEDIA_PICKER_MULTI_SELECT);
mMediaPickerLauncher.showStockMediaPickerForResult(this,
mSite, RequestCodes.STOCK_MEDIA_PICKER_MULTI_SELECT, true);
break;
case ITEM_CHOOSE_GIF:
ActivityLauncher.showGifPickerForResult(this, mSite, RequestCodes.GIF_PICKER_MULTI_SELECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.net.Uri
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import org.wordpress.android.util.UriWrapper
import java.lang.IllegalArgumentException

data class MediaItem(
val identifier: Identifier,
Expand All @@ -17,6 +16,7 @@ data class MediaItem(
sealed class Identifier {
data class LocalUri(val value: UriWrapper) : Identifier()
data class RemoteId(val value: Long) : Identifier()
data class StockMediaIdentifier(val url: String?, val name: String?, val title: String?) : Identifier()

fun toParcel() = Parcel((this as? LocalUri)?.value?.uri, (this as? RemoteId)?.value)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.net.Uri
import android.os.Bundle
import android.text.TextUtils
import android.view.MenuItem
import android.widget.Toast
import androidx.fragment.app.FragmentTransaction
import kotlinx.android.synthetic.main.toolbar_main.*
import org.wordpress.android.R
Expand Down Expand Up @@ -46,10 +45,6 @@ import org.wordpress.android.ui.photopicker.MediaPickerConstants.EXTRA_MEDIA_URI
import org.wordpress.android.ui.photopicker.MediaPickerConstants.LOCAL_POST_ID
import org.wordpress.android.ui.posts.EMPTY_LOCAL_POST_ID
import org.wordpress.android.ui.posts.FeaturedImageHelper
import org.wordpress.android.ui.posts.FeaturedImageHelper.EnqueueFeaturedImageResult.FILE_NOT_FOUND
import org.wordpress.android.ui.posts.FeaturedImageHelper.EnqueueFeaturedImageResult.INVALID_POST_ID
import org.wordpress.android.ui.posts.FeaturedImageHelper.EnqueueFeaturedImageResult.SUCCESS
import org.wordpress.android.ui.posts.FeaturedImageHelper.TrackableEvent.IMAGE_PICKED
import org.wordpress.android.ui.posts.editor.ImageEditorTracker
import org.wordpress.android.ui.utils.UiHelpers
import org.wordpress.android.util.AppLog
Expand Down Expand Up @@ -235,39 +230,11 @@ class MediaPickerActivity : LocaleAwareActivity(), MediaPickerListener {
) {
// if user chose a featured image, we need to upload it and return the uploaded media object
if (mediaPickerSetup.queueResults) {
val mediaUri = mediaUris[0]
val mimeType = contentResolver.getType(mediaUri)
featuredImageHelper.trackFeaturedImageEvent(
IMAGE_PICKED,
localPostId
)
WPMediaUtils.fetchMediaAndDoNext(
this, mediaUri
) { uri ->
val queueImageResult = featuredImageHelper
.queueFeaturedImageForUpload(
localPostId, site!!, uri,
mimeType
)
when (queueImageResult) {
FILE_NOT_FOUND -> Toast.makeText(
applicationContext,
R.string.file_not_found, Toast.LENGTH_SHORT
)
.show()
INVALID_POST_ID -> Toast.makeText(
applicationContext,
R.string.error_generic, Toast.LENGTH_SHORT
)
.show()
SUCCESS -> {
}
}
val intent = Intent()
.putExtra(EXTRA_MEDIA_QUEUED, true)
setResult(Activity.RESULT_OK, intent)
finish()
}
val intent = Intent()
.putExtra(EXTRA_MEDIA_QUEUED, true)
.putExtra(EXTRA_MEDIA_URIS, convertUrisListToStringArray(mediaUris))
setResult(Activity.RESULT_OK, intent)
finish()
} else {
val intent = Intent()
.putExtra(EXTRA_MEDIA_URIS, convertUrisListToStringArray(mediaUris))
Expand Down
Loading