14
14
import android .widget .LinearLayout ;
15
15
import android .widget .RelativeLayout ;
16
16
import android .widget .TextView ;
17
+ import android .widget .Toast ;
17
18
import androidx .appcompat .app .AlertDialog ;
18
19
import androidx .cardview .widget .CardView ;
19
20
import androidx .fragment .app .Fragment ;
@@ -115,10 +116,10 @@ protected void onCreate(Bundle savedInstanceState) {
115
116
init ();
116
117
117
118
PermissionUtils .checkPermissionsAndPerformAction (this ,
118
- Manifest .permission .WRITE_EXTERNAL_STORAGE ,
119
- this ::receiveSharedItems ,
120
- R .string .storage_permission_title ,
121
- R .string .write_storage_permission_rationale_for_image_share );
119
+ Manifest .permission .WRITE_EXTERNAL_STORAGE ,
120
+ this ::receiveSharedItems ,
121
+ R .string .storage_permission_title ,
122
+ R .string .write_storage_permission_rationale_for_image_share );
122
123
}
123
124
124
125
private void init () {
@@ -135,7 +136,7 @@ private void initProgressDialog() {
135
136
136
137
private void initThumbnailsRecyclerView () {
137
138
rvThumbnails .setLayoutManager (new LinearLayoutManager (this ,
138
- LinearLayoutManager .HORIZONTAL , false ));
139
+ LinearLayoutManager .HORIZONTAL , false ));
139
140
thumbnailsAdapter = new ThumbnailsAdapter (() -> currentSelectedPosition );
140
141
rvThumbnails .setAdapter (thumbnailsAdapter );
141
142
@@ -147,7 +148,7 @@ private void initViewPager() {
147
148
vpUpload .addOnPageChangeListener (new ViewPager .OnPageChangeListener () {
148
149
@ Override
149
150
public void onPageScrolled (int position , float positionOffset ,
150
- int positionOffsetPixels ) {
151
+ int positionOffsetPixels ) {
151
152
152
153
}
153
154
@@ -192,22 +193,22 @@ protected void onResume() {
192
193
*/
193
194
protected void checkBlockStatus () {
194
195
compositeDisposable .add (userClient .isUserBlockedFromCommons ()
195
- .subscribeOn (Schedulers .io ())
196
- .observeOn (AndroidSchedulers .mainThread ())
197
- .filter (result -> result )
198
- .subscribe (result -> showInfoAlert (R .string .block_notification_title ,
199
- R .string .block_notification , UploadActivity .this ::finish )
200
- ));
196
+ .subscribeOn (Schedulers .io ())
197
+ .observeOn (AndroidSchedulers .mainThread ())
198
+ .filter (result -> result )
199
+ .subscribe (result -> showInfoAlert (R .string .block_notification_title ,
200
+ R .string .block_notification , UploadActivity .this ::finish )
201
+ ));
201
202
}
202
203
203
204
private void checkStoragePermissions () {
204
205
PermissionUtils .checkPermissionsAndPerformAction (this ,
205
- Manifest .permission .WRITE_EXTERNAL_STORAGE ,
206
- () -> {
207
- //TODO handle this
208
- },
209
- R .string .storage_permission_title ,
210
- R .string .write_storage_permission_rationale_for_image_share );
206
+ Manifest .permission .WRITE_EXTERNAL_STORAGE ,
207
+ () -> {
208
+ //TODO handle this
209
+ },
210
+ R .string .storage_permission_title ,
211
+ R .string .write_storage_permission_rationale_for_image_share );
211
212
}
212
213
213
214
@@ -268,7 +269,7 @@ public void onUploadMediaDeleted(int index) {
268
269
@ Override
269
270
public void updateTopCardTitle () {
270
271
tvTopCardTitle .setText (getResources ()
271
- .getQuantityString (R .plurals .upload_count_title , uploadableFiles .size (), uploadableFiles .size ()));
272
+ .getQuantityString (R .plurals .upload_count_title , uploadableFiles .size (), uploadableFiles .size ()));
272
273
}
273
274
274
275
@ Override
@@ -297,19 +298,21 @@ private void receiveSharedItems() {
297
298
} else if (ACTION_INTERNAL_UPLOADS .equals (action )) {
298
299
receiveInternalSharedItems ();
299
300
}
300
-
301
- if (uploadableFiles == null || uploadableFiles .isEmpty ()) {
301
+ if (uploadableFiles .size () > 5 ) {
302
+ handleLargeMedia ();
303
+ }
304
+ else if (uploadableFiles == null || uploadableFiles .isEmpty ()) {
302
305
handleNullMedia ();
303
306
} else {
304
307
//Show thumbnails
305
308
if (uploadableFiles .size ()
306
- > 1 ) {//If there is only file, no need to show the image thumbnails
309
+ > 1 ) {//If there is only file, no need to show the image thumbnails
307
310
thumbnailsAdapter .setUploadableFiles (uploadableFiles );
308
311
} else {
309
312
llContainerTopCard .setVisibility (View .GONE );
310
313
}
311
314
tvTopCardTitle .setText (getResources ()
312
- .getQuantityString (R .plurals .upload_count_title , uploadableFiles .size (), uploadableFiles .size ()));
315
+ .getQuantityString (R .plurals .upload_count_title , uploadableFiles .size (), uploadableFiles .size ()));
313
316
314
317
fragments = new ArrayList <>();
315
318
for (UploadableFile uploadableFile : uploadableFiles ) {
@@ -395,18 +398,22 @@ private void handleNullMedia() {
395
398
ViewUtil .showLongToast (this , R .string .error_processing_image );
396
399
finish ();
397
400
}
401
+ private void handleLargeMedia () {
402
+ ViewUtil .showLongToast (this , R .string .HandleLargeMedia );
403
+ finish ();
404
+ }
398
405
399
406
private void showInfoAlert (int titleStringID , int messageStringId , Runnable positive , String ... formatArgs ) {
400
407
new AlertDialog .Builder (this )
401
- .setTitle (titleStringID )
402
- .setMessage (getString (messageStringId , (Object []) formatArgs ))
403
- .setCancelable (true )
404
- .setPositiveButton (android .R .string .ok , (dialog , id ) -> {
405
- positive .run ();
406
- dialog .cancel ();
407
- })
408
- .create ()
409
- .show ();
408
+ .setTitle (titleStringID )
409
+ .setMessage (getString (messageStringId , (Object []) formatArgs ))
410
+ .setCancelable (true )
411
+ .setPositiveButton (android .R .string .ok , (dialog , id ) -> {
412
+ positive .run ();
413
+ dialog .cancel ();
414
+ })
415
+ .create ()
416
+ .show ();
410
417
}
411
418
412
419
@ Override
0 commit comments