checkstyle: Finally add proper indentation checks
Somewhat painful conversion, but should go much smoother from here onward.
This commit is contained in:
parent
dd4420965d
commit
9efe173380
@ -114,7 +114,7 @@ public class IntentIntegrator {
|
||||
|
||||
public static final String DEFAULT_TITLE = "Install Barcode Scanner?";
|
||||
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_NO = "No";
|
||||
|
||||
@ -124,8 +124,8 @@ public class IntentIntegrator {
|
||||
// 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> ONE_D_CODE_TYPES =
|
||||
list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128",
|
||||
"ITF", "RSS_14", "RSS_EXPANDED");
|
||||
list("UPC_A", "UPC_E", "EAN_8", "EAN_13", "CODE_39", "CODE_93", "CODE_128",
|
||||
"ITF", "RSS_14", "RSS_EXPANDED");
|
||||
public static final Collection<String> QR_CODE_TYPES = Collections.singleton("QR_CODE");
|
||||
public static final Collection<String> DATA_MATRIX_TYPES = Collections.singleton("DATA_MATRIX");
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class AppDetails extends AppCompatActivity implements ProgressListener, A
|
||||
return getString(R.string.app_inst_unknown_source);
|
||||
}
|
||||
final String installerLabel = InstalledAppProvider
|
||||
.getApplicationLabel(mctx, installerPkgName);
|
||||
.getApplicationLabel(mctx, installerPkgName);
|
||||
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) {
|
||||
holder.incompatibleReasons.setText(
|
||||
getResources().getString(
|
||||
R.string.requires_features,
|
||||
apk.incompatibleReasons.toPrettyString()));
|
||||
getResources().getString(
|
||||
R.string.requires_features,
|
||||
apk.incompatibleReasons.toPrettyString()));
|
||||
holder.incompatibleReasons.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.incompatibleReasons.setVisibility(View.GONE);
|
||||
|
@ -399,7 +399,7 @@ public class FDroid extends AppCompatActivity implements SearchView.OnQueryTextL
|
||||
|
||||
public void removeNotification(int id) {
|
||||
NotificationManager nMgr = (NotificationManager) getBaseContext()
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nMgr.cancel(id);
|
||||
}
|
||||
|
||||
|
@ -270,23 +270,23 @@ public class FDroidApp extends Application {
|
||||
bluetoothAdapter = getBluetoothAdapter();
|
||||
|
||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
|
||||
.imageDownloader(new IconDownloader(getApplicationContext()))
|
||||
.diskCache(new LimitedAgeDiskCache(
|
||||
new File(StorageUtils.getCacheDirectory(getApplicationContext(), true),
|
||||
"icons"),
|
||||
null,
|
||||
new FileNameGenerator() {
|
||||
@Override
|
||||
public String generate(String imageUri) {
|
||||
return imageUri.substring(
|
||||
imageUri.lastIndexOf('/') + 1);
|
||||
} },
|
||||
// 30 days in secs: 30*24*60*60 = 2592000
|
||||
2592000)
|
||||
)
|
||||
.threadPoolSize(4)
|
||||
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
|
||||
.build();
|
||||
.imageDownloader(new IconDownloader(getApplicationContext()))
|
||||
.diskCache(new LimitedAgeDiskCache(
|
||||
new File(StorageUtils.getCacheDirectory(getApplicationContext(), true),
|
||||
"icons"),
|
||||
null,
|
||||
new FileNameGenerator() {
|
||||
@Override
|
||||
public String generate(String imageUri) {
|
||||
return imageUri.substring(
|
||||
imageUri.lastIndexOf('/') + 1);
|
||||
} },
|
||||
// 30 days in secs: 30*24*60*60 = 2592000
|
||||
2592000)
|
||||
)
|
||||
.threadPoolSize(4)
|
||||
.threadPriority(Thread.NORM_PRIORITY - 2) // Default is NORM_PRIORITY - 1
|
||||
.build();
|
||||
ImageLoader.getInstance().init(config);
|
||||
|
||||
// TODO reintroduce PinningTrustManager and MemorizingTrustManager
|
||||
|
@ -317,7 +317,7 @@ public class RepoUpdater {
|
||||
String fingerprintFromIndexXml = Utils.calcFingerprint(certFromIndexXml);
|
||||
String fingerprintFromJar = Utils.calcFingerprint(rawCertFromJar);
|
||||
if (!repo.fingerprint.equalsIgnoreCase(fingerprintFromIndexXml)
|
||||
|| !repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) {
|
||||
|| !repo.fingerprint.equalsIgnoreCase(fingerprintFromJar)) {
|
||||
throw new SigningException(repo, "Supplied certificate fingerprint does not match!");
|
||||
}
|
||||
} // 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
|
||||
if (TextUtils.isEmpty(repo.pubkey)
|
||||
|| TextUtils.isEmpty(certFromJar)
|
||||
|| TextUtils.isEmpty(certFromIndexXml))
|
||||
|| TextUtils.isEmpty(certFromJar)
|
||||
|| TextUtils.isEmpty(certFromIndexXml))
|
||||
throw new SigningException(repo, "A empty repo or signing certificate is invalid!");
|
||||
|
||||
// though its called repo.pubkey, its actually a X509 certificate
|
||||
if (repo.pubkey.equals(certFromJar)
|
||||
&& repo.pubkey.equals(certFromIndexXml)
|
||||
&& certFromIndexXml.equals(certFromJar)) {
|
||||
&& repo.pubkey.equals(certFromIndexXml)
|
||||
&& certFromIndexXml.equals(certFromJar)) {
|
||||
return; // we have a match!
|
||||
}
|
||||
throw new SigningException(repo, "Signing certificate does not match!");
|
||||
|
@ -101,7 +101,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
public static void schedule(Context ctx) {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(ctx);
|
||||
.getDefaultSharedPreferences(ctx);
|
||||
String sint = prefs.getString(Preferences.PREF_UPD_INTERVAL, "0");
|
||||
int interval = Integer.parseInt(sint);
|
||||
|
||||
@ -109,12 +109,12 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
PendingIntent pending = PendingIntent.getService(ctx, 0, intent, 0);
|
||||
|
||||
AlarmManager alarm = (AlarmManager) ctx
|
||||
.getSystemService(Context.ALARM_SERVICE);
|
||||
.getSystemService(Context.ALARM_SERVICE);
|
||||
alarm.cancel(pending);
|
||||
if (interval > 0) {
|
||||
alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
|
||||
SystemClock.elapsedRealtime() + 5000,
|
||||
AlarmManager.INTERVAL_HOUR, pending);
|
||||
SystemClock.elapsedRealtime() + 5000,
|
||||
AlarmManager.INTERVAL_HOUR, pending);
|
||||
Utils.debugLog(TAG, "Update scheduler alarm set");
|
||||
} else {
|
||||
Utils.debugLog(TAG, "Update scheduler alarm not set");
|
||||
@ -128,17 +128,17 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
|
||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
localBroadcastManager.registerReceiver(downloadProgressReceiver,
|
||||
new IntentFilter(Downloader.LOCAL_ACTION_PROGRESS));
|
||||
new IntentFilter(Downloader.LOCAL_ACTION_PROGRESS));
|
||||
localBroadcastManager.registerReceiver(updateStatusReceiver,
|
||||
new IntentFilter(LOCAL_ACTION_STATUS));
|
||||
new IntentFilter(LOCAL_ACTION_STATUS));
|
||||
|
||||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
notificationBuilder = new NotificationCompat.Builder(this)
|
||||
.setSmallIcon(R.drawable.ic_refresh_white)
|
||||
.setOngoing(true)
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.setContentTitle(getString(R.string.update_notification_title));
|
||||
.setSmallIcon(R.drawable.ic_refresh_white)
|
||||
.setOngoing(true)
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.setContentTitle(getString(R.string.update_notification_title));
|
||||
|
||||
// Android docs are a little sketchy, however it seems that Gingerbread is the last
|
||||
// sdk that made a content intent mandatory:
|
||||
@ -302,7 +302,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
long elapsed = System.currentTimeMillis() - lastUpdate;
|
||||
if (elapsed < interval * 60 * 60 * 1000) {
|
||||
Log.i(TAG, "Skipping update - done " + elapsed
|
||||
+ "ms ago, interval is " + interval + " hours");
|
||||
+ "ms ago, interval is " + interval + " hours");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
@ -431,9 +431,9 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
|
||||
private void performUpdateNotification() {
|
||||
Cursor cursor = getContentResolver().query(
|
||||
AppProvider.getCanUpdateUri(),
|
||||
AppProvider.DataColumns.ALL,
|
||||
null, null, null);
|
||||
AppProvider.getCanUpdateUri(),
|
||||
AppProvider.DataColumns.ALL,
|
||||
null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor.getCount() > 0) {
|
||||
showAppUpdatesNotification(cursor);
|
||||
@ -445,8 +445,8 @@ public class UpdateService extends IntentService implements ProgressListener {
|
||||
private PendingIntent createNotificationIntent() {
|
||||
Intent notifyIntent = new Intent(this, FDroid.class).putExtra(FDroid.EXTRA_TAB_UPDATE, true);
|
||||
TaskStackBuilder stackBuilder = TaskStackBuilder
|
||||
.create(this).addParentStack(FDroid.class)
|
||||
.addNextIntent(notifyIntent);
|
||||
.create(this).addParentStack(FDroid.class)
|
||||
.addNextIntent(notifyIntent);
|
||||
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) {
|
||||
|
||||
final String contentText = hasUpdates.getCount() > 1
|
||||
? getString(R.string.many_updates_available, hasUpdates.getCount())
|
||||
: getString(R.string.one_update_available);
|
||||
? getString(R.string.many_updates_available, hasUpdates.getCount())
|
||||
: getString(R.string.one_update_available);
|
||||
|
||||
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
|
||||
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 String contentText = hasUpdates.getCount() > 1
|
||||
? getString(R.string.many_updates_available, hasUpdates.getCount())
|
||||
: getString(R.string.one_update_available);
|
||||
? getString(R.string.many_updates_available, hasUpdates.getCount())
|
||||
: getString(R.string.one_update_available);
|
||||
|
||||
NotificationCompat.Builder builder =
|
||||
new NotificationCompat.Builder(this)
|
||||
.setAutoCancel(true)
|
||||
.setContentTitle(getString(R.string.fdroid_updates_available))
|
||||
.setSmallIcon(icon)
|
||||
.setContentIntent(createNotificationIntent())
|
||||
.setContentText(contentText)
|
||||
.setStyle(createNotificationBigStyle(hasUpdates));
|
||||
new NotificationCompat.Builder(this)
|
||||
.setAutoCancel(true)
|
||||
.setContentTitle(getString(R.string.fdroid_updates_available))
|
||||
.setSmallIcon(icon)
|
||||
.setContentIntent(createNotificationIntent())
|
||||
.setContentText(contentText)
|
||||
.setStyle(createNotificationBigStyle(hasUpdates));
|
||||
|
||||
notificationManager.notify(NOTIFY_ID_UPDATES_AVAILABLE, builder.build());
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ public final class Utils {
|
||||
|
||||
for (File f : files) {
|
||||
if ((startsWith != null && f.getName().startsWith(startsWith))
|
||||
|| (endsWith != null && f.getName().endsWith(endsWith))) {
|
||||
|| (endsWith != null && f.getName().endsWith(endsWith))) {
|
||||
if (!f.delete()) {
|
||||
Log.w(TAG, "Couldn't delete cache file " + f);
|
||||
}
|
||||
|
@ -48,26 +48,27 @@ public class TabManager {
|
||||
for (int i = 0; i < pager.getAdapter().getCount(); i++) {
|
||||
CharSequence label = pager.getAdapter().getPageTitle(i);
|
||||
actionBar.addTab(
|
||||
actionBar.newTab()
|
||||
.setText(label)
|
||||
.setTabListener(new ActionBar.TabListener() {
|
||||
@Override
|
||||
public void onTabSelected(ActionBar.Tab tab,
|
||||
FragmentTransaction ft) {
|
||||
int pos = tab.getPosition();
|
||||
pager.setCurrentItem(pos);
|
||||
if (pos == INDEX_CAN_UPDATE)
|
||||
removeNotification(1);
|
||||
}
|
||||
actionBar.newTab()
|
||||
.setText(label)
|
||||
.setTabListener(new ActionBar.TabListener() {
|
||||
@Override
|
||||
public void onTabSelected(ActionBar.Tab tab,
|
||||
FragmentTransaction ft) {
|
||||
int pos = tab.getPosition();
|
||||
pager.setCurrentItem(pos);
|
||||
if (pos == INDEX_CAN_UPDATE)
|
||||
removeNotification(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||
}
|
||||
@Override
|
||||
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||
}
|
||||
}));
|
||||
@Override
|
||||
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,9 +325,9 @@ public class AppProvider extends FDroidProvider {
|
||||
public void naturalJoinToInstalledTable() {
|
||||
if (!requiresInstalledTable) {
|
||||
join(
|
||||
DBHelper.TABLE_INSTALLED_APP,
|
||||
"installed",
|
||||
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
|
||||
DBHelper.TABLE_INSTALLED_APP,
|
||||
"installed",
|
||||
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
|
||||
requiresInstalledTable = true;
|
||||
}
|
||||
}
|
||||
@ -335,9 +335,9 @@ public class AppProvider extends FDroidProvider {
|
||||
public void leftJoinToInstalledTable() {
|
||||
if (!requiresInstalledTable) {
|
||||
leftJoin(
|
||||
DBHelper.TABLE_INSTALLED_APP,
|
||||
"installed",
|
||||
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
|
||||
DBHelper.TABLE_INSTALLED_APP,
|
||||
"installed",
|
||||
"installed." + InstalledAppProvider.DataColumns.PACKAGE_NAME + " = " + getTableName() + ".id");
|
||||
requiresInstalledTable = true;
|
||||
}
|
||||
}
|
||||
@ -376,16 +376,16 @@ public class AppProvider extends FDroidProvider {
|
||||
|
||||
private void addSuggestedApkVersionField() {
|
||||
addSuggestedApkField(
|
||||
ApkProvider.DataColumns.VERSION,
|
||||
DataColumns.SuggestedApk.VERSION);
|
||||
ApkProvider.DataColumns.VERSION,
|
||||
DataColumns.SuggestedApk.VERSION);
|
||||
}
|
||||
|
||||
private void addSuggestedApkField(String fieldName, String alias) {
|
||||
if (!isSuggestedApkTableAdded) {
|
||||
isSuggestedApkTableAdded = true;
|
||||
leftJoin(
|
||||
getApkTableName(),
|
||||
"suggestedApk",
|
||||
getApkTableName(),
|
||||
"suggestedApk",
|
||||
getTableName() + ".suggestedVercode = suggestedApk.vercode AND " + getTableName() + ".id = suggestedApk.id");
|
||||
}
|
||||
appendField(fieldName, "suggestedApk", alias);
|
||||
@ -393,8 +393,8 @@ public class AppProvider extends FDroidProvider {
|
||||
|
||||
private void addInstalledAppVersionName() {
|
||||
addInstalledAppField(
|
||||
InstalledAppProvider.DataColumns.VERSION_NAME,
|
||||
DataColumns.InstalledApp.VERSION_NAME
|
||||
InstalledAppProvider.DataColumns.VERSION_NAME,
|
||||
DataColumns.InstalledApp.VERSION_NAME
|
||||
);
|
||||
}
|
||||
|
||||
@ -904,7 +904,7 @@ public class AppProvider extends FDroidProvider {
|
||||
final String app = getTableName();
|
||||
|
||||
String updateSql =
|
||||
"UPDATE " + app + " SET compatible = ( " +
|
||||
"UPDATE " + app + " SET compatible = ( " +
|
||||
" SELECT TOTAL( " + apk + ".compatible ) > 0 " +
|
||||
" FROM " + apk +
|
||||
" WHERE " + apk + ".id = " + app + ".id );";
|
||||
@ -941,14 +941,14 @@ public class AppProvider extends FDroidProvider {
|
||||
final boolean unstableUpdates = Preferences.get().getUnstableUpdates();
|
||||
String restrictToStable = unstableUpdates ? "" : (apk + ".vercode <= " + app + ".upstreamVercode AND ");
|
||||
String updateSql =
|
||||
"UPDATE " + app + " SET suggestedVercode = ( " +
|
||||
"UPDATE " + app + " SET suggestedVercode = ( " +
|
||||
" SELECT MAX( " + apk + ".vercode ) " +
|
||||
" FROM " + apk +
|
||||
" WHERE " +
|
||||
app + ".id = " + apk + ".id AND " +
|
||||
restrictToStable +
|
||||
" ( " + app + ".compatible = 0 OR " + apk + ".compatible = 1 ) ) " +
|
||||
" WHERE upstreamVercode > 0 ";
|
||||
" WHERE upstreamVercode > 0 ";
|
||||
|
||||
write().execSQL(updateSql);
|
||||
}
|
||||
@ -980,13 +980,13 @@ public class AppProvider extends FDroidProvider {
|
||||
final String app = getTableName();
|
||||
|
||||
String updateSql =
|
||||
"UPDATE " + app + " SET suggestedVercode = ( " +
|
||||
"UPDATE " + app + " SET suggestedVercode = ( " +
|
||||
" SELECT MAX( " + apk + ".vercode ) " +
|
||||
" FROM " + apk +
|
||||
" WHERE " +
|
||||
app + ".id = " + apk + ".id AND " +
|
||||
" ( " + 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);
|
||||
}
|
||||
@ -1022,7 +1022,7 @@ public class AppProvider extends FDroidProvider {
|
||||
final String repo = DBHelper.TABLE_REPO;
|
||||
|
||||
final String iconUrlQuery =
|
||||
" SELECT " +
|
||||
" SELECT " +
|
||||
|
||||
// Concatenate (using the "||" operator) the address, the
|
||||
// icons directory (bound to the ? as the second parameter
|
||||
@ -1039,10 +1039,10 @@ public class AppProvider extends FDroidProvider {
|
||||
" || " +
|
||||
app + ".icon " +
|
||||
") " +
|
||||
" FROM " +
|
||||
" FROM " +
|
||||
apk +
|
||||
" JOIN " + repo + " ON (" + repo + "._id = " + apk + ".repo) " +
|
||||
" WHERE " +
|
||||
" WHERE " +
|
||||
app + ".id = " + apk + ".id AND " +
|
||||
apk + ".vercode = ( " +
|
||||
|
||||
|
@ -198,53 +198,53 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||
db.execSQL(CREATE_TABLE_REPO);
|
||||
|
||||
insertRepo(
|
||||
db,
|
||||
context.getString(R.string.fdroid_repo_name),
|
||||
context.getString(R.string.fdroid_repo_address),
|
||||
context.getString(R.string.fdroid_repo_description),
|
||||
context.getString(R.string.fdroid_repo_pubkey),
|
||||
context.getResources().getInteger(R.integer.fdroid_repo_version),
|
||||
context.getResources().getInteger(R.integer.fdroid_repo_inuse),
|
||||
context.getResources().getInteger(R.integer.fdroid_repo_priority)
|
||||
db,
|
||||
context.getString(R.string.fdroid_repo_name),
|
||||
context.getString(R.string.fdroid_repo_address),
|
||||
context.getString(R.string.fdroid_repo_description),
|
||||
context.getString(R.string.fdroid_repo_pubkey),
|
||||
context.getResources().getInteger(R.integer.fdroid_repo_version),
|
||||
context.getResources().getInteger(R.integer.fdroid_repo_inuse),
|
||||
context.getResources().getInteger(R.integer.fdroid_repo_priority)
|
||||
);
|
||||
|
||||
insertRepo(
|
||||
db,
|
||||
context.getString(R.string.fdroid_archive_name),
|
||||
context.getString(R.string.fdroid_archive_address),
|
||||
context.getString(R.string.fdroid_archive_description),
|
||||
context.getString(R.string.fdroid_archive_pubkey),
|
||||
context.getResources().getInteger(R.integer.fdroid_archive_version),
|
||||
context.getResources().getInteger(R.integer.fdroid_archive_inuse),
|
||||
context.getResources().getInteger(R.integer.fdroid_archive_priority)
|
||||
db,
|
||||
context.getString(R.string.fdroid_archive_name),
|
||||
context.getString(R.string.fdroid_archive_address),
|
||||
context.getString(R.string.fdroid_archive_description),
|
||||
context.getString(R.string.fdroid_archive_pubkey),
|
||||
context.getResources().getInteger(R.integer.fdroid_archive_version),
|
||||
context.getResources().getInteger(R.integer.fdroid_archive_inuse),
|
||||
context.getResources().getInteger(R.integer.fdroid_archive_priority)
|
||||
);
|
||||
|
||||
insertRepo(
|
||||
db,
|
||||
context.getString(R.string.guardianproject_repo_name),
|
||||
context.getString(R.string.guardianproject_repo_address),
|
||||
context.getString(R.string.guardianproject_repo_description),
|
||||
context.getString(R.string.guardianproject_repo_pubkey),
|
||||
context.getResources().getInteger(R.integer.guardianproject_repo_version),
|
||||
context.getResources().getInteger(R.integer.guardianproject_repo_inuse),
|
||||
context.getResources().getInteger(R.integer.guardianproject_repo_priority)
|
||||
db,
|
||||
context.getString(R.string.guardianproject_repo_name),
|
||||
context.getString(R.string.guardianproject_repo_address),
|
||||
context.getString(R.string.guardianproject_repo_description),
|
||||
context.getString(R.string.guardianproject_repo_pubkey),
|
||||
context.getResources().getInteger(R.integer.guardianproject_repo_version),
|
||||
context.getResources().getInteger(R.integer.guardianproject_repo_inuse),
|
||||
context.getResources().getInteger(R.integer.guardianproject_repo_priority)
|
||||
);
|
||||
|
||||
insertRepo(
|
||||
db,
|
||||
context.getString(R.string.guardianproject_archive_name),
|
||||
context.getString(R.string.guardianproject_archive_address),
|
||||
context.getString(R.string.guardianproject_archive_description),
|
||||
context.getString(R.string.guardianproject_archive_pubkey),
|
||||
context.getResources().getInteger(R.integer.guardianproject_archive_version),
|
||||
context.getResources().getInteger(R.integer.guardianproject_archive_inuse),
|
||||
context.getResources().getInteger(R.integer.guardianproject_archive_priority)
|
||||
db,
|
||||
context.getString(R.string.guardianproject_archive_name),
|
||||
context.getString(R.string.guardianproject_archive_address),
|
||||
context.getString(R.string.guardianproject_archive_description),
|
||||
context.getString(R.string.guardianproject_archive_pubkey),
|
||||
context.getResources().getInteger(R.integer.guardianproject_archive_version),
|
||||
context.getResources().getInteger(R.integer.guardianproject_archive_inuse),
|
||||
context.getResources().getInteger(R.integer.guardianproject_archive_priority)
|
||||
);
|
||||
}
|
||||
|
||||
private void insertRepo(
|
||||
SQLiteDatabase db, String name, String address, String description,
|
||||
String pubKey, int version, int inUse, int priority) {
|
||||
private void insertRepo(SQLiteDatabase db, String name, String address,
|
||||
String description, String pubKey, int version, int inUse,
|
||||
int priority) {
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(RepoProvider.DataColumns.ADDRESS, address);
|
||||
|
@ -112,7 +112,7 @@ public class InstalledAppCacheUpdater {
|
||||
Map<String, Integer> cachedInfo = InstalledAppProvider.Helper.all(context);
|
||||
|
||||
List<PackageInfo> installedPackages = context.getPackageManager()
|
||||
.getInstalledPackages(PackageManager.GET_SIGNATURES);
|
||||
.getInstalledPackages(PackageManager.GET_SIGNATURES);
|
||||
for (PackageInfo appInfo : installedPackages) {
|
||||
toInsert.add(appInfo);
|
||||
if (cachedInfo.containsKey(appInfo.packageName)) {
|
||||
@ -134,14 +134,14 @@ public class InstalledAppCacheUpdater {
|
||||
Uri uri = InstalledAppProvider.getContentUri();
|
||||
for (PackageInfo info : appsToInsert) {
|
||||
ContentProviderOperation op = ContentProviderOperation.newInsert(uri)
|
||||
.withValue(InstalledAppProvider.DataColumns.PACKAGE_NAME, info.packageName)
|
||||
.withValue(InstalledAppProvider.DataColumns.VERSION_CODE, info.versionCode)
|
||||
.withValue(InstalledAppProvider.DataColumns.VERSION_NAME, info.versionName)
|
||||
.withValue(InstalledAppProvider.DataColumns.APPLICATION_LABEL,
|
||||
InstalledAppProvider.getApplicationLabel(context, info.packageName))
|
||||
.withValue(InstalledAppProvider.DataColumns.SIGNATURE,
|
||||
InstalledAppProvider.getPackageSig(info))
|
||||
.build();
|
||||
.withValue(InstalledAppProvider.DataColumns.PACKAGE_NAME, info.packageName)
|
||||
.withValue(InstalledAppProvider.DataColumns.VERSION_CODE, info.versionCode)
|
||||
.withValue(InstalledAppProvider.DataColumns.VERSION_NAME, info.versionName)
|
||||
.withValue(InstalledAppProvider.DataColumns.APPLICATION_LABEL,
|
||||
InstalledAppProvider.getApplicationLabel(context, info.packageName))
|
||||
.withValue(InstalledAppProvider.DataColumns.SIGNATURE,
|
||||
InstalledAppProvider.getPackageSig(info))
|
||||
.build();
|
||||
ops.add(op);
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public class InstalledAppProvider extends FDroidProvider {
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
cachedInfo.put(
|
||||
cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME)),
|
||||
cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE))
|
||||
cursor.getString(cursor.getColumnIndex(InstalledAppProvider.DataColumns.PACKAGE_NAME)),
|
||||
cursor.getInt(cursor.getColumnIndex(InstalledAppProvider.DataColumns.VERSION_CODE))
|
||||
);
|
||||
cursor.moveToNext();
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ public class AppSecurityPermissions {
|
||||
// Dangerous and normal permissions are always shown to the user if the permission
|
||||
// is required, or it was previously granted
|
||||
if ((isNormal || isDangerous) && (isRequired || wasGranted || isGranted ||
|
||||
Build.VERSION.SDK_INT < 16)) {
|
||||
Build.VERSION.SDK_INT < 16)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public abstract class AppListAdapter extends CursorAdapter {
|
||||
holder.summary.setText(app.summary);
|
||||
|
||||
ImageLoader.getInstance().displayImage(app.iconUrl, holder.icon,
|
||||
displayImageOptions);
|
||||
displayImageOptions);
|
||||
|
||||
holder.status.setText(getVersionInfo(app));
|
||||
holder.license.setText(app.license);
|
||||
|
@ -230,13 +230,13 @@ public class ManageReposActivity extends ActionBarActivity {
|
||||
|
||||
addRepoDialog.setTitle(R.string.repo_add_title);
|
||||
addRepoDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
|
||||
getString(R.string.cancel),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
getString(R.string.cancel),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
// HACK:
|
||||
// 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.
|
||||
addRepoDialog.setButton(DialogInterface.BUTTON_POSITIVE,
|
||||
getString(R.string.repo_add_add),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
});
|
||||
getString(R.string.repo_add_add),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
});
|
||||
|
||||
addRepoDialog.show();
|
||||
|
||||
// This must be *after* addRepoDialog.show() otherwise getButtion() returns null:
|
||||
// https://code.google.com/p/android/issues/detail?id=6360
|
||||
addRepoDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
String url = uriEditText.getText().toString();
|
||||
String url = uriEditText.getText().toString();
|
||||
|
||||
try {
|
||||
url = normalizeUrl(url);
|
||||
} catch (URISyntaxException e) {
|
||||
invalidUrl();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
url = normalizeUrl(url);
|
||||
} catch (URISyntaxException e) {
|
||||
invalidUrl();
|
||||
return;
|
||||
}
|
||||
|
||||
String fp = fingerprintEditText.getText().toString();
|
||||
String fp = fingerprintEditText.getText().toString();
|
||||
|
||||
switch (addRepoState) {
|
||||
case DOESNT_EXIST:
|
||||
prepareToCreateNewRepo(url, fp);
|
||||
break;
|
||||
switch (addRepoState) {
|
||||
case DOESNT_EXIST:
|
||||
prepareToCreateNewRepo(url, fp);
|
||||
break;
|
||||
|
||||
case IS_SWAP:
|
||||
Utils.debugLog(TAG, "Removing existing swap repo " + url + " before adding new repo.");
|
||||
Repo repo = RepoProvider.Helper.findByAddress(context, url);
|
||||
RepoProvider.Helper.remove(context, repo.getId());
|
||||
prepareToCreateNewRepo(url, fp);
|
||||
break;
|
||||
case IS_SWAP:
|
||||
Utils.debugLog(TAG, "Removing existing swap repo " + url + " before adding new repo.");
|
||||
Repo repo = RepoProvider.Helper.findByAddress(context, url);
|
||||
RepoProvider.Helper.remove(context, repo.getId());
|
||||
prepareToCreateNewRepo(url, fp);
|
||||
break;
|
||||
|
||||
case EXISTS_DISABLED:
|
||||
case EXISTS_UPGRADABLE_TO_SIGNED:
|
||||
case EXISTS_FINGERPRINT_MATCH:
|
||||
updateAndEnableExistingRepo(url, fp);
|
||||
finishedAddingRepo();
|
||||
break;
|
||||
case EXISTS_DISABLED:
|
||||
case EXISTS_UPGRADABLE_TO_SIGNED:
|
||||
case EXISTS_FINGERPRINT_MATCH:
|
||||
updateAndEnableExistingRepo(url, fp);
|
||||
finishedAddingRepo();
|
||||
break;
|
||||
|
||||
default:
|
||||
finishedAddingRepo();
|
||||
break;
|
||||
default:
|
||||
finishedAddingRepo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
addButton = addRepoDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
|
@ -127,12 +127,12 @@ public class AvailableAppsFragment extends AppListFragment implements
|
||||
categories = AppProvider.Helper.categories(getActivity());
|
||||
|
||||
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);
|
||||
categorySpinner.setAdapter(adapter);
|
||||
|
||||
getActivity().getContentResolver().registerContentObserver(
|
||||
AppProvider.getContentUri(), false, new CategoryObserver(adapter));
|
||||
AppProvider.getContentUri(), false, new CategoryObserver(adapter));
|
||||
|
||||
categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
|
@ -197,7 +197,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
||||
assertTotalApkCount(20);
|
||||
|
||||
Cursor cursor = getMockContentResolver().query(
|
||||
ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null);
|
||||
ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null);
|
||||
assertResultCount(10, cursor);
|
||||
assertBelongsToRepo(cursor, REPO_DELETE);
|
||||
cursor.close();
|
||||
@ -207,7 +207,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
||||
|
||||
assertTotalApkCount(10);
|
||||
cursor = getMockContentResolver().query(
|
||||
ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null);
|
||||
ApkProvider.getRepoUri(REPO_DELETE), getMinimalProjection(), null, null, null);
|
||||
assertResultCount(0, cursor);
|
||||
cursor.close();
|
||||
|
||||
|
@ -64,9 +64,9 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
|
||||
|
||||
try {
|
||||
getMockContentResolver().update(
|
||||
InstalledAppProvider.getAppUri("com.example.app2"),
|
||||
createContentValues(11, "1.1"),
|
||||
null, null
|
||||
InstalledAppProvider.getAppUri("com.example.app2"),
|
||||
createContentValues(11, "1.1"),
|
||||
null, null
|
||||
);
|
||||
fail();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
@ -74,8 +74,8 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
|
||||
}
|
||||
|
||||
getMockContentResolver().insert(
|
||||
InstalledAppProvider.getContentUri(),
|
||||
createContentValues("com.example.app2", 11, "1.1")
|
||||
InstalledAppProvider.getContentUri(),
|
||||
createContentValues("com.example.app2", 11, "1.1")
|
||||
);
|
||||
|
||||
assertResultCount(2, InstalledAppProvider.getContentUri());
|
||||
@ -140,9 +140,9 @@ public class InstalledAppProviderTest extends FDroidProviderTest<InstalledAppPro
|
||||
@Override
|
||||
protected String[] getMinimalProjection() {
|
||||
return new String[] {
|
||||
InstalledAppProvider.DataColumns.PACKAGE_NAME,
|
||||
InstalledAppProvider.DataColumns.VERSION_CODE,
|
||||
InstalledAppProvider.DataColumns.VERSION_NAME,
|
||||
InstalledAppProvider.DataColumns.PACKAGE_NAME,
|
||||
InstalledAppProvider.DataColumns.VERSION_CODE,
|
||||
InstalledAppProvider.DataColumns.VERSION_NAME,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
||||
private File testFilesDir;
|
||||
|
||||
private static final String PUB_KEY =
|
||||
"3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" +
|
||||
"3082050b308202f3a003020102020420d8f212300d06092a864886f70d01010b050030363110300e0603" +
|
||||
"55040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e7365727779" +
|
||||
"6c6f2e636f6d301e170d3135303931323233313632315a170d3433303132383233313632315a30363110" +
|
||||
"300e060355040b1307462d44726f69643122302006035504031319657073696c6f6e2e70657465722e73" +
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -67,7 +67,7 @@ public class TestUtils {
|
||||
public static <T extends Comparable> void assertContainsOnly(List<T> actualList, List<T> expectedContains) {
|
||||
if (actualList.size() != expectedContains.size()) {
|
||||
String message =
|
||||
"List sizes don't match.\n" +
|
||||
"List sizes don't match.\n" +
|
||||
"Expected: " +
|
||||
listToString(expectedContains) + "\n" +
|
||||
"Actual: " +
|
||||
@ -84,7 +84,7 @@ public class TestUtils {
|
||||
}
|
||||
if (!containsRequired) {
|
||||
String message =
|
||||
"List doesn't contain \"" + required + "\".\n" +
|
||||
"List doesn't contain \"" + required + "\".\n" +
|
||||
"Expected: " +
|
||||
listToString(expectedContains) + "\n" +
|
||||
"Actual: " +
|
||||
@ -150,9 +150,9 @@ public class TestUtils {
|
||||
* {@link org.fdroid.fdroid.receiver.PackageAddedReceiver}. This will in turn update the
|
||||
* "installed apps" table in the database.
|
||||
*/
|
||||
public static void installAndBroadcast(
|
||||
MockContextSwappableComponents context, MockInstallablePackageManager pm,
|
||||
String appId, int versionCode, String versionName) {
|
||||
public static void installAndBroadcast(MockContextSwappableComponents context,
|
||||
MockInstallablePackageManager pm, String appId,
|
||||
int versionCode, String versionName) {
|
||||
|
||||
context.setPackageManager(pm);
|
||||
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)
|
||||
*/
|
||||
public static void upgradeAndBroadcast(
|
||||
MockContextSwappableComponents context, MockInstallablePackageManager pm,
|
||||
String appId, int versionCode, String versionName) {
|
||||
public static void upgradeAndBroadcast(MockContextSwappableComponents context,
|
||||
MockInstallablePackageManager pm, String appId,
|
||||
int versionCode, String versionName) {
|
||||
/*
|
||||
removeAndBroadcast(context, pm, appId);
|
||||
installAndBroadcast(context, pm, appId, versionCode, versionName);
|
||||
|
@ -41,6 +41,14 @@
|
||||
<!--<module name="MethodLength" />-->
|
||||
<!--<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">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true" />
|
||||
<property name="allowMultipleEmptyLines" value="false" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user