Minor cleanup after CR.
Formatting, spelling, NonNull/Nullable annotations, removing unused imports, and adding SuppressWarning for unused logging "TAG" properties.
This commit is contained in:
parent
f5ce318be7
commit
85300331e0
@ -356,15 +356,16 @@ public class UpdateService extends IntentService implements ProgressListener {
|
|||||||
ArrayList<CharSequence> repoErrors = new ArrayList<>();
|
ArrayList<CharSequence> repoErrors = new ArrayList<>();
|
||||||
List<RepoUpdater.RepoUpdateRememberer> repoUpdateRememberers = new ArrayList<>();
|
List<RepoUpdater.RepoUpdateRememberer> repoUpdateRememberers = new ArrayList<>();
|
||||||
boolean changes = false;
|
boolean changes = false;
|
||||||
|
boolean singleRepoUpdate = !TextUtils.isEmpty(address);
|
||||||
for (final Repo repo : repos) {
|
for (final Repo repo : repos) {
|
||||||
|
|
||||||
if (!repo.inuse) {
|
if (!repo.inuse) {
|
||||||
disabledRepos.add(repo);
|
disabledRepos.add(repo);
|
||||||
continue;
|
continue;
|
||||||
} else if (!TextUtils.isEmpty(address) && !repo.address.equals(address)) {
|
} else if (singleRepoUpdate && !repo.address.equals(address)) {
|
||||||
unchangedRepos.add(repo);
|
unchangedRepos.add(repo);
|
||||||
continue;
|
continue;
|
||||||
} else if (TextUtils.isEmpty(address) && repo.isSwap) {
|
} else if (!singleRepoUpdate && repo.isSwap) {
|
||||||
swapRepos.add(repo);
|
swapRepos.add(repo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.content.res.XmlResourceParser;
|
import android.content.res.XmlResourceParser;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
@ -59,6 +60,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public final class Utils {
|
public final class Utils {
|
||||||
|
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
private static final String TAG = "org.fdroid.fdroid.Utils";
|
private static final String TAG = "org.fdroid.fdroid.Utils";
|
||||||
|
|
||||||
public static final int BUFFER_SIZE = 4096;
|
public static final int BUFFER_SIZE = 4096;
|
||||||
@ -280,6 +282,7 @@ public final class Utils {
|
|||||||
return displayFP;
|
return displayFP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public static Uri getSharingUri(Repo repo) {
|
public static Uri getSharingUri(Repo repo) {
|
||||||
if (TextUtils.isEmpty(repo.address))
|
if (TextUtils.isEmpty(repo.address))
|
||||||
return Uri.parse("http://wifi-not-enabled");
|
return Uri.parse("http://wifi-not-enabled");
|
||||||
|
@ -277,6 +277,7 @@ public class RepoProvider extends FDroidProvider {
|
|||||||
|
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
|
// Do nothing (don't restrict query)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODE_SINGLE:
|
case CODE_SINGLE:
|
||||||
|
@ -314,44 +314,6 @@ public class LocalRepoManager {
|
|||||||
return new File(iconsDir, packageName + "_" + versionCode + ".png");
|
return new File(iconsDir, packageName + "_" + versionCode + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeIndexJar() throws IOException {
|
|
||||||
try {
|
|
||||||
new IndexXmlBuilder(context, apps).build(new FileWriter(xmlIndex));
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, Log.getStackTraceString(e));
|
|
||||||
Toast.makeText(context, R.string.failed_to_create_index, Toast.LENGTH_LONG).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned));
|
|
||||||
JarOutputStream jo = new JarOutputStream(bo);
|
|
||||||
|
|
||||||
BufferedInputStream bi = new BufferedInputStream(new FileInputStream(xmlIndex));
|
|
||||||
|
|
||||||
JarEntry je = new JarEntry("index.xml");
|
|
||||||
jo.putNextEntry(je);
|
|
||||||
|
|
||||||
byte[] buf = new byte[1024];
|
|
||||||
int bytesRead;
|
|
||||||
|
|
||||||
while ((bytesRead = bi.read(buf)) != -1) {
|
|
||||||
jo.write(buf, 0, bytesRead);
|
|
||||||
}
|
|
||||||
|
|
||||||
bi.close();
|
|
||||||
jo.close();
|
|
||||||
bo.close();
|
|
||||||
|
|
||||||
try {
|
|
||||||
LocalRepoKeyStore.get(context).signZip(xmlIndexJarUnsigned, xmlIndexJar);
|
|
||||||
} catch (LocalRepoKeyStore.InitException e) {
|
|
||||||
throw new IOException("Could not sign index - keystore failed to initialize");
|
|
||||||
} finally {
|
|
||||||
attemptToDelete(xmlIndexJarUnsigned);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to aid in constructing index.xml file.
|
* Helper class to aid in constructing index.xml file.
|
||||||
* It uses the PullParser API, because the DOM api is only able to be serialized from
|
* It uses the PullParser API, because the DOM api is only able to be serialized from
|
||||||
@ -514,4 +476,42 @@ public class LocalRepoManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeIndexJar() throws IOException {
|
||||||
|
try {
|
||||||
|
new IndexXmlBuilder(context, apps).build(new FileWriter(xmlIndex));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
|
Toast.makeText(context, R.string.failed_to_create_index, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream(xmlIndexJarUnsigned));
|
||||||
|
JarOutputStream jo = new JarOutputStream(bo);
|
||||||
|
|
||||||
|
BufferedInputStream bi = new BufferedInputStream(new FileInputStream(xmlIndex));
|
||||||
|
|
||||||
|
JarEntry je = new JarEntry("index.xml");
|
||||||
|
jo.putNextEntry(je);
|
||||||
|
|
||||||
|
byte[] buf = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
|
||||||
|
while ((bytesRead = bi.read(buf)) != -1) {
|
||||||
|
jo.write(buf, 0, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
bi.close();
|
||||||
|
jo.close();
|
||||||
|
bo.close();
|
||||||
|
|
||||||
|
try {
|
||||||
|
LocalRepoKeyStore.get(context).signZip(xmlIndexJarUnsigned, xmlIndexJar);
|
||||||
|
} catch (LocalRepoKeyStore.InitException e) {
|
||||||
|
throw new IOException("Could not sign index - keystore failed to initialize");
|
||||||
|
} finally {
|
||||||
|
attemptToDelete(xmlIndexJarUnsigned);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
|
|||||||
|
|
||||||
setContentView(R.layout.swap_activity);
|
setContentView(R.layout.swap_activity);
|
||||||
|
|
||||||
|
// Necessary to run on an Android 2.3.[something] device.
|
||||||
new Handler().post(new Runnable() {
|
new Handler().post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -207,9 +208,17 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UpdateAsyncTask extends AsyncTask<Void, String, Void> {
|
class UpdateAsyncTask extends AsyncTask<Void, String, Void> {
|
||||||
|
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
private static final String TAG = "fdroid.SwapActivity.UpdateAsyncTask";
|
private static final String TAG = "fdroid.SwapActivity.UpdateAsyncTask";
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private final ProgressDialog progressDialog;
|
private final ProgressDialog progressDialog;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private final Set<String> selectedApps;
|
private final Set<String> selectedApps;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private final Uri sharingUri;
|
private final Uri sharingUri;
|
||||||
|
|
||||||
public UpdateAsyncTask(Context c, @NonNull Set<String> apps) {
|
public UpdateAsyncTask(Context c, @NonNull Set<String> apps) {
|
||||||
|
@ -21,6 +21,8 @@ public class SwapAppListActivity extends ActionBarActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
|
|
||||||
|
// Necessary to run on an Android 2.3.[something] device.
|
||||||
new Handler().post(new Runnable() {
|
new Handler().post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -139,7 +139,7 @@ public class WifiQrFragment extends Fragment {
|
|||||||
|
|
||||||
// Andorid provides an API for getting the query parameters and iterating over them:
|
// Andorid provides an API for getting the query parameters and iterating over them:
|
||||||
// Uri.getQueryParameterNames()
|
// Uri.getQueryParameterNames()
|
||||||
// But it is only available on later Android versions. As such we URLEncodedUtils instead.
|
// But it is only available on later Android versions. As such we use URLEncodedUtils instead.
|
||||||
List<NameValuePair> parameters = URLEncodedUtils.parse(URI.create(sharingUri.toString()), "UTF-8");
|
List<NameValuePair> parameters = URLEncodedUtils.parse(URI.create(sharingUri.toString()), "UTF-8");
|
||||||
for (NameValuePair parameter : parameters) {
|
for (NameValuePair parameter : parameters) {
|
||||||
if (!parameter.getName().equals("ssid")) {
|
if (!parameter.getName().equals("ssid")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user