diff --git a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java index 63643fd0b..412d03897 100644 --- a/src/org/thoughtcrime/securesms/BaseActionBarActivity.java +++ b/src/org/thoughtcrime/securesms/BaseActionBarActivity.java @@ -145,12 +145,6 @@ public abstract class BaseActionBarActivity extends AppCompatActivity { } } - protected void startActivitySceneTransition(Intent intent, View sharedView, String transitionName) { - Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(this, sharedView, transitionName) - .toBundle(); - ActivityCompat.startActivity(this, intent, bundle); - } - @Override public void startActivityForResult(Intent intent, int requestCode) { super.startActivityForResult(intent, requestCode); diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index ead2a002e..c7df93160 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -1005,14 +1005,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity return dcChat.getVisibility() == DcChat.DC_CHAT_VISIBILITY_ARCHIVED; } - protected Recipient getRecipient() { - return this.recipient; - } - - protected long getChatId() { - return this.chatId; - } - private MediaConstraints getCurrentMediaConstraints() { return MediaConstraints.getPushMediaConstraints(); } @@ -1458,11 +1450,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity public void onFocusChange(View v, boolean hasFocus) {} } - @Override - public void setChatId(int chatId) { - this.chatId = chatId; - } - @Override public void handleReplyMessage(DcMsg messageRecord) { } diff --git a/src/org/thoughtcrime/securesms/ConversationAdapter.java b/src/org/thoughtcrime/securesms/ConversationAdapter.java index 13be84d26..9a628269a 100644 --- a/src/org/thoughtcrime/securesms/ConversationAdapter.java +++ b/src/org/thoughtcrime/securesms/ConversationAdapter.java @@ -115,17 +115,10 @@ public class ConversationAdapter return dcMsgList.length > 0; } - public boolean isGroupChat(){ - return dcChat.isGroup(); - } - public @NonNull DcChat getChat(){ return dcChat; } - public String getChatName(){ - return dcChat.getName(); - } public void setLastSeen(long timestamp) { lastSeen = timestamp; diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index 83a181581..635a54e75 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -534,7 +534,6 @@ public class ConversationFragment extends Fragment } public interface ConversationFragmentListener { - void setChatId(int threadId); void handleReplyMessage(DcMsg messageRecord); } diff --git a/src/org/thoughtcrime/securesms/ConversationItem.java b/src/org/thoughtcrime/securesms/ConversationItem.java index 7a4cb7ebc..cfb53a9f2 100644 --- a/src/org/thoughtcrime/securesms/ConversationItem.java +++ b/src/org/thoughtcrime/securesms/ConversationItem.java @@ -204,44 +204,6 @@ public class ConversationItem extends LinearLayout if (isInEditMode()) { return; } - - //boolean needsMeasure = false; - - /* - ConversationItemFooter activeFooter = getActiveFooter(messageRecord); - int availableWidth = getAvailableMessageBubbleWidth(footer); - - if (activeFooter.getVisibility() != GONE && activeFooter.getMeasuredWidth() != availableWidth) { - activeFooter.getLayoutParams().width = availableWidth; - needsMeasure = true; - } - - if (needsMeasure) { - if (measureCalls < MAX_MEASURE_CALLS) { - measureCalls++; - measure(widthMeasureSpec, heightMeasureSpec); - } else { - Log.w(TAG, "Hit measure() cap of " + MAX_MEASURE_CALLS); - } - } else { - measureCalls = 0; - } - */ - } - - private int getAvailableMessageBubbleWidth(@NonNull View forView) { - int availableWidth; - if (hasAudio(messageRecord)) { - availableWidth = audioViewStub.get().getMeasuredWidth() + ViewUtil.getLeftMargin(audioViewStub.get()) + ViewUtil.getRightMargin(audioViewStub.get()); - } else if (hasThumbnail(messageRecord)) { - availableWidth = mediaThumbnailStub.get().getMeasuredWidth(); - } else { - availableWidth = bodyBubble.getMeasuredWidth() - bodyBubble.getPaddingLeft() - bodyBubble.getPaddingRight(); - } - - availableWidth -= ViewUtil.getLeftMargin(forView) + ViewUtil.getRightMargin(forView); - - return availableWidth; } private void initializeAttributes() { diff --git a/src/org/thoughtcrime/securesms/components/reminder/ReminderView.java b/src/org/thoughtcrime/securesms/components/reminder/ReminderView.java index 18e29b374..f7d331b64 100644 --- a/src/org/thoughtcrime/securesms/components/reminder/ReminderView.java +++ b/src/org/thoughtcrime/securesms/components/reminder/ReminderView.java @@ -80,10 +80,6 @@ public class ReminderView extends LinearLayout { this.dismissListener = dismissListener; } - public void requestDismiss() { - closeButton.performClick(); - } - public void hide() { container.setVisibility(View.GONE); } diff --git a/src/org/thoughtcrime/securesms/contactshare/Contact.java b/src/org/thoughtcrime/securesms/contactshare/Contact.java deleted file mode 100644 index 6547b9137..000000000 --- a/src/org/thoughtcrime/securesms/contactshare/Contact.java +++ /dev/null @@ -1,608 +0,0 @@ -package org.thoughtcrime.securesms.contactshare; - -import android.net.Uri; -import android.os.Parcel; -import android.os.Parcelable; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import android.text.TextUtils; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.thoughtcrime.securesms.attachments.Attachment; -import org.thoughtcrime.securesms.attachments.UriAttachment; -import org.thoughtcrime.securesms.database.AttachmentDatabase; -import org.thoughtcrime.securesms.util.MediaUtil; - -import java.util.Collections; -import java.util.List; - -public class Contact implements Parcelable { - - @JsonProperty - private final Name name; - - @JsonProperty - private final String organization; - - @JsonProperty - private final List phoneNumbers; - - @JsonProperty - private final List emails; - - @JsonProperty - private final List postalAddresses; - - @JsonProperty - private final Avatar avatar; - - public Contact(@JsonProperty("name") @NonNull Name name, - @JsonProperty("organization") @Nullable String organization, - @JsonProperty("phoneNumbers") @NonNull List phoneNumbers, - @JsonProperty("emails") @NonNull List emails, - @JsonProperty("postalAddresses") @NonNull List postalAddresses, - @JsonProperty("avatar") @Nullable Avatar avatar) - { - this.name = name; - this.organization = organization; - this.phoneNumbers = Collections.unmodifiableList(phoneNumbers); - this.emails = Collections.unmodifiableList(emails); - this.postalAddresses = Collections.unmodifiableList(postalAddresses); - this.avatar = avatar; - } - - public Contact(@NonNull Contact contact, @Nullable Avatar avatar) { - this(contact.getName(), - contact.getOrganization(), - contact.getPhoneNumbers(), - contact.getEmails(), - contact.getPostalAddresses(), - avatar); - } - - private Contact(Parcel in) { - this(in.readParcelable(Name.class.getClassLoader()), - in.readString(), - in.createTypedArrayList(Phone.CREATOR), - in.createTypedArrayList(Email.CREATOR), - in.createTypedArrayList(PostalAddress.CREATOR), - in.readParcelable(Avatar.class.getClassLoader())); - } - - public @NonNull Name getName() { - return name; - } - - public @Nullable String getOrganization() { - return organization; - } - - public @NonNull List getPhoneNumbers() { - return phoneNumbers; - } - - public @NonNull List getEmails() { - return emails; - } - - public @NonNull List getPostalAddresses() { - return postalAddresses; - } - - public @Nullable Avatar getAvatar() { - return avatar; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeParcelable(name, flags); - dest.writeString(organization); - dest.writeTypedList(phoneNumbers); - dest.writeTypedList(emails); - dest.writeTypedList(postalAddresses); - dest.writeParcelable(avatar, flags); - } - - public static final Creator CREATOR = new Creator() { - @Override - public Contact createFromParcel(Parcel in) { - return new Contact(in); - } - - @Override - public Contact[] newArray(int size) { - return new Contact[size]; - } - }; - - public static class Name implements Parcelable { - - @JsonProperty - private final String displayName; - - @JsonProperty - private final String givenName; - - @JsonProperty - private final String familyName; - - @JsonProperty - private final String prefix; - - @JsonProperty - private final String suffix; - - @JsonProperty - private final String middleName; - - Name(@JsonProperty("displayName") @Nullable String displayName, - @JsonProperty("givenName") @Nullable String givenName, - @JsonProperty("familyName") @Nullable String familyName, - @JsonProperty("prefix") @Nullable String prefix, - @JsonProperty("suffix") @Nullable String suffix, - @JsonProperty("middleName") @Nullable String middleName) - { - this.displayName = displayName; - this.givenName = givenName; - this.familyName = familyName; - this.prefix = prefix; - this.suffix = suffix; - this.middleName = middleName; - } - - private Name(Parcel in) { - this(in.readString(), in.readString(), in.readString(), in.readString(), in.readString(), in.readString()); - } - - public @Nullable String getGivenName() { - return givenName; - } - - public @Nullable String getPrefix() { - return prefix; - } - - public @Nullable String getSuffix() { - return suffix; - } - - public boolean isEmpty() { - return TextUtils.isEmpty(displayName) && - TextUtils.isEmpty(givenName) && - TextUtils.isEmpty(familyName) && - TextUtils.isEmpty(prefix) && - TextUtils.isEmpty(suffix) && - TextUtils.isEmpty(middleName); - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(displayName); - dest.writeString(givenName); - dest.writeString(familyName); - dest.writeString(prefix); - dest.writeString(suffix); - dest.writeString(middleName); - } - - public static final Creator CREATOR = new Creator() { - @Override - public Name createFromParcel(Parcel in) { - return new Name(in); - } - - @Override - public Name[] newArray(int size) { - return new Name[size]; - } - }; - } - - public static class Phone implements Selectable, Parcelable { - - @JsonProperty - private final String number; - - @JsonProperty - private final Type type; - - @JsonProperty - private final String label; - - @JsonIgnore - private boolean selected; - - Phone(@JsonProperty("number") @NonNull String number, - @JsonProperty("type") @NonNull Type type, - @JsonProperty("label") @Nullable String label) - { - this.number = number; - this.type = type; - this.label = label; - this.selected = true; - } - - private Phone(Parcel in) { - this(in.readString(), Type.valueOf(in.readString()), in.readString()); - } - - public @NonNull String getNumber() { - return number; - } - - public @NonNull Type getType() { - return type; - } - - public @Nullable String getLabel() { - return label; - } - - @Override - public void setSelected(boolean selected) { - this.selected = selected; - } - - @Override - public boolean isSelected() { - return selected; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(number); - dest.writeString(type.name()); - dest.writeString(label); - } - - public static final Creator CREATOR = new Creator() { - @Override - public Phone createFromParcel(Parcel in) { - return new Phone(in); - } - - @Override - public Phone[] newArray(int size) { - return new Phone[size]; - } - }; - - public enum Type { - HOME, MOBILE, WORK, CUSTOM - } - } - - public static class Email implements Selectable, Parcelable { - - @JsonProperty - private final String email; - - @JsonProperty - private final Type type; - - @JsonProperty - private final String label; - - @JsonIgnore - private boolean selected; - - Email(@JsonProperty("email") @NonNull String email, - @JsonProperty("type") @NonNull Type type, - @JsonProperty("label") @Nullable String label) - { - this.email = email; - this.type = type; - this.label = label; - this.selected = true; - } - - private Email(Parcel in) { - this(in.readString(), Type.valueOf(in.readString()), in.readString()); - } - - public @NonNull String getEmail() { - return email; - } - - public @NonNull Type getType() { - return type; - } - - public @NonNull String getLabel() { - return label; - } - - @Override - public void setSelected(boolean selected) { - this.selected = selected; - } - - @Override - public boolean isSelected() { - return selected; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(email); - dest.writeString(type.name()); - dest.writeString(label); - } - - public static final Creator CREATOR = new Creator() { - @Override - public Email createFromParcel(Parcel in) { - return new Email(in); - } - - @Override - public Email[] newArray(int size) { - return new Email[size]; - } - }; - - public enum Type { - HOME, MOBILE, WORK, CUSTOM - } - } - - public static class PostalAddress implements Selectable, Parcelable { - - @JsonProperty - private final Type type; - - @JsonProperty - private final String label; - - @JsonProperty - private final String street; - - @JsonProperty - private final String poBox; - - @JsonProperty - private final String neighborhood; - - @JsonProperty - private final String city; - - @JsonProperty - private final String region; - - @JsonProperty - private final String postalCode; - - @JsonProperty - private final String country; - - @JsonIgnore - private boolean selected; - - PostalAddress(@JsonProperty("type") @NonNull Type type, - @JsonProperty("label") @Nullable String label, - @JsonProperty("street") @Nullable String street, - @JsonProperty("poBox") @Nullable String poBox, - @JsonProperty("neighborhood") @Nullable String neighborhood, - @JsonProperty("city") @Nullable String city, - @JsonProperty("region") @Nullable String region, - @JsonProperty("postalCode") @Nullable String postalCode, - @JsonProperty("country") @Nullable String country) - { - this.type = type; - this.label = label; - this.street = street; - this.poBox = poBox; - this.neighborhood = neighborhood; - this.city = city; - this.region = region; - this.postalCode = postalCode; - this.country = country; - this.selected = true; - } - - private PostalAddress(Parcel in) { - this(Type.valueOf(in.readString()), - in.readString(), - in.readString(), - in.readString(), - in.readString(), - in.readString(), - in.readString(), - in.readString(), - in.readString()); - } - - public @NonNull Type getType() { - return type; - } - - public @Nullable String getLabel() { - return label; - } - - public @Nullable String getStreet() { - return street; - } - - public @Nullable String getRegion() { - return region; - } - - public @Nullable String getPostalCode() { - return postalCode; - } - - @Override - public void setSelected(boolean selected) { - this.selected = selected; - } - - @Override - public boolean isSelected() { - return selected; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(type.name()); - dest.writeString(label); - dest.writeString(street); - dest.writeString(poBox); - dest.writeString(neighborhood); - dest.writeString(city); - dest.writeString(region); - dest.writeString(postalCode); - dest.writeString(country); - } - - public static final Creator CREATOR = new Creator() { - @Override - public PostalAddress createFromParcel(Parcel in) { - return new PostalAddress(in); - } - - @Override - public PostalAddress[] newArray(int size) { - return new PostalAddress[size]; - } - }; - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - - if (!TextUtils.isEmpty(street)) { - builder.append(street).append('\n'); - } - - if (!TextUtils.isEmpty(poBox)) { - builder.append(poBox).append('\n'); - } - - if (!TextUtils.isEmpty(neighborhood)) { - builder.append(neighborhood).append('\n'); - } - - if (!TextUtils.isEmpty(city) && !TextUtils.isEmpty(region)) { - builder.append(city).append(", ").append(region); - } else if (!TextUtils.isEmpty(city)) { - builder.append(city).append(' '); - } else if (!TextUtils.isEmpty(region)) { - builder.append(region).append(' '); - } - - if (!TextUtils.isEmpty(postalCode)) { - builder.append(postalCode); - } - - if (!TextUtils.isEmpty(country)) { - builder.append('\n').append(country); - } - - return builder.toString().trim(); - } - - public enum Type { - HOME, WORK, CUSTOM - } - } - - public static class Avatar implements Selectable, Parcelable { - - @JsonProperty - private final boolean isProfile; - - @JsonIgnore - private final Attachment attachment; - - @JsonIgnore - private boolean selected; - - public Avatar(@Nullable Attachment attachment, boolean isProfile) { - this.attachment = attachment; - this.isProfile = isProfile; - this.selected = true; - } - - Avatar(@Nullable Uri attachmentUri, boolean isProfile) { - this(attachmentFromUri(attachmentUri), isProfile); - } - - private Avatar(Parcel in) { - this((Uri) in.readParcelable(Uri.class.getClassLoader()), in.readByte() != 0); - } - - public @Nullable Attachment getAttachment() { - return attachment; - } - - public boolean isProfile() { - return isProfile; - } - - @Override - public void setSelected(boolean selected) { - this.selected = selected; - } - - @Override - public boolean isSelected() { - return selected; - } - - @Override - public int describeContents() { - return 0; - } - - private static Attachment attachmentFromUri(@Nullable Uri uri) { - if (uri == null) return null; - return new UriAttachment(uri, MediaUtil.IMAGE_JPEG, AttachmentDatabase.TRANSFER_PROGRESS_DONE, 0, null, false); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeParcelable(attachment != null ? attachment.getDataUri() : null, flags); - dest.writeByte((byte) (isProfile ? 1 : 0)); - } - - public static final Creator CREATOR = new Creator() { - @Override - public Avatar createFromParcel(Parcel in) { - return new Avatar(in); - } - - @Override - public Avatar[] newArray(int size) { - return new Avatar[size]; - } - }; - } -} diff --git a/src/org/thoughtcrime/securesms/jobmanager/Job.java b/src/org/thoughtcrime/securesms/jobmanager/Job.java index 4b52fd859..f231873cb 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/Job.java +++ b/src/org/thoughtcrime/securesms/jobmanager/Job.java @@ -31,19 +31,13 @@ public abstract class Job implements Serializable { private final JobParameters parameters; - private transient long persistentId; private transient int runIteration; - private transient long lastRunTime; private transient PowerManager.WakeLock wakeLock; public Job(JobParameters parameters) { this.parameters = parameters; } - public List getRequirements() { - return parameters.getRequirements(); - } - public boolean isRequirementsMet() { for (Requirement requirement : parameters.getRequirements()) { if (!requirement.isPresent(this)) return false; @@ -56,10 +50,6 @@ public abstract class Job implements Serializable { return parameters.getGroupId(); } - public boolean isPersistent() { - return parameters.isPersistent(); - } - public int getRetryCount() { return parameters.getRetryCount(); } @@ -68,21 +58,8 @@ public abstract class Job implements Serializable { return parameters.getRetryUntil(); } - public long getLastRunTime() { - return lastRunTime; - } - public void resetRunStats() { runIteration = 0; - lastRunTime = 0; - } - - public void setPersistentId(long persistentId) { - this.persistentId = persistentId; - } - - public long getPersistentId() { - return persistentId; } public int getRunIteration() { @@ -107,7 +84,6 @@ public abstract class Job implements Serializable { public void onRetry() { runIteration++; - lastRunTime = System.currentTimeMillis(); for (Requirement requirement : parameters.getRequirements()) { requirement.onRetry(this); diff --git a/src/org/thoughtcrime/securesms/jobmanager/JobParameters.java b/src/org/thoughtcrime/securesms/jobmanager/JobParameters.java index d2e64d63d..14dae988e 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/JobParameters.java +++ b/src/org/thoughtcrime/securesms/jobmanager/JobParameters.java @@ -54,10 +54,6 @@ public class JobParameters implements Serializable { return requirements; } - public boolean isPersistent() { - return false; - } - public int getRetryCount() { return retryCount; } @@ -93,36 +89,6 @@ public class JobParameters implements Serializable { private boolean wakeLock = false; private long wakeLockTimeout = 0; - /** - * Specify a {@link org.thoughtcrime.securesms.jobmanager.requirements.Requirement }that must be met - * before the Job is executed. May be called multiple times to register multiple requirements. - * @param requirement The Requirement that must be met. - * @return the builder. - */ - public Builder withRequirement(Requirement requirement) { - this.requirements.add(requirement); - return this; - } - - /** - * Specify how many times the job should be retried if execution fails but onShouldRetry() returns - * true. - * - * @param retryCount The number of times the job should be retried. - * @return the builder. - */ - public Builder withRetryCount(int retryCount) { - this.retryCount = retryCount; - this.retryDuration = 0; - return this; - } - - public Builder withRetryDuration(long duration) { - this.retryDuration = duration; - this.retryCount = 0; - return this; - } - /** * Specify a groupId the job should belong to. Jobs with the same groupId are guaranteed to be * executed serially. @@ -135,31 +101,6 @@ public class JobParameters implements Serializable { return this; } - /** - * Specify whether this job should hold a wake lock. - * - * @param needsWakeLock If set, this job will acquire a wakelock on add(), and hold it until - * run() completes, or cancel(). - * @param timeout Specify a timeout for the wakelock. A timeout of - * 0 will result in no timeout. - * - * @return the builder. - */ - public Builder withWakeLock(boolean needsWakeLock, long timeout, TimeUnit unit) { - this.wakeLock = needsWakeLock; - this.wakeLockTimeout = unit.toMillis(timeout); - return this; - } - - /** - * Specify whether this job should hold a wake lock. - * - * @return the builder. - */ - public Builder withWakeLock(boolean needsWakeLock) { - return withWakeLock(needsWakeLock, 0, TimeUnit.MILLISECONDS); - } - /** * @return the JobParameters instance that describes a Job. */ diff --git a/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java b/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java index 5bbbdf264..acd8919ee 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java +++ b/src/org/thoughtcrime/securesms/jobmanager/JobQueue.java @@ -39,16 +39,6 @@ class JobQueue { notifyAll(); } - synchronized void addAll(List jobs) { - jobQueue.addAll(jobs); - - for (Job job : jobs) { - processJobAddition(job); - } - - notifyAll(); - } - private void processJobAddition(@NonNull Job job) { if (isJobActive(job) && isGroupIdAvailable(job)) { setGroupIdUnavailable(job); diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java index 9b1fa9ba5..2b458aa7b 100644 --- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java +++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java @@ -593,17 +593,6 @@ public class AttachmentManager { default: throw new AssertionError("unrecognized enum"); } } - - public static @Nullable MediaType from(final @Nullable String mimeType) { - if (TextUtils.isEmpty(mimeType)) return null; - if (MediaUtil.isGif(mimeType)) return GIF; - if (MediaUtil.isImageType(mimeType)) return IMAGE; - if (MediaUtil.isAudioType(mimeType)) return AUDIO; - if (MediaUtil.isVideoType(mimeType)) return VIDEO; - - return DOCUMENT; - } - } public int getVisibility() { diff --git a/src/org/thoughtcrime/securesms/mms/MediaConstraints.java b/src/org/thoughtcrime/securesms/mms/MediaConstraints.java index 0caf79e91..d29485444 100644 --- a/src/org/thoughtcrime/securesms/mms/MediaConstraints.java +++ b/src/org/thoughtcrime/securesms/mms/MediaConstraints.java @@ -14,8 +14,4 @@ public abstract class MediaConstraints { public abstract int getImageMaxWidth(Context context); public abstract int getImageMaxHeight(Context context); public abstract int getImageMaxSize(Context context); - - public boolean canResize(@Nullable Attachment attachment) { - return attachment != null && MediaUtil.isImage(attachment) && !MediaUtil.isGif(attachment); - } } diff --git a/src/org/thoughtcrime/securesms/mms/SlideDeck.java b/src/org/thoughtcrime/securesms/mms/SlideDeck.java index 2010f3b52..e90d97004 100644 --- a/src/org/thoughtcrime/securesms/mms/SlideDeck.java +++ b/src/org/thoughtcrime/securesms/mms/SlideDeck.java @@ -16,15 +16,10 @@ */ package org.thoughtcrime.securesms.mms; -import android.content.Context; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.b44t.messenger.DcMsg; - import org.thoughtcrime.securesms.attachments.Attachment; -import org.thoughtcrime.securesms.util.MediaUtil; -import org.thoughtcrime.securesms.util.guava.Optional; import java.util.LinkedList; import java.util.List; @@ -33,33 +28,6 @@ public class SlideDeck { private final List slides = new LinkedList<>(); - public SlideDeck(@NonNull Context context, @NonNull List attachments) { - for (Attachment attachment : attachments) { - Slide slide = MediaUtil.getSlideForAttachment(context, attachment); - if (slide != null) slides.add(slide); - } - } - - // this uses the odd order of arguments to avoid type erasure problems. If the constructor that takes attachments is gone - // update this. - public SlideDeck(@NonNull List messages, @NonNull Context context) { - for (DcMsg message : messages) { - Slide slide = MediaUtil.getSlideForMsg(context, message); - if (slide != null) slides.add(slide); - } - } - - - public SlideDeck(@NonNull Context context, @NonNull Attachment attachment) { - Slide slide = MediaUtil.getSlideForAttachment(context, attachment); - if (slide != null) slides.add(slide); - } - - public SlideDeck(@NonNull Context context, @NonNull DcMsg message) { - Slide slide = MediaUtil.getSlideForMsg(context, message); - if (slide != null) slides.add(slide); - } - public SlideDeck() { } @@ -67,21 +35,6 @@ public class SlideDeck { slides.clear(); } - @NonNull - public String getBody() { - String body = ""; - - for (Slide slide : slides) { - Optional slideBody = slide.getBody(); - - if (slideBody.isPresent()) { - body = slideBody.get(); - } - } - - return body; - } - @NonNull public List asAttachments() { List attachments = new LinkedList<>(); @@ -97,39 +50,6 @@ public class SlideDeck { slides.add(slide); } - public List getSlides() { - return slides; - } - - public boolean containsMediaSlide() { - for (Slide slide : slides) { - if (slide.hasImage() || slide.hasVideo() || slide.hasAudio() || slide.hasDocument()) { - return true; - } - } - return false; - } - - public @Nullable Slide getThumbnailSlide() { - for (Slide slide : slides) { - if (slide.hasImage()) { - return slide; - } - } - - return null; - } - - public @Nullable AudioSlide getAudioSlide() { - for (Slide slide : slides) { - if (slide.hasAudio()) { - return (AudioSlide)slide; - } - } - - return null; - } - public @Nullable DocumentSlide getDocumentSlide() { for (Slide slide: slides) { if (slide.hasDocument()) { diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index 5e7adfb04..881b56b51 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -60,7 +60,6 @@ public class Recipient { private @Nullable Uri systemContactPhoto; private Uri contactUri; - private @Nullable Uri messageRingtone = null; private @Nullable String profileName; private @Nullable String profileAvatar; @@ -128,10 +127,6 @@ public class Recipient { } } - public @Nullable Uri getContactUri() { - return this.contactUri; - } - public @Nullable String getName() { if(dcChat!=null) { return dcChat.getName(); @@ -252,21 +247,6 @@ public class Recipient { if (notify) notifyListeners(); } - public synchronized @Nullable Uri getMessageRingtone() { - if (messageRingtone != null && messageRingtone.getScheme() != null && messageRingtone.getScheme().startsWith("file")) { - return null; - } - - return messageRingtone; - } - - public boolean isBlocked() { - if (dcContact!=null) { - return dcContact.isBlocked(); - } - return false; - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -293,17 +273,6 @@ public class Recipient { listener.onModified(this); } - public void reload(Context context) - { - DcContext dcContext = DcHelper.getContext(context); - if(dcContact!=null) { - dcContact = dcContext.getContact(dcContact.getId()); - } - else if(dcChat!=null) { - dcChat = dcContext.getChat(dcChat.getId()); - } - } - public DcChat getChat() { return dcChat!=null? dcChat : new DcChat(0); diff --git a/src/org/thoughtcrime/securesms/util/BitmapUtil.java b/src/org/thoughtcrime/securesms/util/BitmapUtil.java index faeb1dabc..d8212bed9 100644 --- a/src/org/thoughtcrime/securesms/util/BitmapUtil.java +++ b/src/org/thoughtcrime/securesms/util/BitmapUtil.java @@ -123,22 +123,6 @@ public class BitmapUtil { } } - @WorkerThread - public static Bitmap createScaledBitmap(Context context, T model, int maxWidth, int maxHeight) - throws BitmapDecodingException - { - try { - return GlideApp.with(context.getApplicationContext()) - .asBitmap() - .load(model) - .downsample(DownsampleStrategy.AT_MOST) - .submit(maxWidth, maxHeight) - .get(); - } catch (InterruptedException | ExecutionException e) { - throw new BitmapDecodingException(e); - } - } - @WorkerThread public static Bitmap createScaledBitmap(Bitmap bitmap, int maxWidth, int maxHeight) { if (bitmap.getWidth() <= maxWidth && bitmap.getHeight() <= maxHeight) { @@ -209,24 +193,6 @@ public class BitmapUtil { return new Pair<>(options.outWidth, options.outHeight); } - public static InputStream toCompressedJpeg(Bitmap bitmap) { - ByteArrayOutputStream thumbnailBytes = new ByteArrayOutputStream(); - bitmap.compress(CompressFormat.JPEG, 85, thumbnailBytes); - return new ByteArrayInputStream(thumbnailBytes.toByteArray()); - } - - public static @Nullable byte[] toByteArray(@Nullable Bitmap bitmap) { - if (bitmap == null) return null; - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); - return stream.toByteArray(); - } - - public static @Nullable Bitmap fromByteArray(@Nullable byte[] bytes) { - if (bytes == null) return null; - return BitmapFactory.decodeByteArray(bytes, 0, bytes.length); - } - public static byte[] createFromNV21(@NonNull final byte[] data, final int width, final int height, diff --git a/src/org/thoughtcrime/securesms/util/Conversions.java b/src/org/thoughtcrime/securesms/util/Conversions.java index 832531416..7fe341111 100644 --- a/src/org/thoughtcrime/securesms/util/Conversions.java +++ b/src/org/thoughtcrime/securesms/util/Conversions.java @@ -35,12 +35,4 @@ public class Conversions { bytes[offset] = (byte)(value >> 56); return 8; } - - public static int longTo4ByteArray(byte[] bytes, int offset, long value) { - bytes[offset + 3] = (byte)value; - bytes[offset + 2] = (byte)(value >> 8); - bytes[offset + 1] = (byte)(value >> 16); - bytes[offset + 0] = (byte)(value >> 24); - return 4; - } } diff --git a/src/org/thoughtcrime/securesms/util/DateUtils.java b/src/org/thoughtcrime/securesms/util/DateUtils.java index dbb0a2e3b..5f0afb19a 100644 --- a/src/org/thoughtcrime/securesms/util/DateUtils.java +++ b/src/org/thoughtcrime/securesms/util/DateUtils.java @@ -98,49 +98,6 @@ public class DateUtils extends android.text.format.DateUtils { } } - public static String getTimeOfDayTimeSpanString(final Context c, final Locale locale, final long timestamp) { - if (isWithin(timestamp, 1, TimeUnit.MINUTES)) { - return c.getString(R.string.now); - } else if (isWithin(timestamp, 1, TimeUnit.HOURS)) { - int mins = (int)TimeUnit.MINUTES.convert(System.currentTimeMillis() - timestamp, TimeUnit.MILLISECONDS); - return c.getResources().getQuantityString(R.plurals.n_minutes, mins, mins); - } else { - StringBuilder format = new StringBuilder(); - if (DateFormat.is24HourFormat(c)) format.append("HH:mm"); - else format.append("hh:mm a"); - - return getFormattedDateTime(timestamp, format.toString(), locale); - } - } - - public static String getDayPrecisionTimeSpanString(Context context, Locale locale, long timestamp) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); - - if (simpleDateFormat.format(System.currentTimeMillis()).equals(simpleDateFormat.format(timestamp))) { - return context.getString(R.string.today); - } else { - String format; - - if (isWithin(timestamp, 6, TimeUnit.DAYS)) format = "EEE "; - else if (isWithin(timestamp, 365, TimeUnit.DAYS)) format = "MMM d"; - else format = "MMM d, yyy"; - - return getFormattedDateTime(timestamp, format, locale); - } - } - - public static SimpleDateFormat getDetailedDateFormatter(Context context, Locale locale) { - String dateFormatPattern; - - if (DateFormat.is24HourFormat(context)) { - dateFormatPattern = getLocalizedPattern("MMM d, yyyy HH:mm:ss zzz", locale); - } else { - dateFormatPattern = getLocalizedPattern("MMM d, yyyy hh:mm:ss a zzz", locale); - } - - return new SimpleDateFormat(dateFormatPattern, locale); - } - public static String getRelativeDate(@NonNull Context context, @NonNull Locale locale, long timestamp) @@ -154,14 +111,6 @@ public class DateUtils extends android.text.format.DateUtils { } } - public static boolean isSameDay(long t1, long t2) { - return DATE_FORMAT.format(new Date(t1)).equals(DATE_FORMAT.format(new Date(t2))); - } - - public static boolean isSameBriefRelativeTimestamp(@NonNull Context context, @NonNull Locale locale, long t1, long t2) { - return getBriefRelativeTimeSpanString(context, locale, t1).equals(getBriefRelativeTimeSpanString(context, locale, t2)); - } - private static String getLocalizedPattern(String template, Locale locale) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { return DateFormat.getBestDateTimePattern(locale, template); diff --git a/src/org/thoughtcrime/securesms/util/FileUtils.java b/src/org/thoughtcrime/securesms/util/FileUtils.java index a79c0482e..9cafb393d 100644 --- a/src/org/thoughtcrime/securesms/util/FileUtils.java +++ b/src/org/thoughtcrime/securesms/util/FileUtils.java @@ -1,57 +1,9 @@ package org.thoughtcrime.securesms.util; -import android.annotation.SuppressLint; -import android.content.Context; - -import java.io.File; import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; public class FileUtils { public static native int getFileDescriptorOwner(FileDescriptor fileDescriptor); - public static byte[] getFileDigest(FileInputStream fin) throws IOException { - try { - MessageDigest digest = MessageDigest.getInstance("SHA256"); - - byte[] buffer = new byte[4096]; - int read = 0; - - while ((read = fin.read(buffer, 0, buffer.length)) != -1) { - digest.update(buffer, 0, read); - } - - return digest.digest(); - } catch (NoSuchAlgorithmException e) { - throw new AssertionError(e); - } - } - - public static void deleteDirectoryContents(File directory) throws IOException { - if (directory == null || !directory.exists() || !directory.isDirectory()) return; - - File[] files = directory.listFiles(); - - if (files != null) { - for (File file : files) { - if (file.isDirectory()) deleteDirectory(file); - else file.delete(); - } - } - } - - public static void deleteDirectory(File directory) throws IOException { - if (directory == null || !directory.exists() || !directory.isDirectory()) { - return; - } - - deleteDirectoryContents(directory); - - directory.delete(); - } - } diff --git a/src/org/thoughtcrime/securesms/util/Hex.java b/src/org/thoughtcrime/securesms/util/Hex.java index a2142fbbf..0b0e64b6f 100644 --- a/src/org/thoughtcrime/securesms/util/Hex.java +++ b/src/org/thoughtcrime/securesms/util/Hex.java @@ -16,8 +16,6 @@ */ package org.thoughtcrime.securesms.util; -import java.io.IOException; - /** * Utility for generating hex dumps. */ @@ -32,10 +30,6 @@ public class Hex { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - public static String toString(byte[] bytes) { - return toString(bytes, 0, bytes.length); - } - public static String toString(byte[] bytes, int offset, int length) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < length; i++) { @@ -53,32 +47,6 @@ public class Hex { return buf.toString(); } - public static byte[] fromStringCondensed(String encoded) throws IOException { - final char[] data = encoded.toCharArray(); - final int len = data.length; - - if ((len & 0x01) != 0) { - throw new IOException("Odd number of characters."); - } - - final byte[] out = new byte[len >> 1]; - - // two characters form the hex value. - for (int i = 0, j = 0; j < len; i++) { - int f = Character.digit(data[j], 16) << 4; - j++; - f = f | Character.digit(data[j], 16); - j++; - out[i] = (byte) (f & 0xFF); - } - - return out; - } - - public static String dump(byte[] bytes) { - return dump(bytes, 0, bytes.length); - } - public static String dump(byte[] bytes, int offset, int length) { StringBuffer buf = new StringBuffer(); int lines = ((length - 1) / 16) + 1; diff --git a/src/org/thoughtcrime/securesms/util/MathUtils.java b/src/org/thoughtcrime/securesms/util/MathUtils.java deleted file mode 100644 index 93842ea03..000000000 --- a/src/org/thoughtcrime/securesms/util/MathUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.thoughtcrime.securesms.util; - -import android.graphics.PointF; -import androidx.annotation.NonNull; - -public class MathUtils { - - /** - * For more info: - * StackOverflow: How to check point is in rectangle - * - * @param pt point to check - * @param v1 vertex 1 of the triangle - * @param v2 vertex 2 of the triangle - * @param v3 vertex 3 of the triangle - * @return true if point (x, y) is inside the triangle - */ - public static boolean pointInTriangle(@NonNull PointF pt, @NonNull PointF v1, - @NonNull PointF v2, @NonNull PointF v3) { - - boolean b1 = crossProduct(pt, v1, v2) < 0.0f; - boolean b2 = crossProduct(pt, v2, v3) < 0.0f; - boolean b3 = crossProduct(pt, v3, v1) < 0.0f; - - return (b1 == b2) && (b2 == b3); - } - - /** - * calculates cross product of vectors AB and AC - * - * @param a beginning of 2 vectors - * @param b end of vector 1 - * @param c enf of vector 2 - * @return cross product AB * AC - */ - private static float crossProduct(@NonNull PointF a, @NonNull PointF b, @NonNull PointF c) { - return crossProduct(a.x, a.y, b.x, b.y, c.x, c.y); - } - - /** - * calculates cross product of vectors AB and AC - * - * @param ax X coordinate of point A - * @param ay Y coordinate of point A - * @param bx X coordinate of point B - * @param by Y coordinate of point B - * @param cx X coordinate of point C - * @param cy Y coordinate of point C - * @return cross product AB * AC - */ - private static float crossProduct(float ax, float ay, float bx, float by, float cx, float cy) { - return (ax - cx) * (by - cy) - (bx - cx) * (ay - cy); - } -} \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/util/MediaUtil.java b/src/org/thoughtcrime/securesms/util/MediaUtil.java index a83fac7b1..a4c64fc43 100644 --- a/src/org/thoughtcrime/securesms/util/MediaUtil.java +++ b/src/org/thoughtcrime/securesms/util/MediaUtil.java @@ -41,7 +41,6 @@ public class MediaUtil { private static final String TAG = MediaUtil.class.getSimpleName(); public static final String IMAGE_WEBP = "image/webp"; - public static final String IMAGE_PNG = "image/png"; public static final String IMAGE_JPEG = "image/jpeg"; public static final String IMAGE_GIF = "image/gif"; public static final String AUDIO_AAC = "audio/aac"; @@ -198,22 +197,6 @@ public class MediaUtil { return !TextUtils.isEmpty(contentType) && contentType.trim().equals("application/mms"); } - public static boolean isGif(Attachment attachment) { - return isGif(attachment.getContentType()); - } - - public static boolean isImage(Attachment attachment) { - return isImageType(attachment.getContentType()); - } - - public static boolean isAudio(Attachment attachment) { - return isAudioType(attachment.getContentType()); - } - - public static boolean isVideo(Attachment attachment) { - return isVideoType(attachment.getContentType()); - } - public static boolean isVideo(String contentType) { return !TextUtils.isEmpty(contentType) && contentType.trim().startsWith("video/"); } @@ -226,10 +209,6 @@ public class MediaUtil { return !TextUtils.isEmpty(contentType) && contentType.trim().equals(IMAGE_JPEG); } - public static boolean isFile(Attachment attachment) { - return !isGif(attachment) && !isImage(attachment) && !isAudio(attachment) && !isVideo(attachment); - } - public static boolean isImageType(String contentType) { return (null != contentType) && contentType.startsWith("image/"); } diff --git a/src/org/thoughtcrime/securesms/util/MemoryFileUtil.java b/src/org/thoughtcrime/securesms/util/MemoryFileUtil.java deleted file mode 100644 index 06a4cecd1..000000000 --- a/src/org/thoughtcrime/securesms/util/MemoryFileUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.thoughtcrime.securesms.util; - - -import android.os.Build; -import android.os.MemoryFile; -import android.os.ParcelFileDescriptor; - -import java.io.FileDescriptor; -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class MemoryFileUtil { - - public static ParcelFileDescriptor getParcelFileDescriptor(MemoryFile file) throws IOException { - try { - Method method = MemoryFile.class.getDeclaredMethod("getFileDescriptor"); - FileDescriptor fileDescriptor = (FileDescriptor) method.invoke(file); - - Field field = fileDescriptor.getClass().getDeclaredField("descriptor"); - field.setAccessible(true); - - int fd = field.getInt(fileDescriptor); - - if (Build.VERSION.SDK_INT >= 13) { - return ParcelFileDescriptor.adoptFd(fd); - } else { - return ParcelFileDescriptor.dup(fileDescriptor); - } - } catch (IllegalAccessException e) { - throw new IOException(e); - } catch (InvocationTargetException e) { - throw new IOException(e); - } catch (NoSuchMethodException e) { - throw new IOException(e); - } catch (NoSuchFieldException e) { - throw new IOException(e); - } - } -} diff --git a/src/org/thoughtcrime/securesms/util/NumberUtil.java b/src/org/thoughtcrime/securesms/util/NumberUtil.java index 9ab4f4756..2352c4c30 100644 --- a/src/org/thoughtcrime/securesms/util/NumberUtil.java +++ b/src/org/thoughtcrime/securesms/util/NumberUtil.java @@ -16,8 +16,6 @@ */ package org.thoughtcrime.securesms.util; -import android.telephony.PhoneNumberUtils; - import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -29,30 +27,4 @@ public class NumberUtil { Matcher matcher = emailPattern.matcher(number); return matcher.matches(); } - - public static boolean isValidSmsOrEmail(String number) { - return PhoneNumberUtils.isWellFormedSmsAddress(number) || isValidEmail(number); - } - -// public static boolean isValidSmsOrEmailOrGroup(String number) { -// return PhoneNumberUtils.isWellFormedSmsAddress(number) || -// isValidEmail(number) || -// GroupUtil.isEncodedGroup(number); -// } -// -// public static String filterNumber(String number) { -// if (number == null) return null; -// -// int length = number.length(); -// StringBuilder builder = new StringBuilder(length); -// -// for (int i = 0; i < length; i++) { -// char character = number.charAt(i); -// -// if (Character.isDigit(character) || character == '+') -// builder.append(character); -// } -// -// return builder.toString(); -// } } diff --git a/src/org/thoughtcrime/securesms/util/ResUtil.java b/src/org/thoughtcrime/securesms/util/ResUtil.java index b71822c4a..08a28cef8 100644 --- a/src/org/thoughtcrime/securesms/util/ResUtil.java +++ b/src/org/thoughtcrime/securesms/util/ResUtil.java @@ -55,14 +55,4 @@ public class ResUtil { return null; } } - - public static int[] getResourceIds(Context c, @ArrayRes int array) { - final TypedArray typedArray = c.getResources().obtainTypedArray(array); - final int[] resourceIds = new int[typedArray.length()]; - for (int i = 0; i < typedArray.length(); i++) { - resourceIds[i] = typedArray.getResourceId(i, 0); - } - typedArray.recycle(); - return resourceIds; - } } diff --git a/src/org/thoughtcrime/securesms/util/SelectedRecipientsAdapter.java b/src/org/thoughtcrime/securesms/util/SelectedRecipientsAdapter.java index 5fc06686f..e18a40144 100644 --- a/src/org/thoughtcrime/securesms/util/SelectedRecipientsAdapter.java +++ b/src/org/thoughtcrime/securesms/util/SelectedRecipientsAdapter.java @@ -34,10 +34,6 @@ public class SelectedRecipientsAdapter extends BaseAdapter { @NonNull private List recipients; @NonNull private final ApplicationDcContext dcContext; - public SelectedRecipientsAdapter(@NonNull Context context) { - this(context, Collections.emptyList()); - } - public SelectedRecipientsAdapter(@NonNull Context context, @NonNull Collection existingRecipients) { @@ -175,9 +171,5 @@ public class SelectedRecipientsAdapter extends BaseAdapter { public boolean isModifiable() { return modifiable; } - - public boolean isPush() { - return push; - } } } \ No newline at end of file diff --git a/src/org/thoughtcrime/securesms/util/ServiceUtil.java b/src/org/thoughtcrime/securesms/util/ServiceUtil.java index d57a86c77..7b416589d 100644 --- a/src/org/thoughtcrime/securesms/util/ServiceUtil.java +++ b/src/org/thoughtcrime/securesms/util/ServiceUtil.java @@ -20,26 +20,6 @@ public class ServiceUtil { return (WindowManager) context.getSystemService(Activity.WINDOW_SERVICE); } - public static ConnectivityManager getConnectivityManager(Context context) { - return (ConnectivityManager) context.getSystemService(Activity.CONNECTIVITY_SERVICE); - } - - public static NotificationManager getNotificationManager(Context context) { - return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); - } - - public static AudioManager getAudioManager(Context context) { - return (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); - } - - public static PowerManager getPowerManager(Context context) { - return (PowerManager)context.getSystemService(Context.POWER_SERVICE); - } - - public static AlarmManager getAlarmManager(Context context) { - return (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); - } - public static Vibrator getVibrator(Context context) { return (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); } diff --git a/src/org/thoughtcrime/securesms/util/Util.java b/src/org/thoughtcrime/securesms/util/Util.java index 3a6f2588c..25c90bafa 100644 --- a/src/org/thoughtcrime/securesms/util/Util.java +++ b/src/org/thoughtcrime/securesms/util/Util.java @@ -138,18 +138,6 @@ public class Util { } } - public static void readFully(InputStream in, byte[] buffer) throws IOException { - int offset = 0; - - for (;;) { - int read = in.read(buffer, offset, buffer.length - offset); - if (read == -1) throw new IOException("Stream ended early"); - - if (read + offset < buffer.length) offset += read; - else return; - } - } - public static byte[] readFully(InputStream in) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; @@ -227,47 +215,6 @@ public class Util { return results; } - public static byte[][] split(byte[] input, int firstLength, int secondLength) { - byte[][] parts = new byte[2][]; - - parts[0] = new byte[firstLength]; - System.arraycopy(input, 0, parts[0], 0, firstLength); - - parts[1] = new byte[secondLength]; - System.arraycopy(input, firstLength, parts[1], 0, secondLength); - - return parts; - } - - public static byte[] combine(byte[]... elements) { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - for (byte[] element : elements) { - baos.write(element); - } - - return baos.toByteArray(); - } catch (IOException e) { - throw new AssertionError(e); - } - } - - public static byte[] trim(byte[] input, int length) { - byte[] result = new byte[length]; - System.arraycopy(input, 0, result, 0, result.length); - - return result; - } - - public static int getCurrentApkReleaseVersion(Context context) { - try { - return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; - } catch (PackageManager.NameNotFoundException e) { - throw new AssertionError(e); - } - } - public static byte[] getSecretBytes(int size) { byte[] secret = new byte[size]; getSecureRandom().nextBytes(secret);