From b7fe41cf17d6b2ecf9cc857f03c7d3149ef93cc2 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:18:28 +0200 Subject: [PATCH 01/12] improve --- .gitignore | 3 +- .../challegram/component/chat/TopBarView.java | 95 ++++++++++++++----- .../challegram/ui/MessagesController.java | 6 +- 3 files changed, 75 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 8db2f09ab7..2116bdd399 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ obj /captures /local.properties -libc++_shared.so \ No newline at end of file +libc++_shared.so +signing.properties diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index bc776ebf8f..a6887818f6 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -12,6 +12,7 @@ */ package org.thunderdog.challegram.component.chat; +import android.annotation.SuppressLint; import android.content.Context; import android.text.TextUtils; import android.view.Gravity; @@ -24,6 +25,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageView; import org.thunderdog.challegram.R; import org.thunderdog.challegram.core.Lang; @@ -38,34 +40,42 @@ public class TopBarView extends FrameLayoutFix { private final ImageView topDismissButton; - private final LinearLayout actionsList; + private final LinearLayout actionsContainer; + private final TextView additionalTextView; + private LinearLayout actionsList; private boolean canDismiss; public interface DismissListener { - void onDismissRequest (TopBarView barView); + void onDismissRequest(TopBarView barView); } public static class Item { final int id; final int stringRes; + final int iconResId; final View.OnClickListener onClickListener; boolean isNegative; boolean noDismiss; - public Item (int id, int stringRes, View.OnClickListener onClickListener) { + public Item(int id, int stringRes, int iconResId, View.OnClickListener onClickListener) { this.id = id; this.stringRes = stringRes; + this.iconResId = iconResId; this.onClickListener = onClickListener; } - public Item setIsNegative () { + public Item(int id, int stringRes, View.OnClickListener onClickListener) { + this(id, stringRes, 0, onClickListener); + } + + public Item setIsNegative() { this.isNegative = true; return this; } - public Item setNoDismiss () { + public Item setNoDismiss() { this.noDismiss = true; return this; } @@ -73,20 +83,26 @@ public Item setNoDismiss () { private DismissListener dismissListener; - public TopBarView (@NonNull Context context) { + public TopBarView(@NonNull Context context) { super(context); setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(36f))); ViewSupport.setThemedBackground(this, ColorId.filling, null); + actionsContainer = new LinearLayout(context); + actionsContainer.setOrientation(LinearLayout.VERTICAL); + actionsContainer.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(40f), Lang.gravity() | Gravity.TOP)); + addView(actionsContainer); + actionsList = new LinearLayout(context); actionsList.setOrientation(LinearLayout.HORIZONTAL); actionsList.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Lang.gravity() | Gravity.TOP)); - addView(actionsList); + actionsContainer.addView(actionsList); - topDismissButton = new ImageView(context) { + topDismissButton = new AppCompatImageView(context) { + @SuppressLint("ClickableViewAccessibility") @Override - public boolean onTouchEvent (MotionEvent event) { + public boolean onTouchEvent(MotionEvent event) { return Views.isValid(this) && super.onTouchEvent(event); } }; @@ -98,20 +114,27 @@ public boolean onTouchEvent (MotionEvent event) { topDismissButton.setScaleType(ImageView.ScaleType.CENTER); topDismissButton.setColorFilter(Theme.iconColor()); topDismissButton.setImageResource(R.drawable.baseline_close_18); - topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, Lang.gravity() | Gravity.TOP)); + topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, Gravity.END | Gravity.TOP)); topDismissButton.setBackgroundResource(R.drawable.bg_btn_header); Views.setClickable(topDismissButton); topDismissButton.setVisibility(View.INVISIBLE); addView(topDismissButton); + + additionalTextView = new TextView(context); + additionalTextView.setVisibility(View.GONE); + additionalTextView.setGravity(Gravity.CENTER); + additionalTextView.setTextColor(Theme.getColor(ColorId.textNeutral)); + additionalTextView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); + actionsContainer.addView(additionalTextView); } - public void setDismissListener (DismissListener dismissListener) { + public void setDismissListener(DismissListener dismissListener) { this.dismissListener = dismissListener; } private @Nullable ViewController themeProvider; - public void addThemeListeners (@Nullable ViewController themeProvider) { + public void addThemeListeners(@Nullable ViewController themeProvider) { this.themeProvider = themeProvider; if (themeProvider != null) { themeProvider.addThemeFilterListener(topDismissButton, ColorId.icon); @@ -119,14 +142,15 @@ public void addThemeListeners (@Nullable ViewController themeProvider) { } } - public void setCanDismiss (boolean canDismiss) { + public void setCanDismiss(boolean canDismiss) { if (this.canDismiss != canDismiss) { this.canDismiss = canDismiss; topDismissButton.setVisibility(canDismiss ? View.VISIBLE : View.GONE); } } - public void setItems (Item... items) { + public void setItems(Item... items) { + actionsList = (LinearLayout) actionsContainer.getChildAt(0); for (int i = 0; i < actionsList.getChildCount(); i++) { View view = actionsList.getChildAt(i); if (view != null && themeProvider != null) { @@ -145,19 +169,34 @@ public void setItems (Item... items) { canDismiss = true; } int textColorId = item.isNegative ? ColorId.textNegative : ColorId.textNeutral; - TextView button = Views.newTextView(getContext(), 15f, Theme.getColor(textColorId), Gravity.CENTER, Views.TEXT_FLAG_BOLD | Views.TEXT_FLAG_HORIZONTAL_PADDING); - button.setId(item.id); + + LinearLayout buttonLayout = new LinearLayout(getContext()); + buttonLayout.setOrientation(LinearLayout.HORIZONTAL); + buttonLayout.setGravity(Gravity.CENTER); + buttonLayout.setBackgroundResource(R.drawable.bg_btn_header); + buttonLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); + Views.setClickable(buttonLayout); + + if (item.iconResId != 0) { + ImageView iconView = new ImageView(getContext()); + iconView.setImageResource(item.iconResId); + iconView.setColorFilter(Theme.getColor(textColorId)); + iconView.setLayoutParams(new LinearLayout.LayoutParams(Screen.dp(24f), Screen.dp(24f))); // Increased icon size + buttonLayout.addView(iconView); + } + + TextView buttonText = Views.newTextView(getContext(), 15f, Theme.getColor(textColorId), Gravity.CENTER, Views.TEXT_FLAG_BOLD | Views.TEXT_FLAG_HORIZONTAL_PADDING); // Increased text size + buttonText.setId(item.id); if (themeProvider != null) { - themeProvider.addThemeTextColorListener(button, textColorId); + themeProvider.addThemeTextColorListener(buttonText, textColorId); } - button.setEllipsize(TextUtils.TruncateAt.END); - button.setSingleLine(true); - button.setBackgroundResource(R.drawable.bg_btn_header); - button.setOnClickListener(item.onClickListener); - Views.setMediumText(button, Lang.getString(item.stringRes).toUpperCase()); - Views.setClickable(button); - button.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); - actionsList.addView(button); + buttonText.setEllipsize(TextUtils.TruncateAt.END); + buttonText.setSingleLine(true); + buttonText.setText(Lang.getString(item.stringRes).toUpperCase()); + buttonText.setOnClickListener(item.onClickListener); + + buttonLayout.addView(buttonText); + actionsList.addView(buttonLayout); } if (items.length > 1) { View offsetView = new View(getContext()); @@ -165,5 +204,11 @@ public void setItems (Item... items) { actionsList.addView(offsetView); } setCanDismiss(canDismiss); + additionalTextView.setVisibility(items.length == 0 && !TextUtils.isEmpty(additionalTextView.getText()) ? View.VISIBLE : View.GONE); + } + + public void setAdditionalText(String text) { + additionalTextView.setText(text); + additionalTextView.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE); } } diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index a0a39645de..eaaea864f9 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -8040,13 +8040,13 @@ private boolean needActionBar () { } private TopBarView.Item newAddContactItem (long chatId) { - return new TopBarView.Item(R.id.btn_addContact, R.string.AddContact, v -> { + return new TopBarView.Item(R.id.btn_addContact, R.string.AddContact, R.drawable.baseline_person_add_24, v -> { tdlib.ui().addContact(this, tdlib.chatUser(chatId)); }); } private TopBarView.Item newUnarchiveItem (long chatId) { - return new TopBarView.Item(R.id.btn_unarchiveChat, R.string.UnarchiveUnmute, v -> { + return new TopBarView.Item(R.id.btn_unarchiveChat, R.string.UnarchiveUnmute, R.drawable.baseline_unarchive_24, v -> { tdlib.client().send(new TdApi.AddChatToList(chatId, new TdApi.ChatListMain()), tdlib.okHandler()); TdApi.ChatNotificationSettings settings = tdlib.chatSettings(chatId); if (settings != null) { @@ -8066,7 +8066,7 @@ private TopBarView.Item newUnarchiveItem (long chatId) { } private TopBarView.Item newReportItem (long chatId, boolean isBlock) { - return new TopBarView.Item(R.id.btn_reportChat, isBlock ? R.string.BlockContact : R.string.ReportSpam, v -> { + return new TopBarView.Item(R.id.btn_reportChat, isBlock ? R.string.BlockContact : R.string.ReportSpam, isBlock ? R.drawable.baseline_block_24 : R.drawable.baseline_report_24, v -> { showSettings(new SettingsWrapBuilder(R.id.btn_reportSpam) .setHeaderItem(new ListItem(ListItem.TYPE_INFO, 0, 0, Lang.getStringBold(R.string.ReportChatSpam, chat.title), false)) .setRawItems(getChatUserId() != 0 ? new ListItem[] { From 6f6920db119897c320e1867d2a89f1e929e08bbf Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Wed, 31 Jul 2024 19:53:11 +0200 Subject: [PATCH 02/12] indent fixes --- .gitignore | 2 +- .../challegram/component/chat/TopBarView.java | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 2116bdd399..6b2b89eae9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,4 @@ obj /local.properties libc++_shared.so -signing.properties + diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index a6887818f6..3b2c79977e 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -47,7 +47,7 @@ public class TopBarView extends FrameLayoutFix { private boolean canDismiss; public interface DismissListener { - void onDismissRequest(TopBarView barView); + void onDismissRequest (TopBarView barView); } public static class Item { @@ -70,12 +70,12 @@ public Item(int id, int stringRes, View.OnClickListener onClickListener) { this(id, stringRes, 0, onClickListener); } - public Item setIsNegative() { + public Item setIsNegative () { this.isNegative = true; return this; } - public Item setNoDismiss() { + public Item setNoDismiss () { this.noDismiss = true; return this; } @@ -83,7 +83,7 @@ public Item setNoDismiss() { private DismissListener dismissListener; - public TopBarView(@NonNull Context context) { + public TopBarView (@NonNull Context context) { super(context); setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(36f))); @@ -102,7 +102,7 @@ public TopBarView(@NonNull Context context) { topDismissButton = new AppCompatImageView(context) { @SuppressLint("ClickableViewAccessibility") @Override - public boolean onTouchEvent(MotionEvent event) { + public boolean onTouchEvent (MotionEvent event) { return Views.isValid(this) && super.onTouchEvent(event); } }; @@ -128,13 +128,13 @@ public boolean onTouchEvent(MotionEvent event) { actionsContainer.addView(additionalTextView); } - public void setDismissListener(DismissListener dismissListener) { + public void setDismissListener (DismissListener dismissListener) { this.dismissListener = dismissListener; } private @Nullable ViewController themeProvider; - public void addThemeListeners(@Nullable ViewController themeProvider) { + public void addThemeListeners (@Nullable ViewController themeProvider) { this.themeProvider = themeProvider; if (themeProvider != null) { themeProvider.addThemeFilterListener(topDismissButton, ColorId.icon); @@ -142,14 +142,14 @@ public void addThemeListeners(@Nullable ViewController themeProvider) { } } - public void setCanDismiss(boolean canDismiss) { + public void setCanDismiss (boolean canDismiss) { if (this.canDismiss != canDismiss) { this.canDismiss = canDismiss; topDismissButton.setVisibility(canDismiss ? View.VISIBLE : View.GONE); } } - public void setItems(Item... items) { + public void setItems (Item... items) { actionsList = (LinearLayout) actionsContainer.getChildAt(0); for (int i = 0; i < actionsList.getChildCount(); i++) { View view = actionsList.getChildAt(i); From 769dfc4e97f7b6f7a1b9c89366a3ab936203666c Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Wed, 31 Jul 2024 19:55:09 +0200 Subject: [PATCH 03/12] indent fixed --- .../org/thunderdog/challegram/component/chat/TopBarView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index 3b2c79977e..f0a614dfac 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -59,14 +59,14 @@ public static class Item { boolean isNegative; boolean noDismiss; - public Item(int id, int stringRes, int iconResId, View.OnClickListener onClickListener) { + public Item (int id, int stringRes, int iconResId, View.OnClickListener onClickListener) { this.id = id; this.stringRes = stringRes; this.iconResId = iconResId; this.onClickListener = onClickListener; } - public Item(int id, int stringRes, View.OnClickListener onClickListener) { + public Item (int id, int stringRes, View.OnClickListener onClickListener) { this(id, stringRes, 0, onClickListener); } From b0c98186efef5c844561952e05d2be630811a286 Mon Sep 17 00:00:00 2001 From: Nick <64551534+null-nick@users.noreply.github.com> Date: Wed, 31 Jul 2024 20:11:50 +0200 Subject: [PATCH 04/12] updated .gitignore Co-authored-by: Vyacheslav <6242627+vkryl@users.noreply.github.com> --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6b2b89eae9..f230a7d4cb 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ obj /local.properties libc++_shared.so - From c830e68abf98e4505a03255e7cfdd65d20fe7602 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Sun, 4 Aug 2024 22:40:34 +0200 Subject: [PATCH 05/12] WIP --- .../challegram/component/chat/TopBarView.java | 72 +++++++++++-------- .../challegram/ui/MessagesController.java | 5 +- app/src/main/res/values/strings.xml | 3 + 3 files changed, 51 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index f0a614dfac..d9dcebd5f5 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -26,6 +26,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatTextView; import org.thunderdog.challegram.R; import org.thunderdog.challegram.core.Lang; @@ -41,7 +42,6 @@ public class TopBarView extends FrameLayoutFix { private final ImageView topDismissButton; private final LinearLayout actionsContainer; - private final TextView additionalTextView; private LinearLayout actionsList; private boolean canDismiss; @@ -53,21 +53,31 @@ public interface DismissListener { public static class Item { final int id; final int stringRes; + final int noticeRes; final int iconResId; final View.OnClickListener onClickListener; boolean isNegative; boolean noDismiss; - public Item (int id, int stringRes, int iconResId, View.OnClickListener onClickListener) { + public Item (int id, int stringRes, int noticeRes, int iconResId, View.OnClickListener onClickListener) { this.id = id; this.stringRes = stringRes; + this.noticeRes = noticeRes; this.iconResId = iconResId; this.onClickListener = onClickListener; } + public Item (int id, int stringRes, int iconResId,View.OnClickListener onClickListener) { + this(id, stringRes, 0, iconResId, onClickListener); + } + public Item (int id, int stringRes, View.OnClickListener onClickListener) { - this(id, stringRes, 0, onClickListener); + this(id, stringRes, 0, 0, onClickListener); + } + + public Item (int noticeRes) { + this(0, 0, noticeRes, 0, null); } public Item setIsNegative () { @@ -119,13 +129,6 @@ public boolean onTouchEvent (MotionEvent event) { Views.setClickable(topDismissButton); topDismissButton.setVisibility(View.INVISIBLE); addView(topDismissButton); - - additionalTextView = new TextView(context); - additionalTextView.setVisibility(View.GONE); - additionalTextView.setGravity(Gravity.CENTER); - additionalTextView.setTextColor(Theme.getColor(ColorId.textNeutral)); - additionalTextView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - actionsContainer.addView(additionalTextView); } public void setDismissListener (DismissListener dismissListener) { @@ -177,26 +180,45 @@ public void setItems (Item... items) { buttonLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); Views.setClickable(buttonLayout); + LinearLayout noticeItem = new LinearLayout(getContext()); + noticeItem.setOrientation(LinearLayout.HORIZONTAL); + noticeItem.setGravity(Lang.gravity()); + noticeItem.setBackgroundResource(R.drawable.bg_btn_header); + noticeItem.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); + if (item.iconResId != 0) { ImageView iconView = new ImageView(getContext()); iconView.setImageResource(item.iconResId); iconView.setColorFilter(Theme.getColor(textColorId)); - iconView.setLayoutParams(new LinearLayout.LayoutParams(Screen.dp(24f), Screen.dp(24f))); // Increased icon size + iconView.setLayoutParams(new LinearLayout.LayoutParams(Screen.dp(24f), Screen.dp(24f))); buttonLayout.addView(iconView); } - TextView buttonText = Views.newTextView(getContext(), 15f, Theme.getColor(textColorId), Gravity.CENTER, Views.TEXT_FLAG_BOLD | Views.TEXT_FLAG_HORIZONTAL_PADDING); // Increased text size - buttonText.setId(item.id); - if (themeProvider != null) { - themeProvider.addThemeTextColorListener(buttonText, textColorId); + if (item.stringRes != 0) { + TextView buttonText = Views.newTextView(getContext(), 15f, Theme.getColor(textColorId), Gravity.CENTER, Views.TEXT_FLAG_BOLD | Views.TEXT_FLAG_HORIZONTAL_PADDING); + buttonText.setId(item.id); + + if (themeProvider != null) { + themeProvider.addThemeTextColorListener(buttonText, textColorId); + } + + buttonText.setEllipsize(TextUtils.TruncateAt.END); + buttonText.setSingleLine(true); + buttonText.setText(Lang.getString(item.stringRes).toUpperCase()); + buttonText.setOnClickListener(item.onClickListener); + buttonLayout.addView(buttonText); + actionsList.addView(buttonLayout); + } + + if (item.noticeRes != 0) { + var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), Gravity.CENTER, Views.TEXT_FLAG_HORIZONTAL_PADDING); + noticeText.setText(Lang.getString(item.noticeRes)); + noticeText.setEllipsize(TextUtils.TruncateAt.END); + noticeText.setPadding(Screen.dp(2f), 0, Screen.dp(2f), 0); + noticeItem.addView(noticeText); + actionsList.addView(noticeItem); } - buttonText.setEllipsize(TextUtils.TruncateAt.END); - buttonText.setSingleLine(true); - buttonText.setText(Lang.getString(item.stringRes).toUpperCase()); - buttonText.setOnClickListener(item.onClickListener); - buttonLayout.addView(buttonText); - actionsList.addView(buttonLayout); } if (items.length > 1) { View offsetView = new View(getContext()); @@ -204,11 +226,5 @@ public void setItems (Item... items) { actionsList.addView(offsetView); } setCanDismiss(canDismiss); - additionalTextView.setVisibility(items.length == 0 && !TextUtils.isEmpty(additionalTextView.getText()) ? View.VISIBLE : View.GONE); - } - - public void setAdditionalText(String text) { - additionalTextView.setText(text); - additionalTextView.setVisibility(TextUtils.isEmpty(text) ? View.GONE : View.VISIBLE); } -} +} \ No newline at end of file diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index eaaea864f9..1e445b7c72 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -8230,7 +8230,10 @@ public boolean onSenderPick (ContactsController context, View view, TdApi.Messag } case TdApi.ChatActionBarJoinRequest.CONSTRUCTOR: { TdApi.ChatActionBarJoinRequest joinRequest = (TdApi.ChatActionBarJoinRequest) actionBar; - // TODO + var userId = tdlib.chatUserId(getChatId()); + var firstname = tdlib.cache().userFirstName(userId); + android.util.Log.d("JoinRequest", String.format("%s is an admin of %s, a channel you requested to join", firstname, joinRequest.title)); + items.add(new TopBarView.Item(R.string.JoinRequestChannelAdminNotice)); break; } default: { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2df667417f..407a1cf978 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5472,4 +5472,7 @@ Hold to access more options Hold and swipe horizontally for precise adjustment %1$s.\n%2$s. + + **%1$s** is an admin of **%2$s**, a channel you requested to join + **%1$s** is an admin of **%2$s**, a channel you requested to join From 65288a967f149be0890e2fd9aee17d1f6edb93a1 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Sun, 4 Aug 2024 23:04:51 +0200 Subject: [PATCH 06/12] some fixes --- .../challegram/component/chat/TopBarView.java | 24 +++++++++---------- .../challegram/ui/MessagesController.java | 7 ++---- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index d9dcebd5f5..341a78e0c6 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -26,7 +26,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; -import androidx.appcompat.widget.AppCompatTextView; import org.thunderdog.challegram.R; import org.thunderdog.challegram.core.Lang; @@ -53,14 +52,14 @@ public interface DismissListener { public static class Item { final int id; final int stringRes; - final int noticeRes; + final CharSequence noticeRes; final int iconResId; final View.OnClickListener onClickListener; boolean isNegative; boolean noDismiss; - public Item (int id, int stringRes, int noticeRes, int iconResId, View.OnClickListener onClickListener) { + public Item (int id, int stringRes, CharSequence noticeRes, int iconResId, View.OnClickListener onClickListener) { this.id = id; this.stringRes = stringRes; this.noticeRes = noticeRes; @@ -69,14 +68,14 @@ public Item (int id, int stringRes, int noticeRes, int iconResId, View.OnClickLi } public Item (int id, int stringRes, int iconResId,View.OnClickListener onClickListener) { - this(id, stringRes, 0, iconResId, onClickListener); + this(id, stringRes, null, iconResId, onClickListener); } public Item (int id, int stringRes, View.OnClickListener onClickListener) { - this(id, stringRes, 0, 0, onClickListener); + this(id, stringRes, null, 0, onClickListener); } - public Item (int noticeRes) { + public Item (CharSequence noticeRes) { this(0, 0, noticeRes, 0, null); } @@ -124,7 +123,7 @@ public boolean onTouchEvent (MotionEvent event) { topDismissButton.setScaleType(ImageView.ScaleType.CENTER); topDismissButton.setColorFilter(Theme.iconColor()); topDismissButton.setImageResource(R.drawable.baseline_close_18); - topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, Gravity.END | Gravity.TOP)); + topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, Lang.reverseGravity() | Gravity.CENTER_VERTICAL)); topDismissButton.setBackgroundResource(R.drawable.bg_btn_header); Views.setClickable(topDismissButton); topDismissButton.setVisibility(View.INVISIBLE); @@ -210,11 +209,10 @@ public void setItems (Item... items) { actionsList.addView(buttonLayout); } - if (item.noticeRes != 0) { - var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), Gravity.CENTER, Views.TEXT_FLAG_HORIZONTAL_PADDING); - noticeText.setText(Lang.getString(item.noticeRes)); - noticeText.setEllipsize(TextUtils.TruncateAt.END); - noticeText.setPadding(Screen.dp(2f), 0, Screen.dp(2f), 0); + if (item.noticeRes != null) { + var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), Lang.gravity(), Views.TEXT_FLAG_HORIZONTAL_PADDING); + noticeText.setText(item.noticeRes); + noticeItem.addView(noticeText); actionsList.addView(noticeItem); } @@ -227,4 +225,4 @@ public void setItems (Item... items) { } setCanDismiss(canDismiss); } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index 1e445b7c72..02fe7eb148 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -791,7 +791,7 @@ protected void onDraw (Canvas c) { liveLocationView.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, liveLocationHeight)); addThemeInvalidateListener(liveLocationView); - int actionBarHeight = Screen.dp(36f); + int actionBarHeight = Screen.dp(60f); actionView = new TopBarView(context); actionView.setDismissListener(barView -> dismissActionBar() @@ -8230,10 +8230,7 @@ public boolean onSenderPick (ContactsController context, View view, TdApi.Messag } case TdApi.ChatActionBarJoinRequest.CONSTRUCTOR: { TdApi.ChatActionBarJoinRequest joinRequest = (TdApi.ChatActionBarJoinRequest) actionBar; - var userId = tdlib.chatUserId(getChatId()); - var firstname = tdlib.cache().userFirstName(userId); - android.util.Log.d("JoinRequest", String.format("%s is an admin of %s, a channel you requested to join", firstname, joinRequest.title)); - items.add(new TopBarView.Item(R.string.JoinRequestChannelAdminNotice)); + items.add(new TopBarView.Item(Strings.replaceBoldTokens(Lang.getString(R.string.JoinRequestChannelAdminNotice, tdlib.cache().userFirstName(tdlib.chatUserId(getChatId())), joinRequest.title)))); break; } default: { From e5183f3138f1786e6449d43153a9c121ee6d5ec6 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:40:05 +0200 Subject: [PATCH 07/12] some fixes + Fixed dismiss icon on pinned message + Fixed topbar container size --- .../challegram/component/chat/TopBarView.java | 30 ++++++++++++++----- .../challegram/ui/MessagesController.java | 26 ++++++++++++---- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index 341a78e0c6..53fce34038 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -55,28 +55,38 @@ public static class Item { final CharSequence noticeRes; final int iconResId; final View.OnClickListener onClickListener; + final boolean showDismissRight; boolean isNegative; boolean noDismiss; - public Item (int id, int stringRes, CharSequence noticeRes, int iconResId, View.OnClickListener onClickListener) { + public Item (int id, int stringRes, CharSequence noticeRes, int iconResId, boolean showDismissRight, View.OnClickListener onClickListener) { this.id = id; this.stringRes = stringRes; this.noticeRes = noticeRes; this.iconResId = iconResId; + this.showDismissRight = showDismissRight; this.onClickListener = onClickListener; } - public Item (int id, int stringRes, int iconResId,View.OnClickListener onClickListener) { - this(id, stringRes, null, iconResId, onClickListener); + public Item (int id, int stringRes, boolean showDismissRight, int iconResId,View.OnClickListener onClickListener) { + this(id, stringRes, null, iconResId, showDismissRight, onClickListener); + } + + public Item (int id, int stringRes, boolean showDismissRight, View.OnClickListener onClickListener) { + this(id, stringRes, null, 0, showDismissRight, onClickListener); } public Item (int id, int stringRes, View.OnClickListener onClickListener) { - this(id, stringRes, null, 0, onClickListener); + this(id, stringRes, null, 0, false, onClickListener); + } + + public Item (CharSequence noticeRes, boolean showDismissRight) { + this(0, 0, noticeRes, 0, showDismissRight, null); } public Item (CharSequence noticeRes) { - this(0, 0, noticeRes, 0, null); + this(0, 0, noticeRes, 0, false, null); } public Item setIsNegative () { @@ -123,7 +133,6 @@ public boolean onTouchEvent (MotionEvent event) { topDismissButton.setScaleType(ImageView.ScaleType.CENTER); topDismissButton.setColorFilter(Theme.iconColor()); topDismissButton.setImageResource(R.drawable.baseline_close_18); - topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, Lang.reverseGravity() | Gravity.CENTER_VERTICAL)); topDismissButton.setBackgroundResource(R.drawable.bg_btn_header); Views.setClickable(topDismissButton); topDismissButton.setVisibility(View.INVISIBLE); @@ -179,11 +188,17 @@ public void setItems (Item... items) { buttonLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); Views.setClickable(buttonLayout); + topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, (item.showDismissRight ? (Gravity.END | Gravity.CENTER_VERTICAL) : (Lang.gravity() | Gravity.TOP)))); + LinearLayout noticeItem = new LinearLayout(getContext()); noticeItem.setOrientation(LinearLayout.HORIZONTAL); noticeItem.setGravity(Lang.gravity()); noticeItem.setBackgroundResource(R.drawable.bg_btn_header); noticeItem.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); + /* Rudimentary debugging + android.util.Log.d("TopBarView", String.format("Width: %d, Height: %d", ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); + android.util.Log.d("TopBarView", String.format("Width: %d, Height: %d", noticeItem.getWidth(), noticeItem.getHeight())); + */ if (item.iconResId != 0) { ImageView iconView = new ImageView(getContext()); @@ -210,8 +225,9 @@ public void setItems (Item... items) { } if (item.noticeRes != null) { - var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), Lang.gravity(), Views.TEXT_FLAG_HORIZONTAL_PADDING); + var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), ViewGroup.MEASURED_HEIGHT_STATE_SHIFT, Views.TEXT_FLAG_HORIZONTAL_PADDING); noticeText.setText(item.noticeRes); + setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(50f))); noticeItem.addView(noticeText); actionsList.addView(noticeItem); diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index 02fe7eb148..aa8a9d7a2a 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -791,7 +791,7 @@ protected void onDraw (Canvas c) { liveLocationView.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, liveLocationHeight)); addThemeInvalidateListener(liveLocationView); - int actionBarHeight = Screen.dp(60f); + int actionBarHeight = Screen.dp(46f); actionView = new TopBarView(context); actionView.setDismissListener(barView -> dismissActionBar() @@ -8040,13 +8040,13 @@ private boolean needActionBar () { } private TopBarView.Item newAddContactItem (long chatId) { - return new TopBarView.Item(R.id.btn_addContact, R.string.AddContact, R.drawable.baseline_person_add_24, v -> { + return new TopBarView.Item(R.id.btn_addContact, R.string.AddContact, true, R.drawable.baseline_person_add_24, v -> { tdlib.ui().addContact(this, tdlib.chatUser(chatId)); }); } private TopBarView.Item newUnarchiveItem (long chatId) { - return new TopBarView.Item(R.id.btn_unarchiveChat, R.string.UnarchiveUnmute, R.drawable.baseline_unarchive_24, v -> { + return new TopBarView.Item(R.id.btn_unarchiveChat, R.string.UnarchiveUnmute, true, R.drawable.baseline_unarchive_24, v -> { tdlib.client().send(new TdApi.AddChatToList(chatId, new TdApi.ChatListMain()), tdlib.okHandler()); TdApi.ChatNotificationSettings settings = tdlib.chatSettings(chatId); if (settings != null) { @@ -8066,7 +8066,7 @@ private TopBarView.Item newUnarchiveItem (long chatId) { } private TopBarView.Item newReportItem (long chatId, boolean isBlock) { - return new TopBarView.Item(R.id.btn_reportChat, isBlock ? R.string.BlockContact : R.string.ReportSpam, isBlock ? R.drawable.baseline_block_24 : R.drawable.baseline_report_24, v -> { + return new TopBarView.Item(R.id.btn_reportChat, isBlock ? R.string.BlockContact : R.string.ReportSpam, true, isBlock ? R.drawable.baseline_block_24 : R.drawable.baseline_report_24, v -> { showSettings(new SettingsWrapBuilder(R.id.btn_reportSpam) .setHeaderItem(new ListItem(ListItem.TYPE_INFO, 0, 0, Lang.getStringBold(R.string.ReportChatSpam, chat.title), false)) .setRawItems(getChatUserId() != 0 ? new ListItem[] { @@ -8163,6 +8163,14 @@ private void checkActionBar () { case TdApi.ChatActionBarReportSpam.CONSTRUCTOR: { TdApi.ChatActionBarReportSpam reportSpam = (TdApi.ChatActionBarReportSpam) actionBar; + /* + TODO: Add anti-scam notice for custom emojis + var customEmoji = tdlib().cache().user(tdlib.chatUserId(getChatId())); + android.util.Log.e("customEmoji", String.format("customEmoji: %s", customEmoji)); + if (customEmoji != null && customEmoji.emojiStatus != null) { + items.add(new TopBarView.Item("Have a custom emoji", true)); + } + */ items.add(newReportItem(chatId, false)); if (reportSpam.canUnarchive) { items.add(newUnarchiveItem(chatId)); @@ -8172,6 +8180,14 @@ private void checkActionBar () { case TdApi.ChatActionBarReportAddBlock.CONSTRUCTOR: { TdApi.ChatActionBarReportAddBlock reportAddBlock = (TdApi.ChatActionBarReportAddBlock) actionBar; + /* + TODO: Add anti-scam notice for custom emojis + var customEmoji = tdlib().cache().user(tdlib.chatUserId(getChatId())); + android.util.Log.e("customEmoji", String.format("customEmoji: %s", customEmoji)); + if (customEmoji != null && customEmoji.emojiStatus != null) { + items.add(new TopBarView.Item("Have a custom emoji", true)); + } + */ items.add(newReportItem(chatId, true)); items.add(newAddContactItem(chatId)); if (reportAddBlock.canUnarchive) { @@ -8230,7 +8246,7 @@ public boolean onSenderPick (ContactsController context, View view, TdApi.Messag } case TdApi.ChatActionBarJoinRequest.CONSTRUCTOR: { TdApi.ChatActionBarJoinRequest joinRequest = (TdApi.ChatActionBarJoinRequest) actionBar; - items.add(new TopBarView.Item(Strings.replaceBoldTokens(Lang.getString(R.string.JoinRequestChannelAdminNotice, tdlib.cache().userFirstName(tdlib.chatUserId(getChatId())), joinRequest.title)))); + items.add(new TopBarView.Item(Strings.replaceBoldTokens(Lang.getString(R.string.JoinRequestChannelAdminNotice, tdlib.cache().userFirstName(tdlib.chatUserId(getChatId())), joinRequest.title)), true)); break; } default: { From dba582b388b99270e8fe07671e02bf133cfde387 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Sun, 9 Mar 2025 12:19:50 +0100 Subject: [PATCH 08/12] padding fixes --- .../challegram/component/chat/TopBarView.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index 53fce34038..1ca7e74d2f 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -105,12 +105,12 @@ public Item setNoDismiss () { public TopBarView (@NonNull Context context) { super(context); - setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(36f))); + setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(40f))); ViewSupport.setThemedBackground(this, ColorId.filling, null); actionsContainer = new LinearLayout(context); actionsContainer.setOrientation(LinearLayout.VERTICAL); - actionsContainer.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(40f), Lang.gravity() | Gravity.TOP)); + actionsContainer.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Lang.gravity() | Gravity.TOP)); addView(actionsContainer); actionsList = new LinearLayout(context); @@ -188,17 +188,13 @@ public void setItems (Item... items) { buttonLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); Views.setClickable(buttonLayout); - topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, (item.showDismissRight ? (Gravity.END | Gravity.CENTER_VERTICAL) : (Lang.gravity() | Gravity.TOP)))); + topDismissButton.setLayoutParams(FrameLayoutFix.newParams(Screen.dp(40f), ViewGroup.LayoutParams.MATCH_PARENT, (item.showDismissRight ? (Gravity.END | Gravity.CENTER_VERTICAL) : (Lang.gravity() | Gravity.CENTER_VERTICAL)))); LinearLayout noticeItem = new LinearLayout(getContext()); noticeItem.setOrientation(LinearLayout.HORIZONTAL); noticeItem.setGravity(Lang.gravity()); noticeItem.setBackgroundResource(R.drawable.bg_btn_header); noticeItem.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); - /* Rudimentary debugging - android.util.Log.d("TopBarView", String.format("Width: %d, Height: %d", ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); - android.util.Log.d("TopBarView", String.format("Width: %d, Height: %d", noticeItem.getWidth(), noticeItem.getHeight())); - */ if (item.iconResId != 0) { ImageView iconView = new ImageView(getContext()); @@ -206,6 +202,9 @@ public void setItems (Item... items) { iconView.setColorFilter(Theme.getColor(textColorId)); iconView.setLayoutParams(new LinearLayout.LayoutParams(Screen.dp(24f), Screen.dp(24f))); buttonLayout.addView(iconView); + LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) iconView.getLayoutParams(); + layoutParams.rightMargin = Screen.dp(8); + iconView.setLayoutParams(layoutParams); } if (item.stringRes != 0) { @@ -218,6 +217,7 @@ public void setItems (Item... items) { buttonText.setEllipsize(TextUtils.TruncateAt.END); buttonText.setSingleLine(true); + buttonText.setPadding(Screen.dp(8), 0, Screen.dp(8), 0); buttonText.setText(Lang.getString(item.stringRes).toUpperCase()); buttonText.setOnClickListener(item.onClickListener); buttonLayout.addView(buttonText); @@ -227,6 +227,7 @@ public void setItems (Item... items) { if (item.noticeRes != null) { var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), ViewGroup.MEASURED_HEIGHT_STATE_SHIFT, Views.TEXT_FLAG_HORIZONTAL_PADDING); noticeText.setText(item.noticeRes); + noticeText.setPadding(Screen.dp(8), 0, Screen.dp(8), 0); setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(50f))); noticeItem.addView(noticeText); From 3370cba1c7809bf44068e8c6a45013842067dea5 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Sun, 9 Mar 2025 12:42:58 +0100 Subject: [PATCH 09/12] another padding fixes --- .../challegram/component/chat/TopBarView.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index 1ca7e74d2f..1e4558c89f 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -105,17 +105,17 @@ public Item setNoDismiss () { public TopBarView (@NonNull Context context) { super(context); - setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(40f))); + setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); ViewSupport.setThemedBackground(this, ColorId.filling, null); actionsContainer = new LinearLayout(context); actionsContainer.setOrientation(LinearLayout.VERTICAL); - actionsContainer.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Lang.gravity() | Gravity.TOP)); + actionsContainer.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Lang.gravity() | Gravity.TOP)); addView(actionsContainer); actionsList = new LinearLayout(context); actionsList.setOrientation(LinearLayout.HORIZONTAL); - actionsList.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Lang.gravity() | Gravity.TOP)); + actionsList.setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Lang.gravity() | Gravity.TOP)); actionsContainer.addView(actionsList); topDismissButton = new AppCompatImageView(context) { @@ -192,9 +192,10 @@ public void setItems (Item... items) { LinearLayout noticeItem = new LinearLayout(getContext()); noticeItem.setOrientation(LinearLayout.HORIZONTAL); - noticeItem.setGravity(Lang.gravity()); - noticeItem.setBackgroundResource(R.drawable.bg_btn_header); - noticeItem.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, 2f)); + noticeItem.setGravity(Gravity.CENTER); + noticeItem.setBackgroundColor(0x00000000); + noticeItem.setPadding(0, 0, 0, 0); + noticeItem.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 2f)); if (item.iconResId != 0) { ImageView iconView = new ImageView(getContext()); @@ -227,9 +228,11 @@ public void setItems (Item... items) { if (item.noticeRes != null) { var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), ViewGroup.MEASURED_HEIGHT_STATE_SHIFT, Views.TEXT_FLAG_HORIZONTAL_PADDING); noticeText.setText(item.noticeRes); - noticeText.setPadding(Screen.dp(8), 0, Screen.dp(8), 0); - setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(50f))); - + noticeText.setGravity(Gravity.START); + noticeText.setPadding(Screen.dp(32), Screen.dp(8), Screen.dp(32), Screen.dp(8)); + noticeText.setSingleLine(false); + noticeText.setEllipsize(null); + setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); noticeItem.addView(noticeText); actionsList.addView(noticeItem); } From f8ae4e3d700dfab3a7b634e76377189124b37de0 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Sun, 9 Mar 2025 13:00:12 +0100 Subject: [PATCH 10/12] another padding fixes + string fixes --- .../org/thunderdog/challegram/component/chat/TopBarView.java | 2 +- .../java/org/thunderdog/challegram/ui/MessagesController.java | 3 ++- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index 1e4558c89f..801151b583 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -229,7 +229,7 @@ public void setItems (Item... items) { var noticeText = Views.newTextView(getContext(), 15f, Theme.getColor(ColorId.textPlaceholder), ViewGroup.MEASURED_HEIGHT_STATE_SHIFT, Views.TEXT_FLAG_HORIZONTAL_PADDING); noticeText.setText(item.noticeRes); noticeText.setGravity(Gravity.START); - noticeText.setPadding(Screen.dp(32), Screen.dp(8), Screen.dp(32), Screen.dp(8)); + noticeText.setPadding(Screen.dp(16), Screen.dp(8), Screen.dp(26), Screen.dp(8)); noticeText.setSingleLine(false); noticeText.setEllipsize(null); setLayoutParams(FrameLayoutFix.newParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index 52f2fd22b6..ef5c1cc18c 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -8149,7 +8149,8 @@ public boolean onSenderPick (ContactsController context, View view, TdApi.Messag } case TdApi.ChatActionBarJoinRequest.CONSTRUCTOR: { TdApi.ChatActionBarJoinRequest joinRequest = (TdApi.ChatActionBarJoinRequest) actionBar; - items.add(new TopBarView.Item(Strings.replaceBoldTokens(Lang.getString(R.string.JoinRequestChannelAdminNotice, tdlib.cache().userFirstName(tdlib.chatUserId(getChatId())), joinRequest.title)), true)); + int noticeResId = joinRequest.isChannel ? R.string.JoinRequestChannelAdminNotice : R.string.JoinRequestGroupAdminNotice; + items.add(new TopBarView.Item(Strings.replaceBoldTokens(Lang.getString(noticeResId, tdlib.cache().userFirstName(tdlib.chatUserId(getChatId())), joinRequest.title)), true)); break; } default: { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 17b5823e3d..fca4f5fa05 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5555,7 +5555,7 @@ %1$s.\n%2$s. **%1$s** is an admin of **%2$s**, a channel you requested to join - **%1$s** is an admin of **%2$s**, a channel you requested to join + **%1$s** is an admin of **%2$s**, a group you requested to join deactivated bot From 2332515da13380d41f37668002bd8f2e689b5088 Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Sun, 9 Mar 2025 13:03:52 +0100 Subject: [PATCH 11/12] indent fixes --- .../org/thunderdog/challegram/component/chat/TopBarView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java index 801151b583..1ddc62c165 100644 --- a/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java +++ b/app/src/main/java/org/thunderdog/challegram/component/chat/TopBarView.java @@ -69,7 +69,7 @@ public Item (int id, int stringRes, CharSequence noticeRes, int iconResId, boole this.onClickListener = onClickListener; } - public Item (int id, int stringRes, boolean showDismissRight, int iconResId,View.OnClickListener onClickListener) { + public Item (int id, int stringRes, boolean showDismissRight, int iconResId, View.OnClickListener onClickListener) { this(id, stringRes, null, iconResId, showDismissRight, onClickListener); } From bdc0181a59b5c8c18a1b550db531abcdd6d4447c Mon Sep 17 00:00:00 2001 From: nick <64551534+null-nick@users.noreply.github.com> Date: Mon, 10 Mar 2025 14:04:24 +0100 Subject: [PATCH 12/12] little fixes --- .../java/org/thunderdog/challegram/ui/MessagesController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index ef5c1cc18c..3f1ca20d7d 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -873,7 +873,7 @@ public void onCompletelyHidden () { pinnedMessagesItem, requestsItem = new CollapseListView.ViewItem(requestsView, requestsViewHeight), liveLocationItem = new CollapseListView.ViewItem(liveLocationView, liveLocationHeight), - actionItem = new CollapseListView.ViewItem(actionView, actionBarHeight), + actionItem = new CollapseListView.ViewItem(actionView, ViewGroup.LayoutParams.WRAP_CONTENT), toastAlertItem }, this);