1010import android .graphics .BitmapFactory ;
1111import android .os .Bundle ;
1212import android .support .v4 .app .NotificationCompat ;
13- import android .util .Log ;
1413import android .webkit .MimeTypeMap ;
1514import android .widget .Toast ;
1615
2726import javax .inject .Inject ;
2827
2928import fr .free .nrw .commons .BuildConfig ;
29+ import fr .free .nrw .commons .CommonsApplication ;
3030import fr .free .nrw .commons .HandlerService ;
3131import fr .free .nrw .commons .R ;
3232import fr .free .nrw .commons .Utils ;
3535import fr .free .nrw .commons .contributions .ContributionDao ;
3636import fr .free .nrw .commons .contributions .ContributionsActivity ;
3737import fr .free .nrw .commons .contributions .ContributionsContentProvider ;
38- import fr .free .nrw .commons .modifications .ModificationsContentProvider ;
3938import fr .free .nrw .commons .mwapi .MediaWikiApi ;
4039import fr .free .nrw .commons .mwapi .UploadResult ;
4140import fr .free .nrw .commons .wikidata .WikidataEditService ;
@@ -182,6 +181,19 @@ public int onStartCommand(Intent intent, int flags, int startId) {
182181 }
183182
184183 @ SuppressLint ("StringFormatInvalid" )
184+ private NotificationCompat .Builder getNotificationBuilder (Contribution contribution , String channelId ) {
185+ return new NotificationCompat .Builder (this , channelId ).setAutoCancel (true )
186+ .setSmallIcon (R .drawable .ic_launcher )
187+ .setLargeIcon (BitmapFactory .decodeResource (getResources (), R .drawable .ic_launcher ))
188+ .setAutoCancel (true )
189+ .setContentTitle (getString (R .string .upload_progress_notification_title_start , contribution .getDisplayTitle ()))
190+ .setContentText (getResources ().getQuantityString (R .plurals .uploads_pending_notification_indicator , toUpload , toUpload ))
191+ .setOngoing (true )
192+ .setProgress (100 , 0 , true )
193+ .setContentIntent (PendingIntent .getActivity (this , 0 , new Intent (this , ContributionsActivity .class ), 0 ))
194+ .setTicker (getString (R .string .upload_progress_notification_title_in_progress , contribution .getDisplayTitle ()));
195+ }
196+
185197 private void uploadContribution (Contribution contribution ) {
186198 InputStream fileInputStream ;
187199
@@ -207,17 +219,9 @@ private void uploadContribution(Contribution contribution) {
207219 }
208220
209221 Timber .d ("Before execution!" );
210- curProgressNotification = new NotificationCompat .Builder (this ).setAutoCancel (true )
211- .setSmallIcon (R .drawable .ic_launcher )
212- .setLargeIcon (BitmapFactory .decodeResource (getResources (), R .drawable .ic_launcher ))
213- .setAutoCancel (true )
214- .setContentTitle (getString (R .string .upload_progress_notification_title_start , contribution .getDisplayTitle ()))
215- .setContentText (getResources ().getQuantityString (R .plurals .uploads_pending_notification_indicator , toUpload , toUpload ))
216- .setOngoing (true )
217- .setProgress (100 , 0 , true )
218- .setContentIntent (PendingIntent .getActivity (this , 0 , new Intent (this , ContributionsActivity .class ), 0 ))
219- .setTicker (getString (R .string .upload_progress_notification_title_in_progress , contribution .getDisplayTitle ()));
220-
222+ curProgressNotification = getNotificationBuilder (
223+ contribution ,
224+ CommonsApplication .NOTIFICATION_CHANNEL_ID_ALL );
221225 this .startForeground (NOTIFICATION_UPLOAD_IN_PROGRESS , curProgressNotification .build ());
222226
223227 String filename = null ;
0 commit comments