Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 2 additions & 32 deletions app/src/main/java/org/thunderdog/challegram/FillingDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
Expand All @@ -41,9 +40,6 @@ public class FillingDrawable extends Drawable {
private ThemeDelegate forcedTheme;

private float cornerRadius;
private float topCornerRadius;
private float bottomCornerRadius;
private Path roundedPath;

public FillingDrawable (int colorId) {
this.colorId = colorId;
Expand All @@ -54,12 +50,6 @@ public FillingDrawable (int colorId, float radius) {
this.cornerRadius = radius;
}

public FillingDrawable (int colorId, float topRadius, float bottomRadius) {
this.colorId = colorId;
this.topCornerRadius = topRadius;
this.bottomCornerRadius = bottomRadius;
}

public final void setForcedTheme (ThemeDelegate forcedTheme) {
if (this.forcedTheme != forcedTheme) {
this.forcedTheme = forcedTheme;
Expand All @@ -68,10 +58,8 @@ public final void setForcedTheme (ThemeDelegate forcedTheme) {
}

public void setCornerRadius (float radius) {
if (this.cornerRadius != radius || topCornerRadius != 0 || bottomCornerRadius != 0) {
if (this.cornerRadius != radius) {
this.cornerRadius = radius;
this.topCornerRadius = 0;
this.bottomCornerRadius = 0;
invalidateSelf();
}
}
Expand Down Expand Up @@ -102,25 +90,7 @@ protected int getFillingColor () {
@Override
public final void draw (@NonNull Canvas c) {
if (colorId != 0) {
if (topCornerRadius != 0 || bottomCornerRadius != 0) {
RectF rectF = Paints.getRectF();
rectF.set(getBounds());
float topRadius = Screen.dp(topCornerRadius);
float bottomRadius = Screen.dp(bottomCornerRadius);
float[] radii = {
topRadius, topRadius,
topRadius, topRadius,
bottomRadius, bottomRadius,
bottomRadius, bottomRadius
};
if (roundedPath == null) {
roundedPath = new Path();
} else {
roundedPath.reset();
}
roundedPath.addRoundRect(rectF, radii, Path.Direction.CW);
c.drawPath(roundedPath, Paints.fillingPaint(getFillingColor()));
} else if (cornerRadius != 0) {
if (cornerRadius != 0) {
RectF rectF = Paints.getRectF();
rectF.set(getBounds());
float radius = Screen.dp(cornerRadius);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import org.thunderdog.challegram.theme.PorterDuffColorId;
import org.thunderdog.challegram.theme.Theme;
import org.thunderdog.challegram.tool.Drawables;
import org.thunderdog.challegram.tool.FrogramUi;
import org.thunderdog.challegram.tool.Paints;
import org.thunderdog.challegram.tool.PorterDuffPaint;
import org.thunderdog.challegram.tool.Screen;
Expand Down Expand Up @@ -168,13 +167,13 @@ public void setType (int type) {
}
case TYPE_RADIO: {
addToggler();
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(FrogramUi.SETTING_ROW_HEIGHT)));
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(55f)));
break;
}
case TYPE_SETTING:
case TYPE_SETTING_INACTIVE:
case TYPE_INFO_SUPERCOMPACT: {
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(FrogramUi.SETTING_ROW_HEIGHT)));
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(55f)));
break;
}
default: {
Expand Down Expand Up @@ -317,7 +316,7 @@ public int getForcedPaddingRight () {
}

private int measurePaddingLeft () {
return forcedPaddingLeft != 0 ? forcedPaddingLeft : Screen.dp(icon == null ? FrogramUi.CONTENT_HORIZONTAL_PADDING : FrogramUi.SETTING_ICON_TEXT_START);
return forcedPaddingLeft != 0 ? forcedPaddingLeft : Screen.dp(icon == null ? 16f : 73f);
}

@SuppressWarnings ("Range")
Expand Down Expand Up @@ -567,7 +566,7 @@ private void buildLayout (int totalWidth, int totalHeight) {
lastMeasuredHeight = totalHeight;

int paddingLeft = measurePaddingLeft();
int paddingRight = Screen.dp(FrogramUi.CONTENT_HORIZONTAL_PADDING) + forcedPaddingRight;
int paddingRight = Screen.dp(17f) + forcedPaddingRight;

pLeft = paddingLeft;

Expand Down Expand Up @@ -637,7 +636,7 @@ private void buildLayout (int totalWidth, int totalHeight) {
}

pIconTop = (flags & FLAG_CENTER_ICON) != 0 && icon != null ? (totalHeight / 2f - icon.getMinimumHeight() / 2f) : Screen.dp(type == TYPE_INFO || type == TYPE_INFO_COMPACT || type == TYPE_INFO_MULTILINE ? 20f : 16f);
pIconLeft = Screen.dp(FrogramUi.CONTENT_HORIZONTAL_PADDING);
pIconLeft = Screen.dp(18f);
}

private boolean subscribedToEmojiUpdates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void setItems (Item... items) {
button.setBackgroundResource(R.drawable.bg_btn_header);
button.setOnClickListener(item.onClickListener);
CharSequence text = item.text != null ? item.text : Lang.getString(item.stringRes);
Views.setMediumText(button, text);
Views.setMediumText(button, item.noUppercase ? text : text.toString().toUpperCase());
Views.setClickable(button);
button.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f));
actionsList.addView(button);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static int getTextOffset () {
}

public static int getAvatarLeft (int chatListMode) {
return Screen.dp(/*inMultiLineMode ? 6f : */10f);
return Screen.dp(/*inMultiLineMode ? 6f : */7f);
}

public static int getAvatarRadius (int chatListMode) {
Expand Down Expand Up @@ -226,7 +226,7 @@ public static int getViewHeight (int chatListMode) {
return Screen.dp(78f);
case Settings.CHAT_MODE_2LINE:
default:
return Screen.dp(76f);
return Screen.dp(72f);
}
}

Expand All @@ -238,7 +238,7 @@ public static float getAvatarSizeDp (int chatListMode) {
return 58f;
case Settings.CHAT_MODE_2LINE:
default:
return 54f;
return 52f;
}
}

Expand All @@ -253,7 +253,7 @@ private static int getAvatarTop (int chatListMode) {
case Settings.CHAT_MODE_3LINE:
case Settings.CHAT_MODE_2LINE:
default:
return Screen.dp(11f);
return Screen.dp(10f);
}
}

