checkstyle: Finally add proper indentation checks

Somewhat painful conversion, but should go much smoother from here
onward.
This commit is contained in:
Daniel Martí 2015-12-29 22:00:23 +01:00
parent dd4420965d
commit 9efe173380
22 changed files with 725 additions and 716 deletions

View File

@ -114,7 +114,7 @@ public class IntentIntegrator {
public static final String DEFAULT_TITLE = "Install Barcode Scanner?"; public static final String DEFAULT_TITLE = "Install Barcode Scanner?";
public static final String DEFAULT_MESSAGE = public static final String DEFAULT_MESSAGE =
"This application requires Barcode Scanner. Would you like to install it?"; "This application requires Barcode Scanner. Would you like to install it?";
public static final String DEFAULT_YES = "Yes"; public static final String DEFAULT_YES = "Yes";
public static final String DEFAULT_NO = "No"; public static final String DEFAULT_NO = "No";
@ -124,8 +124,8 @@ public class IntentIntegrator {
// supported barcode formats // supported barcode formats
public static final Collection<String> PRODUCT_CODE_TYPES = list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "RSS_14"); public static final Collection<String> PRODUCT_CODE_TYPES = list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "RSS_14");
public static final Collection<String> ONE_D_CODE_TYPES = public static final Collection<String> ONE_D_CODE_TYPES =
list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128", list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128",
"ITF", "RSS_14", "RSS_EXPANDED"); "ITF", "RSS_14", "RSS_EXPANDED");
public static final Collection<String> QR_CODE_TYPES = Collections.singleton("QR_CODE"); public static final Collection<String> QR_CODE_TYPES = Collections.singleton("QR_CODE");
public static final Collection<String> DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX"); public static final Collection<String> DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX");

View File

