Skip to content

Commit

Permalink
feat: add disableSharePhoneWithContactByDefault option (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
cinit authored Sep 3, 2023
1 parent c4541a7 commit 998f48d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
import java.io.File;
import java.util.ArrayList;

import top.qwq2333.gen.Config;

public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ImageUpdater.ImageUpdaterDelegate {

private View doneButton;
Expand Down Expand Up @@ -355,7 +357,8 @@ protected Theme.ResourcesProvider getResourcesProvider() {
checkBoxCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
CharSequence firstName = UserObject.getFirstName(user);
firstName = Emoji.replaceEmoji(firstName, infoTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(12), false);
checkBoxCell.setText(AndroidUtilities.replaceCharSequence("%1$s", AndroidUtilities.replaceTags(LocaleController.getString("SharePhoneNumberWith", R.string.SharePhoneNumberWith)), firstName), "", true, false);
checkBoxCell.setText(AndroidUtilities.replaceCharSequence("%1$s", AndroidUtilities.replaceTags(LocaleController.getString("SharePhoneNumberWith", R.string.SharePhoneNumberWith)), firstName), "",
!Config.disableSharePhoneWithContactByDefault, false);
checkBoxCell.setPadding(AndroidUtilities.dp(7), 0, AndroidUtilities.dp(7), 0);
checkBoxCell.setOnClickListener(v -> checkBoxCell.setChecked(!checkBoxCell.isChecked(), true));
linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 10, 0, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class GeneralSettingActivity extends BaseActivity {
private int openArchiveOnPullRow;
private int hideAllTabRow;
private int ignorMutedCountRow;
private int disableSharePhoneWithContactByDefault;


private int devicesRow;
Expand Down Expand Up @@ -254,6 +255,11 @@ protected void onItemClick(View view, int position, float x, float y) {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(Config.ignoreMutedCount);
}
} else if (position == disableSharePhoneWithContactByDefault) {
Config.toggleDisableSharePhoneWithContactByDefault();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(Config.disableSharePhoneWithContactByDefault);
}
} else if (position == autoDisableBuiltInProxyRow) {
Config.toggleAutoDisableBuiltInProxy();
if (view instanceof TextCheckCell) {
Expand Down Expand Up @@ -413,6 +419,7 @@ protected void updateRows() {
openArchiveOnPullRow = addRow("openArchiveOnPull");
hideAllTabRow = addRow("hideAllTab");
ignorMutedCountRow = addRow("ignoreMutedCount");
disableSharePhoneWithContactByDefault = addRow("disableSharePhoneWithContactByDefault");
tabsTitleTypeRow = addRow("tabsTitleType");
general2Row = addRow();

Expand Down Expand Up @@ -588,6 +595,9 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position, boole
} else if (position == ignorMutedCountRow) {
textCell.setTextAndCheck(LocaleController.getString("ignoreMutedCount", R.string.ignoreMutedCount),
Config.ignoreMutedCount, true);
} else if (position == disableSharePhoneWithContactByDefault) {
textCell.setTextAndCheck(LocaleController.getString("disableSharePhoneWithContactByDefault", R.string.disableSharePhoneWithContactByDefault),
Config.disableSharePhoneWithContactByDefault, true);
} else if (position == autoDisableBuiltInProxyRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("autoDisableBuiltInProxy", R.string.autoDisableBuiltInProxy),
LocaleController.getString("autoDisableBuiltInProxyDesc", R.string.autoDisableBuiltInProxyDesc),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ object Defines {
@BooleanConfig const val blockSponsorAds = "blockSponsorMessages"
@BooleanConfig const val hideGroupSticker = "hideGroupSticker"
@BooleanConfig const val allowScreenshotOnNoForwardChat = "allowScreenshotOnNoForwardChat"
@BooleanConfig(true) const val disableSharePhoneWithContactByDefault = "disableSharePhoneWithContactByDefault"
@BooleanConfig const val autoDisableBuiltInProxy = "autoDisableBuiltInProxy"
@BooleanConfig const val labelChannelUser = "labelChannelUser"
@BooleanConfig const val displaySpoilerMsgDirectly = "displaySpoilerMsgDirectly"
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values-zh/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
<string name="openArchiveOnPull">下拉打开已归档对话</string>
<string name="hideAllTab">隐藏“全部对话”栏</string>
<string name="ignoreMutedCount">忽略标签中的静音计数</string>
<string name="disableSharePhoneWithContactByDefault">添加联系人时默认不分享电话号码</string>
<string name="disableStickersAutoReorder">禁用贴纸自动重新排列</string>
<string name="Ban">封禁</string>
<string name="autoDisableBuiltInProxy">自动关闭内置代理</string>
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/res/values/strings_nullgram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
<string name="openArchiveOnPull">Open Archive On Pull</string>
<string name="hideAllTab">Hide \"All Chats\" tab</string>
<string name="ignoreMutedCount">Ignore Muted Count in tab</string>
<string name="disableSharePhoneWithContactByDefault">No Share Phone Number When Add Contact</string>
<string name="disableStickersAutoReorder">Disable sticker packs auto-reorder</string>
<string name="Ban">Ban</string>
<string name="autoDisableBuiltInProxy">Auto Disable Built-In Proxy</string>
Expand Down

0 comments on commit 998f48d

Please sign in to comment.