mirror of https://github.com/NekoX-Dev/NekoX.git
Remove customApi and Disable dev mode for users
This commit is contained in:
parent
e1c74d2aaf
commit
b1dce3510f
|
@ -19720,7 +19720,7 @@ public class TLRPC {
|
||||||
public ArrayList<TL_restrictionReason> restriction_reason = new ArrayList<>();
|
public ArrayList<TL_restrictionReason> restriction_reason = new ArrayList<>();
|
||||||
|
|
||||||
public boolean verifiedExtended() {
|
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) {
|
public static User TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
|
||||||
|
@ -38048,7 +38048,7 @@ public class TLRPC {
|
||||||
public InputChannel migrated_to;
|
public InputChannel migrated_to;
|
||||||
|
|
||||||
public boolean verifiedExtended() {
|
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) {
|
public static Chat TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
|
||||||
|
|
|
@ -3616,6 +3616,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||||
if (!BuildVars.isFdroid && !BuildVars.isPlay && NekoXConfig.autoUpdateReleaseChannel != 0 && System.currentTimeMillis() / 1000 > NekoXConfig.nextUpdateCheck)
|
if (!BuildVars.isFdroid && !BuildVars.isPlay && NekoXConfig.autoUpdateReleaseChannel != 0 && System.currentTimeMillis() / 1000 > NekoXConfig.nextUpdateCheck)
|
||||||
UIUtil.runOnIoDispatcher(() -> InternalUpdater.checkUpdate(getParentActivity(), true), 6000);
|
UIUtil.runOnIoDispatcher(() -> InternalUpdater.checkUpdate(getParentActivity(), true), 6000);
|
||||||
|
|
||||||
|
if (NekoXConfig.developerMode && !NekoXConfig.isDeveloper())
|
||||||
|
NekoXConfig.toggleDeveloperMode();
|
||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -293,7 +293,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
||||||
}
|
}
|
||||||
|
|
||||||
private int menu_other = 5;
|
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_custom_dc = 7;
|
||||||
private int menu_qr_login = 8;
|
private int menu_qr_login = 8;
|
||||||
|
|
||||||
|
@ -409,153 +409,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
||||||
editText.setLayoutParams(layoutParams);
|
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) {
|
} else if (id == menu_custom_dc) {
|
||||||
|
|
||||||
AtomicInteger targetDc = new AtomicInteger(-1);
|
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(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_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));
|
otherItem.addSubItem(menu_custom_dc, R.drawable.baseline_sync_24, LocaleController.getString("CustomBackend", R.string.CustomBackend));
|
||||||
|
|
||||||
actionBar.setAllowOverlayTitle(true);
|
actionBar.setAllowOverlayTitle(true);
|
||||||
|
|
|
@ -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) -> {
|
builder.addItem(LocaleController.getString("DeveloperSettings", R.string.DeveloperSettings), R.drawable.baseline_developer_mode_24, (it) -> {
|
||||||
BottomBuilder devBuilder = new BottomBuilder(ProfileActivity.this.getParentActivity());
|
BottomBuilder devBuilder = new BottomBuilder(ProfileActivity.this.getParentActivity());
|
||||||
devBuilder.addTitle(LocaleController.getString("DevModeTitle", R.string.DevModeTitle), LocaleController.getString("DevModeNotice", R.string.DevModeNotice));
|
devBuilder.addTitle(LocaleController.getString("DevModeTitle", R.string.DevModeTitle), LocaleController.getString("DevModeNotice", R.string.DevModeNotice));
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.NotificationCenter;
|
import org.telegram.messenger.NotificationCenter;
|
||||||
import org.telegram.messenger.R;
|
import org.telegram.messenger.R;
|
||||||
|
import org.telegram.messenger.SharedConfig;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.ui.ActionBar.Theme;
|
import org.telegram.ui.ActionBar.Theme;
|
||||||
|
|
||||||
|
@ -83,9 +84,9 @@ public class NekoXConfig {
|
||||||
public static String ignoredUpdateTag = preferences.getString("ignoredUpdateTag", "");
|
public static String ignoredUpdateTag = preferences.getString("ignoredUpdateTag", "");
|
||||||
public static long nextUpdateCheck = preferences.getLong("nextUpdateCheckTimestamp", 0);
|
public static long nextUpdateCheck = preferences.getLong("nextUpdateCheckTimestamp", 0);
|
||||||
|
|
||||||
public static int customApi = preferences.getInt("custom_api", 0);
|
// public static int customApi = preferences.getInt("custom_api", 0);
|
||||||
public static int customAppId = preferences.getInt("custom_app_id", 0);
|
// public static int customAppId = preferences.getInt("custom_app_id", 0);
|
||||||
public static String customAppHash = preferences.getString("custom_app_hash", "");
|
// public static String customAppHash = preferences.getString("custom_app_hash", "");
|
||||||
|
|
||||||
public static void toggleDeveloperMode() {
|
public static void toggleDeveloperMode() {
|
||||||
preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply();
|
preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply();
|
||||||
|
@ -106,38 +107,10 @@ public class NekoXConfig {
|
||||||
preferences.edit().putBoolean("disable_screenshot_detection", disableScreenshotDetection = !disableScreenshotDetection).apply();
|
preferences.edit().putBoolean("disable_screenshot_detection", disableScreenshotDetection = !disableScreenshotDetection).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Boolean hasDeveloper = null;
|
||||||
|
|
||||||
public static int currentAppId() {
|
public static int currentAppId() {
|
||||||
switch (customApi) {
|
return BuildConfig.APP_ID;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleDisableStatusUpdate() {
|
public static void toggleDisableStatusUpdate() {
|
||||||
|
@ -158,13 +131,26 @@ public class NekoXConfig {
|
||||||
preferences.edit().putString("ignoredUpdateTag", ignoredUpdateTag = ignored).apply();
|
preferences.edit().putString("ignoredUpdateTag", ignoredUpdateTag = ignored).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setNextUpdateCheck(long timestamp) {
|
public static String currentAppHash() {
|
||||||
preferences.edit().putLong("nextUpdateCheckTimestamp", nextUpdateCheck = timestamp).apply();
|
return BuildConfig.APP_HASH;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showCensoredFeatures() {
|
public static void setNextUpdateCheck(long timestamp) {
|
||||||
long myId = UserConfig.getInstance(UserConfig.selectedAccount).clientUserId;
|
preferences.edit().putLong("nextUpdateCheckTimestamp", nextUpdateCheck = timestamp).apply();
|
||||||
return NekoXConfig.developerMode || NekoXConfig.customApi > 0 || ArrayUtil.contains(NekoXConfig.developers, myId);
|
}
|
||||||
|
|
||||||
|
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() {
|
public static String getOpenPGPAppName() {
|
||||||
|
|
|
@ -62,7 +62,6 @@ import tw.nekomimi.nekogram.config.cell.ConfigCellTextInput;
|
||||||
public class NekoChatSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class NekoChatSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
|
|
||||||
private final CellGroup cellGroup = new CellGroup(this);
|
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 header0 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("StickerSize")));
|
||||||
private final AbstractConfigCell stickerSizeRow = cellGroup.appendCell(new ConfigCellCustom(998, true));
|
private final AbstractConfigCell stickerSizeRow = cellGroup.appendCell(new ConfigCellCustom(998, true));
|
||||||
|
@ -169,7 +168,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||||
});
|
});
|
||||||
|
|
||||||
// Before listAdapter
|
// Before listAdapter
|
||||||
if (!showCensoredFeatures) {
|
if (!NekoXConfig.isDeveloper()) {
|
||||||
cellGroup.rows.remove(disableChatActionRow);
|
cellGroup.rows.remove(disableChatActionRow);
|
||||||
cellGroup.rows.remove(disableChoosingStickerRow);
|
cellGroup.rows.remove(disableChoosingStickerRow);
|
||||||
cellGroup.rows.remove(ignoreBlockedRow);
|
cellGroup.rows.remove(ignoreBlockedRow);
|
||||||
|
|
|
@ -77,7 +77,6 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||||
private ListAdapter listAdapter;
|
private ListAdapter listAdapter;
|
||||||
private ValueAnimator statusBarColorAnimator;
|
private ValueAnimator statusBarColorAnimator;
|
||||||
private DrawerProfilePreviewCell profilePreviewCell;
|
private DrawerProfilePreviewCell profilePreviewCell;
|
||||||
private final boolean showCensoredFeatures = NekoXConfig.showCensoredFeatures();
|
|
||||||
|
|
||||||
private final CellGroup cellGroup = new CellGroup(this);
|
private final CellGroup cellGroup = new CellGroup(this);
|
||||||
|
|
||||||
|
@ -712,7 +711,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCanNotChange() {
|
private void setCanNotChange() {
|
||||||
if (!showCensoredFeatures)
|
if (!NekoXConfig.isDeveloper())
|
||||||
cellGroup.rows.remove(hideSponsoredMessageRow);
|
cellGroup.rows.remove(hideSponsoredMessageRow);
|
||||||
|
|
||||||
boolean enabled;
|
boolean enabled;
|
||||||
|
|
Loading…
Reference in New Issue