Add isMultiple tracking parameter

This commit is contained in:
YuviPanda 2013-03-21 00:35:47 +05:30
parent 2e4264c16c
commit 408bb5bb70
5 changed files with 29 additions and 4 deletions

View file

@ -50,7 +50,7 @@ public class CommonsApplication extends Application {
public static final String EVENTLOG_URL = "https://bits.wikimedia.org/event.gif"; public static final String EVENTLOG_URL = "https://bits.wikimedia.org/event.gif";
public static final String EVENTLOG_WIKI = "testwiki"; public static final String EVENTLOG_WIKI = "testwiki";
public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5257716L}; public static final Object[] EVENT_UPLOAD_ATTEMPT = {"MobileAppUploadAttempts", 5334329L};
public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5257721L}; public static final Object[] EVENT_LOGIN_ATTEMPT = {"MobileAppLoginAttempts", 5257721L};
public static final String DEFAULT_EDIT_SUMMARY = "Uploaded using Android Commons app"; public static final String DEFAULT_EDIT_SUMMARY = "Uploaded using Android Commons app";

View file

@ -218,6 +218,8 @@ public class MultipleShareActivity
up.setLocalUri(uri); up.setLocalUri(uri);
up.setTag("mimeType", intent.getType()); up.setTag("mimeType", intent.getType());
up.setTag("sequence", i); up.setTag("sequence", i);
up.setSource(Contribution.SOURCE_EXTERNAL);
up.setMultiple(true);
photosList.add(up); photosList.add(up);
} }
} }

View file

@ -220,6 +220,7 @@ public class UploadService extends HandlerService<Contribution> {
EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT) EventLog.schema(CommonsApplication.EVENT_UPLOAD_ATTEMPT)
.param("username", app.getCurrentAccount().name) .param("username", app.getCurrentAccount().name)
.param("source", contribution.getSource()) .param("source", contribution.getSource())
.param("multiple", contribution.getMultiple())
.param("result", errorCode) .param("result", errorCode)
.param("filename", contribution.getFilename()) .param("filename", contribution.getFilename())
.log(); .log();
@ -238,6 +239,7 @@ public class UploadService extends HandlerService<Contribution> {
.param("username", app.getCurrentAccount().name) .param("username", app.getCurrentAccount().name)
.param("source", contribution.getSource()) //FIXME .param("source", contribution.getSource()) //FIXME
.param("filename", contribution.getFilename()) .param("filename", contribution.getFilename())
.param("multiple", contribution.getMultiple())
.param("result", "success") .param("result", "success")
.log(); .log();
} }

View file

@ -45,6 +45,16 @@ public class Contribution extends Media {
private int state; private int state;
private long transferred; private long transferred;
private boolean isMultiple;
public boolean getMultiple() {
return isMultiple;
}
public void setMultiple(boolean multiple) {
isMultiple = multiple;
}
public EventLog.LogBuilder event; public EventLog.LogBuilder event;
@ -56,6 +66,7 @@ public class Contribution extends Media {
parcel.writeSerializable(timestamp); parcel.writeSerializable(timestamp);
parcel.writeInt(state); parcel.writeInt(state);
parcel.writeLong(transferred); parcel.writeLong(transferred);
parcel.writeInt(isMultiple ? 1 : 0);
} }
public Contribution(Parcel in) { public Contribution(Parcel in) {
@ -65,6 +76,8 @@ public class Contribution extends Media {
timestamp = (Date) in.readSerializable(); timestamp = (Date) in.readSerializable();
state = in.readInt(); state = in.readInt();
transferred = in.readLong(); transferred = in.readLong();
isMultiple = in.readInt() == 1;
} }
public long getTransferred() { public long getTransferred() {
@ -165,6 +178,7 @@ public class Contribution extends Media {
cv.put(Table.COLUMN_SOURCE, source); cv.put(Table.COLUMN_SOURCE, source);
cv.put(Table.COLUMN_DESCRIPTION, description); cv.put(Table.COLUMN_DESCRIPTION, description);
cv.put(Table.COLUMN_CREATOR, creator); cv.put(Table.COLUMN_CREATOR, creator);
cv.put(Table.COLUMN_MULTIPLE, isMultiple ? 1 : 0);
return cv; return cv;
} }
@ -195,6 +209,7 @@ public class Contribution extends Media {
c.source = cursor.getString(9); c.source = cursor.getString(9);
c.description = cursor.getString(10); c.description = cursor.getString(10);
c.creator = cursor.getString(11); c.creator = cursor.getString(11);
c.isMultiple = cursor.getInt(12) == 1;
return c; return c;
} }
@ -226,6 +241,7 @@ public class Contribution extends Media {
public static final String COLUMN_SOURCE = "source"; public static final String COLUMN_SOURCE = "source";
public static final String COLUMN_DESCRIPTION = "description"; public static final String COLUMN_DESCRIPTION = "description";
public static final String COLUMN_CREATOR = "creator"; // Initial uploader public static final String COLUMN_CREATOR = "creator"; // Initial uploader
public static final String COLUMN_MULTIPLE = "multiple";
// NOTE! KEEP IN SAME ORDER AS THEY ARE DEFINED UP THERE. HELPS HARD CODE COLUMN INDICES. // NOTE! KEEP IN SAME ORDER AS THEY ARE DEFINED UP THERE. HELPS HARD CODE COLUMN INDICES.
public static final String[] ALL_FIELDS = { public static final String[] ALL_FIELDS = {
@ -240,7 +256,8 @@ public class Contribution extends Media {
COLUMN_TRANSFERRED, COLUMN_TRANSFERRED,
COLUMN_SOURCE, COLUMN_SOURCE,
COLUMN_DESCRIPTION, COLUMN_DESCRIPTION,
COLUMN_CREATOR COLUMN_CREATOR,
COLUMN_MULTIPLE
}; };
@ -256,7 +273,8 @@ public class Contribution extends Media {
+ "transferred INTEGER," + "transferred INTEGER,"
+ "source STRING," + "source STRING,"
+ "description STRING," + "description STRING,"
+ "creator STRING" + "creator STRING,"
+ "multiple INTEGER"
+ ");"; + ");";
@ -275,6 +293,9 @@ public class Contribution extends Media {
onUpdate(db, from, to); onUpdate(db, from, to);
return; return;
} }
if(from == 2) {
db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN multiple INTEGER;");
}
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db); onCreate(db);
} }

View file

@ -8,7 +8,7 @@ import org.wikimedia.commons.contributions.Contribution;
public class DBOpenHelper extends SQLiteOpenHelper{ public class DBOpenHelper extends SQLiteOpenHelper{
private static final String DATABASE_NAME = "commons.db"; private static final String DATABASE_NAME = "commons.db";
private static final int DATABASE_VERSION = 2; private static final int DATABASE_VERSION = 3;
public DBOpenHelper(Context context) { public DBOpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION); super(context, DATABASE_NAME, null, DATABASE_VERSION);