Skip to content

Commit

Permalink
feat: add information about mutual contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrKozlovskiy authored and NextAlone committed Mar 15, 2022
1 parent 5ca788e commit 8e38441
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
View view;
switch (viewType) {
case 0:
view = new UserCell(mContext, 58, 1, false);
view = new UserCell(mContext, 58, 1, false, false, true);
break;
case 1:
view = new TextCell(mContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14601,6 +14601,10 @@ public void setAnimationRunning(boolean animationRunning, boolean willRemoved) {
}
}

public boolean isSeekbarCell() {
return currentMessageObject.isVoice() || currentMessageObject.isRoundVideo() || currentMessageObject.isMusic();
}

@Override
public boolean onHoverEvent(MotionEvent event) {
int x = (int) event.getX();
Expand Down
23 changes: 23 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.UserObject;
import org.telegram.messenger.R;
import org.telegram.tgnet.ConnectionsManager;
Expand All @@ -34,6 +35,7 @@
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.CheckBox;
import org.telegram.ui.Components.CheckBoxSquare;
import org.telegram.ui.Components.LayoutHelper;
Expand All @@ -50,6 +52,7 @@ public class UserCell extends FrameLayout {
private CheckBoxSquare checkBoxBig;
private TextView adminTextView;
private TextView addButton;
private ImageView mutualView;

private AvatarDrawable avatarDrawable;
private Object currentObject;
Expand Down Expand Up @@ -78,6 +81,10 @@ public UserCell(Context context, int padding, int checkbox, boolean admin) {
}

public UserCell(Context context, int padding, int checkbox, boolean admin, boolean needAddButton) {
this(context, padding, checkbox, admin, needAddButton, false);
}

public UserCell(Context context, int padding, int checkbox, boolean admin, boolean needAddButton, boolean needMutualIcon) {
super(context);

int additionalPadding;
Expand Down Expand Up @@ -140,6 +147,18 @@ public UserCell(Context context, int padding, int checkbox, boolean admin, boole
addView(adminTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 23 : 0, 10, LocaleController.isRTL ? 0 : 23, 0));
}

if (needMutualIcon) {
mutualView = new ImageView(context);
mutualView.setImageResource(R.drawable.ic_round_swap_horiz_24);
mutualView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_player_actionBarSelector)));
mutualView.setScaleType(ImageView.ScaleType.CENTER);
mutualView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY));
mutualView.setVisibility(GONE);
mutualView.setContentDescription(LocaleController.getString("MutualContact", R.string.MutualContact));
mutualView.setOnClickListener(v -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_ERROR, LocaleController.getString("MutualContactDescription", R.string.MutualContactDescription)));
addView(mutualView, LayoutHelper.createFrame(40, 40, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 8 : 0, 0, LocaleController.isRTL ? 0 : 8, 0));
}

setFocusable(true);
}

Expand Down Expand Up @@ -490,6 +509,10 @@ public void update(int mask) {
if (adminTextView != null) {
adminTextView.setTextColor(Theme.getColor(Theme.key_profile_creatorIcon));
}

if (mutualView != null) {
mutualView.setVisibility(currentUser != null && currentUser.mutual_contact ? VISIBLE : GONE);
}
}

public void setSelfAsSavedMessages(boolean value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M6.14,11.86l-2.78,2.79c-0.19,0.2 -0.19,0.51 0,0.71l2.78,2.79c0.31,0.32 0.85,0.09 0.85,-0.35L6.99,16L13,16c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L6.99,14v-1.79c0,-0.45 -0.54,-0.67 -0.85,-0.35zM20.65,8.65l-2.78,-2.79c-0.31,-0.32 -0.85,-0.09 -0.85,0.35L17.02,8L11,8c-0.55,0 -1,0.45 -1,1s0.45,1 1,1h6.01v1.79c0,0.45 0.54,0.67 0.85,0.35l2.78,-2.79c0.2,-0.19 0.2,-0.51 0.01,-0.7z" />
</vector>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values/strings_neko.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,6 @@
<string name="forceBlurInChat">Force enable Chat Blur</string>
<string name="ChatBlurAlphaValue">Chat Blur Alpha</string>
<string name="SelectAnIcon">Choose an icon</string>
<string name="MutualContact">Mutual contact</string>
<string name="MutualContactDescription">This contact is a mutual contact.</string>
</resources>

0 comments on commit 8e38441

Please sign in to comment.