Skip to content

Commit 22ab728

Browse files
Andy ValdezAndy Valdez
authored andcommitted
[Bug] Made updates related to targetSdk update for media.
I omitted the targetSdk update in this PR simply to allow testing with the previous version to ensure everything remains the same. Additionally, I added the foreground service types related to images.
1 parent f561faa commit 22ab728

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

WordPress/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
2929
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
3030
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
31+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
3132

3233
<!-- GCM all build types configuration -->
3334
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
@@ -823,11 +824,13 @@
823824
<!-- Services -->
824825
<service
825826
android:name=".ui.uploads.UploadService"
826-
android:label="Upload Service" />
827+
android:label="Upload Service"
828+
android:foregroundServiceType="dataSync"/>
827829
<service
828830
android:name=".ui.media.services.MediaDeleteService"
829831
android:label="Media Delete Service"
830832
android:exported="false"
833+
android:foregroundServiceType="dataSync"
831834
/>
832835

833836
<service
@@ -1048,7 +1051,7 @@
10481051

10491052
<service
10501053
android:name=".push.GCMMessageService"
1051-
android:exported="false">
1054+
android:exported="false" >
10521055
<intent-filter>
10531056
<action android:name="com.google.firebase.MESSAGING_EVENT" />
10541057
</intent-filter>

WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
import android.content.ClipData;
1010
import android.content.ClipboardManager;
1111
import android.content.Context;
12+
import android.content.ContextWrapper;
1213
import android.content.Intent;
1314
import android.content.IntentFilter;
1415
import android.database.Cursor;
1516
import android.graphics.Bitmap;
1617
import android.graphics.drawable.Drawable;
1718
import android.net.Uri;
1819
import android.os.Build;
20+
import android.os.Build.VERSION_CODES;
1921
import android.os.Bundle;
2022
import android.os.Environment;
2123
import android.os.Handler;
@@ -467,7 +469,11 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
467469
@SuppressLint("UnspecifiedRegisterReceiverFlag")
468470
public void onStart() {
469471
super.onStart();
470-
registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
472+
if (Build.VERSION.SDK_INT >= VERSION_CODES.UPSIDE_DOWN_CAKE) {
473+
registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), ContextWrapper.RECEIVER_NOT_EXPORTED);
474+
} else {
475+
registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
476+
}
471477
mDispatcher.register(this);
472478

473479
// we only register with EventBus the first time - necessary since we don't unregister in onStop()

WordPress/src/main/java/org/wordpress/android/ui/mediapicker/loader/DeviceListBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class DeviceListBuilder(
6969
// This item sets the threshold for the visible items in all the list
7070
val lastShownTimestamp = results.fold(0L) { timestamp, (_, result) ->
7171
val nextTimestamp = result?.nextTimestamp
72-
if (nextTimestamp != null && nextTimestamp > timestamp) {
72+
if (result?.items?.isNotEmpty() == true && nextTimestamp != null && nextTimestamp > timestamp) {
7373
nextTimestamp
7474
} else {
7575
timestamp

0 commit comments

Comments
 (0)