mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 04:25:18 +00:00
Lint - Custom Widgets extend Appcompat Widgets.
This commit is contained in:
parent
9445555d66
commit
88dac70087
@ -3,15 +3,14 @@ package org.thoughtcrime.securesms.components;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
|
|
||||||
public class CircleColorImageView extends ImageView {
|
public class CircleColorImageView extends AppCompatImageView {
|
||||||
|
|
||||||
public CircleColorImageView(Context context) {
|
public CircleColorImageView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
|
@ -4,12 +4,12 @@ import android.content.Context;
|
|||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
|
|
||||||
public class ImageDivet extends ImageView {
|
public class ImageDivet extends AppCompatImageView {
|
||||||
private static final float CORNER_OFFSET = 12F;
|
private static final float CORNER_OFFSET = 12F;
|
||||||
private static final String[] POSITIONS = new String[] {"bottom_right"};
|
private static final String[] POSITIONS = new String[] {"bottom_right"};
|
||||||
|
|
||||||
@ -84,10 +84,6 @@ public class ImageDivet extends ImageView {
|
|||||||
return CORNER_OFFSET * density;
|
return CORNER_OFFSET * density;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageView asImageView() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getFarOffset() {
|
public float getFarOffset() {
|
||||||
return getCloseOffset() + drawableIntrinsicHeight;
|
return getCloseOffset() + drawableIntrinsicHeight;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
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.VERSION;
|
import android.support.v7.widget.AppCompatImageButton;
|
||||||
import android.os.Build.VERSION_CODES;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
|
|
||||||
public class RepeatableImageKey extends ImageButton {
|
public class RepeatableImageKey extends AppCompatImageButton {
|
||||||
|
|
||||||
private KeyEventListener listener;
|
private KeyEventListener listener;
|
||||||
|
|
||||||
@ -32,14 +27,6 @@ public class RepeatableImageKey extends ImageButton {
|
|||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(VERSION_CODES.LOLLIPOP)
|
|
||||||
public RepeatableImageKey(Context context, AttributeSet attrs, int defStyleAttr,
|
|
||||||
int defStyleRes)
|
|
||||||
{
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
setOnClickListener(new RepeaterClickListener());
|
setOnClickListener(new RepeaterClickListener());
|
||||||
setOnTouchListener(new RepeaterTouchListener());
|
setOnTouchListener(new RepeaterTouchListener());
|
||||||
@ -60,31 +47,25 @@ public class RepeatableImageKey extends ImageButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Repeater implements Runnable {
|
private class Repeater implements Runnable {
|
||||||
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
notifyListener();
|
notifyListener();
|
||||||
postDelayed(this, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
|
postDelayed(this, ViewConfiguration.getKeyRepeatDelay());
|
||||||
? ViewConfiguration.getKeyRepeatDelay()
|
|
||||||
: 50);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RepeaterTouchListener implements OnTouchListener {
|
private class RepeaterTouchListener implements OnTouchListener {
|
||||||
private Repeater repeater;
|
private final Repeater repeater;
|
||||||
|
|
||||||
public RepeaterTouchListener() {
|
RepeaterTouchListener() {
|
||||||
this.repeater = new Repeater();
|
this.repeater = new Repeater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
switch (motionEvent.getAction()) {
|
switch (motionEvent.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
view.postDelayed(repeater, VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1
|
view.postDelayed(repeater, ViewConfiguration.getKeyRepeatTimeout());
|
||||||
? ViewConfiguration.getKeyRepeatTimeout()
|
|
||||||
: ViewConfiguration.getLongPressTimeout());
|
|
||||||
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
|
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
|
||||||
return false;
|
return false;
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
|
@ -2,9 +2,9 @@ package org.thoughtcrime.securesms.components;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v7.widget.AppCompatImageButton;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageButton;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
import org.thoughtcrime.securesms.TransportOption;
|
||||||
import org.thoughtcrime.securesms.TransportOptions;
|
import org.thoughtcrime.securesms.TransportOptions;
|
||||||
@ -13,7 +13,7 @@ import org.thoughtcrime.securesms.TransportOptionsPopup;
|
|||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.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
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
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 android.support.v7.widget.AppCompatImageView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
public class SquareImageView extends ImageView {
|
public class SquareImageView extends AppCompatImageView {
|
||||||
public SquareImageView(Context context) {
|
public SquareImageView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
@ -19,13 +17,9 @@ public class SquareImageView extends ImageView {
|
|||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
//noinspection SuspiciousNameCombination
|
||||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package org.thoughtcrime.securesms.components.emoji;
|
package org.thoughtcrime.securesms.components.emoji;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.support.v7.widget.AppCompatImageButton;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageButton;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer.EmojiDrawerListener;
|
import org.thoughtcrime.securesms.components.emoji.EmojiDrawer.EmojiDrawerListener;
|
||||||
|
|
||||||
public class EmojiToggle extends ImageButton implements EmojiDrawerListener {
|
public class EmojiToggle extends AppCompatImageButton implements EmojiDrawerListener {
|
||||||
|
|
||||||
private Drawable emojiToggle;
|
private Drawable emojiToggle;
|
||||||
private Drawable imeToggle;
|
private Drawable imeToggle;
|
||||||
|
@ -18,15 +18,14 @@
|
|||||||
package org.thoughtcrime.securesms.giph.ui;
|
package org.thoughtcrime.securesms.giph.ui;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AspectRatioImageView maintains an aspect ratio by adjusting the width or height dimension. The
|
* AspectRatioImageView maintains an aspect ratio by adjusting the width or height dimension. The
|
||||||
* aspect ratio (width to height ratio) and adjustment dimension can be configured.
|
* aspect ratio (width to height ratio) and adjustment dimension can be configured.
|
||||||
*/
|
*/
|
||||||
public class AspectRatioImageView extends ImageView {
|
public class AspectRatioImageView extends AppCompatImageView {
|
||||||
|
|
||||||
private static final float DEFAULT_ASPECT_RATIO = 1.0f;
|
private static final float DEFAULT_ASPECT_RATIO = 1.0f;
|
||||||
private static final int DEFAULT_ADJUST_DIMENSION = 0;
|
private static final int DEFAULT_ADJUST_DIMENSION = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user