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