Show Tab Name in ActionBar when Tab Names disabled
This commit is contained in:
@@ -42,7 +42,7 @@ public class ExteraConfig {
|
||||
public static boolean centerTitle;
|
||||
public static int tabIcons; // icons with titles - 0, titles - 1, icons - 2
|
||||
public static int tabStyle;
|
||||
public static int actionBarTitle;
|
||||
public static int titleText;
|
||||
|
||||
public static boolean useSolarIcons;
|
||||
|
||||
@@ -182,7 +182,7 @@ public class ExteraConfig {
|
||||
tabCounter = preferences.getBoolean("tabCounter", true);
|
||||
tabIcons = preferences.getInt("tabIcons", 1);
|
||||
tabStyle = preferences.getInt("tabStyle", 1);
|
||||
actionBarTitle = preferences.getInt("actionBarTitle", 0);
|
||||
titleText = preferences.getInt("titleText", 0);
|
||||
|
||||
useSolarIcons = preferences.getBoolean("useSolarIcons", true);
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ public class AppearancePreferencesActivity extends BasePreferencesActivity {
|
||||
LocaleController.getString("TabStylePills", R.string.TabStylePills),
|
||||
}, titles = new CharSequence[]{
|
||||
LocaleController.getString("exteraAppName", R.string.exteraAppName),
|
||||
LocaleController.getString("SearchAllChatsShort", R.string.SearchAllChatsShort),
|
||||
LocaleController.getString("ActionBarTitleUsername", R.string.ActionBarTitleUsername),
|
||||
LocaleController.getString("ActionBarTitleName", R.string.ActionBarTitleName)
|
||||
}, tabIcons = new CharSequence[]{
|
||||
@@ -126,8 +125,8 @@ public class AppearancePreferencesActivity extends BasePreferencesActivity {
|
||||
actionBarSetupRow = newRow();
|
||||
hideActionBarStatusRow = getUserConfig().isPremium() ? newRow() : -1;
|
||||
hideAllChatsRow = newRow();
|
||||
tabCounterRow = newRow();
|
||||
centerTitleRow = newRow();
|
||||
tabCounterRow = newRow();
|
||||
tabStyleRow = newRow();
|
||||
tabTitleRow = newRow();
|
||||
actionBarTitleRow = newRow();
|
||||
@@ -304,8 +303,8 @@ public class AppearancePreferencesActivity extends BasePreferencesActivity {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
PopupUtils.showDialog(titles, LocaleController.getString("ActionBarTitle", R.string.ActionBarTitle), ExteraConfig.actionBarTitle, getContext(), i -> {
|
||||
ExteraConfig.editor.putInt("actionBarTitle", ExteraConfig.actionBarTitle = i).apply();
|
||||
PopupUtils.showDialog(titles, LocaleController.getString("ActionBarTitle", R.string.ActionBarTitle), ExteraConfig.titleText, getContext(), i -> {
|
||||
ExteraConfig.editor.putInt("titleText", ExteraConfig.titleText = i).apply();
|
||||
mainScreenSetupCell.updateTitle(true);
|
||||
parentLayout.rebuildAllFragmentViews(false, false);
|
||||
listAdapter.notifyItemChanged(actionBarTitleRow, payload);
|
||||
@@ -473,7 +472,7 @@ public class AppearancePreferencesActivity extends BasePreferencesActivity {
|
||||
if (position == eventChooserRow) {
|
||||
textSettingsCell.setTextAndValue(LocaleController.getString("DrawerIconSet", R.string.DrawerIconSet), events[ExteraConfig.eventType], payload, true);
|
||||
} else if (position == actionBarTitleRow) {
|
||||
textSettingsCell.setTextAndValue(LocaleController.getString("ActionBarTitle", R.string.ActionBarTitle), titles[ExteraConfig.actionBarTitle], payload, false);
|
||||
textSettingsCell.setTextAndValue(LocaleController.getString("ActionBarTitle", R.string.ActionBarTitle), titles[ExteraConfig.titleText], payload, false);
|
||||
} else if (position == tabTitleRow) {
|
||||
textSettingsCell.setTextAndValue(LocaleController.getString("TabTitleStyle", R.string.TabTitleStyle), tabIcons[ExteraConfig.tabIcons], payload, true);
|
||||
} else if (position == tabStyleRow) {
|
||||
|
||||
@@ -368,8 +368,9 @@ public class ChatsPreferencesActivity extends BasePreferencesActivity implements
|
||||
PopupUtils.showDialog(videoMessagesCamera, LocaleController.getString("VideoMessagesCamera", R.string.VideoMessagesCamera), ExteraConfig.videoMessagesCamera, getContext(), which -> {
|
||||
int old = ExteraConfig.videoMessagesCamera;
|
||||
ExteraConfig.editor.putInt("videoMessagesCamera", ExteraConfig.videoMessagesCamera = which).apply();
|
||||
if (old == which)
|
||||
if (old == which) {
|
||||
return;
|
||||
}
|
||||
if (old == 2 && ExteraConfig.videoMessagesCamera != 2) {
|
||||
updateRowsId();
|
||||
listAdapter.notifyItemInserted(rememberLastUsedCameraRow);
|
||||
@@ -393,7 +394,7 @@ public class ChatsPreferencesActivity extends BasePreferencesActivity implements
|
||||
((TextCheckCell) view).setChecked(ExteraConfig.disablePlayback);
|
||||
showBulletin();
|
||||
} else if (position == doubleTapSeekDurationRow) {
|
||||
if (getParentActivity()==null) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
PopupUtils.showDialog(doubleTapSeekDuration, LocaleController.getString("DoubleTapSeekDuration", R.string.DoubleTapSeekDuration), ExteraConfig.doubleTapSeekDuration, getContext(), which -> {
|
||||
|
||||
@@ -31,24 +31,17 @@ import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||
|
||||
public class LocaleUtils {
|
||||
public static String getActionBarTitle() {
|
||||
return getActionBarTitle(ExteraConfig.actionBarTitle);
|
||||
}
|
||||
|
||||
public static String getActionBarTitle(int num) {
|
||||
TLRPC.User user = UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser();
|
||||
String title;
|
||||
if (num == 0) {
|
||||
int actionBarTitle = ExteraConfig.titleText;
|
||||
if (actionBarTitle == 0) {
|
||||
title = LocaleController.getString("exteraAppName", R.string.exteraAppName);
|
||||
} else if (num == 1) {
|
||||
title = LocaleController.getString("SearchAllChatsShort", R.string.SearchAllChatsShort);
|
||||
} else if (num == 2) {
|
||||
if (!TextUtils.isEmpty(UserObject.getPublicUsername(user))) {
|
||||
} else {
|
||||
TLRPC.User user = UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser();
|
||||
if (actionBarTitle == 1 && !TextUtils.isEmpty(UserObject.getPublicUsername(user))) {
|
||||
title = UserObject.getPublicUsername(user);
|
||||
} else {
|
||||
title = UserObject.getFirstName(user);
|
||||
}
|
||||
} else {
|
||||
title = UserObject.getFirstName(user);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -1687,6 +1687,71 @@ public class ActionBar extends FrameLayout {
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
private AnimatorSet titleAnimator;
|
||||
|
||||
// TODO: rework with gesture progress
|
||||
public void setTitleAnimatedX(CharSequence title, Drawable rightDrawable, boolean forward, int duration) {
|
||||
if (titleTextView[0] == null || title == null) {
|
||||
setTitle(title, rightDrawable);
|
||||
return;
|
||||
}
|
||||
|
||||
if (titleTextView[1] != null) {
|
||||
if (titleTextView[1].getParent() != null) {
|
||||
ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
|
||||
viewGroup.removeView(titleTextView[1]);
|
||||
}
|
||||
titleTextView[1] = null;
|
||||
}
|
||||
|
||||
if (titleAnimator != null) {
|
||||
titleAnimator.cancel();
|
||||
titleAnimator = null;
|
||||
}
|
||||
|
||||
titleTextView[1] = titleTextView[0];
|
||||
titleTextView[0] = null;
|
||||
setTitle(title, rightDrawable);
|
||||
titleAnimationRunning = true;
|
||||
|
||||
float amplitude = AndroidUtilities.dp(10) * (forward ? -1 : 1);
|
||||
|
||||
titleTextView[1].setTranslationX(0);
|
||||
titleTextView[1].setTranslationY(0);
|
||||
titleTextView[0].setTranslationX(-amplitude);
|
||||
titleTextView[0].setTranslationY(0);
|
||||
|
||||
titleTextView[0].setAlpha(0);
|
||||
titleTextView[1].setAlpha(1);
|
||||
titleTextView[0].setVisibility(View.VISIBLE);
|
||||
titleTextView[1].setVisibility(View.VISIBLE);
|
||||
|
||||
ArrayList<Animator> arrayList = new ArrayList<>();
|
||||
arrayList.add(ObjectAnimator.ofFloat(titleTextView[1], View.ALPHA, 0));
|
||||
arrayList.add(ObjectAnimator.ofFloat(titleTextView[0], View.ALPHA, 1));
|
||||
arrayList.add(ObjectAnimator.ofFloat(titleTextView[1], View.TRANSLATION_X, amplitude));
|
||||
arrayList.add(ObjectAnimator.ofFloat(titleTextView[0], View.TRANSLATION_X, 0));
|
||||
titleAnimator = new AnimatorSet();
|
||||
titleAnimator.playTogether(arrayList);
|
||||
titleAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (titleTextView[1] != null && titleTextView[1].getParent() != null) {
|
||||
ViewGroup viewGroup = (ViewGroup) titleTextView[1].getParent();
|
||||
viewGroup.removeView(titleTextView[1]);
|
||||
}
|
||||
titleTextView[1] = null;
|
||||
titleAnimationRunning = false;
|
||||
|
||||
requestLayout();
|
||||
}
|
||||
});
|
||||
titleAnimator.setDuration(duration);
|
||||
titleAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
|
||||
titleAnimator.start();
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
|
||||
@@ -1191,6 +1191,7 @@ public class FilterTabsView extends FrameLayout {
|
||||
if (delegate != null) {
|
||||
delegate.onPageSelected(tab, scrollingForward);
|
||||
delegate.onTabSelected(tab, scrollingForward, true);
|
||||
oldAnimatedTab = currentPosition;
|
||||
}
|
||||
scrollToChild(position);
|
||||
}
|
||||
@@ -1285,6 +1286,7 @@ public class FilterTabsView extends FrameLayout {
|
||||
listView.setItemAnimator(animated ? itemAnimator : null);
|
||||
adapter.notifyDataSetChanged();
|
||||
delegate.onTabSelected(tabs.get(currentPosition), false, false);
|
||||
oldAnimatedTab = currentPosition;
|
||||
}
|
||||
|
||||
public void animateColorsTo(int line, int active, int unactive, int selector, int background) {
|
||||
@@ -1521,6 +1523,8 @@ public class FilterTabsView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private int oldAnimatedTab = -1;
|
||||
|
||||
public void selectTabWithId(int id, float progress) {
|
||||
int position = idToPosition.get(id, -1);
|
||||
if (position < 0) {
|
||||
@@ -1544,8 +1548,13 @@ public class FilterTabsView extends FrameLayout {
|
||||
invalidate();
|
||||
scrollToChild(position);
|
||||
|
||||
if ((((progress >= 0.5f && oldAnimatedTab != position) || (progress <= 0.5f && oldAnimatedTab != currentPosition)) && manualScrollingToPosition != currentPosition)) {
|
||||
position = progress >= 0.5f ? position : currentPosition;
|
||||
delegate.onTabSelected(tabs.get(position), currentPosition < position, true);
|
||||
oldAnimatedTab = position;
|
||||
}
|
||||
|
||||
if (progress >= 1.0f) {
|
||||
if (manualScrollingToPosition != currentPosition) delegate.onTabSelected(tabs.get(position), currentPosition < position, true);
|
||||
manualScrollingToPosition = -1;
|
||||
manualScrollingToId = -1;
|
||||
currentPosition = position;
|
||||
|
||||
@@ -2538,6 +2538,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
return actionBar;
|
||||
}
|
||||
|
||||
private String actionBarDefaultTitle;
|
||||
|
||||
@Override
|
||||
public View createView(final Context context) {
|
||||
searching = false;
|
||||
@@ -2737,6 +2739,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
} else {
|
||||
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
||||
}
|
||||
actionBarDefaultTitle = actionBar.getTitle();
|
||||
actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault));
|
||||
} else {
|
||||
if (searchString != null || folderId != 0) {
|
||||
@@ -2758,6 +2761,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
actionBar.setTitle(LocaleUtils.getActionBarTitle());
|
||||
}
|
||||
}
|
||||
actionBarDefaultTitle = actionBar.getTitle();
|
||||
if (folderId == 0) {
|
||||
actionBar.setSupportsHolidayImage(true);
|
||||
}
|
||||
@@ -3053,26 +3057,26 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
showDeleteAlert(getMessagesController().getDialogFilters().get(id));
|
||||
}
|
||||
|
||||
// private int lastTitleType = ExteraConfig.tabIcons;
|
||||
//
|
||||
// @Override
|
||||
// public void onTabSelected(FilterTabsView.Tab tab, boolean forward, boolean animated) {
|
||||
// if (ExteraConfig.tabIcons != 2) {
|
||||
// if (lastTitleType == 2) {
|
||||
// actionBar.setTitle(actionBarDefaultTitle);
|
||||
// lastTitleType = ExteraConfig.tabIcons;
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
// if (!selectedDialogs.isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
// if (animated) {
|
||||
// actionBar.setTitleAnimatedX(tab.isDefault ? actionBarDefaultTitle : tab.realTitle, tab.isDefault ? statusDrawable : null, forward, 200);
|
||||
// } else {
|
||||
// actionBar.setTitle(tab.isDefault ? actionBarDefaultTitle : tab.realTitle, tab.isDefault ? statusDrawable : null);
|
||||
// }
|
||||
// }
|
||||
private int lastTitleType = ExteraConfig.titleText;
|
||||
|
||||
@Override
|
||||
public void onTabSelected(FilterTabsView.Tab tab, boolean forward, boolean animated) {
|
||||
if (ExteraConfig.tabIcons != 2 || lastTitleType != ExteraConfig.titleText) {
|
||||
actionBar.setTitle(actionBarDefaultTitle = LocaleUtils.getActionBarTitle(), statusDrawable);
|
||||
lastTitleType = ExteraConfig.titleText;
|
||||
if (ExteraConfig.tabIcons != 2) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!selectedDialogs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (animated) {
|
||||
actionBar.setTitleAnimatedX(tab.isDefault ? actionBarDefaultTitle : tab.realTitle, tab.isDefault ? statusDrawable : null, forward, 350);
|
||||
} else {
|
||||
actionBar.setTitle(tab.isDefault ? actionBarDefaultTitle : tab.realTitle, tab.isDefault ? statusDrawable : null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5502,7 +5506,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
viewPages[a].listView.requestLayout();
|
||||
viewPages[a].requestLayout();
|
||||
}
|
||||
|
||||
if (!actionBarDefaultTitle.equals(actionBar.getTitle())) {
|
||||
if (animated) {
|
||||
actionBar.setTitleAnimatedX(actionBarDefaultTitle, statusDrawable, false, 350);
|
||||
} else {
|
||||
actionBar.setTitle(actionBarDefaultTitle, statusDrawable);
|
||||
}
|
||||
}
|
||||
filterTabsView.resetTabId();
|
||||
}
|
||||
updateDrawerSwipeEnabled();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<string name="HideActionBarStatus">Hide Status</string>
|
||||
<string name="HideAllChats">Hide \"%1$s\" Tab</string>
|
||||
<string name="TabCounter">Tab Counter</string>
|
||||
<string name="CenterTitle">Center Title in Action Bar</string>
|
||||
<string name="CenterTitle">Center Title</string>
|
||||
<string name="ActionBarTitle">Title Text</string>
|
||||
<string name="TabTitleStyle">Tab Title</string>
|
||||
<string name="TabTitleStyleTextWithIcons">Names with Icons</string>
|
||||
|
||||
Reference in New Issue
Block a user