From 16c8cc88d77f61a024ffa0cd6e99de654de4dbb1 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Mon, 20 May 2019 12:19:15 -0300 Subject: [PATCH 01/22] Update visibility and icon of camera flip control in call. Fixes #8221 --- .../components/webrtc/WebRtcCallControls.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallControls.java b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallControls.java index 8c4556c011..b02cb631cb 100644 --- a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallControls.java +++ b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallControls.java @@ -91,8 +91,7 @@ public class WebRtcCallControls extends LinearLayout { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { listener.onToggle(); - cameraFlipButton.setBackgroundResource(isChecked ? R.drawable.webrtc_camera_front_button - : R.drawable.webrtc_camera_rear_button); + updateCameraFlipIcon(isChecked); cameraFlipButton.setEnabled(false); } }); @@ -153,10 +152,17 @@ public class WebRtcCallControls extends LinearLayout { public void setCameraFlipButtonEnabled(boolean enabled) { cameraFlipButton.setChecked(enabled, false); + updateCameraFlipIcon(cameraFlipButton.isChecked()); + } + + private void updateCameraFlipIcon(boolean isChecked) { + cameraFlipButton.setBackgroundResource(isChecked ? R.drawable.webrtc_camera_front_button + : R.drawable.webrtc_camera_rear_button); } public void setCameraFlipAvailable(boolean available) { cameraFlipAvailable = available; + cameraFlipButton.setVisibility(cameraFlipAvailable && isVideoEnabled() ? View.VISIBLE : View.GONE); } public void setCameraFlipClickable(boolean clickable) { From 95858898d738786361ae5c5363b052490e28912f Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Mon, 20 May 2019 12:19:34 -0300 Subject: [PATCH 02/22] Lint - avoid calling a restricted API. --- src/org/thoughtcrime/securesms/ConversationListFragment.java | 4 ++-- .../securesms/components/webrtc/WebRtcCallScreen.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationListFragment.java b/src/org/thoughtcrime/securesms/ConversationListFragment.java index 8957eef761..c6542115c3 100644 --- a/src/org/thoughtcrime/securesms/ConversationListFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationListFragment.java @@ -133,8 +133,8 @@ public class ConversationListFragment extends Fragment emptyImage = ViewUtil.findById(view, R.id.empty); emptySearch = ViewUtil.findById(view, R.id.empty_search); - if (archive) fab.setVisibility(View.GONE); - else fab.setVisibility(View.VISIBLE); + if (archive) fab.hide(); + else fab.show(); reminderView.setOnDismissListener(() -> updateReminders(true)); diff --git a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java index a605aa9c08..9bbc3c7215 100644 --- a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java +++ b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java @@ -118,7 +118,7 @@ public class WebRtcCallScreen extends FrameLayout implements RecipientModifiedLi public void setIncomingCall(Recipient personInfo) { setCard(personInfo, getContext().getString(R.string.CallScreen_Incoming_call)); - endCallButton.setVisibility(View.INVISIBLE); + endCallButton.hide(); incomingCallButton.setVisibility(View.VISIBLE); incomingCallButton.startRingingAnimation(); } @@ -141,7 +141,7 @@ public class WebRtcCallScreen extends FrameLayout implements RecipientModifiedLi this.untrustedIdentityExplanation.setText(spannableString); this.untrustedIdentityExplanation.setMovementMethod(LinkMovementMethod.getInstance()); - this.endCallButton.setVisibility(View.INVISIBLE); + this.endCallButton.hide(); } public void setIncomingCallActionListener(WebRtcAnswerDeclineButton.AnswerDeclineListener listener) { From 10ad3fbf821d00a26b82689b16ca2fc59f2b2b55 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Mon, 20 May 2019 12:19:57 -0300 Subject: [PATCH 03/22] Lint - Use easily identifiable wake lock tags. --- src/org/thoughtcrime/securesms/mms/MmsRadio.java | 2 +- .../service/ApplicationMigrationService.java | 2 +- .../thoughtcrime/securesms/util/WakeLockUtil.java | 14 ++++++++++++++ .../securesms/webrtc/locks/LockManager.java | 6 +++--- .../securesms/webrtc/locks/ProximityLock.java | 5 ++--- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/org/thoughtcrime/securesms/mms/MmsRadio.java b/src/org/thoughtcrime/securesms/mms/MmsRadio.java index 1d5325631a..2ae17f5d02 100644 --- a/src/org/thoughtcrime/securesms/mms/MmsRadio.java +++ b/src/org/thoughtcrime/securesms/mms/MmsRadio.java @@ -44,7 +44,7 @@ public class MmsRadio { PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); this.context = context; this.connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - this.wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MMS Connection"); + this.wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "signal:mms"); this.wakeLock.setReferenceCounted(true); } diff --git a/src/org/thoughtcrime/securesms/service/ApplicationMigrationService.java b/src/org/thoughtcrime/securesms/service/ApplicationMigrationService.java index 9ca26774c2..0436711b16 100644 --- a/src/org/thoughtcrime/securesms/service/ApplicationMigrationService.java +++ b/src/org/thoughtcrime/securesms/service/ApplicationMigrationService.java @@ -149,7 +149,7 @@ public class ApplicationMigrationService extends Service public void run() { notification = initializeBackgroundNotification(); PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE); - WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Migration"); + WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "signal:migration"); try { wakeLock.acquire(); diff --git a/src/org/thoughtcrime/securesms/util/WakeLockUtil.java b/src/org/thoughtcrime/securesms/util/WakeLockUtil.java index f5ed6d13f3..6d16e354c6 100644 --- a/src/org/thoughtcrime/securesms/util/WakeLockUtil.java +++ b/src/org/thoughtcrime/securesms/util/WakeLockUtil.java @@ -13,6 +13,8 @@ public class WakeLockUtil { /** * Run a runnable with a wake lock. Ensures that the lock is safely acquired and released. + * + * @param tag will be prefixed with "signal:" if it does not already start with it. */ public static void runWithLock(@NonNull Context context, int lockType, long timeout, @NonNull String tag, @NonNull Runnable task) { WakeLock wakeLock = null; @@ -26,7 +28,11 @@ public class WakeLockUtil { } } + /** + * @param tag will be prefixed with "signal:" if it does not already start with it. + */ public static WakeLock acquire(@NonNull Context context, int lockType, long timeout, @NonNull String tag) { + tag = prefixTag(tag); try { PowerManager powerManager = ServiceUtil.getPowerManager(context); WakeLock wakeLock = powerManager.newWakeLock(lockType, tag); @@ -41,7 +47,11 @@ public class WakeLockUtil { } } + /** + * @param tag will be prefixed with "signal:" if it does not already start with it. + */ public static void release(@NonNull WakeLock wakeLock, @NonNull String tag) { + tag = prefixTag(tag); try { if (wakeLock.isHeld()) { wakeLock.release(); @@ -53,4 +63,8 @@ public class WakeLockUtil { Log.w(TAG, "Failed to release wakelock with tag: " + tag, e); } } + + private static String prefixTag(@NonNull String tag) { + return tag.startsWith("signal:") ? tag : "signal:" + tag; + } } diff --git a/src/org/thoughtcrime/securesms/webrtc/locks/LockManager.java b/src/org/thoughtcrime/securesms/webrtc/locks/LockManager.java index 0eb278a0f7..20a6edeba7 100644 --- a/src/org/thoughtcrime/securesms/webrtc/locks/LockManager.java +++ b/src/org/thoughtcrime/securesms/webrtc/locks/LockManager.java @@ -44,12 +44,12 @@ public class LockManager { public LockManager(Context context) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - fullLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "RedPhone Full"); - partialLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RedPhone Partial"); + fullLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "signal:full"); + partialLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "signal:partial"); proximityLock = new ProximityLock(pm); WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); - wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "RedPhone Wifi"); + wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "signal:wifi"); fullLock.setReferenceCounted(false); partialLock.setReferenceCounted(false); diff --git a/src/org/thoughtcrime/securesms/webrtc/locks/ProximityLock.java b/src/org/thoughtcrime/securesms/webrtc/locks/ProximityLock.java index 938381e7ea..323db13dc4 100644 --- a/src/org/thoughtcrime/securesms/webrtc/locks/ProximityLock.java +++ b/src/org/thoughtcrime/securesms/webrtc/locks/ProximityLock.java @@ -32,14 +32,13 @@ class ProximityLock { private Optional getProximityLock(PowerManager pm) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (pm.isWakeLockLevelSupported(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK)) { - return Optional.fromNullable(pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, - "Signal Proximity Lock")); + return Optional.fromNullable(pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "signal:proximity")); } else { return Optional.absent(); } } else { try { - return Optional.fromNullable(pm.newWakeLock(PROXIMITY_SCREEN_OFF_WAKE_LOCK, "RedPhone Incall")); + return Optional.fromNullable(pm.newWakeLock(PROXIMITY_SCREEN_OFF_WAKE_LOCK, "signal:incall")); } catch (Throwable t) { Log.e(TAG, "Failed to create proximity lock", t); return Optional.absent(); From 0a7970ad0cb6afd0f7576716b5cbbe7d00486549 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Wed, 22 May 2019 13:28:02 -0300 Subject: [PATCH 04/22] Image Editor - Allow undoing back to the original state when exceeds the undo limit. --- .../securesms/imageeditor/model/ElementStack.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/imageeditor/model/ElementStack.java b/src/org/thoughtcrime/securesms/imageeditor/model/ElementStack.java index 15e0516143..4eb8aa609e 100644 --- a/src/org/thoughtcrime/securesms/imageeditor/model/ElementStack.java +++ b/src/org/thoughtcrime/securesms/imageeditor/model/ElementStack.java @@ -13,7 +13,9 @@ import java.util.Stack; *

* Elements are mutable, so this stack serializes the element and keeps a stack of serialized data. *