Expand All @@ -269,7 +269,7 @@ private static int getCounterOffset (int chatsListMode) {
return Screen.dp(44f);
case Settings.CHAT_MODE_2LINE:
default:
return Screen.dp(40f);
return Screen.dp(38f);
}
}

Expand All @@ -285,7 +285,7 @@ public static int getTextTop (int chatListMode) {
return Screen.dp(33f);
case Settings.CHAT_MODE_2LINE:
default:
return Screen.dp(41.5f);
return Screen.dp(39.5f);
}
}

Expand All @@ -300,7 +300,7 @@ public static int getTitleTop (int chatListMode) {
return getTextOffset() + Screen.dp(14f);
case Settings.CHAT_MODE_2LINE:
default:
return getTextOffset() + Screen.dp(18f);
return getTextOffset() + Screen.dp(16f);
}
}

Expand All @@ -311,7 +311,7 @@ private static int getClockTop (int chatListMode) {
return Screen.dp(15f);
case Settings.CHAT_MODE_2LINE:
default:
return Screen.dp(19f);
return Screen.dp(17f);
}
}

Expand All @@ -322,7 +322,7 @@ private static int getMuteTop (int chatListMode) {
return Screen.dp(9f);
case Settings.CHAT_MODE_2LINE:
default:
return Screen.dp(13f);
return Screen.dp(11f);
}
}

Expand All @@ -333,7 +333,7 @@ public static int getTitleTop2 (int chatListMode) {
return Screen.dp(10f);
case Settings.CHAT_MODE_2LINE:
default:
return Screen.dp(14f);
return Screen.dp(12f);
}
}

