From 8ce7bfb95e4fb2bfdbad34e2ad69a95b22bd0d77 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 23 Jan 2021 09:25:34 +0100 Subject: [PATCH] automated code clean up --- .../entities/AccountConfiguration.java | 1 - .../services/ImportBackupService.java | 5 ++- .../ui/EasyOnboardingInviteActivity.java | 6 +-- .../ui/ImportBackupActivity.java | 13 +++--- .../conversations/ui/MagicCreateActivity.java | 6 +-- .../ui/ManageAccountActivity.java | 11 ++--- .../conversations/ui/PickServerActivity.java | 8 ++-- .../conversations/ui/WelcomeActivity.java | 11 +++-- .../ui/adapter/BackupFileAdapter.java | 7 ++-- .../java/eu/siacs/conversations/Config.java | 2 +- .../siacs/conversations/crypto/PgpEngine.java | 7 ++-- .../crypto/axolotl/AxolotlService.java | 15 +++---- .../crypto/axolotl/SQLiteAxolotlStore.java | 4 +- .../crypto/axolotl/XmppAxolotlSession.java | 5 ++- .../siacs/conversations/entities/Account.java | 2 +- .../conversations/entities/Bookmark.java | 3 +- .../siacs/conversations/entities/Contact.java | 5 ++- .../conversations/entities/Conversation.java | 15 +++---- .../conversations/entities/MucOptions.java | 17 ++++---- .../conversations/entities/Presence.java | 3 +- .../entities/ServiceDiscoveryResult.java | 29 +++++-------- .../entities/TransferablePlaceholder.java | 2 +- .../conversations/generator/IqGenerator.java | 6 +-- .../http/HttpDownloadConnection.java | 5 ++- .../conversations/http/SlotRequester.java | 4 +- .../conversations/parser/AbstractParser.java | 5 +-- .../siacs/conversations/parser/IqParser.java | 5 ++- .../conversations/parser/MessageParser.java | 4 +- .../conversations/parser/PresenceParser.java | 3 +- .../persistance/DatabaseBackend.java | 41 +++++++++---------- .../persistance/FileBackend.java | 15 +++---- .../persistance/OnPhoneContactsMerged.java | 2 +- .../services/AppRTCAudioManager.java | 7 ++-- .../services/AppRTCBluetoothManager.java | 7 ++-- .../services/AppRTCProximitySensor.java | 3 +- .../AttachFileToConversationRunnable.java | 5 +-- .../conversations/services/AvatarService.java | 12 +++--- .../services/BarcodeProvider.java | 3 +- .../services/ChannelDiscoveryService.java | 5 ++- .../conversations/services/EventReceiver.java | 3 -- .../services/ExportBackupService.java | 3 +- .../services/MemorizingTrustManager.java | 9 ++-- .../services/MessageArchiveService.java | 16 ++++---- .../services/NotificationService.java | 9 ++-- .../services/ShortcutService.java | 3 +- .../services/XmppConnectionService.java | 8 ++-- .../siacs/conversations/ui/AboutActivity.java | 2 +- .../AbstractSearchableListItemActivity.java | 6 +-- .../conversations/ui/ActionBarActivity.java | 9 +++- .../conversations/ui/BlockContactDialog.java | 7 ++-- .../conversations/ui/BlocklistActivity.java | 7 ++-- .../ui/ChangePasswordActivity.java | 5 ++- .../ui/ChannelDiscoveryActivity.java | 6 +-- .../ui/ChooseContactActivity.java | 19 +++++---- .../ui/ConferenceDetailsActivity.java | 16 ++++---- .../ui/ContactDetailsActivity.java | 34 ++++++--------- .../ui/ConversationActivity.java | 1 + .../ui/ConversationFragment.java | 37 +++++++++-------- .../ui/ConversationsActivity.java | 22 +++++----- .../ui/ConversationsOverviewFragment.java | 15 +++---- .../ui/CreatePrivateGroupChatDialog.java | 9 ++-- .../ui/CreatePublicChannelDialog.java | 11 ++--- .../conversations/ui/EditAccountActivity.java | 16 ++++---- .../conversations/ui/EnterJidDialog.java | 9 ++-- .../ui/JoinConferenceDialog.java | 14 +++---- .../conversations/ui/LocationActivity.java | 5 ++- .../ui/MediaBrowserActivity.java | 9 ++-- .../conversations/ui/MemorizingActivity.java | 3 +- .../conversations/ui/MucUsersActivity.java | 6 +-- .../siacs/conversations/ui/OmemoActivity.java | 9 ++-- ...ublishGroupChatProfilePictureActivity.java | 8 ++-- .../ui/PublishProfilePictureActivity.java | 7 ++-- .../conversations/ui/RecordingActivity.java | 9 ++-- .../conversations/ui/RtpSessionActivity.java | 15 +++---- .../siacs/conversations/ui/ScanActivity.java | 31 +++++++------- .../conversations/ui/SearchActivity.java | 8 ++-- .../conversations/ui/SettingsActivity.java | 16 +++----- .../ui/ShareLocationActivity.java | 11 ++--- .../conversations/ui/ShareWithActivity.java | 9 ++-- .../conversations/ui/ShortcutActivity.java | 6 +-- .../ui/ShowLocationActivity.java | 10 ++--- .../ui/StartConversationActivity.java | 34 +++++++-------- .../conversations/ui/TrustKeysActivity.java | 16 ++++---- .../conversations/ui/UriHandlerActivity.java | 5 ++- .../siacs/conversations/ui/XmppActivity.java | 25 +++++------ .../ui/adapter/AccountAdapter.java | 10 ++--- .../adapter/ChannelSearchResultAdapter.java | 11 ++--- .../ui/adapter/ConversationAdapter.java | 13 +++--- .../ui/adapter/KnownHostsAdapter.java | 7 ++-- .../ui/adapter/ListItemAdapter.java | 5 ++- .../ui/adapter/MediaAdapter.java | 11 ++--- .../ui/adapter/MediaPreviewAdapter.java | 7 ++-- .../ui/adapter/MessageAdapter.java | 5 ++- .../ui/adapter/PresenceTemplateAdapter.java | 3 +- .../conversations/ui/adapter/UserAdapter.java | 11 ++--- .../ui/adapter/UserPreviewAdapter.java | 9 ++-- .../ui/forms/FormBooleanFieldWrapper.java | 4 +- .../ui/forms/FormJidSingleFieldWrapper.java | 4 +- .../ui/forms/FormTextFieldWrapper.java | 6 +-- .../conversations/ui/service/AudioPlayer.java | 5 ++- .../ui/service/CameraManager.java | 20 ++++----- .../conversations/ui/text/FixedURLSpan.java | 3 -- .../conversations/ui/text/QuoteSpan.java | 3 +- .../ui/util/AvatarWorkerTask.java | 6 ++- .../ui/util/ConversationMenuConfigurator.java | 6 +-- .../ui/util/DelayedHintHelper.java | 3 +- .../conversations/ui/util/GridManager.java | 5 ++- .../conversations/ui/util/JidDialog.java | 5 ++- .../conversations/ui/util/LocationHelper.java | 7 +--- .../ui/util/MucConfiguration.java | 1 + .../ui/util/MucDetailsContextMenuHelper.java | 3 +- .../conversations/ui/util/MyLinkify.java | 4 +- .../ui/util/PresenceSelector.java | 3 +- .../ui/util/SoftKeyboardUtils.java | 3 +- .../ui/util/StyledAttributes.java | 1 + .../conversations/ui/widget/EditMessage.java | 12 +++--- .../conversations/ui/widget/ScannerView.java | 12 +++--- .../ui/widget/SwipeRefreshListFragment.java | 5 ++- .../ui/widget/UnreadCountCustomView.java | 3 +- .../utils/Android360pFormatStrategy.java | 3 +- .../utils/Android720pFormatStrategy.java | 3 +- .../utils/AndroidUsingExecLowPriority.java | 10 ++--- .../conversations/utils/BackupFileHeader.java | 10 ++--- .../conversations/utils/Compatibility.java | 3 +- .../utils/ConversationsFileObserver.java | 1 - .../conversations/utils/CryptoHelper.java | 3 +- .../utils/EasyOnboardingInvite.java | 6 +-- .../siacs/conversations/utils/Emoticons.java | 3 +- .../conversations/utils/ExceptionHandler.java | 1 + .../conversations/utils/ExceptionHelper.java | 3 +- .../siacs/conversations/utils/FtsUtils.java | 2 +- .../siacs/conversations/utils/GeoHelper.java | 4 +- .../conversations/utils/ImStyleParser.java | 2 +- .../utils/IrregularUnicodeDetector.java | 6 +-- .../siacs/conversations/utils/JidHelper.java | 2 +- .../conversations/utils/MessageUtils.java | 4 +- .../utils/OnPhoneContactsLoadedListener.java | 2 +- .../conversations/utils/PermissionUtils.java | 1 + .../conversations/utils/PhoneHelper.java | 7 ---- .../conversations/utils/QuickLoader.java | 2 +- .../siacs/conversations/utils/Resolver.java | 3 +- .../conversations/utils/SSLSocketHelper.java | 6 ++- .../conversations/utils/StylingHelper.java | 7 ++-- .../conversations/utils/TLSSocketFactory.java | 1 + .../conversations/utils/ThemeHelper.java | 8 ++-- .../conversations/utils/TimeFrameUtils.java | 1 + .../siacs/conversations/utils/UIHelper.java | 3 +- .../conversations/utils/XEP0392Helper.java | 4 +- .../eu/siacs/conversations/utils/XmppUri.java | 1 + .../eu/siacs/conversations/xml/Element.java | 2 +- .../eu/siacs/conversations/xml/TagWriter.java | 4 +- .../xmpp/OnAdvancedStreamFeaturesLoaded.java | 2 +- .../conversations/xmpp/OnBindListener.java | 2 +- .../xmpp/OnContactStatusChanged.java | 2 +- .../xmpp/OnKeyStatusUpdated.java | 2 +- .../xmpp/OnMessagePacketReceived.java | 2 +- .../xmpp/OnPresencePacketReceived.java | 2 +- .../conversations/xmpp/OnStatusChanged.java | 2 +- .../conversations/xmpp/OnUpdateBlocklist.java | 4 +- .../conversations/xmpp/PacketReceived.java | 2 +- .../siacs/conversations/xmpp/WrappedJid.java | 1 - .../conversations/xmpp/XmppConnection.java | 3 +- .../xmpp/jingle/AbstractJingleConnection.java | 2 +- .../xmpp/jingle/JingleCandidate.java | 4 +- .../xmpp/jingle/JingleConnectionManager.java | 3 +- .../jingle/JingleFileTransferConnection.java | 12 +++--- .../xmpp/jingle/JingleInBandTransport.java | 4 +- .../xmpp/jingle/OnTransportConnected.java | 4 +- .../xmpp/jingle/RtpCapability.java | 2 +- .../xmpp/jingle/SessionDescription.java | 1 - .../xmpp/jingle/stanzas/Content.java | 1 - .../xmpp/jingle/stanzas/JinglePacket.java | 2 +- .../siacs/conversations/xmpp/pep/Avatar.java | 4 +- .../services/MaintenanceReceiver.java | 1 - .../services/PushManagementService.java | 1 - .../services/PushMessageReceiver.java | 1 - .../ui/service/EmojiService.java | 5 ++- 177 files changed, 641 insertions(+), 611 deletions(-) diff --git a/src/conversations/java/eu/siacs/conversations/entities/AccountConfiguration.java b/src/conversations/java/eu/siacs/conversations/entities/AccountConfiguration.java index 702d45e23..65b6804f9 100644 --- a/src/conversations/java/eu/siacs/conversations/entities/AccountConfiguration.java +++ b/src/conversations/java/eu/siacs/conversations/entities/AccountConfiguration.java @@ -1,7 +1,6 @@ package eu.siacs.conversations.entities; import com.google.common.base.Preconditions; -import com.google.common.base.Strings; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonSyntaxException; diff --git a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java index 3aa1ab56b..9c6ebaafd 100644 --- a/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java +++ b/src/conversations/java/eu/siacs/conversations/services/ImportBackupService.java @@ -12,9 +12,10 @@ import android.net.Uri; import android.os.Binder; import android.os.IBinder; import android.provider.OpenableColumns; +import android.util.Log; + import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; -import android.util.Log; import com.google.common.base.Charsets; import com.google.common.base.Stopwatch; @@ -60,7 +61,7 @@ import eu.siacs.conversations.xmpp.Jid; public class ImportBackupService extends Service { private static final int NOTIFICATION_ID = 21; - private static AtomicBoolean running = new AtomicBoolean(false); + private static final AtomicBoolean running = new AtomicBoolean(false); private final ImportBackupServiceBinder binder = new ImportBackupServiceBinder(); private final SerialSingleThreadExecutor executor = new SerialSingleThreadExecutor(getClass().getSimpleName()); private final Set mOnBackupProcessedListeners = Collections.newSetFromMap(new WeakHashMap<>()); diff --git a/src/conversations/java/eu/siacs/conversations/ui/EasyOnboardingInviteActivity.java b/src/conversations/java/eu/siacs/conversations/ui/EasyOnboardingInviteActivity.java index 072c7f87b..fea92401b 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/EasyOnboardingInviteActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/EasyOnboardingInviteActivity.java @@ -2,17 +2,17 @@ package eu.siacs.conversations.ui; import android.app.Activity; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.graphics.Point; import android.os.Bundle; -import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Toast; +import androidx.databinding.DataBindingUtil; + import com.google.common.base.Strings; import eu.siacs.conversations.Config; @@ -34,7 +34,7 @@ public class EasyOnboardingInviteActivity extends XmppActivity implements EasyOn public void onCreate(final Bundle bundle) { super.onCreate(bundle); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_easy_invite); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar(), true); this.binding.shareButton.setOnClickListener(v -> share()); if (bundle != null && bundle.containsKey("invite")) { diff --git a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java index b37918591..888c75129 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java @@ -5,21 +5,22 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; -import androidx.databinding.DataBindingUtil; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.IBinder; -import com.google.android.material.snackbar.Snackbar; -import androidx.core.content.ContextCompat; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import androidx.appcompat.app.AlertDialog; +import androidx.core.content.ContextCompat; +import androidx.databinding.DataBindingUtil; + +import com.google.android.material.snackbar.Snackbar; + import java.io.IOException; import java.util.List; @@ -48,7 +49,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo setTheme(this.mTheme); super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_import_backup); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); setLoadingState(savedInstanceState != null && savedInstanceState.getBoolean("loading_state", false)); this.backupFileAdapter = new BackupFileAdapter(); this.binding.list.setAdapter(this.backupFileAdapter); diff --git a/src/conversations/java/eu/siacs/conversations/ui/MagicCreateActivity.java b/src/conversations/java/eu/siacs/conversations/ui/MagicCreateActivity.java index 8d2c904d9..3419d8fc9 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/MagicCreateActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/MagicCreateActivity.java @@ -2,14 +2,14 @@ package eu.siacs.conversations.ui; import android.content.Intent; import android.content.pm.ActivityInfo; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.Toast; +import androidx.databinding.DataBindingUtil; + import java.security.SecureRandom; import eu.siacs.conversations.Config; @@ -61,7 +61,7 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher { } super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this, R.layout.magic_create); - setSupportActionBar((Toolbar) this.binding.toolbar); + setSupportActionBar(this.binding.toolbar); configureActionBar(getSupportActionBar(), this.domain == null); if (username != null && domain != null) { binding.title.setText(R.string.your_server_invitation); diff --git a/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java index 93cc7ec79..c1ee451be 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -5,9 +5,6 @@ import android.content.Intent; import android.os.Bundle; import android.security.KeyChain; import android.security.KeyChainAliasCallback; -import androidx.annotation.NonNull; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; import android.util.Pair; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; @@ -18,6 +15,10 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.ListView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; + import org.openintents.openpgp.util.OpenPgpApi; import java.util.ArrayList; @@ -31,8 +32,8 @@ import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.ui.adapter.AccountAdapter; import eu.siacs.conversations.ui.util.MenuDoubleTabUtil; -import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.XmppConnection; import static eu.siacs.conversations.utils.PermissionUtils.allGranted; import static eu.siacs.conversations.utils.PermissionUtils.writeGranted; @@ -226,7 +227,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (grantResults.length > 0) { if (allGranted(grantResults)) { switch (requestCode) { diff --git a/src/conversations/java/eu/siacs/conversations/ui/PickServerActivity.java b/src/conversations/java/eu/siacs/conversations/ui/PickServerActivity.java index 7c991c57b..06320d33d 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/PickServerActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/PickServerActivity.java @@ -2,12 +2,12 @@ package eu.siacs.conversations.ui; import android.content.Intent; import android.content.pm.ActivityInfo; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import android.view.MenuItem; +import androidx.appcompat.app.AppCompatActivity; +import androidx.databinding.DataBindingUtil; + import java.util.List; import eu.siacs.conversations.R; @@ -66,7 +66,7 @@ public class PickServerActivity extends XmppActivity { } super.onCreate(savedInstanceState); ActivityPickServerBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_pick_server); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); binding.useCim.setOnClickListener(v -> { final Intent intent = new Intent(this, MagicCreateActivity.class); diff --git a/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java b/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java index 266b7c9d4..8f652ce8e 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java @@ -4,20 +4,19 @@ import android.Manifest; import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.pm.ActivityInfo; - -import androidx.databinding.DataBindingUtil; import android.net.Uri; import android.os.Bundle; import android.security.KeyChain; import android.security.KeyChainAliasCallback; -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.databinding.DataBindingUtil; + import java.util.Arrays; import java.util.List; @@ -120,7 +119,7 @@ public class WelcomeActivity extends XmppActivity implements XmppConnectionServi } super.onCreate(savedInstanceState); ActivityWelcomeBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_welcome); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar(), false); binding.registerNewAccount.setOnClickListener(v -> { final Intent intent = new Intent(this, PickServerActivity.class); diff --git a/src/conversations/java/eu/siacs/conversations/ui/adapter/BackupFileAdapter.java b/src/conversations/java/eu/siacs/conversations/ui/adapter/BackupFileAdapter.java index 375e1d73a..9857dcd8a 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/adapter/BackupFileAdapter.java +++ b/src/conversations/java/eu/siacs/conversations/ui/adapter/BackupFileAdapter.java @@ -1,13 +1,10 @@ package eu.siacs.conversations.ui.adapter; import android.content.res.Resources; -import androidx.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; import android.text.format.DateUtils; import android.util.DisplayMetrics; import android.view.LayoutInflater; @@ -15,6 +12,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.RecyclerView; + import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 074432030..a6a1a2118 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -6,8 +6,8 @@ import android.net.Uri; import java.util.Collections; import java.util.List; -import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.chatstate.ChatState; public final class Config { private static final int UNENCRYPTED = 1; diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java index 2ffbbafbd..c5ca3ad75 100644 --- a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java +++ b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java @@ -2,9 +2,10 @@ package eu.siacs.conversations.crypto; import android.app.PendingIntent; import android.content.Intent; -import androidx.annotation.StringRes; import android.util.Log; +import androidx.annotation.StringRes; + import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.util.OpenPgpApi; @@ -30,8 +31,8 @@ import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.UiCallback; public class PgpEngine { - private OpenPgpApi api; - private XmppConnectionService mXmppConnectionService; + private final OpenPgpApi api; + private final XmppConnectionService mXmppConnectionService; public PgpEngine(OpenPgpApi api, XmppConnectionService service) { this.api = api; diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 7c363258c..b43d331c8 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -2,18 +2,19 @@ package eu.siacs.conversations.crypto.axolotl; import android.os.Bundle; import android.security.KeyChain; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import android.util.Log; import android.util.Pair; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.IdentityKeyPair; import org.whispersystems.libsignal.InvalidKeyException; import org.whispersystems.libsignal.InvalidKeyIdException; import org.whispersystems.libsignal.SessionBuilder; +import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.UntrustedIdentityException; import org.whispersystems.libsignal.ecc.ECPublicKey; import org.whispersystems.libsignal.state.PreKeyBundle; @@ -48,12 +49,12 @@ import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.SerialSingleThreadExecutor; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnAdvancedStreamFeaturesLoaded; import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.pep.PublishOptions; import eu.siacs.conversations.xmpp.stanzas.IqPacket; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; -import eu.siacs.conversations.xmpp.Jid; public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { @@ -85,9 +86,9 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { private int numPublishTriesOnEmptyPep = 0; private boolean pepBroken = false; private int lastDeviceListNotificationHash = 0; - private Set postponedSessions = new HashSet<>(); //sessions stored here will receive after mam catchup treatment - private Set postponedHealing = new HashSet<>(); //addresses stored here will need a healing notification after mam catchup - private AtomicBoolean changeAccessMode = new AtomicBoolean(false); + private final Set postponedSessions = new HashSet<>(); //sessions stored here will receive after mam catchup treatment + private final Set postponedHealing = new HashSet<>(); //addresses stored here will need a healing notification after mam catchup + private final AtomicBoolean changeAccessMode = new AtomicBoolean(false); public AxolotlService(Account account, XmppConnectionService connectionService) { if (account == null || connectionService == null) { diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/SQLiteAxolotlStore.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/SQLiteAxolotlStore.java index d723bd262..866449c18 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/SQLiteAxolotlStore.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/SQLiteAxolotlStore.java @@ -3,15 +3,15 @@ package eu.siacs.conversations.crypto.axolotl; import android.util.Log; import android.util.LruCache; -import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.IdentityKeyPair; import org.whispersystems.libsignal.InvalidKeyIdException; +import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.ecc.Curve; import org.whispersystems.libsignal.ecc.ECKeyPair; -import org.whispersystems.libsignal.state.SignalProtocolStore; import org.whispersystems.libsignal.state.PreKeyRecord; import org.whispersystems.libsignal.state.SessionRecord; +import org.whispersystems.libsignal.state.SignalProtocolStore; import org.whispersystems.libsignal.state.SignedPreKeyRecord; import org.whispersystems.libsignal.util.KeyHelper; diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java index bf3b097dd..20af42fe4 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/XmppAxolotlSession.java @@ -1,10 +1,10 @@ package eu.siacs.conversations.crypto.axolotl; +import android.util.Log; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import android.util.Log; -import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.DuplicateMessageException; import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.InvalidKeyException; @@ -14,6 +14,7 @@ import org.whispersystems.libsignal.InvalidVersionException; import org.whispersystems.libsignal.LegacyMessageException; import org.whispersystems.libsignal.NoSessionException; import org.whispersystems.libsignal.SessionCipher; +import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.UntrustedIdentityException; import org.whispersystems.libsignal.protocol.CiphertextMessage; import org.whispersystems.libsignal.protocol.PreKeySignalMessage; diff --git a/src/main/java/eu/siacs/conversations/entities/Account.java b/src/main/java/eu/siacs/conversations/entities/Account.java index bd6e4e54e..bd71dc9fa 100644 --- a/src/main/java/eu/siacs/conversations/entities/Account.java +++ b/src/main/java/eu/siacs/conversations/entities/Account.java @@ -27,9 +27,9 @@ import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.utils.XmppUri; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.jingle.RtpCapability; -import eu.siacs.conversations.xmpp.Jid; public class Account extends AbstractEntity implements AvatarService.Avatarable { diff --git a/src/main/java/eu/siacs/conversations/entities/Bookmark.java b/src/main/java/eu/siacs/conversations/entities/Bookmark.java index 08e54565f..7ded4f842 100644 --- a/src/main/java/eu/siacs/conversations/entities/Bookmark.java +++ b/src/main/java/eu/siacs/conversations/entities/Bookmark.java @@ -1,6 +1,7 @@ package eu.siacs.conversations.entities; import android.content.Context; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -21,7 +22,7 @@ import eu.siacs.conversations.xmpp.Jid; public class Bookmark extends Element implements ListItem { - private Account account; + private final Account account; private WeakReference conversation; private Jid jid; diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 7f169c5d5..5453f9c23 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -4,9 +4,10 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; -import androidx.annotation.NonNull; import android.text.TextUtils; +import androidx.annotation.NonNull; + import com.google.common.base.Strings; import org.json.JSONArray; @@ -28,9 +29,9 @@ import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.utils.JidHelper; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.jingle.RtpCapability; import eu.siacs.conversations.xmpp.pep.Avatar; -import eu.siacs.conversations.xmpp.Jid; public class Contact implements ListItem, Blockable { public static final String TABLENAME = "contacts"; diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index 4e38caa78..a38dc5427 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -2,9 +2,10 @@ package eu.siacs.conversations.entities; import android.content.ContentValues; import android.database.Cursor; +import android.text.TextUtils; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import android.text.TextUtils; import com.google.common.collect.ComparisonChain; import com.google.common.collect.Lists; @@ -28,9 +29,9 @@ import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.utils.JidHelper; import eu.siacs.conversations.utils.UIHelper; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.mam.MamReference; -import eu.siacs.conversations.xmpp.Jid; import static eu.siacs.conversations.entities.Bookmark.printableValue; @@ -68,12 +69,12 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl public AtomicBoolean messagesLoaded = new AtomicBoolean(true); protected Account account = null; private String draftMessage; - private String name; - private String contactUuid; - private String accountUuid; + private final String name; + private final String contactUuid; + private final String accountUuid; private Jid contactJid; private int status; - private long created; + private final long created; private int mode; private JSONObject attributes; private Jid nextCounterpart; @@ -487,7 +488,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl public void setLastClearHistory(long time, String reference) { if (reference != null) { - setAttribute(ATTRIBUTE_LAST_CLEAR_HISTORY, String.valueOf(time) + ":" + reference); + setAttribute(ATTRIBUTE_LAST_CLEAR_HISTORY, time + ":" + reference); } else { setAttribute(ATTRIBUTE_LAST_CLEAR_HISTORY, time); } diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 57fc5b1d7..d1f6525ce 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -1,8 +1,9 @@ package eu.siacs.conversations.entities; +import android.text.TextUtils; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import android.text.TextUtils; import java.util.ArrayList; import java.util.Collections; @@ -17,11 +18,11 @@ import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.MessageArchiveService; import eu.siacs.conversations.utils.JidHelper; import eu.siacs.conversations.utils.UIHelper; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Field; import eu.siacs.conversations.xmpp.pep.Avatar; -import eu.siacs.conversations.xmpp.Jid; public class MucOptions { @@ -633,8 +634,8 @@ public class MucOptions { OUTCAST(0, R.string.outcast), NONE(1, R.string.no_affiliation); - private int resId; - private int rank; + private final int resId; + private final int rank; Affiliation(int rank, int resId) { this.resId = resId; @@ -676,8 +677,8 @@ public class MucOptions { PARTICIPANT(R.string.participant, 2), NONE(R.string.no_role, 0); - private int resId; - private int rank; + private final int resId; + private final int rank; Role(int resId, int rank) { this.resId = resId; @@ -744,7 +745,7 @@ public class MucOptions { private Jid fullJid; private long pgpKeyId = 0; private Avatar avatar; - private MucOptions options; + private final MucOptions options; private ChatState chatState = Config.DEFAULT_CHAT_STATE; public User(MucOptions options, Jid fullJid) { @@ -855,7 +856,7 @@ public class MucOptions { @Override public String toString() { - return "[fulljid:" + String.valueOf(fullJid) + ",realjid:" + String.valueOf(realJid) + ",affiliation" + affiliation.toString() + "]"; + return "[fulljid:" + fullJid + ",realjid:" + realJid + ",affiliation" + affiliation.toString() + "]"; } public boolean realJidMatchesAccount() { diff --git a/src/main/java/eu/siacs/conversations/entities/Presence.java b/src/main/java/eu/siacs/conversations/entities/Presence.java index 9dce29d39..edafd95de 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presence.java +++ b/src/main/java/eu/siacs/conversations/entities/Presence.java @@ -2,7 +2,6 @@ package eu.siacs.conversations.entities; import androidx.annotation.NonNull; -import java.lang.Comparable; import java.util.Locale; import eu.siacs.conversations.xml.Element; @@ -65,7 +64,7 @@ public class Presence implements Comparable { } public int compareTo(@NonNull Presence other) { - return this.status.compareTo(((Presence)other).status); + return this.status.compareTo(other.status); } public Status getStatus() { diff --git a/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java b/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java index 8b8e58458..8eccbe141 100644 --- a/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java +++ b/src/main/java/eu/siacs/conversations/entities/ServiceDiscoveryResult.java @@ -2,26 +2,23 @@ package eu.siacs.conversations.entities; import android.content.ContentValues; import android.database.Cursor; -import androidx.annotation.NonNull; import android.util.Base64; -import android.util.Log; + +import androidx.annotation.NonNull; import com.google.common.base.Strings; -import java.io.UnsupportedEncodingException; -import java.lang.Comparable; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import eu.siacs.conversations.Config; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xmpp.forms.Data; @@ -242,12 +239,8 @@ public class ServiceDiscoveryResult { return null; } - try { - return md.digest(s.toString().getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - return null; - } - } + return md.digest(s.toString().getBytes(StandardCharsets.UTF_8)); + } private JSONObject toJSON() { try { diff --git a/src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java b/src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java index e065953ef..c8a60d7d9 100644 --- a/src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java +++ b/src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java @@ -2,7 +2,7 @@ package eu.siacs.conversations.entities; public class TransferablePlaceholder implements Transferable { - private int status; + private final int status; public TransferablePlaceholder(int status) { this.status = status; diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java index 1e5a0ed14..ae9ce3bd5 100644 --- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java @@ -29,12 +29,12 @@ import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.services.MessageArchiveService; import eu.siacs.conversations.services.XmppConnectionService; -import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xml.Namespace; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.pep.Avatar; import eu.siacs.conversations.xmpp.stanzas.IqPacket; -import eu.siacs.conversations.xmpp.Jid; public class IqGenerator extends AbstractGenerator { @@ -430,7 +430,7 @@ public class IqGenerator extends AbstractGenerator { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); - return Base64.encodeToString(bb.array(), Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP) + name.substring(pos, name.length()); + return Base64.encodeToString(bb.array(), Base64.URL_SAFE | Base64.NO_PADDING | Base64.NO_WRAP) + name.substring(pos); } catch (Exception e) { return name; } diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index df397ac7f..03ee51de0 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -1,9 +1,10 @@ package eu.siacs.conversations.http; import android.os.PowerManager; -import androidx.annotation.Nullable; import android.util.Log; +import androidx.annotation.Nullable; + import com.google.common.base.Strings; import com.google.common.io.ByteStreams; @@ -328,7 +329,7 @@ public class HttpDownloadConnection implements Transferable { private long retrieveFileSize() throws IOException { try { - Log.d(Config.LOGTAG, "retrieve file size. interactive:" + String.valueOf(interactive)); + Log.d(Config.LOGTAG, "retrieve file size. interactive:" + interactive); changeStatus(STATUS_CHECKING); HttpURLConnection connection; final String hostname = mUrl.getHost(); diff --git a/src/main/java/eu/siacs/conversations/http/SlotRequester.java b/src/main/java/eu/siacs/conversations/http/SlotRequester.java index d9f4cdc20..b52bab39a 100644 --- a/src/main/java/eu/siacs/conversations/http/SlotRequester.java +++ b/src/main/java/eu/siacs/conversations/http/SlotRequester.java @@ -42,12 +42,12 @@ import eu.siacs.conversations.parser.IqParser; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; -import eu.siacs.conversations.xmpp.stanzas.IqPacket; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.stanzas.IqPacket; public class SlotRequester { - private XmppConnectionService service; + private final XmppConnectionService service; public SlotRequester(XmppConnectionService service) { this.service = service; diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java index 80390be43..000fa036d 100644 --- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java @@ -3,7 +3,6 @@ package eu.siacs.conversations.parser; import java.text.ParseException; import java.text.SimpleDateFormat; - import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -15,8 +14,8 @@ import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.InvalidJid; -import eu.siacs.conversations.xmpp.stanzas.AbstractStanza; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.stanzas.AbstractStanza; public abstract class AbstractParser { @@ -82,7 +81,7 @@ public abstract class AbstractParser { } else { ms = 0; } - timestamp = timestamp.substring(0,19)+timestamp.substring(timestamp.length() -5,timestamp.length()); + timestamp = timestamp.substring(0,19)+timestamp.substring(timestamp.length() -5); dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ",Locale.US); return Math.min(dateFormat.parse(timestamp).getTime()+ms, System.currentTimeMillis()); } diff --git a/src/main/java/eu/siacs/conversations/parser/IqParser.java b/src/main/java/eu/siacs/conversations/parser/IqParser.java index 076487a32..d02d69ddc 100644 --- a/src/main/java/eu/siacs/conversations/parser/IqParser.java +++ b/src/main/java/eu/siacs/conversations/parser/IqParser.java @@ -1,10 +1,11 @@ package eu.siacs.conversations.parser; -import androidx.annotation.NonNull; import android.text.TextUtils; import android.util.Log; import android.util.Pair; +import androidx.annotation.NonNull; + import com.google.common.base.CharMatcher; import com.google.common.io.BaseEncoding; @@ -35,11 +36,11 @@ import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xmpp.InvalidJid; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.stanzas.IqPacket; -import eu.siacs.conversations.xmpp.Jid; public class IqParser extends AbstractParser implements OnIqPacketReceived { diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index d2e35fc4f..17e00a975 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -38,17 +38,17 @@ import eu.siacs.conversations.services.MessageArchiveService; import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.utils.CryptoHelper; +import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.LocalizedContent; import eu.siacs.conversations.xml.Namespace; -import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.InvalidJid; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnMessagePacketReceived; import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager; import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection; import eu.siacs.conversations.xmpp.pep.Avatar; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; -import eu.siacs.conversations.xmpp.Jid; public class MessageParser extends AbstractParser implements OnMessagePacketReceived { diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index 6d9937766..d0ec7f6bc 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -5,7 +5,6 @@ import android.util.Log; import java.util.ArrayList; import java.util.List; - import eu.siacs.conversations.Config; import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.crypto.axolotl.AxolotlService; @@ -22,10 +21,10 @@ import eu.siacs.conversations.utils.XmppUri; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xmpp.InvalidJid; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnPresencePacketReceived; import eu.siacs.conversations.xmpp.pep.Avatar; import eu.siacs.conversations.xmpp.stanzas.PresencePacket; -import eu.siacs.conversations.xmpp.Jid; public class PresenceParser extends AbstractParser implements OnPresencePacketReceived { diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index 4d11cfa1a..cf6f05ae7 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -11,11 +11,12 @@ import android.os.SystemClock; import android.util.Base64; import android.util.Log; +import org.json.JSONException; import org.json.JSONObject; -import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.IdentityKey; import org.whispersystems.libsignal.IdentityKeyPair; import org.whispersystems.libsignal.InvalidKeyException; +import org.whispersystems.libsignal.SignalProtocolAddress; import org.whispersystems.libsignal.state.PreKeyRecord; import org.whispersystems.libsignal.state.SessionRecord; import org.whispersystems.libsignal.state.SignedPreKeyRecord; @@ -36,8 +37,6 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.CopyOnWriteArrayList; -import org.json.JSONException; - import eu.siacs.conversations.Config; import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.FingerprintStatus; @@ -57,8 +56,8 @@ import eu.siacs.conversations.utils.FtsUtils; import eu.siacs.conversations.utils.MimeUtils; import eu.siacs.conversations.utils.Resolver; import eu.siacs.conversations.xmpp.InvalidJid; -import eu.siacs.conversations.xmpp.mam.MamReference; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.mam.MamReference; public class DatabaseBackend extends SQLiteOpenHelper { @@ -107,7 +106,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { + ") ON CONFLICT REPLACE" + ");"; - private static String CREATE_SIGNED_PREKEYS_STATEMENT = "CREATE TABLE " + private static final String CREATE_SIGNED_PREKEYS_STATEMENT = "CREATE TABLE " + SQLiteAxolotlStore.SIGNED_PREKEY_TABLENAME + "(" + SQLiteAxolotlStore.ACCOUNT + " TEXT, " + SQLiteAxolotlStore.ID + " INTEGER, " @@ -119,7 +118,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { + ") ON CONFLICT REPLACE" + ");"; - private static String CREATE_SESSIONS_STATEMENT = "CREATE TABLE " + private static final String CREATE_SESSIONS_STATEMENT = "CREATE TABLE " + SQLiteAxolotlStore.SESSION_TABLENAME + "(" + SQLiteAxolotlStore.ACCOUNT + " TEXT, " + SQLiteAxolotlStore.NAME + " TEXT, " @@ -133,7 +132,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { + ") ON CONFLICT REPLACE" + ");"; - private static String CREATE_IDENTITIES_STATEMENT = "CREATE TABLE " + private static final String CREATE_IDENTITIES_STATEMENT = "CREATE TABLE " + SQLiteAxolotlStore.IDENTITIES_TABLENAME + "(" + SQLiteAxolotlStore.ACCOUNT + " TEXT, " + SQLiteAxolotlStore.NAME + " TEXT, " @@ -152,9 +151,9 @@ public class DatabaseBackend extends SQLiteOpenHelper { + ") ON CONFLICT IGNORE" + ");"; - private static String RESOLVER_RESULTS_TABLENAME = "resolver_results"; + private static final String RESOLVER_RESULTS_TABLENAME = "resolver_results"; - private static String CREATE_RESOLVER_RESULTS_TABLE = "create table " + RESOLVER_RESULTS_TABLENAME + "(" + private static final String CREATE_RESOLVER_RESULTS_TABLE = "create table " + RESOLVER_RESULTS_TABLENAME + "(" + Resolver.Result.DOMAIN + " TEXT," + Resolver.Result.HOSTNAME + " TEXT," + Resolver.Result.IP + " BLOB," @@ -165,16 +164,16 @@ public class DatabaseBackend extends SQLiteOpenHelper { + "UNIQUE(" + Resolver.Result.DOMAIN + ") ON CONFLICT REPLACE" + ");"; - private static String CREATE_MESSAGE_TIME_INDEX = "create INDEX message_time_index ON " + Message.TABLENAME + "(" + Message.TIME_SENT + ")"; - private static String CREATE_MESSAGE_CONVERSATION_INDEX = "create INDEX message_conversation_index ON " + Message.TABLENAME + "(" + Message.CONVERSATION + ")"; - private static String CREATE_MESSAGE_DELETED_INDEX = "create index message_deleted_index ON " + Message.TABLENAME + "(" + Message.DELETED + ")"; - private static String CREATE_MESSAGE_RELATIVE_FILE_PATH_INDEX = "create INDEX message_file_path_index ON " + Message.TABLENAME + "(" + Message.RELATIVE_FILE_PATH + ")"; - private static String CREATE_MESSAGE_TYPE_INDEX = "create INDEX message_type_index ON " + Message.TABLENAME + "(" + Message.TYPE + ")"; + private static final String CREATE_MESSAGE_TIME_INDEX = "create INDEX message_time_index ON " + Message.TABLENAME + "(" + Message.TIME_SENT + ")"; + private static final String CREATE_MESSAGE_CONVERSATION_INDEX = "create INDEX message_conversation_index ON " + Message.TABLENAME + "(" + Message.CONVERSATION + ")"; + private static final String CREATE_MESSAGE_DELETED_INDEX = "create index message_deleted_index ON " + Message.TABLENAME + "(" + Message.DELETED + ")"; + private static final String CREATE_MESSAGE_RELATIVE_FILE_PATH_INDEX = "create INDEX message_file_path_index ON " + Message.TABLENAME + "(" + Message.RELATIVE_FILE_PATH + ")"; + private static final String CREATE_MESSAGE_TYPE_INDEX = "create INDEX message_type_index ON " + Message.TABLENAME + "(" + Message.TYPE + ")"; - private static String CREATE_MESSAGE_INDEX_TABLE = "CREATE VIRTUAL TABLE messages_index USING FTS4(uuid TEXT PRIMARY KEY, body TEXT)"; - private static String CREATE_MESSAGE_INSERT_TRIGGER = "CREATE TRIGGER after_message_insert AFTER INSERT ON " + Message.TABLENAME + " BEGIN INSERT INTO messages_index (uuid,body) VALUES (new.uuid,new.body); END;"; - private static String CREATE_MESSAGE_UPDATE_TRIGGER = "CREATE TRIGGER after_message_update UPDATE of uuid,body ON " + Message.TABLENAME + " BEGIN update messages_index set body=new.body,uuid=new.uuid WHERE uuid=old.uuid; END;"; - private static String COPY_PREEXISTING_ENTRIES = "INSERT into messages_index(uuid,body) select uuid,body FROM " + Message.TABLENAME + ";"; + private static final String CREATE_MESSAGE_INDEX_TABLE = "CREATE VIRTUAL TABLE messages_index USING FTS4(uuid TEXT PRIMARY KEY, body TEXT)"; + private static final String CREATE_MESSAGE_INSERT_TRIGGER = "CREATE TRIGGER after_message_insert AFTER INSERT ON " + Message.TABLENAME + " BEGIN INSERT INTO messages_index (uuid,body) VALUES (new.uuid,new.body); END;"; + private static final String CREATE_MESSAGE_UPDATE_TRIGGER = "CREATE TRIGGER after_message_update UPDATE of uuid,body ON " + Message.TABLENAME + " BEGIN update messages_index set body=new.body,uuid=new.uuid WHERE uuid=old.uuid; END;"; + private static final String COPY_PREEXISTING_ENTRIES = "INSERT into messages_index(uuid,body) select uuid,body FROM " + Message.TABLENAME + ";"; private DatabaseBackend(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); @@ -633,7 +632,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { continue; } - String updateArgs[] = { + String[] updateArgs = { newServer, cursor.getString(cursor.getColumnIndex(Account.UUID)), }; @@ -872,7 +871,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { SQLiteDatabase db = this.getReadableDatabase(); final String SQL = "select uuid,relativeFilePath from messages where type in (1,2,5) and deleted=0 and "+Message.RELATIVE_FILE_PATH+" is not null and conversationUuid=(select uuid from conversations where accountUuid=? and (contactJid=? or contactJid like ?)) order by timeSent desc"; final String[] args = {account, jid.toString(), jid.toString() + "/%"}; - Cursor cursor = db.rawQuery(SQL + (limit > 0 ? " limit " + String.valueOf(limit) : ""), args); + Cursor cursor = db.rawQuery(SQL + (limit > 0 ? " limit " + limit : ""), args); List filesPaths = new ArrayList<>(); while (cursor.moveToNext()) { filesPaths.add(new FilePath(cursor.getString(0), cursor.getString(1))); @@ -1005,7 +1004,7 @@ public class DatabaseBackend extends SQLiteOpenHelper { public void readRoster(Roster roster) { SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor; - String args[] = {roster.getAccount().getUuid()}; + String[] args = {roster.getAccount().getUuid()}; cursor = db.query(Contact.TABLENAME, null, Contact.ACCOUNT + "=?", args, null, null, null); while (cursor.moveToNext()) { roster.initContact(Contact.fromCursor(cursor)); diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 448613bf9..ce81694e4 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -20,8 +20,6 @@ import android.os.Environment; import android.os.ParcelFileDescriptor; import android.provider.MediaStore; import android.provider.OpenableColumns; -import androidx.annotation.RequiresApi; -import androidx.core.content.FileProvider; import android.system.Os; import android.system.StructStat; import android.util.Base64; @@ -30,6 +28,9 @@ import android.util.DisplayMetrics; import android.util.Log; import android.util.LruCache; +import androidx.annotation.RequiresApi; +import androidx.core.content.FileProvider; + import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.io.File; @@ -277,7 +278,6 @@ public class FileBackend { } finally { if (bitmap != null) { bitmap.recycle(); - ; } } } @@ -982,9 +982,9 @@ public class FileBackend { public Uri getTakePhotoUri() { File file; if (Config.ONLY_INTERNAL_STORAGE) { - file = new File(mXmppConnectionService.getCacheDir().getAbsolutePath(), "Camera/IMG_" + this.IMAGE_DATE_FORMAT.format(new Date()) + ".jpg"); + file = new File(mXmppConnectionService.getCacheDir().getAbsolutePath(), "Camera/IMG_" + IMAGE_DATE_FORMAT.format(new Date()) + ".jpg"); } else { - file = new File(getTakePhotoPath() + "IMG_" + this.IMAGE_DATE_FORMAT.format(new Date()) + ".jpg"); + file = new File(getTakePhotoPath() + "IMG_" + IMAGE_DATE_FORMAT.format(new Date()) + ".jpg"); } file.getParentFile().mkdirs(); return getUriForFile(mXmppConnectionService, file); @@ -1408,9 +1408,6 @@ public class FileBackend { return null; } Bitmap bm = cropCenter(getAvatarUri(avatar), size, size); - if (bm == null) { - return null; - } return bm; } @@ -1447,7 +1444,7 @@ public class FileBackend { } public static class FileCopyException extends Exception { - private int resId; + private final int resId; private FileCopyException(int resId) { this.resId = resId; diff --git a/src/main/java/eu/siacs/conversations/persistance/OnPhoneContactsMerged.java b/src/main/java/eu/siacs/conversations/persistance/OnPhoneContactsMerged.java index 6a457b17f..46ad9fa7b 100644 --- a/src/main/java/eu/siacs/conversations/persistance/OnPhoneContactsMerged.java +++ b/src/main/java/eu/siacs/conversations/persistance/OnPhoneContactsMerged.java @@ -1,5 +1,5 @@ package eu.siacs.conversations.persistance; public interface OnPhoneContactsMerged { - public void phoneContactsMerged(); + void phoneContactsMerged(); } diff --git a/src/main/java/eu/siacs/conversations/services/AppRTCAudioManager.java b/src/main/java/eu/siacs/conversations/services/AppRTCAudioManager.java index 9f010087a..e1fe854ff 100644 --- a/src/main/java/eu/siacs/conversations/services/AppRTCAudioManager.java +++ b/src/main/java/eu/siacs/conversations/services/AppRTCAudioManager.java @@ -20,9 +20,10 @@ import android.media.AudioManager; import android.media.AudioRecord; import android.media.MediaRecorder; import android.os.Build; -import androidx.annotation.Nullable; import android.util.Log; +import androidx.annotation.Nullable; + import org.webrtc.ThreadUtils; import java.util.Collections; @@ -47,7 +48,7 @@ public class AppRTCAudioManager { // Handles all tasks related to Bluetooth headset devices. private final AppRTCBluetoothManager bluetoothManager; @Nullable - private AudioManager audioManager; + private final AudioManager audioManager; @Nullable private AudioManagerEvents audioManagerEvents; private AudioManagerState amState; @@ -78,7 +79,7 @@ public class AppRTCAudioManager { // avoid duplicate elements. private Set audioDevices = new HashSet<>(); // Broadcast receiver for wired headset intent broadcasts. - private BroadcastReceiver wiredHeadsetReceiver; + private final BroadcastReceiver wiredHeadsetReceiver; // Callback method for changes in audio focus. @Nullable private AudioManager.OnAudioFocusChangeListener audioFocusChangeListener; diff --git a/src/main/java/eu/siacs/conversations/services/AppRTCBluetoothManager.java b/src/main/java/eu/siacs/conversations/services/AppRTCBluetoothManager.java index b0a3b81f5..862cdf0c7 100644 --- a/src/main/java/eu/siacs/conversations/services/AppRTCBluetoothManager.java +++ b/src/main/java/eu/siacs/conversations/services/AppRTCBluetoothManager.java @@ -23,14 +23,15 @@ import android.media.AudioManager; import android.os.Handler; import android.os.Looper; import android.os.Process; -import androidx.annotation.Nullable; import android.util.Log; +import androidx.annotation.Nullable; + +import org.webrtc.ThreadUtils; + import java.util.List; import java.util.Set; -import org.webrtc.ThreadUtils; - import eu.siacs.conversations.Config; import eu.siacs.conversations.utils.AppRTCUtils; diff --git a/src/main/java/eu/siacs/conversations/services/AppRTCProximitySensor.java b/src/main/java/eu/siacs/conversations/services/AppRTCProximitySensor.java index daacefa3a..2f24787c0 100644 --- a/src/main/java/eu/siacs/conversations/services/AppRTCProximitySensor.java +++ b/src/main/java/eu/siacs/conversations/services/AppRTCProximitySensor.java @@ -15,9 +15,10 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Build; -import androidx.annotation.Nullable; import android.util.Log; +import androidx.annotation.Nullable; + import org.webrtc.ThreadUtils; import eu.siacs.conversations.Config; diff --git a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java index c9acc6e58..a24d9e1e4 100644 --- a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java +++ b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java @@ -6,19 +6,18 @@ import android.net.Uri; import android.os.Build; import android.os.ParcelFileDescriptor; import android.preference.PreferenceManager; -import androidx.annotation.RequiresApi; import android.util.Log; +import androidx.annotation.RequiresApi; + import net.ypresto.androidtranscoder.MediaTranscoder; import net.ypresto.androidtranscoder.format.MediaFormatStrategy; -import net.ypresto.androidtranscoder.format.MediaFormatStrategyPresets; import java.io.File; import java.io.FileDescriptor; import java.io.FileNotFoundException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicInteger; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index 54def2386..7baee23f9 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -12,15 +12,15 @@ import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; -import androidx.annotation.ColorInt; -import androidx.annotation.Nullable; -import androidx.core.content.res.ResourcesCompat; import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.util.LruCache; -import java.util.ArrayList; +import androidx.annotation.ColorInt; +import androidx.annotation.Nullable; +import androidx.core.content.res.ResourcesCompat; + import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -40,9 +40,9 @@ import eu.siacs.conversations.entities.MucOptions; import eu.siacs.conversations.entities.RawBlockable; import eu.siacs.conversations.entities.Room; import eu.siacs.conversations.utils.UIHelper; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnAdvancedStreamFeaturesLoaded; import eu.siacs.conversations.xmpp.XmppConnection; -import eu.siacs.conversations.xmpp.Jid; public class AvatarService implements OnAdvancedStreamFeaturesLoaded { @@ -519,7 +519,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { this.sizes.add(size); } return PREFIX_ACCOUNT + "_" + account.getUuid() + "_" - + String.valueOf(size); + + size; } /*public Bitmap get(String name, int size) { diff --git a/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java b/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java index baa679599..582998aa2 100644 --- a/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java +++ b/src/main/java/eu/siacs/conversations/services/BarcodeProvider.java @@ -13,9 +13,10 @@ import android.net.Uri; import android.os.CancellationSignal; import android.os.IBinder; import android.os.ParcelFileDescriptor; -import androidx.annotation.Nullable; import android.util.Log; +import androidx.annotation.Nullable; + import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.common.BitMatrix; diff --git a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java index a3b0b667d..a706dfb30 100644 --- a/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java +++ b/src/main/java/eu/siacs/conversations/services/ChannelDiscoveryService.java @@ -1,8 +1,9 @@ package eu.siacs.conversations.services; -import androidx.annotation.NonNull; import android.util.Log; +import androidx.annotation.NonNull; + import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; @@ -22,6 +23,7 @@ import eu.siacs.conversations.entities.Room; import eu.siacs.conversations.http.HttpConnectionManager; import eu.siacs.conversations.http.services.MuclumbusService; import eu.siacs.conversations.parser.IqParser; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.stanzas.IqPacket; @@ -32,7 +34,6 @@ import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; -import eu.siacs.conversations.xmpp.Jid; public class ChannelDiscoveryService { diff --git a/src/main/java/eu/siacs/conversations/services/EventReceiver.java b/src/main/java/eu/siacs/conversations/services/EventReceiver.java index c9bc3170b..b189e9a9e 100644 --- a/src/main/java/eu/siacs/conversations/services/EventReceiver.java +++ b/src/main/java/eu/siacs/conversations/services/EventReceiver.java @@ -5,9 +5,6 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.preference.PreferenceManager; - -import androidx.core.content.ContextCompat; - import android.util.Log; import com.google.common.base.Strings; diff --git a/src/main/java/eu/siacs/conversations/services/ExportBackupService.java b/src/main/java/eu/siacs/conversations/services/ExportBackupService.java index ae95573d6..95584ae23 100644 --- a/src/main/java/eu/siacs/conversations/services/ExportBackupService.java +++ b/src/main/java/eu/siacs/conversations/services/ExportBackupService.java @@ -11,9 +11,10 @@ import android.database.DatabaseUtils; import android.database.sqlite.SQLiteDatabase; import android.net.Uri; import android.os.IBinder; -import androidx.core.app.NotificationCompat; import android.util.Log; +import androidx.core.app.NotificationCompat; + import com.google.common.base.Strings; import java.io.DataOutputStream; diff --git a/src/main/java/eu/siacs/conversations/services/MemorizingTrustManager.java b/src/main/java/eu/siacs/conversations/services/MemorizingTrustManager.java index 4899f06e9..1aa82d8a3 100644 --- a/src/main/java/eu/siacs/conversations/services/MemorizingTrustManager.java +++ b/src/main/java/eu/siacs/conversations/services/MemorizingTrustManager.java @@ -34,11 +34,12 @@ import android.content.Intent; import android.net.Uri; import android.os.Handler; import android.preference.PreferenceManager; -import androidx.appcompat.app.AppCompatActivity; import android.util.Base64; import android.util.Log; import android.util.SparseArray; +import androidx.appcompat.app.AppCompatActivity; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -114,14 +115,14 @@ public class MemorizingTrustManager { static String KEYSTORE_DIR = "KeyStore"; static String KEYSTORE_FILE = "KeyStore.bks"; private static int decisionId = 0; - private static SparseArray openDecisions = new SparseArray(); + private static final SparseArray openDecisions = new SparseArray(); Context master; AppCompatActivity foregroundAct; NotificationManager notificationManager; Handler masterHandler; private File keyStoreFile; private KeyStore appKeyStore; - private X509TrustManager defaultTrustManager; + private final X509TrustManager defaultTrustManager; private X509TrustManager appTrustManager; private String poshCacheDir; @@ -699,7 +700,7 @@ public class MemorizingTrustManager { Object name = altName.get(1); if (name instanceof String) { si.append("["); - si.append((Integer) altName.get(0)); + si.append(altName.get(0)); si.append("] "); si.append(name); si.append("\n"); diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java index 47d4a240b..592a36702 100644 --- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java +++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java @@ -18,11 +18,11 @@ import eu.siacs.conversations.entities.Conversational; import eu.siacs.conversations.entities.ReceiptRequest; import eu.siacs.conversations.generator.AbstractGenerator; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnAdvancedStreamFeaturesLoaded; import eu.siacs.conversations.xmpp.mam.MamReference; import eu.siacs.conversations.xmpp.stanzas.IqPacket; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; -import eu.siacs.conversations.xmpp.Jid; public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { @@ -89,9 +89,9 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { return null; } - }; + } - MessageArchiveService(final XmppConnectionService service) { + MessageArchiveService(final XmppConnectionService service) { this.mXmppConnectionService = service; } @@ -370,7 +370,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { done = done || (query.getActualMessageCount() == 0 && !query.isCatchup()); this.finalizeQuery(query, done); - Log.d(Config.LOGTAG, query.getAccount().getJid().asBareJid() + ": finished mam after " + query.getTotalCount() + "(" + query.getActualMessageCount() + ") messages. messages left=" + Boolean.toString(!done) + " count=" + count); + Log.d(Config.LOGTAG, query.getAccount().getJid().asBareJid() + ": finished mam after " + query.getTotalCount() + "(" + query.getActualMessageCount() + ") messages. messages left=" + !done + " count=" + count); if (query.isCatchup() && query.getActualMessageCount() > 0) { mXmppConnectionService.getNotificationService().finishBacklog(true, query.getAccount()); } @@ -459,10 +459,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { private int actualCount = 0; private int actualInThisQuery = 0; private long start; - private long end; - private String queryId; + private final long end; + private final String queryId; private String reference = null; - private Account account; + private final Account account; private Conversation conversation; private PagingOrder pagingOrder = PagingOrder.NORMAL; private XmppConnectionService.OnMoreMessagesLoaded callback = null; @@ -649,7 +649,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } builder.append(this.reference); } - builder.append(", catchup=").append(Boolean.toString(catchup)); + builder.append(", catchup=").append(catchup); builder.append(", ns=").append(version.namespace); return builder.toString(); } diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 7925c2010..bc7d5d97f 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -17,6 +17,11 @@ import android.net.Uri; import android.os.Build; import android.os.SystemClock; import android.preference.PreferenceManager; +import android.text.SpannableString; +import android.text.style.StyleSpan; +import android.util.DisplayMetrics; +import android.util.Log; + import androidx.annotation.RequiresApi; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat.BigPictureStyle; @@ -26,10 +31,6 @@ import androidx.core.app.Person; import androidx.core.app.RemoteInput; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.IconCompat; -import android.text.SpannableString; -import android.text.style.StyleSpan; -import android.util.DisplayMetrics; -import android.util.Log; import java.io.File; import java.io.IOException; diff --git a/src/main/java/eu/siacs/conversations/services/ShortcutService.java b/src/main/java/eu/siacs/conversations/services/ShortcutService.java index 7d9a74061..6b7106f74 100644 --- a/src/main/java/eu/siacs/conversations/services/ShortcutService.java +++ b/src/main/java/eu/siacs/conversations/services/ShortcutService.java @@ -8,9 +8,10 @@ import android.graphics.Bitmap; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Build; -import androidx.annotation.NonNull; import android.util.Log; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 23e156f67..de18882d7 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -460,8 +460,8 @@ public class XmppConnectionService extends Service { private WakeLock wakeLock; private PowerManager pm; private LruCache mBitmapCache; - private BroadcastReceiver mInternalEventReceiver = new InternalEventReceiver(); - private BroadcastReceiver mInternalScreenEventReceiver = new InternalEventReceiver(); + private final BroadcastReceiver mInternalEventReceiver = new InternalEventReceiver(); + private final BroadcastReceiver mInternalScreenEventReceiver = new InternalEventReceiver(); private static String generateFetchKey(Account account, final Avatar avatar) { return account.getJid().asBareJid() + "_" + avatar.owner + "_" + avatar.sha1sum; @@ -800,7 +800,7 @@ public class XmppConnectionService extends Service { for (Account account : pingCandidates) { final boolean lowTimeout = isInLowPingTimeoutMode(account); account.getXmppConnection().sendPing(); - Log.d(Config.LOGTAG, account.getJid().asBareJid() + " send ping (action=" + action + ",lowTimeout=" + Boolean.toString(lowTimeout) + ")"); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + " send ping (action=" + action + ",lowTimeout=" + lowTimeout + ")"); scheduleWakeUpCall(lowTimeout ? Config.LOW_PING_TIMEOUT : Config.PING_TIMEOUT, account.getUuid().hashCode()); } } @@ -1840,7 +1840,7 @@ public class XmppConnectionService extends Service { } }); } else { - Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error publishing bookmarks (retry=" + Boolean.toString(retry) + ") " + response); + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error publishing bookmarks (retry=" + retry + ") " + response); } }); } diff --git a/src/main/java/eu/siacs/conversations/ui/AboutActivity.java b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java index 916cbfbfc..3c705e639 100644 --- a/src/main/java/eu/siacs/conversations/ui/AboutActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java @@ -1,7 +1,7 @@ package eu.siacs.conversations.ui; import android.os.Bundle; -import android.preference.PreferenceManager; + import androidx.appcompat.app.AppCompatActivity; import eu.siacs.conversations.R; diff --git a/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java b/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java index 8cb5f0617..3db6aa5a1 100644 --- a/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java @@ -1,9 +1,7 @@ package eu.siacs.conversations.ui; import android.content.Context; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.view.KeyEvent; @@ -16,6 +14,8 @@ import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; +import androidx.databinding.DataBindingUtil; + import java.util.ArrayList; import java.util.List; @@ -92,7 +92,7 @@ public abstract class AbstractSearchableListItemActivity extends XmppActivity im public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this,R.layout.activity_choose_contact); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); this.binding.chooseContactList.setFastScrollEnabled(true); mListItemsAdapter = new ListItemAdapter(this, listItems); diff --git a/src/main/java/eu/siacs/conversations/ui/ActionBarActivity.java b/src/main/java/eu/siacs/conversations/ui/ActionBarActivity.java index 38835161b..8564bcfcb 100644 --- a/src/main/java/eu/siacs/conversations/ui/ActionBarActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ActionBarActivity.java @@ -1,8 +1,11 @@ package eu.siacs.conversations.ui; +import android.view.MenuItem; +import android.view.View; + import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; -import android.view.MenuItem; +import androidx.appcompat.widget.Toolbar; public abstract class ActionBarActivity extends AppCompatActivity { @@ -17,6 +20,10 @@ public abstract class ActionBarActivity extends AppCompatActivity { } } + public void setSupportActionBar(View toolbar) { + super.setSupportActionBar((Toolbar) toolbar); + } + @Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { diff --git a/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java b/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java index 922b272f0..6f4d77c51 100644 --- a/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/BlockContactDialog.java @@ -1,11 +1,12 @@ package eu.siacs.conversations.ui; -import androidx.databinding.DataBindingUtil; -import androidx.annotation.StringRes; -import androidx.appcompat.app.AlertDialog; import android.view.View; import android.widget.Toast; +import androidx.annotation.StringRes; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; + import eu.siacs.conversations.R; import eu.siacs.conversations.databinding.DialogBlockContactBinding; import eu.siacs.conversations.entities.Blockable; diff --git a/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java b/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java index 01f16a510..55cf9ba03 100644 --- a/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/BlocklistActivity.java @@ -1,11 +1,12 @@ package eu.siacs.conversations.ui; import android.os.Bundle; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentTransaction; import android.text.Editable; import android.widget.Toast; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; + import java.util.Collections; import eu.siacs.conversations.R; @@ -14,8 +15,8 @@ import eu.siacs.conversations.entities.Blockable; import eu.siacs.conversations.entities.ListItem; import eu.siacs.conversations.entities.RawBlockable; import eu.siacs.conversations.ui.interfaces.OnBackendConnected; -import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.OnUpdateBlocklist; public class BlocklistActivity extends AbstractSearchableListItemActivity implements OnUpdateBlocklist { diff --git a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java index 2fd853564..c2a334821 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java @@ -2,12 +2,13 @@ package eu.siacs.conversations.ui; import android.content.Intent; import android.os.Bundle; -import com.google.android.material.textfield.TextInputLayout; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; +import com.google.android.material.textfield.TextInputLayout; + import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.services.XmppConnectionService; @@ -16,7 +17,7 @@ import eu.siacs.conversations.ui.widget.DisabledActionModeCallback; public class ChangePasswordActivity extends XmppActivity implements XmppConnectionService.OnAccountPasswordChanged { private Button mChangePasswordButton; - private View.OnClickListener mOnChangePasswordButtonClicked = new View.OnClickListener() { + private final View.OnClickListener mOnChangePasswordButtonClicked = new View.OnClickListener() { @Override public void onClick(View view) { if (mAccount != null) { diff --git a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java index 1f6b1d847..4687e5f63 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChannelDiscoveryActivity.java @@ -4,11 +4,9 @@ import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import androidx.databinding.DataBindingUtil; import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; -import androidx.appcompat.widget.Toolbar; import android.text.Html; import android.text.method.LinkMovementMethod; import android.view.KeyEvent; @@ -20,6 +18,8 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; +import androidx.databinding.DataBindingUtil; + import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -77,7 +77,7 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_channel_discovery); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar(), true); binding.list.setAdapter(this.adapter); this.adapter.setOnChannelSearchResultSelectedListener(this); diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java index ecb21ed73..9da5c7546 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java @@ -5,11 +5,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.StringRes; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentTransaction; -import androidx.appcompat.app.ActionBar; import android.view.ActionMode; import android.view.KeyEvent; import android.view.Menu; @@ -21,6 +16,12 @@ import android.widget.AdapterView; import android.widget.ListView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.StringRes; +import androidx.appcompat.app.ActionBar; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentTransaction; + import com.google.common.base.Strings; import java.util.ArrayList; @@ -50,15 +51,15 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im public static final String EXTRA_SHOW_ENTER_JID = "extra_show_enter_jid"; public static final String EXTRA_CONVERSATION = "extra_conversation"; private static final String EXTRA_FILTERED_CONTACTS = "extra_filtered_contacts"; - private List mActivatedAccounts = new ArrayList<>(); - private Set selected = new HashSet<>(); + private final List mActivatedAccounts = new ArrayList<>(); + private final Set selected = new HashSet<>(); private Set filterContacts; private boolean showEnterJid = false; private boolean startSearching = false; private boolean multiple = false; - private PendingItem postponedActivityResult = new PendingItem<>(); + private final PendingItem postponedActivityResult = new PendingItem<>(); public static Intent create(Activity activity, Conversation conversation) { final Intent intent = new Intent(activity, ChooseContactActivity.class); @@ -380,7 +381,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { ScanActivity.onRequestPermissionResult(this, requestCode, grantResults); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 7bda9b21c..3d29bb89a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -3,10 +3,7 @@ package eu.siacs.conversations.ui; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.SpannableStringBuilder; import android.text.TextWatcher; @@ -16,6 +13,9 @@ import android.view.View; import android.view.View.OnClickListener; import android.widget.Toast; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; + import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -48,8 +48,8 @@ import eu.siacs.conversations.utils.EmojiWrapper; import eu.siacs.conversations.utils.StringUtils; import eu.siacs.conversations.utils.StylingHelper; import eu.siacs.conversations.utils.XmppUri; -import me.drakeet.support.toast.ToastCompat; import eu.siacs.conversations.xmpp.Jid; +import me.drakeet.support.toast.ToastCompat; import static eu.siacs.conversations.entities.Bookmark.printableValue; import static eu.siacs.conversations.utils.StringUtils.changed; @@ -65,7 +65,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private boolean mAdvancedMode = false; - private UiCallback renameCallback = new UiCallback() { + private final UiCallback renameCallback = new UiCallback() { @Override public void success(Conversation object) { displayToast(getString(R.string.your_nick_has_been_changed)); @@ -86,7 +86,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } }; - private OnClickListener mNotifyStatusClickListener = new OnClickListener() { + private final OnClickListener mNotifyStatusClickListener = new OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this); @@ -118,7 +118,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } }; - private OnClickListener mChangeConferenceSettings = new OnClickListener() { + private final OnClickListener mChangeConferenceSettings = new OnClickListener() { @Override public void onClick(View v) { final MucOptions mucOptions = mConversation.getMucOptions(); @@ -160,7 +160,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_muc_details); this.binding.changeConferenceButton.setOnClickListener(this.mChangeConferenceSettings); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(), R.string.nickname, diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 181ad281f..74f9e7068 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -6,7 +6,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; -import androidx.databinding.DataBindingUtil; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -14,9 +13,6 @@ import android.preference.PreferenceManager; import android.provider.ContactsContract.CommonDataKinds; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; -import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; import android.text.Spannable; import android.text.SpannableString; import android.text.style.RelativeSizeSpan; @@ -30,6 +26,10 @@ import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; + import org.openintents.openpgp.util.OpenPgpUtils; import java.util.Collection; @@ -73,14 +73,14 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp private MediaAdapter mMediaAdapter; private Contact contact; - private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() { + private final DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { xmppConnectionService.deleteContactOnServer(contact); } }; - private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() { + private final OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -96,7 +96,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } } }; - private OnCheckedChangeListener mOnReceiveCheckedChange = new OnCheckedChangeListener() { + private final OnCheckedChangeListener mOnReceiveCheckedChange = new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -197,7 +197,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp this.messageFingerprint = getIntent().getStringExtra("fingerprint"); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); binding.showInactiveDevices.setOnClickListener(v -> { showInactiveOmemo = !showInactiveOmemo; @@ -232,7 +232,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (grantResults.length > 0) if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (requestCode == REQUEST_SYNC_CONTACTS && xmppConnectionServiceBound) { @@ -371,22 +371,14 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp binding.detailsSendPresence.setText(R.string.send_presence_updates); } else { binding.detailsSendPresence.setText(R.string.preemptively_grant); - if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) { - binding.detailsSendPresence.setChecked(true); - } else { - binding.detailsSendPresence.setChecked(false); - } + binding.detailsSendPresence.setChecked(contact.getOption(Contact.Options.PREEMPTIVE_GRANT)); } if (contact.getOption(Contact.Options.TO)) { binding.detailsReceivePresence.setText(R.string.receive_presence_updates); binding.detailsReceivePresence.setChecked(true); } else { binding.detailsReceivePresence.setText(R.string.ask_for_presence_updates); - if (contact.getOption(Contact.Options.ASKING)) { - binding.detailsReceivePresence.setChecked(true); - } else { - binding.detailsReceivePresence.setChecked(false); - } + binding.detailsReceivePresence.setChecked(contact.getOption(Contact.Options.ASKING)); } if (contact.getAccount().isOnlineAndConnected()) { binding.detailsReceivePresence.setEnabled(true); @@ -476,8 +468,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp if (Config.supportOpenPgp() && contact.getPgpKeyId() != 0) { hasKeys = true; View view = inflater.inflate(R.layout.contact_key, binding.detailsContactKeys, false); - TextView key = (TextView) view.findViewById(R.id.key); - TextView keyType = (TextView) view.findViewById(R.id.key_type); + TextView key = view.findViewById(R.id.key); + TextView keyType = view.findViewById(R.id.key_type); keyType.setText(R.string.openpgp_key_id); if ("pgp".equals(messageFingerprint)) { keyType.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption_Highlight); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 8ffe98c78..8e23da5bc 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -2,6 +2,7 @@ package eu.siacs.conversations.ui; import android.content.Intent; import android.os.Bundle; + import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 8fd2cfd12..77bec0a1b 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -3,29 +3,22 @@ package eu.siacs.conversations.ui; import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; -import android.app.FragmentManager; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import androidx.databinding.DataBindingUtil; -import android.net.Uri; -import android.os.Build; -import android.preference.PreferenceManager; -import android.provider.MediaStore; -import androidx.annotation.IdRes; -import androidx.annotation.NonNull; -import androidx.annotation.StringRes; -import androidx.appcompat.app.AlertDialog; import android.app.Fragment; +import android.app.FragmentManager; import android.app.PendingIntent; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender.SendIntentException; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; -import androidx.core.view.inputmethod.InputConnectionCompat; -import androidx.core.view.inputmethod.InputContentInfoCompat; +import android.preference.PreferenceManager; +import android.provider.MediaStore; import android.text.Editable; import android.text.TextUtils; import android.util.Log; @@ -52,6 +45,14 @@ import android.widget.PopupMenu; import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; +import androidx.annotation.IdRes; +import androidx.annotation.NonNull; +import androidx.annotation.StringRes; +import androidx.appcompat.app.AlertDialog; +import androidx.core.view.inputmethod.InputConnectionCompat; +import androidx.core.view.inputmethod.InputContentInfoCompat; +import androidx.databinding.DataBindingUtil; + import com.google.common.base.Optional; import java.util.ArrayList; @@ -117,6 +118,7 @@ import eu.siacs.conversations.utils.StylingHelper; import eu.siacs.conversations.utils.TimeFrameUtils; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xml.Namespace; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection; @@ -125,7 +127,6 @@ import eu.siacs.conversations.xmpp.jingle.JingleFileTransferConnection; import eu.siacs.conversations.xmpp.jingle.Media; import eu.siacs.conversations.xmpp.jingle.OngoingRtpSession; import eu.siacs.conversations.xmpp.jingle.RtpCapability; -import eu.siacs.conversations.xmpp.Jid; import static eu.siacs.conversations.ui.XmppActivity.EXTRA_ACCOUNT; import static eu.siacs.conversations.ui.XmppActivity.REQUEST_INVITE_TO_CONVERSATION; @@ -848,7 +849,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke case ATTACHMENT_CHOICE_LOCATION: double latitude = data.getDoubleExtra("latitude", 0); double longitude = data.getDoubleExtra("longitude", 0); - Uri geo = Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude)); + Uri geo = Uri.parse("geo:" + latitude + "," + longitude); mediaPreviewAdapter.addMediaPreviews(Attachment.of(getActivity(), geo, Attachment.Type.LOCATION)); toggleInputMethod(); break; @@ -2099,7 +2100,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } stopScrolling(); - Log.d(Config.LOGTAG, "reInit(hasExtras=" + Boolean.toString(hasExtras) + ")"); + Log.d(Config.LOGTAG, "reInit(hasExtras=" + hasExtras + ")"); if (this.conversation.isRead() && hasExtras) { Log.d(Config.LOGTAG, "trimming conversation"); @@ -2122,7 +2123,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke refresh(false); activity.invalidateOptionsMenu(); this.conversation.messagesLoaded.set(true); - Log.d(Config.LOGTAG, "scrolledToBottomAndNoPending=" + Boolean.toString(scrolledToBottomAndNoPending)); + Log.d(Config.LOGTAG, "scrolledToBottomAndNoPending=" + scrolledToBottomAndNoPending); if (hasExtras || scrolledToBottomAndNoPending) { resetUnreadMessagesCount(); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java index caac16ec7..7f33ef05f 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java @@ -39,21 +39,21 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; -import androidx.databinding.DataBindingUtil; import android.net.Uri; import android.os.Bundle; import android.provider.Settings; -import androidx.annotation.IdRes; -import androidx.annotation.NonNull; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; +import androidx.annotation.IdRes; +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; + import org.openintents.openpgp.util.OpenPgpApi; import java.util.Arrays; @@ -80,8 +80,8 @@ import eu.siacs.conversations.utils.EmojiWrapper; import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.SignupUtils; import eu.siacs.conversations.utils.XmppUri; -import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP; @@ -97,7 +97,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio public static final String EXTRA_POST_INIT_ACTION = "post_init_action"; public static final String POST_ACTION_RECORD_VOICE = "record_voice"; - private static List VIEW_AND_SHARE_ACTIONS = Arrays.asList( + private static final List VIEW_AND_SHARE_ACTIONS = Arrays.asList( ACTION_VIEW_CONVERSATION, Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE @@ -114,7 +114,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio private final PendingItem postponedActivityResult = new PendingItem<>(); private ActivityConversationsBinding binding; private boolean mActivityPaused = true; - private AtomicBoolean mRedirectInProcess = new AtomicBoolean(false); + private final AtomicBoolean mRedirectInProcess = new AtomicBoolean(false); private static boolean isViewOrShareIntent(Intent i) { Log.d(Config.LOGTAG, "action: " + (i == null ? null : i.getAction())); @@ -359,7 +359,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio ConversationMenuConfigurator.reloadFeatures(this); OmemoSetting.load(this); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle); this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview); @@ -660,7 +660,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio if (!mActivityPaused && pendingViewIntent.peek() == null) { xmppConnectionService.sendReadMarker(conversation, upToUuid); } else { - Log.d(Config.LOGTAG, "ignoring read callback. mActivityPaused=" + Boolean.toString(mActivityPaused)); + Log.d(Config.LOGTAG, "ignoring read callback. mActivityPaused=" + mActivityPaused); } } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java index 17bbdd141..eebd94df5 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java @@ -33,14 +33,9 @@ import android.app.Activity; import android.app.AlertDialog; import android.app.Fragment; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.graphics.Canvas; import android.graphics.Paint; import android.os.Bundle; -import com.google.android.material.snackbar.Snackbar; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.recyclerview.widget.ItemTouchHelper; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; @@ -50,6 +45,12 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Toast; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.ItemTouchHelper; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.google.android.material.snackbar.Snackbar; import com.google.common.collect.Collections2; import java.util.ArrayList; @@ -88,9 +89,9 @@ public class ConversationsOverviewFragment extends XmppFragment { private ConversationAdapter conversationsAdapter; private XmppActivity activity; private float mSwipeEscapeVelocity = 0f; - private PendingActionHelper pendingActionHelper = new PendingActionHelper(); + private final PendingActionHelper pendingActionHelper = new PendingActionHelper(); - private ItemTouchHelper.SimpleCallback callback = new ItemTouchHelper.SimpleCallback(0,LEFT|RIGHT) { + private final ItemTouchHelper.SimpleCallback callback = new ItemTouchHelper.SimpleCallback(0,LEFT|RIGHT) { @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { //todo maybe we can manually changing the position of the conversation diff --git a/src/main/java/eu/siacs/conversations/ui/CreatePrivateGroupChatDialog.java b/src/main/java/eu/siacs/conversations/ui/CreatePrivateGroupChatDialog.java index 5ce510a22..6e4098264 100644 --- a/src/main/java/eu/siacs/conversations/ui/CreatePrivateGroupChatDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/CreatePrivateGroupChatDialog.java @@ -2,13 +2,14 @@ package eu.siacs.conversations.ui; import android.app.Dialog; import android.content.Context; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; -import androidx.appcompat.app.AlertDialog; import android.widget.Spinner; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; +import androidx.fragment.app.DialogFragment; + import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/eu/siacs/conversations/ui/CreatePublicChannelDialog.java b/src/main/java/eu/siacs/conversations/ui/CreatePublicChannelDialog.java index 4ddbcb551..3c23b06eb 100644 --- a/src/main/java/eu/siacs/conversations/ui/CreatePublicChannelDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/CreatePublicChannelDialog.java @@ -4,11 +4,7 @@ import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; -import androidx.appcompat.app.AlertDialog; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -16,6 +12,11 @@ import android.view.View; import android.widget.AdapterView; import android.widget.Button; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; +import androidx.fragment.app.DialogFragment; + import java.security.SecureRandom; import java.util.ArrayList; import java.util.Collection; @@ -29,8 +30,8 @@ import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.interfaces.OnBackendConnected; import eu.siacs.conversations.ui.util.DelayedHintHelper; import eu.siacs.conversations.utils.CryptoHelper; -import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.XmppConnection; public class CreatePublicChannelDialog extends DialogFragment implements OnBackendConnected { diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 8765e8529..a8f8f3cd2 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -6,7 +6,6 @@ import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.IntentSender; import android.content.SharedPreferences; -import androidx.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; @@ -16,11 +15,6 @@ import android.preference.PreferenceManager; import android.provider.Settings; import android.security.KeyChain; import android.security.KeyChainAliasCallback; -import com.google.android.material.textfield.TextInputLayout; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AlertDialog.Builder; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -34,6 +28,12 @@ import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AlertDialog.Builder; +import androidx.databinding.DataBindingUtil; + +import com.google.android.material.textfield.TextInputLayout; import com.google.common.base.CharMatcher; import org.openintents.openpgp.util.OpenPgpUtils; @@ -317,7 +317,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } }; - private View.OnFocusChangeListener mEditTextFocusListener = new View.OnFocusChangeListener() { + private final View.OnFocusChangeListener mEditTextFocusListener = new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean b) { EditText et = (EditText) view; @@ -597,7 +597,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.mSavedInstanceInit = savedInstanceState.getBoolean("initMode", false); } this.binding = DataBindingUtil.setContentView(this, R.layout.activity_edit_account); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); binding.accountJid.addTextChangedListener(this.mTextWatcher); binding.accountJid.setOnFocusChangeListener(this.mEditTextFocusListener); this.binding.accountPassword.addTextChangedListener(this.mTextWatcher); diff --git a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java index a6481f2f3..2f8c98d76 100644 --- a/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/EnterJidDialog.java @@ -2,16 +2,17 @@ package eu.siacs.conversations.ui; import android.app.Activity; import android.app.Dialog; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.fragment.app.DialogFragment; -import androidx.appcompat.app.AlertDialog; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.ArrayAdapter; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; +import androidx.fragment.app.DialogFragment; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; diff --git a/src/main/java/eu/siacs/conversations/ui/JoinConferenceDialog.java b/src/main/java/eu/siacs/conversations/ui/JoinConferenceDialog.java index 9a55467f9..e17aab3a4 100644 --- a/src/main/java/eu/siacs/conversations/ui/JoinConferenceDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/JoinConferenceDialog.java @@ -2,18 +2,18 @@ package eu.siacs.conversations.ui; import android.app.Activity; import android.app.Dialog; -import androidx.databinding.DataBindingUtil; -import androidx.annotation.NonNull; -import com.google.android.material.textfield.TextInputLayout; -import androidx.fragment.app.DialogFragment; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import androidx.appcompat.app.AlertDialog; -import android.view.KeyEvent; import android.widget.AutoCompleteTextView; import android.widget.Spinner; -import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; +import androidx.fragment.app.DialogFragment; + +import com.google.android.material.textfield.TextInputLayout; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/eu/siacs/conversations/ui/LocationActivity.java b/src/main/java/eu/siacs/conversations/ui/LocationActivity.java index 487218c52..3e830c7c0 100644 --- a/src/main/java/eu/siacs/conversations/ui/LocationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/LocationActivity.java @@ -14,11 +14,12 @@ import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; import android.provider.Settings; -import androidx.annotation.BoolRes; -import androidx.annotation.NonNull; import android.util.Log; import android.view.MenuItem; +import androidx.annotation.BoolRes; +import androidx.annotation.NonNull; + import org.osmdroid.api.IGeoPoint; import org.osmdroid.api.IMapController; import org.osmdroid.config.Configuration; diff --git a/src/main/java/eu/siacs/conversations/ui/MediaBrowserActivity.java b/src/main/java/eu/siacs/conversations/ui/MediaBrowserActivity.java index 7dbf9ac16..3793203dd 100644 --- a/src/main/java/eu/siacs/conversations/ui/MediaBrowserActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/MediaBrowserActivity.java @@ -2,18 +2,17 @@ package eu.siacs.conversations.ui; import android.content.Context; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.widget.Toolbar; + +import androidx.databinding.DataBindingUtil; import java.util.List; import eu.siacs.conversations.R; +import eu.siacs.conversations.databinding.ActivityMediaBrowserBinding; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; - -import eu.siacs.conversations.databinding.ActivityMediaBrowserBinding; import eu.siacs.conversations.ui.adapter.MediaAdapter; import eu.siacs.conversations.ui.interfaces.OnMediaLoaded; import eu.siacs.conversations.ui.util.Attachment; @@ -30,7 +29,7 @@ public class MediaBrowserActivity extends XmppActivity implements OnMediaLoaded protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this,R.layout.activity_media_browser); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); mMediaAdapter = new MediaAdapter(this, R.dimen.media_size); this.binding.media.setAdapter(mMediaAdapter); diff --git a/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java b/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java index 490ed8041..7f8a55a72 100644 --- a/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java @@ -28,9 +28,8 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnClickListener; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; + import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; diff --git a/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java b/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java index 3c5ab5dfd..2f05be90f 100644 --- a/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/MucUsersActivity.java @@ -2,9 +2,7 @@ package eu.siacs.conversations.ui; import android.content.Context; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -15,6 +13,8 @@ import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.Toast; +import androidx.databinding.DataBindingUtil; + import java.util.ArrayList; import java.util.Collections; import java.util.Locale; @@ -90,7 +90,7 @@ public class MucUsersActivity extends XmppActivity implements XmppConnectionServ protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityMucUsersBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_muc_users); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar(), true); this.userAdapter = new UserAdapter(getPreferences().getBoolean("advanced_muc_mode", false)); binding.list.setAdapter(this.userAdapter); diff --git a/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java b/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java index c83c073a3..89fdae333 100644 --- a/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java @@ -1,17 +1,16 @@ package eu.siacs.conversations.ui; -import androidx.databinding.DataBindingUtil; - -import androidx.appcompat.app.AlertDialog; import android.content.Intent; import android.view.ContextMenu; import android.view.MenuItem; import android.view.View; import android.widget.CompoundButton; - import android.widget.LinearLayout; import android.widget.Toast; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; + import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.axolotl.FingerprintStatus; @@ -205,7 +204,7 @@ public abstract class OmemoActivity extends XmppActivity { } @Override - public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { ScanActivity.onRequestPermissionResult(this, requestCode, grantResults); } } diff --git a/src/main/java/eu/siacs/conversations/ui/PublishGroupChatProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishGroupChatProfilePictureActivity.java index fba484a67..81b0ae15c 100644 --- a/src/main/java/eu/siacs/conversations/ui/PublishGroupChatProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/PublishGroupChatProfilePictureActivity.java @@ -30,16 +30,16 @@ package eu.siacs.conversations.ui; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; -import androidx.annotation.StringRes; -import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.View; import android.widget.Toast; +import androidx.annotation.StringRes; +import androidx.databinding.DataBindingUtil; + import com.theartofdev.edmodo.cropper.CropImage; import eu.siacs.conversations.Config; @@ -91,7 +91,7 @@ public class PublishGroupChatProfilePictureActivity extends XmppActivity impleme public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_publish_profile_picture); - setSupportActionBar((Toolbar) this.binding.toolbar); + setSupportActionBar(this.binding.toolbar); configureActionBar(getSupportActionBar()); this.binding.cancelButton.setOnClickListener((v) -> this.finish()); this.binding.secondaryHint.setVisibility(View.GONE); diff --git a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java index d1901fac2..f0e715218 100644 --- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java @@ -6,7 +6,6 @@ import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import androidx.annotation.StringRes; import android.util.Log; import android.view.View; import android.view.View.OnLongClickListener; @@ -15,6 +14,8 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.StringRes; + import com.theartofdev.edmodo.cropper.CropImage; import java.util.concurrent.atomic.AtomicBoolean; @@ -40,8 +41,8 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC private Account account; private boolean support = false; private boolean publishing = false; - private AtomicBoolean handledExternalUri = new AtomicBoolean(false); - private OnLongClickListener backToDefaultListener = new OnLongClickListener() { + private final AtomicBoolean handledExternalUri = new AtomicBoolean(false); + private final OnLongClickListener backToDefaultListener = new OnLongClickListener() { @Override public boolean onLongClick(View v) { diff --git a/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java b/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java index def935efd..5e4c90048 100644 --- a/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RecordingActivity.java @@ -3,7 +3,6 @@ package eu.siacs.conversations.ui; import android.app.Activity; import android.content.Context; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.media.MediaRecorder; import android.net.Uri; import android.os.Bundle; @@ -15,6 +14,8 @@ import android.view.View; import android.view.WindowManager; import android.widget.Toast; +import androidx.databinding.DataBindingUtil; + import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; @@ -39,10 +40,10 @@ public class RecordingActivity extends Activity implements View.OnClickListener private MediaRecorder mRecorder; private long mStartTime = 0; - private CountDownLatch outputFileWrittenLatch = new CountDownLatch(1); + private final CountDownLatch outputFileWrittenLatch = new CountDownLatch(1); - private Handler mHandler = new Handler(); - private Runnable mTickExecutor = new Runnable() { + private final Handler mHandler = new Handler(); + private final Runnable mTickExecutor = new Runnable() { @Override public void run() { tick(); diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index fca5516e0..6a2d19f44 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -7,15 +7,11 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; -import androidx.databinding.DataBindingUtil; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.PowerManager; import android.os.SystemClock; -import androidx.annotation.NonNull; -import androidx.annotation.RequiresApi; -import androidx.annotation.StringRes; import android.util.Log; import android.util.Rational; import android.view.Menu; @@ -24,6 +20,11 @@ import android.view.View; import android.view.WindowManager; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; +import androidx.annotation.StringRes; +import androidx.databinding.DataBindingUtil; + import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; @@ -55,12 +56,12 @@ import eu.siacs.conversations.ui.util.MainThreadExecutor; import eu.siacs.conversations.utils.PermissionUtils; import eu.siacs.conversations.utils.TimeFrameUtils; import eu.siacs.conversations.xml.Namespace; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection; import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager; import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection; import eu.siacs.conversations.xmpp.jingle.Media; import eu.siacs.conversations.xmpp.jingle.RtpEndUserState; -import eu.siacs.conversations.xmpp.Jid; import static eu.siacs.conversations.utils.PermissionUtils.getFirstDenied; import static java.util.Arrays.asList; @@ -99,8 +100,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe private ActivityRtpSessionBinding binding; private PowerManager.WakeLock mProximityWakeLock; - private Handler mHandler = new Handler(); - private Runnable mTickExecutor = new Runnable() { + private final Handler mHandler = new Handler(); + private final Runnable mTickExecutor = new Runnable() { @Override public void run() { updateCallDuration(); diff --git a/src/main/java/eu/siacs/conversations/ui/ScanActivity.java b/src/main/java/eu/siacs/conversations/ui/ScanActivity.java index ad5aa3266..cebd19bc3 100644 --- a/src/main/java/eu/siacs/conversations/ui/ScanActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ScanActivity.java @@ -17,18 +17,6 @@ package eu.siacs.conversations.ui; -import java.util.EnumMap; -import java.util.Map; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.PlanarYUVLuminanceSource; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.ResultPointCallback; -import com.google.zxing.common.HybridBinarizer; -import com.google.zxing.qrcode.QRCodeReader; - import android.Manifest; import android.app.Activity; import android.content.Context; @@ -45,8 +33,6 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Process; import android.os.Vibrator; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; import android.util.Log; import android.view.KeyEvent; import android.view.Surface; @@ -56,6 +42,21 @@ import android.view.View; import android.view.WindowManager; import android.widget.Toast; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import com.google.zxing.BinaryBitmap; +import com.google.zxing.DecodeHintType; +import com.google.zxing.PlanarYUVLuminanceSource; +import com.google.zxing.ReaderException; +import com.google.zxing.Result; +import com.google.zxing.ResultPointCallback; +import com.google.zxing.common.HybridBinarizer; +import com.google.zxing.qrcode.QRCodeReader; + +import java.util.EnumMap; +import java.util.Map; + import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.ui.service.CameraManager; @@ -73,7 +74,7 @@ public final class ScanActivity extends Activity implements SurfaceTextureListen private static final long VIBRATE_DURATION = 50L; private static final long AUTO_FOCUS_INTERVAL_MS = 2500L; - private static boolean DISABLE_CONTINUOUS_AUTOFOCUS = Build.MODEL.equals("GT-I9100") // Galaxy S2 + private static final boolean DISABLE_CONTINUOUS_AUTOFOCUS = Build.MODEL.equals("GT-I9100") // Galaxy S2 || Build.MODEL.equals("SGH-T989") // Galaxy S2 || Build.MODEL.equals("SGH-T989D") // Galaxy S2 X || Build.MODEL.equals("SAMSUNG-SGH-I727") // Galaxy S2 Skyrocket diff --git a/src/main/java/eu/siacs/conversations/ui/SearchActivity.java b/src/main/java/eu/siacs/conversations/ui/SearchActivity.java index 6ff7d0764..f5f4eb175 100644 --- a/src/main/java/eu/siacs/conversations/ui/SearchActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SearchActivity.java @@ -30,9 +30,7 @@ package eu.siacs.conversations.ui; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; @@ -44,6 +42,8 @@ import android.view.View; import android.widget.AdapterView; import android.widget.EditText; +import androidx.databinding.DataBindingUtil; + import com.google.common.base.Strings; import java.lang.ref.WeakReference; @@ -61,10 +61,10 @@ import eu.siacs.conversations.ui.adapter.MessageAdapter; import eu.siacs.conversations.ui.interfaces.OnSearchResultsAvailable; import eu.siacs.conversations.ui.util.ChangeWatcher; import eu.siacs.conversations.ui.util.DateSeparator; -import eu.siacs.conversations.ui.util.StyledAttributes; import eu.siacs.conversations.ui.util.ListViewUtils; import eu.siacs.conversations.ui.util.PendingItem; import eu.siacs.conversations.ui.util.ShareUtil; +import eu.siacs.conversations.ui.util.StyledAttributes; import eu.siacs.conversations.utils.FtsUtils; import eu.siacs.conversations.utils.MessageUtils; @@ -95,7 +95,7 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc } super.onCreate(bundle); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_search); - setSupportActionBar((Toolbar) this.binding.toolbar); + setSupportActionBar(this.binding.toolbar); configureActionBar(getSupportActionBar()); this.messageListAdapter = new MessageAdapter(this, this.messages); this.messageListAdapter.setOnContactPictureClicked(this); diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index 7683bb732..3632c9cd8 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -1,19 +1,15 @@ package eu.siacs.conversations.ui; -import android.preference.CheckBoxPreference; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; -import androidx.appcompat.app.AlertDialog; import android.app.FragmentManager; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.pm.PackageManager; - import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceCategory; @@ -23,6 +19,10 @@ import android.provider.MediaStore; import android.util.Log; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.core.content.ContextCompat; + import java.io.File; import java.security.KeyStoreException; import java.util.ArrayList; @@ -188,11 +188,7 @@ public class SettingsActivity extends XmppActivity implements } else if (selectedItems.contains(indexSelected)) { selectedItems.remove(Integer.valueOf(indexSelected)); } - if (selectedItems.size() > 0) - ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true); - else { - ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false); - } + ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(selectedItems.size() > 0); }); dialogBuilder.setPositiveButton( diff --git a/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java index dc36da9bf..641a01e5c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareLocationActivity.java @@ -3,16 +3,17 @@ package eu.siacs.conversations.ui; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; -import androidx.databinding.DataBindingUtil; import android.location.Location; import android.location.LocationListener; import android.os.Build; import android.os.Bundle; -import androidx.annotation.NonNull; -import com.google.android.material.snackbar.Snackbar; -import androidx.appcompat.widget.Toolbar; import android.view.View; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; + +import com.google.android.material.snackbar.Snackbar; + import org.osmdroid.api.IGeoPoint; import org.osmdroid.util.GeoPoint; @@ -54,7 +55,7 @@ public class ShareLocationActivity extends LocationActivity implements LocationL super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this,R.layout.activity_share_location); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); setupMapView(binding.map, LocationProvider.getGeoPoint(this)); diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index df8b2a263..a55df7105 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -4,13 +4,14 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + import java.util.ArrayList; import java.util.List; @@ -44,7 +45,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer private static final int REQUEST_START_NEW_CONVERSATION = 0x0501; private ConversationAdapter mAdapter; - private List mConversations = new ArrayList<>(); + private final List mConversations = new ArrayList<>(); protected void onActivityResult(int requestCode, int resultCode, final Intent data) { @@ -63,7 +64,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer } @Override - public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (grantResults.length > 0) if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (requestCode == REQUEST_STORAGE_PERMISSION) { diff --git a/src/main/java/eu/siacs/conversations/ui/ShortcutActivity.java b/src/main/java/eu/siacs/conversations/ui/ShortcutActivity.java index f2e73307e..33164c95c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShortcutActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShortcutActivity.java @@ -4,16 +4,14 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import androidx.appcompat.app.ActionBar; -import android.util.Log; -import android.view.View; import android.view.inputmethod.InputMethodManager; +import androidx.appcompat.app.ActionBar; + import java.util.Arrays; import java.util.Collections; import java.util.List; -import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; diff --git a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java index ffd9e1f79..43c55de49 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShowLocationActivity.java @@ -5,18 +5,18 @@ import android.content.ClipData; import android.content.ClipboardManager; import android.content.ComponentName; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.location.Location; import android.location.LocationListener; import android.net.Uri; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.appcompat.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; + import org.osmdroid.util.GeoPoint; import java.util.HashMap; @@ -48,7 +48,7 @@ public class ShowLocationActivity extends LocationActivity implements LocationLi super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this,R.layout.activity_show_location); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); setupMapView(this.binding.map, this.loc); @@ -193,7 +193,7 @@ public class ShowLocationActivity extends LocationActivity implements LocationLi private void startNavigation() { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( "google.navigation:q=" + - String.valueOf(this.loc.getLatitude()) + "," + String.valueOf(this.loc.getLongitude()) + this.loc.getLatitude() + "," + this.loc.getLongitude() ))); } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index b2d33a7d1..bfb922fa1 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -9,22 +9,9 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; -import androidx.databinding.DataBindingUtil; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.google.android.material.textfield.TextInputLayout; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentTransaction; -import androidx.viewpager.widget.PagerAdapter; -import androidx.viewpager.widget.ViewPager; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.Html; import android.text.TextWatcher; @@ -50,6 +37,20 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.databinding.DataBindingUtil; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; + +import com.google.android.material.textfield.TextInputLayout; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -77,9 +78,9 @@ import eu.siacs.conversations.ui.util.SoftKeyboardUtils; import eu.siacs.conversations.ui.widget.SwipeRefreshListFragment; import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.XmppUri; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnUpdateBlocklist; import eu.siacs.conversations.xmpp.XmppConnection; -import eu.siacs.conversations.xmpp.Jid; public class StartConversationActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate, OnRosterUpdate, OnUpdateBlocklist, CreatePrivateGroupChatDialog.CreateConferenceDialogListener, JoinConferenceDialog.JoinConferenceDialogListener, SwipeRefreshLayout.OnRefreshListener, CreatePublicChannelDialog.CreatePublicChannelDialogListener { @@ -261,8 +262,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_start_conversation); - Toolbar toolbar = (Toolbar) binding.toolbar; - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); binding.speedDial.inflate(R.menu.start_conversation_fab_submenu); @@ -760,7 +760,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (grantResults.length > 0) if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { ScanActivity.onRequestPermissionResult(this, requestCode, grantResults); diff --git a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java index 5aa3479dd..ece042ffd 100644 --- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java @@ -2,10 +2,7 @@ package eu.siacs.conversations.ui; import android.app.AlertDialog; import android.content.Intent; -import androidx.databinding.DataBindingUtil; import android.os.Bundle; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.Gravity; import android.view.Menu; @@ -14,6 +11,9 @@ import android.view.View; import android.view.View.OnClickListener; import android.widget.Toast; +import androidx.appcompat.app.ActionBar; +import androidx.databinding.DataBindingUtil; + import org.whispersystems.libsignal.IdentityKey; import java.util.ArrayList; @@ -37,8 +37,8 @@ import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.IrregularUnicodeDetector; import eu.siacs.conversations.utils.XmppUri; -import eu.siacs.conversations.xmpp.OnKeyStatusUpdated; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.OnKeyStatusUpdated; public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdated { @@ -55,7 +55,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat commitTrusts(); finishOk(false); }; - private AtomicBoolean mUseCameraHintShown = new AtomicBoolean(false); + private final AtomicBoolean mUseCameraHintShown = new AtomicBoolean(false); private AxolotlService.FetchStatus lastFetchReport = AxolotlService.FetchStatus.SUCCESS; private Toast mUseCameraHintToast = null; private ActivityTrustKeysBinding binding; @@ -82,7 +82,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat binding.cancelButton.setOnClickListener(mCancelButtonListener); binding.saveButton.setOnClickListener(mSaveButtonListener); - setSupportActionBar((Toolbar) binding.toolbar); + setSupportActionBar(binding.toolbar); configureActionBar(getSupportActionBar()); if (savedInstanceState != null) { @@ -151,7 +151,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat } } else { reloadFingerprints(); - Log.d(Config.LOGTAG, "xmpp uri was: " + uri.getJid() + " has Fingerprints: " + Boolean.toString(uri.hasFingerprints())); + Log.d(Config.LOGTAG, "xmpp uri was: " + uri.getJid() + " has Fingerprints: " + uri.hasFingerprints()); Toast.makeText(this, R.string.barcode_does_not_contain_fingerprints_for_this_conversation, Toast.LENGTH_SHORT).show(); } populateView(); @@ -437,7 +437,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat synchronized (this.foreignKeysToTrust) { for (Jid jid : contactJids) { Map fingerprints = foreignKeysToTrust.get(jid); - if (hasNoOtherTrustedKeys(jid) && (fingerprints == null || !fingerprints.values().contains(true))) { + if (hasNoOtherTrustedKeys(jid) && (fingerprints == null || !fingerprints.containsValue(true))) { lock(); return; } diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java index e4acde536..f868e3337 100644 --- a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java @@ -7,10 +7,11 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import androidx.core.content.ContextCompat; -import androidx.appcompat.app.AppCompatActivity; import android.widget.Toast; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; + import com.google.common.base.Strings; import java.util.List; diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 15887880e..b3591551b 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -19,7 +19,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.TypedArray; -import androidx.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Point; @@ -35,12 +34,6 @@ import android.os.IBinder; import android.os.PowerManager; import android.os.SystemClock; import android.preference.PreferenceManager; -import androidx.annotation.BoolRes; -import androidx.annotation.NonNull; -import androidx.annotation.StringRes; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AlertDialog.Builder; -import androidx.appcompat.app.AppCompatDelegate; import android.text.InputType; import android.util.DisplayMetrics; import android.util.Log; @@ -50,6 +43,14 @@ import android.view.View; import android.widget.ImageView; import android.widget.Toast; +import androidx.annotation.BoolRes; +import androidx.annotation.NonNull; +import androidx.annotation.StringRes; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AlertDialog.Builder; +import androidx.appcompat.app.AppCompatDelegate; +import androidx.databinding.DataBindingUtil; + import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -77,9 +78,9 @@ import eu.siacs.conversations.ui.util.SoftKeyboardUtils; import eu.siacs.conversations.utils.AccountUtils; import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.ThemeHelper; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnKeyStatusUpdated; import eu.siacs.conversations.xmpp.OnUpdateBlocklist; -import eu.siacs.conversations.xmpp.Jid; public abstract class XmppActivity extends ActionBarActivity { @@ -119,12 +120,12 @@ public abstract class XmppActivity extends ActionBarActivity { }; private DisplayMetrics metrics; private long mLastUiRefresh = 0; - private Handler mRefreshUiHandler = new Handler(); - private Runnable mRefreshUiRunnable = () -> { + private final Handler mRefreshUiHandler = new Handler(); + private final Runnable mRefreshUiRunnable = () -> { mLastUiRefresh = SystemClock.elapsedRealtime(); refreshUiReal(); }; - private UiCallback adhocCallback = new UiCallback() { + private final UiCallback adhocCallback = new UiCallback() { @Override public void success(final Conversation conversation) { runOnUiThread(() -> { @@ -913,7 +914,7 @@ public abstract class XmppActivity extends ActionBarActivity { public static class ConferenceInvite { private String uuid; - private List jids = new ArrayList<>(); + private final List jids = new ArrayList<>(); public static ConferenceInvite parse(Intent data) { ConferenceInvite invite = new ConferenceInvite(); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java index 6bbe3d979..b070a63bb 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java @@ -1,13 +1,13 @@ package eu.siacs.conversations.ui.adapter; -import androidx.databinding.DataBindingUtil; - -import androidx.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; + import java.util.List; import eu.siacs.conversations.Config; @@ -20,8 +20,8 @@ import eu.siacs.conversations.ui.util.StyledAttributes; public class AccountAdapter extends ArrayAdapter { - private XmppActivity activity; - private boolean showStateButton; + private final XmppActivity activity; + private final boolean showStateButton; public AccountAdapter(XmppActivity activity, List objects, boolean showStateButton) { super(activity, 0, objects); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java index 6966da365..ae9a67f6b 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java @@ -1,17 +1,18 @@ package eu.siacs.conversations.ui.adapter; import android.app.Activity; -import androidx.databinding.DataBindingUtil; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.ListAdapter; -import androidx.recyclerview.widget.DiffUtil; -import androidx.recyclerview.widget.RecyclerView; import android.text.TextUtils; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.DiffUtil; +import androidx.recyclerview.widget.ListAdapter; +import androidx.recyclerview.widget.RecyclerView; + import java.util.Locale; import eu.siacs.conversations.R; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index b97a39c5b..049703597 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -1,14 +1,15 @@ package eu.siacs.conversations.ui.adapter; -import androidx.databinding.DataBindingUtil; import android.graphics.Typeface; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; import android.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.RecyclerView; + import com.google.common.base.Optional; import java.util.List; @@ -25,13 +26,13 @@ import eu.siacs.conversations.ui.util.StyledAttributes; import eu.siacs.conversations.utils.EmojiWrapper; import eu.siacs.conversations.utils.IrregularUnicodeDetector; import eu.siacs.conversations.utils.UIHelper; -import eu.siacs.conversations.xmpp.jingle.OngoingRtpSession; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.jingle.OngoingRtpSession; public class ConversationAdapter extends RecyclerView.Adapter { - private XmppActivity activity; - private List conversations; + private final XmppActivity activity; + private final List conversations; private OnConversationClickListener listener; public ConversationAdapter(XmppActivity activity, List conversations) { diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java index ba59f52b9..08f8fcd32 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java @@ -1,10 +1,11 @@ package eu.siacs.conversations.ui.adapter; import android.content.Context; -import androidx.annotation.NonNull; import android.widget.ArrayAdapter; import android.widget.Filter; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -15,10 +16,10 @@ import eu.siacs.conversations.Config; public class KnownHostsAdapter extends ArrayAdapter { - private static Pattern E164_PATTERN = Pattern.compile("^\\+[1-9]\\d{1,14}$"); + private static final Pattern E164_PATTERN = Pattern.compile("^\\+[1-9]\\d{1,14}$"); private ArrayList domains; - private Filter domainFilter = new Filter() { + private final Filter domainFilter = new Filter() { @Override protected FilterResults performFiltering(CharSequence constraint) { diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java index cea63f2ee..4e7213380 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ListItemAdapter.java @@ -1,7 +1,6 @@ package eu.siacs.conversations.ui.adapter; import android.content.SharedPreferences; -import androidx.databinding.DataBindingUtil; import android.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.View; @@ -10,6 +9,8 @@ import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; +import androidx.databinding.DataBindingUtil; + import com.wefika.flowlayout.FlowLayout; import java.util.List; @@ -30,7 +31,7 @@ public class ListItemAdapter extends ArrayAdapter { protected XmppActivity activity; private boolean showDynamicTags = false; private OnTagClickedListener mOnTagClickedListener = null; - private View.OnClickListener onTagTvClick = view -> { + private final View.OnClickListener onTagTvClick = view -> { if (view instanceof TextView && mOnTagClickedListener != null) { TextView tv = (TextView) view; final String tag = tv.getText().toString(); diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java index a1212a68c..75ab964f4 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java @@ -2,20 +2,21 @@ package eu.siacs.conversations.ui.adapter; import android.content.Context; import android.content.res.Resources; -import androidx.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import androidx.annotation.AttrRes; -import androidx.annotation.DimenRes; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.ImageView; +import androidx.annotation.AttrRes; +import androidx.annotation.DimenRes; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.RecyclerView; + import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MediaPreviewAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MediaPreviewAdapter.java index 49981c623..73f24fe15 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MediaPreviewAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MediaPreviewAdapter.java @@ -4,19 +4,20 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.res.Resources; -import androidx.databinding.DataBindingUtil; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.RecyclerView; + import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 9d092af6c..af895bc0b 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -7,8 +7,6 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.Typeface; import android.preference.PreferenceManager; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableStringBuilder; @@ -28,6 +26,9 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + import com.google.common.base.Strings; import java.net.URL; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/PresenceTemplateAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/PresenceTemplateAdapter.java index 5fe4a727d..62526da62 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/PresenceTemplateAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/PresenceTemplateAdapter.java @@ -30,10 +30,11 @@ package eu.siacs.conversations.ui.adapter; import android.content.Context; -import androidx.annotation.NonNull; import android.widget.ArrayAdapter; import android.widget.Filter; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.List; import java.util.Locale; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/UserAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/UserAdapter.java index f96d2dac5..41bfb24a1 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/UserAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/UserAdapter.java @@ -2,16 +2,17 @@ package eu.siacs.conversations.ui.adapter; import android.app.PendingIntent; import android.content.IntentSender; -import androidx.databinding.DataBindingUtil; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.ListAdapter; -import androidx.recyclerview.widget.DiffUtil; -import androidx.recyclerview.widget.RecyclerView; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.DiffUtil; +import androidx.recyclerview.widget.ListAdapter; +import androidx.recyclerview.widget.RecyclerView; + import org.openintents.openpgp.util.OpenPgpUtils; import eu.siacs.conversations.R; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/UserPreviewAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/UserPreviewAdapter.java index 77c4734a8..14920c9c6 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/UserPreviewAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/UserPreviewAdapter.java @@ -1,14 +1,15 @@ package eu.siacs.conversations.ui.adapter; -import androidx.databinding.DataBindingUtil; -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.ListAdapter; -import androidx.recyclerview.widget.RecyclerView; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.databinding.DataBindingUtil; +import androidx.recyclerview.widget.ListAdapter; +import androidx.recyclerview.widget.RecyclerView; + import eu.siacs.conversations.R; import eu.siacs.conversations.databinding.UserPreviewBinding; import eu.siacs.conversations.entities.MucOptions; diff --git a/src/main/java/eu/siacs/conversations/ui/forms/FormBooleanFieldWrapper.java b/src/main/java/eu/siacs/conversations/ui/forms/FormBooleanFieldWrapper.java index 6cb357a90..0c85d88ba 100644 --- a/src/main/java/eu/siacs/conversations/ui/forms/FormBooleanFieldWrapper.java +++ b/src/main/java/eu/siacs/conversations/ui/forms/FormBooleanFieldWrapper.java @@ -16,7 +16,7 @@ public class FormBooleanFieldWrapper extends FormFieldWrapper { protected FormBooleanFieldWrapper(Context context, Field field) { super(context, field); - checkBox = (CheckBox) view.findViewById(R.id.field); + checkBox = view.findViewById(R.id.field); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { @@ -28,7 +28,7 @@ public class FormBooleanFieldWrapper extends FormFieldWrapper { @Override protected void setLabel(String label, boolean required) { - CheckBox checkBox = (CheckBox) view.findViewById(R.id.field); + CheckBox checkBox = view.findViewById(R.id.field); checkBox.setText(createSpannableLabelString(label, required)); } diff --git a/src/main/java/eu/siacs/conversations/ui/forms/FormJidSingleFieldWrapper.java b/src/main/java/eu/siacs/conversations/ui/forms/FormJidSingleFieldWrapper.java index 0cb21ed93..00f0899c1 100644 --- a/src/main/java/eu/siacs/conversations/ui/forms/FormJidSingleFieldWrapper.java +++ b/src/main/java/eu/siacs/conversations/ui/forms/FormJidSingleFieldWrapper.java @@ -6,8 +6,8 @@ import android.text.InputType; import java.util.List; import eu.siacs.conversations.R; -import eu.siacs.conversations.xmpp.forms.Field; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.forms.Field; public class FormJidSingleFieldWrapper extends FormTextFieldWrapper { @@ -34,7 +34,7 @@ public class FormJidSingleFieldWrapper extends FormTextFieldWrapper { @Override protected void setValues(List values) { - StringBuilder builder = new StringBuilder(""); + StringBuilder builder = new StringBuilder(); for(String value : values) { builder.append(value); } diff --git a/src/main/java/eu/siacs/conversations/ui/forms/FormTextFieldWrapper.java b/src/main/java/eu/siacs/conversations/ui/forms/FormTextFieldWrapper.java index b7dac9510..81fbb2e2e 100644 --- a/src/main/java/eu/siacs/conversations/ui/forms/FormTextFieldWrapper.java +++ b/src/main/java/eu/siacs/conversations/ui/forms/FormTextFieldWrapper.java @@ -19,7 +19,7 @@ public class FormTextFieldWrapper extends FormFieldWrapper { protected FormTextFieldWrapper(Context context, Field field) { super(context, field); - editText = (EditText) view.findViewById(R.id.field); + editText = view.findViewById(R.id.field); editText.setSingleLine(!"text-multi".equals(field.getType())); if ("text-private".equals(field.getType())) { editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); @@ -43,7 +43,7 @@ public class FormTextFieldWrapper extends FormFieldWrapper { @Override protected void setLabel(String label, boolean required) { - TextView textView = (TextView) view.findViewById(R.id.label); + TextView textView = view.findViewById(R.id.label); textView.setText(createSpannableLabelString(label, required)); } @@ -64,7 +64,7 @@ public class FormTextFieldWrapper extends FormFieldWrapper { @Override protected void setValues(List values) { - StringBuilder builder = new StringBuilder(""); + StringBuilder builder = new StringBuilder(); for(int i = 0; i < values.size(); ++i) { builder.append(values.get(i)); if (i < values.size() - 1 && "text-multi".equals(field.getType())) { diff --git a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java index 1a48f1387..08edfadbe 100644 --- a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java +++ b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java @@ -12,8 +12,6 @@ import android.media.AudioManager; import android.os.Build; import android.os.Handler; import android.os.PowerManager; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; import android.util.Log; import android.view.View; import android.widget.ImageButton; @@ -21,6 +19,9 @@ import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + import java.lang.ref.WeakReference; import java.util.Locale; import java.util.concurrent.ExecutorService; diff --git a/src/main/java/eu/siacs/conversations/ui/service/CameraManager.java b/src/main/java/eu/siacs/conversations/ui/service/CameraManager.java index 9f1fc99a7..f3af5d3ed 100644 --- a/src/main/java/eu/siacs/conversations/ui/service/CameraManager.java +++ b/src/main/java/eu/siacs/conversations/ui/service/CameraManager.java @@ -17,15 +17,6 @@ package eu.siacs.conversations.ui.service; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import com.google.zxing.PlanarYUVLuminanceSource; - import android.annotation.SuppressLint; import android.graphics.Rect; import android.graphics.RectF; @@ -35,6 +26,15 @@ import android.hardware.Camera.PreviewCallback; import android.util.Log; import android.view.TextureView; +import com.google.zxing.PlanarYUVLuminanceSource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + import eu.siacs.conversations.Config; /** @@ -48,7 +48,7 @@ public final class CameraManager { private static final int MAX_PREVIEW_PIXELS = 1280 * 720; private Camera camera; - private CameraInfo cameraInfo = new CameraInfo(); + private final CameraInfo cameraInfo = new CameraInfo(); private Camera.Size cameraResolution; private Rect frame; private RectF framePreview; diff --git a/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java b/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java index eb45feebe..684fd8094 100644 --- a/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java +++ b/src/main/java/eu/siacs/conversations/ui/text/FixedURLSpan.java @@ -38,16 +38,13 @@ import android.os.Build; import android.text.Editable; import android.text.Spanned; import android.text.style.URLSpan; -import android.util.Log; import android.view.View; import android.widget.Toast; import java.util.Arrays; -import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.ui.ConversationsActivity; -import eu.siacs.conversations.utils.XmppUri; @SuppressLint("ParcelCreator") diff --git a/src/main/java/eu/siacs/conversations/ui/text/QuoteSpan.java b/src/main/java/eu/siacs/conversations/ui/text/QuoteSpan.java index 48b20a47f..98360e9b8 100644 --- a/src/main/java/eu/siacs/conversations/ui/text/QuoteSpan.java +++ b/src/main/java/eu/siacs/conversations/ui/text/QuoteSpan.java @@ -2,7 +2,6 @@ package eu.siacs.conversations.ui.text; import android.graphics.Canvas; import android.graphics.Paint; -import androidx.annotation.ColorInt; import android.text.Layout; import android.text.TextPaint; import android.text.style.CharacterStyle; @@ -10,6 +9,8 @@ import android.text.style.LeadingMarginSpan; import android.util.DisplayMetrics; import android.util.TypedValue; +import androidx.annotation.ColorInt; + public class QuoteSpan extends CharacterStyle implements LeadingMarginSpan { private final int color; diff --git a/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java b/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java index 388a38003..f5331c7a6 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java +++ b/src/main/java/eu/siacs/conversations/ui/util/AvatarWorkerTask.java @@ -6,9 +6,10 @@ import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import androidx.annotation.DimenRes; import android.widget.ImageView; +import androidx.annotation.DimenRes; + import java.lang.ref.WeakReference; import java.util.concurrent.RejectedExecutionException; @@ -20,7 +21,8 @@ import eu.siacs.conversations.ui.XmppActivity; public class AvatarWorkerTask extends AsyncTask { private final WeakReference imageViewReference; private AvatarService.Avatarable avatarable = null; - private @DimenRes int size; + private @DimenRes + final int size; public AvatarWorkerTask(ImageView imageView, @DimenRes int size) { imageViewReference = new WeakReference<>(imageView); diff --git a/src/main/java/eu/siacs/conversations/ui/util/ConversationMenuConfigurator.java b/src/main/java/eu/siacs/conversations/ui/util/ConversationMenuConfigurator.java index c301a03ce..900246591 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/ConversationMenuConfigurator.java +++ b/src/main/java/eu/siacs/conversations/ui/util/ConversationMenuConfigurator.java @@ -30,17 +30,15 @@ package eu.siacs.conversations.ui.util; import android.content.Context; -import android.content.Intent; import android.content.pm.PackageManager; -import android.provider.MediaStore; -import androidx.annotation.NonNull; import android.view.Menu; import android.view.MenuItem; +import androidx.annotation.NonNull; + import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.OmemoSetting; -import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversational; import eu.siacs.conversations.entities.Message; diff --git a/src/main/java/eu/siacs/conversations/ui/util/DelayedHintHelper.java b/src/main/java/eu/siacs/conversations/ui/util/DelayedHintHelper.java index 4680b2afd..2df162099 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/DelayedHintHelper.java +++ b/src/main/java/eu/siacs/conversations/ui/util/DelayedHintHelper.java @@ -30,9 +30,10 @@ package eu.siacs.conversations.ui.util; import android.os.Handler; -import androidx.annotation.StringRes; import android.widget.EditText; +import androidx.annotation.StringRes; + public class DelayedHintHelper { public static void setHint(@StringRes final int res, EditText editText) { diff --git a/src/main/java/eu/siacs/conversations/ui/util/GridManager.java b/src/main/java/eu/siacs/conversations/ui/util/GridManager.java index 5e523aa31..c11e423c5 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/GridManager.java +++ b/src/main/java/eu/siacs/conversations/ui/util/GridManager.java @@ -1,11 +1,12 @@ package eu.siacs.conversations.ui.util; import android.content.Context; +import android.util.Log; +import android.view.ViewTreeObserver; + import androidx.annotation.DimenRes; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import android.util.Log; -import android.view.ViewTreeObserver; import eu.siacs.conversations.Config; import eu.siacs.conversations.ui.adapter.MediaAdapter; diff --git a/src/main/java/eu/siacs/conversations/ui/util/JidDialog.java b/src/main/java/eu/siacs/conversations/ui/util/JidDialog.java index dbc196f4b..7ac8a6f9c 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/JidDialog.java +++ b/src/main/java/eu/siacs/conversations/ui/util/JidDialog.java @@ -1,16 +1,17 @@ package eu.siacs.conversations.ui.util; import android.content.Context; -import androidx.annotation.StringRes; import android.text.SpannableString; import android.text.Spanned; import android.text.style.TypefaceSpan; +import androidx.annotation.StringRes; + public class JidDialog { public static SpannableString style(Context context, @StringRes int res, String... args) { - SpannableString spannable = new SpannableString(context.getString(res, (Object[]) args)); + final SpannableString spannable = new SpannableString(context.getString(res, (Object[]) args)); if (args.length >= 1) { final String value = args[0]; int start = spannable.toString().indexOf(value); diff --git a/src/main/java/eu/siacs/conversations/ui/util/LocationHelper.java b/src/main/java/eu/siacs/conversations/ui/util/LocationHelper.java index 27a6c0837..7922ac369 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/LocationHelper.java +++ b/src/main/java/eu/siacs/conversations/ui/util/LocationHelper.java @@ -64,9 +64,6 @@ public final class LocationHelper { return true; } else if (isNewer && !isLessAccurate) { return true; - } else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) { - return true; - } - return false; - } + } else return isNewer && !isSignificantlyLessAccurate && isFromSameProvider; + } } \ No newline at end of file diff --git a/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java b/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java index 952084816..3772a851e 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MucConfiguration.java @@ -2,6 +2,7 @@ package eu.siacs.conversations.ui.util; import android.content.Context; import android.os.Bundle; + import androidx.annotation.StringRes; import eu.siacs.conversations.R; diff --git a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java index 31da26f22..da1ac7a44 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java @@ -2,7 +2,6 @@ package eu.siacs.conversations.ui.util; import android.app.Activity; import android.preference.PreferenceManager; -import androidx.appcompat.app.AlertDialog; import android.text.SpannableString; import android.text.Spanned; import android.text.style.TypefaceSpan; @@ -11,6 +10,8 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; +import androidx.appcompat.app.AlertDialog; + import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; diff --git a/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java b/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java index aa2aeb704..b72c5aa86 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MyLinkify.java @@ -81,9 +81,7 @@ public class MyLinkify { if (end < cs.length()) { // Reject strings that were probably matched only because they contain a dot followed by // by some known TLD (see also comment for WORD_BOUNDARY in Patterns.java) - if (isAlphabetic(cs.charAt(end-1)) && isAlphabetic(cs.charAt(end))) { - return false; - } + return !isAlphabetic(cs.charAt(end - 1)) || !isAlphabetic(cs.charAt(end)); } return true; diff --git a/src/main/java/eu/siacs/conversations/ui/util/PresenceSelector.java b/src/main/java/eu/siacs/conversations/ui/util/PresenceSelector.java index 05a364b79..6edcf3349 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/PresenceSelector.java +++ b/src/main/java/eu/siacs/conversations/ui/util/PresenceSelector.java @@ -31,9 +31,10 @@ package eu.siacs.conversations.ui.util; import android.app.Activity; import android.content.Context; -import androidx.appcompat.app.AlertDialog; import android.util.Pair; +import androidx.appcompat.app.AlertDialog; + import java.util.Collections; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; diff --git a/src/main/java/eu/siacs/conversations/ui/util/SoftKeyboardUtils.java b/src/main/java/eu/siacs/conversations/ui/util/SoftKeyboardUtils.java index 09a8544df..0b2eaf801 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/SoftKeyboardUtils.java +++ b/src/main/java/eu/siacs/conversations/ui/util/SoftKeyboardUtils.java @@ -31,11 +31,12 @@ package eu.siacs.conversations.ui.util; import android.app.Activity; import android.content.Context; -import androidx.annotation.NonNull; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; +import androidx.annotation.NonNull; + public class SoftKeyboardUtils { diff --git a/src/main/java/eu/siacs/conversations/ui/util/StyledAttributes.java b/src/main/java/eu/siacs/conversations/ui/util/StyledAttributes.java index cfd177031..709aa0386 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/StyledAttributes.java +++ b/src/main/java/eu/siacs/conversations/ui/util/StyledAttributes.java @@ -31,6 +31,7 @@ package eu.siacs.conversations.ui.util; import android.content.Context; import android.content.res.TypedArray; + import androidx.annotation.AttrRes; import androidx.annotation.ColorInt; diff --git a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java index 3461ebc9e..eadd562a7 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/EditMessage.java @@ -1,15 +1,11 @@ package eu.siacs.conversations.ui.widget; -import android.content.SharedPreferences; -import android.preference.PreferenceManager; -import androidx.core.view.inputmethod.EditorInfoCompat; -import androidx.core.view.inputmethod.InputConnectionCompat; -import androidx.core.view.inputmethod.InputContentInfoCompat; - import android.content.Context; +import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.preference.PreferenceManager; import android.text.Editable; import android.text.InputFilter; import android.text.InputType; @@ -19,6 +15,10 @@ import android.view.KeyEvent; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; +import androidx.core.view.inputmethod.EditorInfoCompat; +import androidx.core.view.inputmethod.InputConnectionCompat; +import androidx.core.view.inputmethod.InputContentInfoCompat; + import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; diff --git a/src/main/java/eu/siacs/conversations/ui/widget/ScannerView.java b/src/main/java/eu/siacs/conversations/ui/widget/ScannerView.java index 4eb25418d..3d7d37170 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/ScannerView.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/ScannerView.java @@ -17,12 +17,6 @@ package eu.siacs.conversations.ui.widget; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import com.google.zxing.ResultPoint; - import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; @@ -35,6 +29,12 @@ import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; +import com.google.zxing.ResultPoint; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + import eu.siacs.conversations.R; /** diff --git a/src/main/java/eu/siacs/conversations/ui/widget/SwipeRefreshListFragment.java b/src/main/java/eu/siacs/conversations/ui/widget/SwipeRefreshListFragment.java index 8057a423f..b1ef6165a 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/SwipeRefreshListFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/SwipeRefreshListFragment.java @@ -18,13 +18,14 @@ package eu.siacs.conversations.ui.widget; import android.content.Context; import android.os.Bundle; -import androidx.fragment.app.ListFragment; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; +import androidx.fragment.app.ListFragment; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + import eu.siacs.conversations.R; import eu.siacs.conversations.ui.util.StyledAttributes; diff --git a/src/main/java/eu/siacs/conversations/ui/widget/UnreadCountCustomView.java b/src/main/java/eu/siacs/conversations/ui/widget/UnreadCountCustomView.java index cfe291f73..380b929e3 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/UnreadCountCustomView.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/UnreadCountCustomView.java @@ -6,10 +6,11 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Typeface; -import androidx.core.content.ContextCompat; import android.util.AttributeSet; import android.view.View; +import androidx.core.content.ContextCompat; + import eu.siacs.conversations.R; public class UnreadCountCustomView extends View { diff --git a/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java b/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java index b2da09f97..a692cc6dc 100644 --- a/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java +++ b/src/main/java/eu/siacs/conversations/utils/Android360pFormatStrategy.java @@ -3,9 +3,10 @@ package eu.siacs.conversations.utils; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.os.Build; -import androidx.annotation.RequiresApi; import android.util.Log; +import androidx.annotation.RequiresApi; + import net.ypresto.androidtranscoder.format.MediaFormatExtraConstants; import net.ypresto.androidtranscoder.format.MediaFormatStrategy; import net.ypresto.androidtranscoder.format.OutputFormatUnavailableException; diff --git a/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java b/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java index 47ad515eb..274ebb76f 100644 --- a/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java +++ b/src/main/java/eu/siacs/conversations/utils/Android720pFormatStrategy.java @@ -3,9 +3,10 @@ package eu.siacs.conversations.utils; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.os.Build; -import androidx.annotation.RequiresApi; import android.util.Log; +import androidx.annotation.RequiresApi; + import net.ypresto.androidtranscoder.format.MediaFormatExtraConstants; import net.ypresto.androidtranscoder.format.MediaFormatStrategy; import net.ypresto.androidtranscoder.format.OutputFormatUnavailableException; diff --git a/src/main/java/eu/siacs/conversations/utils/AndroidUsingExecLowPriority.java b/src/main/java/eu/siacs/conversations/utils/AndroidUsingExecLowPriority.java index d06c3afeb..d8c46b08f 100644 --- a/src/main/java/eu/siacs/conversations/utils/AndroidUsingExecLowPriority.java +++ b/src/main/java/eu/siacs/conversations/utils/AndroidUsingExecLowPriority.java @@ -11,11 +11,6 @@ package eu.siacs.conversations.utils; -import de.measite.minidns.dnsserverlookup.AbstractDNSServerLookupMechanism; -import de.measite.minidns.dnsserverlookup.AndroidUsingReflection; -import de.measite.minidns.dnsserverlookup.DNSServerLookupMechanism; -import de.measite.minidns.util.PlatformDetection; - import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -24,6 +19,11 @@ import java.net.InetAddress; import java.util.HashSet; import java.util.logging.Level; +import de.measite.minidns.dnsserverlookup.AbstractDNSServerLookupMechanism; +import de.measite.minidns.dnsserverlookup.AndroidUsingReflection; +import de.measite.minidns.dnsserverlookup.DNSServerLookupMechanism; +import de.measite.minidns.util.PlatformDetection; + /** * Try to retrieve the list of DNS server by executing getprop. */ diff --git a/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java b/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java index 212473ea4..54387a8ee 100644 --- a/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java +++ b/src/main/java/eu/siacs/conversations/utils/BackupFileHeader.java @@ -10,11 +10,11 @@ public class BackupFileHeader { private static final int VERSION = 1; - private String app; - private Jid jid; - private long timestamp; - private byte[] iv; - private byte[] salt; + private final String app; + private final Jid jid; + private final long timestamp; + private final byte[] iv; + private final byte[] salt; @Override diff --git a/src/main/java/eu/siacs/conversations/utils/Compatibility.java b/src/main/java/eu/siacs/conversations/utils/Compatibility.java index e11ea42d7..1ea0d70ea 100644 --- a/src/main/java/eu/siacs/conversations/utils/Compatibility.java +++ b/src/main/java/eu/siacs/conversations/utils/Compatibility.java @@ -10,9 +10,10 @@ import android.os.Build; import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceManager; +import android.util.Log; + import androidx.annotation.BoolRes; import androidx.core.content.ContextCompat; -import android.util.Log; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/eu/siacs/conversations/utils/ConversationsFileObserver.java b/src/main/java/eu/siacs/conversations/utils/ConversationsFileObserver.java index 8bf36ea1f..4ee842223 100644 --- a/src/main/java/eu/siacs/conversations/utils/ConversationsFileObserver.java +++ b/src/main/java/eu/siacs/conversations/utils/ConversationsFileObserver.java @@ -6,7 +6,6 @@ import android.util.Log; import java.io.File; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Stack; import java.util.concurrent.Executor; diff --git a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java index 0a2231389..3174c4198 100644 --- a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java @@ -11,6 +11,7 @@ import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; @@ -256,7 +257,7 @@ public final class CryptoHelper { public static String getFingerprint(String value) { try { MessageDigest md = MessageDigest.getInstance("SHA-1"); - return bytesToHex(md.digest(value.getBytes("UTF-8"))); + return bytesToHex(md.digest(value.getBytes(StandardCharsets.UTF_8))); } catch (Exception e) { return ""; } diff --git a/src/main/java/eu/siacs/conversations/utils/EasyOnboardingInvite.java b/src/main/java/eu/siacs/conversations/utils/EasyOnboardingInvite.java index e4ed8e1b5..37bce5e22 100644 --- a/src/main/java/eu/siacs/conversations/utils/EasyOnboardingInvite.java +++ b/src/main/java/eu/siacs/conversations/utils/EasyOnboardingInvite.java @@ -16,9 +16,9 @@ import eu.siacs.conversations.xmpp.XmppConnection; public class EasyOnboardingInvite implements Parcelable { - private String domain; - private String uri; - private String landingUrl; + private final String domain; + private final String uri; + private final String landingUrl; protected EasyOnboardingInvite(Parcel in) { domain = in.readString(); diff --git a/src/main/java/eu/siacs/conversations/utils/Emoticons.java b/src/main/java/eu/siacs/conversations/utils/Emoticons.java index 39106caa8..266d9d081 100644 --- a/src/main/java/eu/siacs/conversations/utils/Emoticons.java +++ b/src/main/java/eu/siacs/conversations/utils/Emoticons.java @@ -29,9 +29,10 @@ package eu.siacs.conversations.utils; -import androidx.annotation.NonNull; import android.util.LruCache; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; diff --git a/src/main/java/eu/siacs/conversations/utils/ExceptionHandler.java b/src/main/java/eu/siacs/conversations/utils/ExceptionHandler.java index 808abbdb4..8a77e04bb 100644 --- a/src/main/java/eu/siacs/conversations/utils/ExceptionHandler.java +++ b/src/main/java/eu/siacs/conversations/utils/ExceptionHandler.java @@ -1,6 +1,7 @@ package eu.siacs.conversations.utils; import android.content.Context; + import androidx.annotation.NonNull; import java.io.PrintWriter; diff --git a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java index 9ad6b5d3d..ea272302b 100644 --- a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java @@ -6,9 +6,10 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import android.preference.PreferenceManager; -import androidx.appcompat.app.AlertDialog; import android.util.Log; +import androidx.appcompat.app.AlertDialog; + import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; diff --git a/src/main/java/eu/siacs/conversations/utils/FtsUtils.java b/src/main/java/eu/siacs/conversations/utils/FtsUtils.java index 88959c6b2..6984d20ec 100644 --- a/src/main/java/eu/siacs/conversations/utils/FtsUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/FtsUtils.java @@ -37,7 +37,7 @@ import java.util.Locale; public class FtsUtils { - private static List KEYWORDS = Arrays.asList("OR", "AND"); + private static final List KEYWORDS = Arrays.asList("OR", "AND"); public static List parse(String input) { List term = new ArrayList<>(); diff --git a/src/main/java/eu/siacs/conversations/utils/GeoHelper.java b/src/main/java/eu/siacs/conversations/utils/GeoHelper.java index 9847236ef..459968f37 100644 --- a/src/main/java/eu/siacs/conversations/utils/GeoHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/GeoHelper.java @@ -107,7 +107,7 @@ public class GeoHelper { intents.add(geoIntent(geoPoint, label)); Intent httpIntent = new Intent(Intent.ACTION_VIEW); - httpIntent.setData(Uri.parse("https://maps.google.com/maps?q=loc:"+String.valueOf(geoPoint.getLatitude()) + "," + String.valueOf(geoPoint.getLongitude()) +label)); + httpIntent.setData(Uri.parse("https://maps.google.com/maps?q=loc:"+ geoPoint.getLatitude() + "," + geoPoint.getLongitude() +label)); intents.add(httpIntent); return intents; } @@ -120,7 +120,7 @@ public class GeoHelper { private static Intent geoIntent(GeoPoint geoPoint, String label) { Intent geoIntent = new Intent(Intent.ACTION_VIEW); - geoIntent.setData(Uri.parse("geo:" + String.valueOf(geoPoint.getLatitude()) + "," + String.valueOf(geoPoint.getLongitude()) + "?q=" + String.valueOf(geoPoint.getLatitude()) + "," + String.valueOf(geoPoint.getLongitude()) + "("+ label+")")); + geoIntent.setData(Uri.parse("geo:" + geoPoint.getLatitude() + "," + geoPoint.getLongitude() + "?q=" + geoPoint.getLatitude() + "," + geoPoint.getLongitude() + "("+ label+")")); return geoIntent; } diff --git a/src/main/java/eu/siacs/conversations/utils/ImStyleParser.java b/src/main/java/eu/siacs/conversations/utils/ImStyleParser.java index 873ab9f43..d21bfadf1 100644 --- a/src/main/java/eu/siacs/conversations/utils/ImStyleParser.java +++ b/src/main/java/eu/siacs/conversations/utils/ImStyleParser.java @@ -53,7 +53,7 @@ public class ImStyleParser { if (BLOCK_KEYWORDS.contains(c) && isCharRepeatedTwoTimes(text, c, i + 1, end)) { int to = seekEndBlock(text, c, i + 3, end); if (to != -1 && (to != i + 5 || ALLOW_EMPTY)) { - String keyword = String.valueOf(c) + String.valueOf(c) + String.valueOf(c); + String keyword = String.valueOf(c) + c + c; styles.add(new Style(keyword, i, to)); i = to; continue; diff --git a/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java b/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java index 52936fcfa..d3aade355 100644 --- a/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java +++ b/src/main/java/eu/siacs/conversations/utils/IrregularUnicodeDetector.java @@ -32,13 +32,14 @@ package eu.siacs.conversations.utils; import android.annotation.TargetApi; import android.content.Context; import android.os.Build; -import androidx.annotation.ColorInt; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import android.util.LruCache; +import androidx.annotation.ColorInt; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -229,8 +230,7 @@ public class IrregularUnicodeDetector { if (pattern != null) { return pattern; } - ; - pattern = PatternTuple.of(jid); + pattern = PatternTuple.of(jid); CACHE.put(jid, pattern); return pattern; } diff --git a/src/main/java/eu/siacs/conversations/utils/JidHelper.java b/src/main/java/eu/siacs/conversations/utils/JidHelper.java index c53af65ed..e7443c8bb 100644 --- a/src/main/java/eu/siacs/conversations/utils/JidHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/JidHelper.java @@ -40,7 +40,7 @@ import eu.siacs.conversations.xmpp.Jid; public class JidHelper { - private static List LOCAL_PART_BLACKLIST = Arrays.asList("xmpp", "jabber", "me"); + private static final List LOCAL_PART_BLACKLIST = Arrays.asList("xmpp", "jabber", "me"); public static String localPartOrFallback(Jid jid) { if (LOCAL_PART_BLACKLIST.contains(jid.getLocal().toLowerCase(Locale.ENGLISH))) { diff --git a/src/main/java/eu/siacs/conversations/utils/MessageUtils.java b/src/main/java/eu/siacs/conversations/utils/MessageUtils.java index e8ae07e68..d8b991894 100644 --- a/src/main/java/eu/siacs/conversations/utils/MessageUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/MessageUtils.java @@ -62,8 +62,8 @@ public class MessageUtils { } body = nick + " " + message.getBody().substring(Message.ME_COMMAND.length()); } else { - body = message.getMergedBody().toString();; - } + body = message.getMergedBody().toString(); + } for (String line : body.split("\n")) { if (line.length() <= 0) { continue; diff --git a/src/main/java/eu/siacs/conversations/utils/OnPhoneContactsLoadedListener.java b/src/main/java/eu/siacs/conversations/utils/OnPhoneContactsLoadedListener.java index f18a4ed8e..9ae928812 100644 --- a/src/main/java/eu/siacs/conversations/utils/OnPhoneContactsLoadedListener.java +++ b/src/main/java/eu/siacs/conversations/utils/OnPhoneContactsLoadedListener.java @@ -5,5 +5,5 @@ import android.os.Bundle; import java.util.List; public interface OnPhoneContactsLoadedListener { - public void onPhoneContactsLoaded(List phoneContacts); + void onPhoneContactsLoaded(List phoneContacts); } diff --git a/src/main/java/eu/siacs/conversations/utils/PermissionUtils.java b/src/main/java/eu/siacs/conversations/utils/PermissionUtils.java index f025c256f..80b58d8cb 100644 --- a/src/main/java/eu/siacs/conversations/utils/PermissionUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/PermissionUtils.java @@ -4,6 +4,7 @@ import android.Manifest; import android.app.Activity; import android.content.pm.PackageManager; import android.os.Build; + import androidx.core.app.ActivityCompat; import com.google.common.collect.ImmutableList; diff --git a/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java b/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java index e849730b7..0238dc975 100644 --- a/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java @@ -3,20 +3,13 @@ package eu.siacs.conversations.utils; import android.Manifest; import android.annotation.SuppressLint; import android.content.Context; -import android.content.CursorLoader; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Build; -import android.os.Bundle; -import android.provider.ContactsContract; import android.provider.ContactsContract.Profile; import android.provider.Settings; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.RejectedExecutionException; - public class PhoneHelper { @SuppressLint("HardwareIds") diff --git a/src/main/java/eu/siacs/conversations/utils/QuickLoader.java b/src/main/java/eu/siacs/conversations/utils/QuickLoader.java index 34e9e0e97..07d46281d 100644 --- a/src/main/java/eu/siacs/conversations/utils/QuickLoader.java +++ b/src/main/java/eu/siacs/conversations/utils/QuickLoader.java @@ -37,7 +37,7 @@ import eu.siacs.conversations.entities.Conversation; public class QuickLoader { private static String CONVERSATION_UUID = null; - private static Object LOCK = new Object(); + private static final Object LOCK = new Object(); public static void set(final String uuid) { synchronized (LOCK) { diff --git a/src/main/java/eu/siacs/conversations/utils/Resolver.java b/src/main/java/eu/siacs/conversations/utils/Resolver.java index 27685a65d..6e0973bf4 100644 --- a/src/main/java/eu/siacs/conversations/utils/Resolver.java +++ b/src/main/java/eu/siacs/conversations/utils/Resolver.java @@ -2,9 +2,10 @@ package eu.siacs.conversations.utils; import android.content.ContentValues; import android.database.Cursor; -import androidx.annotation.NonNull; import android.util.Log; +import androidx.annotation.NonNull; + import java.io.IOException; import java.lang.reflect.Field; import java.net.Inet4Address; diff --git a/src/main/java/eu/siacs/conversations/utils/SSLSocketHelper.java b/src/main/java/eu/siacs/conversations/utils/SSLSocketHelper.java index 6835f5d3f..53d4f4169 100644 --- a/src/main/java/eu/siacs/conversations/utils/SSLSocketHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/SSLSocketHelper.java @@ -1,12 +1,14 @@ package eu.siacs.conversations.utils; import android.os.Build; -import androidx.annotation.RequiresApi; import android.util.Log; +import androidx.annotation.RequiresApi; + import org.conscrypt.Conscrypt; import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; import java.security.NoSuchAlgorithmException; import java.util.Arrays; import java.util.Collection; @@ -70,7 +72,7 @@ public class SSLSocketHelper { final Method method = socket.getClass().getMethod("setAlpnProtocols", byte[].class); // the concatenation of 8-bit, length prefixed protocol names, just one in our case... // http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4 - final byte[] protocolUTF8Bytes = protocol.getBytes("UTF-8"); + final byte[] protocolUTF8Bytes = protocol.getBytes(StandardCharsets.UTF_8); final byte[] lengthPrefixedProtocols = new byte[protocolUTF8Bytes.length + 1]; lengthPrefixedProtocols[0] = (byte) protocol.length(); // cannot be over 255 anyhow System.arraycopy(protocolUTF8Bytes, 0, lengthPrefixedProtocols, 1, protocolUTF8Bytes.length); diff --git a/src/main/java/eu/siacs/conversations/utils/StylingHelper.java b/src/main/java/eu/siacs/conversations/utils/StylingHelper.java index d434be126..7a18dffbb 100644 --- a/src/main/java/eu/siacs/conversations/utils/StylingHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/StylingHelper.java @@ -32,8 +32,6 @@ package eu.siacs.conversations.utils; import android.content.Context; import android.graphics.Color; import android.graphics.Typeface; -import androidx.annotation.ColorInt; -import androidx.core.content.ContextCompat; import android.text.Editable; import android.text.ParcelableSpan; import android.text.Spannable; @@ -48,6 +46,9 @@ import android.text.style.TypefaceSpan; import android.widget.EditText; import android.widget.TextView; +import androidx.annotation.ColorInt; +import androidx.core.content.ContextCompat; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -58,7 +59,7 @@ import eu.siacs.conversations.ui.text.QuoteSpan; public class StylingHelper { - private static List> SPAN_CLASSES = Arrays.asList( + private static final List> SPAN_CLASSES = Arrays.asList( StyleSpan.class, StrikethroughSpan.class, TypefaceSpan.class, diff --git a/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java b/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java index 00bae7b75..8bd737c7e 100644 --- a/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java +++ b/src/main/java/eu/siacs/conversations/utils/TLSSocketFactory.java @@ -6,6 +6,7 @@ import java.net.Socket; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; + import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; diff --git a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java index 36e8d8179..17311cb0c 100644 --- a/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ThemeHelper.java @@ -36,12 +36,14 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.preference.PreferenceManager; -import androidx.annotation.StyleRes; -import com.google.android.material.snackbar.Snackbar; -import androidx.core.content.ContextCompat; import android.util.TypedValue; import android.widget.TextView; +import androidx.annotation.StyleRes; +import androidx.core.content.ContextCompat; + +import com.google.android.material.snackbar.Snackbar; + import eu.siacs.conversations.R; import eu.siacs.conversations.ui.SettingsActivity; diff --git a/src/main/java/eu/siacs/conversations/utils/TimeFrameUtils.java b/src/main/java/eu/siacs/conversations/utils/TimeFrameUtils.java index b96370dc3..1cb78db0c 100644 --- a/src/main/java/eu/siacs/conversations/utils/TimeFrameUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/TimeFrameUtils.java @@ -31,6 +31,7 @@ package eu.siacs.conversations.utils; import android.content.Context; import android.os.SystemClock; + import androidx.annotation.PluralsRes; import java.util.Locale; diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index 2105c3db1..a686f8697 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -1,12 +1,13 @@ package eu.siacs.conversations.utils; import android.content.Context; -import androidx.annotation.ColorInt; import android.text.SpannableStringBuilder; import android.text.format.DateFormat; import android.text.format.DateUtils; import android.util.Pair; +import androidx.annotation.ColorInt; + import com.google.common.base.Strings; import java.math.BigInteger; diff --git a/src/main/java/eu/siacs/conversations/utils/XEP0392Helper.java b/src/main/java/eu/siacs/conversations/utils/XEP0392Helper.java index ee6a90e1e..69c00365e 100644 --- a/src/main/java/eu/siacs/conversations/utils/XEP0392Helper.java +++ b/src/main/java/eu/siacs/conversations/utils/XEP0392Helper.java @@ -1,10 +1,10 @@ package eu.siacs.conversations.utils; import android.graphics.Color; -import android.util.Log; import org.hsluv.HUSLColorConverter; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; class XEP0392Helper { @@ -12,7 +12,7 @@ class XEP0392Helper { private static double angle(String nickname) { try { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); - byte[] digest = sha1.digest(nickname.getBytes("UTF-8")); + byte[] digest = sha1.digest(nickname.getBytes(StandardCharsets.UTF_8)); int angle = ((int) (digest[0]) & 0xff) + ((int) (digest[1]) & 0xff) * 256; return angle / 65536.; } catch (Exception e) { diff --git a/src/main/java/eu/siacs/conversations/utils/XmppUri.java b/src/main/java/eu/siacs/conversations/utils/XmppUri.java index 7be4766f3..f3aa65155 100644 --- a/src/main/java/eu/siacs/conversations/utils/XmppUri.java +++ b/src/main/java/eu/siacs/conversations/utils/XmppUri.java @@ -1,6 +1,7 @@ package eu.siacs.conversations.utils; import android.net.Uri; + import androidx.annotation.NonNull; import com.google.common.collect.ImmutableList; diff --git a/src/main/java/eu/siacs/conversations/xml/Element.java b/src/main/java/eu/siacs/conversations/xml/Element.java index 1bd11f604..c0ece7f4c 100644 --- a/src/main/java/eu/siacs/conversations/xml/Element.java +++ b/src/main/java/eu/siacs/conversations/xml/Element.java @@ -6,8 +6,8 @@ import java.util.List; import eu.siacs.conversations.utils.XmlHelper; import eu.siacs.conversations.xmpp.InvalidJid; -import eu.siacs.conversations.xmpp.stanzas.MessagePacket; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.stanzas.MessagePacket; public class Element { private final String name; diff --git a/src/main/java/eu/siacs/conversations/xml/TagWriter.java b/src/main/java/eu/siacs/conversations/xml/TagWriter.java index df062b8cf..0e03fc1e8 100644 --- a/src/main/java/eu/siacs/conversations/xml/TagWriter.java +++ b/src/main/java/eu/siacs/conversations/xml/TagWriter.java @@ -16,10 +16,10 @@ public class TagWriter { private OutputStreamWriter outputStream; private boolean finished = false; - private LinkedBlockingQueue writeQueue = new LinkedBlockingQueue(); + private final LinkedBlockingQueue writeQueue = new LinkedBlockingQueue(); private CountDownLatch stanzaWriterCountDownLatch = null; - private Thread asyncStanzaWriter = new Thread() { + private final Thread asyncStanzaWriter = new Thread() { @Override public void run() { diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnAdvancedStreamFeaturesLoaded.java b/src/main/java/eu/siacs/conversations/xmpp/OnAdvancedStreamFeaturesLoaded.java index e45eba73e..9093076f7 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnAdvancedStreamFeaturesLoaded.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnAdvancedStreamFeaturesLoaded.java @@ -3,5 +3,5 @@ package eu.siacs.conversations.xmpp; import eu.siacs.conversations.entities.Account; public interface OnAdvancedStreamFeaturesLoaded { - public void onAdvancedStreamFeaturesAvailable(final Account account); + void onAdvancedStreamFeaturesAvailable(final Account account); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnBindListener.java b/src/main/java/eu/siacs/conversations/xmpp/OnBindListener.java index f09cf33dd..2406d8d7f 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnBindListener.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnBindListener.java @@ -3,5 +3,5 @@ package eu.siacs.conversations.xmpp; import eu.siacs.conversations.entities.Account; public interface OnBindListener { - public void onBind(Account account); + void onBind(Account account); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnContactStatusChanged.java b/src/main/java/eu/siacs/conversations/xmpp/OnContactStatusChanged.java index 20b17f021..afbe21c32 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnContactStatusChanged.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnContactStatusChanged.java @@ -3,5 +3,5 @@ package eu.siacs.conversations.xmpp; import eu.siacs.conversations.entities.Contact; public interface OnContactStatusChanged { - public void onContactStatusChanged(final Contact contact, final boolean online); + void onContactStatusChanged(final Contact contact, final boolean online); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnKeyStatusUpdated.java b/src/main/java/eu/siacs/conversations/xmpp/OnKeyStatusUpdated.java index e7fc582e4..705782455 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnKeyStatusUpdated.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnKeyStatusUpdated.java @@ -3,5 +3,5 @@ package eu.siacs.conversations.xmpp; import eu.siacs.conversations.crypto.axolotl.AxolotlService; public interface OnKeyStatusUpdated { - public void onKeyStatusUpdated(AxolotlService.FetchStatus report); + void onKeyStatusUpdated(AxolotlService.FetchStatus report); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnMessagePacketReceived.java b/src/main/java/eu/siacs/conversations/xmpp/OnMessagePacketReceived.java index 325e945f0..24acf16e2 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnMessagePacketReceived.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnMessagePacketReceived.java @@ -4,5 +4,5 @@ import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; public interface OnMessagePacketReceived extends PacketReceived { - public void onMessagePacketReceived(Account account, MessagePacket packet); + void onMessagePacketReceived(Account account, MessagePacket packet); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnPresencePacketReceived.java b/src/main/java/eu/siacs/conversations/xmpp/OnPresencePacketReceived.java index 95c1acfcc..e1bf839f4 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnPresencePacketReceived.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnPresencePacketReceived.java @@ -4,5 +4,5 @@ import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.xmpp.stanzas.PresencePacket; public interface OnPresencePacketReceived extends PacketReceived { - public void onPresencePacketReceived(Account account, PresencePacket packet); + void onPresencePacketReceived(Account account, PresencePacket packet); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnStatusChanged.java b/src/main/java/eu/siacs/conversations/xmpp/OnStatusChanged.java index ad1d98cb9..262838b51 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnStatusChanged.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnStatusChanged.java @@ -3,5 +3,5 @@ package eu.siacs.conversations.xmpp; import eu.siacs.conversations.entities.Account; public interface OnStatusChanged { - public void onStatusChanged(Account account); + void onStatusChanged(Account account); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/OnUpdateBlocklist.java b/src/main/java/eu/siacs/conversations/xmpp/OnUpdateBlocklist.java index 92e72cfa8..e4f1a7cbe 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/OnUpdateBlocklist.java +++ b/src/main/java/eu/siacs/conversations/xmpp/OnUpdateBlocklist.java @@ -3,11 +3,11 @@ package eu.siacs.conversations.xmpp; public interface OnUpdateBlocklist { // Use an enum instead of a boolean to make sure we don't run into the boolean trap // (`onUpdateBlocklist(true)' doesn't read well, and could be confusing). - public static enum Status { + enum Status { BLOCKED, UNBLOCKED } @SuppressWarnings("MethodNameSameAsClassName") - public void OnUpdateBlocklist(final Status status); + void OnUpdateBlocklist(final Status status); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/PacketReceived.java b/src/main/java/eu/siacs/conversations/xmpp/PacketReceived.java index d4502d734..05ddc392f 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/PacketReceived.java +++ b/src/main/java/eu/siacs/conversations/xmpp/PacketReceived.java @@ -1,5 +1,5 @@ package eu.siacs.conversations.xmpp; -public abstract interface PacketReceived { +public interface PacketReceived { } diff --git a/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java b/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java index 42fa7f3ae..08fb6e6dc 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/WrappedJid.java @@ -5,7 +5,6 @@ import androidx.annotation.NonNull; import org.jxmpp.jid.Jid; import org.jxmpp.jid.impl.JidCreate; -import org.jxmpp.jid.parts.Domainpart; import org.jxmpp.jid.parts.Localpart; import org.jxmpp.jid.parts.Resourcepart; import org.jxmpp.stringprep.XmppStringprepException; diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 59fc3977a..4537b85c5 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -5,12 +5,13 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.SystemClock; import android.security.KeyChain; -import androidx.annotation.NonNull; import android.util.Base64; import android.util.Log; import android.util.Pair; import android.util.SparseArray; +import androidx.annotation.NonNull; + import org.xmlpull.v1.XmlPullParserException; import java.io.ByteArrayInputStream; diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java index bd50a22a2..0b1ff4495 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/AbstractJingleConnection.java @@ -8,8 +8,8 @@ import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.services.XmppConnectionService; -import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket; public abstract class AbstractJingleConnection { diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java index 0fd0eabaf..78ffb28be 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleCandidate.java @@ -13,9 +13,9 @@ public class JingleCandidate { public static int TYPE_DIRECT = 0; public static int TYPE_PROXY = 1; - private boolean ours; + private final boolean ours; private boolean usedByCounterpart = false; - private String cid; + private final String cid; private String host; private int port; private int type; diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java index 178ac659c..27111af35 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java @@ -14,7 +14,6 @@ import com.google.common.collect.ImmutableSet; import java.lang.ref.WeakReference; import java.security.SecureRandom; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -61,7 +60,7 @@ public class JingleConnectionManager extends AbstractConnectionManager { .expireAfterWrite(24, TimeUnit.HOURS) .build(); - private HashMap primaryCandidates = new HashMap<>(); + private final HashMap primaryCandidates = new HashMap<>(); public JingleConnectionManager(XmppConnectionService service) { super(service); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java index 408635f93..8997a5043 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleFileTransferConnection.java @@ -41,6 +41,7 @@ import eu.siacs.conversations.services.AbstractConnectionManager; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.jingle.stanzas.Content; import eu.siacs.conversations.xmpp.jingle.stanzas.FileTransferDescription; @@ -50,7 +51,6 @@ import eu.siacs.conversations.xmpp.jingle.stanzas.JinglePacket; import eu.siacs.conversations.xmpp.jingle.stanzas.Reason; import eu.siacs.conversations.xmpp.jingle.stanzas.S5BTransportInfo; import eu.siacs.conversations.xmpp.stanzas.IqPacket; -import eu.siacs.conversations.xmpp.Jid; public class JingleFileTransferConnection extends AbstractJingleConnection implements Transferable { @@ -70,8 +70,8 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple private int mStatus = Transferable.STATUS_UNKNOWN; private Message message; private Jid responder; - private List candidates = new ArrayList<>(); - private ConcurrentHashMap connections = new ConcurrentHashMap<>(); + private final List candidates = new ArrayList<>(); + private final ConcurrentHashMap connections = new ConcurrentHashMap<>(); private String transportId; private FileTransferDescription description; @@ -100,7 +100,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple private OutputStream mFileOutputStream; private InputStream mFileInputStream; - private OnIqPacketReceived responseListener = (account, packet) -> { + private final OnIqPacketReceived responseListener = (account, packet) -> { if (packet.getType() != IqPacket.TYPE.RESULT) { if (mJingleStatus != JINGLE_STATUS_FAILED && mJingleStatus != JINGLE_STATUS_FINISHED) { fail(IqParser.extractErrorMessage(packet)); @@ -164,7 +164,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple JingleFileTransferConnection.this.fail(); } }; - private OnTransportConnected onIbbTransportConnected = new OnTransportConnected() { + private final OnTransportConnected onIbbTransportConnected = new OnTransportConnected() { @Override public void failed() { Log.d(Config.LOGTAG, "ibb open failed"); @@ -177,7 +177,7 @@ public class JingleFileTransferConnection extends AbstractJingleConnection imple JingleFileTransferConnection.this.transport.send(file, onFileTransmissionStatusChanged); } }; - private OnProxyActivated onProxyActivated = new OnProxyActivated() { + private final OnProxyActivated onProxyActivated = new OnProxyActivated() { @Override public void success() { diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java index 7be13bedb..c68941928 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleInBandTransport.java @@ -18,9 +18,9 @@ import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.services.AbstractConnectionManager; import eu.siacs.conversations.xml.Element; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.stanzas.IqPacket; -import eu.siacs.conversations.xmpp.Jid; public class JingleInBandTransport extends JingleTransport { @@ -46,7 +46,7 @@ public class JingleInBandTransport extends JingleTransport { private OnFileTransmissionStatusChanged onFileTransmissionStatusChanged; - private OnIqPacketReceived onAckReceived = new OnIqPacketReceived() { + private final OnIqPacketReceived onAckReceived = new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket packet) { if (!connected) { diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java index 38f03c5d0..3e397823d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/OnTransportConnected.java @@ -1,7 +1,7 @@ package eu.siacs.conversations.xmpp.jingle; public interface OnTransportConnected { - public void failed(); + void failed(); - public void established(); + void established(); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java index fb7a60480..e24e68ebb 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/RtpCapability.java @@ -16,7 +16,7 @@ import eu.siacs.conversations.xml.Namespace; public class RtpCapability { - private static List BASIC_RTP_REQUIREMENTS = Arrays.asList( + private static final List BASIC_RTP_REQUIREMENTS = Arrays.asList( Namespace.JINGLE, Namespace.JINGLE_TRANSPORT_ICE_UDP, Namespace.JINGLE_APPS_RTP, diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java index 52762407f..7c329089a 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java @@ -88,7 +88,6 @@ public class SessionDescription { case 'm': if (currentMediaBuilder == null) { sessionDescriptionBuilder.setAttributes(attributeMap); - ; } else { currentMediaBuilder.setAttributes(attributeMap); mediaBuilder.add(currentMediaBuilder.createMedia()); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java index e945e4b4b..e21c38968 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/Content.java @@ -6,7 +6,6 @@ import com.google.common.base.Preconditions; import java.util.Locale; -import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java index d4c5fd745..0863b29df 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/stanzas/JinglePacket.java @@ -11,8 +11,8 @@ import java.util.Map; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; -import eu.siacs.conversations.xmpp.stanzas.IqPacket; import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.stanzas.IqPacket; public class JinglePacket extends IqPacket { diff --git a/src/main/java/eu/siacs/conversations/xmpp/pep/Avatar.java b/src/main/java/eu/siacs/conversations/xmpp/pep/Avatar.java index 1e4c1f629..a4397e466 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/pep/Avatar.java +++ b/src/main/java/eu/siacs/conversations/xmpp/pep/Avatar.java @@ -7,9 +7,9 @@ import eu.siacs.conversations.xmpp.Jid; public class Avatar { - public enum Origin { PEP, VCARD }; + public enum Origin { PEP, VCARD } - public String type; + public String type; public String sha1sum; public String image; public int height; diff --git a/src/playstore/java/eu/siacs/conversations/services/MaintenanceReceiver.java b/src/playstore/java/eu/siacs/conversations/services/MaintenanceReceiver.java index cdbdd5954..24212cf34 100644 --- a/src/playstore/java/eu/siacs/conversations/services/MaintenanceReceiver.java +++ b/src/playstore/java/eu/siacs/conversations/services/MaintenanceReceiver.java @@ -3,7 +3,6 @@ package eu.siacs.conversations.services; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import androidx.core.content.ContextCompat; import android.util.Log; import com.google.firebase.iid.FirebaseInstanceId; diff --git a/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java b/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java index 987b511e5..db1ad6586 100644 --- a/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java +++ b/src/playstore/java/eu/siacs/conversations/services/PushManagementService.java @@ -75,7 +75,6 @@ public class PushManagementService { final FirebaseMessaging firebaseMessaging; try { firebaseMessaging = FirebaseMessaging.getInstance(); - ; } catch (IllegalStateException e) { Log.d(Config.LOGTAG, "unable to get firebase instance token ", e); return; diff --git a/src/playstore/java/eu/siacs/conversations/services/PushMessageReceiver.java b/src/playstore/java/eu/siacs/conversations/services/PushMessageReceiver.java index 871fdb03a..f060747a5 100644 --- a/src/playstore/java/eu/siacs/conversations/services/PushMessageReceiver.java +++ b/src/playstore/java/eu/siacs/conversations/services/PushMessageReceiver.java @@ -1,7 +1,6 @@ package eu.siacs.conversations.services; import android.content.Intent; -import androidx.core.content.ContextCompat; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; diff --git a/src/playstoreCompat/java/eu/siacs/conversations/ui/service/EmojiService.java b/src/playstoreCompat/java/eu/siacs/conversations/ui/service/EmojiService.java index 242539543..5ed8c100a 100644 --- a/src/playstoreCompat/java/eu/siacs/conversations/ui/service/EmojiService.java +++ b/src/playstoreCompat/java/eu/siacs/conversations/ui/service/EmojiService.java @@ -2,10 +2,11 @@ package eu.siacs.conversations.ui.service; import android.content.Context; import android.os.Build; +import android.util.Log; + +import androidx.core.provider.FontRequest; import androidx.emoji.text.EmojiCompat; import androidx.emoji.text.FontRequestEmojiCompatConfig; -import androidx.core.provider.FontRequest; -import android.util.Log; import eu.siacs.conversations.Config; import eu.siacs.conversations.R;