Skip to content

Commit

Permalink
Merge branch 'NextAlone:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYi0526 authored Jan 9, 2024
2 parents 1437167 + 26a4835 commit 4ecd4c4
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2283,6 +2283,12 @@ public boolean seekToProgress(MessageObject messageObject, float progress) {
return true;
}

public void seekShift(int ms) {
if (audioPlayer != null) {
audioPlayer.seekTo(Math.max(0, audioPlayer.getCurrentPosition() + ms));
}
}

public long getDuration() {
if (audioPlayer == null) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,20 @@ public void setProgress(float progress) {

public void drawStatusWithImage(Canvas canvas, ImageReceiver imageReceiver, int radius) {
String formatUserStatus = currentUser != null ? LocaleController.formatUserStatus(this.currentAccount, currentUser) : "";
if (!NaConfig.INSTANCE.getShowOnlineStatus().Bool() || currentUser == null || currentUser.bot || !formatUserStatus.equals(LocaleController.getString("Online", R.string.Online))) {
if (!NaConfig.INSTANCE.getShowOnlineStatus().Bool() || currentUser == null || currentUser.bot) {
imageReceiver.draw(canvas);
return;
}
int diff = -60 * 60 - 1;
if (NaConfig.INSTANCE.getShowRecentOnlineStatus().Bool()) {
if (currentUser != null && currentUser.status != null) {
diff = currentUser.status.expires - ConnectionsManager.getInstance(currentAccount).getCurrentTime();
}
if (diff < -60 * 60) {
imageReceiver.draw(canvas);
return;
}
} else if (!formatUserStatus.equals(LocaleController.getString("Online", R.string.Online))) {
imageReceiver.draw(canvas);
return;
}
Expand All @@ -1556,8 +1569,17 @@ public void drawStatusWithImage(Canvas canvas, ImageReceiver imageReceiver, int
int spaceLeft = radius - circleRadius;
int xCenterRegion = x - spaceLeft;
int yCenterRegion = y - spaceLeft;
int colorOnline = diff > 0
? Theme.getColor(Theme.key_chats_onlineCircle)
: diff > -15 * 60
? android.graphics.Color.argb(255, 234, 234, 30)
: diff > -30 * 60
? android.graphics.Color.argb(255, 234, 132, 30)
: diff > -60 * 60
? android.graphics.Color.argb(255, 234, 30, 30)
: 0;
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Theme.getColor(Theme.key_chats_onlineCircle));
paint.setColor(colorOnline);
canvas.save();
Path p = new Path();
p.addCircle(x - radius, y - radius, radius, Path.Direction.CW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,10 @@ private void checkOnline() {
}
}
boolean isOnline = isOnline();
if (NaConfig.INSTANCE.getShowRecentOnlineStatus().Bool() && !isOnline && user != null && !user.self && user.status != null) {
final int diff = user.status.expires - ConnectionsManager.getInstance(currentAccount).getCurrentTime();
isOnline = diff > -60 * 60;
}
onlineProgress = isOnline ? 1.0f : 0.0f;
}

Expand Down Expand Up @@ -4104,7 +4108,26 @@ public boolean drawAvatarOverlays(Canvas canvas) {
if (user != null && !MessagesController.isSupportUser(user) && !user.bot) {
boolean isOnline = isOnline();
wasDrawnOnline = isOnline;
int colorOnline = 0;
if (NaConfig.INSTANCE.getShowRecentOnlineStatus().Bool() && !user.self && user.status != null) {
final int diff = user.status.expires - ConnectionsManager.getInstance(currentAccount).getCurrentTime();
colorOnline = diff > 0
? Theme.getColor(Theme.key_chats_onlineCircle)
: diff > -15 * 60
? android.graphics.Color.argb(255, 234, 234, 30)
: diff > -30 * 60
? android.graphics.Color.argb(255, 234, 132, 30)
: diff > -60 * 60
? android.graphics.Color.argb(255, 234, 30, 30)
: 0;
if (colorOnline != 0) {
isOnline = true;
}
}
if (isOnline || onlineProgress != 0) {
if (onlineProgress != 0 && colorOnline == 0) {
colorOnline = Theme.getColor(Theme.key_chats_onlineCircle, resourcesProvider);
}
int top = (int) (storyParams.originalAvatarRect.bottom - AndroidUtilities.dp(useForceThreeLines || SharedConfig.useThreeLinesLayout ? 6 : 8));
int left;
if (LocaleController.isRTL) {
Expand All @@ -4115,7 +4138,7 @@ public boolean drawAvatarOverlays(Canvas canvas) {

Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite, resourcesProvider));
canvas.drawCircle(left, top, AndroidUtilities.dp(7) * onlineProgress, Theme.dialogs_onlineCirclePaint);
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_chats_onlineCircle, resourcesProvider));
Theme.dialogs_onlineCirclePaint.setColor(colorOnline);
canvas.drawCircle(left, top, AndroidUtilities.dp(5) * onlineProgress, Theme.dialogs_onlineCirclePaint);
if (isOnline) {
if (onlineProgress < 1.0f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@

public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate, DownloadController.FileDownloadProgressListener {

private TextView forwardButton;
private TextView backwardButton;

private ActionBar actionBar;
private View actionBarShadow;
private View playerShadow;
Expand Down Expand Up @@ -747,14 +750,52 @@ public CharSequence getContentDescription() {
FrameLayout bottomView = new FrameLayout(context) {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
int dist = ((right - left) - AndroidUtilities.dp(8 + 48 * 5)) / 4;
for (int a = 0; a < 5; a++) {
int dist = ((right - left) - AndroidUtilities.dp(8 + 48 * 7)) / 4;
int forkButtonsLayouted = 0;
for (int a = 0; a < 7; a++) {
int l = AndroidUtilities.dp(4 + 48 * a) + dist * a;
int t = AndroidUtilities.dp(9);
buttons[a].layout(l, t, l + buttons[a].getMeasuredWidth(), t + buttons[a].getMeasuredHeight());
if (a == 1) {
backwardButton.layout(l, t, l + backwardButton.getMeasuredWidth(), t + backwardButton.getMeasuredHeight());
forkButtonsLayouted++;
} else if (a == 5) {
forwardButton.layout(l, t, l + forwardButton.getMeasuredWidth(), t + forwardButton.getMeasuredHeight());
forkButtonsLayouted++;
} else {
int i = a - forkButtonsLayouted;
buttons[i].layout(l, t, l + buttons[i].getMeasuredWidth(), t + buttons[i].getMeasuredHeight());
}
}
}
};

{
final int s = 5;
final int color = getThemedColor(Theme.key_listSelector);
final FrameLayout.LayoutParams frame = LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP);
forwardButton = new TextView(context);
forwardButton.setText("+" + s + "s");
forwardButton.setGravity(Gravity.CENTER);
bottomView.addView(forwardButton, frame);

backwardButton = new TextView(context);
backwardButton.setText("–" + s + "s");
backwardButton.setGravity(Gravity.CENTER);
bottomView.addView(backwardButton, frame);

if (Build.VERSION.SDK_INT >= 21) {
forwardButton.setBackgroundDrawable(Theme.createSelectorDrawable(color, 1, AndroidUtilities.dp(24)));
backwardButton.setBackgroundDrawable(Theme.createSelectorDrawable(color, 1, AndroidUtilities.dp(24)));
}

forwardButton.setOnClickListener(view -> {
MediaController.getInstance().seekShift(s * 1000);
});
backwardButton.setOnClickListener(view -> {
MediaController.getInstance().seekShift(-s * 1000);
});
}

playerLayout.addView(bottomView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 66, Gravity.TOP | Gravity.LEFT, 0, 111, 0, 0));

buttons[0] = repeatButton = new ActionBarMenuItem(context, null, 0, 0, false, resourcesProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public class NekoChatSettingsActivity extends BaseNekoXSettingsActivity implemen
private final AbstractConfigCell disableZalgoSymbolsRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getZalgoFilter(), LocaleController.getString("ZalgoFilterNotice", R.string.ZalgoFilterNotice)));
private final AbstractConfigCell quickToggleAnonymousRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getQuickToggleAnonymous(), LocaleController.getString("QuickToggleAnonymousNotice", R.string.QuickToggleAnonymousNotice)));
private final AbstractConfigCell showOnlineStatusRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowOnlineStatus(), LocaleController.getString("ShowOnlineStatusNotice", R.string.ShowOnlineStatusNotice)));
private final AbstractConfigCell showRecentOnlineStatusRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getShowRecentOnlineStatus()));
private final AbstractConfigCell dividerChat = cellGroup.appendCell(new ConfigCellDivider());

// Interactions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ object NaConfig {
ConfigItem.configTypeString,
""
)
val showRecentOnlineStatus =
addConfig(
"ShowRecentOnlineStatus",
ConfigItem.configTypeBool,
false
)

private fun addConfig(
k: String,
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<string name="HalloWeen">万圣节</string>
<string name="ShowOnlineStatus">显示用户在线状态</string>
<string name="ShowOnlineStatusNotice">在群组聊天时用户头像的右下角显示在线状态</string>
<string name="ShowRecentOnlineStatus">显示用户最近在线状态</string>
<string name="DoActionsInCommonGroups">也在共同群操作</string>
<string name="ShowFullAbout">直接显示完整的群组简介</string>
<string name="HideMessageSeenTooltip">隐藏消息已读提示</string>
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<string name="HalloWeen">HalloWeen</string>
<string name="ShowOnlineStatus">Show Online Status</string>
<string name="ShowOnlineStatusNotice">Show the online status of other people next to their profile photo in groups</string>
<string name="ShowRecentOnlineStatus">Show Recent Online Status</string>
<string name="DoActionsInCommonGroups">Applied in common groups</string>
<string name="ShowFullAbout">Show full about info</string>
<string name="HideMessageSeenTooltip">Hide message seen tooltip</string>
Expand Down

0 comments on commit 4ecd4c4

Please sign in to comment.