mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Optimized imports before starting
This commit is contained in:
		
							parent
							
								
									d53858f7d2
								
							
						
					
					
						commit
						5396fc6ed0
					
				
					 19 changed files with 51 additions and 57 deletions
				
			
		|  | @ -15,10 +15,9 @@ import java.util.Locale; | |||
| 
 | ||||
| import fr.free.nrw.commons.BuildConfig; | ||||
| import fr.free.nrw.commons.CommonsApplication; | ||||
| import fr.free.nrw.commons.EventLog; | ||||
| import fr.free.nrw.commons.Media; | ||||
| import fr.free.nrw.commons.settings.Prefs; | ||||
| import fr.free.nrw.commons.Utils; | ||||
| import fr.free.nrw.commons.settings.Prefs; | ||||
| 
 | ||||
| public class Contribution extends Media { | ||||
| 
 | ||||
|  | @ -63,8 +62,6 @@ public class Contribution extends Media { | |||
|         isMultiple = multiple; | ||||
|     } | ||||
| 
 | ||||
|     public EventLog.LogBuilder event; | ||||
| 
 | ||||
|     public Contribution(Uri localUri, String remoteUri, String filename, String description, long dataLength, Date dateCreated, Date dateUploaded, String creator, String editSummary, String decimalCoords) { | ||||
|         super(localUri, remoteUri, filename, description, dataLength, dateCreated, dateUploaded, creator); | ||||
|         this.decimalCoords = decimalCoords; | ||||
|  | @ -132,14 +129,14 @@ public class Contribution extends Media { | |||
|     public String getPageContents() { | ||||
|         StringBuffer buffer = new StringBuffer(); | ||||
|         SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); | ||||
|          | ||||
| 
 | ||||
|         buffer | ||||
|             .append("== {{int:filedesc}} ==\n") | ||||
|                 .append("== {{int:filedesc}} ==\n") | ||||
|                 .append("{{Information\n") | ||||
|                     .append("|description=").append(getDescription()).append("\n") | ||||
|                     .append("|source=").append("{{own}}\n") | ||||
|                     .append("|author=[[User:").append(creator).append("|").append(creator).append("]]\n"); | ||||
|         if(dateCreated != null) { | ||||
|                 .append("|description=").append(getDescription()).append("\n") | ||||
|                 .append("|source=").append("{{own}}\n") | ||||
|                 .append("|author=[[User:").append(creator).append("|").append(creator).append("]]\n"); | ||||
|         if (dateCreated != null) { | ||||
|             buffer | ||||
|                     .append("|date={{According to EXIF data|").append(isoFormat.format(dateCreated)).append("}}\n"); | ||||
|         } | ||||
|  | @ -148,13 +145,13 @@ public class Contribution extends Media { | |||
| 
 | ||||
|         //Only add Location template (e.g. {{Location|37.51136|-77.602615}} ) if coords is not null | ||||
|         if (decimalCoords != null) { | ||||
|                 buffer.append("{{Location|").append(decimalCoords).append("}}").append("\n"); | ||||
|             buffer.append("{{Location|").append(decimalCoords).append("}}").append("\n"); | ||||
|         } | ||||
| 
 | ||||
|         buffer.append("== {{int:license-header}} ==\n") | ||||
|                 .append(Utils.licenseTemplateFor(getLicense())).append("\n\n") | ||||
|             .append("{{Uploaded from Mobile|platform=Android|version=").append(BuildConfig.VERSION_NAME).append("}}\n") | ||||
|             .append(getTrackingTemplates()); | ||||
|                 .append("{{Uploaded from Mobile|platform=Android|version=").append(BuildConfig.VERSION_NAME).append("}}\n") | ||||
|                 .append(getTrackingTemplates()); | ||||
|         return buffer.toString(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -164,19 +161,19 @@ public class Contribution extends Media { | |||
| 
 | ||||
|     public void save() { | ||||
|         try { | ||||
|             if(contentUri == null) { | ||||
|             if (contentUri == null) { | ||||
|                 contentUri = client.insert(ContributionsContentProvider.BASE_URI, this.toContentValues()); | ||||
|             } else { | ||||
|                 client.update(contentUri, toContentValues(), null, null); | ||||
|             } | ||||
|         } catch(RemoteException e) { | ||||
|         } catch (RemoteException e) { | ||||
|             throw new RuntimeException(e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void delete() { | ||||
|         try { | ||||
|             if(contentUri == null) { | ||||
|             if (contentUri == null) { | ||||
|                 // noooo | ||||
|                 throw new RuntimeException("tried to delete item with no content URI"); | ||||
|             } else { | ||||
|  | @ -191,20 +188,20 @@ public class Contribution extends Media { | |||
|     public ContentValues toContentValues() { | ||||
|         ContentValues cv = new ContentValues(); | ||||
|         cv.put(Table.COLUMN_FILENAME, getFilename()); | ||||
|         if(getLocalUri() != null) { | ||||
|         if (getLocalUri() != null) { | ||||
|             cv.put(Table.COLUMN_LOCAL_URI, getLocalUri().toString()); | ||||
|         } | ||||
|         if(getImageUrl() != null) { | ||||
|         if (getImageUrl() != null) { | ||||
|             cv.put(Table.COLUMN_IMAGE_URL, getImageUrl()); | ||||
|         } | ||||
|         if(getDateUploaded() != null) { | ||||
|         if (getDateUploaded() != null) { | ||||
|             cv.put(Table.COLUMN_UPLOADED, getDateUploaded().getTime()); | ||||
|         } | ||||
|         cv.put(Table.COLUMN_LENGTH, getDataLength()); | ||||
|         cv.put(Table.COLUMN_TIMESTAMP, getTimestamp().getTime()); | ||||
|         cv.put(Table.COLUMN_STATE, getState()); | ||||
|         cv.put(Table.COLUMN_TRANSFERRED, transferred); | ||||
|         cv.put(Table.COLUMN_SOURCE,  source); | ||||
|         cv.put(Table.COLUMN_SOURCE, source); | ||||
|         cv.put(Table.COLUMN_DESCRIPTION, description); | ||||
|         cv.put(Table.COLUMN_CREATOR, creator); | ||||
|         cv.put(Table.COLUMN_MULTIPLE, isMultiple ? 1 : 0); | ||||
|  | @ -240,7 +237,7 @@ public class Contribution extends Media { | |||
|             c.timestamp = cursor.getLong(4) == 0 ? null : new Date(cursor.getLong(4)); | ||||
|             c.state = cursor.getInt(5); | ||||
|             c.dataLength = cursor.getLong(6); | ||||
|             c.dateUploaded =  cursor.getLong(7) == 0 ? null : new Date(cursor.getLong(7)); | ||||
|             c.dateUploaded = cursor.getLong(7) == 0 ? null : new Date(cursor.getLong(7)); | ||||
|             c.transferred = cursor.getLong(8); | ||||
|             c.source = cursor.getString(9); | ||||
|             c.description = cursor.getString(10); | ||||
|  | @ -324,7 +321,7 @@ public class Contribution extends Media { | |||
|                 + "width INTEGER," | ||||
|                 + "height INTEGER," | ||||
|                 + "LICENSE STRING" | ||||
|         + ");"; | ||||
|                 + ");"; | ||||
| 
 | ||||
| 
 | ||||
|         public static void onCreate(SQLiteDatabase db) { | ||||
|  | @ -337,36 +334,36 @@ public class Contribution extends Media { | |||
|         } | ||||
| 
 | ||||
|         public static void onUpdate(SQLiteDatabase db, int from, int to) { | ||||
|             if(from == to) { | ||||
|             if (from == to) { | ||||
|                 return; | ||||
|             } | ||||
|             if(from == 1) { | ||||
|             if (from == 1) { | ||||
|                 db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN description STRING;"); | ||||
|                 db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN creator STRING;"); | ||||
|                 from++; | ||||
|                 onUpdate(db, from, to); | ||||
|                 return; | ||||
|             } | ||||
|             if(from == 2) { | ||||
|             if (from == 2) { | ||||
|                 db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN multiple INTEGER;"); | ||||
|                 db.execSQL("UPDATE " + TABLE_NAME + " SET multiple = 0"); | ||||
|                 from++; | ||||
|                 onUpdate(db, from, to); | ||||
|                 return; | ||||
|             } | ||||
|             if(from == 3) { | ||||
|             if (from == 3) { | ||||
|                 // Do nothing | ||||
|                 from++; | ||||
|                 onUpdate(db, from, to); | ||||
|                 return; | ||||
|             } | ||||
|             if(from == 4) { | ||||
|             if (from == 4) { | ||||
|                 // Do nothing -- added Category | ||||
|                 from++; | ||||
|                 onUpdate(db, from, to); | ||||
|                 return; | ||||
|             } | ||||
|             if(from == 5) { | ||||
|             if (from == 5) { | ||||
|                 // Added width and height fields | ||||
|                 db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN width INTEGER;"); | ||||
|                 db.execSQL("UPDATE " + TABLE_NAME + " SET width = 0"); | ||||
|  |  | |||
|  | @ -3,15 +3,12 @@ package fr.free.nrw.commons.contributions; | |||
| import android.app.Activity; | ||||
| import android.content.Intent; | ||||
| import android.net.Uri; | ||||
| import android.os.Build; | ||||
| import android.os.Bundle; | ||||
| import android.os.Environment; | ||||
| import android.provider.MediaStore; | ||||
| import android.support.v4.app.Fragment; | ||||
| import android.support.v4.content.FileProvider; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| import fr.free.nrw.commons.upload.ShareActivity; | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| package fr.free.nrw.commons.contributions; | ||||
| 
 | ||||
| import android.Manifest; | ||||
| import android.content.ActivityNotFoundException; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.content.SharedPreferences; | ||||
|  |  | |||
|  | @ -9,7 +9,6 @@ import java.net.HttpURLConnection; | |||
| import java.net.URL; | ||||
| import java.util.Locale; | ||||
| 
 | ||||
| import fr.free.nrw.commons.CommonsApplication; | ||||
| import fr.free.nrw.commons.concurrency.BackgroundPoolExceptionHandler; | ||||
| import fr.free.nrw.commons.concurrency.ThreadPoolExecutorService; | ||||
| import timber.log.Timber; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Paul Hawke
						Paul Hawke