@ -201,7 +201,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
return getString(R.string.app_inst_unknown_source); return getString(R.string.app_inst_unknown_source);
} }
final String installerLabel = InstalledAppProvider final String installerLabel = InstalledAppProvider
.getApplicationLabel(mctx, installerPkgName); .getApplicationLabel(mctx, installerPkgName);
return getString(R.string.app_inst_known_source, installerLabel); return getString(R.string.app_inst_known_source, installerLabel);
} }
@ -283,9 +283,9 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
if (apk.incompatibleReasons != null) { if (apk.incompatibleReasons != null) {
holder.incompatibleReasons.setText( holder.incompatibleReasons.setText(
getResources().getString( getResources().getString(
R.string.requires_features, R.string.requires_features,
apk.incompatibleReasons.toPrettyString())); apk.incompatibleReasons.toPrettyString()));
holder.incompatibleReasons.setVisibility(View.VISIBLE); holder.incompatibleReasons.setVisibility(View.VISIBLE);
} else { } else {
holder.incompatibleReasons.setVisibility(View.GONE); holder.incompatibleReasons.setVisibility(View.GONE);

View File

@ -399,7 +399,7 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
public void removeNotification(int id) { public void removeNotification(int id) {
NotificationManager nMgr = (NotificationManager) getBaseContext() NotificationManager nMgr = (NotificationManager) getBaseContext()
.getSystemService(Context.NOTIFICATION_SERVICE); .getSystemService(Context.NOTIFICATION_SERVICE);
nMgr.cancel(id); nMgr.cancel(id);
} }

View File

@ -270,23 +270,23 @@ public class FDroidApp extends Application {
bluetoothAdapter = getBluetoothAdapter(); bluetoothAdapter = getBluetoothAdapter();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.imageDownloader(new IconDownloader(getApplicationContext())) .imageDownloader(new IconDownloader(getApplicationContext()))
.diskCache(new LimitedAgeDiskCache( .diskCache(new LimitedAgeDiskCache(
new File(StorageUtils.getCacheDirectory(getApplicationContext(), true), new File(StorageUtils.getCacheDirectory(getApplicationContext(), true),
"icons"), "icons"),
null, null,
new FileNameGenerator() { new FileNameGenerator() {
@Override @Override
public String generate(String imageUri) { public String generate(String imageUri) {
return imageUri.substring( return imageUri.substring(
imageUri.lastIndexOf('/') + 1); imageUri.lastIndexOf('/') + 1);
} }, } },
// 30 days in secs: 30*24*60*60 = 2592000 // 30 days in secs: 30*24*60*60 = 2592000
2592000) 2592000)
) )
.threadPoolSize(4) .threadPoolSize(4)
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1 .threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
.build(); .build();
ImageLoader.getInstance().init(config); ImageLoader.getInstance().init(config);
// TODO reintroduce PinningTrustManager and MemorizingTrustManager // TODO reintroduce PinningTrustManager and MemorizingTrustManager

View File

@ -317,7 +317,7 @@ public class RepoUpdater {
String fingerprintFromIndexXml = Utils.calcFingerprint(certFromIndexXml); String fingerprintFromIndexXml = Utils.calcFingerprint(certFromIndexXml);
String fingerprintFromJar = Utils.calcFingerprint(rawCertFromJar); String fingerprintFromJar = Utils.calcFingerprint(rawCertFromJar);
if (!repo.fingerprint.equalsIgnoreCase(fingerprintFromIndexXml) if (!repo.fingerprint.equalsIgnoreCase(fingerprintFromIndexXml)
|| !repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) { || !repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) {
throw new SigningException(repo, "Supplied certificate fingerprint does not match!"); throw new SigningException(repo, "Supplied certificate fingerprint does not match!");
} }
} // else - no info to check things are valid, so just Trust On First Use } // else - no info to check things are valid, so just Trust On First Use
@ -347,14 +347,14 @@ public class RepoUpdater {
// repo and repo.pubkey must be pre-loaded from the database // repo and repo.pubkey must be pre-loaded from the database
if (TextUtils.isEmpty(repo.pubkey) if (TextUtils.isEmpty(repo.pubkey)
|| TextUtils.isEmpty(certFromJar) || TextUtils.isEmpty(certFromJar)
|| TextUtils.isEmpty(certFromIndexXml)) || TextUtils.isEmpty(certFromIndexXml))
throw new SigningException(repo, "A empty repo or signing certificate is invalid!"); throw new SigningException(repo, "A empty repo or signing certificate is invalid!");
// though its called repo.pubkey, its actually a X509 certificate // though its called repo.pubkey, its actually a X509 certificate
if (repo.pubkey.equals(certFromJar) if (repo.pubkey.equals(certFromJar)
&& repo.pubkey.equals(certFromIndexXml) && repo.pubkey.equals(certFromIndexXml)
&& certFromIndexXml.equals(certFromJar)) { && certFromIndexXml.equals(certFromJar)) {
return; // we have a match! return; // we have a match!
} }
throw new SigningException(repo, "Signing certificate does not match!"); throw new SigningException(repo, "Signing certificate does not match!");

View File

@ -101,7 +101,7 @@ public class UpdateService extends IntentService implements ProgressListener {
public static void schedule(Context ctx) { public static void schedule(Context ctx) {
SharedPreferences prefs = PreferenceManager SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(ctx); .getDefaultSharedPreferences(ctx);
String sint = prefs.getString(Preferences.PREF_UPD_INTERVAL, "0"); String sint = prefs.getString(Preferences.PREF_UPD_INTERVAL, "0");
int interval = Integer.parseInt(sint); int interval = Integer.parseInt(sint);
@ -109,12 +109,12 @@ public class UpdateService extends IntentService implements ProgressListener {
PendingIntent pending = PendingIntent.getService(ctx, 0, intent, 0); PendingIntent pending = PendingIntent.getService(ctx, 0, intent, 0);
AlarmManager alarm = (AlarmManager) ctx AlarmManager alarm = (AlarmManager) ctx
.getSystemService(Context.ALARM_SERVICE); .getSystemService(Context.ALARM_SERVICE);
alarm.cancel(pending); alarm.cancel(pending);
if (interval > 0) { if (interval > 0) {
alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() + 5000, SystemClock.elapsedRealtime() + 5000,
AlarmManager.INTERVAL_HOUR, pending); AlarmManager.INTERVAL_HOUR, pending);
Utils.debugLog(TAG, "Update scheduler alarm set"); Utils.debugLog(TAG, "Update scheduler alarm set");
} else { } else {
Utils.debugLog(TAG, "Update scheduler alarm not set"); Utils.debugLog(TAG, "Update scheduler alarm not set");
@ -128,17 +128,17 @@ public class UpdateService extends IntentService implements ProgressListener {
localBroadcastManager = LocalBroadcastManager.getInstance(this); localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.registerReceiver(downloadProgressReceiver, localBroadcastManager.registerReceiver(downloadProgressReceiver,
new IntentFilter(Downloader.LOCAL_ACTION_PROGRESS)); new IntentFilter(Downloader.LOCAL_ACTION_PROGRESS));
localBroadcastManager.registerReceiver(updateStatusReceiver, localBroadcastManager.registerReceiver(updateStatusReceiver,
new IntentFilter(LOCAL_ACTION_STATUS)); new IntentFilter(LOCAL_ACTION_STATUS));
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationBuilder = new NotificationCompat.Builder(this) notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_refresh_white) .setSmallIcon(R.drawable.ic_refresh_white)
.setOngoing(true) .setOngoing(true)
.setCategory(NotificationCompat.CATEGORY_SERVICE) .setCategory(NotificationCompat.CATEGORY_SERVICE)
.setContentTitle(getString(R.string.update_notification_title)); .setContentTitle(getString(R.string.update_notification_title));
// Android docs are a little sketchy, however it seems that Gingerbread is the last // Android docs are a little sketchy, however it seems that Gingerbread is the last
// sdk that made a content intent mandatory: // sdk that made a content intent mandatory:
@ -302,7 +302,7 @@ public class UpdateService extends IntentService implements ProgressListener {
long elapsed = System.currentTimeMillis() - lastUpdate; long elapsed = System.currentTimeMillis() - lastUpdate;
if (elapsed < interval * 60 * 60 * 1000) { if (elapsed < interval * 60 * 60 * 1000) {
Log.i(TAG, "Skipping update - done " + elapsed Log.i(TAG, "Skipping update - done " + elapsed
+ "ms ago, interval is " + interval + " hours"); + "ms ago, interval is " + interval + " hours");
return false; return false;
} }
@ -322,7 +322,7 @@ public class UpdateService extends IntentService implements ProgressListener {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (activeNetwork.getType() != ConnectivityManager.TYPE_WIFI if (activeNetwork.getType() != ConnectivityManager.TYPE_WIFI
&& prefs.getBoolean(Preferences.PREF_UPD_WIFI_ONLY, false)) { && prefs.getBoolean(Preferences.PREF_UPD_WIFI_ONLY, false)) {
Log.i(TAG, "Skipping update - wifi not available"); Log.i(TAG, "Skipping update - wifi not available");
return false; return false;
} }
@ -431,9 +431,9 @@ public class UpdateService extends IntentService implements ProgressListener {
private void performUpdateNotification() { private void performUpdateNotification() {
Cursor cursor = getContentResolver().query( Cursor cursor = getContentResolver().query(
AppProvider.getCanUpdateUri(), AppProvider.getCanUpdateUri(),
AppProvider.DataColumns.ALL, AppProvider.DataColumns.ALL,
null, null, null); null, null, null);
if (cursor != null) { if (cursor != null) {
if (cursor.getCount() > 0) { if (cursor.getCount() > 0) {
showAppUpdatesNotification(cursor); showAppUpdatesNotification(cursor);
@ -445,8 +445,8 @@ public class UpdateService extends IntentService implements ProgressListener {
private PendingIntent createNotificationIntent() { private PendingIntent createNotificationIntent() {
Intent notifyIntent = new Intent(this, FDroid.class).putExtra(FDroid.EXTRA_TAB_UPDATE, true); Intent notifyIntent = new Intent(this, FDroid.class).putExtra(FDroid.EXTRA_TAB_UPDATE, true);
TaskStackBuilder stackBuilder = TaskStackBuilder TaskStackBuilder stackBuilder = TaskStackBuilder
.create(this).addParentStack(FDroid.class) .create(this).addParentStack(FDroid.class)
.addNextIntent(notifyIntent); .addNextIntent(notifyIntent);
return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); return stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
} }
@ -455,8 +455,8 @@ public class UpdateService extends IntentService implements ProgressListener {
private NotificationCompat.Style createNotificationBigStyle(Cursor hasUpdates) { private NotificationCompat.Style createNotificationBigStyle(Cursor hasUpdates) {
final String contentText = hasUpdates.getCount() > 1 final String contentText = hasUpdates.getCount() > 1
? getString(R.string.many_updates_available, hasUpdates.getCount()) ? getString(R.string.many_updates_available, hasUpdates.getCount())
: getString(R.string.one_update_available); : getString(R.string.one_update_available);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(contentText); inboxStyle.setBigContentTitle(contentText);
@ -481,17 +481,17 @@ public class UpdateService extends IntentService implements ProgressListener {
final int icon = Build.VERSION.SDK_INT >= 11 ? R.drawable.ic_stat_notify_updates : R.drawable.ic_launcher; final int icon = Build.VERSION.SDK_INT >= 11 ? R.drawable.ic_stat_notify_updates : R.drawable.ic_launcher;
final String contentText = hasUpdates.getCount() > 1 final String contentText = hasUpdates.getCount() > 1
? getString(R.string.many_updates_available, hasUpdates.getCount()) ? getString(R.string.many_updates_available, hasUpdates.getCount())
: getString(R.string.one_update_available); : getString(R.string.one_update_available);
NotificationCompat.Builder builder = NotificationCompat.Builder builder =
new NotificationCompat.Builder(this) new NotificationCompat.Builder(this)
.setAutoCancel(true) .setAutoCancel(true)
.setContentTitle(getString(R.string.fdroid_updates_available)) .setContentTitle(getString(R.string.fdroid_updates_available))
.setSmallIcon(icon) .setSmallIcon(icon)
.setContentIntent(createNotificationIntent()) .setContentIntent(createNotificationIntent())
.setContentText(contentText) .setContentText(contentText)
.setStyle(createNotificationBigStyle(hasUpdates)); .setStyle(createNotificationBigStyle(hasUpdates));
notificationManager.notify(NOTIFY_ID_UPDATES_AVAILABLE, builder.build()); notificationManager.notify(NOTIFY_ID_UPDATES_AVAILABLE, builder.build());
} }

View File

@ -667,7 +667,7 @@ public final class Utils {
for (File f : files) { for (File f : files) {
if ((startsWith != null && f.getName().startsWith(startsWith)) if ((startsWith != null && f.getName().startsWith(startsWith))
|| (endsWith != null && f.getName().endsWith(endsWith))) { || (endsWith != null && f.getName().endsWith(endsWith))) {
if (!f.delete()) { if (!f.delete()) {
Log.w(TAG, "Couldn't delete cache file " + f); Log.w(TAG, "Couldn't delete cache file " + f);
} }

View File

@ -48,26 +48,27 @@ public class TabManager {
for (int i = 0; i < pager.getAdapter().getCount(); i++) { for (int i = 0; i < pager.getAdapter().getCount(); i++) {
CharSequence label = pager.getAdapter().getPageTitle(i); CharSequence label = pager.getAdapter().getPageTitle(i);
actionBar.addTab( actionBar.addTab(
actionBar.newTab() actionBar.newTab()
.setText(label) .setText(label)
.setTabListener(new ActionBar.TabListener() { .setTabListener(new ActionBar.TabListener() {
@Override @Override
public void onTabSelected(ActionBar.Tab tab, public void onTabSelected(ActionBar.Tab tab,
FragmentTransaction ft) { FragmentTransaction ft) {
int pos = tab.getPosition(); int pos = tab.getPosition();
pager.setCurrentItem(pos); pager.setCurrentItem(pos);
if (pos == INDEX_CAN_UPDATE) if (pos == INDEX_CAN_UPDATE)
removeNotification(1); removeNotification(1);
} }
@Override @Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
} }
@Override @Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
} }
})); })
);
} }
} }

View File

@ -325,9 +325,9 @@ public class AppProvider extends FDroidProvider {
public void naturalJoinToInstalledTable() { public void naturalJoinToInstalledTable() {
if (!requiresInstalledTable) { if (!requiresInstalledTable) {
join( join(
DBHelper.TABLE_INSTALLED_APP, DBHelper.TABLE_INSTALLED_APP,
"installed", "installed",
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id"); "installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
requiresInstalledTable = true; requiresInstalledTable = true;
} }
} }
@ -335,9 +335,9 @@ public class AppProvider extends FDroidProvider {
public void leftJoinToInstalledTable() { public void leftJoinToInstalledTable() {
if (!requiresInstalledTable) { if (!requiresInstalledTable) {
leftJoin( leftJoin(
DBHelper.TABLE_INSTALLED_APP, DBHelper.TABLE_INSTALLED_APP,
"installed", "installed",
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id"); "installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
requiresInstalledTable = true; requiresInstalledTable = true;
} }
} }
@ -376,16 +376,16 @@ public class AppProvider extends FDroidProvider {
private void addSuggestedApkVersionField() { private void addSuggestedApkVersionField() {
addSuggestedApkField( addSuggestedApkField(
ApkProvider.DataColumns.VERSION, ApkProvider.DataColumns.VERSION,
DataColumns.SuggestedApk.VERSION); DataColumns.SuggestedApk.VERSION);
} }
private void addSuggestedApkField(String fieldName, String alias) { private void addSuggestedApkField(String fieldName, String alias) {
if (!isSuggestedApkTableAdded) { if (!isSuggestedApkTableAdded) {
isSuggestedApkTableAdded = true; isSuggestedApkTableAdded = true;
leftJoin( leftJoin(
getApkTableName(), getApkTableName(),
"suggestedApk", "suggestedApk",
getTableName() + ".suggestedVercode = suggestedApk.vercode AND " + getTableName() + ".id = suggestedApk.id"); getTableName() + ".suggestedVercode = suggestedApk.vercode AND " + getTableName() + ".id = suggestedApk.id");
} }
appendField(fieldName, "suggestedApk", alias); appendField(fieldName, "suggestedApk", alias);
@ -393,8 +393,8 @@ public class AppProvider extends FDroidProvider {
private void addInstalledAppVersionName() { private void addInstalledAppVersionName() {
addInstalledAppField( addInstalledAppField(
InstalledAppProvider.DataColumns.VERSION_NAME, InstalledAppProvider.DataColumns.VERSION_NAME,
DataColumns.InstalledApp.VERSION_NAME DataColumns.InstalledApp.VERSION_NAME
); );
} }
@ -904,7 +904,7 @@ public class AppProvider extends FDroidProvider {
final String app = getTableName(); final String app = getTableName();
String updateSql = String updateSql =
"UPDATE " + app + " SET compatible = ( " + "UPDATE " + app + " SET compatible = ( " +
" SELECT TOTAL( " + apk + ".compatible ) > 0 " + " SELECT TOTAL( " + apk + ".compatible ) > 0 " +
" FROM " + apk + " FROM " + apk +
" WHERE " + apk + ".id = " + app + ".id );"; " WHERE " + apk + ".id = " + app + ".id );";
@ -941,14 +941,14 @@ public class AppProvider extends FDroidProvider {
final boolean unstableUpdates = Preferences.get().getUnstableUpdates(); final boolean unstableUpdates = Preferences.get().getUnstableUpdates();
String restrictToStable = unstableUpdates ? "" : (apk + ".vercode <= " + app + ".upstreamVercode AND "); String restrictToStable = unstableUpdates ? "" : (apk + ".vercode <= " + app + ".upstreamVercode AND ");
String updateSql = String updateSql =
"UPDATE " + app + " SET suggestedVercode = ( " + "UPDATE " + app + " SET suggestedVercode = ( " +
" SELECT MAX( " + apk + ".vercode ) " + " SELECT MAX( " + apk + ".vercode ) " +
" FROM " + apk + " FROM " + apk +
" WHERE " + " WHERE " +
app + ".id = " + apk + ".id AND " + app + ".id = " + apk + ".id AND " +
restrictToStable + restrictToStable +
" ( " + app + ".compatible = 0 OR " + apk + ".compatible = 1 ) ) " + " ( " + app + ".compatible = 0 OR " + apk + ".compatible = 1 ) ) " +
" WHERE upstreamVercode > 0 "; " WHERE upstreamVercode > 0 ";
write().execSQL(updateSql); write().execSQL(updateSql);
} }
@ -980,13 +980,13 @@ public class AppProvider extends FDroidProvider {
final String app = getTableName(); final String app = getTableName();
String updateSql = String updateSql =
"UPDATE " + app + " SET suggestedVercode = ( " + "UPDATE " + app + " SET suggestedVercode = ( " +
" SELECT MAX( " + apk + ".vercode ) " + " SELECT MAX( " + apk + ".vercode ) " +
" FROM " + apk + " FROM " + apk +
" WHERE " + " WHERE " +
app + ".id = " + apk + ".id AND " + app + ".id = " + apk + ".id AND " +
" ( " + app + ".compatible = 0 OR " + apk + ".compatible = 1 ) ) " + " ( " + app + ".compatible = 0 OR " + apk + ".compatible = 1 ) ) " +
" WHERE upstreamVercode = 0 OR upstreamVercode IS NULL OR suggestedVercode IS NULL "; " WHERE upstreamVercode = 0 OR upstreamVercode IS NULL OR suggestedVercode IS NULL ";
write().execSQL(updateSql); write().execSQL(updateSql);
} }
@ -1022,7 +1022,7 @@ public class AppProvider extends FDroidProvider {
final String repo = DBHelper.TABLE_REPO; final String repo = DBHelper.TABLE_REPO;
final String iconUrlQuery = final String iconUrlQuery =
" SELECT " + " SELECT " +
// Concatenate (using the "||" operator) the address, the // Concatenate (using the "||" operator) the address, the
// icons directory (bound to the ? as the second parameter // icons directory (bound to the ? as the second parameter
@ -1039,10 +1039,10 @@ public class AppProvider extends FDroidProvider {
" || " + " || " +
app + ".icon " + app + ".icon " +
") " + ") " +
" FROM " + " FROM " +
apk + apk +
" JOIN " + repo + " ON (" + repo + "._id = " + apk + ".repo) " + " JOIN " + repo + " ON (" + repo + "._id = " + apk + ".repo) " +
" WHERE " + " WHERE " +
app + ".id = " + apk + ".id AND " + app + ".id = " + apk + ".id AND " +
apk + ".vercode = ( " + apk + ".vercode = ( " +

View File

@ -198,53 +198,53 @@ public class DBHelper extends SQLiteOpenHelper {
db.execSQL(CREATE_TABLE_REPO); db.execSQL(CREATE_TABLE_REPO);
insertRepo( insertRepo(
db, db,
context.getString(R.string.fdroid_repo_name), context.getString(R.string.fdroid_repo_name),
context.getString(R.string.fdroid_repo_address), context.getString(R.string.fdroid_repo_address),
context.getString(R.string.fdroid_repo_description), context.getString(R.string.fdroid_repo_description),
context.getString(R.string.fdroid_repo_pubkey), context.getString(R.string.fdroid_repo_pubkey),
context.getResources().getInteger(R.integer.fdroid_repo_version), context.getResources().getInteger(R.integer.fdroid_repo_version),
context.getResources().getInteger(R.integer.fdroid_repo_inuse), context.getResources().getInteger(R.integer.fdroid_repo_inuse),
context.getResources().getInteger(R.integer.fdroid_repo_priority) context.getResources().getInteger(R.integer.fdroid_repo_priority)
); );
insertRepo( insertRepo(
db, db,
context.getString(R.string.fdroid_archive_name), context.getString(R.string.fdroid_archive_name),
context.getString(R.string.fdroid_archive_address), context.getString(R.string.fdroid_archive_address),
context.getString(R.string.fdroid_archive_description), context.getString(R.string.fdroid_archive_description),
context.getString(R.string.fdroid_archive_pubkey), context.getString(R.string.fdroid_archive_pubkey),
context.getResources().getInteger(R.integer.fdroid_archive_version), context.getResources().getInteger(R.integer.fdroid_archive_version),
context.getResources().getInteger(R.integer.fdroid_archive_inuse), context.getResources().getInteger(R.integer.fdroid_archive_inuse),
context.getResources().getInteger(R.integer.fdroid_archive_priority) context.getResources().getInteger(R.integer.fdroid_archive_priority)
); );
insertRepo( insertRepo(
db, db,
context.getString(R.string.guardianproject_repo_name), context.getString(R.string.guardianproject_repo_name),
context.getString(R.string.guardianproject_repo_address), context.getString(R.string.guardianproject_repo_address),
context.getString(R.string.guardianproject_repo_description), context.getString(R.string.guardianproject_repo_description),
context.getString(R.string.guardianproject_repo_pubkey), context.getString(R.string.guardianproject_repo_pubkey),
context.getResources().getInteger(R.integer.guardianproject_repo_version), context.getResources().getInteger(R.integer.guardianproject_repo_version),
context.getResources().getInteger(R.integer.guardianproject_repo_inuse), context.getResources().getInteger(R.integer.guardianproject_repo_inuse),
context.getResources().getInteger(R.integer.guardianproject_repo_priority) context.getResources().getInteger(R.integer.guardianproject_repo_priority)
); );
insertRepo( insertRepo(
db, db,
context.getString(R.string.guardianproject_archive_name), context.getString(R.string.guardianproject_archive_name),
context.getString(R.string.guardianproject_archive_address), context.getString(R.string.guardianproject_archive_address),
context.getString(R.string.guardianproject_archive_description), context.getString(R.string.guardianproject_archive_description),
context.getString(R.string.guardianproject_archive_pubkey), context.getString(R.string.guardianproject_archive_pubkey),
context.getResources().getInteger(R.integer.guardianproject_archive_version), context.getResources().getInteger(R.integer.guardianproject_archive_version),
context.getResources().getInteger(R.integer.guardianproject_archive_inuse), context.getResources().getInteger(R.integer.guardianproject_archive_inuse),
context.getResources().getInteger(R.integer.guardianproject_archive_priority) context.getResources().getInteger(R.integer.guardianproject_archive_priority)
); );
} }
private void insertRepo( private void insertRepo(SQLiteDatabase db, String name, String address,
SQLiteDatabase db, String name, String address, String description, String description, String pubKey, int version, int inUse,
String pubKey, int version, int inUse, int priority) { int priority) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(RepoProvider.DataColumns.ADDRESS, address); values.put(RepoProvider.DataColumns.ADDRESS, address);

View File

@ -112,7 +112,7 @@ public class InstalledAppCacheUpdater {
Map<String, Integer> cachedInfo = InstalledAppProvider.Helper.all(context); Map<String, Integer> cachedInfo = InstalledAppProvider.Helper.all(context);
List<PackageInfo> installedPackages = context.getPackageManager() List<PackageInfo> installedPackages = context.getPackageManager()
.getInstalledPackages(PackageManager.GET_SIGNATURES); .getInstalledPackages(PackageManager.GET_SIGNATURES);
for (PackageInfo appInfo : installedPackages) { for (PackageInfo appInfo : installedPackages) {
toInsert.add(appInfo); toInsert.add(appInfo);
if (cachedInfo.containsKey(appInfo.packageName)) { if (cachedInfo.containsKey(appInfo.packageName)) {
@ -134,14 +134,14 @@ public class InstalledAppCacheUpdater {
Uri uri = InstalledAppProvider.getContentUri(); Uri uri = InstalledAppProvider.getContentUri();
for (PackageInfo info : appsToInsert) { for (PackageInfo info : appsToInsert) {
ContentProviderOperation op = ContentProviderOperation.newInsert(uri) ContentProviderOperation op = ContentProviderOperation.newInsert(uri)
.withValue(InstalledAppProvider.DataColumns.PACKAGE_NAME, info.packageName) .withValue(InstalledAppProvider.DataColumns.PACKAGE_NAME, info.packageName)
.withValue(InstalledAppProvider.DataColumns.VERSION_CODE, info.versionCode) .withValue(InstalledAppProvider.DataColumns.VERSION_CODE, info.versionCode)
.withValue(InstalledAppProvider.DataColumns.VERSION_NAME, info.versionName) .withValue(InstalledAppProvider.DataColumns.VERSION_NAME, info.versionName)
.withValue(InstalledAppProvider.DataColumns.APPLICATION_LABEL, .withValue(InstalledAppProvider.DataColumns.APPLICATION_LABEL,
InstalledAppProvider.getApplicationLabel(context, info.packageName)) InstalledAppProvider.getApplicationLabel(context, info.packageName))
.withValue(InstalledAppProvider.DataColumns.SIGNATURE, .withValue(InstalledAppProvider.DataColumns.SIGNATURE,
InstalledAppProvider.getPackageSig(info)) InstalledAppProvider.getPackageSig(info))
.build(); .build();
ops.add(op); ops.add(op);
} }
} }

View File

@ -42,8 +42,8 @@ public class InstalledAppProvider extends FDroidProvider {
cursor.moveToFirst(); cursor.moveToFirst();
while (!cursor.isAfterLast()) { while (!cursor.isAfterLast()) {
cachedInfo.put( cachedInfo.put(
cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME)), cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME)),
cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE)) cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE))
); );
cursor.moveToNext(); cursor.moveToNext();
} }

View File

@ -439,7 +439,7 @@ public class AppSecurityPermissions {
// Dangerous and normal permissions are always shown to the user if the permission // Dangerous and normal permissions are always shown to the user if the permission
// is required, or it was previously granted // is required, or it was previously granted
if ((isNormal || isDangerous) && (isRequired || wasGranted || isGranted || if ((isNormal || isDangerous) && (isRequired || wasGranted || isGranted ||
Build.VERSION.SDK_INT < 16)) { Build.VERSION.SDK_INT < 16)) {
return true; return true;
} }

View File

@ -90,7 +90,7 @@ public abstract class AppListAdapter extends CursorAdapter {
holder.summary.setText(app.summary); holder.summary.setText(app.summary);
ImageLoader.getInstance().displayImage(app.iconUrl, holder.icon, ImageLoader.getInstance().displayImage(app.iconUrl, holder.icon,
displayImageOptions); displayImageOptions);
holder.status.setText(getVersionInfo(app)); holder.status.setText(getVersionInfo(app));
holder.license.setText(app.license); holder.license.setText(app.license);

View File

@ -230,13 +230,13 @@ public class ManageReposActivity extends ActionBarActivity {
addRepoDialog.setTitle(R.string.repo_add_title); addRepoDialog.setTitle(R.string.repo_add_title);
addRepoDialog.setButton(DialogInterface.BUTTON_NEGATIVE, addRepoDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
getString(R.string.cancel), getString(R.string.cancel),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); dialog.dismiss();
} }
}); });
// HACK: // HACK:
// After adding a new repo, need to show feedback to the user. // After adding a new repo, need to show feedback to the user.
@ -252,58 +252,58 @@ public class ManageReposActivity extends ActionBarActivity {
// //
// Thus, the hack described at http://stackoverflow.com/a/15619098 is implemented. // Thus, the hack described at http://stackoverflow.com/a/15619098 is implemented.
addRepoDialog.setButton(DialogInterface.BUTTON_POSITIVE, addRepoDialog.setButton(DialogInterface.BUTTON_POSITIVE,
getString(R.string.repo_add_add), getString(R.string.repo_add_add),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
} }
}); });
addRepoDialog.show(); addRepoDialog.show();
// This must be *after* addRepoDialog.show() otherwise getButtion() returns null: // This must be *after* addRepoDialog.show() otherwise getButtion() returns null:
// https://code.google.com/p/android/issues/detail?id=6360 // https://code.google.com/p/android/issues/detail?id=6360
addRepoDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener( addRepoDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
String url = uriEditText.getText().toString(); String url = uriEditText.getText().toString();
try { try {
url = normalizeUrl(url); url = normalizeUrl(url);
} catch (URISyntaxException e) { } catch (URISyntaxException e) {
invalidUrl(); invalidUrl();
return; return;
} }
String fp = fingerprintEditText.getText().toString(); String fp = fingerprintEditText.getText().toString();
switch (addRepoState) { switch (addRepoState) {
case DOESNT_EXIST: case DOESNT_EXIST:
prepareToCreateNewRepo(url, fp); prepareToCreateNewRepo(url, fp);
break; break;
case IS_SWAP: case IS_SWAP:
Utils.debugLog(TAG, "Removing existing swap repo " + url + " before adding new repo."); Utils.debugLog(TAG, "Removing existing swap repo " + url + " before adding new repo.");
Repo repo = RepoProvider.Helper.findByAddress(context, url); Repo repo = RepoProvider.Helper.findByAddress(context, url);
RepoProvider.Helper.remove(context, repo.getId()); RepoProvider.Helper.remove(context, repo.getId());
prepareToCreateNewRepo(url, fp); prepareToCreateNewRepo(url, fp);
break; break;
case EXISTS_DISABLED: case EXISTS_DISABLED:
case EXISTS_UPGRADABLE_TO_SIGNED: case EXISTS_UPGRADABLE_TO_SIGNED:
case EXISTS_FINGERPRINT_MATCH: case EXISTS_FINGERPRINT_MATCH:
updateAndEnableExistingRepo(url, fp); updateAndEnableExistingRepo(url, fp);
finishedAddingRepo(); finishedAddingRepo();
break; break;
default: default:
finishedAddingRepo(); finishedAddingRepo();
break; break;
}
} }
} }
}
); );
addButton = addRepoDialog.getButton(DialogInterface.BUTTON_POSITIVE); addButton = addRepoDialog.getButton(DialogInterface.BUTTON_POSITIVE);

View File

@ -127,12 +127,12 @@ public class AvailableAppsFragment extends AppListFragment implements
categories = AppProvider.Helper.categories(getActivity()); categories = AppProvider.Helper.categories(getActivity());
ArrayAdapter<String> adapter = new ArrayAdapter<>( ArrayAdapter<String> adapter = new ArrayAdapter<>(
getActivity(), android.R.layout.simple_spinner_item, translateCategories(categories)); getActivity(), android.R.layout.simple_spinner_item, translateCategories(categories));
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
categorySpinner.setAdapter(adapter); categorySpinner.setAdapter(adapter);
getActivity().getContentResolver().registerContentObserver( getActivity().getContentResolver().registerContentObserver(
AppProvider.getContentUri(), false, new CategoryObserver(adapter)); AppProvider.getContentUri(), false, new CategoryObserver(adapter));
categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override

View File

@ -197,7 +197,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertTotalApkCount(20); assertTotalApkCount(20);
Cursor cursor = getMockContentResolver().query( Cursor cursor = getMockContentResolver().query(
ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null); ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null);
assertResultCount(10, cursor); assertResultCount(10, cursor);
assertBelongsToRepo(cursor, REPO_DELETE); assertBelongsToRepo(cursor, REPO_DELETE);
cursor.close(); cursor.close();
@ -207,7 +207,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertTotalApkCount(10); assertTotalApkCount(10);
cursor = getMockContentResolver().query( cursor = getMockContentResolver().query(
ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null); ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null);
assertResultCount(0, cursor); assertResultCount(0, cursor);
cursor.close(); cursor.close();

View File

@ -64,9 +64,9 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
try { try {
getMockContentResolver().update( getMockContentResolver().update(
InstalledAppProvider.getAppUri("com.example.app2"), InstalledAppProvider.getAppUri("com.example.app2"),
createContentValues(11, "1.1"), createContentValues(11, "1.1"),
null, null null, null
); );
fail(); fail();
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
@ -74,8 +74,8 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
} }
getMockContentResolver().insert( getMockContentResolver().insert(
InstalledAppProvider.getContentUri(), InstalledAppProvider.getContentUri(),
createContentValues("com.example.app2", 11, "1.1") createContentValues("com.example.app2", 11, "1.1")
); );
assertResultCount(2, InstalledAppProvider.getContentUri()); assertResultCount(2, InstalledAppProvider.getContentUri());
@ -140,9 +140,9 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
@Override @Override
protected String[] getMinimalProjection() { protected String[] getMinimalProjection() {
return new String[] { return new String[] {
InstalledAppProvider.DataColumns.PACKAGE_NAME, InstalledAppProvider.DataColumns.PACKAGE_NAME,
InstalledAppProvider.DataColumns.VERSION_CODE, InstalledAppProvider.DataColumns.VERSION_CODE,
InstalledAppProvider.DataColumns.VERSION_NAME, InstalledAppProvider.DataColumns.VERSION_NAME,
}; };
} }

View File

@ -41,7 +41,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
private File testFilesDir; private File testFilesDir;
private static final String PUB_KEY = private static final String PUB_KEY =
"3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" + "3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" +
"55040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e7365727779" + "55040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e7365727779" +
"6c6f2e636f6d301e170d3135303931323233313632315a170d3433303132383233313632315a30363110" + "6c6f2e636f6d301e170d3135303931323233313632315a170d3433303132383233313632315a30363110" +
"300e060355040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e73" + "300e060355040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e73" +

File diff suppressed because it is too large Load Diff

View File

@ -67,7 +67,7 @@ public class TestUtils {
public static <T extends Comparable> void assertContainsOnly(List<T> actualList, List<T> expectedContains) { public static <T extends Comparable> void assertContainsOnly(List<T> actualList, List<T> expectedContains) {
if (actualList.size() != expectedContains.size()) { if (actualList.size() != expectedContains.size()) {
String message = String message =
"List sizes don't match.\n" + "List sizes don't match.\n" +
"Expected: " + "Expected: " +
listToString(expectedContains) + "\n" + listToString(expectedContains) + "\n" +
"Actual: " + "Actual: " +
@ -84,7 +84,7 @@ public class TestUtils {
} }
if (!containsRequired) { if (!containsRequired) {
String message = String message =
"List doesn't contain \"" + required + "\".\n" + "List doesn't contain \"" + required + "\".\n" +
"Expected: " + "Expected: " +
listToString(expectedContains) + "\n" + listToString(expectedContains) + "\n" +
"Actual: " + "Actual: " +
@ -150,9 +150,9 @@ public class TestUtils {
* {@link org.fdroid.fdroid.receiver.PackageAddedReceiver}. This will in turn update the * {@link org.fdroid.fdroid.receiver.PackageAddedReceiver}. This will in turn update the
* "installed apps" table in the database. * "installed apps" table in the database.
*/ */
public static void installAndBroadcast( public static void installAndBroadcast(MockContextSwappableComponents context,
MockContextSwappableComponents context, MockInstallablePackageManager pm, MockInstallablePackageManager pm, String appId,
String appId, int versionCode, String versionName) { int versionCode, String versionName) {
context.setPackageManager(pm); context.setPackageManager(pm);
pm.install(appId, versionCode, versionName); pm.install(appId, versionCode, versionName);
@ -165,9 +165,9 @@ public class TestUtils {
/** /**
* @see org.fdroid.fdroid.TestUtils#installAndBroadcast(mock.MockContextSwappableComponents, mock.MockInstallablePackageManager, String, int, String) * @see org.fdroid.fdroid.TestUtils#installAndBroadcast(mock.MockContextSwappableComponents, mock.MockInstallablePackageManager, String, int, String)
*/ */
public static void upgradeAndBroadcast( public static void upgradeAndBroadcast(MockContextSwappableComponents context,
MockContextSwappableComponents context, MockInstallablePackageManager pm, MockInstallablePackageManager pm, String appId,
String appId, int versionCode, String versionName) { int versionCode, String versionName) {
/* /*
removeAndBroadcast(context, pm, appId); removeAndBroadcast(context, pm, appId);
installAndBroadcast(context, pm, appId, versionCode, versionName); installAndBroadcast(context, pm, appId, versionCode, versionName);

View File

@ -41,6 +41,14 @@
<!--<module name="MethodLength" />--> <!--<module name="MethodLength" />-->
<!--<module name="ParameterNumber" />--> <!--<module name="ParameterNumber" />-->
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="braceAdjustment" value="0"/>
<property name="caseIndent" value="4"/>
<property name="throwsIndent" value="8"/>
<property name="lineWrappingIndentation" value="8"/>
<property name="arrayInitIndent" value="4"/>
</module>
<module name="EmptyLineSeparator"> <module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true" /> <property name="allowNoEmptyLineBetweenFields" value="true" />
<property name="allowMultipleEmptyLines" value="false" /> <property name="allowMultipleEmptyLines" value="false" />