Apply a few android studio fixes

This commit is contained in:
Daniel Martí 2015-05-01 00:30:49 +02:00
parent 869662152a
commit bc98fd69b1
8 changed files with 10 additions and 18 deletions

View File

@ -5,16 +5,16 @@ import android.os.Build;
public abstract class Compatibility { public abstract class Compatibility {
// like minSdkVersion // like minSdkVersion
protected static final boolean hasApi(int apiLevel) { protected static boolean hasApi(int apiLevel) {
return getApi() >= apiLevel; return getApi() >= apiLevel;
} }
// like maxSdkVersion // like maxSdkVersion
protected static final boolean upToApi(int apiLevel) { protected static boolean upToApi(int apiLevel) {
return (apiLevel < 1 || getApi() <= apiLevel); return (apiLevel < 1 || getApi() <= apiLevel);
} }
protected static final int getApi() { protected static int getApi() {
return Build.VERSION.SDK_INT; return Build.VERSION.SDK_INT;
} }

View File

@ -1,6 +1,5 @@
package org.fdroid.fdroid.compat; package org.fdroid.fdroid.compat;
import android.annotation.TargetApi;
import android.os.Build; import android.os.Build;
public class SupportedArchitectures extends Compatibility { public class SupportedArchitectures extends Compatibility {
@ -8,6 +7,7 @@ public class SupportedArchitectures extends Compatibility {
/** /**
* The most preferred ABI is the first element in the list. * The most preferred ABI is the first element in the list.
*/ */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static String[] getAbis() { public static String[] getAbis() {
if (hasApi(21)) { if (hasApi(21)) {

View File

@ -21,10 +21,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;

View File

@ -47,13 +47,11 @@ public class RootInstaller extends Installer {
} }
private Shell.Builder createShellBuilder() { private Shell.Builder createShellBuilder() {
Shell.Builder shellBuilder = new Shell.Builder() return new Shell.Builder()
.useSU() .useSU()
.setWantSTDERR(true) .setWantSTDERR(true)
.setWatchdogTimeout(30) .setWatchdogTimeout(30)
.setMinimalLogging(false); .setMinimalLogging(false);
return shellBuilder;
} }
@Override @Override

View File

@ -272,8 +272,7 @@ public class LocalRepoKeyStore {
private KeyPair generateRandomKeypair() throws NoSuchAlgorithmException { private KeyPair generateRandomKeypair() throws NoSuchAlgorithmException {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(DEFAULT_KEY_ALGO); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(DEFAULT_KEY_ALGO);
keyPairGenerator.initialize(DEFAULT_KEY_BITS); keyPairGenerator.initialize(DEFAULT_KEY_BITS);
KeyPair keyPair = keyPairGenerator.generateKeyPair(); return keyPairGenerator.generateKeyPair();
return keyPair;
} }
private Certificate generateSelfSignedCertChain(KeyPair kp, X500Name subject) private Certificate generateSelfSignedCertChain(KeyPair kp, X500Name subject)

View File

@ -119,12 +119,12 @@ public class SignedRepoUpdater extends RepoUpdater {
@Override @Override
protected File getIndexFromFile(File downloadedFile) throws protected File getIndexFromFile(File downloadedFile) throws
UpdateException { UpdateException {
Date updateTime = new Date(System.currentTimeMillis()); final Date updateTime = new Date(System.currentTimeMillis());
Log.d(TAG, "Getting signed index from " + repo.address + " at " + Log.d(TAG, "Getting signed index from " + repo.address + " at " +
Utils.formatLogDate(updateTime)); Utils.formatLogDate(updateTime));
File indexJar = downloadedFile; final File indexJar = downloadedFile;
File indexXml = null; File indexXml = null;
// Don't worry about checking the status code for 200. If it was a // Don't worry about checking the status code for 200. If it was a
// successful download, then we will have a file ready to use: // successful download, then we will have a file ready to use:

View File

@ -141,14 +141,13 @@ public class SelectLocalAppsFragment extends ListFragment
} else { } else {
baseUri = InstalledAppProvider.getSearchUri(mCurrentFilterString); baseUri = InstalledAppProvider.getSearchUri(mCurrentFilterString);
} }
CursorLoader loader = new CursorLoader( return new CursorLoader(
this.getActivity(), this.getActivity(),
baseUri, baseUri,
InstalledAppProvider.DataColumns.ALL, InstalledAppProvider.DataColumns.ALL,
null, null,
null, null,
InstalledAppProvider.DataColumns.APPLICATION_LABEL); InstalledAppProvider.DataColumns.APPLICATION_LABEL);
return loader;
} }
@Override @Override

View File

@ -88,7 +88,6 @@ public class ConfirmReceiveSwapFragment extends Fragment implements ProgressList
} }
} }
@NonNull
private Repo ensureRepoExists() { private Repo ensureRepoExists() {
if (!newRepoConfig.isValidRepo()) { if (!newRepoConfig.isValidRepo()) {
return null; return null;