|
1 | 1 | package fr.free.nrw.commons.upload; |
2 | 2 |
|
| 3 | +import android.accounts.Account; |
3 | 4 | import android.content.ComponentName; |
4 | 5 | import android.content.ContentResolver; |
5 | 6 | import android.content.Context; |
|
13 | 14 | import android.os.IBinder; |
14 | 15 | import android.provider.MediaStore; |
15 | 16 | import android.text.TextUtils; |
| 17 | +import android.widget.Toast; |
16 | 18 |
|
17 | 19 | import java.io.BufferedInputStream; |
18 | 20 | import java.io.IOException; |
|
22 | 24 |
|
23 | 25 | import fr.free.nrw.commons.CommonsApplication; |
24 | 26 | import fr.free.nrw.commons.HandlerService; |
| 27 | +import fr.free.nrw.commons.R; |
25 | 28 | import fr.free.nrw.commons.auth.SessionManager; |
26 | 29 | import fr.free.nrw.commons.contributions.Contribution; |
27 | 30 | import fr.free.nrw.commons.settings.Prefs; |
| 31 | +import fr.free.nrw.commons.utils.ViewUtil; |
28 | 32 | import timber.log.Timber; |
29 | 33 |
|
30 | 34 | public class UploadController { |
@@ -95,8 +99,15 @@ public void startUpload(String title, Uri mediaUri, String description, String m |
95 | 99 | Contribution contribution; |
96 | 100 |
|
97 | 101 | //TODO: Modify this to include coords |
| 102 | + Account currentAccount = sessionManager.getCurrentAccount(); |
| 103 | + if(currentAccount == null) { |
| 104 | + Timber.d("Current account is null"); |
| 105 | + ViewUtil.showLongToast(context, context.getString(R.string.user_not_logged_in)); |
| 106 | + sessionManager.forceLogin(context); |
| 107 | + return; |
| 108 | + } |
98 | 109 | contribution = new Contribution(mediaUri, null, title, description, -1, |
99 | | - null, null, sessionManager.getCurrentAccount().name, |
| 110 | + null, null, currentAccount.name, |
100 | 111 | CommonsApplication.DEFAULT_EDIT_SUMMARY, decimalCoords); |
101 | 112 |
|
102 | 113 | contribution.setTag("mimeType", mimeType); |
|
0 commit comments