From 495537d087c346076fa4ff58dff927d2a9a348e2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 6 Oct 2021 12:18:58 +0200 Subject: [PATCH] minor code cleanup in UriHandlerActivity --- .../conversations/ui/UriHandlerActivity.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java index 57e1aadcb..5715cd3f1 100644 --- a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java @@ -147,13 +147,7 @@ public class UriHandlerActivity extends AppCompatActivity { final String body = xmppUri.getBody(); if (jid != null) { - Class clazz; - try { - clazz = Class.forName("eu.siacs.conversations.ui.ShareViaAccountActivity"); - } catch (ClassNotFoundException e) { - clazz = null; - - } + final Class clazz = findShareViaAccountClass(); if (clazz != null) { intent = new Intent(this, clazz); intent.putExtra("contact", jid.toEscapedString()); @@ -164,7 +158,6 @@ public class UriHandlerActivity extends AppCompatActivity { intent.setData(uri); intent.putExtra("account", accounts.get(0).toEscapedString()); } - } else { intent = new Intent(this, ShareWithActivity.class); intent.setAction(Intent.ACTION_SEND); @@ -191,6 +184,14 @@ public class UriHandlerActivity extends AppCompatActivity { startActivity(intent); } + private static Class findShareViaAccountClass() { + try { + return Class.forName("eu.siacs.conversations.ui.ShareViaAccountActivity"); + } catch (final ClassNotFoundException e) { + return null; + } + } + private void handleIntent(Intent data) { if (handled) { return; @@ -248,7 +249,7 @@ public class UriHandlerActivity extends AppCompatActivity { } private static boolean looksLikeJsonObject(final String input) { - final String trimmed = Strings.emptyToNull(input).trim(); + final String trimmed = Strings.nullToEmpty(input).trim(); return trimmed.charAt(0) == '{' && trimmed.charAt(trimmed.length() - 1) == '}'; } } \ No newline at end of file