mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Add appropriate info and licensing templates
This commit is contained in:
parent
f8c9dba049
commit
b3f8bf815e
3 changed files with 59 additions and 5 deletions
|
|
@ -57,7 +57,7 @@ public class ShareActivity extends AuthenticatedActivity {
|
||||||
Intent uploadIntent = new Intent(getApplicationContext(), UploadService.class);
|
Intent uploadIntent = new Intent(getApplicationContext(), UploadService.class);
|
||||||
uploadIntent.putExtra(UploadService.EXTRA_MEDIA_URI, imageUri);
|
uploadIntent.putExtra(UploadService.EXTRA_MEDIA_URI, imageUri);
|
||||||
uploadIntent.putExtra(UploadService.EXTRA_TARGET_FILENAME, titleEdit.getText().toString());
|
uploadIntent.putExtra(UploadService.EXTRA_TARGET_FILENAME, titleEdit.getText().toString());
|
||||||
uploadIntent.putExtra(UploadService.EXTRA_PAGE_CONTENT, descEdit.getText().toString());
|
uploadIntent.putExtra(UploadService.EXTRA_DESCRIPTION, descEdit.getText().toString());
|
||||||
uploadIntent.putExtra(UploadService.EXTRA_EDIT_SUMMARY, "Mobile upload from Wikimedia Commons Android app");
|
uploadIntent.putExtra(UploadService.EXTRA_EDIT_SUMMARY, "Mobile upload from Wikimedia Commons Android app");
|
||||||
startService(uploadIntent);
|
startService(uploadIntent);
|
||||||
Toast startingToast = Toast.makeText(that, R.string.uploading_started, Toast.LENGTH_LONG);
|
Toast startingToast = Toast.makeText(that, R.string.uploading_started, Toast.LENGTH_LONG);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package org.wikimedia.commons;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import org.mediawiki.api.*;
|
import org.mediawiki.api.*;
|
||||||
|
import org.wikimedia.commons.media.Media;
|
||||||
|
|
||||||
import de.mastacode.http.ProgressListener;
|
import de.mastacode.http.ProgressListener;
|
||||||
|
|
||||||
|
|
@ -21,7 +22,7 @@ public class UploadService extends IntentService {
|
||||||
private static final String EXTRA_PREFIX = "org.wikimedia.commons.uploader";
|
private static final String EXTRA_PREFIX = "org.wikimedia.commons.uploader";
|
||||||
public static final String EXTRA_MEDIA_URI = EXTRA_PREFIX + ".media_uri";
|
public static final String EXTRA_MEDIA_URI = EXTRA_PREFIX + ".media_uri";
|
||||||
public static final String EXTRA_TARGET_FILENAME = EXTRA_PREFIX + ".filename";
|
public static final String EXTRA_TARGET_FILENAME = EXTRA_PREFIX + ".filename";
|
||||||
public static final String EXTRA_PAGE_CONTENT = EXTRA_PREFIX + ".content";
|
public static final String EXTRA_DESCRIPTION = EXTRA_PREFIX + ".description";
|
||||||
public static final String EXTRA_EDIT_SUMMARY = EXTRA_PREFIX + ".summary";
|
public static final String EXTRA_EDIT_SUMMARY = EXTRA_PREFIX + ".summary";
|
||||||
|
|
||||||
private NotificationManager notificationManager;
|
private NotificationManager notificationManager;
|
||||||
|
|
@ -101,9 +102,8 @@ public class UploadService extends IntentService {
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
Uri mediaUri = (Uri)extras.getParcelable(EXTRA_MEDIA_URI);
|
Uri mediaUri = (Uri)extras.getParcelable(EXTRA_MEDIA_URI);
|
||||||
String filename = intent.getStringExtra(EXTRA_TARGET_FILENAME);
|
String filename = intent.getStringExtra(EXTRA_TARGET_FILENAME);
|
||||||
String pageContents = intent.getStringExtra(EXTRA_PAGE_CONTENT);
|
String description = intent.getStringExtra(EXTRA_DESCRIPTION);
|
||||||
String editSummary = intent.getStringExtra(EXTRA_EDIT_SUMMARY);
|
String editSummary = intent.getStringExtra(EXTRA_EDIT_SUMMARY);
|
||||||
|
|
||||||
String notificationTag = mediaUri.toString();
|
String notificationTag = mediaUri.toString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -147,7 +147,8 @@ public class UploadService extends IntentService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = api.upload(filename, file, length, pageContents, editSummary, notificationUpdater);
|
Media media = new Media(mediaUri, filename, description, editSummary, app.getCurrentAccount().name);
|
||||||
|
result = api.upload(filename, file, length, media.getPageContents(), editSummary, notificationUpdater);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
||||||
53
src/org/wikimedia/commons/media/Media.java
Normal file
53
src/org/wikimedia/commons/media/Media.java
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
package org.wikimedia.commons.media;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import android.net.*;
|
||||||
|
|
||||||
|
public class Media {
|
||||||
|
private Uri mediaUri;
|
||||||
|
private String fileName;
|
||||||
|
private String editSummary;
|
||||||
|
private String mimeType;
|
||||||
|
private String description;
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
public Media(Uri mediaUri, String fileName, String description, String editSummary, String userName) {
|
||||||
|
this.mediaUri = mediaUri;
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.description = description;
|
||||||
|
this.editSummary = editSummary;
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Uri getMediaUri() {
|
||||||
|
return mediaUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEditSummary() {
|
||||||
|
return editSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPageContents() {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer
|
||||||
|
.append("== {{int:filedesc}} ==\n")
|
||||||
|
.append("{{Information")
|
||||||
|
.append("|Description=").append(description)
|
||||||
|
.append("|source=").append("{{own}}")
|
||||||
|
.append("|author=[[User:").append(userName).append("]]")
|
||||||
|
.append("}}").append("\n")
|
||||||
|
.append("== {{int:license-header}} ==\n")
|
||||||
|
.append("{{self|cc-by-sa-3.0}}")
|
||||||
|
;
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMimeType() {
|
||||||
|
return mimeType;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue