Skip to content

Commit

Permalink
Fixes for Navigation Bar, Bell Icon, Archived Chats in Drawer and etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
immat0x1 committed May 8, 2023
1 parent 255de6e commit 4ee4b7c
Show file tree
Hide file tree
Showing 41 changed files with 200 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.components;

import android.animation.Animator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.components;

import android.annotation.SuppressLint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.components;

import android.content.Intent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.components;

import android.annotation.SuppressLint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.components;

import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.preferences.components;

import static org.telegram.messenger.AndroidUtilities.dp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.utils;

import org.telegram.messenger.ApplicationLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.utils;

import android.content.Context;
Expand All @@ -18,11 +29,11 @@

public class CanvasUtils {

public static Drawable drawFab() {
return drawFab(false);
public static Drawable createFabBackground() {
return createFabBackground(false);
}

public static Drawable drawFab(boolean altColor) {
public static Drawable createFabBackground(boolean altColor) {
int r = AndroidUtilities.dp(ExteraConfig.squareFab ? 16 : 100);
int c = Theme.getColor(altColor ? Theme.key_dialogFloatingButton : Theme.key_chats_actionBackground);
int pc = Theme.getColor(altColor ? Theme.key_dialogFloatingButtonPressed : Theme.key_chats_actionPressedBackground);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.utils;

import android.text.TextUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.utils;

import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.utils;

import android.text.Spannable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.utils;

import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
This is the source code of exteraGram for Android.
We do not and cannot prevent the use of our code,
but be respectful and credit the original author.
Copyright @immat0x1, 2023
*/

package com.exteragram.messenger.utils;

import android.net.Uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3814,7 +3814,7 @@ private void showOrUpdateNotification(boolean notifyAboutLast) {
.setWhen(((long) lastMessageObject.messageOwner.date) * 1000);

if (Build.VERSION.SDK_INT < 31) {
mBuilder.setColor(setNotificationColor());
mBuilder.setColor(getNotificationColor());
}

long[] vibrationPattern = null;
Expand Down Expand Up @@ -3976,7 +3976,7 @@ private void showOrUpdateNotification(boolean notifyAboutLast) {
}
}

private int setNotificationColor() {
private int getNotificationColor() {
return AppUtils.getNotificationIconColor();
}

Expand Down Expand Up @@ -4608,7 +4608,7 @@ void call() {
.setCategory(NotificationCompat.CATEGORY_MESSAGE);

if (Build.VERSION.SDK_INT < 31)
builder.setColor(setNotificationColor());
builder.setColor(getNotificationColor());

try {
Intent dismissIntent = new Intent(ApplicationLoader.applicationContext, NotificationDismissReceiver.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6269,7 +6269,7 @@ public static void refreshThemeColors(boolean bg, boolean messages) {
applyProfileTheme();
applyChatTheme(false, bg);
boolean checkNavigationBarColor = !hasPreviousTheme;
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewTheme, false, checkNavigationBarColor));
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewTheme, false, checkNavigationBarColor, true));
}

public static int changeColorAccent(ThemeInfo themeInfo, int accent, int color) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
floatingButton.setVisibility(View.VISIBLE);
floatingButton.setScaleType(ImageView.ScaleType.CENTER);

Drawable drawable = CanvasUtils.drawFab();
Drawable drawable = CanvasUtils.createFabBackground();
floatingButton.setBackgroundDrawable(drawable);
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
floatingButton.setImageResource(R.drawable.ic_call);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public int getBottomOffset(int tag) {

@Override
public int getNavigationBarColor() {
return getThemedColor(Theme.key_windowBackgroundGray);
return getThemedColor(Theme.key_chat_messagePanelBackground);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23894,7 +23894,7 @@ public void setAutoDeleteHistory(int time, int action) {
}
if (canViewStats) {
items.add(LocaleController.getString("ViewStats", R.string.ViewStats));
options.add(28);
options.add(OPTION_STATISTICS);
icons.add(R.drawable.msg_stats);
}
if (selectedObject != null && selectedObject.contentType == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,7 @@ protected void onDraw(Canvas canvas) {
notifyButton = new ImageView(context);
notifySilentDrawable = new CrossOutDrawable(context, R.drawable.input_notify_on, Theme.key_chat_messagePanelIcons);
notifyButton.setImageDrawable(notifySilentDrawable);
if (ExteraConfig.useSolarIcons) notifySilentDrawable.setPaddings(0, -AndroidUtilities.dp(0.5f), 0, -AndroidUtilities.dp(0.5f));
notifySilentDrawable.setCrossOut(silent, false);
notifyButton.setContentDescription(silent ? LocaleController.getString("AccDescrChanSilentOn", R.string.AccDescrChanSilentOn) : LocaleController.getString("AccDescrChanSilentOff", R.string.AccDescrChanSilentOff));
notifyButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
Expand All @@ -2011,6 +2012,7 @@ protected void onDraw(Canvas canvas) {
silent = !silent;
if (notifySilentDrawable == null) {
notifySilentDrawable = new CrossOutDrawable(context, R.drawable.input_notify_on, Theme.key_chat_messagePanelIcons);
if (ExteraConfig.useSolarIcons) notifySilentDrawable.setPaddings(0, -AndroidUtilities.dp(0.5f), 0, -AndroidUtilities.dp(0.5f));
}
notifySilentDrawable.setCrossOut(silent, true);
notifyButton.setImageDrawable(notifySilentDrawable);
Expand Down Expand Up @@ -7728,6 +7730,7 @@ public void updateScheduleButton(boolean animated) {
notifyVisible = canWriteToChannel;
if (notifySilentDrawable == null) {
notifySilentDrawable = new CrossOutDrawable(getContext(), R.drawable.input_notify_on, Theme.key_chat_messagePanelIcons);
if (ExteraConfig.useSolarIcons) notifySilentDrawable.setPaddings(0, -AndroidUtilities.dp(0.5f), 0, -AndroidUtilities.dp(0.5f));
}
notifySilentDrawable.setCrossOut(silent, false);
notifyButton.setImageDrawable(notifySilentDrawable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
containerView.addView(doneItem, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 48, Gravity.TOP | Gravity.RIGHT));

floatingButton = new FrameLayout(context);
Drawable drawable = CanvasUtils.drawFab();
Drawable drawable = CanvasUtils.createFabBackground();
floatingButton.setBackground(drawable);
floatingButton.setVisibility(shouldShowFloatingCamera() ? View.VISIBLE : View.GONE);
StateListAnimator stateListAnimator = new StateListAnimator();
Expand Down Expand Up @@ -2473,7 +2473,7 @@ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
containerView.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 10));

writeButton = new ImageView(context);
writeButtonDrawable = CanvasUtils.drawFab(true);
writeButtonDrawable = CanvasUtils.createFabBackground(true);
writeButton.setBackgroundDrawable(writeButtonDrawable);
writeButton.setImageResource(R.drawable.attach_send);
writeButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ public void onClick(View v) {
} else {
addView(bottomTabContainer, LayoutHelper.createFrame(40 + 16, 40 + 8, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, 0, 0, 2, 0));

Drawable drawable = CanvasUtils.drawFab();
Drawable drawable = CanvasUtils.createFabBackground();
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[]{}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
floatingButton = new ImageView(context);
floatingButton.setScaleType(ImageView.ScaleType.CENTER);

Drawable drawable = CanvasUtils.drawFab();
Drawable drawable = CanvasUtils.createFabBackground();
floatingButton.setBackgroundDrawable(drawable);
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
floatingButton.setImageResource(R.drawable.floating_check);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
containerView.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 10));

ImageView writeButton = new ImageView(context);
Drawable drawable = CanvasUtils.drawFab(true);
Drawable drawable = CanvasUtils.createFabBackground(true);
writeButton.setBackgroundDrawable(drawable);
writeButton.setImageResource(R.drawable.attach_send);
writeButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ public void dismissInternal() {

floatingButton = new RLottieImageView(context);
floatingButton.setScaleType(ImageView.ScaleType.CENTER);
Drawable drawable = CanvasUtils.drawFab();
Drawable drawable = CanvasUtils.createFabBackground();
floatingButton.setBackgroundDrawable(drawable);
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
Expand Down
21 changes: 15 additions & 6 deletions TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4155,7 +4155,7 @@ protected void onDraw(Canvas canvas) {


FrameLayout writeButtonBackground = new FrameLayout(context);
Drawable writeButtonDrawable = CanvasUtils.drawFab(true);
Drawable writeButtonDrawable = CanvasUtils.createFabBackground(true);
writeButtonBackground.setBackgroundDrawable(writeButtonDrawable);
writeButtonBackground.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
writeButtonBackground.setOutlineProvider(new ViewOutlineProvider() {
Expand Down Expand Up @@ -4325,11 +4325,20 @@ public void setAlpha(float alpha) {
if (inPreviewMode) {
final TLRPC.User currentUser = getUserConfig().getCurrentUser();
avatarContainer = new ChatAvatarContainer(actionBar.getContext(), null, false);
avatarContainer.setTitle(UserObject.getUserName(currentUser));
avatarContainer.setSubtitle(LocaleController.formatUserStatus(currentAccount, currentUser));
avatarContainer.setUserAvatar(currentUser, true);
if (folderId == 1) {
avatarContainer.getSubtitleTextView().setVisibility(View.GONE);
avatarContainer.setTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats));
AvatarDrawable avatarDrawable = new AvatarDrawable();
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_ARCHIVED);
avatarDrawable.setColor(getThemedColor(SharedConfig.archiveHidden ? Theme.key_avatar_backgroundArchivedHidden : Theme.key_avatar_backgroundArchived));
avatarContainer.getAvatarImageView().setImage(null, null, avatarDrawable, 42, 0);
} else {
avatarContainer.setTitle(UserObject.getUserName(currentUser));
avatarContainer.setSubtitle(LocaleController.formatUserStatus(currentAccount, currentUser));
avatarContainer.setUserAvatar(currentUser, true);
}
avatarContainer.setOccupyStatusBar(false);
avatarContainer.setLeftPadding(AndroidUtilities.dp(10));
avatarContainer.setLeftPadding(AndroidUtilities.dp(12));
actionBar.addView(avatarContainer, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 40, 0));
floatingButton.setVisibility(View.INVISIBLE);
actionBar.setOccupyStatusBar(false);
Expand Down Expand Up @@ -10467,7 +10476,7 @@ private void updateFloatingButtonColor() {
if (getParentActivity() == null || floatingButtonContainer == null) {
return;
}
Drawable drawable = CanvasUtils.drawFab();
Drawable drawable = CanvasUtils.createFabBackground();
floatingButtonContainer.setBackground(drawable);
}

Expand Down
Loading

0 comments on commit 4ee4b7c

Please sign in to comment.