Appese checkstyle + pmd

This commit is contained in:
Peter Serwylo 2016-07-25 22:28:51 +10:00
parent 5e263c0e0f
commit 4b5481b8f2
5 changed files with 23 additions and 12 deletions

View File

@ -26,7 +26,6 @@ import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;

View File

@ -24,8 +24,13 @@ public class AppPrefs extends ValueObject {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
return o != null && o instanceof AppPrefs && return o != null && o instanceof AppPrefs &&
((AppPrefs)o).ignoreAllUpdates == ignoreAllUpdates && ((AppPrefs) o).ignoreAllUpdates == ignoreAllUpdates &&
((AppPrefs)o).ignoreThisUpdate == ignoreThisUpdate; ((AppPrefs) o).ignoreThisUpdate == ignoreThisUpdate;
}
@Override
public int hashCode() {
return (ignoreThisUpdate + "-" + ignoreAllUpdates).hashCode();
} }
public AppPrefs createClone() { public AppPrefs createClone() {

View File

@ -103,7 +103,7 @@ class DBHelper extends SQLiteOpenHelper {
private static final String CREATE_TABLE_APP_PREFS = "CREATE TABLE " + AppPrefsTable.NAME private static final String CREATE_TABLE_APP_PREFS = "CREATE TABLE " + AppPrefsTable.NAME
+ " ( " + " ( "
+ AppPrefsTable.Cols.APP_ID + " INT REFERENCES " + AppTable.NAME + "(" + AppTable.Cols.ROW_ID + ") ON DELETE CASCADE, " + AppPrefsTable.Cols.APP_ID + " INT REFERENCES " + AppTable.NAME + "(" + AppTable.Cols.ROW_ID + ") ON DELETE CASCADE, "
+ AppPrefsTable.Cols.IGNORE_THIS_UPDATE+ " INT BOOLEAN NOT NULL, " + AppPrefsTable.Cols.IGNORE_THIS_UPDATE + " INT BOOLEAN NOT NULL, "
+ AppPrefsTable.Cols.IGNORE_ALL_UPDATES + " INT NOT NULL " + AppPrefsTable.Cols.IGNORE_ALL_UPDATES + " INT NOT NULL "
+ " );"; + " );";
@ -305,7 +305,7 @@ class DBHelper extends SQLiteOpenHelper {
// The other tables are transient and can just be reset. Do this after // The other tables are transient and can just be reset. Do this after
// the repo table changes though, because it also clears the lastetag // the repo table changes though, because it also clears the lastetag
// fields which didn't always exist. // fields which didn't always exist.
resetTransient(db, oldVersion); resetTransientPre42(db, oldVersion);
addNameAndDescriptionToRepo(db, oldVersion); addNameAndDescriptionToRepo(db, oldVersion);
addFingerprintToRepo(db, oldVersion); addFingerprintToRepo(db, oldVersion);
@ -672,6 +672,17 @@ class DBHelper extends SQLiteOpenHelper {
} }
private void resetTransient(SQLiteDatabase db, int oldVersion) { private void resetTransient(SQLiteDatabase db, int oldVersion) {
context.getSharedPreferences("FDroid", Context.MODE_PRIVATE).edit()
.putBoolean("triedEmptyUpdate", false).apply();
db.execSQL("drop table " + AppTable.NAME);
db.execSQL("drop table " + ApkTable.NAME);
clearRepoEtags(db);
db.execSQL(CREATE_TABLE_APP);
db.execSQL(CREATE_TABLE_APK);
ensureIndexes(db);
}
private void resetTransientPre42(SQLiteDatabase db, int oldVersion) {
// Before version 42, only transient info was stored in here. As of some time // Before version 42, only transient info was stored in here. As of some time
// just before 42 (F-Droid 0.60ish) it now has "ignore this version" info which // just before 42 (F-Droid 0.60ish) it now has "ignore this version" info which
// was is specified by the user. We don't want to weely-neely nuke that data. // was is specified by the user. We don't want to weely-neely nuke that data.
@ -681,7 +692,7 @@ class DBHelper extends SQLiteOpenHelper {
return; return;
} }
context.getSharedPreferences("FDroid", Context.MODE_PRIVATE).edit() context.getSharedPreferences("FDroid", Context.MODE_PRIVATE).edit()
.putBoolean("triedEmptyUpdate", false).commit(); .putBoolean("triedEmptyUpdate", false).apply();
db.execSQL("drop table " + AppTable.NAME); db.execSQL("drop table " + AppTable.NAME);
db.execSQL("drop table " + ApkTable.NAME); db.execSQL("drop table " + ApkTable.NAME);
clearRepoEtags(db); clearRepoEtags(db);

View File

@ -18,7 +18,7 @@ public interface Schema {
String IGNORE_ALL_UPDATES = "ignoreAllUpdates"; String IGNORE_ALL_UPDATES = "ignoreAllUpdates";
String IGNORE_THIS_UPDATE = "ignoreThisUpdate"; String IGNORE_THIS_UPDATE = "ignoreThisUpdate";
String[] ALL = {APP_ID, IGNORE_ALL_UPDATES, IGNORE_THIS_UPDATE,}; String[] ALL = {APP_ID, IGNORE_ALL_UPDATES, IGNORE_THIS_UPDATE};
} }
} }

View File

@ -4,8 +4,6 @@ import android.app.Application;
import org.fdroid.fdroid.Assert; import org.fdroid.fdroid.Assert;
import org.fdroid.fdroid.BuildConfig; import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.TestUtils;
import org.fdroid.fdroid.data.Schema.AppPrefsTable.Cols;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -13,7 +11,7 @@ import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config; import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowContentResolver; import org.robolectric.shadows.ShadowContentResolver;
import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@ -22,8 +20,6 @@ import static org.junit.Assert.assertNull;
@RunWith(RobolectricGradleTestRunner.class) @RunWith(RobolectricGradleTestRunner.class)
public class AppPrefsProviderTest extends FDroidProviderTest { public class AppPrefsProviderTest extends FDroidProviderTest {
private static final String[] PROJ = Cols.ALL;
@Before @Before
public void setup() { public void setup() {
ShadowContentResolver.registerProvider(AppProvider.getAuthority(), new AppProvider()); ShadowContentResolver.registerProvider(AppProvider.getAuthority(), new AppProvider());