Remove customApi and Disable dev mode for users

This commit is contained in:
luvletter2333 2022-01-20 15:41:31 +08:00
parent e1c74d2aaf
commit b1dce3510f
No known key found for this signature in database
GPG Key ID: A26A8880836E1978
7 changed files with 34 additions and 195 deletions

View File

@ -19720,7 +19720,7 @@ public class TLRPC {
public ArrayList<TL_restrictionReason> restriction_reason = new ArrayList<>();
public boolean verifiedExtended() {
return verified || (ArrayUtil.contains(NekoXConfig.developers, id) && NekoXConfig.showCensoredFeatures());
return verified || (ArrayUtil.contains(NekoXConfig.developers, id) && NekoXConfig.isDeveloper());
}
public static User TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
@ -38048,7 +38048,7 @@ public class TLRPC {
public InputChannel migrated_to;
public boolean verifiedExtended() {
return verified ||( ArrayUtil.contains(NekoXConfig.officialChats, id) && NekoXConfig.showCensoredFeatures());
return verified ||( ArrayUtil.contains(NekoXConfig.officialChats, id) && NekoXConfig.isDeveloper());
}
public static Chat TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {

View File

@ -3616,6 +3616,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (!BuildVars.isFdroid && !BuildVars.isPlay && NekoXConfig.autoUpdateReleaseChannel != 0 && System.currentTimeMillis() / 1000 > NekoXConfig.nextUpdateCheck)
UIUtil.runOnIoDispatcher(() -> InternalUpdater.checkUpdate(getParentActivity(), true), 6000);
if (NekoXConfig.developerMode && !NekoXConfig.isDeveloper())
NekoXConfig.toggleDeveloperMode();
return fragmentView;
}

View File

@ -293,7 +293,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
}
private int menu_other = 5;
private int menu_custom_api = 6;
// private int menu_custom_api = 6;
private int menu_custom_dc = 7;
private int menu_qr_login = 8;
@ -409,153 +409,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
editText.setLayoutParams(layoutParams);
}
}
} else if (id == menu_custom_api) {
AtomicInteger targetApi = new AtomicInteger(-1);
BottomBuilder builder = new BottomBuilder(getParentActivity());
EditText[] inputs = new EditText[2];
builder.addTitle(LocaleController.getString("CustomApi", R.string.CustomApi),
true,
LocaleController.getString("UseCustomApiNotice", R.string.UseCustomApiNotice));
builder.addRadioItem(LocaleController.getString("CustomApiNo", R.string.CustomApiNo), NekoXConfig.customApi == 0, (cell) -> {
targetApi.set(0);
builder.doRadioCheck(cell);
for (EditText input : inputs) input.setVisibility(View.GONE);
return Unit.INSTANCE;
});
builder.addRadioItem(LocaleController.getString("CustomApiOfficial", R.string.CustomApiOfficial), NekoXConfig.customApi == 1, (cell) -> {
targetApi.set(1);
builder.doRadioCheck(cell);
for (EditText input : inputs) input.setVisibility(View.GONE);
return Unit.INSTANCE;
});
builder.addRadioItem(LocaleController.getString("CustomApiTGX", R.string.CustomApiTGX), NekoXConfig.customApi == 2, (cell) -> {
targetApi.set(2);
builder.doRadioCheck(cell);
for (EditText input : inputs) input.setVisibility(View.GONE);
return Unit.INSTANCE;
});
builder.addRadioItem(LocaleController.getString("CustomApiInput", R.string.CustomApiInput), NekoXConfig.customApi > 2, (cell) -> {
targetApi.set(3);
builder.doRadioCheck(cell);
for (EditText input : inputs) input.setVisibility(View.VISIBLE);
return Unit.INSTANCE;
});
inputs[0] = builder.addEditText("App Id");
inputs[0].setInputType(InputType.TYPE_CLASS_NUMBER);
if (NekoXConfig.customAppId != 0) {
inputs[0].setText(NekoXConfig.customAppId + "");
}
inputs[0].addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (StrUtil.isBlank(s.toString())) {
NekoXConfig.customAppId = 0;
} else if (!NumberUtil.isInteger(s.toString())) {
inputs[0].setText("0");
} else {
NekoXConfig.customAppId = NumberUtil.parseInt(s.toString());
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
inputs[1] = builder.addEditText("App Hash");
inputs[1].setFilters(new InputFilter[]{new InputFilter.LengthFilter(BuildVars.OFFICAL_APP_HASH.length())});
if (StrUtil.isNotBlank(NekoXConfig.customAppHash)) {
inputs[1].setText(NekoXConfig.customAppHash);
}
inputs[1].addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
NekoXConfig.customAppHash = s.toString();
}
@Override
public void afterTextChanged(Editable s) {
}
});
if (NekoXConfig.customApi <= 2) {
for (EditText input : inputs) input.setVisibility(View.GONE);
}
builder.addCancelButton();
builder.addButton(LocaleController.getString("Set", R.string.Set), (it) -> {
int target = targetApi.get();
if (target > 2) {
if (NekoXConfig.customAppId == 0) {
inputs[0].requestFocus();
AndroidUtilities.showKeyboard(inputs[0]);
return Unit.INSTANCE;
} else if (StrUtil.isBlank(NekoXConfig.customAppHash)) {
inputs[1].requestFocus();
AndroidUtilities.showKeyboard(inputs[1]);
return Unit.INSTANCE;
}
}
NekoXConfig.customApi = target;
NekoXConfig.saveCustomApi();
return Unit.INSTANCE;
});
builder.show();
} else if (id == menu_custom_dc) {
AtomicInteger targetDc = new AtomicInteger(-1);
@ -645,7 +498,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
otherItem.addSubItem(4, R.drawable.list_bot, LocaleController.getString("BotLogin", R.string.BotLogin));
otherItem.addSubItem(menu_qr_login, R.drawable.wallet_qr, LocaleController.getString("ImportLogin", R.string.ImportLogin));
otherItem.addSubItem(menu_custom_api, R.drawable.baseline_vpn_key_24, LocaleController.getString("CustomApi", R.string.CustomApi));
// otherItem.addSubItem(menu_custom_api, R.drawable.baseline_vpn_key_24, LocaleController.getString("CustomApi", R.string.CustomApi));
otherItem.addSubItem(menu_custom_dc, R.drawable.baseline_sync_24, LocaleController.getString("CustomBackend", R.string.CustomBackend));
actionBar.setAllowOverlayTitle(true);

View File

@ -3047,7 +3047,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
});
}
if (NekoXConfig.showCensoredFeatures()) {
if (NekoXConfig.isDeveloper()) {
builder.addItem(LocaleController.getString("DeveloperSettings", R.string.DeveloperSettings), R.drawable.baseline_developer_mode_24, (it) -> {
BottomBuilder devBuilder = new BottomBuilder(ProfileActivity.this.getParentActivity());
devBuilder.addTitle(LocaleController.getString("DevModeTitle", R.string.DevModeTitle), LocaleController.getString("DevModeNotice", R.string.DevModeNotice));

View File

@ -16,6 +16,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.Theme;
@ -83,9 +84,9 @@ public class NekoXConfig {
public static String ignoredUpdateTag = preferences.getString("ignoredUpdateTag", "");
public static long nextUpdateCheck = preferences.getLong("nextUpdateCheckTimestamp", 0);
public static int customApi = preferences.getInt("custom_api", 0);
public static int customAppId = preferences.getInt("custom_app_id", 0);
public static String customAppHash = preferences.getString("custom_app_hash", "");
// public static int customApi = preferences.getInt("custom_api", 0);
// public static int customAppId = preferences.getInt("custom_app_id", 0);
// public static String customAppHash = preferences.getString("custom_app_hash", "");
public static void toggleDeveloperMode() {
preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply();
@ -106,38 +107,10 @@ public class NekoXConfig {
preferences.edit().putBoolean("disable_screenshot_detection", disableScreenshotDetection = !disableScreenshotDetection).apply();
}
private static Boolean hasDeveloper = null;
public static int currentAppId() {
switch (customApi) {
case 0:
return BuildConfig.APP_ID;
case 1:
return BuildVars.OFFICAL_APP_ID;
case 2:
return BuildVars.TGX_APP_ID;
default:
return customAppId;
}
}
public static String currentAppHash() {
switch (customApi) {
case 0:
return BuildConfig.APP_HASH;
case 1:
return BuildVars.OFFICAL_APP_HASH;
case 2:
return BuildVars.TGX_APP_HASH;
default:
return customAppHash;
}
}
public static void saveCustomApi() {
preferences.edit()
.putInt("custom_api", customApi)
.putInt("custom_app_id", customAppId)
.putString("custom_app_hash", customAppHash)
.apply();
return BuildConfig.APP_ID;
}
public static void toggleDisableStatusUpdate() {
@ -158,13 +131,26 @@ public class NekoXConfig {
preferences.edit().putString("ignoredUpdateTag", ignoredUpdateTag = ignored).apply();
}
public static void setNextUpdateCheck(long timestamp) {
preferences.edit().putLong("nextUpdateCheckTimestamp", nextUpdateCheck = timestamp).apply();
public static String currentAppHash() {
return BuildConfig.APP_HASH;
}
public static boolean showCensoredFeatures() {
long myId = UserConfig.getInstance(UserConfig.selectedAccount).clientUserId;
return NekoXConfig.developerMode || NekoXConfig.customApi > 0 || ArrayUtil.contains(NekoXConfig.developers, myId);
public static void setNextUpdateCheck(long timestamp) {
preferences.edit().putLong("nextUpdateCheckTimestamp", nextUpdateCheck = timestamp).apply();
}
public static boolean isDeveloper() {
if (hasDeveloper != null)
return hasDeveloper;
hasDeveloper = false;
for (int acc : SharedConfig.activeAccounts) {
long myId = UserConfig.getInstance(acc).clientUserId;
if (ArrayUtil.contains(NekoXConfig.developers, myId)) {
hasDeveloper = true;
break;
}
}
return hasDeveloper;
}
public static String getOpenPGPAppName() {

View File

@ -62,7 +62,6 @@ import tw.nekomimi.nekogram.config.cell.ConfigCellTextInput;
public class NekoChatSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private final CellGroup cellGroup = new CellGroup(this);
private final boolean showCensoredFeatures = NekoXConfig.showCensoredFeatures();
private final AbstractConfigCell header0 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("StickerSize")));
private final AbstractConfigCell stickerSizeRow = cellGroup.appendCell(new ConfigCellCustom(998, true));
@ -169,7 +168,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
});
// Before listAdapter
if (!showCensoredFeatures) {
if (!NekoXConfig.isDeveloper()) {
cellGroup.rows.remove(disableChatActionRow);
cellGroup.rows.remove(disableChoosingStickerRow);
cellGroup.rows.remove(ignoreBlockedRow);

View File

@ -77,7 +77,6 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
private ListAdapter listAdapter;
private ValueAnimator statusBarColorAnimator;
private DrawerProfilePreviewCell profilePreviewCell;
private final boolean showCensoredFeatures = NekoXConfig.showCensoredFeatures();
private final CellGroup cellGroup = new CellGroup(this);
@ -712,7 +711,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
}
private void setCanNotChange() {
if (!showCensoredFeatures)
if (!NekoXConfig.isDeveloper())
cellGroup.rows.remove(hideSponsoredMessageRow);
boolean enabled;