- * The stack has a {@link #limit} and if it exceeds that limit during a push the earliest item is removed. + * The stack has a {@link #limit} and if it exceeds that limit during a push the second to earliest item + * is removed so that it can always go back to the first state. Effectively collapsing the history for + * the start of the stack. */ final class ElementStack implements Parcelable { @@ -35,6 +37,8 @@ final class ElementStack implements Parcelable { /** * Pushes an element to the stack iff the element's serialized value is different to any found at * the top of the stack. + *

+ * Removes the second to earliest item if it is overflowing. * * @param element new editor element state. * @return true iff the pushed item was different to the top item. @@ -46,7 +50,7 @@ final class ElementStack implements Parcelable { if (push) { stack.push(bytes); if (stack.size() > limit) { - stack.remove(0); + stack.remove(1); } } return push; From 7db15885781e20d9adeaaecf22e9e700ff399020 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Wed, 22 May 2019 13:29:45 -0300 Subject: [PATCH 05/22] Do not assume phone number in conversation. Fixes #8813 --- .../thoughtcrime/securesms/ConversationListItem.java | 2 +- src/org/thoughtcrime/securesms/database/Address.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationListItem.java b/src/org/thoughtcrime/securesms/ConversationListItem.java index fb62951dc3..067b3efbfb 100644 --- a/src/org/thoughtcrime/securesms/ConversationListItem.java +++ b/src/org/thoughtcrime/securesms/ConversationListItem.java @@ -200,7 +200,7 @@ public class ConversationListItem extends RelativeLayout String name = recipient.isLocalNumber() ? getContext().getString(R.string.note_to_self) : recipient.getName(); fromView.setText(SearchUtil.getHighlightedSpan(locale, () -> new StyleSpan(Typeface.BOLD), name, highlightSubstring)); - subjectView.setText(SearchUtil.getHighlightedSpan(locale, () -> new StyleSpan(Typeface.BOLD), contact.getAddress().toPhoneString(), highlightSubstring)); + subjectView.setText(SearchUtil.getHighlightedSpan(locale, () -> new StyleSpan(Typeface.BOLD), contact.getAddress().toString(), highlightSubstring)); dateView.setText(""); archivedView.setVisibility(GONE); unreadIndicator.setVisibility(GONE); diff --git a/src/org/thoughtcrime/securesms/database/Address.java b/src/org/thoughtcrime/securesms/database/Address.java index a60028c7a6..ac7eaea579 100644 --- a/src/org/thoughtcrime/securesms/database/Address.java +++ b/src/org/thoughtcrime/securesms/database/Address.java @@ -126,17 +126,21 @@ public class Address implements Parcelable, Comparable

{ } public @NonNull String toGroupString() { - if (!isGroup()) throw new AssertionError("Not group: " + address); + if (!isGroup()) throw new AssertionError("Not group"); return address; } public @NonNull String toPhoneString() { - if (!isPhone()) throw new AssertionError("Not e164: " + address); + if (!isPhone()) { + if (isEmail()) throw new AssertionError("Not e164, is email"); + if (isGroup()) throw new AssertionError("Not e164, is group"); + throw new AssertionError("Not e164, unknown"); + } return address; } public @NonNull String toEmailString() { - if (!isEmail()) throw new AssertionError("Not email: " + address); + if (!isEmail()) throw new AssertionError("Not email"); return address; } From 9445555d662fc042a578864192e84e861ba40b22 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Wed, 22 May 2019 13:51:56 -0300 Subject: [PATCH 06/22] Code analysis - address @NotNull/@Nullable issues. --- .../securesms/BasicIntroFragment.java | 3 ++- .../securesms/BlockedContactsActivity.java | 6 +++--- .../ContactSelectionListFragment.java | 8 ++++---- .../securesms/ConversationListFragment.java | 20 +++++++++---------- .../securesms/CountrySelectionFragment.java | 7 ++++--- .../securesms/DeviceAddFragment.java | 3 ++- .../securesms/DeviceListFragment.java | 9 +++++---- .../securesms/LinkPreviewsIntroFragment.java | 3 ++- .../securesms/MediaOverviewActivity.java | 12 +++++------ .../securesms/MediaPreviewActivity.java | 6 +++--- .../PlayServicesProblemFragment.java | 5 +++-- .../securesms/ReadReceiptsIntroFragment.java | 3 ++- .../RecipientPreferenceActivity.java | 6 +++--- .../TypingIndicatorIntroFragment.java | 3 ++- .../securesms/VerifyIdentityActivity.java | 4 ++-- .../securesms/attachments/AttachmentId.java | 4 +++- .../components/CustomDefaultPreference.java | 2 +- .../components/RecentPhotoViewRail.java | 6 +++--- .../components/RecyclerViewFastScroller.java | 2 +- .../components/emoji/EmojiDrawer.java | 6 +++--- .../securesms/components/emoji/EmojiSpan.java | 4 ++-- .../emoji/parsing/EmojiDrawInfo.java | 2 +- .../emoji/parsing/EmojiPageBitmap.java | 2 +- .../components/emoji/parsing/EmojiParser.java | 2 +- .../avatars/GroupRecordContactPhoto.java | 2 +- .../contacts/avatars/ProfileContactPhoto.java | 2 +- .../contacts/avatars/SystemContactPhoto.java | 5 ++--- .../securesms/contactshare/Contact.java | 2 +- .../contactshare/ContactFieldAdapter.java | 6 +++--- .../contactshare/ContactShareEditAdapter.java | 4 ++-- .../conversation/ConversationFragment.java | 10 +++++----- .../conversation/ConversationItem.java | 12 +++++------ .../securesms/database/Address.java | 2 +- .../securesms/database/CursorList.java | 18 +++++++---------- .../database/CursorRecyclerViewAdapter.java | 6 +++--- .../securesms/database/IdentityDatabase.java | 2 +- .../securesms/events/WebRtcViewModel.java | 2 +- .../securesms/giph/model/ChunkedImageUrl.java | 2 +- .../securesms/giph/ui/GiphyAdapter.java | 6 +++--- .../securesms/giph/ui/GiphyFragment.java | 6 +++--- .../securesms/giph/ui/GiphyGifFragment.java | 3 ++- .../giph/ui/GiphyStickerFragment.java | 3 ++- .../giph/util/InfiniteScrollListener.java | 3 ++- .../glide/ChunkedImageUrlLoader.java | 8 ++++---- .../securesms/glide/ContactPhotoFetcher.java | 8 +++----- .../securesms/glide/ContactPhotoLoader.java | 8 ++++---- .../securesms/glide/OkHttpStreamFetcher.java | 8 +++----- .../securesms/glide/OkHttpUrlLoader.java | 8 ++++---- .../glide/PaddedHeadersInterceptor.java | 2 +- .../securesms/imageeditor/DrawingSession.java | 4 ++-- .../imageeditor/ElementDragEditSession.java | 2 +- .../securesms/jobs/AttachmentDownloadJob.java | 2 +- .../securesms/jobs/AttachmentUploadJob.java | 2 +- .../securesms/jobs/AvatarDownloadJob.java | 2 +- .../securesms/jobs/CleanPreKeysJob.java | 2 +- .../securesms/jobs/CreateSignedPreKeyJob.java | 2 +- .../securesms/jobs/DirectoryRefreshJob.java | 2 +- .../securesms/jobs/FcmRefreshJob.java | 2 +- .../securesms/jobs/LocalBackupJob.java | 2 +- .../securesms/jobs/MmsDownloadJob.java | 2 +- .../securesms/jobs/MmsReceiveJob.java | 2 +- .../securesms/jobs/MmsSendJob.java | 2 +- .../jobs/MultiDeviceBlockedUpdateJob.java | 2 +- .../MultiDeviceConfigurationUpdateJob.java | 2 +- .../jobs/MultiDeviceContactUpdateJob.java | 2 +- .../jobs/MultiDeviceGroupUpdateJob.java | 2 +- .../jobs/MultiDeviceProfileKeyUpdateJob.java | 2 +- .../jobs/MultiDeviceReadUpdateJob.java | 2 +- .../jobs/MultiDeviceVerifiedUpdateJob.java | 2 +- .../securesms/jobs/PushContentReceiveJob.java | 2 +- .../securesms/jobs/PushDecryptJob.java | 2 +- .../securesms/jobs/PushGroupSendJob.java | 2 +- .../securesms/jobs/PushGroupUpdateJob.java | 2 +- .../securesms/jobs/PushMediaSendJob.java | 2 +- .../jobs/PushNotificationReceiveJob.java | 2 +- .../securesms/jobs/PushTextSendJob.java | 5 ++--- .../securesms/jobs/RefreshAttributesJob.java | 2 +- .../securesms/jobs/RefreshPreKeysJob.java | 2 +- ...RefreshUnidentifiedDeliveryAbilityJob.java | 2 +- .../securesms/jobs/RequestGroupInfoJob.java | 2 +- .../jobs/RetrieveProfileAvatarJob.java | 2 +- .../securesms/jobs/RetrieveProfileJob.java | 2 +- .../securesms/jobs/RotateCertificateJob.java | 4 ++-- .../securesms/jobs/RotateProfileKeyJob.java | 2 +- .../securesms/jobs/RotateSignedPreKeyJob.java | 2 +- .../jobs/SendDeliveryReceiptJob.java | 2 +- .../securesms/jobs/SendReadReceiptJob.java | 2 +- .../jobs/ServiceOutageDetectionJob.java | 2 +- .../securesms/jobs/SmsReceiveJob.java | 2 +- .../securesms/jobs/SmsSendJob.java | 2 +- .../securesms/jobs/SmsSentJob.java | 2 +- .../securesms/jobs/TrimThreadJob.java | 2 +- .../securesms/jobs/TypingSendJob.java | 2 +- .../securesms/jobs/UpdateApkJob.java | 4 ++-- .../linkpreview/LinkPreviewRepository.java | 4 ++-- .../lock/RegistrationLockDialog.java | 2 +- .../logsubmit/ShareIntentListAdapter.java | 3 ++- .../logsubmit/SubmitLogFragment.java | 6 +++--- .../mediasend/Camera1Controller.java | 2 +- .../mms/AttachmentStreamLocalUriFetcher.java | 8 +++----- .../mms/AttachmentStreamUriLoader.java | 9 ++++----- .../securesms/mms/LegacyMmsConnection.java | 2 +- .../notifications/NotificationItem.java | 2 +- .../securesms/providers/MmsBodyProvider.java | 14 +++++++------ .../securesms/recipients/Recipient.java | 2 +- .../scribbles/StickerSelectFragment.java | 15 +++++++------- .../scribbles/widget/ColorPaletteAdapter.java | 4 ++-- .../securesms/search/SearchListAdapter.java | 5 ++--- .../securesms/util/LongClickCopySpan.java | 3 ++- .../securesms/util/SoftHashMap.java | 12 ++++++----- .../util/StickyHeaderDecoration.java | 7 ++++--- .../securesms/util/VerifySpan.java | 2 +- .../spans/CenterAlignedRelativeSizeSpan.java | 3 ++- 113 files changed, 238 insertions(+), 232 deletions(-) diff --git a/src/org/thoughtcrime/securesms/BasicIntroFragment.java b/src/org/thoughtcrime/securesms/BasicIntroFragment.java index db1520ad61..9d50273fc3 100644 --- a/src/org/thoughtcrime/securesms/BasicIntroFragment.java +++ b/src/org/thoughtcrime/securesms/BasicIntroFragment.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; @@ -41,7 +42,7 @@ public class BasicIntroFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.color_fragment, container, false); diff --git a/src/org/thoughtcrime/securesms/BlockedContactsActivity.java b/src/org/thoughtcrime/securesms/BlockedContactsActivity.java index 1c3f5b5959..2dc23d6107 100644 --- a/src/org/thoughtcrime/securesms/BlockedContactsActivity.java +++ b/src/org/thoughtcrime/securesms/BlockedContactsActivity.java @@ -85,19 +85,19 @@ public class BlockedContactsActivity extends PassphraseRequiredActionBarActivity } @Override - public Loader onCreateLoader(int id, Bundle args) { + public @NonNull Loader onCreateLoader(int id, Bundle args) { return new BlockedContactsLoader(getActivity()); } @Override - public void onLoadFinished(Loader loader, Cursor data) { + public void onLoadFinished(@NonNull Loader loader, Cursor data) { if (getListAdapter() != null) { ((CursorAdapter) getListAdapter()).changeCursor(data); } } @Override - public void onLoaderReset(Loader loader) { + public void onLoaderReset(@NonNull Loader loader) { if (getListAdapter() != null) { ((CursorAdapter) getListAdapter()).changeCursor(null); } diff --git a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java index e6c244b238..d68d7ef1f8 100644 --- a/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java +++ b/src/org/thoughtcrime/securesms/ContactSelectionListFragment.java @@ -122,7 +122,7 @@ public class ContactSelectionListFragment extends Fragment } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.contact_selection_list_fragment, container, false); emptyText = ViewUtil.findById(view, android.R.id.empty); @@ -214,14 +214,14 @@ public class ContactSelectionListFragment extends Fragment } @Override - public Loader onCreateLoader(int id, Bundle args) { + public @NonNull Loader onCreateLoader(int id, Bundle args) { return new ContactsCursorLoader(getActivity(), getActivity().getIntent().getIntExtra(DISPLAY_MODE, DisplayMode.FLAG_ALL), cursorFilter, getActivity().getIntent().getBooleanExtra(RECENTS, false)); } @Override - public void onLoadFinished(Loader loader, Cursor data) { + public void onLoadFinished(@NonNull Loader loader, Cursor data) { swipeRefresh.setVisibility(View.VISIBLE); showContactsLayout.setVisibility(View.GONE); @@ -236,7 +236,7 @@ public class ContactSelectionListFragment extends Fragment } @Override - public void onLoaderReset(Loader loader) { + public void onLoaderReset(@NonNull Loader loader) { ((CursorRecyclerViewAdapter) recyclerView.getAdapter()).changeCursor(null); fastScroller.setVisibility(View.GONE); } diff --git a/src/org/thoughtcrime/securesms/ConversationListFragment.java b/src/org/thoughtcrime/securesms/ConversationListFragment.java index c6542115c3..216854bb9f 100644 --- a/src/org/thoughtcrime/securesms/ConversationListFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationListFragment.java @@ -352,12 +352,12 @@ public class ConversationListFragment extends Fragment } @Override - public Loader onCreateLoader(int arg0, Bundle arg1) { + public @NonNull Loader onCreateLoader(int arg0, Bundle arg1) { return new ConversationListLoader(getActivity(), queryFilter, archive); } @Override - public void onLoadFinished(Loader arg0, Cursor cursor) { + public void onLoadFinished(@NonNull Loader arg0, Cursor cursor) { if ((cursor == null || cursor.getCount() <= 0) && TextUtils.isEmpty(queryFilter) && !archive) { list.setVisibility(View.INVISIBLE); emptyState.setVisibility(View.VISIBLE); @@ -380,7 +380,7 @@ public class ConversationListFragment extends Fragment } @Override - public void onLoaderReset(Loader arg0) { + public void onLoaderReset(@NonNull Loader arg0) { getListAdapter().changeCursor(null); } @@ -481,15 +481,15 @@ public class ConversationListFragment extends Fragment } @Override - public boolean onMove(RecyclerView recyclerView, - RecyclerView.ViewHolder viewHolder, - RecyclerView.ViewHolder target) + public boolean onMove(@NonNull RecyclerView recyclerView, + @NonNull RecyclerView.ViewHolder viewHolder, + @NonNull RecyclerView.ViewHolder target) { return false; } @Override - public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + public int getSwipeDirs(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { if (viewHolder.itemView instanceof ConversationListItemAction) { return 0; } @@ -503,7 +503,7 @@ public class ConversationListFragment extends Fragment @SuppressLint("StaticFieldLeak") @Override - public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { + public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) { if (viewHolder.itemView instanceof ConversationListItemInboxZero) return; final long threadId = ((ConversationListItem)viewHolder.itemView).getThreadId(); final int unreadCount = ((ConversationListItem)viewHolder.itemView).getUnreadCount(); @@ -557,8 +557,8 @@ public class ConversationListFragment extends Fragment } @Override - public void onChildDraw(Canvas c, RecyclerView recyclerView, - RecyclerView.ViewHolder viewHolder, + public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, + @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { diff --git a/src/org/thoughtcrime/securesms/CountrySelectionFragment.java b/src/org/thoughtcrime/securesms/CountrySelectionFragment.java index e39d1d95bd..3f53b40ed8 100644 --- a/src/org/thoughtcrime/securesms/CountrySelectionFragment.java +++ b/src/org/thoughtcrime/securesms/CountrySelectionFragment.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms; import android.app.Activity; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.ListFragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.Loader; @@ -54,12 +55,12 @@ public class CountrySelectionFragment extends ListFragment implements LoaderMana } @Override - public Loader>> onCreateLoader(int arg0, Bundle arg1) { + public @NonNull Loader>> onCreateLoader(int arg0, Bundle arg1) { return new CountryListLoader(getActivity()); } @Override - public void onLoadFinished(Loader>> loader, + public void onLoadFinished(@NonNull Loader>> loader, ArrayList> results) { String[] from = {"country_name", "country_code"}; @@ -72,7 +73,7 @@ public class CountrySelectionFragment extends ListFragment implements LoaderMana } @Override - public void onLoaderReset(Loader>> arg0) { + public void onLoaderReset(@NonNull Loader>> arg0) { this.setListAdapter(null); } diff --git a/src/org/thoughtcrime/securesms/DeviceAddFragment.java b/src/org/thoughtcrime/securesms/DeviceAddFragment.java index 0cfa4b6b2c..e0116f52eb 100644 --- a/src/org/thoughtcrime/securesms/DeviceAddFragment.java +++ b/src/org/thoughtcrime/securesms/DeviceAddFragment.java @@ -5,6 +5,7 @@ import android.annotation.TargetApi; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; @@ -29,7 +30,7 @@ public class DeviceAddFragment extends Fragment { private ScanListener scanListener; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { this.container = ViewUtil.inflate(inflater, viewGroup, R.layout.device_add_fragment); this.overlay = ViewUtil.findById(this.container, R.id.overlay); this.scannerView = ViewUtil.findById(this.container, R.id.scanner); diff --git a/src/org/thoughtcrime/securesms/DeviceListFragment.java b/src/org/thoughtcrime/securesms/DeviceListFragment.java index d200457f5c..ca847a9846 100644 --- a/src/org/thoughtcrime/securesms/DeviceListFragment.java +++ b/src/org/thoughtcrime/securesms/DeviceListFragment.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.DialogInterface; import android.os.AsyncTask; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.ListFragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.Loader; @@ -89,7 +90,7 @@ public class DeviceListFragment extends ListFragment } @Override - public Loader> onCreateLoader(int id, Bundle args) { + public @NonNull Loader> onCreateLoader(int id, Bundle args) { empty.setVisibility(View.GONE); progressContainer.setVisibility(View.VISIBLE); @@ -97,7 +98,7 @@ public class DeviceListFragment extends ListFragment } @Override - public void onLoadFinished(Loader> loader, List data) { + public void onLoadFinished(@NonNull Loader> loader, List data) { progressContainer.setVisibility(View.GONE); if (data == null) { @@ -116,7 +117,7 @@ public class DeviceListFragment extends ListFragment } @Override - public void onLoaderReset(Loader> loader) { + public void onLoaderReset(@NonNull Loader> loader) { setListAdapter(null); } @@ -210,7 +211,7 @@ public class DeviceListFragment extends ListFragment } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent) { if (convertView == null) { convertView = ((Activity)getContext()).getLayoutInflater().inflate(resource, parent, false); } diff --git a/src/org/thoughtcrime/securesms/LinkPreviewsIntroFragment.java b/src/org/thoughtcrime/securesms/LinkPreviewsIntroFragment.java index 1016e4a91c..c87fe65e07 100644 --- a/src/org/thoughtcrime/securesms/LinkPreviewsIntroFragment.java +++ b/src/org/thoughtcrime/securesms/LinkPreviewsIntroFragment.java @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; @@ -41,7 +42,7 @@ public class LinkPreviewsIntroFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.experience_upgrade_link_previews_fragment, container, false); view.findViewById(R.id.experience_ok_button).setOnClickListener(v -> { diff --git a/src/org/thoughtcrime/securesms/MediaOverviewActivity.java b/src/org/thoughtcrime/securesms/MediaOverviewActivity.java index 519cc30862..395514f39d 100644 --- a/src/org/thoughtcrime/securesms/MediaOverviewActivity.java +++ b/src/org/thoughtcrime/securesms/MediaOverviewActivity.java @@ -257,12 +257,12 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity { } @Override - public Loader onCreateLoader(int i, Bundle bundle) { + public @NonNull Loader onCreateLoader(int i, Bundle bundle) { return new BucketedThreadMediaLoader(getContext(), recipient.getAddress()); } @Override - public void onLoadFinished(Loader loader, BucketedThreadMedia bucketedThreadMedia) { + public void onLoadFinished(@NonNull Loader loader, BucketedThreadMedia bucketedThreadMedia) { ((MediaGalleryAdapter) recyclerView.getAdapter()).setMedia(bucketedThreadMedia); ((MediaGalleryAdapter) recyclerView.getAdapter()).notifyAllSectionsDataSetChanged(); @@ -271,7 +271,7 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity { } @Override - public void onLoaderReset(Loader cursorLoader) { + public void onLoaderReset(@NonNull Loader cursorLoader) { ((MediaGalleryAdapter) recyclerView.getAdapter()).setMedia(new BucketedThreadMedia(getContext())); } @@ -496,12 +496,12 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity { } @Override - public Loader onCreateLoader(int id, Bundle args) { + public @NonNull Loader onCreateLoader(int id, Bundle args) { return new ThreadMediaLoader(getContext(), recipient.getAddress(), false); } @Override - public void onLoadFinished(Loader loader, Cursor data) { + public void onLoadFinished(@NonNull Loader loader, Cursor data) { ((CursorRecyclerViewAdapter)this.recyclerView.getAdapter()).changeCursor(data); getActivity().invalidateOptionsMenu(); @@ -509,7 +509,7 @@ public class MediaOverviewActivity extends PassphraseRequiredActionBarActivity { } @Override - public void onLoaderReset(Loader loader) { + public void onLoaderReset(@NonNull Loader loader) { ((CursorRecyclerViewAdapter)this.recyclerView.getAdapter()).changeCursor(null); getActivity().invalidateOptionsMenu(); } diff --git a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java index a3a994cb54..a23c4cd962 100644 --- a/src/org/thoughtcrime/securesms/MediaPreviewActivity.java +++ b/src/org/thoughtcrime/securesms/MediaPreviewActivity.java @@ -441,12 +441,12 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im } @Override - public Loader> onCreateLoader(int id, Bundle args) { + public @NonNull Loader> onCreateLoader(int id, Bundle args) { return new PagingMediaLoader(this, conversationRecipient, initialMediaUri, leftIsRecent); } @Override - public void onLoadFinished(Loader> loader, @Nullable Pair data) { + public void onLoadFinished(@NonNull Loader> loader, @Nullable Pair data) { if (data != null) { @SuppressWarnings("ConstantConditions") CursorPagerAdapter adapter = new CursorPagerAdapter(this, GlideApp.with(this), getWindow(), data.first, data.second, leftIsRecent); @@ -465,7 +465,7 @@ public class MediaPreviewActivity extends PassphraseRequiredActionBarActivity im } @Override - public void onLoaderReset(Loader> loader) { + public void onLoaderReset(@NonNull Loader> loader) { } diff --git a/src/org/thoughtcrime/securesms/PlayServicesProblemFragment.java b/src/org/thoughtcrime/securesms/PlayServicesProblemFragment.java index 890b9ecc93..07fb96c76a 100644 --- a/src/org/thoughtcrime/securesms/PlayServicesProblemFragment.java +++ b/src/org/thoughtcrime/securesms/PlayServicesProblemFragment.java @@ -22,6 +22,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v7.app.AlertDialog; @@ -31,12 +32,12 @@ import com.google.android.gms.common.GooglePlayServicesUtil; public class PlayServicesProblemFragment extends DialogFragment { @Override - public @NonNull Dialog onCreateDialog(@NonNull Bundle bundle) { + public @NonNull Dialog onCreateDialog(@Nullable Bundle bundle) { int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(getActivity()); Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(getActivity(), code, 9111); if (dialog == null) { - return new AlertDialog.Builder(getActivity()) + return new AlertDialog.Builder(requireActivity()) .setNegativeButton(android.R.string.ok, null) .setMessage(R.string.PlayServicesProblemFragment_the_version_of_google_play_services_you_have_installed_is_not_functioning) .create(); diff --git a/src/org/thoughtcrime/securesms/ReadReceiptsIntroFragment.java b/src/org/thoughtcrime/securesms/ReadReceiptsIntroFragment.java index b154fb98fd..154f2a452b 100644 --- a/src/org/thoughtcrime/securesms/ReadReceiptsIntroFragment.java +++ b/src/org/thoughtcrime/securesms/ReadReceiptsIntroFragment.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.support.v7.widget.SwitchCompat; import android.view.LayoutInflater; @@ -29,7 +30,7 @@ public class ReadReceiptsIntroFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.experience_upgrade_preference_fragment, container, false); SwitchCompat preference = ViewUtil.findById(v, R.id.preference); diff --git a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java index 0b9078a884..707204e87b 100644 --- a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java +++ b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java @@ -231,12 +231,12 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi } @Override - public Loader onCreateLoader(int id, Bundle args) { + public @NonNull Loader onCreateLoader(int id, Bundle args) { return new ThreadMediaLoader(this, address, true); } @Override - public void onLoadFinished(Loader loader, Cursor data) { + public void onLoadFinished(@NonNull Loader loader, Cursor data) { if (data != null && data.getCount() > 0) { this.threadPhotoRailLabel.setVisibility(View.VISIBLE); this.threadPhotoRailView.setVisibility(View.VISIBLE); @@ -253,7 +253,7 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi } @Override - public void onLoaderReset(Loader loader) { + public void onLoaderReset(@NonNull Loader loader) { this.threadPhotoRailView.setCursor(glideRequests, null); } diff --git a/src/org/thoughtcrime/securesms/TypingIndicatorIntroFragment.java b/src/org/thoughtcrime/securesms/TypingIndicatorIntroFragment.java index e783ba30d9..f52b75f5e6 100644 --- a/src/org/thoughtcrime/securesms/TypingIndicatorIntroFragment.java +++ b/src/org/thoughtcrime/securesms/TypingIndicatorIntroFragment.java @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms; import android.content.Context; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; @@ -42,7 +43,7 @@ public class TypingIndicatorIntroFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.experience_upgrade_typing_indicators_fragment, container, false); View yesButton = view.findViewById(R.id.experience_yes_button); View noButton = view.findViewById(R.id.experience_no_button); diff --git a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java index db9a76d3e6..ccee12342f 100644 --- a/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java +++ b/src/org/thoughtcrime/securesms/VerifyIdentityActivity.java @@ -230,7 +230,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity private boolean animateFailureOnDraw = false; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { this.container = ViewUtil.inflate(inflater, viewGroup, R.layout.verify_display_fragment); this.numbersContainer = ViewUtil.findById(container, R.id.number_table); this.qrCode = ViewUtil.findById(container, R.id.qr_code); @@ -623,7 +623,7 @@ public class VerifyIdentityActivity extends PassphraseRequiredActionBarActivity private ScanningThread scanningThread; private ScanListener scanListener; - public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { this.container = ViewUtil.inflate(inflater, viewGroup, R.layout.verify_scan_fragment); this.cameraView = ViewUtil.findById(container, R.id.scanner); diff --git a/src/org/thoughtcrime/securesms/attachments/AttachmentId.java b/src/org/thoughtcrime/securesms/attachments/AttachmentId.java index afd44c0348..89389bb8df 100644 --- a/src/org/thoughtcrime/securesms/attachments/AttachmentId.java +++ b/src/org/thoughtcrime/securesms/attachments/AttachmentId.java @@ -1,5 +1,7 @@ package org.thoughtcrime.securesms.attachments; +import android.support.annotation.NonNull; + import com.fasterxml.jackson.annotation.JsonProperty; import org.thoughtcrime.securesms.util.Util; @@ -29,7 +31,7 @@ public class AttachmentId { return new String[] {String.valueOf(rowId), String.valueOf(uniqueId)}; } - public String toString() { + public @NonNull String toString() { return "(row id: " + rowId + ", unique ID: " + uniqueId + ")"; } diff --git a/src/org/thoughtcrime/securesms/components/CustomDefaultPreference.java b/src/org/thoughtcrime/securesms/components/CustomDefaultPreference.java index 757a58b9d3..149a903b2d 100644 --- a/src/org/thoughtcrime/securesms/components/CustomDefaultPreference.java +++ b/src/org/thoughtcrime/securesms/components/CustomDefaultPreference.java @@ -140,7 +140,7 @@ public class CustomDefaultPreference extends DialogPreference { @Override - public Dialog onCreateDialog(Bundle instanceState) { + public @NonNull Dialog onCreateDialog(Bundle instanceState) { Dialog dialog = super.onCreateDialog(instanceState); CustomDefaultPreference preference = (CustomDefaultPreference)getPreference(); diff --git a/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java b/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java index 87721de484..9fa8719c5b 100644 --- a/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java +++ b/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java @@ -64,17 +64,17 @@ public class RecentPhotoViewRail extends FrameLayout implements LoaderManager.Lo } @Override - public Loader onCreateLoader(int id, Bundle args) { + public @NonNull Loader onCreateLoader(int id, Bundle args) { return new RecentPhotosLoader(getContext()); } @Override - public void onLoadFinished(Loader loader, Cursor data) { + public void onLoadFinished(@NonNull Loader loader, Cursor data) { this.recyclerView.setAdapter(new RecentPhotoAdapter(getContext(), data, RecentPhotosLoader.BASE_URL, listener)); } @Override - public void onLoaderReset(Loader loader) { + public void onLoaderReset(@NonNull Loader loader) { ((CursorRecyclerViewAdapter)this.recyclerView.getAdapter()).changeCursor(null); } diff --git a/src/org/thoughtcrime/securesms/components/RecyclerViewFastScroller.java b/src/org/thoughtcrime/securesms/components/RecyclerViewFastScroller.java index 91f0b368de..f6567b43eb 100644 --- a/src/org/thoughtcrime/securesms/components/RecyclerViewFastScroller.java +++ b/src/org/thoughtcrime/securesms/components/RecyclerViewFastScroller.java @@ -52,7 +52,7 @@ public class RecyclerViewFastScroller extends LinearLayout { private final RecyclerView.OnScrollListener onScrollListener = new RecyclerView.OnScrollListener() { @Override - public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) { + public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) { if (handle.isSelected()) return; final int offset = recyclerView.computeVerticalScrollOffset(); final int range = recyclerView.computeVerticalScrollRange(); diff --git a/src/org/thoughtcrime/securesms/components/emoji/EmojiDrawer.java b/src/org/thoughtcrime/securesms/components/emoji/EmojiDrawer.java index e850bfe9da..05a3229d51 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/EmojiDrawer.java +++ b/src/org/thoughtcrime/securesms/components/emoji/EmojiDrawer.java @@ -165,19 +165,19 @@ public class EmojiDrawer extends LinearLayout implements InputView, EmojiSelecti } @Override - public void destroyItem(ViewGroup container, int position, Object object) { + public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { container.removeView((View)object); } @Override - public void setPrimaryItem(ViewGroup container, int position, Object object) { + public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) { EmojiPageView current = (EmojiPageView) object; current.onSelected(); super.setPrimaryItem(container, position, object); } @Override - public boolean isViewFromObject(View view, Object object) { + public boolean isViewFromObject(@NonNull View view, @NonNull Object object) { return view == object; } diff --git a/src/org/thoughtcrime/securesms/components/emoji/EmojiSpan.java b/src/org/thoughtcrime/securesms/components/emoji/EmojiSpan.java index d784165a51..39b33ed48a 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/EmojiSpan.java +++ b/src/org/thoughtcrime/securesms/components/emoji/EmojiSpan.java @@ -25,7 +25,7 @@ public class EmojiSpan extends AnimatingImageSpan { } @Override - public int getSize(Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) { + public int getSize(@NonNull Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) { if (fm != null && this.fm != null) { fm.ascent = this.fm.ascent; fm.descent = this.fm.descent; @@ -39,7 +39,7 @@ public class EmojiSpan extends AnimatingImageSpan { } @Override - public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { + public void draw(@NonNull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @NonNull Paint paint) { int height = bottom - top; int centeringMargin = (height - size) / 2; int adjustedMargin = (int) (centeringMargin * SHIFT_FACTOR); diff --git a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiDrawInfo.java b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiDrawInfo.java index 142b2b2549..28aed06238 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiDrawInfo.java +++ b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiDrawInfo.java @@ -22,7 +22,7 @@ public class EmojiDrawInfo { } @Override - public String toString() { + public @NonNull String toString() { return "DrawInfo{" + "page=" + page + ", index=" + index + diff --git a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java index bc7ca54bc8..a5487f7872 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java +++ b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiPageBitmap.java @@ -104,7 +104,7 @@ public class EmojiPageBitmap { } @Override - public String toString() { + public @NonNull String toString() { return model.getSprite(); } } diff --git a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiParser.java b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiParser.java index 119e79725c..7a9bc32a78 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiParser.java +++ b/src/org/thoughtcrime/securesms/components/emoji/parsing/EmojiParser.java @@ -124,7 +124,7 @@ public class EmojiParser { } @Override - public Iterator iterator() { + public @NonNull Iterator iterator() { return list.iterator(); } } diff --git a/src/org/thoughtcrime/securesms/contacts/avatars/GroupRecordContactPhoto.java b/src/org/thoughtcrime/securesms/contacts/avatars/GroupRecordContactPhoto.java index 461c2166c0..249841afa9 100644 --- a/src/org/thoughtcrime/securesms/contacts/avatars/GroupRecordContactPhoto.java +++ b/src/org/thoughtcrime/securesms/contacts/avatars/GroupRecordContactPhoto.java @@ -50,7 +50,7 @@ public class GroupRecordContactPhoto implements ContactPhoto { } @Override - public void updateDiskCacheKey(MessageDigest messageDigest) { + public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { messageDigest.update(address.serialize().getBytes()); messageDigest.update(Conversions.longToByteArray(avatarId)); } diff --git a/src/org/thoughtcrime/securesms/contacts/avatars/ProfileContactPhoto.java b/src/org/thoughtcrime/securesms/contacts/avatars/ProfileContactPhoto.java index 486065e3ee..62f4cd26a6 100644 --- a/src/org/thoughtcrime/securesms/contacts/avatars/ProfileContactPhoto.java +++ b/src/org/thoughtcrime/securesms/contacts/avatars/ProfileContactPhoto.java @@ -40,7 +40,7 @@ public class ProfileContactPhoto implements ContactPhoto { } @Override - public void updateDiskCacheKey(MessageDigest messageDigest) { + public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { messageDigest.update(address.serialize().getBytes()); messageDigest.update(avatarObject.getBytes()); } diff --git a/src/org/thoughtcrime/securesms/contacts/avatars/SystemContactPhoto.java b/src/org/thoughtcrime/securesms/contacts/avatars/SystemContactPhoto.java index 1a16b92677..817df232c0 100644 --- a/src/org/thoughtcrime/securesms/contacts/avatars/SystemContactPhoto.java +++ b/src/org/thoughtcrime/securesms/contacts/avatars/SystemContactPhoto.java @@ -30,9 +30,8 @@ public class SystemContactPhoto implements ContactPhoto { return context.getContentResolver().openInputStream(contactPhotoUri); } - @Nullable @Override - public Uri getUri(@NonNull Context context) { + public @Nullable Uri getUri(@NonNull Context context) { return contactPhotoUri; } @@ -42,7 +41,7 @@ public class SystemContactPhoto implements ContactPhoto { } @Override - public void updateDiskCacheKey(MessageDigest messageDigest) { + public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { messageDigest.update(address.serialize().getBytes()); messageDigest.update(contactPhotoUri.toString().getBytes()); messageDigest.update(Conversions.longToByteArray(lastModifiedTime)); diff --git a/src/org/thoughtcrime/securesms/contactshare/Contact.java b/src/org/thoughtcrime/securesms/contactshare/Contact.java index 39d6f1cd39..23e7a93e03 100644 --- a/src/org/thoughtcrime/securesms/contactshare/Contact.java +++ b/src/org/thoughtcrime/securesms/contactshare/Contact.java @@ -540,7 +540,7 @@ public class Contact implements Parcelable { }; @Override - public String toString() { + public @NonNull String toString() { StringBuilder builder = new StringBuilder(); if (!TextUtils.isEmpty(street)) { diff --git a/src/org/thoughtcrime/securesms/contactshare/ContactFieldAdapter.java b/src/org/thoughtcrime/securesms/contactshare/ContactFieldAdapter.java index 2888117455..6ffc9a2789 100644 --- a/src/org/thoughtcrime/securesms/contactshare/ContactFieldAdapter.java +++ b/src/org/thoughtcrime/securesms/contactshare/ContactFieldAdapter.java @@ -39,17 +39,17 @@ class ContactFieldAdapter extends RecyclerView.Adapter onCreateLoader(int id, Bundle args) { + public @NonNull Loader onCreateLoader(int id, Bundle args) { Log.i(TAG, "onCreateLoader"); loaderStartTime = System.currentTimeMillis(); @@ -630,7 +630,7 @@ public class ConversationFragment extends Fragment } @Override - public void onLoadFinished(Loader cursorLoader, Cursor cursor) { + public void onLoadFinished(@NonNull Loader cursorLoader, Cursor cursor) { long loadTime = System.currentTimeMillis() - loaderStartTime; int count = cursor.getCount(); Log.i(TAG, "onLoadFinished - took " + loadTime + " ms to load a cursor of size " + count); @@ -705,7 +705,7 @@ public class ConversationFragment extends Fragment } @Override - public void onLoaderReset(Loader arg0) { + public void onLoaderReset(@NonNull Loader arg0) { if (list.getAdapter() != null) { getListAdapter().changeCursor(null); } @@ -828,7 +828,7 @@ public class ConversationFragment extends Fragment } @Override - public void onScrolled(final RecyclerView rv, final int dx, final int dy) { + public void onScrolled(@NonNull final RecyclerView rv, final int dx, final int dy) { boolean currentlyAtBottom = isAtBottom(); boolean currentlyAtZoomScrollHeight = isAtZoomScrollHeight(); int positionId = getHeaderPositionId(); @@ -854,7 +854,7 @@ public class ConversationFragment extends Fragment } @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { conversationDateHeader.show(); } else if (newState == RecyclerView.SCROLL_STATE_IDLE) { diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationItem.java b/src/org/thoughtcrime/securesms/conversation/ConversationItem.java index e05286b0c0..79b809a5bb 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -149,12 +149,12 @@ public class ConversationItem extends LinearLayout private ViewGroup container; private @NonNull Set batchSelected = new HashSet<>(); - private @NonNull Recipient conversationRecipient; - private @NonNull Stub mediaThumbnailStub; - private @NonNull Stub audioViewStub; - private @NonNull Stub documentViewStub; - private @NonNull Stub sharedContactStub; - private @NonNull Stub linkPreviewStub; + private Recipient conversationRecipient; + private Stub mediaThumbnailStub; + private Stub audioViewStub; + private Stub documentViewStub; + private Stub sharedContactStub; + private Stub linkPreviewStub; private @Nullable EventListener eventListener; private int defaultBubbleColor; diff --git a/src/org/thoughtcrime/securesms/database/Address.java b/src/org/thoughtcrime/securesms/database/Address.java index ac7eaea579..c87352d194 100644 --- a/src/org/thoughtcrime/securesms/database/Address.java +++ b/src/org/thoughtcrime/securesms/database/Address.java @@ -145,7 +145,7 @@ public class Address implements Parcelable, Comparable
{ } @Override - public String toString() { + public @NonNull String toString() { return address; } diff --git a/src/org/thoughtcrime/securesms/database/CursorList.java b/src/org/thoughtcrime/securesms/database/CursorList.java index f53aa3b3d8..51120ee672 100644 --- a/src/org/thoughtcrime/securesms/database/CursorList.java +++ b/src/org/thoughtcrime/securesms/database/CursorList.java @@ -5,6 +5,7 @@ import android.database.Cursor; import android.database.DataSetObserver; import android.database.MatrixCursor; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import java.io.Closeable; import java.util.Collection; @@ -58,9 +59,8 @@ public class CursorList implements List, Closeable { throw new UnsupportedOperationException(); } - @NonNull @Override - public Iterator iterator() { + public @NonNull Iterator iterator() { return new Iterator() { int index = 0; @@ -77,9 +77,8 @@ public class CursorList implements List, Closeable { }; } - @NonNull @Override - public Object[] toArray() { + public @NonNull Object[] toArray() { Object[] out = new Object[size()]; for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); @@ -145,19 +144,17 @@ public class CursorList implements List, Closeable { } @Override - public ListIterator listIterator() { + public @NonNull ListIterator listIterator() { throw new UnsupportedOperationException(); } - @NonNull @Override - public ListIterator listIterator(int i) { + public @NonNull ListIterator listIterator(int i) { throw new UnsupportedOperationException(); } - @NonNull @Override - public List subList(int i, int i1) { + public @NonNull List subList(int i, int i1) { throw new UnsupportedOperationException(); } @@ -176,9 +173,8 @@ public class CursorList implements List, Closeable { throw new UnsupportedOperationException(); } - @NonNull @Override - public T[] toArray(@NonNull Object[] objects) { + public @NonNull T[] toArray(@Nullable Object[] objects) { throw new UnsupportedOperationException(); } diff --git a/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java b/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java index f815e900de..0385f56e4b 100644 --- a/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java +++ b/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java @@ -130,7 +130,7 @@ public abstract class CursorRecyclerViewAdapter { } @Override - public GiphyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public @NonNull GiphyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.giphy_thumbnail, parent, false); @@ -140,7 +140,7 @@ class GiphyAdapter extends RecyclerView.Adapter { } @Override - public void onBindViewHolder(GiphyViewHolder holder, int position) { + public void onBindViewHolder(@NonNull GiphyViewHolder holder, int position) { GiphyImage image = images.get(position); holder.modelReady = false; @@ -173,7 +173,7 @@ class GiphyAdapter extends RecyclerView.Adapter { } @Override - public void onViewRecycled(GiphyViewHolder holder) { + public void onViewRecycled(@NonNull GiphyViewHolder holder) { super.onViewRecycled(holder); glideRequests.clear(holder.thumbnail); } diff --git a/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java b/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java index 9ce6440866..7a6e668ad6 100644 --- a/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java +++ b/src/org/thoughtcrime/securesms/giph/ui/GiphyFragment.java @@ -41,7 +41,7 @@ public abstract class GiphyFragment extends Fragment implements LoaderManager.Lo protected String searchString; @Override - public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup viewGroup, Bundle bundle) { ViewGroup container = ViewUtil.inflate(inflater, viewGroup, R.layout.giphy_fragment); this.recyclerView = ViewUtil.findById(container, R.id.giphy_list); this.loadingProgress = ViewUtil.findById(container, R.id.loading_progress); @@ -66,7 +66,7 @@ public abstract class GiphyFragment extends Fragment implements LoaderManager.Lo } @Override - public void onLoadFinished(Loader> loader, @NonNull List data) { + public void onLoadFinished(@NonNull Loader> loader, @NonNull List data) { this.loadingProgress.setVisibility(View.GONE); if (data.isEmpty()) noResultsView.setVisibility(View.VISIBLE); @@ -76,7 +76,7 @@ public abstract class GiphyFragment extends Fragment implements LoaderManager.Lo } @Override - public void onLoaderReset(Loader> loader) { + public void onLoaderReset(@NonNull Loader> loader) { noResultsView.setVisibility(View.GONE); this.giphyAdapter.setImages(new LinkedList()); } diff --git a/src/org/thoughtcrime/securesms/giph/ui/GiphyGifFragment.java b/src/org/thoughtcrime/securesms/giph/ui/GiphyGifFragment.java index ea6b845972..d38007b4a9 100644 --- a/src/org/thoughtcrime/securesms/giph/ui/GiphyGifFragment.java +++ b/src/org/thoughtcrime/securesms/giph/ui/GiphyGifFragment.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.giph.ui; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.content.Loader; import org.thoughtcrime.securesms.giph.model.GiphyImage; @@ -12,7 +13,7 @@ import java.util.List; public class GiphyGifFragment extends GiphyFragment { @Override - public Loader> onCreateLoader(int id, Bundle args) { + public @NonNull Loader> onCreateLoader(int id, Bundle args) { return new GiphyGifLoader(getActivity(), searchString); } diff --git a/src/org/thoughtcrime/securesms/giph/ui/GiphyStickerFragment.java b/src/org/thoughtcrime/securesms/giph/ui/GiphyStickerFragment.java index 27a03b326b..1b0289155f 100644 --- a/src/org/thoughtcrime/securesms/giph/ui/GiphyStickerFragment.java +++ b/src/org/thoughtcrime/securesms/giph/ui/GiphyStickerFragment.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.giph.ui; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.content.Loader; import org.thoughtcrime.securesms.giph.model.GiphyImage; @@ -11,7 +12,7 @@ import java.util.List; public class GiphyStickerFragment extends GiphyFragment { @Override - public Loader> onCreateLoader(int id, Bundle args) { + public @NonNull Loader> onCreateLoader(int id, Bundle args) { return new GiphyStickerLoader(getActivity(), searchString); } } diff --git a/src/org/thoughtcrime/securesms/giph/util/InfiniteScrollListener.java b/src/org/thoughtcrime/securesms/giph/util/InfiniteScrollListener.java index ba82f7e0da..872fc28a61 100644 --- a/src/org/thoughtcrime/securesms/giph/util/InfiniteScrollListener.java +++ b/src/org/thoughtcrime/securesms/giph/util/InfiniteScrollListener.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.giph.util; +import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; public abstract class InfiniteScrollListener extends RecyclerView.OnScrollListener { @@ -17,7 +18,7 @@ public abstract class InfiniteScrollListener extends RecyclerView.OnScrollListen private int currentPage = 1; @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); RecyclerViewPositionHelper recyclerViewPositionHelper = RecyclerViewPositionHelper.createHelper(recyclerView); diff --git a/src/org/thoughtcrime/securesms/glide/ChunkedImageUrlLoader.java b/src/org/thoughtcrime/securesms/glide/ChunkedImageUrlLoader.java index 5ac02f33f6..af6fa8faa6 100644 --- a/src/org/thoughtcrime/securesms/glide/ChunkedImageUrlLoader.java +++ b/src/org/thoughtcrime/securesms/glide/ChunkedImageUrlLoader.java @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms.glide; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.bumptech.glide.load.Options; @@ -23,14 +24,13 @@ public class ChunkedImageUrlLoader implements ModelLoader buildLoadData(ChunkedImageUrl url, int width, int height, Options options) { + public @Nullable LoadData buildLoadData(@NonNull ChunkedImageUrl url, int width, int height, @NonNull Options options) { return new LoadData<>(url, new ChunkedImageUrlFetcher(client, url)); } @Override - public boolean handles(ChunkedImageUrl url) { + public boolean handles(@NonNull ChunkedImageUrl url) { return true; } @@ -48,7 +48,7 @@ public class ChunkedImageUrlLoader implements ModelLoader build(MultiModelLoaderFactory multiFactory) { + public @NonNull ModelLoader build(@NonNull MultiModelLoaderFactory multiFactory) { return new ChunkedImageUrlLoader(client); } diff --git a/src/org/thoughtcrime/securesms/glide/ContactPhotoFetcher.java b/src/org/thoughtcrime/securesms/glide/ContactPhotoFetcher.java index 29a5d1d674..e8d22713fc 100644 --- a/src/org/thoughtcrime/securesms/glide/ContactPhotoFetcher.java +++ b/src/org/thoughtcrime/securesms/glide/ContactPhotoFetcher.java @@ -26,7 +26,7 @@ class ContactPhotoFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { try { inputStream = contactPhoto.openInputStream(context); callback.onDataReady(inputStream); @@ -47,15 +47,13 @@ class ContactPhotoFetcher implements DataFetcher { } - @NonNull @Override - public Class getDataClass() { + public @NonNull Class getDataClass() { return InputStream.class; } - @NonNull @Override - public DataSource getDataSource() { + public @NonNull DataSource getDataSource() { return DataSource.LOCAL; } } diff --git a/src/org/thoughtcrime/securesms/glide/ContactPhotoLoader.java b/src/org/thoughtcrime/securesms/glide/ContactPhotoLoader.java index 5bdedf979d..fa18edb08e 100644 --- a/src/org/thoughtcrime/securesms/glide/ContactPhotoLoader.java +++ b/src/org/thoughtcrime/securesms/glide/ContactPhotoLoader.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.glide; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.bumptech.glide.load.Options; @@ -20,14 +21,13 @@ public class ContactPhotoLoader implements ModelLoader buildLoadData(ContactPhoto contactPhoto, int width, int height, Options options) { + public @Nullable LoadData buildLoadData(@NonNull ContactPhoto contactPhoto, int width, int height, @NonNull Options options) { return new LoadData<>(contactPhoto, new ContactPhotoFetcher(context, contactPhoto)); } @Override - public boolean handles(ContactPhoto contactPhoto) { + public boolean handles(@NonNull ContactPhoto contactPhoto) { return true; } @@ -40,7 +40,7 @@ public class ContactPhotoLoader implements ModelLoader build(MultiModelLoaderFactory multiFactory) { + public @NonNull ModelLoader build(@NonNull MultiModelLoaderFactory multiFactory) { return new ContactPhotoLoader(context); } diff --git a/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java b/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java index bd0c334b35..cf85ee1bb1 100644 --- a/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java +++ b/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java @@ -35,7 +35,7 @@ class OkHttpStreamFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { try { Request.Builder requestBuilder = new Request.Builder() .url(url.toStringUrl()); @@ -82,15 +82,13 @@ class OkHttpStreamFetcher implements DataFetcher { // TODO: call cancel on the client when this method is called on a background thread. See #257 } - @NonNull @Override - public Class getDataClass() { + public @NonNull Class getDataClass() { return InputStream.class; } - @NonNull @Override - public DataSource getDataSource() { + public @NonNull DataSource getDataSource() { return DataSource.REMOTE; } } \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/glide/OkHttpUrlLoader.java b/src/org/thoughtcrime/securesms/glide/OkHttpUrlLoader.java index a6f8fa9629..39637f76d8 100644 --- a/src/org/thoughtcrime/securesms/glide/OkHttpUrlLoader.java +++ b/src/org/thoughtcrime/securesms/glide/OkHttpUrlLoader.java @@ -1,5 +1,6 @@ package org.thoughtcrime.securesms.glide; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.bumptech.glide.load.Options; @@ -25,14 +26,13 @@ public class OkHttpUrlLoader implements ModelLoader { this.client = client; } - @Nullable @Override - public LoadData buildLoadData(GlideUrl glideUrl, int width, int height, Options options) { + public @Nullable LoadData buildLoadData(@NonNull GlideUrl glideUrl, int width, int height, @NonNull Options options) { return new LoadData<>(glideUrl, new OkHttpStreamFetcher(client, glideUrl)); } @Override - public boolean handles(GlideUrl glideUrl) { + public boolean handles(@NonNull GlideUrl glideUrl) { return true; } @@ -62,7 +62,7 @@ public class OkHttpUrlLoader implements ModelLoader { } @Override - public ModelLoader build(MultiModelLoaderFactory multiFactory) { + public @NonNull ModelLoader build(@NonNull MultiModelLoaderFactory multiFactory) { return new OkHttpUrlLoader(client); } diff --git a/src/org/thoughtcrime/securesms/glide/PaddedHeadersInterceptor.java b/src/org/thoughtcrime/securesms/glide/PaddedHeadersInterceptor.java index 03922b536e..e602935874 100644 --- a/src/org/thoughtcrime/securesms/glide/PaddedHeadersInterceptor.java +++ b/src/org/thoughtcrime/securesms/glide/PaddedHeadersInterceptor.java @@ -20,7 +20,7 @@ public class PaddedHeadersInterceptor implements Interceptor { private static final int MAX_RANDOM_BYTES = 64; @Override - public Response intercept(@NonNull Chain chain) throws IOException { + public @NonNull Response intercept(@NonNull Chain chain) throws IOException { Request padded = chain.request().newBuilder() .headers(getPaddedHeaders(chain.request().headers())) .build(); diff --git a/src/org/thoughtcrime/securesms/imageeditor/DrawingSession.java b/src/org/thoughtcrime/securesms/imageeditor/DrawingSession.java index 72dcaa27b3..05ef7ad22a 100644 --- a/src/org/thoughtcrime/securesms/imageeditor/DrawingSession.java +++ b/src/org/thoughtcrime/securesms/imageeditor/DrawingSession.java @@ -34,12 +34,12 @@ class DrawingSession extends ElementEditSession { } @Override - public EditSession newPoint(Matrix newInverse, PointF point, int p) { + public EditSession newPoint(@NonNull Matrix newInverse, @NonNull PointF point, int p) { return this; } @Override - public EditSession removePoint(Matrix newInverse, int p) { + public EditSession removePoint(@NonNull Matrix newInverse, int p) { return this; } } diff --git a/src/org/thoughtcrime/securesms/imageeditor/ElementDragEditSession.java b/src/org/thoughtcrime/securesms/imageeditor/ElementDragEditSession.java index 6f8e053563..27cbb0cdcb 100644 --- a/src/org/thoughtcrime/securesms/imageeditor/ElementDragEditSession.java +++ b/src/org/thoughtcrime/securesms/imageeditor/ElementDragEditSession.java @@ -31,7 +31,7 @@ final class ElementDragEditSession extends ElementEditSession { } @Override - public EditSession newPoint(@NonNull Matrix newInverse, PointF point, int p) { + public EditSession newPoint(@NonNull Matrix newInverse, @NonNull PointF point, int p) { return ElementScaleEditSession.startScale(this, newInverse, point, p); } diff --git a/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java b/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java index 6cda006c99..26b41c7f52 100644 --- a/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java @@ -145,7 +145,7 @@ public class AttachmentDownloadJob extends BaseJob implements InjectableType { } @Override - protected boolean onShouldRetry(Exception exception) { + protected boolean onShouldRetry(@NonNull Exception exception) { return (exception instanceof PushNetworkException); } diff --git a/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java b/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java index c9866c390a..c6adc50f8c 100644 --- a/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java @@ -95,7 +95,7 @@ public class AttachmentUploadJob extends BaseJob implements InjectableType { public void onCanceled() { } @Override - protected boolean onShouldRetry(Exception exception) { + protected boolean onShouldRetry(@NonNull Exception exception) { return exception instanceof PushNetworkException || exception instanceof SSLException || exception instanceof ConnectException; diff --git a/src/org/thoughtcrime/securesms/jobs/AvatarDownloadJob.java b/src/org/thoughtcrime/securesms/jobs/AvatarDownloadJob.java index 21ae4b3abe..b97a410dbd 100644 --- a/src/org/thoughtcrime/securesms/jobs/AvatarDownloadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/AvatarDownloadJob.java @@ -111,7 +111,7 @@ public class AvatarDownloadJob extends BaseJob implements InjectableType { public void onCanceled() {} @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof IOException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/CleanPreKeysJob.java b/src/org/thoughtcrime/securesms/jobs/CleanPreKeysJob.java index d239a9d7ce..464d6e6a25 100644 --- a/src/org/thoughtcrime/securesms/jobs/CleanPreKeysJob.java +++ b/src/org/thoughtcrime/securesms/jobs/CleanPreKeysJob.java @@ -97,7 +97,7 @@ public class CleanPreKeysJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception throwable) { + public boolean onShouldRetry(@NonNull Exception throwable) { if (throwable instanceof NonSuccessfulResponseCodeException) return false; if (throwable instanceof PushNetworkException) return true; return false; diff --git a/src/org/thoughtcrime/securesms/jobs/CreateSignedPreKeyJob.java b/src/org/thoughtcrime/securesms/jobs/CreateSignedPreKeyJob.java index cfb5a9fdf5..28a866611b 100644 --- a/src/org/thoughtcrime/securesms/jobs/CreateSignedPreKeyJob.java +++ b/src/org/thoughtcrime/securesms/jobs/CreateSignedPreKeyJob.java @@ -74,7 +74,7 @@ public class CreateSignedPreKeyJob extends BaseJob implements InjectableType { public void onCanceled() {} @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/DirectoryRefreshJob.java b/src/org/thoughtcrime/securesms/jobs/DirectoryRefreshJob.java index a7074187f3..5b367dd335 100644 --- a/src/org/thoughtcrime/securesms/jobs/DirectoryRefreshJob.java +++ b/src/org/thoughtcrime/securesms/jobs/DirectoryRefreshJob.java @@ -75,7 +75,7 @@ public class DirectoryRefreshJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/FcmRefreshJob.java b/src/org/thoughtcrime/securesms/jobs/FcmRefreshJob.java index 245a222ea4..458db590a2 100644 --- a/src/org/thoughtcrime/securesms/jobs/FcmRefreshJob.java +++ b/src/org/thoughtcrime/securesms/jobs/FcmRefreshJob.java @@ -119,7 +119,7 @@ public class FcmRefreshJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception throwable) { + public boolean onShouldRetry(@NonNull Exception throwable) { if (throwable instanceof NonSuccessfulResponseCodeException) return false; return true; } diff --git a/src/org/thoughtcrime/securesms/jobs/LocalBackupJob.java b/src/org/thoughtcrime/securesms/jobs/LocalBackupJob.java index 4fe6ecf613..0849d22875 100644 --- a/src/org/thoughtcrime/securesms/jobs/LocalBackupJob.java +++ b/src/org/thoughtcrime/securesms/jobs/LocalBackupJob.java @@ -102,7 +102,7 @@ public class LocalBackupJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java b/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java index e418d416a1..0d5f66bfda 100644 --- a/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java @@ -183,7 +183,7 @@ public class MmsDownloadJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MmsReceiveJob.java b/src/org/thoughtcrime/securesms/jobs/MmsReceiveJob.java index d445ba5683..5cda9e2151 100644 --- a/src/org/thoughtcrime/securesms/jobs/MmsReceiveJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MmsReceiveJob.java @@ -95,7 +95,7 @@ public class MmsReceiveJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MmsSendJob.java b/src/org/thoughtcrime/securesms/jobs/MmsSendJob.java index bacda8b029..d3112ef61c 100644 --- a/src/org/thoughtcrime/securesms/jobs/MmsSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MmsSendJob.java @@ -121,7 +121,7 @@ public class MmsSendJob extends SendJob { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceBlockedUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceBlockedUpdateJob.java index f575a63b7e..ce7e9c53e2 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceBlockedUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceBlockedUpdateJob.java @@ -90,7 +90,7 @@ public class MultiDeviceBlockedUpdateJob extends BaseJob implements InjectableTy } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceConfigurationUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceConfigurationUpdateJob.java index b960815578..d0da9d6bc9 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceConfigurationUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceConfigurationUpdateJob.java @@ -99,7 +99,7 @@ public class MultiDeviceConfigurationUpdateJob extends BaseJob implements Inject } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return e instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java index d39bd68254..c828485c5d 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceContactUpdateJob.java @@ -217,7 +217,7 @@ public class MultiDeviceContactUpdateJob extends BaseJob implements InjectableTy } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceGroupUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceGroupUpdateJob.java index 3611ef6c55..3476a6f034 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceGroupUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceGroupUpdateJob.java @@ -119,7 +119,7 @@ public class MultiDeviceGroupUpdateJob extends BaseJob implements InjectableType } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceProfileKeyUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceProfileKeyUpdateJob.java index 593479a2a0..fbee8fc3b8 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceProfileKeyUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceProfileKeyUpdateJob.java @@ -93,7 +93,7 @@ public class MultiDeviceProfileKeyUpdateJob extends BaseJob implements Injectabl } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceReadUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceReadUpdateJob.java index 82e269c899..ecf18ec362 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceReadUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceReadUpdateJob.java @@ -98,7 +98,7 @@ public class MultiDeviceReadUpdateJob extends BaseJob implements InjectableType } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return exception instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/MultiDeviceVerifiedUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/MultiDeviceVerifiedUpdateJob.java index a23fa062f3..8a498d02cd 100644 --- a/src/org/thoughtcrime/securesms/jobs/MultiDeviceVerifiedUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MultiDeviceVerifiedUpdateJob.java @@ -125,7 +125,7 @@ public class MultiDeviceVerifiedUpdateJob extends BaseJob implements InjectableT } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return exception instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/PushContentReceiveJob.java b/src/org/thoughtcrime/securesms/jobs/PushContentReceiveJob.java index 060f36c10c..79ad58f618 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushContentReceiveJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushContentReceiveJob.java @@ -36,7 +36,7 @@ public class PushContentReceiveJob extends PushReceivedJob { public void onCanceled() { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 2ac05bc40c..ee6b674373 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -180,7 +180,7 @@ public class PushDecryptJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index 6c2fa39fb2..1f8699fa26 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -212,7 +212,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof IOException) return true; if (exception instanceof RetryLaterException) return true; return false; diff --git a/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java index 4935e18010..b5615fed87 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java @@ -124,7 +124,7 @@ public class PushGroupUpdateJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { Log.w(TAG, e); return e instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java index e09de2e3a3..4e100e7e40 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java @@ -178,7 +178,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof RetryLaterException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java b/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java index fd1af3f614..dcc5c706c0 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java @@ -64,7 +64,7 @@ public class PushNotificationReceiveJob extends PushReceivedJob implements Injec } } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { Log.w(TAG, e); return e instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java index 55532af70a..1b4c7edf37 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java @@ -60,9 +60,8 @@ public class PushTextSendJob extends PushSendJob implements InjectableType { return new Data.Builder().putLong(KEY_MESSAGE_ID, messageId).build(); } - @NonNull @Override - public String getFactoryKey() { + public @NonNull String getFactoryKey() { return KEY; } @@ -134,7 +133,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof RetryLaterException) return true; return false; diff --git a/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java b/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java index 058960a8b0..9ed1639180 100644 --- a/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RefreshAttributesJob.java @@ -65,7 +65,7 @@ public class RefreshAttributesJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return e instanceof NetworkFailureException; } diff --git a/src/org/thoughtcrime/securesms/jobs/RefreshPreKeysJob.java b/src/org/thoughtcrime/securesms/jobs/RefreshPreKeysJob.java index 362942107c..76fb1e186d 100644 --- a/src/org/thoughtcrime/securesms/jobs/RefreshPreKeysJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RefreshPreKeysJob.java @@ -83,7 +83,7 @@ public class RefreshPreKeysJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { if (exception instanceof NonSuccessfulResponseCodeException) return false; if (exception instanceof PushNetworkException) return true; diff --git a/src/org/thoughtcrime/securesms/jobs/RefreshUnidentifiedDeliveryAbilityJob.java b/src/org/thoughtcrime/securesms/jobs/RefreshUnidentifiedDeliveryAbilityJob.java index b3977a07cb..1b6c87599a 100644 --- a/src/org/thoughtcrime/securesms/jobs/RefreshUnidentifiedDeliveryAbilityJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RefreshUnidentifiedDeliveryAbilityJob.java @@ -68,7 +68,7 @@ public class RefreshUnidentifiedDeliveryAbilityJob extends BaseJob implements In } @Override - protected boolean onShouldRetry(Exception exception) { + protected boolean onShouldRetry(@NonNull Exception exception) { return exception instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/RequestGroupInfoJob.java b/src/org/thoughtcrime/securesms/jobs/RequestGroupInfoJob.java index 31dd8b81f6..5db8442810 100644 --- a/src/org/thoughtcrime/securesms/jobs/RequestGroupInfoJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RequestGroupInfoJob.java @@ -85,7 +85,7 @@ public class RequestGroupInfoJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return e instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java b/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java index 443c11ea32..45f551d5aa 100644 --- a/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java @@ -112,7 +112,7 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { if (e instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.java b/src/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.java index c9d7dd3c3c..e7effa2eb5 100644 --- a/src/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RetrieveProfileJob.java @@ -86,7 +86,7 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java b/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java index 3a0270f806..66c94aab80 100644 --- a/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java @@ -47,7 +47,7 @@ public class RotateCertificateJob extends BaseJob implements InjectableType { } @Override - public String getFactoryKey() { + public @NonNull String getFactoryKey() { return KEY; } @@ -63,7 +63,7 @@ public class RotateCertificateJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return e instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/RotateProfileKeyJob.java b/src/org/thoughtcrime/securesms/jobs/RotateProfileKeyJob.java index 3124ad4d29..6f65e21077 100644 --- a/src/org/thoughtcrime/securesms/jobs/RotateProfileKeyJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RotateProfileKeyJob.java @@ -69,7 +69,7 @@ public class RotateProfileKeyJob extends BaseJob implements InjectableType { } @Override - protected boolean onShouldRetry(Exception exception) { + protected boolean onShouldRetry(@NonNull Exception exception) { return exception instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java b/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java index 9f1ccdb0fe..0d776b089b 100644 --- a/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java @@ -67,7 +67,7 @@ public class RotateSignedPreKeyJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return exception instanceof PushNetworkException; } diff --git a/src/org/thoughtcrime/securesms/jobs/SendDeliveryReceiptJob.java b/src/org/thoughtcrime/securesms/jobs/SendDeliveryReceiptJob.java index 0a0711f5b2..b008edb95e 100644 --- a/src/org/thoughtcrime/securesms/jobs/SendDeliveryReceiptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SendDeliveryReceiptJob.java @@ -89,7 +89,7 @@ public class SendDeliveryReceiptJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { if (e instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/SendReadReceiptJob.java b/src/org/thoughtcrime/securesms/jobs/SendReadReceiptJob.java index 8b3eeb19d0..da08f5aa1f 100644 --- a/src/org/thoughtcrime/securesms/jobs/SendReadReceiptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SendReadReceiptJob.java @@ -95,7 +95,7 @@ public class SendReadReceiptJob extends BaseJob implements InjectableType { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { if (e instanceof PushNetworkException) return true; return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/ServiceOutageDetectionJob.java b/src/org/thoughtcrime/securesms/jobs/ServiceOutageDetectionJob.java index 47dbd6a770..b5a0cad462 100644 --- a/src/org/thoughtcrime/securesms/jobs/ServiceOutageDetectionJob.java +++ b/src/org/thoughtcrime/securesms/jobs/ServiceOutageDetectionJob.java @@ -81,7 +81,7 @@ public class ServiceOutageDetectionJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return e instanceof RetryLaterException; } diff --git a/src/org/thoughtcrime/securesms/jobs/SmsReceiveJob.java b/src/org/thoughtcrime/securesms/jobs/SmsReceiveJob.java index fceeaae38e..69a6e5c12b 100644 --- a/src/org/thoughtcrime/securesms/jobs/SmsReceiveJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SmsReceiveJob.java @@ -94,7 +94,7 @@ public class SmsReceiveJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return exception instanceof MigrationPendingException; } diff --git a/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java b/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java index 0e49d60aa3..0f33579374 100644 --- a/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java @@ -93,7 +93,7 @@ public class SmsSendJob extends SendJob { } @Override - public boolean onShouldRetry(Exception throwable) { + public boolean onShouldRetry(@NonNull Exception throwable) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/SmsSentJob.java b/src/org/thoughtcrime/securesms/jobs/SmsSentJob.java index fa765b7c90..cadecd0b81 100644 --- a/src/org/thoughtcrime/securesms/jobs/SmsSentJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SmsSentJob.java @@ -78,7 +78,7 @@ public class SmsSentJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception throwable) { + public boolean onShouldRetry(@NonNull Exception throwable) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/TrimThreadJob.java b/src/org/thoughtcrime/securesms/jobs/TrimThreadJob.java index 818cbac632..95be3090b5 100644 --- a/src/org/thoughtcrime/securesms/jobs/TrimThreadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/TrimThreadJob.java @@ -65,7 +65,7 @@ public class TrimThreadJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception exception) { + public boolean onShouldRetry(@NonNull Exception exception) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/TypingSendJob.java b/src/org/thoughtcrime/securesms/jobs/TypingSendJob.java index 926fde25ef..51015297f7 100644 --- a/src/org/thoughtcrime/securesms/jobs/TypingSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/TypingSendJob.java @@ -104,7 +104,7 @@ public class TypingSendJob extends BaseJob implements InjectableType { } @Override - protected boolean onShouldRetry(Exception exception) { + protected boolean onShouldRetry(@NonNull Exception exception) { return false; } diff --git a/src/org/thoughtcrime/securesms/jobs/UpdateApkJob.java b/src/org/thoughtcrime/securesms/jobs/UpdateApkJob.java index e7d3561c80..6cc0f8066d 100644 --- a/src/org/thoughtcrime/securesms/jobs/UpdateApkJob.java +++ b/src/org/thoughtcrime/securesms/jobs/UpdateApkJob.java @@ -97,7 +97,7 @@ public class UpdateApkJob extends BaseJob { } @Override - public boolean onShouldRetry(Exception e) { + public boolean onShouldRetry(@NonNull Exception e) { return e instanceof IOException; } @@ -229,7 +229,7 @@ public class UpdateApkJob extends BaseJob { return url; } - public String toString() { + public @NonNull String toString() { return "[" + versionCode + ", " + versionName + ", " + url + "]"; } diff --git a/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java b/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java index bda1461a4b..a48a437f5b 100644 --- a/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java +++ b/src/org/thoughtcrime/securesms/linkpreview/LinkPreviewRepository.java @@ -95,13 +95,13 @@ public class LinkPreviewRepository { call.enqueue(new okhttp3.Callback() { @Override - public void onFailure(Call call, IOException e) { + public void onFailure(@NonNull Call call, @NonNull IOException e) { Log.w(TAG, "Request failed.", e); callback.onComplete(Metadata.empty()); } @Override - public void onResponse(Call call, Response response) throws IOException { + public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException { if (!response.isSuccessful()) { Log.w(TAG, "Non-successful response. Code: " + response.code()); callback.onComplete(Metadata.empty()); diff --git a/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java b/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java index 2d5ef85c36..b270fd95d0 100644 --- a/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java +++ b/src/org/thoughtcrime/securesms/lock/RegistrationLockDialog.java @@ -72,7 +72,7 @@ public class RegistrationLockDialog { ClickableSpan clickableSpan = new ClickableSpan() { @Override - public void onClick(View widget) { + public void onClick(@NonNull View widget) { dialog.dismiss(); new AlertDialog.Builder(context).setTitle(R.string.RegistrationLockDialog_forgotten_pin) .setMessage(R.string.RegistrationLockDialog_registration_lock_helps_protect_your_phone_number_from_unauthorized_registration_attempts) diff --git a/src/org/thoughtcrime/securesms/logsubmit/ShareIntentListAdapter.java b/src/org/thoughtcrime/securesms/logsubmit/ShareIntentListAdapter.java index 57fae1ad23..344c1cda8b 100644 --- a/src/org/thoughtcrime/securesms/logsubmit/ShareIntentListAdapter.java +++ b/src/org/thoughtcrime/securesms/logsubmit/ShareIntentListAdapter.java @@ -23,6 +23,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.ResolveInfo; +import android.support.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -49,7 +50,7 @@ public class ShareIntentListAdapter extends ArrayAdapter { } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.share_intent_row, parent, false); ImageView intentImage = (ImageView) rowView.findViewById(R.id.share_intent_image); diff --git a/src/org/thoughtcrime/securesms/logsubmit/SubmitLogFragment.java b/src/org/thoughtcrime/securesms/logsubmit/SubmitLogFragment.java index 77bc2da90c..97ae93d874 100644 --- a/src/org/thoughtcrime/securesms/logsubmit/SubmitLogFragment.java +++ b/src/org/thoughtcrime/securesms/logsubmit/SubmitLogFragment.java @@ -139,14 +139,14 @@ public class SubmitLogFragment extends Fragment { } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_submit_log, container, false); } @Override - public void onViewCreated(View view, Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); initializeResources(); } @@ -199,7 +199,7 @@ public class SubmitLogFragment extends Fragment { logPreview.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override - public void onScrolled(RecyclerView recyclerView, int dx, int dy) { + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { if (((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition() < logPreviewAdapter.getItemCount() - 10) { scrollButton.setVisibility(View.VISIBLE); } else { diff --git a/src/org/thoughtcrime/securesms/mediasend/Camera1Controller.java b/src/org/thoughtcrime/securesms/mediasend/Camera1Controller.java index ba6530e912..1bc0da102e 100644 --- a/src/org/thoughtcrime/securesms/mediasend/Camera1Controller.java +++ b/src/org/thoughtcrime/securesms/mediasend/Camera1Controller.java @@ -243,7 +243,7 @@ class Camera1Controller { } @Override - public String toString() { + public @NonNull String toString() { return "cameraCount: " + cameraCount + " previewWidth: " + previewWidth + " previewHeight: " + previewHeight; } } diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentStreamLocalUriFetcher.java b/src/org/thoughtcrime/securesms/mms/AttachmentStreamLocalUriFetcher.java index 8475761428..831c3ca5ed 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentStreamLocalUriFetcher.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentStreamLocalUriFetcher.java @@ -34,7 +34,7 @@ class AttachmentStreamLocalUriFetcher implements DataFetcher { } @Override - public void loadData(Priority priority, DataCallback callback) { + public void loadData(@NonNull Priority priority, @NonNull DataCallback callback) { try { if (!digest.isPresent()) throw new InvalidMessageException("No attachment digest!"); is = AttachmentCipherInputStream.createFor(attachment, plaintextLength, key, digest.get()); @@ -57,15 +57,13 @@ class AttachmentStreamLocalUriFetcher implements DataFetcher { @Override public void cancel() {} - @NonNull @Override - public Class getDataClass() { + public @NonNull Class getDataClass() { return InputStream.class; } - @NonNull @Override - public DataSource getDataSource() { + public @NonNull DataSource getDataSource() { return DataSource.LOCAL; } diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java b/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java index 4005936b35..d98c68c006 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentStreamUriLoader.java @@ -18,21 +18,20 @@ import java.security.MessageDigest; public class AttachmentStreamUriLoader implements ModelLoader { - @Nullable @Override - public LoadData buildLoadData(AttachmentModel attachmentModel, int width, int height, Options options) { + public @Nullable LoadData buildLoadData(@NonNull AttachmentModel attachmentModel, int width, int height, @NonNull Options options) { return new LoadData<>(attachmentModel, new AttachmentStreamLocalUriFetcher(attachmentModel.attachment, attachmentModel.plaintextLength, attachmentModel.key, attachmentModel.digest)); } @Override - public boolean handles(AttachmentModel attachmentModel) { + public boolean handles(@NonNull AttachmentModel attachmentModel) { return true; } static class Factory implements ModelLoaderFactory { @Override - public ModelLoader build(MultiModelLoaderFactory multiFactory) { + public @NonNull ModelLoader build(@NonNull MultiModelLoaderFactory multiFactory) { return new AttachmentStreamUriLoader(); } @@ -58,7 +57,7 @@ public class AttachmentStreamUriLoader implements ModelLoader onCreateLoader(int id, Bundle args) { + public @NonNull Loader onCreateLoader(int id, Bundle args) { return new StickerLoader(getActivity(), assetDirectory); } @Override - public void onLoadFinished(Loader loader, String[] data) { + public void onLoadFinished(@NonNull Loader loader, String[] data) { recyclerView.setAdapter(new StickersAdapter(getActivity(), glideRequests, data)); } @Override - public void onLoaderReset(Loader loader) { + public void onLoaderReset(@NonNull Loader loader) { recyclerView.setAdapter(null); } @@ -108,12 +107,12 @@ public class StickerSelectFragment extends Fragment implements LoaderManager.Loa } @Override - public StickerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public @NonNull StickerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { return new StickerViewHolder(layoutInflater.inflate(R.layout.scribble_sticker_item, parent, false)); } @Override - public void onBindViewHolder(StickerViewHolder holder, int position) { + public void onBindViewHolder(@NonNull StickerViewHolder holder, int position) { holder.fileName = stickerFiles[position]; glideRequests.load(Uri.parse("file:///android_asset/" + holder.fileName)) @@ -127,7 +126,7 @@ public class StickerSelectFragment extends Fragment implements LoaderManager.Loa } @Override - public void onViewRecycled(StickerViewHolder holder) { + public void onViewRecycled(@NonNull StickerViewHolder holder) { super.onViewRecycled(holder); glideRequests.clear(holder.image); } diff --git a/src/org/thoughtcrime/securesms/scribbles/widget/ColorPaletteAdapter.java b/src/org/thoughtcrime/securesms/scribbles/widget/ColorPaletteAdapter.java index 401a847f0f..509b5c1f91 100644 --- a/src/org/thoughtcrime/securesms/scribbles/widget/ColorPaletteAdapter.java +++ b/src/org/thoughtcrime/securesms/scribbles/widget/ColorPaletteAdapter.java @@ -22,12 +22,12 @@ public class ColorPaletteAdapter extends RecyclerView.Adapter implements Map { return values != null && values.contains(value); } - public void putAll(Map m) { + public void putAll(@NonNull Map m) { if (m == null || m.isEmpty()) { processQueue(); return; @@ -220,12 +222,12 @@ public class SoftHashMap implements Map { } } - public Set keySet() { + public @NonNull Set keySet() { processQueue(); return map.keySet(); } - public Collection values() { + public @NonNull Collection values() { processQueue(); Collection keys = map.keySet(); if (keys.isEmpty()) { @@ -245,7 +247,7 @@ public class SoftHashMap implements Map { /** * Creates a new entry, but wraps the value in a SoftValue instance to enable auto garbage collection. */ - public V put(K key, V value) { + public V put(@NonNull K key, @NonNull V value) { processQueue(); // throw out garbage collected values first SoftValue sv = new SoftValue(value, key, queue); SoftValue previous = map.put(key, sv); @@ -275,7 +277,7 @@ public class SoftHashMap implements Map { return map.size(); } - public Set> entrySet() { + public @NonNull Set> entrySet() { processQueue(); // throw out garbage collected values first Collection keys = map.keySet(); if (keys.isEmpty()) { diff --git a/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java b/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java index e0540b9d53..3370528256 100644 --- a/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java +++ b/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.util; import android.graphics.Canvas; import android.graphics.Rect; import android.os.Build.VERSION; +import android.support.annotation.NonNull; import android.support.v4.view.ViewCompat; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -42,8 +43,8 @@ public class StickyHeaderDecoration extends RecyclerView.ItemDecoration { * {@inheritDoc} */ @Override - public void getItemOffsets(Rect outRect, View view, RecyclerView parent, - RecyclerView.State state) + public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, + @NonNull RecyclerView.State state) { int position = parent.getChildAdapterPosition(view); int headerHeight = 0; @@ -106,7 +107,7 @@ public class StickyHeaderDecoration extends RecyclerView.ItemDecoration { * {@inheritDoc} */ @Override - public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { + public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { final int count = parent.getChildCount(); for (int layoutPos = 0; layoutPos < count; layoutPos++) { diff --git a/src/org/thoughtcrime/securesms/util/VerifySpan.java b/src/org/thoughtcrime/securesms/util/VerifySpan.java index 697ff24dd0..0df463de54 100644 --- a/src/org/thoughtcrime/securesms/util/VerifySpan.java +++ b/src/org/thoughtcrime/securesms/util/VerifySpan.java @@ -31,7 +31,7 @@ public class VerifySpan extends ClickableSpan { } @Override - public void onClick(View widget) { + public void onClick(@NonNull View widget) { Intent intent = new Intent(context, VerifyIdentityActivity.class); intent.putExtra(VerifyIdentityActivity.ADDRESS_EXTRA, address); intent.putExtra(VerifyIdentityActivity.IDENTITY_EXTRA, new IdentityKeyParcelable(identityKey)); diff --git a/src/org/thoughtcrime/securesms/util/spans/CenterAlignedRelativeSizeSpan.java b/src/org/thoughtcrime/securesms/util/spans/CenterAlignedRelativeSizeSpan.java index b15c96137d..62bd3874e3 100644 --- a/src/org/thoughtcrime/securesms/util/spans/CenterAlignedRelativeSizeSpan.java +++ b/src/org/thoughtcrime/securesms/util/spans/CenterAlignedRelativeSizeSpan.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.util.spans; +import android.support.annotation.NonNull; import android.text.TextPaint; import android.text.style.MetricAffectingSpan; @@ -13,7 +14,7 @@ public class CenterAlignedRelativeSizeSpan extends MetricAffectingSpan { } @Override - public void updateMeasureState(TextPaint p) { + public void updateMeasureState(@NonNull TextPaint p) { updateDrawState(p); } From 88dac700874fb10f0cd4bca60386a087b0487a3f Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Wed, 22 May 2019 14:02:21 -0300 Subject: [PATCH 07/22] Lint - Custom Widgets extend Appcompat Widgets. --- .../components/CircleColorImageView.java | 5 ++- .../securesms/components/ImageDivet.java | 8 ++--- .../components/RepeatableImageKey.java | 31 ++++--------------- .../securesms/components/SendButton.java | 4 +-- .../securesms/components/SquareImageView.java | 12 ++----- .../components/emoji/EmojiToggle.java | 5 ++- .../giph/ui/AspectRatioImageView.java | 5 ++- 7 files changed, 19 insertions(+), 51 deletions(-) diff --git a/src/org/thoughtcrime/securesms/components/CircleColorImageView.java b/src/org/thoughtcrime/securesms/components/CircleColorImageView.java index 179c80aec4..1bb04a48bf 100644 --- a/src/org/thoughtcrime/securesms/components/CircleColorImageView.java +++ b/src/org/thoughtcrime/securesms/components/CircleColorImageView.java @@ -3,15 +3,14 @@ package org.thoughtcrime.securesms.components; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; -import android.graphics.ColorFilter; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; +import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; -import android.widget.ImageView; import org.thoughtcrime.securesms.R; -public class CircleColorImageView extends ImageView { +public class CircleColorImageView extends AppCompatImageView { public CircleColorImageView(Context context) { this(context, null); diff --git a/src/org/thoughtcrime/securesms/components/ImageDivet.java b/src/org/thoughtcrime/securesms/components/ImageDivet.java index 770226b835..51f615989f 100644 --- a/src/org/thoughtcrime/securesms/components/ImageDivet.java +++ b/src/org/thoughtcrime/securesms/components/ImageDivet.java @@ -4,12 +4,12 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.drawable.Drawable; +import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; -import android.widget.ImageView; import org.thoughtcrime.securesms.R; -public class ImageDivet extends ImageView { +public class ImageDivet extends AppCompatImageView { private static final float CORNER_OFFSET = 12F; private static final String[] POSITIONS = new String[] {"bottom_right"}; @@ -84,10 +84,6 @@ public class ImageDivet extends ImageView { return CORNER_OFFSET * density; } - public ImageView asImageView() { - return this; - } - public float getFarOffset() { return getCloseOffset() + drawableIntrinsicHeight; } diff --git a/src/org/thoughtcrime/securesms/components/RepeatableImageKey.java b/src/org/thoughtcrime/securesms/components/RepeatableImageKey.java index 602db3d9f9..5cf63cfe73 100644 --- a/src/org/thoughtcrime/securesms/components/RepeatableImageKey.java +++ b/src/org/thoughtcrime/securesms/components/RepeatableImageKey.java @@ -1,19 +1,14 @@ package org.thoughtcrime.securesms.components; -import android.annotation.TargetApi; import android.content.Context; -import android.os.Build.VERSION; -import android.os.Build.VERSION_CODES; +import android.support.v7.widget.AppCompatImageButton; import android.util.AttributeSet; import android.view.HapticFeedbackConstants; -import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; -import android.widget.EditText; -import android.widget.ImageButton; -public class RepeatableImageKey extends ImageButton { +public class RepeatableImageKey extends AppCompatImageButton { private KeyEventListener listener; @@ -32,14 +27,6 @@ public class RepeatableImageKey extends ImageButton { init(); } - @TargetApi(VERSION_CODES.LOLLIPOP) - public RepeatableImageKey(Context context, AttributeSet attrs, int defStyleAttr, - int defStyleRes) - { - super(context, attrs, defStyleAttr, defStyleRes); - init(); - } - private void init() { setOnClickListener(new RepeaterClickListener()); setOnTouchListener(new RepeaterTouchListener()); @@ -60,31 +47,25 @@ public class RepeatableImageKey extends ImageButton { } private class Repeater implements Runnable { - @TargetApi(VERSION_CODES.HONEYCOMB_MR1) @Override public void run() { notifyListener(); - postDelayed(this, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1 - ? ViewConfiguration.getKeyRepeatDelay() - : 50); + postDelayed(this, ViewConfiguration.getKeyRepeatDelay()); } } private class RepeaterTouchListener implements OnTouchListener { - private Repeater repeater; + private final Repeater repeater; - public RepeaterTouchListener() { + RepeaterTouchListener() { this.repeater = new Repeater(); } - @TargetApi(VERSION_CODES.HONEYCOMB_MR1) @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: - view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1 - ? ViewConfiguration.getKeyRepeatTimeout() - : ViewConfiguration.getLongPressTimeout()); + view.postDelayed(repeater, ViewConfiguration.getKeyRepeatTimeout()); performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); return false; case MotionEvent.ACTION_CANCEL: diff --git a/src/org/thoughtcrime/securesms/components/SendButton.java b/src/org/thoughtcrime/securesms/components/SendButton.java index 7d15791899..476b99fa59 100644 --- a/src/org/thoughtcrime/securesms/components/SendButton.java +++ b/src/org/thoughtcrime/securesms/components/SendButton.java @@ -2,9 +2,9 @@ package org.thoughtcrime.securesms.components; import android.content.Context; import android.support.annotation.NonNull; +import android.support.v7.widget.AppCompatImageButton; import android.util.AttributeSet; import android.view.View; -import android.widget.ImageButton; import org.thoughtcrime.securesms.TransportOption; import org.thoughtcrime.securesms.TransportOptions; @@ -13,7 +13,7 @@ import org.thoughtcrime.securesms.TransportOptionsPopup; import org.thoughtcrime.securesms.util.ViewUtil; import org.whispersystems.libsignal.util.guava.Optional; -public class SendButton extends ImageButton +public class SendButton extends AppCompatImageButton implements TransportOptions.OnTransportChangedListener, TransportOptionsPopup.SelectedListener, View.OnLongClickListener diff --git a/src/org/thoughtcrime/securesms/components/SquareImageView.java b/src/org/thoughtcrime/securesms/components/SquareImageView.java index 57ba997203..997349d699 100644 --- a/src/org/thoughtcrime/securesms/components/SquareImageView.java +++ b/src/org/thoughtcrime/securesms/components/SquareImageView.java @@ -1,12 +1,10 @@ package org.thoughtcrime.securesms.components; -import android.annotation.TargetApi; import android.content.Context; -import android.os.Build; +import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; -import android.widget.ImageView; -public class SquareImageView extends ImageView { +public class SquareImageView extends AppCompatImageView { public SquareImageView(Context context) { super(context); } @@ -19,13 +17,9 @@ public class SquareImageView extends ImageView { super(context, attrs, defStyleAttr); } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - } - @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + //noinspection SuspiciousNameCombination super.onMeasure(widthMeasureSpec, widthMeasureSpec); } } diff --git a/src/org/thoughtcrime/securesms/components/emoji/EmojiToggle.java b/src/org/thoughtcrime/securesms/components/emoji/EmojiToggle.java index 5ffeb9b8ac..d0db467a39 100644 --- a/src/org/thoughtcrime/securesms/components/emoji/EmojiToggle.java +++ b/src/org/thoughtcrime/securesms/components/emoji/EmojiToggle.java @@ -1,16 +1,15 @@ package org.thoughtcrime.securesms.components.emoji; - import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; +import android.support.v7.widget.AppCompatImageButton; import android.util.AttributeSet; -import android.widget.ImageButton; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.components.emoji.EmojiDrawer.EmojiDrawerListener; -public class EmojiToggle extends ImageButton implements EmojiDrawerListener { +public class EmojiToggle extends AppCompatImageButton implements EmojiDrawerListener { private Drawable emojiToggle; private Drawable imeToggle; diff --git a/src/org/thoughtcrime/securesms/giph/ui/AspectRatioImageView.java b/src/org/thoughtcrime/securesms/giph/ui/AspectRatioImageView.java index a1ce36e23d..3a7c746821 100644 --- a/src/org/thoughtcrime/securesms/giph/ui/AspectRatioImageView.java +++ b/src/org/thoughtcrime/securesms/giph/ui/AspectRatioImageView.java @@ -18,15 +18,14 @@ package org.thoughtcrime.securesms.giph.ui; import android.content.Context; +import android.support.v7.widget.AppCompatImageView; import android.util.AttributeSet; -import android.widget.ImageView; - /** * AspectRatioImageView maintains an aspect ratio by adjusting the width or height dimension. The * aspect ratio (width to height ratio) and adjustment dimension can be configured. */ -public class AspectRatioImageView extends ImageView { +public class AspectRatioImageView extends AppCompatImageView { private static final float DEFAULT_ASPECT_RATIO = 1.0f; private static final int DEFAULT_ADJUST_DIMENSION = 0; From 3cba8ab58a60d164ef68dafa0fc8c4a0c0365a27 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Wed, 22 May 2019 16:59:00 -0300 Subject: [PATCH 08/22] Keep system default SIM as a fallback for when no conversation default SIM. Fixes #8452 --- .../securesms/TransportOptions.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/org/thoughtcrime/securesms/TransportOptions.java b/src/org/thoughtcrime/securesms/TransportOptions.java index 889e8dea73..e835f4604b 100644 --- a/src/org/thoughtcrime/securesms/TransportOptions.java +++ b/src/org/thoughtcrime/securesms/TransportOptions.java @@ -34,10 +34,12 @@ public class TransportOptions { private Optional defaultSubscriptionId = Optional.absent(); private Optional selectedOption = Optional.absent(); + private final Optional systemSubscriptionId; + public TransportOptions(Context context, boolean media) { - this.context = context; - this.enabledTransports = initializeAvailableTransports(media); - this.defaultSubscriptionId = new SubscriptionManagerCompat(context).getPreferredSubscriptionId(); + this.context = context; + this.enabledTransports = initializeAvailableTransports(media); + this.systemSubscriptionId = new SubscriptionManagerCompat(context).getPreferredSubscriptionId(); } public void reset(boolean media) { @@ -88,13 +90,10 @@ public class TransportOptions { public @NonNull TransportOption getSelectedTransport() { if (selectedOption.isPresent()) return selectedOption.get(); - if (defaultSubscriptionId.isPresent()) { - for (TransportOption transportOption : enabledTransports) { - if (transportOption.getType() == defaultTransportType && - (int)defaultSubscriptionId.get() == transportOption.getSimSubscriptionId().or(-1)) - { - return transportOption; - } + if (defaultTransportType == Type.SMS) { + TransportOption transportOption = findEnabledSmsTransportOption(defaultSubscriptionId.or(systemSubscriptionId)); + if (transportOption != null) { + return transportOption; } } @@ -107,6 +106,20 @@ public class TransportOptions { throw new AssertionError("No options of default type!"); } + private @Nullable TransportOption findEnabledSmsTransportOption(Optional subscriptionId) { + if (subscriptionId.isPresent()) { + final int subId = subscriptionId.get(); + + for (TransportOption transportOption : enabledTransports) { + if (transportOption.getType() == Type.SMS && + subId == transportOption.getSimSubscriptionId().or(-1)) { + return transportOption; + } + } + } + return null; + } + public void disableTransport(Type type) { TransportOption selected = selectedOption.orNull(); From 56848fb83da1086374ee0cfca47e620c5056434f Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Thu, 23 May 2019 08:02:15 -0300 Subject: [PATCH 09/22] Replace sgnl.link urls with a more readable url. * Taken out random string, reverted to single "Let's switch". #8767 --- res/values/strings.xml | 4 +++- src/org/thoughtcrime/securesms/InviteActivity.java | 2 +- .../contactshare/SharedContactDetailsActivity.java | 2 +- .../securesms/conversation/ConversationActivity.java | 7 +------ .../securesms/conversation/ConversationFragment.java | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 19dc61e607..72d294034c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,6 +1,9 @@ Signal + + https://signal.org/install + Yes No Delete @@ -158,7 +161,6 @@ Insecure MMS Signal Let\'s switch to Signal %1$s - Let\'s use this to chat: %1$s Error leaving group Please choose a contact Unblock this contact? diff --git a/src/org/thoughtcrime/securesms/InviteActivity.java b/src/org/thoughtcrime/securesms/InviteActivity.java index 74a5478f4d..411fbc337f 100644 --- a/src/org/thoughtcrime/securesms/InviteActivity.java +++ b/src/org/thoughtcrime/securesms/InviteActivity.java @@ -76,7 +76,7 @@ public class InviteActivity extends PassphraseRequiredActionBarActivity implemen heart = ViewUtil.findById(this, R.id.heart); contactsFragment = (ContactSelectionListFragment)getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment); - inviteText.setText(getString(R.string.InviteActivity_lets_switch_to_signal, "https://sgnl.link/1KpeYmF")); + inviteText.setText(getString(R.string.InviteActivity_lets_switch_to_signal, getString(R.string.install_url))); updateSmsButtonText(); if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { diff --git a/src/org/thoughtcrime/securesms/contactshare/SharedContactDetailsActivity.java b/src/org/thoughtcrime/securesms/contactshare/SharedContactDetailsActivity.java index 178364a757..80f0024ddf 100644 --- a/src/org/thoughtcrime/securesms/contactshare/SharedContactDetailsActivity.java +++ b/src/org/thoughtcrime/securesms/contactshare/SharedContactDetailsActivity.java @@ -230,7 +230,7 @@ public class SharedContactDetailsActivity extends PassphraseRequiredActionBarAct inviteButtonView.setOnClickListener(v -> { ContactUtil.selectRecipientThroughDialog(this, systemUsers, dynamicLanguage.getCurrentLocale(), recipient -> { - CommunicationActions.composeSmsThroughDefaultApp(this, recipient.getAddress(), getString(R.string.InviteActivity_lets_switch_to_signal, "https://sgnl.link/1KpeYmF")); + CommunicationActions.composeSmsThroughDefaultApp(this, recipient.getAddress(), getString(R.string.InviteActivity_lets_switch_to_signal, getString(R.string.install_url))); }); }); } else { diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index bc8a4fc74f..465bc7ec9f 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -210,7 +210,6 @@ import org.whispersystems.libsignal.InvalidMessageException; import org.whispersystems.libsignal.util.guava.Optional; import java.io.IOException; -import java.security.SecureRandom; import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Date; @@ -874,11 +873,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } private void handleInviteLink() { - String inviteText; - - boolean a = new SecureRandom().nextBoolean(); - if (a) inviteText = getString(R.string.ConversationActivity_lets_switch_to_signal, "https://sgnl.link/1LoIMUl"); - else inviteText = getString(R.string.ConversationActivity_lets_use_this_to_chat, "https://sgnl.link/1MF56H1"); + String inviteText = getString(R.string.ConversationActivity_lets_switch_to_signal, getString(R.string.install_url)); if (isDefaultSms) { composeText.appendInvite(inviteText); diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java index 377bfc6a50..9b33b93d6c 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -980,7 +980,7 @@ public class ConversationFragment extends Fragment if (getContext() == null) return; ContactUtil.selectRecipientThroughDialog(getContext(), choices, locale, recipient -> { - CommunicationActions.composeSmsThroughDefaultApp(getContext(), recipient.getAddress(), getString(R.string.InviteActivity_lets_switch_to_signal, "https://sgnl.link/1KpeYmF")); + CommunicationActions.composeSmsThroughDefaultApp(getContext(), recipient.getAddress(), getString(R.string.InviteActivity_lets_switch_to_signal, getString(R.string.install_url))); }); } } From 156fe37a60c91b021242bc59ae5e2ec0c18028ec Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Thu, 23 May 2019 11:38:24 -0300 Subject: [PATCH 10/22] Get SubscriptionManager by name due to ContextCompat bug for API 22. Fixes #8826 --- src/org/thoughtcrime/securesms/util/ServiceUtil.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/util/ServiceUtil.java b/src/org/thoughtcrime/securesms/util/ServiceUtil.java index 8cb1111c6d..348df1fd61 100644 --- a/src/org/thoughtcrime/securesms/util/ServiceUtil.java +++ b/src/org/thoughtcrime/securesms/util/ServiceUtil.java @@ -12,7 +12,6 @@ import android.os.Vibrator; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RequiresApi; -import android.support.v4.content.ContextCompat; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.view.WindowManager; @@ -57,6 +56,6 @@ public class ServiceUtil { @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1) public static @Nullable SubscriptionManager getSubscriptionManager(@NonNull Context context) { - return ContextCompat.getSystemService(context, SubscriptionManager.class); + return (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); } } From e5f70bdbda10e34632aa4185ab37fa80080c08c4 Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Thu, 23 May 2019 16:56:05 -0300 Subject: [PATCH 11/22] End RTC call on incoming PSTN call. * Hangs up when new device call is answered. * Ensure not on a device call when starting a Signal call. --- res/values/strings.xml | 1 + .../securesms/service/WebRtcCallService.java | 39 ++++++++++++++++--- .../securesms/util/CommunicationActions.java | 8 ++++ .../securesms/util/TelephonyUtil.java | 6 +++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 72d294034c..a363709fb8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -94,6 +94,7 @@ No web browser found. + A cellular call is already in progress. Your safety number with %1$s has changed. This could either mean that someone is trying to intercept your communication, or that %2$s simply reinstalled Signal. diff --git a/src/org/thoughtcrime/securesms/service/WebRtcCallService.java b/src/org/thoughtcrime/securesms/service/WebRtcCallService.java index be20047e97..96800516ae 100644 --- a/src/org/thoughtcrime/securesms/service/WebRtcCallService.java +++ b/src/org/thoughtcrime/securesms/service/WebRtcCallService.java @@ -18,8 +18,8 @@ import android.os.ResultReceiver; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; +import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; -import org.thoughtcrime.securesms.logging.Log; import android.util.Pair; import com.google.protobuf.InvalidProtocolBufferException; @@ -34,12 +34,14 @@ import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState; import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.events.WebRtcViewModel; +import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.notifications.MessageNotifier; import org.thoughtcrime.securesms.permissions.Permissions; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.util.FutureTaskListener; import org.thoughtcrime.securesms.util.ListenableFutureTask; import org.thoughtcrime.securesms.util.ServiceUtil; +import org.thoughtcrime.securesms.util.TelephonyUtil; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.Util; import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder; @@ -90,12 +92,10 @@ import org.whispersystems.signalservice.internal.util.concurrent.SettableFuture; import java.io.IOException; import java.nio.ByteBuffer; -import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.LinkedList; import java.util.List; import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -192,15 +192,21 @@ public class WebRtcCallService extends Service implements InjectableType, private ExecutorService networkExecutor = Executors.newSingleThreadExecutor(); private ScheduledExecutorService timeoutExecutor = Executors.newScheduledThreadPool(1); + private final PhoneStateListener hangUpRtcOnDeviceCallAnswered = new HangUpRtcOnPstnCallAnsweredListener(); + @Override public void onCreate() { super.onCreate(); + Log.d(TAG, "onCreate"); initializeResources(); registerIncomingPstnCallReceiver(); registerUncaughtExceptionHandler(); registerWiredHeadsetStateReceiver(); + + TelephonyUtil.getManager(this) + .listen(hangUpRtcOnDeviceCallAnswered, PhoneStateListener.LISTEN_CALL_STATE); } @Override @@ -239,6 +245,7 @@ public class WebRtcCallService extends Service implements InjectableType, @Override public void onDestroy() { super.onDestroy(); + Log.d(TAG, "onDestroy"); if (callReceiver != null) { unregisterReceiver(callReceiver); @@ -261,6 +268,9 @@ public class WebRtcCallService extends Service implements InjectableType, unregisterReceiver(powerButtonReceiver); powerButtonReceiver = null; } + + TelephonyUtil.getManager(this) + .listen(hangUpRtcOnDeviceCallAnswered, PhoneStateListener.LISTEN_NONE); } @Override @@ -901,9 +911,7 @@ public class WebRtcCallService extends Service implements InjectableType, /// Helper Methods private boolean isBusy() { - TelephonyManager telephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); - - return callState != CallState.STATE_IDLE || telephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE; + return callState != CallState.STATE_IDLE || TelephonyUtil.isAnyPstnLineBusy(this); } private boolean isIdle() { @@ -1381,4 +1389,23 @@ public class WebRtcCallService extends Service implements InjectableType, context.startService(intent); } + + private class HangUpRtcOnPstnCallAnsweredListener extends PhoneStateListener { + + @Override + public void onCallStateChanged(int state, String phoneNumber) { + super.onCallStateChanged(state, phoneNumber); + if (state == TelephonyManager.CALL_STATE_OFFHOOK) { + hangup(); + Log.i(TAG, "Device phone call ended Signal call."); + } + } + + private void hangup() { + Intent intent = new Intent(WebRtcCallService.this, WebRtcCallService.class); + intent.setAction(ACTION_LOCAL_HANGUP); + + startService(intent); + } + } } diff --git a/src/org/thoughtcrime/securesms/util/CommunicationActions.java b/src/org/thoughtcrime/securesms/util/CommunicationActions.java index 20dad6ae61..1df299cefa 100644 --- a/src/org/thoughtcrime/securesms/util/CommunicationActions.java +++ b/src/org/thoughtcrime/securesms/util/CommunicationActions.java @@ -25,6 +25,14 @@ import org.thoughtcrime.securesms.service.WebRtcCallService; public class CommunicationActions { public static void startVoiceCall(@NonNull Activity activity, @NonNull Recipient recipient) { + if (TelephonyUtil.isAnyPstnLineBusy(activity)) { + Toast.makeText(activity, + R.string.CommunicationActions_a_cellular_call_is_already_in_progress, + Toast.LENGTH_SHORT + ).show(); + return; + } + Permissions.with(activity) .request(Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA) .ifNecessary() diff --git a/src/org/thoughtcrime/securesms/util/TelephonyUtil.java b/src/org/thoughtcrime/securesms/util/TelephonyUtil.java index 949ef46ca5..3609cc7c7c 100644 --- a/src/org/thoughtcrime/securesms/util/TelephonyUtil.java +++ b/src/org/thoughtcrime/securesms/util/TelephonyUtil.java @@ -3,7 +3,9 @@ package org.thoughtcrime.securesms.util; import android.content.Context; import android.content.res.Configuration; import android.net.ConnectivityManager; +import android.support.annotation.NonNull; import android.telephony.TelephonyManager; + import org.thoughtcrime.securesms.logging.Log; import java.util.Locale; @@ -39,4 +41,8 @@ public class TelephonyUtil { final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS).getExtraInfo(); } + + public static boolean isAnyPstnLineBusy(@NonNull Context context) { + return getManager(context).getCallState() != TelephonyManager.CALL_STATE_IDLE; + } } From dae0d30367350b69f295e33729111cb9a636adec Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Thu, 23 May 2019 16:21:09 -0300 Subject: [PATCH 12/22] Do not show contact address in subtitle. --- .../conversation/ConversationTitleView.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationTitleView.java b/src/org/thoughtcrime/securesms/conversation/ConversationTitleView.java index 4e88960e5f..2950b97d09 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationTitleView.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationTitleView.java @@ -144,10 +144,14 @@ public class ConversationTitleView extends RelativeLayout { private void setContactRecipientTitle(Recipient recipient) { this.title.setText(recipient.getName()); - if (recipient.getCustomLabel() != null) this.subtitle.setText(recipient.getCustomLabel()); - else this.subtitle.setText(recipient.getAddress().serialize()); - - this.subtitle.setVisibility(View.VISIBLE); - this.subtitleContainer.setVisibility(VISIBLE); + if (TextUtils.isEmpty(recipient.getCustomLabel())) { + this.subtitle.setText(null); + this.subtitle.setVisibility(View.GONE); + this.subtitleContainer.setVisibility(View.GONE); + } else { + this.subtitle.setText(recipient.getCustomLabel()); + this.subtitle.setVisibility(View.VISIBLE); + this.subtitleContainer.setVisibility(View.VISIBLE); + } } } From 2ae42cb095c4b61e462ddf80522020f661f4d05e Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Fri, 24 May 2019 14:29:25 -0300 Subject: [PATCH 13/22] Hide local video when toggled on and off. Fixes #8827 --- .../securesms/components/webrtc/WebRtcCallScreen.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java index 9bbc3c7215..81416b6614 100644 --- a/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java +++ b/src/org/thoughtcrime/securesms/components/webrtc/WebRtcCallScreen.java @@ -203,6 +203,7 @@ public class WebRtcCallScreen extends FrameLayout implements RecipientModifiedLi if (this.localRenderLayout.isHidden() == cameraState.isEnabled()) { this.localRenderLayout.setHidden(!cameraState.isEnabled()); this.localRenderLayout.requestLayout(); + this.localRenderer.setVisibility(cameraState.isEnabled() ? VISIBLE : INVISIBLE); } } From 350d1f47d3405f490c66d98da33071c06aae566f Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Fri, 24 May 2019 14:31:48 -0300 Subject: [PATCH 14/22] Give conversation a standard navigate up button. * Prevent a failing IDE preview. --- res/layout/conversation_activity.xml | 194 ++++++++++-------- res/layout/conversation_title_view.xml | 16 +- .../conversation/ConversationActivity.java | 24 +-- .../conversation/ConversationTitleView.java | 6 - .../securesms/util/ThemeUtil.java | 9 +- 5 files changed, 127 insertions(+), 122 deletions(-) diff --git a/res/layout/conversation_activity.xml b/res/layout/conversation_activity.xml index 4672c46636..7ee9106ffc 100644 --- a/res/layout/conversation_activity.xml +++ b/res/layout/conversation_activity.xml @@ -1,108 +1,130 @@ - - - + android:layout_height="?attr/actionBarSize" + android:theme="@style/TextSecure.LightActionBar" + app:contentInsetStartWithNavigation="0dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:navigationIcon="?homeAsUpIndicator" + tools:background="#ff007f00"> - + - + - + - - - - - + android:clipToPadding="false" + android:gravity="bottom" + android:orientation="vertical" + android:paddingTop="?attr/actionBarSize"> - + - + - + -