🍭 v1.8.0版本的 MD5 值为:0229079aa4aa60e49c57f3c4c415ae2e
以下内容为反编译后的 QrScanActivity.java 源代码,内容仅作参考
package im.pkahdfyclb.ui.hui.discovery;
import android.content.Context;
import android.content.Intent;
import android.hardware.Camera;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Base64;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.URLUtil;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.king.zxing.CaptureHelper;
import com.king.zxing.OnCaptureCallback;
import com.king.zxing.ViewfinderView;
import com.king.zxing.util.CodeUtils;
import im.pkahdfyclb.messenger.AndroidUtilities;
import im.pkahdfyclb.messenger.FileLog;
import im.pkahdfyclb.messenger.LocaleController;
import im.pkahdfyclb.messenger.MessagesController;
import im.pkahdfyclb.messenger.R;
import im.pkahdfyclb.messenger.SharedConfig;
import im.pkahdfyclb.messenger.browser.Browser;
import im.pkahdfyclb.tgnet.RequestDelegate;
import im.pkahdfyclb.tgnet.TLObject;
import im.pkahdfyclb.tgnet.TLRPC;
import im.pkahdfyclb.ui.ProfileActivity;
import im.pkahdfyclb.ui.WebviewActivity;
import im.pkahdfyclb.ui.actionbar.BaseFragment;
import im.pkahdfyclb.ui.actionbar.Theme;
import im.pkahdfyclb.ui.components.toast.ToastUtils;
import im.pkahdfyclb.ui.hui.chats.NewProfileActivity;
import im.pkahdfyclb.ui.hui.contacts.AddContactsInfoActivity;
import im.pkahdfyclb.ui.hui.login.PcScanCodeLoginActivity;
import im.pkahdfyclb.ui.hui.mine.QrCodeActivity;
import im.pkahdfyclb.ui.hviews.MryTextView;
public class QrScanActivity extends BaseFragment implements OnCaptureCallback {
private static final int GALLERY_REQUEST_CODE = 2;
private LinearLayout flashLayout;
private LinearLayout galleryLayout;
private ImageView ivBackView;
private ImageView ivFlash;
private CaptureHelper mCaptureHelper;
private Context mContext;
private LinearLayout qrLayout;
private SurfaceView surfaceView;
private TextView tvFlash;
private ViewfinderView viewfinderView;
@Override
public boolean onFragmentCreate() {
return super.onFragmentCreate();
}
@Override
public void onResume() {
super.onResume();
this.mCaptureHelper.onResume();
}
@Override
public void onPause() {
super.onPause();
this.mCaptureHelper.onPause();
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
this.mCaptureHelper.onDestroy();
}
private void requestCameraPermissions() {
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission("android.permission.CAMERA") != 0) {
try {
getParentActivity().requestPermissions(new String[]{"android.permission.CAMERA"}, 20);
} catch (Throwable th) {
}
}
}
@Override
public View createView(Context context) {
this.mContext = context;
requestCameraPermissions();
this.actionBar.setAddToContainer(false);
this.fragmentView = LayoutInflater.from(this.mContext).inflate(R.layout.activity_qr_code_scan_layout, (ViewGroup) null, false);
this.fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view, MotionEvent motionEvent) {
return QrScanActivity.this.lambda$createView$0$QrScanActivity(view, motionEvent);
}
});
initView();
return this.fragmentView;
}
public boolean lambda$createView$0$QrScanActivity(View v, MotionEvent event) {
this.mCaptureHelper.onTouchEvent(event);
return true;
}
private void initView() {
this.surfaceView = (SurfaceView) this.fragmentView.findViewById(R.id.surfaceView);
ViewfinderView viewfinderView = (ViewfinderView) this.fragmentView.findViewById(R.id.viewfinderView);
this.viewfinderView = viewfinderView;
viewfinderView.setLabelText(LocaleController.getString("PutQrCodeInbox", R.string.PutQrCodeInbox));
this.qrLayout = (LinearLayout) this.fragmentView.findViewById(R.id.qrLayout);
this.galleryLayout = (LinearLayout) this.fragmentView.findViewById(R.id.galleryLayout);
this.flashLayout = (LinearLayout) this.fragmentView.findViewById(R.id.flashLayout);
this.ivFlash = (ImageView) this.fragmentView.findViewById(R.id.flash_switch);
this.tvFlash = (TextView) this.fragmentView.findViewById(R.id.tvFlash);
this.ivFlash.setImageDrawable(Theme.createSimpleSelectorDrawable(getParentActivity(), R.mipmap.icon_scan_flash, Theme.getColor(Theme.key_windowBackgroundWhite), Theme.getColor(Theme.key_windowBackgroundWhiteBlueIcon)));
this.tvFlash.setTextColor(Theme.createColorStateList(Theme.getColor(Theme.key_windowBackgroundWhite), Theme.getColor(Theme.key_windowBackgroundWhiteBlueIcon)));
this.tvFlash.setText(LocaleController.getString("FlashOn", R.string.FlashOn));
ImageView imageView = (ImageView) this.fragmentView.findViewById(R.id.ivBack);
this.ivBackView = imageView;
ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) imageView.getLayoutParams();
layoutParams.setMargins(0, AndroidUtilities.statusBarHeight, 0, 0);
this.ivBackView.setLayoutParams(layoutParams);
this.ivBackView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
QrScanActivity.this.lambda$initView$1$QrScanActivity(view);
}
});
MryTextView tvTitle = (MryTextView) this.fragmentView.findViewById(R.id.tv_title);
ConstraintLayout.LayoutParams layoutParams1 = (ConstraintLayout.LayoutParams) tvTitle.getLayoutParams();
layoutParams1.setMargins(0, AndroidUtilities.statusBarHeight, 0, 0);
tvTitle.setLayoutParams(layoutParams1);
CaptureHelper captureHelper = new CaptureHelper(getParentActivity(), this.surfaceView, this.viewfinderView, (View) null);
this.mCaptureHelper = captureHelper;
captureHelper.setOnCaptureCallback(this);
this.mCaptureHelper.vibrate(true).playBeep(true).fullScreenScan(true).supportVerticalCode(false).supportLuminanceInvert(true).continuousScan(false);
this.mCaptureHelper.onCreate();
this.flashLayout.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
QrScanActivity.this.clickFlash(view);
}
});
this.galleryLayout.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
QrScanActivity.this.goGallery(view);
}
});
this.qrLayout.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
QrScanActivity.this.goMyQrCode(view);
}
});
}
public void lambda$initView$1$QrScanActivity(View v) {
finishFragment();
}
private void offFlash() {
Camera camera = this.mCaptureHelper.getCameraManager().getOpenCamera().getCamera();
Camera.Parameters parameters = camera.getParameters();
parameters.setFlashMode("off");
camera.setParameters(parameters);
}
private void openFlash() {
Camera camera = this.mCaptureHelper.getCameraManager().getOpenCamera().getCamera();
Camera.Parameters parameters = camera.getParameters();
parameters.setFlashMode("torch");
camera.setParameters(parameters);
}
public void clickFlash(View v) {
if (v.isSelected()) {
offFlash();
v.setSelected(false);
this.tvFlash.setSelected(false);
this.tvFlash.setText(LocaleController.getString("FlashOn", R.string.FlashOn));
return;
}
openFlash();
v.setSelected(true);
this.tvFlash.setSelected(true);
this.tvFlash.setText(LocaleController.getString("FlashOff", R.string.FlashOff));
}
public void goGallery(View v) {
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
getParentActivity().requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 4);
return;
}
Intent intent = new Intent();
intent.setAction("android.intent.action.PICK");
intent.setType("image/*");
startActivityForResult(intent, 2);
}
public void goMyQrCode(View v) {
QrCodeActivity qrCodeActivity = new QrCodeActivity(getUserConfig().getClientUserId());
presentFragment(qrCodeActivity);
}
@Override
public boolean onBackPressed() {
finishFragment(false);
return false;
}
private void getUserInfo(TLRPC.User user) {
TLRPC.TL_users_getFullUser req = new TLRPC.TL_users_getFullUser();
req.id = getMessagesController().getInputUser(user);
int reqId = getConnectionsManager().sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
QrScanActivity.this.lambda$getUserInfo$3$QrScanActivity(tLObject, tL_error);
}
});
getConnectionsManager().bindRequestToGuid(reqId, this.classGuid);
}
public void lambda$getUserInfo$3$QrScanActivity(final TLObject response, TLRPC.TL_error error) {
if (error == null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
QrScanActivity.this.lambda$null$2$QrScanActivity(response);
}
});
} else {
ToastUtils.show((int) R.string.NoUsernameFound);
}
}
public void lambda$null$2$QrScanActivity(TLObject response) {
TLRPC.UserFull userFull = (TLRPC.UserFull) response;
getMessagesController().putUser(userFull.user, false);
if (userFull.user == null) {
return;
}
if (userFull.user.self || userFull.user.contact) {
Bundle bundle = new Bundle();
bundle.putInt("user_id", userFull.user.id);
presentFragment(new NewProfileActivity(bundle), true);
} else {
Bundle bundle2 = new Bundle();
bundle2.putInt("from_type", 1);
presentFragment(new AddContactsInfoActivity(bundle2, userFull.user), true);
}
}
private void getChatInfo(TLRPC.Chat chat) {
TLRPC.TL_channels_getFullChannel req = new TLRPC.TL_channels_getFullChannel();
req.channel = MessagesController.getInputChannel(chat);
int reqId = getConnectionsManager().sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
QrScanActivity.this.lambda$getChatInfo$5$QrScanActivity(tLObject, tL_error);
}
});
getConnectionsManager().bindRequestToGuid(reqId, this.classGuid);
}
public void lambda$getChatInfo$5$QrScanActivity(final TLObject response, TLRPC.TL_error error) {
if (error == null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
QrScanActivity.this.lambda$null$4$QrScanActivity(response);
}
});
}
}
public void lambda$null$4$QrScanActivity(TLObject response) {
TLRPC.TL_messages_chatFull res = (TLRPC.TL_messages_chatFull) response;
getMessagesController().putChats(res.chats, false);
Bundle bundle = new Bundle();
bundle.putInt("chat_id", res.full_chat.id);
ProfileActivity profileActivity = new ProfileActivity(bundle);
profileActivity.setChatInfo(res.full_chat);
presentFragment(profileActivity, true);
}
public void parseQRCodeResult(String result) {
String result2;
String preStr = getMessagesController().sharePrefix + "&Key=";
if (result.startsWith(preStr) || result.startsWith("https://lovechat323.com") || result.startsWith("http://lovechat323.com")) {
if (result.startsWith(preStr)) {
byte[] decode = Base64.decode(result.substring(preStr.length()).replace("%3D", "="), 0);
String ret = new String(decode);
String[] split = ret.split("#");
String pUid = split[0].split("=")[1];
String hash = split[1].split("=")[1];
if (ret.contains("Uname")) {
String uName = split[2].split("=")[1];
getMessagesController().openByUserName(uName, (BaseFragment) this, 1, true);
return;
}
TLRPC.User user = new TLRPC.TL_user();
try {
user.id = Integer.parseInt(pUid);
user.access_hash = Long.parseLong(hash);
getUserInfo(user);
return;
} catch (NumberFormatException e) {
FileLog.e("parse qr code err:" + e);
return;
}
}
if (result.startsWith("http://lovechat323.com")) {
result2 = result.substring("http://lovechat323.com".length());
} else {
result2 = result.substring("https://lovechat323.com".length());
}
boolean isGroup = result2.startsWith("/g/");
byte[] decode2 = Base64.decode(result2.substring(result2.lastIndexOf("/") + 1), 0);
String ret2 = new String(decode2);
if (isGroup) {
getMessagesController().openByUserName(ret2.substring(ret2.lastIndexOf("/") + 1), (BaseFragment) this, 1, true);
return;
}
String[] split2 = ret2.substring(0, ret2.length() - 4).split("&", 2);
String uid = split2[0];
String uhash = split2[1];
TLRPC.User user2 = new TLRPC.TL_user();
try {
user2.id = Integer.parseInt(uid);
user2.access_hash = Long.parseLong(uhash);
getUserInfo(user2);
return;
} catch (NumberFormatException e2) {
FileLog.e("parse qr code err:" + e2);
return;
}
}
if (result.startsWith("https://lovechat323.com/authtoken/")) {
String strToken = result.substring(result.indexOf(" "));
String strUntilDate = result.substring("https://lovechat323.com/authtoken/".length(), result.indexOf(" "));
presentFragment(new PcScanCodeLoginActivity(strToken, strUntilDate), true);
} else {
if (URLUtil.isNetworkUrl(result)) {
if (SharedConfig.customTabs) {
presentFragment(new WebviewActivity(result, (String) null), true);
return;
} else {
Browser.openUrl(getParentActivity(), result);
return;
}
}
presentFragment(new QrScanResultActivity(result), true);
}
}
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
Uri uri;
if (resultCode == -1 && requestCode != 20 && requestCode == 2 && (uri = data.getData()) != null) {
String path = AndroidUtilities.getPath(uri);
String result = CodeUtils.parseQRCode(path);
if (result != null) {
parseQRCodeResult(result);
} else {
ToastUtils.show((int) R.string.NoQRCode);
}
}
}
@Override
public boolean onResultCallback(String result) {
parseQRCodeResult(result);
return true;
}
}