Optimized imports before starting

This commit is contained in:
Paul Hawke 2017-07-04 14:23:13 -05:00
parent d53858f7d2
commit 5396fc6ed0
19 changed files with 51 additions and 57 deletions

View file

@ -7,8 +7,12 @@ import android.preference.PreferenceManager;
import android.text.Html; import android.text.Html;
import android.text.Spanned; import android.text.Spanned;
import fr.free.nrw.commons.settings.Prefs; import org.apache.commons.codec.binary.Hex;
import timber.log.Timber; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.codec.net.URLCodec;
import org.w3c.dom.Node;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
@ -34,12 +38,8 @@ import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.apache.commons.codec.binary.Hex; import fr.free.nrw.commons.settings.Prefs;
import org.apache.commons.codec.digest.DigestUtils; import timber.log.Timber;
import org.apache.commons.codec.net.URLCodec;
import org.w3c.dom.Node;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class Utils { public class Utils {

View file

@ -9,7 +9,6 @@ import com.viewpagerindicator.CirclePageIndicator;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import fr.free.nrw.commons.contributions.ContributionsActivity;
import fr.free.nrw.commons.theme.BaseActivity; import fr.free.nrw.commons.theme.BaseActivity;
public class WelcomeActivity extends BaseActivity { public class WelcomeActivity extends BaseActivity {

View file

@ -7,6 +7,7 @@ import android.content.ContentResolver;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.contributions.ContributionsContentProvider; import fr.free.nrw.commons.contributions.ContributionsContentProvider;
import fr.free.nrw.commons.modifications.ModificationsContentProvider; import fr.free.nrw.commons.modifications.ModificationsContentProvider;

View file

@ -15,9 +15,13 @@ import android.view.inputmethod.EditorInfo;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import fr.free.nrw.commons.*;
import fr.free.nrw.commons.BuildConfig;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.WelcomeActivity;
import fr.free.nrw.commons.contributions.ContributionsActivity; import fr.free.nrw.commons.contributions.ContributionsActivity;
import timber.log.Timber; import timber.log.Timber;

View file

@ -9,8 +9,8 @@ import android.os.Bundle;
import java.io.IOException; import java.io.IOException;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.EventLog;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.mwapi.EventLog;
import timber.log.Timber; import timber.log.Timber;
class LoginTask extends AsyncTask<String, String, String> { class LoginTask extends AsyncTask<String, String, String> {

View file

@ -1,6 +1,7 @@
package fr.free.nrw.commons.concurrency; package fr.free.nrw.commons.concurrency;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import fr.free.nrw.commons.BuildConfig; import fr.free.nrw.commons.BuildConfig;
public class BackgroundPoolExceptionHandler implements ExceptionHandler { public class BackgroundPoolExceptionHandler implements ExceptionHandler {

View file

@ -15,10 +15,9 @@ import java.util.Locale;
import fr.free.nrw.commons.BuildConfig; import fr.free.nrw.commons.BuildConfig;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.EventLog;
import fr.free.nrw.commons.Media; import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.settings.Prefs;
import fr.free.nrw.commons.Utils; import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.settings.Prefs;
public class Contribution extends Media { public class Contribution extends Media {
@ -63,8 +62,6 @@ public class Contribution extends Media {
isMultiple = multiple; 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) { 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); super(localUri, remoteUri, filename, description, dataLength, dateCreated, dateUploaded, creator);
this.decimalCoords = decimalCoords; this.decimalCoords = decimalCoords;
@ -132,14 +129,14 @@ public class Contribution extends Media {
public String getPageContents() { public String getPageContents() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
buffer buffer
.append("== {{int:filedesc}} ==\n") .append("== {{int:filedesc}} ==\n")
.append("{{Information\n") .append("{{Information\n")
.append("|description=").append(getDescription()).append("\n") .append("|description=").append(getDescription()).append("\n")
.append("|source=").append("{{own}}\n") .append("|source=").append("{{own}}\n")
.append("|author=[[User:").append(creator).append("|").append(creator).append("]]\n"); .append("|author=[[User:").append(creator).append("|").append(creator).append("]]\n");
if(dateCreated != null) { if (dateCreated != null) {
buffer buffer
.append("|date={{According to EXIF data|").append(isoFormat.format(dateCreated)).append("}}\n"); .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 //Only add Location template (e.g. {{Location|37.51136|-77.602615}} ) if coords is not null
if (decimalCoords != 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") buffer.append("== {{int:license-header}} ==\n")
.append(Utils.licenseTemplateFor(getLicense())).append("\n\n") .append(Utils.licenseTemplateFor(getLicense())).append("\n\n")
.append("{{Uploaded from Mobile|platform=Android|version=").append(BuildConfig.VERSION_NAME).append("}}\n") .append("{{Uploaded from Mobile|platform=Android|version=").append(BuildConfig.VERSION_NAME).append("}}\n")
.append(getTrackingTemplates()); .append(getTrackingTemplates());
return buffer.toString(); return buffer.toString();
} }
@ -164,19 +161,19 @@ public class Contribution extends Media {
public void save() { public void save() {
try { try {
if(contentUri == null) { if (contentUri == null) {
contentUri = client.insert(ContributionsContentProvider.BASE_URI, this.toContentValues()); contentUri = client.insert(ContributionsContentProvider.BASE_URI, this.toContentValues());
} else { } else {
client.update(contentUri, toContentValues(), null, null); client.update(contentUri, toContentValues(), null, null);
} }
} catch(RemoteException e) { } catch (RemoteException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public void delete() { public void delete() {
try { try {
if(contentUri == null) { if (contentUri == null) {
// noooo // noooo
throw new RuntimeException("tried to delete item with no content URI"); throw new RuntimeException("tried to delete item with no content URI");
} else { } else {
@ -191,20 +188,20 @@ public class Contribution extends Media {
public ContentValues toContentValues() { public ContentValues toContentValues() {
ContentValues cv = new ContentValues(); ContentValues cv = new ContentValues();
cv.put(Table.COLUMN_FILENAME, getFilename()); cv.put(Table.COLUMN_FILENAME, getFilename());
if(getLocalUri() != null) { if (getLocalUri() != null) {
cv.put(Table.COLUMN_LOCAL_URI, getLocalUri().toString()); cv.put(Table.COLUMN_LOCAL_URI, getLocalUri().toString());
} }
if(getImageUrl() != null) { if (getImageUrl() != null) {
cv.put(Table.COLUMN_IMAGE_URL, getImageUrl()); cv.put(Table.COLUMN_IMAGE_URL, getImageUrl());
} }
if(getDateUploaded() != null) { if (getDateUploaded() != null) {
cv.put(Table.COLUMN_UPLOADED, getDateUploaded().getTime()); cv.put(Table.COLUMN_UPLOADED, getDateUploaded().getTime());
} }
cv.put(Table.COLUMN_LENGTH, getDataLength()); cv.put(Table.COLUMN_LENGTH, getDataLength());
cv.put(Table.COLUMN_TIMESTAMP, getTimestamp().getTime()); cv.put(Table.COLUMN_TIMESTAMP, getTimestamp().getTime());
cv.put(Table.COLUMN_STATE, getState()); cv.put(Table.COLUMN_STATE, getState());
cv.put(Table.COLUMN_TRANSFERRED, transferred); 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_DESCRIPTION, description);
cv.put(Table.COLUMN_CREATOR, creator); cv.put(Table.COLUMN_CREATOR, creator);
cv.put(Table.COLUMN_MULTIPLE, isMultiple ? 1 : 0); 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.timestamp = cursor.getLong(4) == 0 ? null : new Date(cursor.getLong(4));
c.state = cursor.getInt(5); c.state = cursor.getInt(5);
c.dataLength = cursor.getLong(6); 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.transferred = cursor.getLong(8);
c.source = cursor.getString(9); c.source = cursor.getString(9);
c.description = cursor.getString(10); c.description = cursor.getString(10);
@ -324,7 +321,7 @@ public class Contribution extends Media {
+ "width INTEGER," + "width INTEGER,"
+ "height INTEGER," + "height INTEGER,"
+ "LICENSE STRING" + "LICENSE STRING"
+ ");"; + ");";
public static void onCreate(SQLiteDatabase db) { 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) { public static void onUpdate(SQLiteDatabase db, int from, int to) {
if(from == to) { if (from == to) {
return; 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 description STRING;");
db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN creator STRING;"); db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN creator STRING;");
from++; from++;
onUpdate(db, from, to); onUpdate(db, from, to);
return; return;
} }
if(from == 2) { if (from == 2) {
db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN multiple INTEGER;"); db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN multiple INTEGER;");
db.execSQL("UPDATE " + TABLE_NAME + " SET multiple = 0"); db.execSQL("UPDATE " + TABLE_NAME + " SET multiple = 0");
from++; from++;
onUpdate(db, from, to); onUpdate(db, from, to);
return; return;
} }
if(from == 3) { if (from == 3) {
// Do nothing // Do nothing
from++; from++;
onUpdate(db, from, to); onUpdate(db, from, to);
return; return;
} }
if(from == 4) { if (from == 4) {
// Do nothing -- added Category // Do nothing -- added Category
from++; from++;
onUpdate(db, from, to); onUpdate(db, from, to);
return; return;
} }
if(from == 5) { if (from == 5) {
// Added width and height fields // Added width and height fields
db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN width INTEGER;"); db.execSQL("ALTER TABLE " + TABLE_NAME + " ADD COLUMN width INTEGER;");
db.execSQL("UPDATE " + TABLE_NAME + " SET width = 0"); db.execSQL("UPDATE " + TABLE_NAME + " SET width = 0");

View file

@ -3,15 +3,12 @@ package fr.free.nrw.commons.contributions;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.FileProvider; import android.support.v4.content.FileProvider;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.Date; import java.util.Date;
import fr.free.nrw.commons.upload.ShareActivity; import fr.free.nrw.commons.upload.ShareActivity;

View file

@ -1,7 +1,6 @@
package fr.free.nrw.commons.contributions; package fr.free.nrw.commons.contributions;
import android.Manifest; import android.Manifest;
import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;

View file

@ -9,7 +9,6 @@ import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.Locale; import java.util.Locale;
import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.concurrency.BackgroundPoolExceptionHandler; import fr.free.nrw.commons.concurrency.BackgroundPoolExceptionHandler;
import fr.free.nrw.commons.concurrency.ThreadPoolExecutorService; import fr.free.nrw.commons.concurrency.ThreadPoolExecutorService;
import timber.log.Timber; import timber.log.Timber;

View file

@ -28,11 +28,11 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.EventLog;
import fr.free.nrw.commons.Media; import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.contributions.Contribution; import fr.free.nrw.commons.contributions.Contribution;
import fr.free.nrw.commons.contributions.ContributionsActivity; import fr.free.nrw.commons.contributions.ContributionsActivity;
import fr.free.nrw.commons.mwapi.EventLog;
public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPageChangeListener { public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPageChangeListener {
private ViewPager pager; private ViewPager pager;

View file

@ -30,8 +30,8 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng; import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.location.LocationServiceManager; import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.theme.NavigationBaseActivity; import fr.free.nrw.commons.theme.NavigationBaseActivity;

View file

@ -7,7 +7,6 @@ import android.location.Location;
import android.location.LocationListener; import android.location.LocationListener;
import android.location.LocationManager; import android.location.LocationManager;
import android.media.ExifInterface; import android.media.ExifInterface;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;

View file

@ -20,12 +20,10 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Toast; import android.widget.Toast;
import butterknife.ButterKnife;
import java.util.ArrayList; import java.util.ArrayList;
import butterknife.ButterKnife;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.EventLog;
import fr.free.nrw.commons.Media; import fr.free.nrw.commons.Media;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.auth.AuthenticatedActivity; import fr.free.nrw.commons.auth.AuthenticatedActivity;
@ -36,6 +34,7 @@ import fr.free.nrw.commons.modifications.CategoryModifier;
import fr.free.nrw.commons.modifications.ModificationsContentProvider; import fr.free.nrw.commons.modifications.ModificationsContentProvider;
import fr.free.nrw.commons.modifications.ModifierSequence; import fr.free.nrw.commons.modifications.ModifierSequence;
import fr.free.nrw.commons.modifications.TemplateRemoveModifier; import fr.free.nrw.commons.modifications.TemplateRemoveModifier;
import fr.free.nrw.commons.mwapi.EventLog;
import timber.log.Timber; import timber.log.Timber;
public class MultipleShareActivity public class MultipleShareActivity

View file

@ -6,7 +6,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.graphics.drawable.VectorDrawableCompat; import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;

View file

@ -32,7 +32,6 @@ import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.EventLog;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils; import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.AuthenticatedActivity; import fr.free.nrw.commons.auth.AuthenticatedActivity;
@ -42,6 +41,7 @@ import fr.free.nrw.commons.modifications.CategoryModifier;
import fr.free.nrw.commons.modifications.ModificationsContentProvider; import fr.free.nrw.commons.modifications.ModificationsContentProvider;
import fr.free.nrw.commons.modifications.ModifierSequence; import fr.free.nrw.commons.modifications.ModifierSequence;
import fr.free.nrw.commons.modifications.TemplateRemoveModifier; import fr.free.nrw.commons.modifications.TemplateRemoveModifier;
import fr.free.nrw.commons.mwapi.EventLog;
import timber.log.Timber; import timber.log.Timber;
/** /**

View file

@ -32,9 +32,9 @@ import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.OnItemSelected; import butterknife.OnItemSelected;
import butterknife.OnTouch; import butterknife.OnTouch;
import fr.free.nrw.commons.settings.Prefs;
import fr.free.nrw.commons.R; import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils; import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.settings.Prefs;
import timber.log.Timber; import timber.log.Timber;
public class SingleUploadFragment extends Fragment { public class SingleUploadFragment extends Fragment {

View file

@ -18,9 +18,9 @@ import java.util.Date;
import fr.free.nrw.commons.CommonsApplication; import fr.free.nrw.commons.CommonsApplication;
import fr.free.nrw.commons.HandlerService; import fr.free.nrw.commons.HandlerService;
import fr.free.nrw.commons.settings.Prefs;
import fr.free.nrw.commons.Utils; import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.contributions.Contribution; import fr.free.nrw.commons.contributions.Contribution;
import fr.free.nrw.commons.settings.Prefs;
import timber.log.Timber; import timber.log.Timber;
public class UploadController { public class UploadController {

View file

@ -1,9 +1,9 @@
package fr.free.nrw.commons.utils; package fr.free.nrw.commons.utils;
import fr.free.nrw.commons.location.LatLng;
import java.text.NumberFormat; import java.text.NumberFormat;
import fr.free.nrw.commons.location.LatLng;
public class LengthUtils { public class LengthUtils {
/** Returns a formatted distance string between two points. /** Returns a formatted distance string between two points.
* @param point1 LatLng type point1 * @param point1 LatLng type point1