2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Fixed simple issues detected by lint

This commit is contained in:
Albert Vaca
2016-06-21 16:44:21 +02:00
parent fec0b34330
commit 1a04bfbbea
7 changed files with 29 additions and 34 deletions

View File

@@ -6,14 +6,12 @@
android:orientation="vertical" android:orientation="vertical"
android:gravity="bottom"> android:gravity="bottom">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="KDE Connect" android:text="KDE Connect"
android:textColor="#FFF" android:textColor="#FFF"
android:textStyle="bold" android:textStyle="bold"
android:layout_above="@+id/device_name"
android:id="@+id/kdeconnect_label" android:id="@+id/kdeconnect_label"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingStart="16dp" android:paddingStart="16dp"
@@ -29,9 +27,6 @@
android:id="@+id/device_name" android:id="@+id/device_name"
android:layout_marginBottom="0dp" android:layout_marginBottom="0dp"
android:textColor="#fff" android:textColor="#fff"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingBottom="16dp" android:paddingBottom="16dp"
android:paddingTop="4dp" android:paddingTop="4dp"
android:paddingRight="48dp" android:paddingRight="48dp"

View File

@@ -48,22 +48,22 @@ import javax.net.ssl.SSLSocket;
public class LanLink extends BaseLink { public class LanLink extends BaseLink {
public interface LinkDisconnectedCallback {
void linkDisconnected(LanLink brokenLink);
}
public enum ConnectionStarted { public enum ConnectionStarted {
Locally, Remotely; Locally, Remotely;
}; };
protected ConnectionStarted connectionSource; // If the other device sent me a broadcast, private ConnectionStarted connectionSource; // If the other device sent me a broadcast,
// I should not close the connection with it // I should not close the connection with it
// because it's probably trying to find me and // because it's probably trying to find me and
// potentially ask for pairing. // potentially ask for pairing.
private Socket socket = null; private Socket socket = null;
interface LinkDisconnectedCallback { private LinkDisconnectedCallback callback;
void linkDisconnected(LanLink brokenLink);
}
LinkDisconnectedCallback callback;
@Override @Override
public void disconnect() { public void disconnect() {

View File

@@ -77,7 +77,7 @@ public class Device implements BaseLink.PackageReceiver {
private PairStatus pairStatus; private PairStatus pairStatus;
private final CopyOnWriteArrayList<PairingCallback> pairingCallback = new CopyOnWriteArrayList<>(); private final CopyOnWriteArrayList<PairingCallback> pairingCallback = new CopyOnWriteArrayList<>();
private Map<String, BasePairingHandler> pairingHandlers = new HashMap<String, BasePairingHandler>(); private Map<String, BasePairingHandler> pairingHandlers = new HashMap<>();
private final CopyOnWriteArrayList<BaseLink> links = new CopyOnWriteArrayList<>(); private final CopyOnWriteArrayList<BaseLink> links = new CopyOnWriteArrayList<>();

View File

@@ -20,9 +20,11 @@
package org.kde.kdeconnect.Helpers; package org.kde.kdeconnect.Helpers;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup; import android.provider.ContactsContract.PhoneLookup;
import android.util.Base64; import android.util.Base64;
@@ -36,11 +38,13 @@ import java.util.Map;
public class ContactsHelper { public class ContactsHelper {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static Map<String, String> phoneNumberLookup(Context context, String number) { public static Map<String, String> phoneNumberLookup(Context context, String number) {
//Log.e("PhoneNumberLookup", number); //Log.e("PhoneNumberLookup", number);
Map<String, String> contactInfo = new HashMap<String, String>(); Map<String, String> contactInfo = new HashMap<>();
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number)); Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor cursor = null; Cursor cursor = null;
@@ -82,27 +86,28 @@ public class ContactsHelper {
public static String photoId64Encoded(Context context, String photoId) { public static String photoId64Encoded(Context context, String photoId) {
if (photoId == null) { if (photoId == null) {
return new String(); return "";
} }
Uri photoUri = Uri.parse(photoId); Uri photoUri = Uri.parse(photoId);
Uri displayPhotoUri = Uri.withAppendedPath(photoUri, ContactsContract.Contacts.Photo.DISPLAY_PHOTO);
byte[] buffer = null; InputStream input = null;
Base64OutputStream out = null; Base64OutputStream output= null;
ByteArrayOutputStream encodedPhoto = null;
try { try {
encodedPhoto = new ByteArrayOutputStream(); ByteArrayOutputStream encodedPhoto = new ByteArrayOutputStream();
out = new Base64OutputStream(encodedPhoto, Base64.DEFAULT); output = new Base64OutputStream(encodedPhoto, Base64.DEFAULT);
InputStream fd2 = context.getContentResolver().openInputStream(photoUri); input = context.getContentResolver().openInputStream(photoUri);
buffer = new byte[1024]; byte[] buffer = new byte[1024];
int len; int len;
while ((len = fd2.read(buffer)) != -1) { while ((len = input.read(buffer)) != -1) {
out.write(buffer, 0, len); output.write(buffer, 0, len);
} }
return encodedPhoto.toString(); return encodedPhoto.toString();
} catch (Exception ex) { } catch (Exception ex) {
Log.e("ContactsHelper", ex.toString()); Log.e("ContactsHelper", ex.toString());
return new String(); return "";
} finally {
try { input.close(); } catch(Exception ignored) { };
try { output.close(); } catch(Exception ignored) { };
} }
} }
} }

View File

@@ -42,7 +42,6 @@ import org.spongycastle.operator.jcajce.JcaContentSignerBuilder;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.Socket; import java.net.Socket;
import java.nio.channels.ServerSocketChannel;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.PrivateKey; import java.security.PrivateKey;
@@ -57,7 +56,6 @@ import java.util.Formatter;
import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;

View File

@@ -22,7 +22,6 @@ package org.kde.kdeconnect.Plugins.MprisPlugin;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;

View File

@@ -36,8 +36,6 @@ public class PairingDeviceItem implements ListAdapter.Item {
private final Callback callback; private final Callback callback;
private final Device device; private final Device device;
private TextView titleView;
private ImageView icon;
public PairingDeviceItem(Device device, Callback callback) { public PairingDeviceItem(Device device, Callback callback) {
this.device = device; this.device = device;
@@ -52,10 +50,10 @@ public class PairingDeviceItem implements ListAdapter.Item {
public View inflateView(LayoutInflater layoutInflater) { public View inflateView(LayoutInflater layoutInflater) {
final View v = layoutInflater.inflate(R.layout.list_item_with_icon_entry, null); final View v = layoutInflater.inflate(R.layout.list_item_with_icon_entry, null);
icon = (ImageView)v.findViewById(R.id.list_item_entry_icon); ImageView icon = (ImageView) v.findViewById(R.id.list_item_entry_icon);
icon.setImageDrawable(device.getIcon()); icon.setImageDrawable(device.getIcon());
titleView = (TextView)v.findViewById(R.id.list_item_entry_title); TextView titleView = (TextView) v.findViewById(R.id.list_item_entry_title);
titleView.setText(device.getName()); titleView.setText(device.getName());
if (device.compareProtocolVersion() != 0) { if (device.compareProtocolVersion() != 0) {
@@ -65,7 +63,7 @@ public class PairingDeviceItem implements ListAdapter.Item {
summaryView.setText(R.string.protocol_version_newer); summaryView.setText(R.string.protocol_version_newer);
summaryView.setVisibility(View.VISIBLE); summaryView.setVisibility(View.VISIBLE);
} else { } else {
//FIXME: Uncoment //FIXME: Uncoment when we decide old versions are old enough to notify the user.
summaryView.setVisibility(View.GONE); summaryView.setVisibility(View.GONE);
/* /*
summaryView.setText(R.string.protocol_version_older); summaryView.setText(R.string.protocol_version_older);