diff options
author | lookshe <github@lookshe.org> | 2016-04-17 16:54:19 +0200 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-04-17 16:54:19 +0200 |
commit | 4b11fa4c69834d8e03b18032e12b0ce788da2f70 (patch) | |
tree | 05dac279672a3a207699dc78d44e6cede0f07fb5 /src/main/java/de/thedevstack | |
parent | 2fdd4e6518e16949ce483b15471714b10e9cb92e (diff) | |
parent | bfe01c432244e04daf6804d5cfc3b838ea247c4b (diff) |
Merge tag '1.11.7' into trz/merge_1.11.7
Conflicts:
README.md
build.gradle
gradle/wrapper/gradle-wrapper.properties
src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java
src/main/java/eu/siacs/conversations/persistance/FileBackend.java
src/main/java/eu/siacs/conversations/services/AvatarService.java
src/main/java/eu/siacs/conversations/services/ContactChooserTargetService.java
src/main/java/eu/siacs/conversations/services/NotificationService.java
src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
src/main/res/values-cs/strings.xml
src/main/res/values-de/strings.xml
src/main/res/values-es/strings.xml
src/main/res/values-fr/strings.xml
src/main/res/values-it/strings.xml
src/main/res/values-pt-rBR/strings.xml
src/main/res/values-zh-rCN/strings.xml
src/main/res/values/strings.xml
src/main/res/xml/preferences.xml
Diffstat (limited to 'src/main/java/de/thedevstack')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java | 8 | ||||
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java | 40 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java index d22a10d6..70eec7a2 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java +++ b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java @@ -237,6 +237,14 @@ public class ConversationsPlusPreferences extends Settings { return getBoolean("allow_message_correction", true); } + public static boolean returnToPrevious() { + return getBoolean("return_to_previous", false); + } + + public static boolean led() { + return getBoolean("led", true); + } + private ConversationsPlusPreferences(SharedPreferences sharedPreferences) { this.sharedPreferences = sharedPreferences; } diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java index 63dc320e..b6ffd570 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/AvatarUtil.java @@ -1,12 +1,14 @@ package de.thedevstack.conversationsplus.utils; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.util.Base64; import android.util.Base64OutputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -60,6 +62,44 @@ public final class AvatarUtil { } catch (IOException e) { return null; } + + } + + public static Avatar getStoredPepAvatar(String hash) { + if (hash == null) { + return null; + } + Avatar avatar = new Avatar(); + File file = new File(getAvatarPath(hash)); + FileInputStream is = null; + try { + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + BitmapFactory.decodeFile(file.getAbsolutePath(), options); + is = new FileInputStream(file); + ByteArrayOutputStream mByteArrayOutputStream = new ByteArrayOutputStream(); + Base64OutputStream mBase64OutputStream = new Base64OutputStream(mByteArrayOutputStream, Base64.DEFAULT); + MessageDigest digest = MessageDigest.getInstance("SHA-1"); + DigestOutputStream os = new DigestOutputStream(mBase64OutputStream, digest); + byte[] buffer = new byte[4096]; + int length; + while ((length = is.read(buffer)) > 0) { + os.write(buffer, 0, length); + } + os.flush(); + os.close(); + avatar.sha1sum = CryptoHelper.bytesToHex(digest.digest()); + avatar.image = new String(mByteArrayOutputStream.toByteArray()); + avatar.height = options.outHeight; + avatar.width = options.outWidth; + return avatar; + } catch (IOException e) { + return null; + } catch (NoSuchAlgorithmException e) { + return null; + } finally { + StreamUtil.close(is); + } } /** |