2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-29 13:17:43 +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:gravity="bottom">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KDE Connect"
android:textColor="#FFF"
android:textStyle="bold"
android:layout_above="@+id/device_name"
android:id="@+id/kdeconnect_label"
android:paddingLeft="16dp"
android:paddingStart="16dp"
@ -29,9 +27,6 @@
android:id="@+id/device_name"
android:layout_marginBottom="0dp"
android:textColor="#fff"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:paddingBottom="16dp"
android:paddingTop="4dp"
android:paddingRight="48dp"

View File

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

View File

@ -77,7 +77,7 @@ public class Device implements BaseLink.PackageReceiver {
private PairStatus pairStatus;
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<>();

View File

@ -20,9 +20,11 @@
package org.kde.kdeconnect.Helpers;
import android.annotation.TargetApi;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.provider.ContactsContract;
import android.provider.ContactsContract.PhoneLookup;
import android.util.Base64;
@ -36,11 +38,13 @@ import java.util.Map;
public class ContactsHelper {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static Map<String, String> phoneNumberLookup(Context context, String 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));
Cursor cursor = null;
@ -82,27 +86,28 @@ public class ContactsHelper {
public static String photoId64Encoded(Context context, String photoId) {
if (photoId == null) {
return new String();
return "";
}
Uri photoUri = Uri.parse(photoId);
Uri displayPhotoUri = Uri.withAppendedPath(photoUri, ContactsContract.Contacts.Photo.DISPLAY_PHOTO);
byte[] buffer = null;
Base64OutputStream out = null;
ByteArrayOutputStream encodedPhoto = null;
InputStream input = null;
Base64OutputStream output= null;
try {
encodedPhoto = new ByteArrayOutputStream();
out = new Base64OutputStream(encodedPhoto, Base64.DEFAULT);
InputStream fd2 = context.getContentResolver().openInputStream(photoUri);
buffer = new byte[1024];
ByteArrayOutputStream encodedPhoto = new ByteArrayOutputStream();
output = new Base64OutputStream(encodedPhoto, Base64.DEFAULT);
input = context.getContentResolver().openInputStream(photoUri);
byte[] buffer = new byte[1024];
int len;
while ((len = fd2.read(buffer)) != -1) {
out.write(buffer, 0, len);
while ((len = input.read(buffer)) != -1) {
output.write(buffer, 0, len);
}
return encodedPhoto.toString();
} catch (Exception ex) {
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.math.BigInteger;
import java.net.Socket;
import java.nio.channels.ServerSocketChannel;
import java.security.KeyStore;
import java.security.MessageDigest;
import java.security.PrivateKey;
@ -57,7 +56,6 @@ import java.util.Formatter;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;

View File

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

View File

@ -36,8 +36,6 @@ public class PairingDeviceItem implements ListAdapter.Item {
private final Callback callback;
private final Device device;
private TextView titleView;
private ImageView icon;
public PairingDeviceItem(Device device, Callback callback) {
this.device = device;
@ -52,10 +50,10 @@ public class PairingDeviceItem implements ListAdapter.Item {
public View inflateView(LayoutInflater layoutInflater) {
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());
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());
if (device.compareProtocolVersion() != 0) {
@ -65,7 +63,7 @@ public class PairingDeviceItem implements ListAdapter.Item {
summaryView.setText(R.string.protocol_version_newer);
summaryView.setVisibility(View.VISIBLE);
} else {
//FIXME: Uncoment
//FIXME: Uncoment when we decide old versions are old enough to notify the user.
summaryView.setVisibility(View.GONE);
/*
summaryView.setText(R.string.protocol_version_older);