mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 11:25:13 +01:00
Refactoring
This commit is contained in:
@@ -20,14 +20,10 @@ package eu.faircode.email;
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.DynamicDrawableSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
@@ -46,8 +42,6 @@ import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class PopupMenuLifecycle extends PopupMenu implements LifecycleObserver {
|
||||
|
||||
public PopupMenuLifecycle(@NonNull Context context, LifecycleOwner owner, @NonNull View anchor) {
|
||||
@@ -146,46 +140,4 @@ public class PopupMenuLifecycle extends PopupMenu implements LifecycleObserver {
|
||||
menuItem.setTitle(ssb);
|
||||
menuItem.setIcon(null);
|
||||
}
|
||||
|
||||
private static class CenteredImageSpan extends ImageSpan {
|
||||
public CenteredImageSpan(final Drawable drawable) {
|
||||
this(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
|
||||
}
|
||||
|
||||
public CenteredImageSpan(final Drawable drawable, final int verticalAlignment) {
|
||||
super(drawable, verticalAlignment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas, CharSequence text,
|
||||
int start, int end, float x,
|
||||
int top, int y, int bottom, @NonNull Paint paint) {
|
||||
getDrawable().draw(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize(@NonNull Paint paint, CharSequence text,
|
||||
int start, int end,
|
||||
@Nullable Paint.FontMetricsInt fm) {
|
||||
Drawable d = getDrawable();
|
||||
Rect rect = d.getBounds();
|
||||
|
||||
if (fm != null) {
|
||||
int descent = 0;
|
||||
int padding = 0;
|
||||
if (rect.bottom - (fm.descent - fm.ascent) >= 0) {
|
||||
descent = fm.descent;
|
||||
padding = rect.bottom - (fm.descent - fm.ascent);
|
||||
}
|
||||
|
||||
fm.descent = padding / 2 + descent;
|
||||
fm.bottom = fm.descent;
|
||||
|
||||
fm.ascent = -rect.bottom + fm.descent;
|
||||
fm.top = fm.ascent;
|
||||
}
|
||||
|
||||
return rect.right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user