diff --git a/res/layout/nav_header.xml b/res/layout/nav_header.xml index 275f1e22..8051c578 100644 --- a/res/layout/nav_header.xml +++ b/res/layout/nav_header.xml @@ -6,14 +6,12 @@ android:orientation="vertical" android:gravity="bottom"> - pairingCallback = new CopyOnWriteArrayList<>(); - private Map pairingHandlers = new HashMap(); + private Map pairingHandlers = new HashMap<>(); private final CopyOnWriteArrayList links = new CopyOnWriteArrayList<>(); diff --git a/src/org/kde/kdeconnect/Helpers/ContactsHelper.java b/src/org/kde/kdeconnect/Helpers/ContactsHelper.java index 750e659b..928f95b7 100644 --- a/src/org/kde/kdeconnect/Helpers/ContactsHelper.java +++ b/src/org/kde/kdeconnect/Helpers/ContactsHelper.java @@ -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 phoneNumberLookup(Context context, String number) { //Log.e("PhoneNumberLookup", number); - Map contactInfo = new HashMap(); + Map 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) { }; } } } diff --git a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java index 36c036d8..ef7cf26c 100644 --- a/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java +++ b/src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java @@ -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; diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java index 3132f02d..8905d14c 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisActivity.java @@ -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; diff --git a/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java b/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java index aa41e90a..4e4c7581 100644 --- a/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java +++ b/src/org/kde/kdeconnect/UserInterface/List/PairingDeviceItem.java @@ -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);