Cleaned up some lint errors, i18n some strings.
This commit is contained in:
parent
6f3ca8b9c4
commit
cb73e6352c
@ -329,6 +329,9 @@
|
|||||||
<string name="wifi_warning_public">May work</string>
|
<string name="wifi_warning_public">May work</string>
|
||||||
<string name="wifi_warning_private">Promising</string>
|
<string name="wifi_warning_private">Promising</string>
|
||||||
<string name="wifi_warning_personal">Best bet</string>
|
<string name="wifi_warning_personal">Best bet</string>
|
||||||
<string name="swap_bluetooth_your_device">Your device is</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_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>
|
</resources>
|
||||||
|
@ -17,18 +17,12 @@ import java.net.MalformedURLException;
|
|||||||
|
|
||||||
public class BluetoothDownloader extends Downloader {
|
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 final BluetoothConnection connection;
|
||||||
private FileDetails fileDetails;
|
private FileDetails fileDetails;
|
||||||
private final String sourcePath;
|
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 {
|
public BluetoothDownloader(BluetoothConnection connection, String sourcePath, Context ctx) throws IOException {
|
||||||
super(ctx);
|
super(ctx);
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
@ -54,7 +48,7 @@ public class BluetoothDownloader extends Downloader {
|
|||||||
|
|
||||||
// TODO: Manage the dependency which includes this class better?
|
// TODO: Manage the dependency which includes this class better?
|
||||||
// Right now, I only needed the one class from apache commons.
|
// 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
|
// 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
|
// problem is that they have a funky API which doesn't just wrap a
|
||||||
// plain old InputStream (the class is ContentLengthInputStream -
|
// 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.
|
* 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
|
* Will probably require some thought as to how the API looks, with regards to all of the public methods
|
||||||
* and their signatures.
|
* and their signatures.
|
||||||
*/
|
*/
|
||||||
|
@ -151,6 +151,7 @@ public class WifiStateChangeService extends Service {
|
|||||||
Intent intent = new Intent(BROADCAST);
|
Intent intent = new Intent(BROADCAST);
|
||||||
LocalBroadcastManager.getInstance(WifiStateChangeService.this).sendBroadcast(intent);
|
LocalBroadcastManager.getInstance(WifiStateChangeService.this).sendBroadcast(intent);
|
||||||
WifiStateChangeService.this.stopSelf();
|
WifiStateChangeService.this.stopSelf();
|
||||||
|
FDroidApp.localRepoWifi.restartIfRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class BluetoothClient {
|
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;
|
private BluetoothDevice device;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.io.OutputStream;
|
|||||||
|
|
||||||
public class BluetoothConnection {
|
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 InputStream input = null;
|
||||||
private OutputStream output = null;
|
private OutputStream output = null;
|
||||||
|
@ -4,6 +4,7 @@ import android.bluetooth.BluetoothAdapter;
|
|||||||
import android.bluetooth.BluetoothServerSocket;
|
import android.bluetooth.BluetoothServerSocket;
|
||||||
import android.bluetooth.BluetoothSocket;
|
import android.bluetooth.BluetoothSocket;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import org.fdroid.fdroid.FDroidApp;
|
import org.fdroid.fdroid.FDroidApp;
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
@ -21,10 +22,10 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class BluetoothServer extends Thread {
|
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 BluetoothServerSocket serverSocket;
|
||||||
private List<Connection> clients = new ArrayList<Connection>();
|
private List<Connection> clients = new ArrayList<>();
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
@ -75,8 +76,6 @@ public class BluetoothServer extends Thread {
|
|||||||
private static class Connection 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 Context context;
|
||||||
private final BluetoothSocket socket;
|
private final BluetoothSocket socket;
|
||||||
|
|
||||||
@ -139,7 +138,13 @@ public class BluetoothServer extends Thread {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ import java.util.Map;
|
|||||||
public class Request {
|
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 interface Methods {
|
||||||
public static final String HEAD = "HEAD";
|
String HEAD = "HEAD";
|
||||||
public static final String GET = "GET";
|
String GET = "GET";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String method;
|
private String method;
|
||||||
@ -48,6 +48,10 @@ public class Request {
|
|||||||
return new Request(Methods.GET, path, connection);
|
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 {
|
public Response send() throws IOException {
|
||||||
|
|
||||||
Log.d(TAG, "Sending request to server (" + path + ")");
|
Log.d(TAG, "Sending request to server (" + path + ")");
|
||||||
@ -141,7 +145,7 @@ public class Request {
|
|||||||
* our HTTP-ish implementation.
|
* our HTTP-ish implementation.
|
||||||
*/
|
*/
|
||||||
private Map<String, String> readHeaders() throws IOException {
|
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();
|
String responseLine = input.readLine();
|
||||||
while (responseLine != null && responseLine.length() > 0) {
|
while (responseLine != null && responseLine.length() > 0) {
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Response {
|
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 int statusCode;
|
||||||
private Map<String, String> headers;
|
private Map<String, String> headers;
|
||||||
|
@ -304,12 +304,12 @@ public class BluetoothDeviceListFragment extends ThemeableListFragment {
|
|||||||
// TODO: Is the term "Bonded device" common parlance among phone users?
|
// 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".
|
// 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...
|
// 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) {
|
} else if (deviceBondState == BluetoothDevice.BOND_BONDING) {
|
||||||
return "Currently bonding...";
|
return getString(R.string.swap_bluetooth_bonding_device);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Might be a little bit harsh, makes it sound more malicious than it should.
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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_ENABLE = 1;
|
||||||
private static final int REQUEST_BLUETOOTH_DISCOVERABLE = 2;
|
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 Timer shutdownLocalRepoTimer;
|
||||||
private UpdateAsyncTask updateSwappableAppsTask = null;
|
private UpdateAsyncTask updateSwappableAppsTask = null;
|
||||||
@ -241,6 +241,7 @@ public class SwapActivity extends ActionBarActivity implements SwapProcessManage
|
|||||||
|
|
||||||
Log.d(TAG, "Initiating Bluetooth swap instead of wifi.");
|
Log.d(TAG, "Initiating Bluetooth swap instead of wifi.");
|
||||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
// TODO: May be null (e.g. on an emulator).
|
||||||
if (adapter.isEnabled()) {
|
if (adapter.isEnabled()) {
|
||||||
Log.d(TAG, "Bluetooth enabled, will pair with device.");
|
Log.d(TAG, "Bluetooth enabled, will pair with device.");
|
||||||
ensureBluetoothDiscoverable();
|
ensureBluetoothDiscoverable();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user