From 33ab693a58b6cdd9b40592dffb32746be9f24b07 Mon Sep 17 00:00:00 2001 From: Andrea Cappelli Date: Tue, 18 Mar 2014 12:17:00 +0100 Subject: [PATCH] Merge with Master (#51) Signed-off-by: Andrea Cappelli --- .../kontalk/service/MessageCenterService.java | 2 +- .../kontalk/ui/ComposeMessageFragment.java | 38 ++++++++++--------- src/org/kontalk/ui/MessagingNotification.java | 27 ++++++++++--- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/org/kontalk/service/MessageCenterService.java b/src/org/kontalk/service/MessageCenterService.java index 1893a2c0c..0450898fb 100644 --- a/src/org/kontalk/service/MessageCenterService.java +++ b/src/org/kontalk/service/MessageCenterService.java @@ -1400,7 +1400,7 @@ private Uri incoming(CompositeMessage msg) { public void run() { ContentValues v = new ContentValues(1); v.put(Messages.ATTACHMENT_PREVIEW_PATH, dest.toString()); - + Log.w ("Percorso: ",""+v.get(Messages.ATTACHMENT_PREVIEW_PATH)); getContentResolver().update(_uri, v, null, null); } }, diff --git a/src/org/kontalk/ui/ComposeMessageFragment.java b/src/org/kontalk/ui/ComposeMessageFragment.java index 4a9a64c50..ef329d223 100644 --- a/src/org/kontalk/ui/ComposeMessageFragment.java +++ b/src/org/kontalk/ui/ComposeMessageFragment.java @@ -836,30 +836,32 @@ public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") fi final AlertDialog alert = builder.create(); alert.show(); } - criteria.setAccuracy(criteria.ACCURACY_FINE); - String provider = locationManager.getBestProvider(criteria, false); - LocationListener l = new LocationListener() { - public void onStatusChanged(String provider, int status, Bundle extras) { - } + else { + criteria.setAccuracy(criteria.ACCURACY_FINE); + String provider = locationManager.getBestProvider(criteria, false); + LocationListener l = new LocationListener() { + public void onStatusChanged(String provider, int status, Bundle extras) { + } - public void onProviderEnabled(String provider) { - } + public void onProviderEnabled(String provider) { + } - public void onProviderDisabled(String provider) { - } + public void onProviderDisabled(String provider) { + } - public void onLocationChanged(android.location.Location location) { - Log.w(TAG, "location = " + location.getLatitude() + ", " + location.getLongitude()); + public void onLocationChanged(android.location.Location location) { + Log.w(TAG, "location = " + location.getLatitude() + ", " + location.getLongitude()); - locationManager.removeUpdates(this); + locationManager.removeUpdates(this); - double lat = location.getLatitude(); - double lon = location.getLongitude(); - new TextMessageThread("Location", lat, lon).start(); - } - }; + double lat = location.getLatitude(); + double lon = location.getLongitude(); + new TextMessageThread("Location", lat, lon).start(); + } + }; - locationManager.requestLocationUpdates(provider, 0, 0, l); + locationManager.requestLocationUpdates(provider, 0, 0, l); + } } private void showSmileysPopup(View anchor) { diff --git a/src/org/kontalk/ui/MessagingNotification.java b/src/org/kontalk/ui/MessagingNotification.java index e44ea94cb..5899b8a36 100644 --- a/src/org/kontalk/ui/MessagingNotification.java +++ b/src/org/kontalk/ui/MessagingNotification.java @@ -37,12 +37,15 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.media.AudioManager; import android.net.Uri; import android.support.v4.app.NotificationCompat; +import android.support.v4.app.NotificationCompat.BigPictureStyle; import android.support.v4.app.NotificationCompat.BigTextStyle; import android.support.v4.app.NotificationCompat.InboxStyle; import android.support.v4.app.NotificationCompat.Style; @@ -50,6 +53,7 @@ import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; +import android.util.Log; /** @@ -72,6 +76,7 @@ public class MessagingNotification { CommonColumns.PEER, Messages.BODY_CONTENT, Messages.ATTACHMENT_MIME, + Messages.ATTACHMENT_PREVIEW_PATH, CommonColumns.ENCRYPTED, }; @@ -199,6 +204,7 @@ public static void updateMessagesNotification(Context context, boolean isNew) { if (supportsBigNotifications()) { Map convs = new HashMap(); + String previewPath = null; String peer = null; long id = 0; @@ -208,6 +214,8 @@ public static void updateMessagesNotification(Context context, boolean isNew) { peer = c.getString(1); byte[] content = c.getBlob(2); String attMime = c.getString(3); + previewPath = c.getString(4); + Log.w ("PATH", "" + previewPath); CharSequence[] b = convs.get(peer); if (b == null) { @@ -222,7 +230,7 @@ public static void updateMessagesNotification(Context context, boolean isNew) { String textContent; - boolean encrypted = c.getInt(4) != 0; + boolean encrypted = c.getInt(5) != 0; if (encrypted) { textContent = context.getString(R.string.text_encrypted); } @@ -303,10 +311,19 @@ else if (content == null && attMime != null) { String content = convs.get(peer)[0].toString(); CharSequence last = convs.get(peer)[1]; - // big text content - style = new BigTextStyle(); - ((BigTextStyle) style).bigText(content); - ((BigTextStyle) style).setSummaryText(Authenticator.getDefaultAccount(context).name); + if (unread == 1 && previewPath != null) { + Log.d ("PATH",previewPath); + Bitmap b=BitmapFactory.decodeFile(previewPath); + style = new BigPictureStyle(); + ((BigPictureStyle) style).bigPicture(b); + } + + else { + // big text content + style = new BigTextStyle(); + ((BigTextStyle) style).bigText(content); + ((BigTextStyle) style).setSummaryText(Authenticator.getDefaultAccount(context).name); + } // ticker Contact contact = Contact.findByUserId(context, peer);