mirror of https://github.com/NekoX-Dev/NekoX.git
Minor fixes
This commit is contained in:
parent
3b9f39167f
commit
b54a41dc6c
|
@ -1,8 +1,11 @@
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
def verName = "7.4.2-preview-5"
|
def verName = "7.4.2-preview-6"
|
||||||
def verCode = 172
|
def verCode = 174
|
||||||
|
|
||||||
|
def officialVer = "7.4.2"
|
||||||
|
def officialCode = 2227
|
||||||
|
|
||||||
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
|
def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json")
|
||||||
|
|
||||||
|
@ -161,6 +164,9 @@ android {
|
||||||
appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash
|
appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
buildConfigField 'String', 'OFFICIAL_VERSION', "\"" + officialVer + "\""
|
||||||
|
buildConfigField 'int', 'OFFICIAL_VERSION_CODE', officialCode + ""
|
||||||
buildConfigField 'int', 'APP_ID', appId
|
buildConfigField 'int', 'APP_ID', appId
|
||||||
buildConfigField 'String', 'APP_HASH', "\"" + appHash + "\""
|
buildConfigField 'String', 'APP_HASH', "\"" + appHash + "\""
|
||||||
|
|
||||||
|
|
|
@ -7604,7 +7604,7 @@ public class MessagesController extends BaseController implements NotificationCe
|
||||||
migratingDialogs = false;
|
migratingDialogs = false;
|
||||||
getNotificationCenter().postNotificationName(NotificationCenter.needReloadRecentDialogsSearch);
|
getNotificationCenter().postNotificationName(NotificationCenter.needReloadRecentDialogsSearch);
|
||||||
} else {
|
} else {
|
||||||
generateUpdateMessage();
|
// generateUpdateMessage();
|
||||||
if (!added && loadType == DIALOGS_LOAD_TYPE_CACHE && dialogsEndReached.get(folderId)) {
|
if (!added && loadType == DIALOGS_LOAD_TYPE_CACHE && dialogsEndReached.get(folderId)) {
|
||||||
loadDialogs(folderId, 0, count, false);
|
loadDialogs(folderId, 0, count, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class UserConfig extends BaseController {
|
||||||
public long lastUpdateCheckTime;
|
public long lastUpdateCheckTime;
|
||||||
public long autoDownloadConfigLoadTime;
|
public long autoDownloadConfigLoadTime;
|
||||||
public boolean isBot;
|
public boolean isBot;
|
||||||
|
public boolean official;
|
||||||
|
|
||||||
public volatile byte[] savedPasswordHash;
|
public volatile byte[] savedPasswordHash;
|
||||||
public volatile byte[] savedSaltedPassword;
|
public volatile byte[] savedSaltedPassword;
|
||||||
|
@ -151,6 +152,8 @@ public class UserConfig extends BaseController {
|
||||||
editor.putInt("sharingMyLocationUntil", sharingMyLocationUntil);
|
editor.putInt("sharingMyLocationUntil", sharingMyLocationUntil);
|
||||||
editor.putInt("lastMyLocationShareTime", lastMyLocationShareTime);
|
editor.putInt("lastMyLocationShareTime", lastMyLocationShareTime);
|
||||||
editor.putBoolean("isBot", isBot);
|
editor.putBoolean("isBot", isBot);
|
||||||
|
editor.putBoolean("official", official);
|
||||||
|
|
||||||
editor.putBoolean("filtersLoaded", filtersLoaded);
|
editor.putBoolean("filtersLoaded", filtersLoaded);
|
||||||
if (tonEncryptedData != null) {
|
if (tonEncryptedData != null) {
|
||||||
editor.putString("tonEncryptedData", tonEncryptedData);
|
editor.putString("tonEncryptedData", tonEncryptedData);
|
||||||
|
@ -303,6 +306,7 @@ public class UserConfig extends BaseController {
|
||||||
autoDownloadConfigLoadTime = preferences.getLong("autoDownloadConfigLoadTime", 0);
|
autoDownloadConfigLoadTime = preferences.getLong("autoDownloadConfigLoadTime", 0);
|
||||||
hasValidDialogLoadIds = preferences.contains("2dialogsLoadOffsetId") || preferences.getBoolean("hasValidDialogLoadIds", false);
|
hasValidDialogLoadIds = preferences.contains("2dialogsLoadOffsetId") || preferences.getBoolean("hasValidDialogLoadIds", false);
|
||||||
isBot = preferences.getBoolean("isBot",false);
|
isBot = preferences.getBoolean("isBot",false);
|
||||||
|
official = preferences.getBoolean("official", false);
|
||||||
tonEncryptedData = preferences.getString("tonEncryptedData", null);
|
tonEncryptedData = preferences.getString("tonEncryptedData", null);
|
||||||
tonPublicKey = preferences.getString("tonPublicKey", null);
|
tonPublicKey = preferences.getString("tonPublicKey", null);
|
||||||
tonKeyName = preferences.getString("tonKeyName", "walletKey" + currentAccount);
|
tonKeyName = preferences.getString("tonKeyName", "walletKey" + currentAccount);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.telegram.tgnet;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
@ -52,8 +51,6 @@ import tw.nekomimi.nekogram.NekoConfig;
|
||||||
import tw.nekomimi.nekogram.parts.ProxySwitcher;
|
import tw.nekomimi.nekogram.parts.ProxySwitcher;
|
||||||
import tw.nekomimi.nekogram.utils.DnsFactory;
|
import tw.nekomimi.nekogram.utils.DnsFactory;
|
||||||
|
|
||||||
//import org.telegram.messenger.BuildConfig;
|
|
||||||
|
|
||||||
public class ConnectionsManager extends BaseController {
|
public class ConnectionsManager extends BaseController {
|
||||||
|
|
||||||
public final static int ConnectionTypeGeneric = 1;
|
public final static int ConnectionTypeGeneric = 1;
|
||||||
|
@ -171,21 +168,34 @@ public class ConnectionsManager extends BaseController {
|
||||||
systemLangCode = LocaleController.getSystemLocaleStringIso639().toLowerCase();
|
systemLangCode = LocaleController.getSystemLocaleStringIso639().toLowerCase();
|
||||||
langCode = LocaleController.getLocaleStringIso639().toLowerCase();
|
langCode = LocaleController.getLocaleStringIso639().toLowerCase();
|
||||||
deviceModel = Build.MANUFACTURER + Build.MODEL;
|
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;
|
systemVersion = "SDK " + Build.VERSION.SDK_INT;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
systemLangCode = "en";
|
systemLangCode = "en";
|
||||||
langCode = "";
|
langCode = "";
|
||||||
deviceModel = "Android unknown";
|
deviceModel = "Android unknown";
|
||||||
appVersion = "App version unknown";
|
|
||||||
systemVersion = "SDK " + Build.VERSION.SDK_INT;
|
systemVersion = "SDK " + Build.VERSION.SDK_INT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserConfig().loadConfig();
|
||||||
|
|
||||||
|
int version;
|
||||||
|
int appId;
|
||||||
|
String fingerprint;
|
||||||
|
if (getUserConfig().official || !getUserConfig().isClientActivated()) {
|
||||||
|
fingerprint = "49C1522548EBACD46CE322B6FD47F6092BB745D0F88082145CAF35E14DCC38E1";
|
||||||
|
version = BuildConfig.OFFICIAL_VERSION_CODE;
|
||||||
|
appId = BuildVars.OFFICAL_APP_ID;
|
||||||
|
appVersion = BuildConfig.OFFICIAL_VERSION + " (" + BuildConfig.OFFICIAL_VERSION_CODE * 10 + 9 + ")";
|
||||||
|
if (BuildVars.DEBUG_VERSION) {
|
||||||
|
appVersion += " beta";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fingerprint = AndroidUtilities.getCertificateSHA256Fingerprint();
|
||||||
|
version = BuildConfig.VERSION_CODE;
|
||||||
|
appId = BuildConfig.APP_ID;
|
||||||
|
appVersion = BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + ")";
|
||||||
|
}
|
||||||
|
|
||||||
if (systemLangCode.trim().length() == 0) {
|
if (systemLangCode.trim().length() == 0) {
|
||||||
systemLangCode = "en";
|
systemLangCode = "en";
|
||||||
}
|
}
|
||||||
|
@ -198,16 +208,13 @@ public class ConnectionsManager extends BaseController {
|
||||||
if (systemVersion.trim().length() == 0) {
|
if (systemVersion.trim().length() == 0) {
|
||||||
systemVersion = "SDK Unknown";
|
systemVersion = "SDK Unknown";
|
||||||
}
|
}
|
||||||
getUserConfig().loadConfig();
|
|
||||||
String pushString = SharedConfig.pushString;
|
String pushString = SharedConfig.pushString;
|
||||||
if (TextUtils.isEmpty(pushString) && !TextUtils.isEmpty(SharedConfig.pushStringStatus)) {
|
if (TextUtils.isEmpty(pushString) && !TextUtils.isEmpty(SharedConfig.pushStringStatus)) {
|
||||||
pushString = SharedConfig.pushStringStatus;
|
pushString = SharedConfig.pushStringStatus;
|
||||||
}
|
}
|
||||||
String fingerprint = AndroidUtilities.getCertificateSHA256Fingerprint();
|
|
||||||
|
|
||||||
int timezoneOffset = (TimeZone.getDefault().getRawOffset() + TimeZone.getDefault().getDSTSavings()) / 1000;
|
int timezoneOffset = (TimeZone.getDefault().getRawOffset() + TimeZone.getDefault().getDSTSavings()) / 1000;
|
||||||
|
init(version, TLRPC.LAYER, appId, deviceModel, systemVersion, appVersion, langCode, systemLangCode, configPath, FileLog.getNetworkLogPath(), pushString, fingerprint, timezoneOffset, getUserConfig().getClientUserId(), enablePushConnection);
|
||||||
init(BuildVars.BUILD_VERSION, TLRPC.LAYER, BuildConfig.APP_ID, deviceModel, systemVersion, appVersion, langCode, systemLangCode, configPath, FileLog.getNetworkLogPath(), pushString, fingerprint, timezoneOffset, getUserConfig().getClientUserId(), enablePushConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPushConnectionEnabled() {
|
public boolean isPushConnectionEnabled() {
|
||||||
|
|
|
@ -3439,7 +3439,13 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||||
UIUtil.runOnIoDispatcher(() -> {
|
UIUtil.runOnIoDispatcher(() -> {
|
||||||
String replaced;
|
String replaced;
|
||||||
if (useRegex) {
|
if (useRegex) {
|
||||||
replaced = ReUtil.replaceAll(finalText, originText, replaceText);
|
try {
|
||||||
|
replaced = ReUtil.replaceAll(finalText, originText, replaceText);
|
||||||
|
} catch (Exception e) {
|
||||||
|
UIUtil.runOnUIThread(progress::dismiss);
|
||||||
|
AlertUtil.showToast(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
replaced = StrUtil.replace(finalText, originText, replaceText);
|
replaced = StrUtil.replace(finalText, originText, replaceText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,6 @@ import org.telegram.ui.Components.LayoutHelper;
|
||||||
import org.telegram.ui.Components.ProxyDrawable;
|
import org.telegram.ui.Components.ProxyDrawable;
|
||||||
import org.telegram.ui.Components.RadialProgressView;
|
import org.telegram.ui.Components.RadialProgressView;
|
||||||
import org.telegram.ui.Components.SlideView;
|
import org.telegram.ui.Components.SlideView;
|
||||||
import org.telegram.ui.Components.VerticalPositionAutoAnimator;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
@ -810,12 +809,14 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
||||||
exportLoginTokenRequest.api_id = NekoXConfig.currentAppId();
|
exportLoginTokenRequest.api_id = NekoXConfig.currentAppId();
|
||||||
exportLoginTokenRequest.api_hash = NekoXConfig.currentAppHash();
|
exportLoginTokenRequest.api_hash = NekoXConfig.currentAppHash();
|
||||||
exportLoginTokenRequest.except_ids = new ArrayList<>();
|
exportLoginTokenRequest.except_ids = new ArrayList<>();
|
||||||
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
if (NekoXConfig.customApi == 0) {
|
||||||
UserConfig userConfig = UserConfig.getInstance(a);
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
||||||
if (!userConfig.isClientActivated()) {
|
UserConfig userConfig = UserConfig.getInstance(a);
|
||||||
continue;
|
if (!userConfig.isClientActivated()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
exportLoginTokenRequest.except_ids.add(a);
|
||||||
}
|
}
|
||||||
exportLoginTokenRequest.except_ids.add(a);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1551,6 +1552,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
|
||||||
ConnectionsManager.getInstance(currentAccount).setUserId(res.user.id);
|
ConnectionsManager.getInstance(currentAccount).setUserId(res.user.id);
|
||||||
UserConfig.getInstance(currentAccount).clearConfig();
|
UserConfig.getInstance(currentAccount).clearConfig();
|
||||||
MessagesController.getInstance(currentAccount).cleanup();
|
MessagesController.getInstance(currentAccount).cleanup();
|
||||||
|
UserConfig.getInstance(currentAccount).official = NekoXConfig.currentAppId() == BuildVars.OFFICAL_APP_ID;
|
||||||
UserConfig.getInstance(currentAccount).syncContacts = syncContacts;
|
UserConfig.getInstance(currentAccount).syncContacts = syncContacts;
|
||||||
UserConfig.getInstance(currentAccount).setCurrentUser(res.user);
|
UserConfig.getInstance(currentAccount).setCurrentUser(res.user);
|
||||||
UserConfig.getInstance(currentAccount).saveConfig(true);
|
UserConfig.getInstance(currentAccount).saveConfig(true);
|
||||||
|
|
|
@ -58,6 +58,10 @@ import java.util.ArrayList;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import kotlin.Unit;
|
||||||
|
import tw.nekomimi.nekogram.BottomBuilder;
|
||||||
|
import tw.nekomimi.nekogram.utils.AlertUtil;
|
||||||
|
|
||||||
public class SessionsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
public class SessionsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||||
|
|
||||||
private ListAdapter listAdapter;
|
private ListAdapter listAdapter;
|
||||||
|
@ -115,7 +119,7 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||||
TLRPC.TL_authorization newAuthorizationToOpen;
|
TLRPC.TL_authorization newAuthorizationToOpen;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView(Context context) {
|
public View createView(Context context) {
|
||||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||||
actionBar.setAllowOverlayTitle(true);
|
actionBar.setAllowOverlayTitle(true);
|
||||||
if (currentType == 0) {
|
if (currentType == 0) {
|
||||||
|
@ -288,18 +292,70 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
||||||
}
|
}
|
||||||
} else if (position >= otherSessionsStartRow && position < otherSessionsEndRow || position >= passwordSessionsStartRow && position < passwordSessionsEndRow) {
|
} else if (position == currentSessionRow || position >= otherSessionsStartRow && position < otherSessionsEndRow || position >= passwordSessionsStartRow && position < passwordSessionsEndRow) {
|
||||||
if (getParentActivity() == null) {
|
if (getParentActivity() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
||||||
final boolean[] param = new boolean[1];
|
|
||||||
String buttonText;
|
|
||||||
if (currentType == 0) {
|
if (currentType == 0) {
|
||||||
builder.setMessage(LocaleController.getString("TerminateSessionText", R.string.TerminateSessionText));
|
final TLRPC.TL_authorization authorization;
|
||||||
builder.setTitle(LocaleController.getString("AreYouSureSessionTitle", R.string.AreYouSureSessionTitle));
|
if (position == currentSessionRow) {
|
||||||
buttonText = LocaleController.getString("Terminate", R.string.Terminate);
|
authorization = currentSession;
|
||||||
|
} else if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
|
||||||
|
authorization = (TLRPC.TL_authorization) sessions.get(position - otherSessionsStartRow);
|
||||||
|
} else {
|
||||||
|
authorization = (TLRPC.TL_authorization) passwordSessions.get(position - passwordSessionsStartRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
BottomBuilder builder = new BottomBuilder(getParentActivity());
|
||||||
|
|
||||||
|
String title = authorization.app_name + " " + authorization.app_version + "\n";
|
||||||
|
title += authorization.device_model + ", " + authorization.system_version + "\n";
|
||||||
|
title += "Login: " + LocaleController.getInstance().chatFullDate.format(authorization.date_created * 1000L) + "\n";
|
||||||
|
title += "Active: " + LocaleController.getInstance().chatFullDate.format(authorization.date_active * 1000L) + "\n";
|
||||||
|
if (!authorization.official_app) {
|
||||||
|
title += "Unofficial application " + authorization.api_id + "\n";
|
||||||
|
}
|
||||||
|
title += authorization.ip + " - " + authorization.region + " " + authorization.country;
|
||||||
|
|
||||||
|
if (!authorization.current) {
|
||||||
|
builder.addTitle(LocaleController.getString("TerminateSessionText", R.string.TerminateSessionText), title);
|
||||||
|
builder.addItem(LocaleController.getString("Terminate", R.string.Terminate), R.drawable.baseline_delete_forever_24, true, __ -> {
|
||||||
|
TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
|
||||||
|
req.hash = authorization.hash;
|
||||||
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||||
|
if (error != null) {
|
||||||
|
AlertUtil.showToast(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sessions.remove(authorization);
|
||||||
|
passwordSessions.remove(authorization);
|
||||||
|
updateRows();
|
||||||
|
if (listAdapter != null) {
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
builder.addTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.addCancelItem();
|
||||||
|
|
||||||
|
String finalTitle = title;
|
||||||
|
builder.addItem(LocaleController.getString("Copy", R.string.Copy), R.drawable.baseline_content_copy_24, __ -> {
|
||||||
|
AlertUtil.copyAndAlert(finalTitle);
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.show();
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||||
|
final boolean[] param = new boolean[1];
|
||||||
|
String buttonText;
|
||||||
final TLRPC.TL_webAuthorization authorization = (TLRPC.TL_webAuthorization) sessions.get(position - otherSessionsStartRow);
|
final TLRPC.TL_webAuthorization authorization = (TLRPC.TL_webAuthorization) sessions.get(position - otherSessionsStartRow);
|
||||||
|
|
||||||
builder.setMessage(LocaleController.formatString("TerminateWebSessionText", R.string.TerminateWebSessionText, authorization.domain));
|
builder.setMessage(LocaleController.formatString("TerminateWebSessionText", R.string.TerminateWebSessionText, authorization.domain));
|
||||||
|
@ -331,41 +387,14 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||||
});
|
});
|
||||||
builder.setCustomViewOffset(16);
|
builder.setCustomViewOffset(16);
|
||||||
builder.setView(frameLayout1);
|
builder.setView(frameLayout1);
|
||||||
}
|
|
||||||
builder.setPositiveButton(buttonText, (dialogInterface, option) -> {
|
|
||||||
if (getParentActivity() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
|
|
||||||
progressDialog.setCanCacnel(false);
|
|
||||||
progressDialog.show();
|
|
||||||
|
|
||||||
if (currentType == 0) {
|
builder.setPositiveButton(buttonText, (dialogInterface, option) -> {
|
||||||
final TLRPC.TL_authorization authorization;
|
if (getParentActivity() == null) {
|
||||||
if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
|
return;
|
||||||
authorization = (TLRPC.TL_authorization) sessions.get(position - otherSessionsStartRow);
|
|
||||||
} else {
|
|
||||||
authorization = (TLRPC.TL_authorization) passwordSessions.get(position - passwordSessionsStartRow);
|
|
||||||
}
|
}
|
||||||
TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
|
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
|
||||||
req.hash = authorization.hash;
|
progressDialog.setCanCacnel(false);
|
||||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
progressDialog.show();
|
||||||
try {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
} catch (Exception e) {
|
|
||||||
FileLog.e(e);
|
|
||||||
}
|
|
||||||
if (error == null) {
|
|
||||||
sessions.remove(authorization);
|
|
||||||
passwordSessions.remove(authorization);
|
|
||||||
updateRows();
|
|
||||||
if (listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
final TLRPC.TL_webAuthorization authorization = (TLRPC.TL_webAuthorization) sessions.get(position - otherSessionsStartRow);
|
|
||||||
TLRPC.TL_account_resetWebAuthorization req = new TLRPC.TL_account_resetWebAuthorization();
|
TLRPC.TL_account_resetWebAuthorization req = new TLRPC.TL_account_resetWebAuthorization();
|
||||||
req.hash = authorization.hash;
|
req.hash = authorization.hash;
|
||||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||||
|
@ -385,48 +414,23 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||||
if (param[0]) {
|
if (param[0]) {
|
||||||
MessagesController.getInstance(currentAccount).blockPeer(authorization.bot_id);
|
MessagesController.getInstance(currentAccount).blockPeer(authorization.bot_id);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
showDialog(alertDialog);
|
||||||
|
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||||
|
if (button != null) {
|
||||||
|
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
}
|
||||||
AlertDialog alertDialog = builder.create();
|
|
||||||
showDialog(alertDialog);
|
if (newAuthorizationToOpen != null) {
|
||||||
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
AndroidUtilities.runOnUIThread(() -> undoView.showWithAction(0, UndoView.ACTION_QR_SESSION_ACCEPTED, newAuthorizationToOpen), 3000L);
|
||||||
if (button != null) {
|
|
||||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (currentType == 0) {
|
|
||||||
undoView = new UndoView(context) {
|
|
||||||
@Override
|
|
||||||
public void hide(boolean apply, int animated) {
|
|
||||||
if (!apply) {
|
|
||||||
TLRPC.TL_authorization authorization = (TLRPC.TL_authorization) getCurrentInfoObject();
|
|
||||||
TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
|
|
||||||
req.hash = authorization.hash;
|
|
||||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
||||||
if (error == null) {
|
|
||||||
sessions.remove(authorization);
|
|
||||||
passwordSessions.remove(authorization);
|
|
||||||
updateRows();
|
|
||||||
if (listAdapter != null) {
|
|
||||||
listAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
loadSessions(true);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
super.hide(apply, animated);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
frameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newAuthorizationToOpen != null) {
|
|
||||||
AndroidUtilities.runOnUIThread(() -> undoView.showWithAction(0, UndoView.ACTION_QR_SESSION_ACCEPTED, newAuthorizationToOpen), 3000L);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fragmentView;
|
return fragmentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,7 +582,7 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||||
int position = holder.getAdapterPosition();
|
int position = holder.getAdapterPosition();
|
||||||
return position == terminateAllSessionsRow || position == qrCodeRow || position >= otherSessionsStartRow && position < otherSessionsEndRow || position >= passwordSessionsStartRow && position < passwordSessionsEndRow;
|
return position == currentSessionRow || position == terminateAllSessionsRow || position == qrCodeRow || position >= otherSessionsStartRow && position < otherSessionsEndRow || position >= passwordSessionsStartRow && position < passwordSessionsEndRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -709,6 +713,7 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue