mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +02:00
fix some linter warnings
This commit is contained in:
parent
b5000e2fb9
commit
7193b4d64e
43 changed files with 172 additions and 206 deletions
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms;
|
|||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
|
@ -23,7 +24,7 @@ import com.b44t.messenger.DcChat;
|
|||
import com.b44t.messenger.DcContact;
|
||||
import com.b44t.messenger.DcContext;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import org.thoughtcrime.securesms.components.AvatarSelector;
|
||||
|
@ -74,7 +75,7 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
setContentView(R.layout.group_create_activity);
|
||||
verified = false;
|
||||
broadcast = getIntent().getBooleanExtra(CREATE_BROADCAST, false);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
|
||||
|
||||
groupChatId = getIntent().getIntExtra(EDIT_GROUP_CHAT_ID, 0);
|
||||
|
@ -354,11 +355,14 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity
|
|||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.centerCrop()
|
||||
.override(AVATAR_SIZE, AVATAR_SIZE)
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
setAvatar(output, resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,17 @@ package org.thoughtcrime.securesms.animation;
|
|||
|
||||
import android.animation.Animator;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public abstract class AnimationCompleteListener implements Animator.AnimatorListener {
|
||||
@Override
|
||||
public final void onAnimationStart(Animator animation) {}
|
||||
public final void onAnimationStart(@NonNull Animator animation) {}
|
||||
|
||||
@Override
|
||||
public abstract void onAnimationEnd(Animator animation);
|
||||
public abstract void onAnimationEnd(@NonNull Animator animation);
|
||||
|
||||
@Override
|
||||
public final void onAnimationCancel(Animator animation) {}
|
||||
public final void onAnimationCancel(@NonNull Animator animation) {}
|
||||
@Override
|
||||
public final void onAnimationRepeat(Animator animation) {}
|
||||
public final void onAnimationRepeat(@NonNull Animator animation) {}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class UriAttachment extends Attachment {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other != null && other instanceof UriAttachment && ((UriAttachment) other).dataUri.equals(this.dataUri);
|
||||
return other instanceof UriAttachment && ((UriAttachment) other).dataUri.equals(this.dataUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,7 +46,7 @@ public class AudioRecorder {
|
|||
throw new AssertionError("We can only record once at a time.");
|
||||
}
|
||||
|
||||
ParcelFileDescriptor fds[] = ParcelFileDescriptor.createPipe();
|
||||
ParcelFileDescriptor[] fds = ParcelFileDescriptor.createPipe();
|
||||
|
||||
captureUri = blobProvider.create(context, new ParcelFileDescriptor.AutoCloseInputStream(fds[0]),
|
||||
MediaUtil.AUDIO_AAC, "voice.aac", null);
|
||||
|
|
|
@ -337,7 +337,7 @@ public class AudioSlidePlayer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
AudioSlidePlayer player = playerReference.get();
|
||||
|
||||
if (player == null || player.mediaPlayer == null || !isPlayerActive(player.mediaPlayer)) {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
|
@ -186,13 +185,6 @@ public class AttachmentTypeSelector extends PopupWindow {
|
|||
animator.start();
|
||||
}
|
||||
|
||||
private void animateWindowInTranslate(@NonNull View contentView) {
|
||||
Animation animation = new TranslateAnimation(0, 0, contentView.getHeight(), 0);
|
||||
animation.setDuration(ANIMATION_DURATION);
|
||||
|
||||
getContentView().startAnimation(animation);
|
||||
}
|
||||
|
||||
private void animateWindowOutCircular(@Nullable View anchor, @NonNull View contentView) {
|
||||
Pair<Integer, Integer> coordinates = getClickOrigin(anchor, contentView);
|
||||
Animator animator = ViewAnimationUtils.createCircularReveal(getContentView(),
|
||||
|
@ -204,20 +196,20 @@ public class AttachmentTypeSelector extends PopupWindow {
|
|||
animator.setDuration(ANIMATION_DURATION);
|
||||
animator.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
public void onAnimationStart(@NonNull Animator animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(@NonNull Animator animation) {
|
||||
AttachmentTypeSelector.super.dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
public void onAnimationCancel(@NonNull Animator animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
public void onAnimationRepeat(@NonNull Animator animation) {
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.components;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.net.Uri;
|
||||
import android.view.Gravity;
|
||||
|
@ -32,10 +33,6 @@ public class AvatarSelector extends PopupWindow {
|
|||
|
||||
private final @NonNull LoaderManager loaderManager;
|
||||
private final @NonNull RecentPhotoViewRail recentRail;
|
||||
private final @NonNull ImageView imageButton;
|
||||
private final @NonNull ImageView cameraButton;
|
||||
private final @NonNull ImageView removeButton;
|
||||
private final @NonNull ImageView closeButton;
|
||||
|
||||
private @Nullable AttachmentClickedListener listener;
|
||||
|
||||
|
@ -48,25 +45,25 @@ public class AvatarSelector extends PopupWindow {
|
|||
this.listener = listener;
|
||||
this.loaderManager = loaderManager;
|
||||
this.recentRail = ViewUtil.findById(layout, R.id.recent_photos);
|
||||
this.imageButton = ViewUtil.findById(layout, R.id.gallery_button);
|
||||
this.cameraButton = ViewUtil.findById(layout, R.id.camera_button);
|
||||
this.closeButton = ViewUtil.findById(layout, R.id.close_button);
|
||||
this.removeButton = ViewUtil.findById(layout, R.id.remove_button);
|
||||
ImageView imageButton = ViewUtil.findById(layout, R.id.gallery_button);
|
||||
ImageView cameraButton = ViewUtil.findById(layout, R.id.camera_button);
|
||||
ImageView closeButton = ViewUtil.findById(layout, R.id.close_button);
|
||||
ImageView removeButton = ViewUtil.findById(layout, R.id.remove_button);
|
||||
|
||||
this.imageButton.setOnClickListener(new PropagatingClickListener(ADD_GALLERY));
|
||||
this.cameraButton.setOnClickListener(new PropagatingClickListener(TAKE_PHOTO));
|
||||
this.closeButton.setOnClickListener(new CloseClickListener());
|
||||
this.removeButton.setOnClickListener(new PropagatingClickListener(REMOVE_PHOTO));
|
||||
imageButton.setOnClickListener(new PropagatingClickListener(ADD_GALLERY));
|
||||
cameraButton.setOnClickListener(new PropagatingClickListener(TAKE_PHOTO));
|
||||
closeButton.setOnClickListener(new CloseClickListener());
|
||||
removeButton.setOnClickListener(new PropagatingClickListener(REMOVE_PHOTO));
|
||||
this.recentRail.setListener(new RecentPhotoSelectedListener());
|
||||
if (!includeClear) {
|
||||
this.removeButton.setVisibility(View.GONE);
|
||||
removeButton.setVisibility(View.GONE);
|
||||
ViewUtil.findById(layout, R.id.remove_button_label).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
setContentView(layout);
|
||||
setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
setBackgroundDrawable(new BitmapDrawable());
|
||||
setBackgroundDrawable(new BitmapDrawable(context.getResources(), (Bitmap) null));
|
||||
setAnimationStyle(0);
|
||||
setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
setFocusable(true);
|
||||
|
@ -88,7 +85,7 @@ public class AvatarSelector extends PopupWindow {
|
|||
getContentView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
getContentView().getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
getContentView().getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
|
||||
animateWindowInTranslate(getContentView());
|
||||
}
|
||||
|
@ -167,8 +164,8 @@ public class AvatarSelector extends PopupWindow {
|
|||
}
|
||||
|
||||
public interface AttachmentClickedListener {
|
||||
public void onClick(int type);
|
||||
public void onQuickAttachment(Uri uri);
|
||||
void onClick(int type);
|
||||
void onQuickAttachment(Uri uri);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,10 +53,6 @@ public class AvatarView extends ConstraintLayout {
|
|||
avatarImage.setOnClickListener(listener);
|
||||
}
|
||||
|
||||
public void setAvatarLongClickListener(OnLongClickListener listener) {
|
||||
avatarImage.setOnLongClickListener(listener);
|
||||
}
|
||||
|
||||
public void setSeenRecently(boolean enabled) {
|
||||
seenRecentlyIndicator.setVisibility(enabled? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ public class CircleColorImageView extends AppCompatImageView {
|
|||
int circleColor = Color.WHITE;
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CircleColorImageView, 0, 0);
|
||||
circleColor = typedArray.getColor(R.styleable.CircleColorImageView_circleColor, Color.WHITE);
|
||||
typedArray.recycle();
|
||||
try (TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CircleColorImageView, 0, 0)) {
|
||||
circleColor = typedArray.getColor(R.styleable.CircleColorImageView_circleColor, Color.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
Drawable circle = context.getResources().getDrawable(R.drawable.circle_tintable);
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ComposeText extends AppCompatEditText {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
||||
public InputConnection onCreateInputConnection(@NonNull EditorInfo editorInfo) {
|
||||
InputConnection inputConnection = super.onCreateInputConnection(editorInfo);
|
||||
|
||||
if(Prefs.isEnterSendsEnabled(getContext())) {
|
||||
|
@ -143,7 +143,6 @@ public class ComposeText extends AppCompatEditText {
|
|||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
private static class CommitContentListener implements InputConnectionCompat.OnCommitContentListener {
|
||||
|
||||
private static final String TAG = CommitContentListener.class.getName();
|
||||
|
@ -155,7 +154,7 @@ public class ComposeText extends AppCompatEditText {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
|
||||
public boolean onCommitContent(@NonNull InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
|
||||
if (BuildCompat.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
|
||||
try {
|
||||
inputContentInfo.requestPermission();
|
||||
|
|
|
@ -45,12 +45,9 @@ public class ContactFilterToolbar extends Toolbar {
|
|||
|
||||
searchText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||
|
||||
this.clearToggle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
searchText.setText("");
|
||||
displayTogglingView(null);
|
||||
}
|
||||
this.clearToggle.setOnClickListener(v -> {
|
||||
searchText.setText("");
|
||||
displayTogglingView(null);
|
||||
});
|
||||
|
||||
this.searchText.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -115,19 +112,16 @@ public class ContactFilterToolbar extends Toolbar {
|
|||
private void expandTapArea(final View container, final View child) {
|
||||
final int padding = getResources().getDimensionPixelSize(R.dimen.contact_selection_actions_tap_area);
|
||||
|
||||
container.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Rect rect = new Rect();
|
||||
child.getHitRect(rect);
|
||||
container.post(() -> {
|
||||
Rect rect = new Rect();
|
||||
child.getHitRect(rect);
|
||||
|
||||
rect.top -= padding;
|
||||
rect.left -= padding;
|
||||
rect.right += padding;
|
||||
rect.bottom += padding;
|
||||
rect.top -= padding;
|
||||
rect.left -= padding;
|
||||
rect.right += padding;
|
||||
rect.bottom += padding;
|
||||
|
||||
container.setTouchDelegate(new TouchDelegate(rect, child));
|
||||
}
|
||||
container.setTouchDelegate(new TouchDelegate(rect, child));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,10 @@ public class ConversationItemFooter extends LinearLayout {
|
|||
deliveryStatusView = new DeliveryStatusView(findViewById(R.id.delivery_indicator));
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ConversationItemFooter, 0, 0);
|
||||
textColor = typedArray.getInt(R.styleable.ConversationItemFooter_footer_text_color, getResources().getColor(R.color.core_white));
|
||||
setTextColor(textColor);
|
||||
typedArray.recycle();
|
||||
try (TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ConversationItemFooter, 0, 0)) {
|
||||
textColor = typedArray.getInt(R.styleable.ConversationItemFooter_footer_text_color, getResources().getColor(R.color.core_white));
|
||||
setTextColor(textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
public class ConversationItemThumbnail extends FrameLayout {
|
||||
|
||||
private static final String TAG = ConversationItemThumbnail.class.getSimpleName();
|
||||
|
||||
private static final Paint LIGHT_THEME_OUTLINE_PAINT = new Paint();
|
||||
private static final Paint DARK_THEME_OUTLINE_PAINT = new Paint();
|
||||
public static final double IMAGE_ASPECT_RATIO = 1.0;
|
||||
|
@ -62,20 +60,20 @@ public class ConversationItemThumbnail extends FrameLayout {
|
|||
|
||||
public ConversationItemThumbnail(Context context) {
|
||||
super(context);
|
||||
init(null);
|
||||
init();
|
||||
}
|
||||
|
||||
public ConversationItemThumbnail(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public ConversationItemThumbnail(final Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init(attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init(@Nullable AttributeSet attrs) {
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.conversation_item_thumbnail, this);
|
||||
|
||||
this.thumbnail = findViewById(R.id.conversation_thumbnail_image);
|
||||
|
@ -119,7 +117,7 @@ public class ConversationItemThumbnail extends FrameLayout {
|
|||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
protected void dispatchDraw(@NonNull Canvas canvas) {
|
||||
|
||||
super.dispatchDraw(canvas);
|
||||
|
||||
|
|
|
@ -39,14 +39,12 @@ public class CustomDefaultPreference extends DialogPreference {
|
|||
super(context, attrs);
|
||||
|
||||
int[] attributeNames = new int[]{android.R.attr.inputType, R.attr.custom_pref_toggle};
|
||||
TypedArray attributes = context.obtainStyledAttributes(attrs, attributeNames);
|
||||
|
||||
this.inputType = attributes.getInt(0, 0);
|
||||
this.customPreference = getKey();
|
||||
this.customToggle = attributes.getString(1);
|
||||
this.validator = new CustomDefaultPreferenceDialogFragmentCompat.NullValidator();
|
||||
|
||||
attributes.recycle();
|
||||
try (TypedArray attributes = context.obtainStyledAttributes(attrs, attributeNames)) {
|
||||
this.inputType = attributes.getInt(0, 0);
|
||||
this.customPreference = getKey();
|
||||
this.customToggle = attributes.getString(1);
|
||||
this.validator = new CustomDefaultPreferenceDialogFragmentCompat.NullValidator();
|
||||
}
|
||||
|
||||
setPersistent(false);
|
||||
setDialogLayoutResource(R.layout.custom_default_preference_dialog);
|
||||
|
@ -130,6 +128,7 @@ public class CustomDefaultPreference extends DialogPreference {
|
|||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle instanceState) {
|
||||
Dialog dialog = super.onCreateDialog(instanceState);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.AttrRes;
|
||||
|
@ -19,9 +18,6 @@ import org.thoughtcrime.securesms.util.guava.Optional;
|
|||
|
||||
public class DocumentView extends FrameLayout {
|
||||
|
||||
private static final String TAG = DocumentView.class.getSimpleName();
|
||||
|
||||
private final @NonNull View container;
|
||||
private final @NonNull TextView fileName;
|
||||
private final @NonNull TextView fileSize;
|
||||
|
||||
|
@ -39,7 +35,6 @@ public class DocumentView extends FrameLayout {
|
|||
super(context, attrs, defStyleAttr);
|
||||
inflate(context, R.layout.document_view, this);
|
||||
|
||||
this.container = findViewById(R.id.document_container);
|
||||
this.fileName = findViewById(R.id.file_name);
|
||||
this.fileSize = findViewById(R.id.file_size);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||
import android.graphics.Typeface;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
|
@ -14,6 +14,7 @@ import android.text.style.ForegroundColorSpan;
|
|||
import android.text.style.StyleSpan;
|
||||
import android.text.style.TypefaceSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
@ -22,8 +23,6 @@ import org.thoughtcrime.securesms.util.spans.CenterAlignedRelativeSizeSpan;
|
|||
|
||||
public class FromTextView extends AppCompatTextView {
|
||||
|
||||
private static final String TAG = FromTextView.class.getSimpleName();
|
||||
|
||||
public FromTextView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
@ -59,7 +58,7 @@ public class FromTextView extends AppCompatTextView {
|
|||
profileName.setSpan(new TypefaceSpan("sans-serif-light"), 0, profileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
profileName.setSpan(new ForegroundColorSpan(ResUtil.getColor(getContext(), R.attr.conversation_list_item_subject_color)), 0, profileName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
||||
if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL){
|
||||
if (this.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
|
||||
builder.append(profileName);
|
||||
builder.append(fromSpan);
|
||||
} else {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
|
@ -21,7 +20,6 @@ public class HidingLinearLayout extends LinearLayout {
|
|||
super(context, attrs);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public HidingLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ public class InputPanel extends ConstraintLayout
|
|||
|
||||
quoteAnimator = createHeightAnimator(quoteView, quoteView.getMeasuredHeight(), 0, new AnimationCompleteListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(@NonNull Animator animation) {
|
||||
quoteView.dismiss();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.thoughtcrime.securesms.components;
|
|||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.DisplayMetrics;
|
||||
|
@ -27,8 +26,8 @@ import android.view.Surface;
|
|||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||
|
@ -58,7 +57,6 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat {
|
|||
private final int defaultCustomKeyboardSize;
|
||||
private final int minCustomKeyboardTopMarginPortrait;
|
||||
private final int minCustomKeyboardTopMarginLandscape;
|
||||
private final int minCustomKeyboardTopMarginLandscapeBubble;
|
||||
private final int statusBarHeight;
|
||||
|
||||
private int viewInset;
|
||||
|
@ -82,7 +80,6 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat {
|
|||
defaultCustomKeyboardSize = getResources().getDimensionPixelSize(R.dimen.default_custom_keyboard_size);
|
||||
minCustomKeyboardTopMarginPortrait = getResources().getDimensionPixelSize(R.dimen.min_custom_keyboard_top_margin_portrait);
|
||||
minCustomKeyboardTopMarginLandscape = getResources().getDimensionPixelSize(R.dimen.min_custom_keyboard_top_margin_portrait);
|
||||
minCustomKeyboardTopMarginLandscapeBubble = getResources().getDimensionPixelSize(R.dimen.min_custom_keyboard_top_margin_landscape_bubble);
|
||||
statusBarHeight = ViewUtil.getStatusBarHeight(this);
|
||||
viewInset = getViewInset();
|
||||
}
|
||||
|
|
|
@ -63,18 +63,19 @@ public class RecentPhotoViewRail extends FrameLayout implements LoaderManager.Lo
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
return new RecentPhotosLoader(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor data) {
|
||||
this.recyclerView.setAdapter(new RecentPhotoAdapter(getContext(), data, RecentPhotosLoader.BASE_URL, listener));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
public void onLoaderReset(@NonNull Loader<Cursor> loader) {
|
||||
((CursorRecyclerViewAdapter)this.recyclerView.getAdapter()).changeCursor(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ public class RemovableEditableMediaView extends FrameLayout {
|
|||
private final @NonNull ImageView edit;
|
||||
|
||||
private final int removeSize;
|
||||
private final int editSize;
|
||||
|
||||
private @Nullable View current;
|
||||
|
||||
|
@ -36,7 +35,6 @@ public class RemovableEditableMediaView extends FrameLayout {
|
|||
this.edit = (ImageView)LayoutInflater.from(context).inflate(R.layout.media_view_edit_button, this, false);
|
||||
|
||||
this.removeSize = getResources().getDimensionPixelSize(R.dimen.media_bubble_remove_button_size);
|
||||
this.editSize = getResources().getDimensionPixelSize(R.dimen.media_bubble_edit_button_size);
|
||||
|
||||
this.remove.setVisibility(View.GONE);
|
||||
this.edit.setVisibility(View.GONE);
|
||||
|
@ -69,6 +67,7 @@ public class RemovableEditableMediaView extends FrameLayout {
|
|||
current = view;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public View getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
|
@ -153,7 +154,7 @@ public class SearchToolbar extends LinearLayout {
|
|||
animator.setDuration(400);
|
||||
animator.addListener(new AnimationCompleteListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(@NonNull Animator animation) {
|
||||
setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,7 +3,8 @@ package org.thoughtcrime.securesms.components;
|
|||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatImageButton;
|
||||
|
||||
import org.thoughtcrime.securesms.TransportOption;
|
||||
import org.thoughtcrime.securesms.TransportOptions;
|
||||
|
@ -12,7 +13,7 @@ import org.thoughtcrime.securesms.TransportOptionsPopup;
|
|||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
import org.thoughtcrime.securesms.util.guava.Optional;
|
||||
|
||||
public class SendButton extends ImageButton
|
||||
public class SendButton extends AppCompatImageButton
|
||||
implements TransportOptions.OnTransportChangedListener,
|
||||
TransportOptionsPopup.SelectedListener,
|
||||
View.OnLongClickListener
|
||||
|
|
|
@ -12,6 +12,8 @@ import android.graphics.RectF;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
public class ShapeScrim extends View {
|
||||
|
@ -39,16 +41,15 @@ public class ShapeScrim extends View {
|
|||
super(context, attrs, defStyleAttr);
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ShapeScrim, 0, 0);
|
||||
String shapeName = typedArray.getString(R.styleable.ShapeScrim_shape);
|
||||
try (TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ShapeScrim, 0, 0)) {
|
||||
String shapeName = typedArray.getString(R.styleable.ShapeScrim_shape);
|
||||
|
||||
if ("square".equalsIgnoreCase(shapeName)) this.shape = ShapeType.SQUARE;
|
||||
else if ("circle".equalsIgnoreCase(shapeName)) this.shape = ShapeType.CIRCLE;
|
||||
else this.shape = ShapeType.SQUARE;
|
||||
if ("square".equalsIgnoreCase(shapeName)) this.shape = ShapeType.SQUARE;
|
||||
else if ("circle".equalsIgnoreCase(shapeName)) this.shape = ShapeType.CIRCLE;
|
||||
else this.shape = ShapeType.SQUARE;
|
||||
|
||||
this.radius = typedArray.getFloat(R.styleable.ShapeScrim_radius, 0.4f);
|
||||
|
||||
typedArray.recycle();
|
||||
this.radius = typedArray.getFloat(R.styleable.ShapeScrim_radius, 0.4f);
|
||||
}
|
||||
} else {
|
||||
this.shape = ShapeType.SQUARE;
|
||||
this.radius = 0.4f;
|
||||
|
@ -60,10 +61,10 @@ public class ShapeScrim extends View {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
public void onDraw(@NonNull Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
|
||||
int shortDimension = getWidth() < getHeight() ? getWidth() : getHeight();
|
||||
int shortDimension = Math.min(getWidth(), getHeight());
|
||||
float drawRadius = shortDimension * radius;
|
||||
|
||||
if (scrimCanvas == null) {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
|
@ -21,14 +19,13 @@ public class SquareFrameLayout extends FrameLayout {
|
|||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
@TargetApi(VERSION_CODES.HONEYCOMB)
|
||||
public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SquareFrameLayout, 0, 0);
|
||||
this.squareHeight = typedArray.getBoolean(R.styleable.SquareFrameLayout_square_height, false);
|
||||
typedArray.recycle();
|
||||
try (TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SquareFrameLayout, 0, 0)) {
|
||||
this.squareHeight = typedArray.getBoolean(R.styleable.SquareFrameLayout_square_height, false);
|
||||
}
|
||||
} else {
|
||||
this.squareHeight = false;
|
||||
}
|
||||
|
@ -36,7 +33,6 @@ public class SquareFrameLayout extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
//noinspection SuspiciousNameCombination
|
||||
if (squareHeight) super.onMeasure(heightMeasureSpec, heightMeasureSpec);
|
||||
else super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.preference.CheckBoxPreference;
|
||||
import androidx.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
|
|
|
@ -71,13 +71,13 @@ public class ThumbnailView extends FrameLayout {
|
|||
super.setOnClickListener(new ThumbnailClickDispatcher());
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0);
|
||||
bounds[MIN_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minWidth, 0);
|
||||
bounds[MAX_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxWidth, 0);
|
||||
bounds[MIN_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minHeight, 0);
|
||||
bounds[MAX_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxHeight, 0);
|
||||
// int radius = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_thumbnail_radius, getResources().getDimensionPixelSize(R.dimen.gallery_thumbnail_radius));
|
||||
typedArray.recycle();
|
||||
try (TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0)) {
|
||||
bounds[MIN_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minWidth, 0);
|
||||
bounds[MAX_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxWidth, 0);
|
||||
bounds[MIN_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minHeight, 0);
|
||||
bounds[MAX_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxHeight, 0);
|
||||
// int radius = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_thumbnail_radius, getResources().getDimensionPixelSize(R.dimen.gallery_thumbnail_radius));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ import java.io.ByteArrayInputStream;
|
|||
|
||||
public class WebxdcView extends FrameLayout {
|
||||
|
||||
private static final String TAG = WebxdcView.class.getSimpleName();
|
||||
|
||||
private final @NonNull AppCompatImageView icon;
|
||||
private final @NonNull TextView appName;
|
||||
private final @NonNull TextView appSubtitle;
|
||||
|
@ -46,8 +44,10 @@ public class WebxdcView extends FrameLayout {
|
|||
public WebxdcView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.WebxdcView, 0, 0);
|
||||
boolean compact = a.getBoolean(R.styleable.WebxdcView_compact, false);
|
||||
boolean compact;
|
||||
try (TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.WebxdcView, 0, 0)) {
|
||||
compact = a.getBoolean(R.styleable.WebxdcView_compact, false);
|
||||
}
|
||||
if (compact) {
|
||||
inflate(context, R.layout.webxdc_compact_view, this);
|
||||
} else {
|
||||
|
@ -92,7 +92,7 @@ public class WebxdcView extends FrameLayout {
|
|||
public String getDescription() {
|
||||
String desc = getContext().getString(R.string.webxdc_app);
|
||||
desc += "\n" + appName.getText();
|
||||
if (appSubtitle.getText() != null && !appSubtitle.getText().toString().equals("") && !appSubtitle.getText().toString().equals(getContext().getString(R.string.webxdc_app))) {
|
||||
if (appSubtitle.getText() != null && !appSubtitle.getText().toString().isEmpty() && !appSubtitle.getText().toString().equals(getContext().getString(R.string.webxdc_app))) {
|
||||
desc += "\n" + appSubtitle.getText();
|
||||
}
|
||||
return desc;
|
||||
|
|
|
@ -35,12 +35,12 @@ public class AutoScaledEmojiTextView extends AppCompatTextView {
|
|||
|
||||
public AutoScaledEmojiTextView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.textSize});
|
||||
originalFontSize = ViewUtil.pxToSp(context, typedArray.getDimensionPixelSize(0, 0));
|
||||
if (originalFontSize == 0) {
|
||||
originalFontSize = 16f;
|
||||
try (TypedArray typedArray = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.textSize})) {
|
||||
originalFontSize = ViewUtil.pxToSp(context, typedArray.getDimensionPixelSize(0, 0));
|
||||
if (originalFontSize == 0) {
|
||||
originalFontSize = 16f;
|
||||
}
|
||||
}
|
||||
typedArray.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -53,7 +53,7 @@ public class MediaKeyboard extends FrameLayout implements InputView, Consumer<Em
|
|||
if (emojiPicker == null) {
|
||||
emojiPicker = findViewById(R.id.emoji_picker);
|
||||
emojiPicker.setOnEmojiPickedListener(this);
|
||||
};
|
||||
}
|
||||
setVisibility(VISIBLE);
|
||||
if (keyboardListener != null) keyboardListener.onShown();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.content.Context;
|
|||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.animation.AnimationCompleteListener;
|
||||
|
||||
public class PulsingFloatingActionButton extends FloatingActionButton {
|
||||
|
@ -40,11 +42,11 @@ public class PulsingFloatingActionButton extends FloatingActionButton {
|
|||
|
||||
this.animate().scaleX(1.2f).scaleY(1.2f).setDuration(150).setListener(new AnimationCompleteListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(@NonNull Animator animation) {
|
||||
clearAnimation();
|
||||
animate().scaleX(1.0f).scaleY(1.0f).setDuration(150).setListener(new AnimationCompleteListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void onAnimationEnd(@NonNull Animator animation) {
|
||||
PulsingFloatingActionButton.this.postDelayed(() -> pulse(periodMillis), periodMillis);
|
||||
}
|
||||
}).start();
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
@ -26,6 +27,8 @@ import org.thoughtcrime.securesms.util.Prefs;
|
|||
|
||||
@SuppressLint("BatteryLife")
|
||||
public class DozeReminder {
|
||||
private static final String TAG = DozeReminder.class.getSimpleName();
|
||||
|
||||
public static boolean isEligible(Context context) {
|
||||
if(context==null) {
|
||||
return false;
|
||||
|
@ -58,14 +61,10 @@ public class DozeReminder {
|
|||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Error calling getChatlist()", e);
|
||||
}
|
||||
|
||||
if (isPushAvailableAndSufficient()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // yip, asking for disabling battery optimisations makes sense
|
||||
return !isPushAvailableAndSufficient(); // yip, asking for disabling battery optimisations makes sense
|
||||
}
|
||||
|
||||
public static void addDozeReminderDeviceMsg(Context context) {
|
||||
|
@ -150,7 +149,7 @@ public class DozeReminder {
|
|||
// and no device message will be added.
|
||||
Prefs.setBooleanPreference(context, Prefs.DOZE_ASKED_DIRECTLY, true);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Error in maybeAskDirectly()", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,7 @@ public class AttachmentBitmapDecoder implements ImageDecoder{
|
|||
return new SkiaImageDecoder().decode(context, uri);
|
||||
}
|
||||
|
||||
InputStream inputStream = PartAuthority.getAttachmentStream(context, uri);
|
||||
|
||||
try {
|
||||
try (InputStream inputStream = PartAuthority.getAttachmentStream(context, uri)) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
|
||||
|
||||
|
@ -36,8 +34,6 @@ public class AttachmentBitmapDecoder implements ImageDecoder{
|
|||
}
|
||||
|
||||
return bitmap;
|
||||
} finally {
|
||||
if (inputStream != null) inputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@ import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_VERIFIED_ONE_ON
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.b44t.messenger.DcAccounts;
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
@ -31,7 +32,7 @@ public class AccountManager {
|
|||
|
||||
private void resetDcContext(Context context) {
|
||||
ApplicationContext appContext = (ApplicationContext)context.getApplicationContext();
|
||||
appContext.dcContext = appContext.dcAccounts.getSelectedAccount();
|
||||
appContext.dcContext = ApplicationContext.dcAccounts.getSelectedAccount();
|
||||
DcHelper.setStockTranslations(context);
|
||||
DcHelper.getContext(context).setConfig(CONFIG_VERIFIED_ONE_ON_ONE_CHATS, "1");
|
||||
DirectShareUtil.resetAllShortcuts(appContext);
|
||||
|
@ -52,10 +53,11 @@ public class AccountManager {
|
|||
int selectAccountId = 0;
|
||||
|
||||
File[] files = context.getFilesDir().listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
// old accounts have the pattern "messenger*.db"
|
||||
if (!file.isDirectory() && file.getName().startsWith("messenger") && file.getName().endsWith(".db")) {
|
||||
int accountId = context.dcAccounts.migrateAccount(file.getAbsolutePath());
|
||||
int accountId = ApplicationContext.dcAccounts.migrateAccount(file.getAbsolutePath());
|
||||
if (accountId != 0) {
|
||||
String selName = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getString("curr_account_db_name", "messenger.db");
|
||||
|
@ -67,12 +69,13 @@ public class AccountManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selectAccountId != 0) {
|
||||
context.dcAccounts.selectAccount(selectAccountId);
|
||||
ApplicationContext.dcAccounts.selectAccount(selectAccountId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Error in migrateToDcAccounts()", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +99,7 @@ public class AccountManager {
|
|||
try {
|
||||
id = rpc.addAccount();
|
||||
} catch (RpcException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Error calling rpc.addAccount()", e);
|
||||
}
|
||||
resetDcContext(context);
|
||||
return id;
|
||||
|
|
|
@ -7,12 +7,15 @@ import android.net.Uri;
|
|||
import android.os.ParcelFileDescriptor;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.b44t.messenger.DcContext;
|
||||
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AttachmentsContentProvider extends ContentProvider {
|
||||
|
||||
|
@ -29,8 +32,8 @@ public class AttachmentsContentProvider extends ContentProvider {
|
|||
if the user or another app deletes these files) */
|
||||
|
||||
@Override
|
||||
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
|
||||
DcContext dcContext = DcHelper.getContext(getContext());
|
||||
public ParcelFileDescriptor openFile(Uri uri, @NonNull String mode) throws FileNotFoundException {
|
||||
DcContext dcContext = DcHelper.getContext(Objects.requireNonNull(getContext()));
|
||||
|
||||
// `uri` originally comes from DcHelper.openForViewOrShare() and
|
||||
// looks like `content://chat.delta.attachments/ef39a39/text.txt`
|
||||
|
@ -47,7 +50,7 @@ public class AttachmentsContentProvider extends ContentProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri arg0, String arg1, String[] arg2) {
|
||||
public int delete(@NonNull Uri arg0, String arg1, String[] arg2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -66,7 +69,7 @@ public class AttachmentsContentProvider extends ContentProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri arg0, ContentValues arg1) {
|
||||
public Uri insert(@NonNull Uri arg0, ContentValues arg1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -76,13 +79,13 @@ public class AttachmentsContentProvider extends ContentProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3,
|
||||
public Cursor query(@NonNull Uri arg0, String[] arg1, String arg2, String[] arg3,
|
||||
String arg4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
|
||||
public int update(@NonNull Uri arg0, ContentValues arg1, String arg2, String[] arg3) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import org.thoughtcrime.securesms.util.Util;
|
|||
|
||||
public class DcContactsLoader extends AsyncLoader<DcContactsLoader.Ret> {
|
||||
|
||||
private static final String TAG = DcContactsLoader.class.getName();
|
||||
|
||||
private final int listflags;
|
||||
private final String query;
|
||||
private final boolean addScanQRLink;
|
||||
|
@ -38,7 +36,7 @@ public class DcContactsLoader extends AsyncLoader<DcContactsLoader.Ret> {
|
|||
DcContext dcContext = DcHelper.getContext(getContext());
|
||||
if (blockedContacts) {
|
||||
int[] blocked_ids = dcContext.getBlockedContacts();
|
||||
return new DcContactsLoader.Ret(blocked_ids);
|
||||
return new Ret(blocked_ids);
|
||||
}
|
||||
|
||||
int[] contact_ids = dcContext.getContacts(listflags, query);
|
||||
|
@ -56,13 +54,13 @@ public class DcContactsLoader extends AsyncLoader<DcContactsLoader.Ret> {
|
|||
final boolean broadcastsEnabled = Prefs.isNewBroadcastListAvailable(getContext());
|
||||
if (broadcastsEnabled) additional_items = Util.appendInt(additional_items, DcContact.DC_CONTACT_ID_NEW_BROADCAST_LIST);
|
||||
}
|
||||
int all_ids[] = new int[contact_ids.length + additional_items.length];
|
||||
int[] all_ids = new int[contact_ids.length + additional_items.length];
|
||||
System.arraycopy(additional_items, 0, all_ids, 0, additional_items.length);
|
||||
System.arraycopy(contact_ids, 0, all_ids, additional_items.length, contact_ids.length);
|
||||
return new DcContactsLoader.Ret(all_ids);
|
||||
return new Ret(all_ids);
|
||||
}
|
||||
|
||||
public class Ret {
|
||||
public static class Ret {
|
||||
public final int[] ids;
|
||||
|
||||
Ret(int[] ids) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.ArrayList;
|
|||
import java.util.Hashtable;
|
||||
|
||||
public class DcEventCenter {
|
||||
private static final String TAG = DcEventCenter.class.getSimpleName();
|
||||
private @NonNull final Hashtable<Integer, ArrayList<DcEventDelegate>> currentAccountObservers = new Hashtable<>();
|
||||
private @NonNull final Hashtable<Integer, ArrayList<DcEventDelegate>> multiAccountObservers = new Hashtable<>();
|
||||
private final Object LOCK = new Object();
|
||||
|
@ -104,7 +105,7 @@ public class DcEventCenter {
|
|||
observer.handleEvent(event);
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Error calling observer.handleEvent()", e);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -113,7 +114,7 @@ public class DcEventCenter {
|
|||
observer.handleEvent(event);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Error calling observer.handleEvent()", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -216,9 +217,6 @@ public class DcEventCenter {
|
|||
|
||||
switch (id) {
|
||||
case DcContext.DC_EVENT_ERROR:
|
||||
handleError(id, event.getData2Str());
|
||||
break;
|
||||
|
||||
case DcContext.DC_EVENT_ERROR_SELF_NOT_IN_GROUP:
|
||||
handleError(id, event.getData2Str());
|
||||
break;
|
||||
|
|
|
@ -43,7 +43,7 @@ import java.util.HashMap;
|
|||
|
||||
public class DcHelper {
|
||||
|
||||
private static final String TAG = DcHelper.class.getSimpleName();
|
||||
private static final String TAG = DcHelper.class.getSimpleName();
|
||||
|
||||
public static final String CONFIG_ADDRESS = "addr";
|
||||
public static final String CONFIG_CONFIGURED_ADDRESS = "configured_addr";
|
||||
|
@ -62,10 +62,7 @@ public class DcHelper {
|
|||
public static final String CONFIG_SELF_STATUS = "selfstatus";
|
||||
public static final String CONFIG_SELF_AVATAR = "selfavatar";
|
||||
public static final String CONFIG_E2EE_ENABLED = "e2ee_enabled";
|
||||
public static final String CONFIG_QR_OVERLAY_LOGO = "qr_overlay_logo";
|
||||
public static final String CONFIG_INBOX_WATCH = "inbox_watch";
|
||||
public static final String CONFIG_SENTBOX_WATCH = "sentbox_watch";
|
||||
public static final String CONFIG_MVBOX_WATCH = "mvbox_watch";
|
||||
public static final String CONFIG_MVBOX_MOVE = "mvbox_move";
|
||||
public static final String CONFIG_ONLY_FETCH_MVBOX = "only_fetch_mvbox";
|
||||
public static final String CONFIG_BCC_SELF = "bcc_self";
|
||||
|
@ -442,7 +439,7 @@ public class DcHelper {
|
|||
return true;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ public class DirectShareUtil {
|
|||
try {
|
||||
ShortcutManagerCompat.removeDynamicShortcuts(context, Collections.singletonList(Integer.toString(chatId)));
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Clearing shortcut failed: " + e);
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Clearing shortcut failed", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -66,8 +65,7 @@ public class DirectShareUtil {
|
|||
ShortcutManagerCompat.removeAllDynamicShortcuts(context);
|
||||
triggerRefreshDirectShare(context);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Resetting shortcuts failed: " + e);
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Resetting shortcuts failed", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -153,7 +151,7 @@ public class DirectShareUtil {
|
|||
}
|
||||
|
||||
private static @NonNull Bitmap getShortcutInfoBitmap(@NonNull Context context, @NonNull Recipient recipient) throws ExecutionException, InterruptedException {
|
||||
return DrawableUtil.wrapBitmapForShortcutInfo(request(GlideApp.with(context).asBitmap(), context, recipient, false).circleCrop().submit().get());
|
||||
return DrawableUtil.wrapBitmapForShortcutInfo(request(GlideApp.with(context).asBitmap(), context, recipient).circleCrop().submit().get());
|
||||
}
|
||||
|
||||
private static Bitmap getFallbackDrawable(Context context, @NonNull Recipient recipient) {
|
||||
|
@ -162,7 +160,7 @@ public class DirectShareUtil {
|
|||
context.getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height));
|
||||
}
|
||||
|
||||
private static <T> GlideRequest<T> request(@NonNull GlideRequest<T> glideRequest, @NonNull Context context, @NonNull Recipient recipient, boolean loadSelf) {
|
||||
private static <T> GlideRequest<T> request(@NonNull GlideRequest<T> glideRequest, @NonNull Context context, @NonNull Recipient recipient) {
|
||||
final ContactPhoto photo;
|
||||
photo = recipient.getContactPhoto(context);
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.app.Application;
|
|||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
|
@ -34,7 +36,7 @@ public class ForegroundDetector implements Application.ActivityLifecycleCallback
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(Activity activity) {
|
||||
public void onActivityStarted(@NonNull Activity activity) {
|
||||
if (refs == 0) {
|
||||
Log.i("DeltaChat", "++++++++++++++++++ first ForegroundDetector.onActivityStarted() ++++++++++++++++++");
|
||||
DcHelper.getAccounts(application).startIo();
|
||||
|
@ -52,7 +54,7 @@ public class ForegroundDetector implements Application.ActivityLifecycleCallback
|
|||
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(Activity activity) {
|
||||
public void onActivityStopped(@NonNull Activity activity) {
|
||||
if( refs <= 0 ) {
|
||||
Log.w("DeltaChat", "invalid call to ForegroundDetector.onActivityStopped()");
|
||||
return;
|
||||
|
@ -66,23 +68,23 @@ public class ForegroundDetector implements Application.ActivityLifecycleCallback
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
public void onActivityCreated(@NonNull Activity activity, Bundle savedInstanceState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
public void onActivityResumed(@NonNull Activity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
public void onActivityPaused(@NonNull Activity activity) {
|
||||
// pause/resume will also be called when the app is partially covered by a dialog
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import org.thoughtcrime.securesms.util.Prefs;
|
|||
|
||||
public class KeepAliveService extends Service {
|
||||
|
||||
private static final String TAG = KeepAliveService.class.getSimpleName();
|
||||
|
||||
static KeepAliveService s_this = null;
|
||||
|
||||
public static void maybeStartSelf(Context context) {
|
||||
|
@ -40,7 +42,7 @@ public class KeepAliveService extends Service {
|
|||
ContextCompat.startForegroundService(context, new Intent(context, KeepAliveService.class));
|
||||
}
|
||||
catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.i(TAG, "Error calling ContextCompat.startForegroundService()", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +59,7 @@ public class KeepAliveService extends Service {
|
|||
startForeground(NotificationCenter.ID_PERMANENT, createNotification());
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.i(TAG, "Error in onCreate()", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.util.Log;
|
|||
|
||||
public class NetworkStateReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = NetworkStateReceiver.class.getSimpleName();
|
||||
private int debugConnectedCount;
|
||||
|
||||
@Override
|
||||
|
@ -35,7 +36,7 @@ public class NetworkStateReceiver extends BroadcastReceiver {
|
|||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.i(TAG, "Error in onReceive()", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue