diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 0ffcc996cb..958e09f654 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -3376,7 +3376,12 @@ public boolean canToggleSearch() { } else { statusDrawable = new AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable(null, dp(26)); statusDrawable.center = true; - actionBar.setTitle(NaConfig.INSTANCE.getCustomTitle().String(), statusDrawable); + String title = NaConfig.INSTANCE.getCustomTitle().String(); + if (NaConfig.INSTANCE.getCustomTitleUserName().Bool()) { + TLRPC.User self = UserConfig.getInstance(currentAccount).getCurrentUser(); + if (self != null && self.first_name != null) title = self.first_name; + } + actionBar.setTitle(title, statusDrawable); actionBar.setOnLongClickListener(v -> { if (NekoConfig.hideAllTab.Bool() && filterTabsView != null && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE) { filterTabsView.toggleAllTabs(true); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextInput.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextInput.java index aae95b8bbb..3cce153efd 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextInput.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextInput.java @@ -23,6 +23,8 @@ public class ConfigCellTextInput extends AbstractConfigCell { private final ConfigItem bindConfig; private final String hint; private final String title; + private boolean enabled = true; + public TextSettingsCell cell; private final Runnable onClickCustom; private final Function inputChecker; @@ -60,15 +62,25 @@ public String getKey() { } public boolean isEnabled() { - return true; + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + if (this.cell != null) + this.cell.setEnabled(this.enabled, null); } public void onBindViewHolder(RecyclerView.ViewHolder holder) { TextSettingsCell cell = (TextSettingsCell) holder.itemView; + this.cell = cell; cell.setTextAndValue(title, bindConfig.String(), cellGroup.needSetDivider(this)); + cell.setCanDisable(true); + cell.setEnabled(enabled, null); } public void onClick() { + if (!enabled) return; if (onClickCustom != null) { try { onClickCustom.run(); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java index 37cbda544b..23eaf3023c 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java @@ -233,6 +233,7 @@ public class NekoGeneralSettingsActivity extends BaseNekoXSettingsActivity { private final AbstractConfigCell customSavePathRow = cellGroup.appendCell(new ConfigCellTextInput(null, NekoConfig.customSavePath, LocaleController.getString("customSavePathHint", R.string.customSavePathHint), null, (input) -> input.matches("^[A-za-z0-9.]{1,255}$") || input.isEmpty() ? input : (String) NekoConfig.customSavePath.defaultValue)); + private final AbstractConfigCell customTitleUserNameRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getCustomTitleUserName())); private final AbstractConfigCell useSystemUnlockRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getUseSystemUnlock())); private final AbstractConfigCell disableUndoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableUndo)); private final AbstractConfigCell showIdAndDcRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.showIdAndDc)); @@ -503,6 +504,11 @@ public void onItemClick(int id) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); } else if (key.equals(NaConfig.INSTANCE.getSentryAnalytics().getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); + } else if (key.equals(NaConfig.INSTANCE.getCustomTitleUserName().getKey())) { + boolean enabled = (Boolean) newValue; + ((ConfigCellTextInput) customTitleRow).setEnabled(!enabled); + listAdapter.notifyItemChanged(cellGroup.rows.indexOf(customTitleRow)); + restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); } }; @@ -891,6 +897,9 @@ private void setCanNotChange() { if (NekoConfig.useOSMDroidMap.Bool()) ((ConfigCellTextCheck) mapDriftingFixForGoogleMapsRow).setEnabled(false); + if (NaConfig.INSTANCE.getCustomTitleUserName().Bool()) + ((ConfigCellTextInput) customTitleRow).setEnabled(false); + if (NekoConfig.useTelegramTranslateInChat.Bool()) ((ConfigCellCustom) translationProviderRow).setEnabled(false); diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index 07d93f2fe5..a31479ab10 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -664,6 +664,12 @@ object NaConfig { ConfigItem.configTypeBool, false ) + val customTitleUserName = + addConfig( + "CustomTitleUserName", + ConfigItem.configTypeBool, + false + ) private fun addConfig( k: String, diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml index ebdf2f1916..f4bfe65dbb 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -167,4 +167,5 @@ 不使用 Pangu 发送 默认 Hls 视频质量 禁用 Bot 的打开小程序按钮 + 使用用户昵称作为标题 diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index 9df17d0048..1eb9225009 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -168,4 +168,5 @@ Send without Pangu Default Hls Video Quality Disable Bot Open Button + Use user nickname as Title