Cleaned up some lint errors, i18n some strings.

This commit is contained in:
Peter Serwylo 2015-05-14 10:00:11 +10:00
parent 6f3ca8b9c4
commit cb73e6352c
10 changed files with 37 additions and 28 deletions

View File

@ -329,6 +329,9 @@
<string name="wifi_warning_public">May work</string>
<string name="wifi_warning_private">Promising</string>
<string name="wifi_warning_personal">Best bet</string>
<string name="swap_bluetooth_your_device">Your device is</string>
<string name="swap_bluetooth_select_or_scan">Select from devices below, or press \"Scan\" from the menu to find more devices.</string>
<string name="swap_bluetooth_your_device">Your device is</string>
<string name="swap_bluetooth_select_or_scan">Select from devices below, or press \"Scan\" from the menu to find more devices.</string>
<string name="swap_bluetooth_bonded_device">Bonded</string>
<string name="swap_bluetooth_bonding_device">Currently bonding...</string>
<string name="swap_bluetooth_unknown_device">Unknown device</string>
</resources>

View File

@ -17,18 +17,12 @@ import java.net.MalformedURLException;
public class BluetoothDownloader extends Downloader {
private static final String TAG = "org.fdroid.fdroid.net.BluetoothDownloader";
private static final String TAG = "BluetoothDownloader";
private final BluetoothConnection connection;
private FileDetails fileDetails;
private final String sourcePath;
public BluetoothDownloader(BluetoothConnection connection, String sourcePath, String destFile, Context ctx) throws FileNotFoundException, MalformedURLException {
super(destFile, ctx);
this.connection = connection;
this.sourcePath = sourcePath;
}
public BluetoothDownloader(BluetoothConnection connection, String sourcePath, Context ctx) throws IOException {
super(ctx);
this.connection = connection;
@ -54,7 +48,7 @@ public class BluetoothDownloader extends Downloader {
// TODO: Manage the dependency which includes this class better?
// Right now, I only needed the one class from apache commons.
// There are countless classes online which provide this functionaligy,
// There are countless classes online which provide this functionality,
// including some which are available from the Android SDK - the only
// problem is that they have a funky API which doesn't just wrap a
// plain old InputStream (the class is ContentLengthInputStream -
@ -67,7 +61,7 @@ public class BluetoothDownloader extends Downloader {
/**
* May return null if an error occurred while getting file details.
* TODO: Should we throw an exception? Everywhere else in this blue package throws IO exceptions weely neely.
* TODO: Should we throw an exception? Everywhere else in this blue package throws IO exceptions weelx`x`xy-neely.
* Will probably require some thought as to how the API looks, with regards to all of the public methods
* and their signatures.
*/

View File

@ -151,6 +151,7 @@ public class WifiStateChangeService extends Service {
Intent intent = new Intent(BROADCAST);
LocalBroadcastManager.getInstance(WifiStateChangeService.this).sendBroadcast(intent);
WifiStateChangeService.this.stopSelf();
FDroidApp.localRepoWifi.restartIfRunning();
}
}

View File

@ -7,7 +7,8 @@ import java.io.IOException;
public class BluetoothClient {
private static final String TAG = "org.fdroid.fdroid.net.bluetooth.BluetoothClient";
@SuppressWarnings("unused")
private static final String TAG = "BluetoothClient";
private BluetoothDevice device;

View File

@ -12,7 +12,7 @@ import java.io.OutputStream;
public class BluetoothConnection {
private static final String TAG = "org.fdroid.fdroid.net.bluetooth.BluetoothConnection";
private static final String TAG = "BluetoothConnection";
private InputStream input = null;
private OutputStream output = null;

View File

@ -4,6 +4,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Utils;
@ -21,10 +22,10 @@ import java.util.List;
*/
public class BluetoothServer extends Thread {
private static final String TAG = "org.fdroid.fdroid.net.bluetooth.BluetoothServer";
private static final String TAG = "BluetoothServer";
private BluetoothServerSocket serverSocket;
private List<Connection> clients = new ArrayList<Connection>();
private List<Connection> clients = new ArrayList<>();
private final Context context;
@ -75,8 +76,6 @@ public class BluetoothServer extends Thread {
private static class Connection extends Thread
{
private static final String TAG = "org.fdroid.fdroid.net.bluetooth.BluetoothServer.Connection";
private final Context context;
private final BluetoothSocket socket;
@ -139,7 +138,13 @@ public class BluetoothServer extends Thread {
.build();
} catch (IOException e) {
throw new IOException("Error getting file " + request.getPath() + " from local repo proxy - " + e.getMessage(), e);
if (Build.VERSION.SDK_INT <= 9) {
// Would like to use the specific IOException below with a "cause", but it is
// only supported on SDK 9, so I guess this is the next most useful thing.
throw e;
} else {
throw new IOException("Error getting file " + request.getPath() + " from local repo proxy - " + e.getMessage(), e);
}
}
}

View File

@ -15,11 +15,11 @@ import java.util.Map;
public class Request {
private static final String TAG = "org.fdroid.fdroid.net.bluetooth.httpish.Request";
private static final String TAG = "bluetooth.Request";
public static interface Methods {
public static final String HEAD = "HEAD";
public static final String GET = "GET";
public interface Methods {
String HEAD = "HEAD";
String GET = "GET";
}
private String method;
@ -48,6 +48,10 @@ public class Request {
return new Request(Methods.GET, path, connection);
}
public String getHeaderValue(String header) {
return headers.containsKey(header) ? headers.get(header) : null;
}
public Response send() throws IOException {
Log.d(TAG, "Sending request to server (" + path + ")");
@ -141,7 +145,7 @@ public class Request {
* our HTTP-ish implementation.
*/
private Map<String, String> readHeaders() throws IOException {
Map<String, String> headers = new HashMap<String, String>();
Map<String, String> headers = new HashMap<>();
String responseLine = input.readLine();
while (responseLine != null && responseLine.length() > 0) {

View File

@ -16,7 +16,7 @@ import java.util.Map;
public class Response {
private static final String TAG = "org.fdroid.fdroid.net.bluetooth.httpish.Response";
private static final String TAG = "bluetooth.Response";
private int statusCode;
private Map<String, String> headers;

View File

@ -304,12 +304,12 @@ public class BluetoothDeviceListFragment extends ThemeableListFragment {
// TODO: Is the term "Bonded device" common parlance among phone users?
// It sounds a bit technical to me, maybe something more lay like "Previously connected".
// Although it is technically not as accurate, it would make sense to more people...
return "Bonded";
return getString(R.string.swap_bluetooth_bonded_device);
} else if (deviceBondState == BluetoothDevice.BOND_BONDING) {
return "Currently bonding...";
return getString(R.string.swap_bluetooth_bonding_device);
} else {
// TODO: Might be a little bit harsh, makes it sound more malicious than it should.
return "Unknown device";
return getString(R.string.swap_bluetooth_unknown_device);
}
}
}

View File

@ -40,7 +40,7 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
private static final int REQUEST_BLUETOOTH_ENABLE = 1;
private static final int REQUEST_BLUETOOTH_DISCOVERABLE = 2;
private static final String TAG = "org.fdroid.fdroid.views.swap.SwapActivity";
private static final String TAG = "SwapActivity";
private Timer shutdownLocalRepoTimer;
private UpdateAsyncTask updateSwappableAppsTask = null;
@ -241,6 +241,7 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
Log.d(TAG, "Initiating Bluetooth swap instead of wifi.");
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
// TODO: May be null (e.g. on an emulator).
if (adapter.isEnabled()) {
Log.d(TAG, "Bluetooth enabled, will pair with device.");
ensureBluetoothDiscoverable();