267 lines
15 KiB
Java
267 lines
15 KiB
Java
package com.discord.widgets.tabs;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import c.a.k.b;
|
|
import com.discord.databinding.TabsHostBottomNavigationViewBinding;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.color.ColorCompatKt;
|
|
import com.discord.utilities.view.extensions.ViewExtensions;
|
|
import com.discord.views.user.UserAvatarPresenceView;
|
|
import com.discord.views.user.UserAvatarPresenceViewController;
|
|
import d0.o;
|
|
import d0.t.h0;
|
|
import d0.z.d.m;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: TabsHostBottomNavigationView.kt */
|
|
public final class TabsHostBottomNavigationView extends LinearLayout {
|
|
private final TabsHostBottomNavigationViewBinding binding;
|
|
private final Set<HeightChangedListener> heightChangedListeners;
|
|
private Map<View, ? extends NavigationTab> iconToNavigationTabMap;
|
|
private Map<NavigationTab, ? extends View> navigationTabToViewMap;
|
|
private Map<ImageView, ? extends NavigationTab> tintableIconToNavigationTabMap;
|
|
private UserAvatarPresenceViewController userAvatarPresenceViewController;
|
|
|
|
/* compiled from: TabsHostBottomNavigationView.kt */
|
|
public interface HeightChangedListener {
|
|
void onHeightChanged(int i);
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public TabsHostBottomNavigationView(Context context) {
|
|
super(context);
|
|
m.checkNotNullParameter(context, "context");
|
|
TabsHostBottomNavigationViewBinding a = TabsHostBottomNavigationViewBinding.a(LayoutInflater.from(getContext()), this, true);
|
|
m.checkNotNullExpressionValue(a, "TabsHostBottomNavigation…rom(context), this, true)");
|
|
this.binding = a;
|
|
this.heightChangedListeners = new LinkedHashSet();
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public TabsHostBottomNavigationView(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
m.checkNotNullParameter(context, "context");
|
|
TabsHostBottomNavigationViewBinding a = TabsHostBottomNavigationViewBinding.a(LayoutInflater.from(getContext()), this, true);
|
|
m.checkNotNullExpressionValue(a, "TabsHostBottomNavigation…rom(context), this, true)");
|
|
this.binding = a;
|
|
this.heightChangedListeners = new LinkedHashSet();
|
|
initialize();
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public TabsHostBottomNavigationView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
m.checkNotNullParameter(context, "context");
|
|
TabsHostBottomNavigationViewBinding a = TabsHostBottomNavigationViewBinding.a(LayoutInflater.from(getContext()), this, true);
|
|
m.checkNotNullExpressionValue(a, "TabsHostBottomNavigation…rom(context), this, true)");
|
|
this.binding = a;
|
|
this.heightChangedListeners = new LinkedHashSet();
|
|
initialize();
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ TabsHostBottomNavigationView(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ TabsHostBottomNavigationView(Context context, AttributeSet attributeSet, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, (i & 2) != 0 ? null : attributeSet);
|
|
}
|
|
|
|
private final void initialize() {
|
|
int i;
|
|
Resources resources = getResources();
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
|
if (resources.getConfiguration().orientation == 1) {
|
|
Resources resources2 = getResources();
|
|
m.checkNotNullExpressionValue(resources2, "resources");
|
|
i = resources2.getDisplayMetrics().widthPixels;
|
|
} else {
|
|
Resources resources3 = getResources();
|
|
m.checkNotNullExpressionValue(resources3, "resources");
|
|
i = resources3.getDisplayMetrics().heightPixels;
|
|
}
|
|
LinearLayout linearLayout = this.binding.n;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.tabsHostBottomNavTabsContainer");
|
|
ViewGroup.LayoutParams layoutParams = linearLayout.getLayoutParams();
|
|
layoutParams.width = i;
|
|
LinearLayout linearLayout2 = this.binding.n;
|
|
m.checkNotNullExpressionValue(linearLayout2, "binding.tabsHostBottomNavTabsContainer");
|
|
linearLayout2.setLayoutParams(layoutParams);
|
|
ImageView imageView = this.binding.e;
|
|
NavigationTab navigationTab = NavigationTab.HOME;
|
|
ImageView imageView2 = this.binding.b;
|
|
NavigationTab navigationTab2 = NavigationTab.FRIENDS;
|
|
ImageView imageView3 = this.binding.j;
|
|
NavigationTab navigationTab3 = NavigationTab.SEARCH;
|
|
ImageView imageView4 = this.binding.h;
|
|
NavigationTab navigationTab4 = NavigationTab.MENTIONS;
|
|
ImageView imageView5 = this.binding.l;
|
|
NavigationTab navigationTab5 = NavigationTab.DISCOVERY;
|
|
this.tintableIconToNavigationTabMap = h0.mapOf(o.to(imageView, navigationTab), o.to(imageView2, navigationTab2), o.to(imageView3, navigationTab3), o.to(imageView4, navigationTab4), o.to(imageView5, navigationTab5));
|
|
UserAvatarPresenceView userAvatarPresenceView = this.binding.o;
|
|
NavigationTab navigationTab6 = NavigationTab.SETTINGS;
|
|
this.iconToNavigationTabMap = h0.mapOf(o.to(this.binding.e, navigationTab), o.to(this.binding.b, navigationTab2), o.to(this.binding.j, navigationTab3), o.to(this.binding.h, navigationTab4), o.to(userAvatarPresenceView, navigationTab6), o.to(this.binding.l, navigationTab5));
|
|
this.navigationTabToViewMap = h0.mapOf(o.to(navigationTab, this.binding.f), o.to(navigationTab2, this.binding.f1639c), o.to(navigationTab3, this.binding.k), o.to(navigationTab4, this.binding.i), o.to(navigationTab6, this.binding.p), o.to(navigationTab5, this.binding.m));
|
|
UserAvatarPresenceView userAvatarPresenceView2 = this.binding.o;
|
|
m.checkNotNullExpressionValue(userAvatarPresenceView2, "binding.tabsHostBottomNavUserAvatarPresenceView");
|
|
this.userAvatarPresenceViewController = new UserAvatarPresenceViewController(userAvatarPresenceView2, null, null, null, 14);
|
|
}
|
|
|
|
private final void updateNotificationBadges(int i, int i2) {
|
|
TextView textView = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView, "binding.tabsHostBottomNavHomeNotificationsBadge");
|
|
textView.setText(String.valueOf(i));
|
|
TextView textView2 = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView2, "binding.tabsHostBottomNavHomeNotificationsBadge");
|
|
int i3 = 8;
|
|
textView2.setVisibility(i > 0 ? 0 : 8);
|
|
TextView textView3 = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView3, "binding.tabsHostBottomNavHomeNotificationsBadge");
|
|
Resources resources = getResources();
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
|
textView3.setContentDescription(b.h(resources, 2131891312, new Object[]{String.valueOf(i)}, null, 4));
|
|
TextView textView4 = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView4, "binding.tabsHostBottomNavFriendsNotificationsBadge");
|
|
textView4.setText(String.valueOf(i2));
|
|
TextView textView5 = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView5, "binding.tabsHostBottomNavFriendsNotificationsBadge");
|
|
if (i2 > 0) {
|
|
i3 = 0;
|
|
}
|
|
textView5.setVisibility(i3);
|
|
TextView textView6 = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView6, "binding.tabsHostBottomNavFriendsNotificationsBadge");
|
|
Resources resources2 = getResources();
|
|
m.checkNotNullExpressionValue(resources2, "resources");
|
|
textView6.setContentDescription(b.h(resources2, 2131890482, new Object[]{String.valueOf(i2)}, null, 4));
|
|
}
|
|
|
|
public final void addHeightChangedListener(HeightChangedListener heightChangedListener) {
|
|
m.checkNotNullParameter(heightChangedListener, "heightChangedListener");
|
|
this.heightChangedListeners.add(heightChangedListener);
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onSizeChanged(int i, int i2, int i3, int i4) {
|
|
super.onSizeChanged(i, i2, i3, i4);
|
|
for (HeightChangedListener heightChangedListener : this.heightChangedListeners) {
|
|
heightChangedListener.onHeightChanged(i2);
|
|
}
|
|
}
|
|
|
|
public final void updateView(NavigationTab navigationTab, Function1<? super NavigationTab, Unit> function1, boolean z2, long j, Set<? extends NavigationTab> set, int i, int i2, Function0<Unit> function0, Function0<Unit> function02, Function0<Unit> function03) {
|
|
m.checkNotNullParameter(navigationTab, "selectedTab");
|
|
m.checkNotNullParameter(function1, "onTabSelected");
|
|
m.checkNotNullParameter(set, "visibleTabs");
|
|
m.checkNotNullParameter(function0, "onSearchClick");
|
|
m.checkNotNullParameter(function02, "onSettingsLongPress");
|
|
m.checkNotNullParameter(function03, "onMentionsLongPress");
|
|
LinearLayout linearLayout = this.binding.n;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.tabsHostBottomNavTabsContainer");
|
|
linearLayout.setWeightSum((float) set.size());
|
|
ConstraintLayout constraintLayout = this.binding.f;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.tabsHostBottomNavHomeItem");
|
|
int i3 = 8;
|
|
constraintLayout.setVisibility(set.contains(NavigationTab.HOME) ? 0 : 8);
|
|
ConstraintLayout constraintLayout2 = this.binding.f1639c;
|
|
m.checkNotNullExpressionValue(constraintLayout2, "binding.tabsHostBottomNavFriendsItem");
|
|
constraintLayout2.setVisibility(set.contains(NavigationTab.FRIENDS) ? 0 : 8);
|
|
FrameLayout frameLayout = this.binding.k;
|
|
m.checkNotNullExpressionValue(frameLayout, "binding.tabsHostBottomNavSearchItem");
|
|
frameLayout.setVisibility(set.contains(NavigationTab.SEARCH) ? 0 : 8);
|
|
FrameLayout frameLayout2 = this.binding.i;
|
|
m.checkNotNullExpressionValue(frameLayout2, "binding.tabsHostBottomNavMentionsItem");
|
|
frameLayout2.setVisibility(set.contains(NavigationTab.MENTIONS) ? 0 : 8);
|
|
FrameLayout frameLayout3 = this.binding.p;
|
|
m.checkNotNullExpressionValue(frameLayout3, "binding.tabsHostBottomNavUserSettingsItem");
|
|
frameLayout3.setVisibility(set.contains(NavigationTab.SETTINGS) ? 0 : 8);
|
|
FrameLayout frameLayout4 = this.binding.m;
|
|
m.checkNotNullExpressionValue(frameLayout4, "binding.tabsHostBottomNavStageDiscoveryItem");
|
|
if (set.contains(NavigationTab.DISCOVERY)) {
|
|
i3 = 0;
|
|
}
|
|
frameLayout4.setVisibility(i3);
|
|
Map<ImageView, ? extends NavigationTab> map = this.tintableIconToNavigationTabMap;
|
|
if (map == null) {
|
|
m.throwUninitializedPropertyAccessException("tintableIconToNavigationTabMap");
|
|
}
|
|
Iterator<T> it = map.entrySet().iterator();
|
|
while (it.hasNext()) {
|
|
Map.Entry entry = (Map.Entry) it.next();
|
|
ColorCompatKt.tintWithColor((ImageView) entry.getKey(), ColorCompat.getThemedColor(getContext(), ((NavigationTab) entry.getValue()) == navigationTab ? 2130968984 : 2130968949));
|
|
}
|
|
Map<View, ? extends NavigationTab> map2 = this.iconToNavigationTabMap;
|
|
if (map2 == null) {
|
|
m.throwUninitializedPropertyAccessException("iconToNavigationTabMap");
|
|
}
|
|
Iterator<T> it2 = map2.entrySet().iterator();
|
|
while (it2.hasNext()) {
|
|
Map.Entry entry2 = (Map.Entry) it2.next();
|
|
((View) entry2.getKey()).setAlpha(navigationTab == ((NavigationTab) entry2.getValue()) ? 1.0f : 0.5f);
|
|
}
|
|
Map<NavigationTab, ? extends View> map3 = this.navigationTabToViewMap;
|
|
if (map3 == null) {
|
|
m.throwUninitializedPropertyAccessException("navigationTabToViewMap");
|
|
}
|
|
Iterator<T> it3 = map3.entrySet().iterator();
|
|
while (it3.hasNext()) {
|
|
Map.Entry entry3 = (Map.Entry) it3.next();
|
|
((View) entry3.getValue()).setSelected(navigationTab == ((NavigationTab) entry3.getKey()));
|
|
}
|
|
UserAvatarPresenceViewController userAvatarPresenceViewController = this.userAvatarPresenceViewController;
|
|
if (userAvatarPresenceViewController == null) {
|
|
m.throwUninitializedPropertyAccessException("userAvatarPresenceViewController");
|
|
}
|
|
long j2 = userAvatarPresenceViewController.a;
|
|
userAvatarPresenceViewController.a = j;
|
|
if (j2 != j) {
|
|
userAvatarPresenceViewController.bind();
|
|
}
|
|
updateNotificationBadges(i, i2);
|
|
if (z2) {
|
|
this.binding.f.setOnClickListener(new TabsHostBottomNavigationView$updateView$4(function1));
|
|
this.binding.f1639c.setOnClickListener(new TabsHostBottomNavigationView$updateView$5(function1));
|
|
this.binding.k.setOnClickListener(new TabsHostBottomNavigationView$updateView$6(function0));
|
|
this.binding.i.setOnClickListener(new TabsHostBottomNavigationView$updateView$7(function1));
|
|
this.binding.p.setOnClickListener(new TabsHostBottomNavigationView$updateView$8(function1));
|
|
this.binding.m.setOnClickListener(new TabsHostBottomNavigationView$updateView$9(function1));
|
|
FrameLayout frameLayout5 = this.binding.p;
|
|
m.checkNotNullExpressionValue(frameLayout5, "binding.tabsHostBottomNavUserSettingsItem");
|
|
ViewExtensions.setOnLongClickListenerConsumeClick(frameLayout5, new TabsHostBottomNavigationView$updateView$10(function02));
|
|
if (set.contains(NavigationTab.DISCOVERY)) {
|
|
FrameLayout frameLayout6 = this.binding.i;
|
|
m.checkNotNullExpressionValue(frameLayout6, "binding.tabsHostBottomNavMentionsItem");
|
|
ViewExtensions.setOnLongClickListenerConsumeClick(frameLayout6, new TabsHostBottomNavigationView$updateView$11(function03));
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.binding.f.setOnClickListener(TabsHostBottomNavigationView$updateView$12.INSTANCE);
|
|
this.binding.f1639c.setOnClickListener(TabsHostBottomNavigationView$updateView$13.INSTANCE);
|
|
this.binding.k.setOnClickListener(TabsHostBottomNavigationView$updateView$14.INSTANCE);
|
|
this.binding.i.setOnClickListener(TabsHostBottomNavigationView$updateView$15.INSTANCE);
|
|
this.binding.m.setOnClickListener(TabsHostBottomNavigationView$updateView$16.INSTANCE);
|
|
this.binding.p.setOnClickListener(TabsHostBottomNavigationView$updateView$17.INSTANCE);
|
|
this.binding.p.setOnLongClickListener(TabsHostBottomNavigationView$updateView$18.INSTANCE);
|
|
this.binding.i.setOnLongClickListener(TabsHostBottomNavigationView$updateView$19.INSTANCE);
|
|
}
|
|
}
|