mirror of https://github.com/NekoX-Dev/NekoX.git
代理别名
This commit is contained in:
parent
b64464402b
commit
f3f6a6a3e6
|
@ -1870,13 +1870,13 @@ public class MessagesStorage extends BaseController {
|
|||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) != 0) {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_ONLY_ARCHIVED) == 0) {
|
||||
unreadCount += contacts[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += contacts[0][1];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount += contacts[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += contacts[1][1];
|
||||
}
|
||||
}
|
||||
|
@ -1884,13 +1884,13 @@ public class MessagesStorage extends BaseController {
|
|||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) != 0) {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_ONLY_ARCHIVED) == 0) {
|
||||
unreadCount += nonContacts[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += nonContacts[0][1];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount += nonContacts[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += nonContacts[1][1];
|
||||
}
|
||||
}
|
||||
|
@ -1898,13 +1898,13 @@ public class MessagesStorage extends BaseController {
|
|||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) != 0) {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_ONLY_ARCHIVED) == 0) {
|
||||
unreadCount += groups[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += groups[0][1];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount += groups[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += groups[1][1];
|
||||
}
|
||||
}
|
||||
|
@ -1912,13 +1912,13 @@ public class MessagesStorage extends BaseController {
|
|||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) != 0) {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_ONLY_ARCHIVED) == 0) {
|
||||
unreadCount += channels[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += channels[0][1];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount += channels[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += channels[1][1];
|
||||
}
|
||||
}
|
||||
|
@ -1926,13 +1926,13 @@ public class MessagesStorage extends BaseController {
|
|||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) != 0) {
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_ONLY_ARCHIVED) == 0) {
|
||||
unreadCount += bots[0][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += bots[0][1];
|
||||
}
|
||||
}
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
||||
unreadCount += bots[1][0];
|
||||
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
if (!NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
unreadCount += bots[1][1];
|
||||
}
|
||||
}
|
||||
|
@ -3822,9 +3822,6 @@ public class MessagesStorage extends BaseController {
|
|||
}
|
||||
unreadCount = filter.pendingUnreadCount;
|
||||
flags = filter.flags;
|
||||
if (NekoXConfig.ignoreMutedCount && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) {
|
||||
flags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
|
||||
}
|
||||
} else {
|
||||
filter = null;
|
||||
flags = MessagesController.DIALOG_FILTER_FLAG_ALL_CHATS;
|
||||
|
|
|
@ -10,10 +10,8 @@ package org.telegram.messenger;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Proxy;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
|
@ -36,13 +34,14 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import kotlin.text.StringsKt;
|
||||
import okhttp3.HttpUrl;
|
||||
import tw.nekomimi.nekogram.ShadowsocksRLoader;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.ProxyManager;
|
||||
import tw.nekomimi.nekogram.ShadowsocksLoader;
|
||||
import tw.nekomimi.nekogram.VmessLoader;
|
||||
import tw.nekomimi.nekogram.utils.FileUtil;
|
||||
import tw.nekomimi.nekogram.utils.ProxyUtil;
|
||||
import tw.nekomimi.nekogram.utils.UIUtil;
|
||||
|
||||
import static com.v2ray.ang.V2RayConfig.SSR_PROTOCOL;
|
||||
|
@ -133,6 +132,8 @@ public class SharedConfig {
|
|||
|
||||
public static class ProxyInfo {
|
||||
|
||||
public int group;
|
||||
|
||||
public String address;
|
||||
public int port;
|
||||
public String username;
|
||||
|
@ -175,12 +176,89 @@ public class SharedConfig {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
|
||||
if (StringsKt.isBlank(remarks)) {
|
||||
|
||||
return "[MTProto] " + address + ":" + port;
|
||||
|
||||
} else {
|
||||
|
||||
return "[MTProto] " + remarks;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
if (StringsKt.isBlank(remarks)) {
|
||||
remarks = null;
|
||||
}
|
||||
}
|
||||
|
||||
private String remarks;
|
||||
|
||||
public String toUrl() {
|
||||
|
||||
HttpUrl.Builder builder = HttpUrl.parse(StringsKt.isBlank(secret) ?
|
||||
"https://t.me/socks" : "https://t.me/proxy").newBuilder()
|
||||
.addQueryParameter("address", address)
|
||||
.addQueryParameter("port", port + "");
|
||||
|
||||
if (!StringsKt.isBlank(secret)) {
|
||||
|
||||
builder.addQueryParameter("secret", secret);
|
||||
|
||||
} else {
|
||||
|
||||
builder.addQueryParameter("user", username)
|
||||
.addQueryParameter("pass", password);
|
||||
|
||||
}
|
||||
|
||||
if (!StringsKt.isBlank(remarks)) {
|
||||
|
||||
builder.fragment(remarks);
|
||||
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
|
||||
}
|
||||
|
||||
public static ProxyInfo fromUrl(String url) {
|
||||
|
||||
HttpUrl lnk = HttpUrl.parse(url);
|
||||
|
||||
return new ProxyInfo(lnk.queryParameter("server"),
|
||||
Utilities.parseInt(lnk.queryParameter("port")),
|
||||
lnk.queryParameter("user"),
|
||||
lnk.queryParameter("pass"),
|
||||
lnk.queryParameter("secret"));
|
||||
|
||||
}
|
||||
|
||||
public JSONObject toJson() throws JSONException {
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
|
||||
if (!StringsKt.isBlank(remarks)) {
|
||||
obj.put("remarks", remarks);
|
||||
}
|
||||
|
||||
if (group != 0) {
|
||||
obj.put("group", group);
|
||||
}
|
||||
|
||||
obj.put("address", address);
|
||||
obj.put("port", port);
|
||||
if (secret.isEmpty()) {
|
||||
if (StringsKt.isBlank(secret)) {
|
||||
obj.put("type", "socks5");
|
||||
if (!username.isEmpty()) {
|
||||
obj.put("username", username);
|
||||
|
@ -207,11 +285,18 @@ public class SharedConfig {
|
|||
|
||||
info = new ProxyInfo();
|
||||
|
||||
info.group = obj.optInt("group", 0);
|
||||
info.address = obj.optString("address", "");
|
||||
info.port = obj.optInt("port", 443);
|
||||
info.username = obj.optString("username", "");
|
||||
info.password = obj.optString("password", "");
|
||||
|
||||
info.remarks = obj.optString("remarks");
|
||||
|
||||
if (StringsKt.isBlank(info.remarks)) info.remarks = null;
|
||||
|
||||
info.group = obj.optInt("group", 0);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -224,6 +309,12 @@ public class SharedConfig {
|
|||
info.port = obj.optInt("port", 443);
|
||||
info.secret = obj.optString("secret", "");
|
||||
|
||||
info.remarks = obj.optString("remarks");
|
||||
|
||||
if (StringsKt.isBlank(info.remarks)) info.remarks = null;
|
||||
|
||||
info.group = obj.optInt("group", 0);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -281,6 +372,18 @@ public class SharedConfig {
|
|||
|
||||
public abstract void stop();
|
||||
|
||||
@Override
|
||||
public abstract String getTitle();
|
||||
|
||||
@Override
|
||||
public abstract String toUrl();
|
||||
|
||||
@Override
|
||||
public abstract String getRemarks();
|
||||
|
||||
@Override
|
||||
public abstract void setRemarks(String remarks);
|
||||
|
||||
@Override
|
||||
public abstract JSONObject toJson() throws JSONException;
|
||||
|
||||
|
@ -303,6 +406,21 @@ public class SharedConfig {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
|
||||
if (StringsKt.isBlank(getRemarks())) {
|
||||
|
||||
return "[Vmess] " + bean.getAddress() + ":" + bean.getPort();
|
||||
|
||||
} else {
|
||||
|
||||
return "[Vmess] " + getRemarks();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
|
@ -329,12 +447,27 @@ public class SharedConfig {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toUrl() {
|
||||
return bean.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemarks() {
|
||||
return bean.getRemarks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemarks(String remarks) {
|
||||
bean.setRemarks(remarks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject toJson() throws JSONException {
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", "vmess");
|
||||
obj.put("link", bean.toString());
|
||||
obj.put("link", toUrl());
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
@ -358,6 +491,21 @@ public class SharedConfig {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
|
||||
if (StringsKt.isBlank(getRemarks())) {
|
||||
|
||||
return "[SS] " + bean.getHost() + ":" + bean.getRemotePort();
|
||||
|
||||
} else {
|
||||
|
||||
return "[SS] " + getRemarks();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
|
@ -384,12 +532,28 @@ public class SharedConfig {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toUrl() {
|
||||
return bean.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRemarks() {
|
||||
return bean.getRemarks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemarks(String remarks) {
|
||||
bean.setRemarks(remarks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject toJson() throws JSONException {
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", "shadowsocks");
|
||||
obj.put("link", bean.toString());
|
||||
obj.put("link", toUrl());
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
@ -413,6 +577,22 @@ public class SharedConfig {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
|
||||
if (StringsKt.isBlank(getRemarks())) {
|
||||
|
||||
return "[SSR] " + bean.getHost() + ":" + bean.getRemotePort();
|
||||
|
||||
} else {
|
||||
|
||||
return "[SSR] " + getRemarks();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
|
@ -439,12 +619,27 @@ public class SharedConfig {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toUrl() {
|
||||
return bean.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemarks() {
|
||||
return bean.getRemarks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemarks(String remarks) {
|
||||
bean.setRemarks(remarks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject toJson() throws JSONException {
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", "shadowsocksr");
|
||||
obj.put("link", bean.toString());
|
||||
obj.put("link", toUrl());
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
|
|
@ -132,6 +132,7 @@ public class ConnectionsManager extends BaseController {
|
|||
}
|
||||
|
||||
public String getAddress() {
|
||||
if (addresses.length == 0) return "";
|
||||
return addresses[Utilities.random.nextInt(addresses.length)].getHostAddress();
|
||||
}
|
||||
}
|
||||
|
@ -176,11 +177,6 @@ public class ConnectionsManager extends BaseController {
|
|||
deviceModel = Build.MANUFACTURER + Build.MODEL;
|
||||
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
|
||||
appVersion = pInfo.versionName + " (" + pInfo.versionCode + ")";
|
||||
if (BuildVars.DEBUG_PRIVATE_VERSION) {
|
||||
appVersion += " pbeta";
|
||||
} else if (BuildVars.DEBUG_VERSION) {
|
||||
appVersion += " beta";
|
||||
}
|
||||
systemVersion = "SDK " + Build.VERSION.SDK_INT;
|
||||
} catch (Exception e) {
|
||||
systemLangCode = "en";
|
||||
|
|
|
@ -496,7 +496,6 @@ public class BottomSheet extends Dialog {
|
|||
setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
setBackground(Theme.getSelectorDrawable(false));
|
||||
setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
|
||||
|
||||
super.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
|
||||
|
@ -539,10 +538,10 @@ public class BottomSheet extends Dialog {
|
|||
if (icon != 0) {
|
||||
imageView.setImageResource(icon);
|
||||
imageView.setVisibility(VISIBLE);
|
||||
textView.setPadding(AndroidUtilities.dp(bigTitle ? 21 : 16), 0, 0, 0);
|
||||
textView.setPadding(0, 0, 0, 0);
|
||||
} else {
|
||||
imageView.setVisibility(GONE);
|
||||
textView.setPadding(0, 0, 0, 0);
|
||||
textView.setPadding(AndroidUtilities.dp(bigTitle ? 21 : 16), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3160,6 +3160,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
|||
}
|
||||
}
|
||||
}
|
||||
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
||||
filterTabsView.checkTabsCounter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1624,10 +1624,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
open_settings = 3;
|
||||
} else if (url.contains("folders")) {
|
||||
open_settings = 4;
|
||||
} else if (url.contains("neko")) {
|
||||
open_settings = 5;
|
||||
} else if (url.contains("nekox")) {
|
||||
open_settings = 6;
|
||||
} else if (url.contains("neko")) {
|
||||
open_settings = 5;
|
||||
}
|
||||
} else if (url.startsWith("tg:meow") || url.startsWith("tg://meow") || url.startsWith("tg:nya") || url.startsWith("tg://nya") || url.startsWith("tg:miao") || url.startsWith("tg://miao")) {
|
||||
try {
|
||||
|
|
|
@ -131,27 +131,10 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente
|
|||
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void setProxy(SharedConfig.ProxyInfo proxyInfo) {
|
||||
String server;
|
||||
int port;
|
||||
if (proxyInfo instanceof SharedConfig.VmessProxy) {
|
||||
server = "[ Vmess ] " + ((SharedConfig.VmessProxy) proxyInfo).bean.getAddress();
|
||||
port = ((SharedConfig.VmessProxy) proxyInfo).bean.getPort();
|
||||
} else if (proxyInfo instanceof SharedConfig.ShadowsocksProxy) {
|
||||
server = "[ SS ] " + ((SharedConfig.ShadowsocksProxy) proxyInfo).bean.getHost();
|
||||
port = ((SharedConfig.ShadowsocksProxy) proxyInfo).bean.getRemotePort();
|
||||
} else if (proxyInfo instanceof SharedConfig.ShadowsocksRProxy) {
|
||||
server = "[ SSR ] " + ((SharedConfig.ShadowsocksRProxy) proxyInfo).bean.getHost();
|
||||
port = ((SharedConfig.ShadowsocksRProxy) proxyInfo).bean.getRemotePort();
|
||||
} else {
|
||||
server = proxyInfo.address;
|
||||
port = proxyInfo.port;
|
||||
}
|
||||
if (proxyInfo.isInternal && proxyInfo.descripton == null) {
|
||||
if (proxyInfo.isInternal) {
|
||||
textView.setText(LocaleController.formatString("NekoXProxy", R.string.NekoXProxy));
|
||||
} else if (proxyInfo.isInternal) {
|
||||
textView.setText(LocaleController.formatString("PublicPrefix", R.string.PublicPrefix) + " " + server + ":" + port);
|
||||
} else {
|
||||
textView.setText(server + ":" + port);
|
||||
textView.setText(proxyInfo.getTitle());
|
||||
}
|
||||
currentInfo = proxyInfo;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.animation.ValueAnimator;
|
|||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
|
@ -41,8 +40,6 @@ import android.widget.LinearLayout;
|
|||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
|
@ -56,8 +53,6 @@ import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
|||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ActionBar.ThemeDescription;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.RadioCell;
|
||||
import org.telegram.ui.Cells.ShadowSectionCell;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
|
@ -67,7 +62,6 @@ import org.telegram.ui.Components.LayoutHelper;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ProxySettingsActivity extends BaseFragment {
|
||||
|
@ -80,6 +74,7 @@ public class ProxySettingsActivity extends BaseFragment {
|
|||
private final static int FIELD_USER = 2;
|
||||
private final static int FIELD_PASSWORD = 3;
|
||||
private final static int FIELD_SECRET = 4;
|
||||
private final static int FIELD_REMARKS = 5;
|
||||
|
||||
private EditTextBoldCursor[] inputFields;
|
||||
private ScrollView scrollView;
|
||||
|
@ -209,6 +204,7 @@ public class ProxySettingsActivity extends BaseFragment {
|
|||
}
|
||||
currentProxyInfo.address = inputFields[FIELD_IP].getText().toString();
|
||||
currentProxyInfo.port = Utilities.parseInt(inputFields[FIELD_PORT].getText().toString());
|
||||
currentProxyInfo.setRemarks(inputFields[FIELD_REMARKS].getText().toString());
|
||||
if (currentType == 0) {
|
||||
currentProxyInfo.secret = "";
|
||||
currentProxyInfo.username = inputFields[FIELD_USER].getText().toString();
|
||||
|
@ -279,8 +275,8 @@ public class ProxySettingsActivity extends BaseFragment {
|
|||
}
|
||||
linearLayout2.addView(inputFieldsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
inputFields = new EditTextBoldCursor[5];
|
||||
for (int a = 0; a < 5; a++) {
|
||||
inputFields = new EditTextBoldCursor[6];
|
||||
for (int a = 0; a < 6; a++) {
|
||||
FrameLayout container = new FrameLayout(context);
|
||||
inputFieldsContainer.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64));
|
||||
|
||||
|
@ -395,6 +391,10 @@ public class ProxySettingsActivity extends BaseFragment {
|
|||
inputFields[a].setHintText(LocaleController.getString("UseProxySecret", R.string.UseProxySecret));
|
||||
inputFields[a].setText(currentProxyInfo.secret);
|
||||
break;
|
||||
case FIELD_REMARKS:
|
||||
inputFields[a].setHintText(LocaleController.getString("ProxyRemarks", R.string.ProxyRemarks));
|
||||
inputFields[a].setText(currentProxyInfo.getRemarks());
|
||||
break;
|
||||
}
|
||||
inputFields[a].setSelection(inputFields[a].length());
|
||||
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
package tw.nekomimi.nekogram
|
||||
|
||||
import android.util.Base64
|
||||
import android.util.LongSparseArray
|
||||
import com.v2ray.ang.V2RayConfig.SS_PROTOCOL
|
||||
import com.v2ray.ang.util.Utils
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.telegram.messenger.ApplicationLoader
|
||||
import org.telegram.messenger.FileLog
|
||||
import java.io.File
|
||||
import java.io.FileDescriptor
|
||||
import kotlin.concurrent.thread
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
|
@ -21,7 +17,7 @@ class ShadowsocksLoader {
|
|||
var port by Delegates.notNull<Int>()
|
||||
var shadowsocksProcess: GuardedProcessPool? = null
|
||||
|
||||
fun initConfig(bean: Bean,port: Int) {
|
||||
fun initConfig(bean: Bean, port: Int) {
|
||||
|
||||
this.bean = bean
|
||||
this.port = port
|
||||
|
@ -32,7 +28,7 @@ class ShadowsocksLoader {
|
|||
|
||||
stop()
|
||||
|
||||
val cacheCfg = File(ApplicationLoader.applicationContext.cacheDir,"ss_cfg_${bean.hash}.json")
|
||||
val cacheCfg = File(ApplicationLoader.applicationContext.cacheDir, "ss_cfg_${bean.hash}.json")
|
||||
|
||||
cacheCfg.writeText(bean.toJson().toString())
|
||||
|
||||
|
@ -43,7 +39,7 @@ class ShadowsocksLoader {
|
|||
}.apply {
|
||||
|
||||
start(listOf("${ApplicationLoader.applicationContext.applicationInfo.nativeLibraryDir}/libss-local.so",
|
||||
"-b","127.0.0.1",
|
||||
"-b", "127.0.0.1",
|
||||
"-t", "600",
|
||||
"-c", cacheCfg.path,
|
||||
"-l", port.toString()))
|
||||
|
@ -78,7 +74,8 @@ class ShadowsocksLoader {
|
|||
var host: String = "",
|
||||
var remotePort: Int = 443,
|
||||
var password: String = "",
|
||||
var method: String = "aes-256-cfb"
|
||||
var method: String = "aes-256-cfb",
|
||||
var remarks: String? = null
|
||||
) {
|
||||
|
||||
/*
|
||||
|
@ -95,7 +92,7 @@ class ShadowsocksLoader {
|
|||
put("server", host)
|
||||
put("server_port", remotePort)
|
||||
put("password", password)
|
||||
put("remarks", "nekox-cache")
|
||||
put("remarks", remarks ?: "Proxy From NekoX")
|
||||
put("route", "all")
|
||||
put("remote_dns", "8.8.8.8:53")
|
||||
put("ipv6", true)
|
||||
|
@ -114,7 +111,8 @@ class ShadowsocksLoader {
|
|||
|
||||
// ss-android style
|
||||
|
||||
val link = url.replace(SS_PROTOCOL,"https://").toHttpUrlOrNull() ?: error("invalid ss-android link $url")
|
||||
val link = url.replace(SS_PROTOCOL, "https://").toHttpUrlOrNull()
|
||||
?: error("invalid ss-android link $url")
|
||||
|
||||
if (link.password.isNotBlank()) {
|
||||
|
||||
|
@ -122,7 +120,8 @@ class ShadowsocksLoader {
|
|||
link.host,
|
||||
link.port,
|
||||
link.password,
|
||||
link.username
|
||||
link.username,
|
||||
link.fragment
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -133,7 +132,8 @@ class ShadowsocksLoader {
|
|||
link.host,
|
||||
link.port,
|
||||
methodAndPswd.substringAfter(":"),
|
||||
methodAndPswd.substringBefore(":")
|
||||
methodAndPswd.substringBefore(":"),
|
||||
link.fragment
|
||||
)
|
||||
|
||||
} else {
|
||||
|
@ -144,13 +144,15 @@ class ShadowsocksLoader {
|
|||
|
||||
if (v2Url.contains("#")) v2Url = v2Url.substringBefore("#")
|
||||
|
||||
val link = ("https://" + Utils.decode(v2Url.substringAfter(SS_PROTOCOL))).toHttpUrlOrNull() ?: error("invalid v2rayNG link $url")
|
||||
val link = ("https://" + Utils.decode(v2Url.substringAfter(SS_PROTOCOL))).toHttpUrlOrNull()
|
||||
?: error("invalid v2rayNG link $url")
|
||||
|
||||
return Bean(
|
||||
link.host,
|
||||
link.port,
|
||||
link.password,
|
||||
link.username
|
||||
link.username,
|
||||
link.fragment
|
||||
)
|
||||
|
||||
}
|
||||
|
@ -161,7 +163,11 @@ class ShadowsocksLoader {
|
|||
|
||||
override fun toString(): String {
|
||||
|
||||
return "ss://" + Utils.encode("$method:$password") + "@$host:$remotePort"
|
||||
var url = "ss://" + Utils.encode("$method:$password") + "@$host:$remotePort"
|
||||
|
||||
if (remarks?.isNotBlank() == true) url += "#" + Utils.urlEncode(remarks!!)
|
||||
|
||||
return url
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,8 @@ class ShadowsocksRLoader {
|
|||
var protocol_param: String = "",
|
||||
var obfs: String = "plain",
|
||||
var obfs_param: String = "",
|
||||
var method: String = "aes-256-cfb"
|
||||
var method: String = "aes-256-cfb",
|
||||
var remarks: String? = null
|
||||
) {
|
||||
|
||||
val hash = (host + remotePort + password + protocol + obfs + method).hashCode()
|
||||
|
@ -105,7 +106,7 @@ class ShadowsocksRLoader {
|
|||
put("protocol_param", protocol_param)
|
||||
put("obfs", obfs)
|
||||
put("obfs_param", obfs_param)
|
||||
put("remarks", "nekox-cache")
|
||||
put("remarks", remarks)
|
||||
put("route", "all")
|
||||
put("remote_dns", "8.8.8.8:53")
|
||||
put("ipv6", true)
|
||||
|
@ -143,6 +144,12 @@ class ShadowsocksRLoader {
|
|||
|
||||
}
|
||||
|
||||
runCatching {
|
||||
|
||||
bean.remarks = Utils.decode(httpUrl.queryParameter("remarks")!!)
|
||||
|
||||
}
|
||||
|
||||
return bean
|
||||
|
||||
}
|
||||
|
@ -156,7 +163,7 @@ class ShadowsocksRLoader {
|
|||
Base64.encodeToString("%s".format(Locale.ENGLISH, password).toByteArray(), flags),
|
||||
Base64.encodeToString("%s".format(Locale.ENGLISH, obfs_param).toByteArray(), flags),
|
||||
Base64.encodeToString("%s".format(Locale.ENGLISH, protocol_param).toByteArray(), flags),
|
||||
Base64.encodeToString("Exported From NekogramX".format(Locale.ENGLISH, protocol_param).toByteArray(), flags)).toByteArray(), flags)
|
||||
Base64.encodeToString("%s".format(Locale.ENGLISH, remarks ?: "Exported From NekoX").toByteArray(), flags)).toByteArray(), flags)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ public class ShadowsocksRSettingsActivity extends BaseFragment {
|
|||
private TextSettingsCell obfsField;
|
||||
private EditTextBoldCursor obfsParamField;
|
||||
|
||||
private EditTextBoldCursor remarksField;
|
||||
|
||||
private ScrollView scrollView;
|
||||
private LinearLayout linearLayout2;
|
||||
private LinearLayout inputFieldsContainer;
|
||||
|
@ -200,6 +202,7 @@ public class ShadowsocksRSettingsActivity extends BaseFragment {
|
|||
currentBean.setProtocol_param(protocolParamField.getText().toString());
|
||||
currentBean.setObfs(obfsField.getValueTextView().getText().toString());
|
||||
currentBean.setObfs_param(obfsParamField.getText().toString());
|
||||
currentBean.setRemarks(remarksField.getText().toString());
|
||||
|
||||
if (currentProxyInfo == null) {
|
||||
currentProxyInfo = new SharedConfig.ShadowsocksRProxy(currentBean);
|
||||
|
@ -241,9 +244,9 @@ public class ShadowsocksRSettingsActivity extends BaseFragment {
|
|||
}
|
||||
linearLayout2.addView(inputFieldsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
inputFields = new EditTextBoldCursor[6];
|
||||
inputFields = new EditTextBoldCursor[6];
|
||||
|
||||
for (int a = 0; a < 5; a++) {
|
||||
for (int a = 0; a < 6; a++) {
|
||||
FrameLayout container = new FrameLayout(context);
|
||||
EditTextBoldCursor cursor = mkCursor();
|
||||
inputFields[a] = cursor;
|
||||
|
@ -279,6 +282,12 @@ public class ShadowsocksRSettingsActivity extends BaseFragment {
|
|||
cursor.setHintText(LocaleController.getString("SSRObfsParam", R.string.SSRObfsParam));
|
||||
cursor.setText(currentBean.getObfs_param());
|
||||
break;
|
||||
case 5:
|
||||
remarksField = cursor;
|
||||
cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
cursor.setHintText(LocaleController.getString("ProxyRemarks", R.string.ProxyRemarks));
|
||||
cursor.setText(currentBean.getRemarks());
|
||||
break;
|
||||
}
|
||||
cursor.setSelection(cursor.length());
|
||||
|
||||
|
@ -350,6 +359,8 @@ public class ShadowsocksRSettingsActivity extends BaseFragment {
|
|||
|
||||
inputFieldsContainer.addView((View) obfsParamField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64));
|
||||
|
||||
inputFieldsContainer.addView((View) remarksField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64));
|
||||
|
||||
bottomCell = new TextInfoPrivacyCell(context);
|
||||
bottomCell.setBackground(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
bottomCell.setText(LocaleController.getString("ProxyInfoSSR", R.string.ProxyInfoSSR));
|
||||
|
|
|
@ -54,6 +54,7 @@ public class ShadowsocksSettingsActivity extends BaseFragment {
|
|||
private EditTextBoldCursor portField;
|
||||
private EditTextBoldCursor passwordField;
|
||||
private TextSettingsCell methodField;
|
||||
private EditTextBoldCursor remarksField;
|
||||
|
||||
private ScrollView scrollView;
|
||||
private LinearLayout linearLayout2;
|
||||
|
@ -190,6 +191,7 @@ public class ShadowsocksSettingsActivity extends BaseFragment {
|
|||
currentBean.setRemotePort(Utilities.parseInt(portField.getText().toString()));
|
||||
currentBean.setPassword(passwordField.getText().toString());
|
||||
currentBean.setMethod(methodField.getValueTextView().getText().toString());
|
||||
currentBean.setRemarks(remarksField.getText().toString());
|
||||
|
||||
if (currentProxyInfo == null) {
|
||||
currentProxyInfo = new SharedConfig.ShadowsocksProxy(currentBean);
|
||||
|
@ -231,9 +233,9 @@ public class ShadowsocksSettingsActivity extends BaseFragment {
|
|||
}
|
||||
linearLayout2.addView(inputFieldsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
inputFields = new EditTextBoldCursor[6];
|
||||
inputFields = new EditTextBoldCursor[4];
|
||||
|
||||
for (int a = 0; a < 3; a++) {
|
||||
for (int a = 0; a < 4; a++) {
|
||||
FrameLayout container = new FrameLayout(context);
|
||||
EditTextBoldCursor cursor = mkCursor();
|
||||
inputFields[a] = cursor;
|
||||
|
@ -257,6 +259,12 @@ public class ShadowsocksSettingsActivity extends BaseFragment {
|
|||
cursor.setHintText(LocaleController.getString("SSPassword", R.string.SSPassword));
|
||||
cursor.setText(currentBean.getPassword());
|
||||
break;
|
||||
case 3:
|
||||
remarksField = cursor;
|
||||
cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
cursor.setHintText(LocaleController.getString("ProxyRemarks", R.string.ProxyRemarks));
|
||||
cursor.setText(currentBean.getRemarks());
|
||||
break;
|
||||
}
|
||||
cursor.setSelection(cursor.length());
|
||||
|
||||
|
@ -288,6 +296,8 @@ public class ShadowsocksSettingsActivity extends BaseFragment {
|
|||
|
||||
inputFieldsContainer.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64));
|
||||
|
||||
inputFieldsContainer.addView((View) remarksField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64));
|
||||
|
||||
bottomCell = new TextInfoPrivacyCell(context);
|
||||
bottomCell.setBackground(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
bottomCell.setText(LocaleController.getString("ProxyInfoSS", R.string.ProxyInfoSS));
|
||||
|
|
|
@ -51,6 +51,7 @@ class VmessLoader {
|
|||
bean.address = lnk.host
|
||||
bean.port = lnk.port
|
||||
bean.id = lnk.username
|
||||
bean.remarks = lnk.fragment ?: ""
|
||||
|
||||
lnk.queryParameterNames.forEach {
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ public class VmessSettingsActivity extends BaseFragment {
|
|||
private EditTextBoldCursor requestHostField;
|
||||
private EditTextBoldCursor pathField;
|
||||
private TextCheckCell useTlsField;
|
||||
private EditTextBoldCursor remarksField;
|
||||
|
||||
private ScrollView scrollView;
|
||||
private LinearLayout linearLayout2;
|
||||
|
@ -219,6 +220,7 @@ public class VmessSettingsActivity extends BaseFragment {
|
|||
currentBean.setRequestHost(requestHostField.getText().toString());
|
||||
currentBean.setPath(pathField.getText().toString());
|
||||
currentBean.setStreamSecurity(useTlsField.isChecked() ? "tls" : "");
|
||||
currentBean.setRemarks(remarksField.getText().toString());
|
||||
|
||||
if (currentProxyInfo == null) {
|
||||
currentProxyInfo = new SharedConfig.VmessProxy(currentBean);
|
||||
|
@ -260,9 +262,9 @@ public class VmessSettingsActivity extends BaseFragment {
|
|||
}
|
||||
linearLayout2.addView(inputFieldsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
inputFields = new EditTextBoldCursor[6];
|
||||
inputFields = new EditTextBoldCursor[7];
|
||||
|
||||
for (int a = 0; a < 6; a++) {
|
||||
for (int a = 0; a < 7; a++) {
|
||||
FrameLayout container = new FrameLayout(context);
|
||||
EditTextBoldCursor cursor = mkCursor();
|
||||
inputFields[a] = cursor;
|
||||
|
@ -304,6 +306,12 @@ public class VmessSettingsActivity extends BaseFragment {
|
|||
cursor.setHintText(LocaleController.getString("VmessPath", R.string.VmessPath));
|
||||
cursor.setText(currentBean.getPath());
|
||||
break;
|
||||
case 6:
|
||||
remarksField = cursor;
|
||||
cursor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
cursor.setHintText(LocaleController.getString("ProxyRemarks", R.string.ProxyRemarks));
|
||||
cursor.setText(currentBean.getRemarks());
|
||||
break;
|
||||
}
|
||||
cursor.setSelection(cursor.length());
|
||||
|
||||
|
@ -385,6 +393,8 @@ public class VmessSettingsActivity extends BaseFragment {
|
|||
|
||||
inputFieldsContainer.addView(container, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64));
|
||||
|
||||
inputFieldsContainer.addView((View) remarksField.getParent(), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 64));
|
||||
|
||||
bottomCell = new TextInfoPrivacyCell(context);
|
||||
bottomCell.setBackground(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
bottomCell.setText(LocaleController.getString("ProxyInfoVmess", R.string.ProxyInfoVmess));
|
||||
|
|
|
@ -224,47 +224,7 @@ object ProxyUtil {
|
|||
@JvmStatic
|
||||
fun shareProxy(ctx: Activity, info: SharedConfig.ProxyInfo, type: Int) {
|
||||
|
||||
val url = if (info is SharedConfig.VmessProxy) {
|
||||
|
||||
info.bean.toString()
|
||||
|
||||
} else if (info is SharedConfig.ShadowsocksProxy) {
|
||||
|
||||
info.bean.toString()
|
||||
|
||||
} else if (info is SharedConfig.ShadowsocksRProxy) {
|
||||
|
||||
info.bean.toString()
|
||||
|
||||
} else {
|
||||
|
||||
val httpUrl = (if (info.secret.isEmpty()) {
|
||||
|
||||
"https://t.me/socks"
|
||||
|
||||
} else {
|
||||
|
||||
"https://t.me/proxy"
|
||||
|
||||
}).toHttpUrlOrNull()!!.newBuilder()
|
||||
|
||||
httpUrl.addQueryParameter("server", info.address)
|
||||
httpUrl.addQueryParameter("port", info.port.toString())
|
||||
|
||||
if (info.secret.isNotBlank()) {
|
||||
|
||||
httpUrl.addQueryParameter("secret", info.secret)
|
||||
|
||||
} else {
|
||||
|
||||
httpUrl.addQueryParameter("user", info.username)
|
||||
httpUrl.addQueryParameter("pass", info.password)
|
||||
|
||||
}
|
||||
|
||||
httpUrl.build().toString()
|
||||
|
||||
}
|
||||
val url = info.toUrl();
|
||||
|
||||
if (type == 1) {
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@
|
|||
<string name="SSRObfs">Obfs</string>
|
||||
<string name="SSRObfsParam">Obfs Param</string>
|
||||
|
||||
<string name="ProxyRemarks">Remarks</string>
|
||||
|
||||
<string name="MinApi21Required">Sorry, you need at least Android 5 (API21).</string>
|
||||
|
||||
<string name="ImportProxyFromClipboard">Import From Clipboard</string>
|
||||
|
|
Loading…
Reference in New Issue