mirror of https://github.com/NekoX-Dev/NekoX.git
This commit is contained in:
parent
66152b7307
commit
10e268fbb9
|
@ -41,10 +41,10 @@ dependencies {
|
|||
implementation files('libs/ssr-libev-release.aar')
|
||||
|
||||
compileOnly 'com.google.firebase:firebase-messaging:20.1.5'
|
||||
compileOnly 'com.google.firebase:firebase-crashlytics:17.0.0-beta03'
|
||||
compileOnly 'com.google.firebase:firebase-crashlytics:17.0.0-beta04'
|
||||
|
||||
releaseImplementation 'com.google.firebase:firebase-messaging:20.1.5'
|
||||
releaseImplementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta03'
|
||||
releaseImplementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta04'
|
||||
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ android {
|
|||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
|
||||
versionName "6.0.1.15"
|
||||
versionCode = 20
|
||||
versionName "6.0.1.16"
|
||||
versionCode = 21
|
||||
|
||||
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
|
||||
|
||||
|
|
|
@ -4073,7 +4073,8 @@ public class MessagesController extends BaseController implements NotificationCe
|
|||
checkDeletingTask(false);
|
||||
checkReadTasks();
|
||||
|
||||
if (getUserConfig().isClientActivated()) {
|
||||
if (getUserConfig().isClientActivated() && !getUserConfig().isBot) {
|
||||
|
||||
if (getConnectionsManager().getPauseTime() == 0 && ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePausedStageQueue) {
|
||||
if (ApplicationLoader.mainInterfacePausedStageQueueTime != 0 && Math.abs(ApplicationLoader.mainInterfacePausedStageQueueTime - System.currentTimeMillis()) > 1000) {
|
||||
if (statusSettingState != 1 && (lastStatusUpdateTime == 0 || Math.abs(System.currentTimeMillis() - lastStatusUpdateTime) >= 55000 || offlineSent)) {
|
||||
|
|
|
@ -200,7 +200,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
|
|||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (progressViewStyle == 3) {
|
||||
if (progressViewStyle > 0) {
|
||||
showCancelAlert();
|
||||
return false;
|
||||
}
|
||||
|
@ -474,6 +474,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
|
|||
}
|
||||
messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
|
||||
if (progressViewStyle == 1) {
|
||||
setCanceledOnTouchOutside(false);
|
||||
setCancelable(false);
|
||||
progressViewContainer = new FrameLayout(getContext());
|
||||
containerView.addView(progressViewContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 44, Gravity.LEFT | Gravity.TOP, 23, title == null ? 24 : 0, 23, 24));
|
||||
|
||||
|
@ -485,6 +487,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
|
|||
messageTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
progressViewContainer.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, (LocaleController.isRTL ? 0 : 62), 0, (LocaleController.isRTL ? 62 : 0), 0));
|
||||
} else if (progressViewStyle == 2) {
|
||||
setCanceledOnTouchOutside(false);
|
||||
setCancelable(false);
|
||||
containerView.addView(messageTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, title == null ? 19 : 0, 24, 20));
|
||||
|
||||
lineProgressView = new LineProgressView(getContext());
|
||||
|
|
|
@ -497,7 +497,7 @@ public class BottomSheet extends Dialog {
|
|||
|
||||
setBackground(Theme.getSelectorDrawable(false));
|
||||
|
||||
super.setGravity(Gravity.CENTER);
|
||||
super.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
||||
|
||||
imageView = new ImageView(context);
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
|
@ -508,11 +508,11 @@ public class BottomSheet extends Dialog {
|
|||
textView.setLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textView.setPadding(AndroidUtilities.dp(16),0,0,0);
|
||||
if (type == 0) {
|
||||
textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
textView.setGravity(Gravity.CENTER_VERTICAL);
|
||||
textView.setPadding(AndroidUtilities.dp(16),0,0,0);
|
||||
} else if (type == 1) {
|
||||
textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
|
|
|
@ -33,9 +33,11 @@ import org.telegram.messenger.LocaleController;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AnimationProperties;
|
||||
import org.telegram.ui.Components.CheckBoxSquare;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.Switch;
|
||||
import org.telegram.ui.Components.ViewHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -44,6 +46,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
private TextView textView;
|
||||
private TextView valueTextView;
|
||||
private Switch checkBox;
|
||||
private CheckBoxSquare checkBoxSquare;
|
||||
private boolean needDivider;
|
||||
private boolean isMultiline;
|
||||
private int height = 50;
|
||||
|
@ -95,10 +98,19 @@ public class TextCheckCell extends FrameLayout {
|
|||
valueTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 64 : padding, 36, LocaleController.isRTL ? padding : 64, 0));
|
||||
|
||||
if (!dialog) {
|
||||
|
||||
checkBox = new Switch(context);
|
||||
checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite);
|
||||
addView(checkBox, LayoutHelper.createFrame(37, 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
|
||||
|
||||
} else {
|
||||
|
||||
checkBoxSquare = new CheckBoxSquare(context,true);
|
||||
addView(checkBoxSquare, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
|
||||
|
||||
}
|
||||
|
||||
setClipChildren(false);
|
||||
}
|
||||
|
||||
|
@ -107,7 +119,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
if (isMultiline) {
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||
} else {
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 64 : height) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 64 : height) + (needDivider ? 3 : 0), MeasureSpec.EXACTLY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +132,11 @@ public class TextCheckCell extends FrameLayout {
|
|||
public void setTextAndCheck(String text, boolean checked, boolean divider) {
|
||||
textView.setText(text);
|
||||
isMultiline = false;
|
||||
if (checkBox != null) {
|
||||
checkBox.setChecked(checked, false);
|
||||
} else {
|
||||
checkBoxSquare.setChecked(checked,false);
|
||||
}
|
||||
needDivider = divider;
|
||||
valueTextView.setVisibility(GONE);
|
||||
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
|
||||
|
@ -150,7 +166,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
|
||||
@Override
|
||||
public void setPressed(boolean pressed) {
|
||||
if (drawCheckRipple) {
|
||||
if (drawCheckRipple && checkBox != null) {
|
||||
checkBox.setDrawRipple(pressed);
|
||||
}
|
||||
super.setPressed(pressed);
|
||||
|
@ -159,7 +175,11 @@ public class TextCheckCell extends FrameLayout {
|
|||
public void setTextAndValueAndCheck(String text, String value, boolean checked, boolean multiline, boolean divider) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
if (checkBox != null) {
|
||||
checkBox.setChecked(checked, false);
|
||||
} else {
|
||||
checkBoxSquare.setChecked(checked,false);
|
||||
}
|
||||
needDivider = divider;
|
||||
valueTextView.setVisibility(VISIBLE);
|
||||
isMultiline = multiline;
|
||||
|
@ -187,13 +207,17 @@ public class TextCheckCell extends FrameLayout {
|
|||
super.setEnabled(value);
|
||||
if (animators != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(textView, "alpha", value ? 1.0f : 0.5f));
|
||||
if (checkBox != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(checkBox, "alpha", value ? 1.0f : 0.5f));
|
||||
} else {
|
||||
animators.add(ObjectAnimator.ofFloat(checkBoxSquare, "alpha", value ? 1.0f : 0.5f));
|
||||
}
|
||||
if (valueTextView.getVisibility() == VISIBLE) {
|
||||
animators.add(ObjectAnimator.ofFloat(valueTextView, "alpha", value ? 1.0f : 0.5f));
|
||||
}
|
||||
} else {
|
||||
textView.setAlpha(value ? 1.0f : 0.5f);
|
||||
checkBox.setAlpha(value ? 1.0f : 0.5f);
|
||||
(checkBox != null ? checkBox : checkBoxSquare).setAlpha(value ? 1.0f : 0.5f);
|
||||
if (valueTextView.getVisibility() == VISIBLE) {
|
||||
valueTextView.setAlpha(value ? 1.0f : 0.5f);
|
||||
}
|
||||
|
@ -201,11 +225,15 @@ public class TextCheckCell extends FrameLayout {
|
|||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
if (checkBox != null) {
|
||||
checkBox.setChecked(checked, true);
|
||||
} else {
|
||||
checkBoxSquare.setChecked(checked,true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checkBox.isChecked();
|
||||
return checkBox != null ? checkBox.isChecked() : checkBoxSquare.isChecked();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -226,7 +254,9 @@ public class TextCheckCell extends FrameLayout {
|
|||
if (animationPaint == null) {
|
||||
animationPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
if (checkBox != null) {
|
||||
checkBox.setOverrideColor(checked ? 1 : 2);
|
||||
}
|
||||
animatedColorBackground = color;
|
||||
animationPaint.setColor(animatedColorBackground);
|
||||
animationProgress = 0.0f;
|
||||
|
@ -262,7 +292,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
canvas.drawCircle(cx, cy, animatedRad, animationPaint);
|
||||
}
|
||||
if (needDivider) {
|
||||
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
|
||||
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 3, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 3, Theme.dividerPaint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +301,7 @@ public class TextCheckCell extends FrameLayout {
|
|||
super.onInitializeAccessibilityNodeInfo(info);
|
||||
info.setClassName("android.widget.Switch");
|
||||
info.setCheckable(true);
|
||||
info.setChecked(checkBox.isChecked());
|
||||
info.setContentDescription(checkBox.isChecked() ? LocaleController.getString("NotificationsOn", R.string.NotificationsOn) : LocaleController.getString("NotificationsOff", R.string.NotificationsOff));
|
||||
info.setChecked(isChecked());
|
||||
info.setContentDescription(isChecked() ? LocaleController.getString("NotificationsOn", R.string.NotificationsOn) : LocaleController.getString("NotificationsOff", R.string.NotificationsOff));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ public class ChatRightsEditActivity extends BaseFragment {
|
|||
break;
|
||||
}
|
||||
buttons[a].setTextAndIcon(text, 0);
|
||||
linearLayoutInviteContainer.addView(buttons[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
linearLayoutInviteContainer.addView(buttons[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
|
||||
buttons[a].setOnClickListener(v2 -> {
|
||||
Integer tag = (Integer) v2.getTag();
|
||||
switch (tag) {
|
||||
|
|
|
@ -120,10 +120,9 @@ import java.util.Set;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import tw.nekomimi.nekogram.BottomBuilder;
|
||||
import tw.nekomimi.nekogram.EditTextAutoFill;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.NekoXConfig;
|
||||
import tw.nekomimi.nekogram.utils.AlertUtil;
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
public class LoginActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
@ -140,7 +139,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
private boolean checkPermissions = true;
|
||||
private boolean checkShowPermissions = true;
|
||||
private boolean newAccount;
|
||||
private boolean syncContacts = false;
|
||||
private boolean syncContacts = !"cn".equals(Locale.getDefault().getCountry().toLowerCase());
|
||||
|
||||
private int scrollHeight;
|
||||
|
||||
|
@ -164,9 +163,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
private ActionBarMenuItem proxyItem;
|
||||
private ProxyDrawable proxyDrawable;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private boolean useOfficalId = !"release".equals(BuildConfig.BUILD_TYPE);
|
||||
|
||||
private class ProgressView extends View {
|
||||
|
||||
private final Path path = new Path();
|
||||
|
@ -265,6 +261,12 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
|
||||
}
|
||||
|
||||
private int menu_other = 5;
|
||||
private int menu_custom_api = 6;
|
||||
|
||||
private int customAppId;
|
||||
private String customAppHash = null;
|
||||
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
actionBar.setTitle(LocaleController.getString("NekogramWithEmoji", R.string.NekogramWithEmoji));
|
||||
|
@ -319,8 +321,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
ConnectionsManager.getInstance(currentAccount).cleanup(false);
|
||||
final TLRPC.TL_auth_importBotAuthorization req = new TLRPC.TL_auth_importBotAuthorization();
|
||||
|
||||
req.api_hash = useOfficalId ? BuildVars.OFFICAL_APP_HASH : BuildConfig.APP_HASH;
|
||||
req.api_id = useOfficalId ? BuildVars.OFFICAL_APP_ID : BuildConfig.APP_ID;
|
||||
req.api_hash = customAppId != 0 ? customAppHash : BuildConfig.APP_HASH;
|
||||
req.api_id = customAppId != 0 ? customAppId : BuildConfig.APP_ID;
|
||||
req.bot_auth_token = token;
|
||||
req.flags = 0;
|
||||
int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
|
@ -374,6 +376,15 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
editText.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
} else if (id == menu_custom_api) {
|
||||
|
||||
BottomBuilder builder = new BottomBuilder(getParentActivity());
|
||||
|
||||
builder.addTitle(LocaleController.getString("CustomApi", R.string.CustomApi),
|
||||
true,
|
||||
LocaleController.getString("UseCustomApiNotice", R.string.UseCustomApiNotice));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -391,12 +402,16 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
|
||||
menu.addItem(3, R.drawable.ic_translate);
|
||||
|
||||
if (NekoXConfig.showBotLogin) {
|
||||
ActionBarMenuItem otherItem = menu.addItem(menu_other, R.drawable.ic_ab_other);
|
||||
|
||||
menu.addItem(4, R.drawable.list_bot);
|
||||
if (NekoXConfig.developerMode) {
|
||||
|
||||
otherItem.addSubItem(4, R.drawable.list_bot, LocaleController.getString("BotLogin", R.string.BotLogin));
|
||||
|
||||
}
|
||||
|
||||
otherItem.addSubItem(menu_custom_api, R.drawable.baseline_vpn_key_24, LocaleController.getString("CustomApi", R.string.CustomApi));
|
||||
|
||||
actionBar.setAllowOverlayTitle(true);
|
||||
doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
doneProgressView = new ContextProgressView(context, 1);
|
||||
|
@ -1291,7 +1306,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
private TextView textView2;
|
||||
private CheckBoxCell checkBoxCell;
|
||||
private CheckBoxCell testBackendCell;
|
||||
private CheckBoxCell useOfficalIdCell;
|
||||
|
||||
private int countryState = 0;
|
||||
|
||||
|
@ -1569,7 +1583,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
textView2.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
|
||||
addView(textView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 28, 0, 10));
|
||||
|
||||
if (true) {
|
||||
checkBoxCell = new CheckBoxCell(context, 2);
|
||||
checkBoxCell.setText(LocaleController.getString("SyncContacts", R.string.SyncContacts), "", syncContacts, false);
|
||||
addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
@ -1601,9 +1614,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (NekoXConfig.showTestBackend) {
|
||||
if (NekoXConfig.developerMode) {
|
||||
testBackendCell = new CheckBoxCell(context, 2);
|
||||
testBackendCell.setText(LocaleController.getString("TestBackend", R.string.TestBackend), "", ConnectionsManager.native_isTestBackend(currentAccount) != 0, true);
|
||||
addView(testBackendCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
|
@ -1638,26 +1650,6 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
});
|
||||
}
|
||||
|
||||
useOfficalIdCell = new CheckBoxCell(context, 2);
|
||||
useOfficalIdCell.setText(LocaleController.getString("UseOfficalId", R.string.UseOfficalId), "", useOfficalId, false);
|
||||
addView(useOfficalIdCell, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
||||
useOfficalIdCell.setOnClickListener(new OnClickListener() {
|
||||
|
||||
private Toast visibleToast;
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
CheckBoxCell cell = (CheckBoxCell) v;
|
||||
cell.setChecked(useOfficalId = !useOfficalId, true);
|
||||
if (useOfficalId) {
|
||||
AlertUtil.showSimpleAlert(getParentActivity(), LocaleController.getString("UseOfficalIdNotice", R.string.UseOfficalIdNotice));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
HashMap<String, String> languageMap = new HashMap<>();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().getAssets().open("countries.txt")));
|
||||
|
@ -1866,8 +1858,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
|||
|
||||
ConnectionsManager.getInstance(currentAccount).cleanup(false);
|
||||
final TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode();
|
||||
req.api_hash = useOfficalId ? BuildVars.OFFICAL_APP_HASH : BuildConfig.APP_HASH;
|
||||
req.api_id = useOfficalId ? BuildVars.OFFICAL_APP_ID : BuildConfig.APP_ID;
|
||||
req.api_hash = customAppId != 0 ? customAppHash : BuildConfig.APP_HASH;
|
||||
req.api_id = customAppId != 0 ? customAppId : BuildConfig.APP_ID;
|
||||
req.phone_number = phone;
|
||||
req.settings = new TLRPC.TL_codeSettings();
|
||||
req.settings.allow_flashcall = simcardAvailable && allowCall && allowCancelCall && allowReadCallLog;
|
||||
|
|
|
@ -1085,7 +1085,8 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente
|
|||
private void checkSingleProxy(SharedConfig.ProxyInfo proxyInfo, int repeat, Runnable callback) {
|
||||
|
||||
proxyInfo.checking = true;
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxyCheckDone, proxyInfo);
|
||||
|
||||
UIUtil.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxyCheckDone, proxyInfo));
|
||||
|
||||
if (proxyInfo instanceof SharedConfig.ExternalSocks5Proxy && !((SharedConfig.ExternalSocks5Proxy) proxyInfo).isStarted()) {
|
||||
((SharedConfig.ExternalSocks5Proxy) proxyInfo).start();
|
||||
|
|
|
@ -443,7 +443,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
|
|||
AtomicBoolean exportSets = new AtomicBoolean(true);
|
||||
AtomicBoolean exportArchived = new AtomicBoolean(true);
|
||||
|
||||
final AtomicReference<BottomSheet.BottomSheetCell> exportButton = new AtomicReference<>();
|
||||
final AtomicReference<TextView> exportButton = new AtomicReference<>();
|
||||
|
||||
builder.setCheckItems(new String[]{
|
||||
LocaleController.getString("StickerSets", R.string.StickerSets),
|
||||
|
@ -472,7 +472,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
}
|
||||
|
||||
check.setChecked(export, true);
|
||||
check.setChecked(export);
|
||||
|
||||
if (!exportSets.get() && !exportArchived.get()) {
|
||||
|
||||
|
@ -486,7 +486,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
});
|
||||
|
||||
builder.addButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.addButton(LocaleController.getString("Cancel", R.string.Cancel),false,true, null);
|
||||
|
||||
exportButton.set(builder.addButton(LocaleController.getString("Export", R.string.ExportStickers), (it) -> {
|
||||
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package tw.nekomimi.nekogram
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.util.TypedValue
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import org.telegram.messenger.AndroidUtilities
|
||||
import org.telegram.messenger.LocaleController
|
||||
import org.telegram.ui.ActionBar.BottomSheet
|
||||
import org.telegram.ui.ActionBar.Theme
|
||||
import org.telegram.ui.Cells.CheckBoxCell
|
||||
import org.telegram.ui.Cells.HeaderCell
|
||||
import org.telegram.ui.Cells.ShadowSectionCell
|
||||
import org.telegram.ui.Cells.TextCheckCell
|
||||
import org.telegram.ui.Components.LayoutHelper
|
||||
|
||||
class BottomBuilder(val ctx: Context) {
|
||||
|
@ -26,39 +31,65 @@ class BottomBuilder(val ctx: Context) {
|
|||
|
||||
private val buttonsView by lazy {
|
||||
|
||||
FrameLayout(ctx).apply {
|
||||
|
||||
setBackgroundColor(Theme.getColor(Theme.key_dialogBackground))
|
||||
|
||||
this@BottomBuilder.rootView.addView(this, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT or Gravity.BOTTOM))
|
||||
|
||||
addView(rightButtonsView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP or Gravity.RIGHT));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private val rightButtonsView by lazy {
|
||||
|
||||
LinearLayout(ctx).apply {
|
||||
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
|
||||
gravity = Gravity.CENTER_VERTICAL or if (LocaleController.isRTL) Gravity.LEFT else Gravity.RIGHT
|
||||
|
||||
minimumHeight = AndroidUtilities.dp(48F)
|
||||
|
||||
this@BottomBuilder.rootView.addView(this, LinearLayout.LayoutParams(-1, -2))
|
||||
weightSum = 1F
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun addTitle(title: String, bigTitle: Boolean = true) {
|
||||
fun addTitle(title: String, bigTitle: Boolean = true, subTitle: String? = null) {
|
||||
|
||||
val headerCell = if (bigTitle) HeaderCell(ctx, Theme.key_dialogTextBlue2, 21, 15, false) else HeaderCell(ctx)
|
||||
|
||||
headerCell.setText(title)
|
||||
|
||||
rootView.addView(headerCell, LayoutHelper.createLinear(-1, -2))
|
||||
subTitle?.also { headerCell.setText2(it) }
|
||||
|
||||
rootView.addView(headerCell, LayoutHelper.createLinear(-1, -2).apply {
|
||||
|
||||
bottomMargin = AndroidUtilities.dp(16F)
|
||||
|
||||
})
|
||||
|
||||
rootView.addView(ShadowSectionCell(ctx,3))
|
||||
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun addCheckBox(text: String, value: Boolean, valueText: String? = null, listener: View.OnClickListener) {
|
||||
|
||||
val checkBoxCell = CheckBoxCell(ctx, 1, 21)
|
||||
val checkBoxCell = TextCheckCell(ctx, 21,true)
|
||||
checkBoxCell.setBackgroundDrawable(Theme.getSelectorDrawable(false))
|
||||
checkBoxCell.minimumHeight = AndroidUtilities.dp(50F)
|
||||
rootView.addView(checkBoxCell, LayoutHelper.createLinear(-1, -2))
|
||||
checkBoxCell.setText(text, valueText, value, true)
|
||||
|
||||
if (valueText == null) {
|
||||
|
||||
checkBoxCell.setTextAndCheck(text, value, true)
|
||||
|
||||
} else {
|
||||
|
||||
checkBoxCell.setTextAndValueAndCheck(text,valueText,value,true,true)
|
||||
}
|
||||
|
||||
checkBoxCell.setOnClickListener(listener)
|
||||
|
||||
|
@ -67,7 +98,7 @@ class BottomBuilder(val ctx: Context) {
|
|||
@FunctionalInterface
|
||||
interface IndexedListener {
|
||||
|
||||
fun onClick(index: Int, view: CheckBoxCell)
|
||||
fun onClick(index: Int, view: TextCheckCell)
|
||||
|
||||
}
|
||||
|
||||
|
@ -78,7 +109,7 @@ class BottomBuilder(val ctx: Context) {
|
|||
|
||||
addCheckBox(textI, value(index), valueText?.invoke(index), View.OnClickListener {
|
||||
|
||||
listener.onClick(index, it as CheckBoxCell)
|
||||
listener.onClick(index, it as TextCheckCell)
|
||||
|
||||
})
|
||||
|
||||
|
@ -87,22 +118,21 @@ class BottomBuilder(val ctx: Context) {
|
|||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun addButton(text: String, icon: Int = 0, red: Boolean = false, listener: View.OnClickListener?): BottomSheet.BottomSheetCell {
|
||||
fun addButton(text: String, red: Boolean = false,left : Boolean = false, listener: View.OnClickListener?): TextView {
|
||||
|
||||
return BottomSheet.BottomSheetCell(ctx, 1).apply {
|
||||
return TextView(ctx).apply {
|
||||
|
||||
setBackgroundDrawable(Theme.getSelectorDrawable(false))
|
||||
setTextAndIcon(text, icon)
|
||||
setTextColor(Theme.getColor(if (red) Theme.key_windowBackgroundWhiteRedText else Theme.key_dialogTextBlue2))
|
||||
setOnClickListener { v ->
|
||||
if (listener != null) {
|
||||
listener.onClick(v)
|
||||
} else {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
buttonsView.addView(this, LinearLayout.LayoutParams(-2, -1))
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14f)
|
||||
setTextColor(Theme.getColor(Theme.key_dialogTextBlue4))
|
||||
gravity = Gravity.CENTER
|
||||
isSingleLine = true
|
||||
ellipsize = TextUtils.TruncateAt.END
|
||||
setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 0))
|
||||
setPadding(AndroidUtilities.dp(18f), 0, AndroidUtilities.dp(18f), 0)
|
||||
setText(text)
|
||||
typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf")
|
||||
(if (left) buttonsView else rightButtonsView).addView(this, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP or Gravity.LEFT))
|
||||
setOnClickListener(listener ?: View.OnClickListener { dismiss() })
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@ public class NekoXConfig {
|
|||
public static boolean disableFlagSecure = preferences.getBoolean("disable_flag_secure", false);
|
||||
public static boolean disableScreenshotDetection = preferences.getBoolean("disable_screenshot_detection", false);
|
||||
|
||||
public static boolean showTestBackend = preferences.getBoolean("show_test_backend", false);
|
||||
public static boolean showBotLogin = preferences.getBoolean("show_bot_login", false);
|
||||
|
||||
public static void toggleDeveloperMode() {
|
||||
|
||||
preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply();
|
||||
|
@ -46,17 +43,4 @@ public class NekoXConfig {
|
|||
|
||||
}
|
||||
|
||||
public static void toggleShowTestBackend() {
|
||||
|
||||
preferences.edit().putBoolean("show_test_backend", showTestBackend = !showTestBackend).apply();
|
||||
|
||||
}
|
||||
|
||||
public static void toggleShowBotLogin() {
|
||||
|
||||
preferences.edit().putBoolean("show_bot_login", showBotLogin = !showBotLogin).apply();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -52,10 +52,6 @@ public class NekoXSettingActivity extends BaseFragment {
|
|||
private int disableFlagSecureRow;
|
||||
private int disableScreenshotDetectionRow;
|
||||
|
||||
private int loginSettingsRow;
|
||||
private int showTestBackendRow;
|
||||
private int showBotLoginRow;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
|
@ -118,16 +114,6 @@ public class NekoXSettingActivity extends BaseFragment {
|
|||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoXConfig.disableScreenshotDetection);
|
||||
}
|
||||
} else if (position == showTestBackendRow) {
|
||||
NekoXConfig.toggleShowTestBackend();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoXConfig.showTestBackend);
|
||||
}
|
||||
} else if (position == showBotLoginRow) {
|
||||
NekoXConfig.toggleShowBotLogin();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoXConfig.showBotLogin);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -153,10 +139,6 @@ public class NekoXSettingActivity extends BaseFragment {
|
|||
disableFlagSecureRow = rowCount++;
|
||||
disableScreenshotDetectionRow = rowCount++;
|
||||
|
||||
loginSettingsRow = rowCount++;
|
||||
showTestBackendRow = rowCount++;
|
||||
showBotLoginRow = rowCount++;
|
||||
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
@ -264,8 +246,6 @@ public class NekoXSettingActivity extends BaseFragment {
|
|||
HeaderCell headerCell = (HeaderCell) holder.itemView;
|
||||
if (position == developerSettingsRow) {
|
||||
headerCell.setText(LocaleController.getString("DeveloperSettings", R.string.DeveloperSettings));
|
||||
} else if (position == loginSettingsRow) {
|
||||
headerCell.setText(LocaleController.getString("LoginSettings", R.string.LoginSettings));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -277,10 +257,6 @@ public class NekoXSettingActivity extends BaseFragment {
|
|||
textCell.setTextAndCheck("Disable Flag Secure", NekoXConfig.disableFlagSecure, true);
|
||||
} else if (position == disableScreenshotDetectionRow) {
|
||||
textCell.setTextAndCheck("Disable Screenshot Detection", NekoXConfig.disableScreenshotDetection, false);
|
||||
} else if (position == showTestBackendRow) {
|
||||
textCell.setTextAndCheck("Show Test Backend", NekoXConfig.showTestBackend, true);
|
||||
} else if (position == showBotLoginRow) {
|
||||
textCell.setTextAndCheck("Show Bot Login", NekoXConfig.showBotLogin, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -301,9 +277,7 @@ public class NekoXSettingActivity extends BaseFragment {
|
|||
int position = holder.getAdapterPosition();
|
||||
return position == fetchAndExportLangRow ||
|
||||
position == disableFlagSecureRow ||
|
||||
position == disableScreenshotDetectionRow ||
|
||||
position == showTestBackendRow ||
|
||||
position == showBotLoginRow;
|
||||
position == disableScreenshotDetectionRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -344,10 +318,9 @@ public class NekoXSettingActivity extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position == developerSettingsRow || position == loginSettingsRow) {
|
||||
if (position == developerSettingsRow) {
|
||||
return 4;
|
||||
} else if (position == disableFlagSecureRow || position == disableScreenshotDetectionRow ||
|
||||
position == showTestBackendRow || position == showBotLoginRow) {
|
||||
} else if (position == disableFlagSecureRow || position == disableScreenshotDetectionRow) {
|
||||
return 3;
|
||||
} else if (position == fetchAndExportLangRow) {
|
||||
return 2;
|
||||
|
|
|
@ -22,7 +22,7 @@ object LingoTranslator : Translator {
|
|||
val response = HttpUtil.okHttpClient.newCall(Request.Builder()
|
||||
.url("https://api.interpreter.caiyunai.com/v1/translator")
|
||||
.header("Content-Type", "application/json; charset=UTF-8")
|
||||
.header("X- ", "token 9sdftiq37bnv410eon2l") // 白嫖
|
||||
.header("X-Authorization", "token 9sdftiq37bnv410eon2l") // 白嫖
|
||||
.applyUserAgent()
|
||||
.post(JSONObject().apply {
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package tw.nekomimi.nekogram.utils
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
@ -30,6 +28,42 @@ object StickersUtil {
|
|||
|
||||
}
|
||||
|
||||
val installed = f.mediaDataController.getStickerSets(MediaDataController.TYPE_IMAGE)
|
||||
|
||||
val finishLoad = AtomicBoolean()
|
||||
val archivedSets = LinkedList<StickerSetCovered>()
|
||||
|
||||
fun loadStickers() {
|
||||
|
||||
val req = TL_messages_getArchivedStickers()
|
||||
req.offset_id = if (archivedSets.isEmpty()) 0 else archivedSets[archivedSets.size - 1].set.id
|
||||
req.limit = 100
|
||||
req.masks = false
|
||||
|
||||
f.connectionsManager.sendRequest(req) { response, _ ->
|
||||
|
||||
if (response is TL_messages_archivedStickers) {
|
||||
|
||||
archivedSets.addAll(response.sets)
|
||||
|
||||
if (response.sets.size < 100) {
|
||||
|
||||
finishLoad.set(true)
|
||||
|
||||
} else {
|
||||
|
||||
loadStickers()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
loadStickers()
|
||||
|
||||
stickerObj.getAsJsonObject("stickerSets")?.also {
|
||||
|
||||
val stickerSets = LinkedList(it.entrySet().map {
|
||||
|
@ -45,10 +79,13 @@ object StickersUtil {
|
|||
|
||||
val waitLock = AtomicBoolean()
|
||||
|
||||
for (stickerSetObj in stickerSets) {
|
||||
install@for (stickerSetObj in stickerSets) {
|
||||
|
||||
if (cancel.get()) return@runBlocking
|
||||
|
||||
for (s in installed) if (s.set.short_name == stickerSetObj.value) continue@install
|
||||
for (s in archivedSets) if (s.set.short_name == stickerSetObj.value) continue@install
|
||||
|
||||
waitLock.set(false)
|
||||
|
||||
f.connectionsManager.sendRequest(TL_messages_installStickerSet().apply {
|
||||
|
@ -110,12 +147,15 @@ object StickersUtil {
|
|||
|
||||
val waitLock = AtomicBoolean()
|
||||
|
||||
for (stickerSetObj in stickerSets) {
|
||||
install@ for (stickerSetObj in stickerSets) {
|
||||
|
||||
if (cancel.get()) return@runBlocking
|
||||
|
||||
waitLock.set(false)
|
||||
|
||||
for (s in installed) if (s.set.short_name == stickerSetObj.value) continue@install
|
||||
for (s in archivedSets) if (s.set.short_name == stickerSetObj.value) continue@install
|
||||
|
||||
f.connectionsManager.sendRequest(TL_messages_installStickerSet().apply {
|
||||
|
||||
stickerset = TL_inputStickerSetShortName().apply {
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
<string name="NekoX" translatable="false">Nekogram X</string>
|
||||
|
||||
<string name="UseOfficalId">Disguised as official app</string>
|
||||
<string name="UseOfficalIdNotice">Log in using the official App Id, if you are unable to register or log in, this may help.\n\nNote: fcm will not work if you are using the release version.</string>
|
||||
<string name="CustomApi">Custom Api</string>
|
||||
<string name="UseCustomApiNotice">Log in using the custom api, if you are unable to register or log in, this may help.\n\nNote: fcm will not work if you are using the release version.</string>
|
||||
<string name="CustomApiOffical">Telegram Android</string>
|
||||
<string name="CustomApiTGX">Telegram X</string>
|
||||
<string name="CustomApiInput">Manual input</string>
|
||||
|
||||
<string name="ChangeTranslateProvider">Change Provider</string>
|
||||
|
||||
|
|
Loading…
Reference in New Issue