forked from upstream-mirrors/OpenTracks
Cleanup.
This commit is contained in:
+4
-5
@@ -30,7 +30,6 @@ import org.junit.Test;
|
|||||||
import de.dennisguse.opentracks.content.data.TrackPointsColumns;
|
import de.dennisguse.opentracks.content.data.TrackPointsColumns;
|
||||||
import de.dennisguse.opentracks.content.data.TracksColumns;
|
import de.dennisguse.opentracks.content.data.TracksColumns;
|
||||||
import de.dennisguse.opentracks.content.data.WaypointsColumns;
|
import de.dennisguse.opentracks.content.data.WaypointsColumns;
|
||||||
import de.dennisguse.opentracks.content.provider.CustomContentProvider.DatabaseHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link CustomContentProvider}.
|
* Tests {@link CustomContentProvider}.
|
||||||
@@ -48,13 +47,13 @@ public class CustomContentProviderTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
context.deleteDatabase(DATABASE_NAME);
|
context.deleteDatabase(DATABASE_NAME);
|
||||||
db = (new DatabaseHelper(context, DATABASE_NAME)).getWritableDatabase();
|
db = new CustomSQLiteOpenHelper(context, DATABASE_NAME).getWritableDatabase();
|
||||||
customContentProvider = new CustomContentProvider() {
|
customContentProvider = new CustomContentProvider() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link CustomContentProvider.DatabaseHelper#onCreate(SQLiteDatabase)}.
|
* Tests {@link CustomSQLiteOpenHelper#onCreate(SQLiteDatabase)}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testDatabaseHelper_OnCreate() {
|
public void testDatabaseHelper_OnCreate() {
|
||||||
@@ -148,7 +147,7 @@ public class CustomContentProviderTest {
|
|||||||
createTable(TrackPointsColumns.TABLE_NAME);
|
createTable(TrackPointsColumns.TABLE_NAME);
|
||||||
createTable(WaypointsColumns.TABLE_NAME);
|
createTable(WaypointsColumns.TABLE_NAME);
|
||||||
|
|
||||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
CustomSQLiteOpenHelper databaseHelper = new CustomSQLiteOpenHelper(context);
|
||||||
databaseHelper.onUpgrade(db, oldVersion, CustomContentProvider.DATABASE_VERSION);
|
databaseHelper.onUpgrade(db, oldVersion, CustomSQLiteOpenHelper.DATABASE_VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,6 @@ import android.database.Cursor;
|
|||||||
import android.database.SQLException;
|
import android.database.SQLException;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteException;
|
import android.database.sqlite.SQLiteException;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
|
||||||
import android.database.sqlite.SQLiteQueryBuilder;
|
import android.database.sqlite.SQLiteQueryBuilder;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -45,12 +44,6 @@ import de.dennisguse.opentracks.content.data.WaypointsColumns;
|
|||||||
*/
|
*/
|
||||||
public abstract class CustomContentProvider extends ContentProvider {
|
public abstract class CustomContentProvider extends ContentProvider {
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final int DATABASE_VERSION = 23;
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String DATABASE_NAME = "database.db";
|
|
||||||
|
|
||||||
private static final String TAG = CustomContentProvider.class.getSimpleName();
|
private static final String TAG = CustomContentProvider.class.getSimpleName();
|
||||||
|
|
||||||
private static final String SQL_LIST_DELIMITER = ",";
|
private static final String SQL_LIST_DELIMITER = ",";
|
||||||
@@ -85,7 +78,7 @@ public abstract class CustomContentProvider extends ContentProvider {
|
|||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean onCreate(Context context) {
|
boolean onCreate(Context context) {
|
||||||
DatabaseHelper databaseHelper = new DatabaseHelper(context);
|
CustomSQLiteOpenHelper databaseHelper = new CustomSQLiteOpenHelper(context);
|
||||||
try {
|
try {
|
||||||
db = databaseHelper.getWritableDatabase();
|
db = databaseHelper.getWritableDatabase();
|
||||||
} catch (SQLiteException e) {
|
} catch (SQLiteException e) {
|
||||||
@@ -391,31 +384,4 @@ public abstract class CustomContentProvider extends ContentProvider {
|
|||||||
WAYPOINTS,
|
WAYPOINTS,
|
||||||
WAYPOINTS_BY_ID
|
WAYPOINTS_BY_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Database helper for creating and upgrading the database.
|
|
||||||
*/
|
|
||||||
@VisibleForTesting
|
|
||||||
static class DatabaseHelper extends SQLiteOpenHelper {
|
|
||||||
|
|
||||||
public DatabaseHelper(Context context) {
|
|
||||||
this(context, DATABASE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public DatabaseHelper(Context context, String databaseName) {
|
|
||||||
super(context, databaseName, null, DATABASE_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(SQLiteDatabase db) {
|
|
||||||
db.execSQL(TrackPointsColumns.CREATE_TABLE);
|
|
||||||
db.execSQL(TracksColumns.CREATE_TABLE);
|
|
||||||
db.execSQL(WaypointsColumns.CREATE_TABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package de.dennisguse.opentracks.content.provider;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.content.data.TrackPointsColumns;
|
||||||
|
import de.dennisguse.opentracks.content.data.TracksColumns;
|
||||||
|
import de.dennisguse.opentracks.content.data.WaypointsColumns;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database helper for creating and upgrading the database.
|
||||||
|
*/
|
||||||
|
@VisibleForTesting
|
||||||
|
public class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static final int DATABASE_VERSION = 23;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static final String DATABASE_NAME = "database.db";
|
||||||
|
|
||||||
|
public CustomSQLiteOpenHelper(Context context) {
|
||||||
|
this(context, DATABASE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public CustomSQLiteOpenHelper(Context context, String databaseName) {
|
||||||
|
super(context, databaseName, null, DATABASE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
db.execSQL(TrackPointsColumns.CREATE_TABLE);
|
||||||
|
db.execSQL(TracksColumns.CREATE_TABLE);
|
||||||
|
db.execSQL(WaypointsColumns.CREATE_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -232,7 +232,9 @@ public enum TrackFileFormat {
|
|||||||
/**
|
/**
|
||||||
* Returns whether the format supports photos.
|
* Returns whether the format supports photos.
|
||||||
*/
|
*/
|
||||||
public boolean includesPhotos() { return false; };
|
public boolean includesPhotos() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of for each format.
|
* Returns the name of for each format.
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
|||||||
private ExportActivity exportActivity;
|
private ExportActivity exportActivity;
|
||||||
private WakeLock wakeLock;
|
private WakeLock wakeLock;
|
||||||
|
|
||||||
private boolean completed;
|
private boolean completed = false;
|
||||||
|
|
||||||
private int processedTrackCount;
|
private int processedTrackCount = 0;
|
||||||
private int totalTrackCount;
|
private int totalTrackCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an AsyncTask.
|
* Creates an AsyncTask.
|
||||||
@@ -68,10 +68,6 @@ public class ExportAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
|||||||
this.directory = directory;
|
this.directory = directory;
|
||||||
context = exportActivity.getApplicationContext();
|
context = exportActivity.getApplicationContext();
|
||||||
contentProviderUtils = new ContentProviderUtils(context);
|
contentProviderUtils = new ContentProviderUtils(context);
|
||||||
|
|
||||||
completed = false;
|
|
||||||
processedTrackCount = 0;
|
|
||||||
totalTrackCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user