Expand Down Expand Up @@ -573,10 +573,6 @@ protected void onDraw (Canvas c) {
boolean rtl = Lang.rtl();
int viewWidth = getMeasuredWidth();

float selectedFactor = isSelected.getFloatValue();
if (selectedFactor > 0f) {
c.drawColor(ColorUtils.alphaColor(selectedFactor, Theme.getColor(ColorId.fillingActive)));
}
if (isDragging) {
c.drawColor(ColorUtils.alphaColor(.8f, Theme.fillingColor()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ public TextView genTextTitle (Context context) {
text.setGravity(Gravity.LEFT);
text.setSingleLine();
text.setEllipsize(TextUtils.TruncateAt.END);
text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20f);
text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 19f);
text.setTextColor(0xffffffff);
text.setLayoutParams(params);
return text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
Expand All @@ -31,20 +33,19 @@

import androidx.annotation.Nullable;

import org.thunderdog.challegram.FillingDrawable;
import org.thunderdog.challegram.R;
import org.thunderdog.challegram.core.Lang;
import org.thunderdog.challegram.loader.AvatarReceiver;
import org.thunderdog.challegram.loader.ComplexReceiver;
import org.thunderdog.challegram.support.RippleSupport;
import org.thunderdog.challegram.support.ViewSupport;
import org.thunderdog.challegram.telegram.Tdlib;
import org.thunderdog.challegram.theme.ColorId;
import org.thunderdog.challegram.theme.Theme;
import org.thunderdog.challegram.theme.ThemeDelegate;
import org.thunderdog.challegram.theme.ThemeListenerList;
import org.thunderdog.challegram.tool.Drawables;
import org.thunderdog.challegram.tool.Fonts;
import org.thunderdog.challegram.tool.FrogramUi;
import org.thunderdog.challegram.tool.Paints;
import org.thunderdog.challegram.tool.PorterDuffPaint;
import org.thunderdog.challegram.tool.Screen;
Expand Down Expand Up @@ -121,18 +122,20 @@ public void init (@Nullable ThemeListenerList themeProvider, @Nullable ThemeDele
this.forcedTheme = forcedTheme;

setMinimumWidth(Screen.dp(196f));
FillingDrawable drawable = new FillingDrawable(ColorId.overlayFilling, FrogramUi.POPUP_RADIUS);
drawable.setForcedTheme(forcedTheme);
Drawable drawable;
if (forcedTheme != null) {
drawable = ViewSupport.getDrawableFilter(getContext(), R.drawable.bg_popup_fixed, new PorterDuffColorFilter(forcedTheme.getColor(ColorId.overlayFilling), PorterDuff.Mode.MULTIPLY));
} else {
drawable = ViewSupport.getDrawableFilter(getContext(), R.drawable.bg_popup_fixed, new PorterDuffColorFilter(Theme.headerFloatBackgroundColor(), PorterDuff.Mode.MULTIPLY));
}
ViewUtils.setBackground(this, drawable);

if (themeProvider != null && forcedTheme == null) {
themeProvider.addThemeSpecialFilterListener(drawable, ColorId.overlayFilling);
themeProvider.addThemeInvalidateListener(this);
}

setOrientation(VERTICAL);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
setElevation(Screen.dp(8f));
}
setLayerType(LAYER_TYPE_HARDWARE, Views.getLayerPaint());
setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | (Lang.rtl() ? Gravity.LEFT : Gravity.RIGHT)));
}
Expand Down Expand Up @@ -380,8 +383,8 @@ public TextView addItem (int id, CharSequence title, int iconRes, Drawable icon,
menuItem.setEllipsize(TextUtils.TruncateAt.END);
menuItem.setOnClickListener(listener);
menuItem.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(ITEM_HEIGHT)));
menuItem.setPadding(Screen.dp(FrogramUi.CONTENT_HORIZONTAL_PADDING), 0, Screen.dp(FrogramUi.CONTENT_HORIZONTAL_PADDING), 0);
menuItem.setCompoundDrawablePadding(Screen.dp(16f));
menuItem.setPadding(Screen.dp(17f), 0, Screen.dp(17f), 0);
menuItem.setCompoundDrawablePadding(Screen.dp(18f));
icon = iconRes != 0 ? Drawables.get(getResources(), iconRes) : icon;
if (icon != null) {
if (forcedTheme != null) {
Expand Down Expand Up @@ -554,4 +557,4 @@ protected void onDetachedFromWindow () {
super.onDetachedFromWindow();
complexAvatarReceiver.detach();
}
}
}
Loading