@@ -96,38 +96,29 @@ public void cleanup() {
96
96
* @param wikiDataEntityId
97
97
* @param onComplete the progress tracker
98
98
*/
99
- public void startUpload (String title , Uri contentProviderUri , Uri mediaUri , String description , String mimeType , String source , String decimalCoords , String wikiDataEntityId , ContributionUploadProgress onComplete ) {
99
+ public void startUpload (String title , Uri mediaUri , String description , String mimeType , String source , String decimalCoords , String wikiDataEntityId , ContributionUploadProgress onComplete ) {
100
100
Contribution contribution ;
101
-
102
-
103
- //TODO: Modify this to include coords
104
- contribution = new Contribution (mediaUri , null , title , description , -1 ,
105
- null , null , sessionManager .getCurrentAccount ().name ,
106
- CommonsApplication .DEFAULT_EDIT_SUMMARY , decimalCoords );
107
-
108
-
109
- contribution .setTag ("mimeType" , mimeType );
110
- contribution .setSource (source );
111
-
112
101
Timber .d ("Wikidata entity ID received from Share activity is %s" , wikiDataEntityId );
113
- //TODO: Modify this to include coords
114
102
Account currentAccount = sessionManager .getCurrentAccount ();
115
103
if (currentAccount == null ) {
116
104
Timber .d ("Current account is null" );
117
105
ViewUtil .showLongToast (context , context .getString (R .string .user_not_logged_in ));
118
106
sessionManager .forceLogin (context );
119
107
return ;
120
108
}
109
+ String fileAbsolutePath = mediaUri .toString ();
110
+ File file =new File (fileAbsolutePath );
111
+ long lastModified = file .lastModified ();
112
+ Date lastModifiedDate =new Date (lastModified );
121
113
contribution = new Contribution (mediaUri , null , title , description , -1 ,
122
- null , null , currentAccount .name ,
114
+ lastModifiedDate , new Date ( System . currentTimeMillis ()) , currentAccount .name ,
123
115
CommonsApplication .DEFAULT_EDIT_SUMMARY , decimalCoords );
124
116
125
117
126
118
contribution .setTag ("mimeType" , mimeType );
127
119
contribution .setSource (source );
128
120
contribution .setWikiDataEntityId (wikiDataEntityId );
129
- contribution .setContentProviderUri (contentProviderUri );
130
-
121
+ contribution .setContentProviderUri (mediaUri );
131
122
//Calls the next overloaded method
132
123
startUpload (contribution , onComplete );
133
124
}
@@ -188,36 +179,14 @@ protected Contribution doInBackground(Void... voids /* stare into you */) {
188
179
}
189
180
190
181
String mimeType = (String ) contribution .getTag ("mimeType" );
191
- Boolean imagePrefix = false ;
192
-
193
182
if (mimeType == null || TextUtils .isEmpty (mimeType ) || mimeType .endsWith ("*" )) {
194
183
mimeType = contentResolver .getType (contribution .getLocalUri ());
195
184
}
196
185
197
186
if (mimeType != null ) {
198
187
contribution .setTag ("mimeType" , mimeType );
199
- imagePrefix = mimeType .startsWith ("image/" );
200
188
Timber .d ("MimeType is: %s" , mimeType );
201
189
}
202
-
203
- if (imagePrefix && contribution .getDateCreated () == null ) {
204
- Timber .d ("local uri " + contribution .getLocalUri ());
205
- Cursor cursor = contentResolver .query (contribution .getLocalUri (),
206
- new String []{MediaStore .Images .ImageColumns .DATE_TAKEN }, null , null , null );
207
- if (cursor != null && cursor .getCount () != 0 && cursor .getColumnCount () != 0 ) {
208
- cursor .moveToFirst ();
209
- Date dateCreated = new Date (cursor .getLong (0 ));
210
- Date epochStart = new Date (0 );
211
- if (dateCreated .equals (epochStart ) || dateCreated .before (epochStart )) {
212
- // If date is incorrect (1st second of unix time) then set it to the current date
213
- dateCreated = new Date ();
214
- }
215
- contribution .setDateCreated (dateCreated );
216
- cursor .close ();
217
- } else {
218
- contribution .setDateCreated (new Date ());
219
- }
220
- }
221
190
return contribution ;
222
191
}
223
192
0 commit comments