fix: scan qr login
This commit is contained in:
parent
9be44a4118
commit
3cda7c27b5
@ -3463,47 +3463,11 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
|
||||
}
|
||||
return;
|
||||
} else if (loginToken != null) {
|
||||
BottomBuilder builder = new BottomBuilder(this);
|
||||
builder.addTitle(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan), LocaleController.getString("QRLoginNotice", R.string.QRLoginNotice));
|
||||
builder.addItem(LocaleController.getString("QRLoginConfirm", R.string.QRLoginConfirm), R.drawable.baseline_security_24, true, (c) -> {
|
||||
AlertDialog progressDialog = new AlertDialog(this, 3);
|
||||
progressDialog.setCanCancel(false);
|
||||
progressDialog.show();
|
||||
byte[] token = Base64.decode(loginToken, Base64.URL_SAFE);
|
||||
TLRPC.TL_auth_acceptLoginToken req = new TLRPC.TL_auth_acceptLoginToken();
|
||||
req.token = token;
|
||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
if (response instanceof TLRPC.TL_authorization) {
|
||||
SessionsActivity fragment = new SessionsActivity(0);
|
||||
fragment.newAuthorizationToOpen = (TLRPC.TL_authorization) response;
|
||||
presentFragment(fragment, false, false);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
actionBarLayout.showLastFragment();
|
||||
rightActionBarLayout.showLastFragment();
|
||||
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||
} else {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
} else {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
final String text;
|
||||
if (error.text.equals("AUTH_TOKEN_EXCEPTION")) {
|
||||
text = LocaleController.getString("AccountAlreadyLoggedIn", R.string.AccountAlreadyLoggedIn);
|
||||
} else {
|
||||
text = LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text;
|
||||
}
|
||||
AlertUtil.showSimpleAlert(this, LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient), text);
|
||||
});
|
||||
}
|
||||
}));
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
builder.addCancelItem();
|
||||
builder.show();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(LaunchActivity.this);
|
||||
builder.setTitle(LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient));
|
||||
builder.setMessage(LocaleController.getString("AuthAnotherClientUrl", R.string.AuthAnotherClientUrl));
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
||||
showAlertDialog(builder);
|
||||
return;
|
||||
}
|
||||
final AlertDialog progressDialog = new AlertDialog(this, AlertDialog.ALERT_TYPE_SPINNER);
|
||||
|
@ -33,8 +33,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
@ -54,8 +52,6 @@ import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
@ -84,8 +80,6 @@ import org.telegram.ui.Components.voip.CellFlickerDrawable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import tw.nekomimi.nekogram.utils.ProxyUtil;
|
||||
|
||||
public class SessionsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private ListAdapter listAdapter;
|
||||
@ -189,35 +183,6 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
});
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
ActionBarMenuItem item = menu.addItem(0, R.drawable.msg_qrcode);
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == 0) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
if (getParentActivity().checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
||||
getParentActivity().requestPermissions(new String[]{Manifest.permission.CAMERA}, 22);
|
||||
return;
|
||||
}
|
||||
}
|
||||
CameraScanActivity.showAsSheet(SessionsActivity.this, false, CameraScanActivity.TYPE_QR_LOGIN, new CameraScanActivity.CameraScanActivityDelegate() {
|
||||
@Override
|
||||
public void didFindQr(String text) {
|
||||
ProxyUtil.showLinkAlert(getParentActivity(), text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processQr(String text, Runnable onLoadEnd) {
|
||||
onLoadEnd.run();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
listAdapter = new ListAdapter(context);
|
||||
|
||||
fragmentView = new FrameLayout(context);
|
||||
@ -744,7 +709,7 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||
ttlRow = -1;
|
||||
ttlDivideRow = -1;
|
||||
|
||||
if (currentType == 0 && getMessagesController().qrLoginCamera) {
|
||||
if (currentType == 0) {
|
||||
qrCodeRow = rowCount++;
|
||||
qrCodeDividerRow = rowCount++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user