[RELEASE] 6.0.1.11

This commit is contained in:
世界 2020-04-08 17:47:56 +08:00
parent 370d658573
commit de353c1e83
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
25 changed files with 345 additions and 386 deletions

View File

@ -9,7 +9,7 @@ jobs:
canaryBuild:
name: Canary Build
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[SKIP CI]') && !contains(github.event.head_commit.message, '[RELEASE]')"
if: "!contains(github.event.head_commit.message, '[S]') && !contains(github.event.head_commit.message, '[RELEASE]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1

View File

@ -27,7 +27,7 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5"
def okHttpVersion = '4.4.1'
def okHttpVersion = '4.5.0'
implementation "com.squareup.okhttp3:okhttp:$okHttpVersion"
implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okHttpVersion"
@ -38,17 +38,6 @@ dependencies {
implementation files('libs/ss-libev-release.aar')
implementation files('libs/ssr-libev-release.aar')
/*
def emojiVersion = '0.6.0'
implementation "com.vanniktech:emoji:$emojiVersion"
implementation "com.vanniktech:emoji-ios:$emojiVersion"
implementation "com.vanniktech:emoji-google:$emojiVersion"
implementation "com.vanniktech:emoji-twitter:$emojiVersion"
*/
releaseImplementation 'com.google.firebase:firebase-messaging:20.1.5'
releaseImplementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta03'
@ -65,8 +54,8 @@ android {
minSdkVersion 16
targetSdkVersion 28
versionName "6.0.1.10"
versionCode = 14
versionName "6.0.1.11"
versionCode = 15
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -141,6 +141,7 @@ import java.util.regex.Pattern;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.FileUtil;
import tw.nekomimi.nekogram.utils.StrUtil;
import static com.v2ray.ang.V2RayConfig.SSR_PROTOCOL;
@ -595,12 +596,6 @@ public class AndroidUtilities {
if (pathString.matches(Pattern.quote(new File(ApplicationLoader.applicationContext.getCacheDir(), "voip_logs").getAbsolutePath()) + "/\\d+\\.log")) {
return false;
}
if (!NekoConfig.saveCacheToSdcard && pathString.startsWith(new File(ApplicationLoader.applicationContext.getCacheDir(), "sdcard").getAbsolutePath())) {
return false;
}
if (!NekoConfig.saveCacheToSdcard && pathString.startsWith(new File(ApplicationLoader.applicationContext.getFilesDir(), "Telegram").getAbsolutePath())) {
return false;
}
int tries = 0;
while (true) {
if (pathString != null && pathString.length() > 4096) {
@ -1288,35 +1283,9 @@ public class AndroidUtilities {
}
public static File getCacheDir() {
String state = null;
try {
state = Environment.getExternalStorageState();
} catch (Exception e) {
FileLog.e(e);
}
if (NekoConfig.saveCacheToSdcard && (state == null || state.startsWith(Environment.MEDIA_MOUNTED))) {
try {
File file = ApplicationLoader.applicationContext.getExternalCacheDir();
if (file != null) {
return file;
}
} catch (Exception e) {
FileLog.e(e);
}
}
try {
File file = ApplicationLoader.applicationContext.getCacheDir();
if (file != null) {
if (!NekoConfig.saveCacheToSdcard) {
file = new File(file, "sdcard");
file.mkdirs();
}
return file;
}
} catch (Exception e) {
FileLog.e(e);
}
return new File("");
File cacheDir = new File(ApplicationLoader.getDataDirFixed(),"cache/media");
FileUtil.initDir(cacheDir);
return cacheDir;
}
public static int dp(float value) {

View File

@ -48,7 +48,7 @@ import tw.nekomimi.nekogram.utils.ZipUtil;
public class ApplicationLoader extends Application {
@SuppressLint("StaticFieldLeak")
public static volatile Context applicationContext; { applicationContext = this; }
public static volatile Context applicationContext;
public static volatile NetworkInfo currentNetworkInfo;
public static volatile boolean unableGetCurrentNetwork;
@ -93,111 +93,105 @@ public class ApplicationLoader extends Application {
}
public static void postInitApplication() {
if (applicationInited) {
return;
}
applicationInited = true;
try {
LocaleController.getInstance();
} catch (Exception e) {
e.printStackTrace();
}
if (applicationInited) {
return;
}
try {
connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
BroadcastReceiver networkStateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
try {
currentNetworkInfo = connectivityManager.getActiveNetworkInfo();
} catch (Throwable ignore) {
applicationInited = true;
try {
LocaleController.getInstance();
} catch (Exception e) {
e.printStackTrace();
}
try {
connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
BroadcastReceiver networkStateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
try {
currentNetworkInfo = connectivityManager.getActiveNetworkInfo();
} catch (Throwable ignore) {
}
boolean isSlow = isConnectionSlow();
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
ConnectionsManager.getInstance(a).checkConnection();
FileLoader.getInstance(a).onNetworkChanged(isSlow);
}
}
};
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
//Utilities.globalQueue.postRunnable(ApplicationLoader::ensureCurrentNetworkGet);
} catch (Exception e) {
e.printStackTrace();
}
boolean isSlow = isConnectionSlow();
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
ConnectionsManager.getInstance(a).checkConnection();
FileLoader.getInstance(a).onNetworkChanged(isSlow);
}
try {
final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
final BroadcastReceiver mReceiver = new ScreenReceiver();
applicationContext.registerReceiver(mReceiver, filter);
} catch (Exception e) {
e.printStackTrace();
}
try {
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
isScreenOn = pm.isScreenOn();
if (BuildVars.LOGS_ENABLED) {
FileLog.d("screen state = " + isScreenOn);
}
};
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter);
//Utilities.globalQueue.postRunnable(ApplicationLoader::ensureCurrentNetworkGet);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
FileLog.e(e);
}
try {
final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
final BroadcastReceiver mReceiver = new ScreenReceiver();
applicationContext.registerReceiver(mReceiver, filter);
} catch (Exception e) {
e.printStackTrace();
}
SharedConfig.loadConfig();
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
UserConfig.getInstance(a).loadConfig();
MessagesController.getInstance(a);
if (a == 0) {
SharedConfig.pushStringStatus = "__FIREBASE_GENERATING_SINCE_" + ConnectionsManager.getInstance(a).getCurrentTime() + "__";
} else {
ConnectionsManager.getInstance(a);
}
TLRPC.User user = UserConfig.getInstance(a).getCurrentUser();
if (user != null) {
MessagesController.getInstance(a).putUser(user, true);
SendMessagesHelper.getInstance(a).checkUnsentMessages();
}
}
try {
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
isScreenOn = pm.isScreenOn();
if (ProxyUtil.isVPNEnabled()) {
if (NekoXConfig.disableProxyWhenVpnEnabled) {
SharedConfig.setProxyEnable(false);
}
}
ApplicationLoader app = (ApplicationLoader) ApplicationLoader.applicationContext;
if (ExternalGcm.INSTANCE != null) {
ExternalGcm.INSTANCE.initPlayServices();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("screen state = " + isScreenOn);
FileLog.d("app initied");
}
} catch (Exception e) {
MediaController.getInstance();
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
ContactsController.getInstance(a).checkAppAccount();
DownloadController.getInstance(a);
}
} catch (Throwable e) {
FileLog.e(e);
}
SharedConfig.loadConfig();
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
UserConfig.getInstance(a).loadConfig();
MessagesController.getInstance(a);
if (a == 0) {
SharedConfig.pushStringStatus = "__FIREBASE_GENERATING_SINCE_" + ConnectionsManager.getInstance(a).getCurrentTime() + "__";
} else {
ConnectionsManager.getInstance(a);
}
TLRPC.User user = UserConfig.getInstance(a).getCurrentUser();
if (user != null) {
MessagesController.getInstance(a).putUser(user, true);
SendMessagesHelper.getInstance(a).checkUnsentMessages();
}
}
if (ProxyUtil.isVPNEnabled()) {
if (NekoXConfig.disableProxyWhenVpnEnabled) {
SharedConfig.setProxyEnable(false);
}
} else if (MessagesController.getGlobalMainSettings().getBoolean("first_open", true)) {
MessagesController.getGlobalMainSettings().edit().putBoolean("first_open", false).apply();
if (!UserConfig.getInstance(0).isClientActivated()) {
SharedConfig.setCurrentProxy(SharedConfig.proxyList.get(0));
}
}
ApplicationLoader app = (ApplicationLoader) ApplicationLoader.applicationContext;
if (ExternalGcm.INSTANCE != null) {
ExternalGcm.INSTANCE.initPlayServices();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("app initied");
}
MediaController.getInstance();
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
ContactsController.getInstance(a).checkAppAccount();
DownloadController.getInstance(a);
}
}
public ApplicationLoader() {

View File

@ -23,9 +23,8 @@ public class BuildVars {
public static int BUILD_VERSION;
public static String BUILD_VERSION_STRING;
public static int OFFICAL_APP_ID = 4;
public static String OFFICAL_APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static int OFFICAL_APP_ID = 21724;
public static String OFFICAL_APP_HASH = "3e0cb5efcd52300aec5994fdfc5bdc16";
static {

View File

@ -30,10 +30,15 @@ public class FileLoader extends BaseController {
public interface FileLoaderDelegate {
void fileUploadProgressChanged(String location, long uploadedSize, long totalSize, boolean isEncrypted);
void fileDidUploaded(String location, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile, byte[] key, byte[] iv, long totalFileSize);
void fileDidFailedUpload(String location, boolean isEncrypted);
void fileDidLoaded(String location, File finalFile, int type);
void fileDidFailedLoad(String location, int state);
void fileLoadProgressChanged(String location, long uploadedSize, long totalSize);
}
@ -79,6 +84,7 @@ public class FileLoader extends BaseController {
private ConcurrentHashMap<Integer, Object> parentObjectReferences = new ConcurrentHashMap<>();
private static volatile FileLoader[] Instance = new FileLoader[UserConfig.MAX_ACCOUNT_COUNT];
public static FileLoader getInstance(int num) {
FileLoader localInstance = Instance[num];
if (localInstance == null) {
@ -755,7 +761,7 @@ public class FileLoader extends BaseController {
final CountDownLatch semaphore = new CountDownLatch(1);
final FileLoadOperation[] result = new FileLoadOperation[1];
fileLoaderQueue.postRunnable(() -> {
result[0] = loadFileInternal(document, null, null, null, null, parentObject, null, 0, 1, stream, offset, priority, 0);
result[0] = loadFileInternal(document, null, null, null, null, parentObject, null, 0, 1, stream, offset, priority, 0);
semaphore.countDown();
});
try {
@ -1129,24 +1135,7 @@ public class FileLoader extends BaseController {
public static String getAttachFileName(TLObject attach, String ext) {
if (attach instanceof TLRPC.Document) {
TLRPC.Document document = (TLRPC.Document) attach;
String docExt = null;
if (docExt == null) {
docExt = getDocumentFileName(document);
int idx;
if (docExt == null || (idx = docExt.lastIndexOf('.')) == -1) {
docExt = "";
} else {
docExt = docExt.substring(idx);
}
}
if (docExt.length() <= 1) {
docExt = getExtensionByMimeType(document.mime_type);
}
if (docExt.length() > 1) {
return document.dc_id + "_" + document.id + docExt;
} else {
return document.dc_id + "_" + document.id;
}
return (document.dc_id + "_" + document.id).hashCode() + "_" + getDocumentFileName(document);
} else if (attach instanceof SecureDocument) {
SecureDocument secureDocument = (SecureDocument) attach;
return secureDocument.secureFile.dc_id + "_" + secureDocument.secureFile.id + ".jpg";

View File

@ -17,18 +17,17 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import androidx.exifinterface.media.ExifInterface;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.SparseArray;
import androidx.exifinterface.media.ExifInterface;
import org.json.JSONArray;
import org.json.JSONObject;
import org.telegram.messenger.secretmedia.EncryptedFileInputStream;
@ -66,7 +65,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.FileUtil;
public class ImageLoader {
@ -1638,7 +1637,6 @@ public class ImageLoader {
FileLog.e(e);
}
}
AndroidUtilities.createEmptyFile(new File(cachePath, ".nomedia"));
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath);
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
@ -1773,80 +1771,69 @@ public class ImageLoader {
FileLog.e(e);
}
}
AndroidUtilities.createEmptyFile(new File(cachePath, ".nomedia"));
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("cache path = " + cachePath);
}
try {
if (!NekoConfig.saveCacheToSdcard || Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
if (!NekoConfig.saveCacheToSdcard) {
telegramPath = ApplicationLoader.applicationContext.getExternalFilesDir("Telegram");
} else {
telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
telegramPath = ApplicationLoader.applicationContext.getExternalFilesDir("Telegram").getParentFile();
FileUtil.initDir(telegramPath);
if (telegramPath.isDirectory()) {
try {
File imagePath = new File(telegramPath, "images");
FileUtil.initDir(imagePath);
if (imagePath.isDirectory() && canMoveFiles(cachePath, imagePath, FileLoader.MEDIA_DIR_IMAGE)) {
mediaDirs.put(FileLoader.MEDIA_DIR_IMAGE, imagePath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("image path = " + imagePath);
}
}
} catch (Exception e) {
FileLog.e(e);
}
telegramPath.mkdirs();
if (telegramPath.isDirectory()) {
try {
File imagePath = new File(telegramPath, "Telegram Images");
imagePath.mkdir();
if (imagePath.isDirectory() && canMoveFiles(cachePath, imagePath, FileLoader.MEDIA_DIR_IMAGE)) {
mediaDirs.put(FileLoader.MEDIA_DIR_IMAGE, imagePath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("image path = " + imagePath);
}
try {
File videoPath = new File(telegramPath, "videos");
FileUtil.initDir(videoPath);
if (videoPath.isDirectory() && canMoveFiles(cachePath, videoPath, FileLoader.MEDIA_DIR_VIDEO)) {
mediaDirs.put(FileLoader.MEDIA_DIR_VIDEO, videoPath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("video path = " + videoPath);
}
} catch (Exception e) {
FileLog.e(e);
}
try {
File videoPath = new File(telegramPath, "Telegram Video");
videoPath.mkdir();
if (videoPath.isDirectory() && canMoveFiles(cachePath, videoPath, FileLoader.MEDIA_DIR_VIDEO)) {
mediaDirs.put(FileLoader.MEDIA_DIR_VIDEO, videoPath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("video path = " + videoPath);
}
}
} catch (Exception e) {
FileLog.e(e);
}
try {
File audioPath = new File(telegramPath, "Telegram Audio");
audioPath.mkdir();
if (audioPath.isDirectory() && canMoveFiles(cachePath, audioPath, FileLoader.MEDIA_DIR_AUDIO)) {
AndroidUtilities.createEmptyFile(new File(audioPath, ".nomedia"));
mediaDirs.put(FileLoader.MEDIA_DIR_AUDIO, audioPath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("audio path = " + audioPath);
}
}
} catch (Exception e) {
FileLog.e(e);
}
try {
File documentPath = new File(telegramPath, "Telegram Documents");
documentPath.mkdir();
if (documentPath.isDirectory() && canMoveFiles(cachePath, documentPath, FileLoader.MEDIA_DIR_DOCUMENT)) {
AndroidUtilities.createEmptyFile(new File(documentPath, ".nomedia"));
mediaDirs.put(FileLoader.MEDIA_DIR_DOCUMENT, documentPath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("documents path = " + documentPath);
}
}
} catch (Exception e) {
FileLog.e(e);
}
} catch (Exception e) {
FileLog.e(e);
}
} else {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("this Android can't rename files");
try {
File audioPath = new File(telegramPath, "audios");
FileUtil.initDir(audioPath);
if (audioPath.isDirectory() && canMoveFiles(cachePath, audioPath, FileLoader.MEDIA_DIR_AUDIO)) {
AndroidUtilities.createEmptyFile(new File(audioPath, ".nomedia"));
mediaDirs.put(FileLoader.MEDIA_DIR_AUDIO, audioPath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("audio path = " + audioPath);
}
}
} catch (Exception e) {
FileLog.e(e);
}
try {
File documentPath = new File(telegramPath, "documents");
FileUtil.initDir(documentPath);
if (documentPath.isDirectory() && canMoveFiles(cachePath, documentPath, FileLoader.MEDIA_DIR_DOCUMENT)) {
AndroidUtilities.createEmptyFile(new File(documentPath, ".nomedia"));
mediaDirs.put(FileLoader.MEDIA_DIR_DOCUMENT, documentPath);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("documents path = " + documentPath);
}
}
} catch (Exception e) {
FileLog.e(e);
}
}
SharedConfig.checkSaveToGalleryFiles();

View File

@ -156,7 +156,7 @@ public class LocaleController {
public File getPathToFile() {
File baseDir = new File(ApplicationLoader.applicationContext.getCacheDir().getParentFile(), "languages");
File baseDir = new File(ApplicationLoader.getDataDirFixed(), "languages");
FileUtil.initDir(baseDir);
@ -170,7 +170,8 @@ public class LocaleController {
public File getPathToBaseFile() {
if (isUnofficial()) {
File baseDir = new File(ApplicationLoader.applicationContext.getCacheDir().getParentFile(), "languages");
File baseDir = new File(ApplicationLoader.getDataDirFixed(), "languages");
FileUtil.initDir(baseDir);
return new File(baseDir, "unofficial_base_" + shortName + ".xml");
}
@ -237,7 +238,8 @@ public class LocaleController {
}
}
}
if (localInstance.formatterDay == null || localInstance.chatFullDate == null) localInstance.recreateFormatters();
if (localInstance.formatterDay == null || localInstance.chatFullDate == null)
localInstance.recreateFormatters();
return localInstance;
}

View File

@ -346,6 +346,37 @@ public class MessagesController extends BaseController implements NotificationCe
private DialogFilter sortingDialogFilter;
private final Comparator<TLRPC.Dialog> dialogDateComparator = (dialog1, dialog2) -> {
int pinnedNum1 = sortingDialogFilter.pinnedDialogs.get(dialog1.id, Integer.MIN_VALUE);
int pinnedNum2 = sortingDialogFilter.pinnedDialogs.get(dialog2.id, Integer.MIN_VALUE);
if (dialog1 instanceof TLRPC.TL_dialogFolder && !(dialog2 instanceof TLRPC.TL_dialogFolder)) {
return -1;
} else if (!(dialog1 instanceof TLRPC.TL_dialogFolder) && dialog2 instanceof TLRPC.TL_dialogFolder) {
return 1;
} else if (pinnedNum1 == Integer.MIN_VALUE && pinnedNum2 != Integer.MIN_VALUE) {
return 1;
} else if (pinnedNum1 != Integer.MIN_VALUE && pinnedNum2 == Integer.MIN_VALUE) {
return -1;
} else if (pinnedNum1 != Integer.MIN_VALUE && pinnedNum2 != Integer.MIN_VALUE) {
if (pinnedNum1 > pinnedNum2) {
return 1;
} else if (pinnedNum1 < pinnedNum2) {
return -1;
} else {
return 0;
}
}
final MediaDataController mediaDataController = getMediaDataController();
final long date1 = DialogObject.getLastMessageOrDraftDate(dialog1, mediaDataController.getDraft(dialog1.id));
final long date2 = DialogObject.getLastMessageOrDraftDate(dialog2, mediaDataController.getDraft(dialog2.id));
if (date1 < date2) {
return 1;
} else if (date1 > date2) {
return -1;
}
return 0;
};
private final Comparator<TLRPC.Dialog> dialogComparator = (dialog1, dialog2) -> {
if (dialog1 instanceof TLRPC.TL_dialogFolder && !(dialog2 instanceof TLRPC.TL_dialogFolder)) {
return -1;
@ -2192,7 +2223,7 @@ public class MessagesController extends BaseController implements NotificationCe
return;
}
installReferer = referer;
mainPreferences.edit().putString("installReferer", referer).apply();
mainPreferences.edit().putString("installReferer", referer).commit();
}
public void putEncryptedChat(TLRPC.EncryptedChat encryptedChat, boolean fromCache) {
@ -2671,7 +2702,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
SharedPreferences.Editor editor = notificationsPreferences.edit();
editor.putInt("dialog_bar_vis3" + dialogId, 3);
editor.apply();
editor.commit();
if ((int) dialogId != 0) {
TLRPC.TL_messages_hidePeerSettingsBar req = new TLRPC.TL_messages_hidePeerSettingsBar();
if (currentUser != null) {
@ -2691,7 +2722,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
SharedPreferences.Editor editor = notificationsPreferences.edit();
editor.putInt("dialog_bar_vis3" + dialogId, 3);
editor.apply();
editor.commit();
if ((int) dialogId == 0) {
if (currentEncryptedChat == null || currentEncryptedChat.access_hash == 0) {
return;
@ -2737,7 +2768,7 @@ public class MessagesController extends BaseController implements NotificationCe
editor.putBoolean("dialog_bar_block" + dialogId, settings.block_contact);
editor.putBoolean("dialog_bar_exception" + dialogId, settings.need_contacts_exception);
editor.putBoolean("dialog_bar_location" + dialogId, settings.report_geo);
editor.apply();
editor.commit();
getNotificationCenter().postNotificationName(NotificationCenter.peerSettingsDidLoad, dialogId);
}
@ -4273,14 +4304,14 @@ public class MessagesController extends BaseController implements NotificationCe
AndroidUtilities.runOnUIThread(passwordCheckRunnable);
lastPasswordCheckTime = currentTime;
}
getLocationController().update();
checkProxyInfoInternal(false);
checkTosUpdate();
if (lastPushRegisterSendTime != 0 && Math.abs(SystemClock.elapsedRealtime() - lastPushRegisterSendTime) >= 3 * 60 * 60 * 1000) {
if (ExternalGcm.INSTANCE != null) {
ExternalGcm.INSTANCE.sendRegistrationToServer();
}
}
getLocationController().update();
checkProxyInfoInternal(false);
checkTosUpdate();
}
private void checkTosUpdate() {
@ -4301,7 +4332,7 @@ public class MessagesController extends BaseController implements NotificationCe
} else {
nextTosCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60;
}
notificationsPreferences.edit().putInt("nextTosCheckTime", nextTosCheckTime).apply();
notificationsPreferences.edit().putInt("nextTosCheckTime", nextTosCheckTime).commit();
});
}
@ -4373,7 +4404,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
proxyDialogId = did;
proxyDialogAddress = proxyAddress + proxySecret;
getGlobalMainSettings().edit().putLong("proxy_dialog", proxyDialogId).putString("proxyDialogAddress", proxyDialogAddress).apply();
getGlobalMainSettings().edit().putLong("proxy_dialog", proxyDialogId).putString("proxyDialogAddress", proxyDialogAddress).commit();
nextProxyInfoCheckTime = res.expires;
if (!noDialog) {
AndroidUtilities.runOnUIThread(() -> {
@ -4522,7 +4553,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
if (noDialog) {
proxyDialogId = 0;
getGlobalMainSettings().edit().putLong("proxy_dialog", proxyDialogId).remove("proxyDialogAddress").apply();
getGlobalMainSettings().edit().putLong("proxy_dialog", proxyDialogId).remove("proxyDialogAddress").commit();
checkingProxyInfoRequestId = 0;
checkingProxyInfo = false;
AndroidUtilities.runOnUIThread(this::removeProxyDialog);
@ -4534,7 +4565,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (removeCurrent != 0) {
proxyDialogId = 0;
proxyDialogAddress = null;
getGlobalMainSettings().edit().putLong("proxy_dialog", proxyDialogId).remove("proxyDialogAddress").apply();
getGlobalMainSettings().edit().putLong("proxy_dialog", proxyDialogId).remove("proxyDialogAddress").commit();
nextProxyInfoCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60;
if (removeCurrent == 2) {
checkingProxyInfo = false;
@ -5449,7 +5480,7 @@ public class MessagesController extends BaseController implements NotificationCe
editor1.putInt("EnableGroup2", Integer.MAX_VALUE);
editor1.putInt("EnableChannel2", Integer.MAX_VALUE);
}
editor1.remove("EnableGroup").apply();
editor1.remove("EnableGroup").commit();
}
if (preferences.contains("EnableAll")) {
boolean enabled = preferences.getBoolean("EnableAll", true);
@ -5459,10 +5490,10 @@ public class MessagesController extends BaseController implements NotificationCe
if (!enabled) {
editor1.putInt("EnableAll2", Integer.MAX_VALUE);
}
editor1.remove("EnableAll").apply();
editor1.remove("EnableAll").commit();
}
if (editor1 != null) {
editor1.apply();
editor1.commit();
}
loadingNotificationSettings = 3;
@ -5524,7 +5555,7 @@ public class MessagesController extends BaseController implements NotificationCe
editor.putInt("EnableChannel2", notify_settings.mute_until);
}
}
editor.apply();
editor.commit();
if (loadingNotificationSettings == 0) {
getUserConfig().notificationsSettingsLoaded = true;
getUserConfig().saveConfig(false);
@ -5547,7 +5578,7 @@ public class MessagesController extends BaseController implements NotificationCe
SharedPreferences.Editor editor = notificationsPreferences.edit();
enableJoined = response instanceof TLRPC.TL_boolFalse;
editor.putBoolean("EnableContactJoined", enableJoined);
editor.apply();
editor.commit();
getUserConfig().notificationsSignUpSettingsLoaded = true;
getUserConfig().saveConfig(false);
}));
@ -12037,28 +12068,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
sortingDialogFilter = selectedDialogFilter[b];
try {
Collections.sort(allDialogs, dialogComparator);
} catch (Exception e) {
NekoXConfig.sortByUnread = false;
NekoXConfig.sortByUnmuted = false;
NekoXConfig.sortByUser = false;
NekoXConfig.sortByContacts = false;
try {
Collections.sort(allDialogs, dialogComparator);
} catch (Exception ex) {
FileLog.e(ex);
}
}
Collections.sort(allDialogs, dialogDateComparator);
ArrayList<TLRPC.Dialog> dialogsByFilter = selectedDialogFilter[b].dialogs;

View File

@ -1424,16 +1424,26 @@ public class SharedConfig {
int current = MessagesController.getGlobalMainSettings().getInt("current_proxy", 0);
VmessProxy publicProxy = new VmessProxy(VmessLoader.getPublic());
publicProxy.isPublic = true;
proxyList.add(publicProxy);
try {
if (publicProxy.hashCode() == current) {
if (!NekoXConfig.hidePublicProxy) {
currentProxy = publicProxy;
VmessProxy publicProxy = new VmessProxy(VmessLoader.getPublic());
publicProxy.isPublic = true;
proxyList.add(publicProxy);
publicProxy.start();
if (publicProxy.hashCode() == current) {
currentProxy = publicProxy;
publicProxy.start();
}
}
} catch (Exception e) {
FileLog.e(e);
}
@ -1719,16 +1729,11 @@ public class SharedConfig {
public static void checkSaveToGalleryFiles() {
try {
File telegramPath;
if (!NekoConfig.saveCacheToSdcard) {
telegramPath = new File(ApplicationLoader.applicationContext.getFilesDir(), "Telegram");
} else {
telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
}
File imagePath = new File(telegramPath, "Telegram Images");
imagePath.mkdir();
File videoPath = new File(telegramPath, "Telegram Video");
videoPath.mkdir();
File telegramPath = ApplicationLoader.applicationContext.getExternalFilesDir( "Telegram").getParentFile();
File imagePath = new File(telegramPath, "images");
imagePath.mkdirs();
File videoPath = new File(telegramPath, "videos");
videoPath.mkdirs();
if (saveToGallery) {
if (imagePath.isDirectory()) {

View File

@ -1209,13 +1209,15 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
}
blockCell.setTextAndValueAndIcon(LocaleController.getString("ChannelPermissions", R.string.ChannelPermissions), String.format("%d/%d", count, 8), R.drawable.actions_permissions, true);
}
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants != null && info.participants.participants.size() != info.participants_count && realAdminCount == 0) {
adminCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.actions_addadmin, true);
} else {
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? ChatObject.hasAdminRights(currentChat) ? info.admins_count : realAdminCount == 0 ? getChannelAdminCount() : realAdminCount : getAdminCount()), R.drawable.actions_addadmin, true);
}
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants != null && info.participants.participants.size() != info.participants_count) {
getRealChannelAdminCount();
if (info.participants != null) {
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants.participants.size() != info.participants_count && realAdminCount == 0) {
adminCell.setTextAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), R.drawable.actions_addadmin, true);
} else {
adminCell.setTextAndValueAndIcon(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", ChatObject.isChannel(currentChat) ? ChatObject.hasAdminRights(currentChat) ? info.admins_count : realAdminCount == 0 ? getChannelAdminCount() : realAdminCount : getAdminCount()), R.drawable.actions_addadmin, true);
}
if (ChatObject.isChannel(currentChat) && !ChatObject.hasAdminRights(currentChat) && info.participants.participants.size() != info.participants_count) {
getRealChannelAdminCount();
}
}
} else {
if (isChannel) {

View File

@ -261,7 +261,7 @@ public class UndoView extends FrameLayout {
if (currentActionRunnable != null) {
currentActionRunnable.run();
}
if (NekoXConfig.disableUndo) {
if (NekoXConfig.disableUndo && action != ACTION_DICE_INFO && action != ACTION_DICE_NO_SEND_INFO) {
if (actionRunnable != null) actionRunnable.run();
return;
}

View File

@ -1313,15 +1313,21 @@ public class DocumentSelectActivity extends BaseFragment {
}
}
}
ListItem fs = new ListItem();
/*
fs.title = "/";
fs.subtitle = LocaleController.getString("SystemRoot", R.string.SystemRoot);
fs.icon = R.drawable.files_folder;
fs.file = new File("/");
items.add(fs);
*/
ListItem fs = new ListItem();
try {
File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
File telegramPath = ApplicationLoader.applicationContext.getExternalFilesDir("Telegram").getParentFile();
if (telegramPath.exists()) {
fs = new ListItem();
fs.title = "Telegram";

View File

@ -10,7 +10,6 @@ package org.telegram.ui;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
@ -84,7 +83,6 @@ import tw.nekomimi.nekogram.VmessSettingsActivity;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.FileUtil;
import tw.nekomimi.nekogram.utils.ProxyUtil;
import tw.nekomimi.nekogram.utils.StrUtil;
import tw.nekomimi.nekogram.utils.UIUtil;
public class ProxyListActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -983,22 +981,28 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente
boolean change = callsRow == -1;
callsRow = rowCount++;
callsDetailRow = rowCount++;
if (!notify && change) {
listAdapter.notifyItemChanged(proxyDetailRow);
listAdapter.notifyItemRangeInserted(proxyDetailRow + 1, 2);
}
UIUtil.runOnUIThread(() -> {
if (!notify && change) {
listAdapter.notifyItemChanged(proxyDetailRow);
listAdapter.notifyItemRangeInserted(proxyDetailRow + 1, 2);
}
});
} else {
boolean change = callsRow != -1;
callsRow = -1;
callsDetailRow = -1;
if (!notify && change) {
listAdapter.notifyItemChanged(proxyDetailRow);
listAdapter.notifyItemRangeRemoved(proxyDetailRow + 1, 2);
UIUtil.runOnUIThread(() -> {
listAdapter.notifyItemChanged(proxyDetailRow);
listAdapter.notifyItemRangeRemoved(proxyDetailRow + 1, 2);
});
}
}
checkProxyList(false);
if (notify && listAdapter != null) {
listAdapter.notifyDataSetChanged();
UIUtil.runOnUIThread(() -> {
listAdapter.notifyDataSetChanged();
});
}
}

View File

@ -490,7 +490,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No
emojiRow = rowCount++;
raiseToSpeakRow = rowCount++;
sendByEnterRow = rowCount++;
saveToGalleryRow = NekoConfig.saveCacheToSdcard ? rowCount++ : -1;
saveToGalleryRow = rowCount++;
distanceRow = rowCount++;
settings2Row = rowCount++;
stickersRow = rowCount++;

View File

@ -24,7 +24,6 @@ public class NekoConfig {
public static boolean useSystemEmoji = SharedConfig.useSystemEmoji;
public static boolean ignoreBlocked = false;
public static boolean hideProxySponsorChannel = false;
public static boolean saveCacheToSdcard = false;
public static boolean disablePhotoSideAction = true;
public static boolean hideKeyboardOnChatScroll = false;
public static int mapPreviewProvider = 0;
@ -75,7 +74,6 @@ public class NekoConfig {
editor.putBoolean("transparentStatusBar", transparentStatusBar);
editor.putBoolean("residentNotification", residentNotification);
editor.putBoolean("hideProxySponsorChannel", hideProxySponsorChannel);
editor.putBoolean("saveCacheToSdcard", saveCacheToSdcard);
editor.putBoolean("showAddToSavedMessages", showAddToSavedMessages);
editor.putBoolean("showReport", showReport);
editor.putBoolean("showPrPr", showPrPr);
@ -126,7 +124,6 @@ public class NekoConfig {
transparentStatusBar = preferences.getBoolean("transparentStatusBar", false);
residentNotification = preferences.getBoolean("residentNotification", false);
hideProxySponsorChannel = preferences.getBoolean("hideProxySponsorChannel", false);
saveCacheToSdcard = preferences.getBoolean("saveCacheToSdcard", Build.VERSION.SDK_INT >= Build.VERSION_CODES.N);
showAddToSavedMessages = preferences.getBoolean("showAddToSavedMessages", true);
showReport = preferences.getBoolean("showReport", false);
showPrPr = preferences.getBoolean("showPrPr", false);
@ -310,14 +307,6 @@ public class NekoConfig {
editor.apply();
}
public static void toggleSaveCacheToSdcard() {
saveCacheToSdcard = !saveCacheToSdcard;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("saveCacheToSdcard", saveCacheToSdcard);
editor.apply();
}
public static void setEventType(int type) {
eventType = type;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);

View File

@ -84,7 +84,6 @@ public class NekoSettingsActivity extends BaseFragment {
private int useSystemEmojiRow;
private int ignoreBlockedRow;
private int hideProxySponsorChannelRow;
private int saveCacheToSdcardRow;
private int skipOpenLinkConfiirm;
private int pauseMusicOnRecordRow;
private int disablePhotoSideActionRow;
@ -227,11 +226,6 @@ public class NekoSettingsActivity extends BaseFragment {
MessagesController.getInstance(a).checkProxyInfo(true);
}
}
} else if (position == saveCacheToSdcardRow) {
NekoConfig.toggleSaveCacheToSdcard();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.saveCacheToSdcard);
}
} else if (position == skipOpenLinkConfiirm) {
NekoXConfig.toggleSkipOpenLinkConfirm();
if (view instanceof TextCheckCell) {
@ -535,7 +529,6 @@ public class NekoSettingsActivity extends BaseFragment {
useSystemEmojiRow = rowCount++;
ignoreBlockedRow = rowCount++;
hideProxySponsorChannelRow = rowCount++;
saveCacheToSdcardRow = rowCount++;
skipOpenLinkConfiirm = rowCount++;
pauseMusicOnRecordRow = rowCount++;
disablePhotoSideActionRow = rowCount++;
@ -1103,8 +1096,6 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndCheck(LocaleController.getString("TransparentStatusBar", R.string.TransparentStatusBar), NekoConfig.transparentStatusBar, true);
} else if (position == hideProxySponsorChannelRow) {
textCell.setTextAndCheck(LocaleController.getString("HideProxySponsorChannel", R.string.HideProxySponsorChannel), NekoConfig.hideProxySponsorChannel, true);
} else if (position == saveCacheToSdcardRow) {
textCell.setTextAndCheck(LocaleController.getString("SaveCacheToSdcard", R.string.SaveCacheToSdcard), NekoConfig.saveCacheToSdcard, true);
} else if (position == skipOpenLinkConfiirm) {
textCell.setTextAndCheck(LocaleController.getString("SkipOpenLinkConfirm", R.string.SkipOpenLinkConfirm), NekoXConfig.skipOpenLinkConfirm, true);
} else if (position == disableChatActionRow) {
@ -1180,7 +1171,7 @@ public class NekoSettingsActivity extends BaseFragment {
position == useSystemEmojiRow || position == ipv6Row || position == disableProxyWhenVpnEnabledRow || position == typefaceRow || position == nameOrderRow ||
position == forceTabletRow || position == mapPreviewRow || position == newYearRow ||
position == actionBarDecorationRow || position == eventTypeRow || position == transparentStatusBarRow ||
position == hideProxySponsorChannelRow || position == saveCacheToSdcardRow || position == skipOpenLinkConfiirm ||
position == hideProxySponsorChannelRow || position == skipOpenLinkConfiirm ||
position == disableFilteringRow || position == stickerSizeRow ||
position == unlimitedFavedStickersRow || position == messageMenuRow || position == deleteAccountRow ||
position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
@ -1238,7 +1229,7 @@ public class NekoSettingsActivity extends BaseFragment {
position == transparentStatusBarRow || position == hideProxySponsorChannelRow ||
position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow ||
position == forceTabletRow || position == newYearRow ||
position == saveCacheToSdcardRow || position == unlimitedFavedStickersRow || position == skipOpenLinkConfiirm ||
position == unlimitedFavedStickersRow || position == skipOpenLinkConfiirm ||
position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow ||
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
position == hideKeyboardOnChatScrollRow || position == disableSystemAccountRow || position == avatarAsDrawerBackgroundRow ||

View File

@ -1,7 +1,10 @@
package tw.nekomimi.nekogram;
import android.content.Context;
import android.content.SharedPreferences;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R;
@ -13,9 +16,7 @@ import tw.nekomimi.nekogram.database.NitritesKt;
public class NekoXConfig {
public static String FAQ_URL = "https://telegra.ph/NekoX-%E5%B8%B8%E8%A6%8B%E5%95%8F%E9%A1%8C-03-31";
protected static SharedPreferences preferences = NitritesKt.openMainSharedPreference("nekox_config");
public static String FAQ_URL = "https://telegra.ph/NekoX-FAQ-03-31";
public static boolean disableChatAction;
@ -54,8 +55,12 @@ public class NekoXConfig {
public static boolean removeTitleEmoji;
public static boolean hidePublicProxy;
private static SharedPreferences preferences;
static {
preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekox_config", Context.MODE_PRIVATE);
disableChatAction = preferences.getBoolean("disable_chat_action", false);
developerMode = preferences.getBoolean("developer_mode", false);
@ -89,7 +94,7 @@ public class NekoXConfig {
removeTitleEmoji = preferences.getBoolean("remove_title_emoji", false);
ignoreMutedCount = preferences.getBoolean("ignore_muted_count", true);
hidePublicProxy = preferences.getBoolean("hide_public_proxy",false);
hidePublicProxy = preferences.getBoolean("hide_public_proxy", false);
}

View File

@ -20,7 +20,9 @@ class DbPref(val connection: NitriteCollection) : SharedPreferences {
private inline fun <reified T> getAs(key: String, defValue: T): T {
connection.find(Filters.eq("key", key)).apply {
if (hasMore()) return first().get("value", T::class.java)
runCatching {
return first().get("value", T::class.java)
}
}
return defValue
}
@ -108,25 +110,6 @@ class DbPref(val connection: NitriteCollection) : SharedPreferences {
return this
}
fun putAll(map: MutableMap<String, out Any?>): PrefEditor {
map.forEach { (key, value) ->
if (value == null) {
connection.remove(Filters.eq("key", key))
} else {
connection.update(Filters.eq("key", key), Document().apply {
put("key", key)
put("value", value)
}, UpdateOptions.updateOptions(true))
}
}
return this
}
override fun commit(): Boolean {
try {
if (clear) {

View File

@ -5,10 +5,9 @@ import org.telegram.messenger.ApplicationLoader
import tw.nekomimi.nekogram.utils.FileUtil
import java.io.File
@JvmOverloads
fun mkDatabase(name: String): Nitrite {
val dir = File("${ApplicationLoader.getDataDirFixed()}/databases")
val dir = File("${ApplicationLoader.getDataDirFixed()}/files")
FileUtil.initDir(dir)
@ -18,7 +17,6 @@ fun mkDatabase(name: String): Nitrite {
}
@JvmOverloads
fun mkCacheDatabase(name: String) : Nitrite {
val dir = File("${ApplicationLoader.getDataDirFixed()}/cache")
@ -33,6 +31,16 @@ fun mkCacheDatabase(name: String) : Nitrite {
fun Nitrite.openSharedPreference(name: String) = DbPref(getCollection(name))
val mainSharedPreferencesDatabase = mkDatabase("shared_preferences")
private lateinit var mainSharedPreferencesDatabase: Nitrite
fun openMainSharedPreference(name: String) = mainSharedPreferencesDatabase.openSharedPreference(name)
fun openMainSharedPreference(name: String): DbPref {
if (!::mainSharedPreferencesDatabase.isInitialized) {
mainSharedPreferencesDatabase = mkDatabase("shared_preferences")
}
return mainSharedPreferencesDatabase.openSharedPreference(name)
}

View File

@ -7,14 +7,16 @@ import org.json.JSONException;
import org.json.JSONTokener;
import org.telegram.messenger.FileLog;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.Request;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.utils.HttpUtil;
public class GoogleWebTranslator extends Translator {
@ -116,19 +118,45 @@ public class GoogleWebTranslator extends Translator {
}
private String request(String url) {
try {
ByteArrayOutputStream outbuf;
InputStream httpConnectionStream;
URL downloadUrl = new URL(url);
URLConnection httpConnection = downloadUrl.openConnection();
httpConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A5297c Safari/602.1");
httpConnection.setConnectTimeout(1000);
httpConnection.setReadTimeout(2000);
httpConnection.connect();
httpConnectionStream = httpConnection.getInputStream();
return (NekoConfig.translationProvider == 2 ? HttpUtil.okhttpClient : HttpUtil.getOkhttpClientWithCurrProxy())
.newCall(new Request.Builder()
.url(url)
.header("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A5297c Safari/602.1")
.build()).execute().body().string();
outbuf = new ByteArrayOutputStream();
byte[] data = new byte[1024 * 32];
while (true) {
int read = httpConnectionStream.read(data);
if (read > 0) {
outbuf.write(data, 0, read);
} else if (read == -1) {
break;
} else {
break;
}
}
String result = new String(outbuf.toByteArray());
try {
httpConnectionStream.close();
} catch (Throwable e) {
FileLog.e(e);
}
try {
outbuf.close();
} catch (Exception ignore) {
}
return result;
} catch (Throwable e) {
FileLog.e(e);
return null;
}
}
}

View File

@ -9,19 +9,9 @@ object FileUtil {
@JvmStatic
fun initDir(dir: File) {
dir.parentFile?.also { initDir(it) }
dir.mkdirs()
if (!dir.isDirectory) {
if (dir.isFile) dir.deleteRecursively()
if (!dir.mkdirs() && !dir.isDirectory) {
error("unable to create dir ${dir.path}")
}
}
// ignored
}

View File

@ -127,7 +127,7 @@ object PrivacyUtil {
response.rules.forEach {
if (it !is TLRPC.TL_privacyValueDisallowAll) {
if (it is TLRPC.TL_privacyValueAllowAll) {
showPrivacyAlert(ctx, account, 2)
@ -195,10 +195,11 @@ object PrivacyUtil {
}
val alertDialog = builder.show()
runCatching {
(alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL) as TextView?)?.setTextColor(Theme.getColor(Theme.key_dialogTextRed2))
(builder.show().getButton(DialogInterface.BUTTON_NEUTRAL) as TextView?)?.setTextColor(Theme.getColor(Theme.key_dialogTextRed2))
}
}

View File

@ -2,6 +2,12 @@
<resources>
<string name="UseOfficalId">Disfarçada como aplicativo oficial</string>
<string name="UseOfficalIdNotice">Faça login usando o ID do aplicativo oficial. Se não conseguir se registrar ou fazer login, isso pode ajudar. \n\nNota: o fcm não funcionará se você estiver usando a versão de lançamento.</string>
<string name="PrivacyNotice">Aviso de privacidade</string>
<string name="PrivacyNoticePhoneVisible">Detectou-se que seu número de celular está visível para qualquer pessoa, o que pode fazer com que hackers controlados pelo governo encontrem sua verdadeira identidade, desligue-o!</string>
<string name="PrivacyNoticeAddByPhone">Detectou-se que você não está desativado na configuração \"Permitir que me encontre através do número de telefone\", que pode fazer com que um hacker controlado pelo governo encontre sua verdadeira identidade, desligue-o!</string>
<string name="PrivacyNoticeP2p">Foi detectado que você não desativou a configuração \"Permitir chamadas P2p\", que pode fazer com que hackers controlados pelo governo encontrem sua verdadeira identidade, desligue-a!</string>
<string name="ApplySuggestion">OK, aplique</string>
<string name="DoNotRemindAgain">Não lembre novamente</string>
<string name="RemoveTitleEmoji">Remover emoji no título</string>
<string name="NekoXProxy">NekoX Público Proxy</string>
<string name="PublicPrefix">[ Público ]</string>

View File

@ -6,6 +6,8 @@
<string name="PrivacyNoticePhoneVisible">檢測到您的手機號碼對任何人都可見, 這可能會導致政府控制的黑客找到您的真實身份,請關閉它!</string>
<string name="PrivacyNoticeAddByPhone">檢測到您沒有被關閉“允許通過電話號碼找到我”設置, 這可能會導致政府控制的黑客找到您的真實身份,請關閉它!</string>
<string name="PrivacyNoticeP2p">檢測到您沒有關閉“允許 P2p 通話”設置, 這可能會導致政府控制的黑客找到您的真實身份,請關閉它!</string>
<string name="ApplySuggestion">應用</string>
<string name="DoNotRemindAgain">不再提醒</string>
<string name="RemoveTitleEmoji">移除標題中的表情</string>
<string name="NekoXProxy">NekoX 公共代理</string>
<string name="PublicPrefix">[ 公共 ]</string>