酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319
以下内容为反编译后的 QRCodeScanFragment.java 源代码,内容仅作参考
package com.kugou.android.qrcodescan;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Base64;
import android.view.LayoutInflater;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Space;
import android.widget.TextView;
import com.google.zxing.Result;
import com.huawei.hms.framework.common.ContainerUtils;
import com.kugou.android.app.NavigationUtils;
import com.kugou.android.app.flexowebview.KGFelxoWebFragment;
import com.kugou.android.app.msgchat.image.send.allalbum.AlbumMainActivity;
import com.kugou.android.app.msgchat.skin.KGTransPressLinearLayout;
import com.kugou.android.common.delegate.DelegateFragment;
import com.kugou.android.lite.R;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.b.a;
import com.kugou.common.base.AbsFrameworkFragment;
import com.kugou.common.base.e.c;
import com.kugou.common.dialog8.e;
import com.kugou.common.dialog8.f;
import com.kugou.common.dialog8.i;
import com.kugou.common.event.o;
import com.kugou.common.permission.DenyAction;
import com.kugou.common.permission.GrantAction;
import com.kugou.common.permission.KGCommonRational;
import com.kugou.common.permission.KGPermission;
import com.kugou.common.permission.Permission;
import com.kugou.common.skinpro.utils.b;
import com.kugou.common.utils.al;
import com.kugou.common.utils.as;
import com.kugou.common.utils.br;
import com.kugou.common.utils.bv;
import com.kugou.framework.service.util.BackgroundServiceUtil;
import com.kugou.framework.statistics.easytrace.task.d;
import com.tencent.open.SocialConstants;
import de.greenrobot.event.EventBus;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.codec.net.StringEncodings;
@c(a = 245701912)
public class QRCodeScanFragment extends DelegateFragment implements SurfaceHolder.Callback, View.OnClickListener {
private static final String f38003a = QRCodeScanFragment.class.getSimpleName();
private static final String[] m = {Permission.CAMERA};
private com.kugou.android.qrcodescan.a.c f38004b;
private boolean f38005c;
private RelativeLayout f38006d;
private RelativeLayout f38007e;
private KGTransPressLinearLayout f;
private KGTransPressLinearLayout g;
private SurfaceView l;
private int h = 0;
private int i = 0;
private int j = 0;
private int k = 0;
private boolean n = false;
private boolean o = false;
private BroadcastReceiver p = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if ("com.kugou.android.mediatransfer.wifi_connect_success".equalsIgnoreCase(action)) {
QRCodeScanFragment.this.finish();
} else if ("com.kugou.android.mediatransfer.wifi_connect_fail".equalsIgnoreCase(action)) {
QRCodeScanFragment.this.showToast(R.string.blv);
QRCodeScanFragment.this.finish();
}
}
};
@Override
public boolean hasNavigationBar() {
return false;
}
@Override
public boolean hasPlayingBar() {
return false;
}
@Override
public boolean onLayerChange() {
return false;
}
@Override
public boolean statusBarLightMode() {
return true;
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
}
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
return layoutInflater.inflate(R.layout.adf, viewGroup, false);
}
@Override
public void onViewCreated(View view, Bundle bundle) {
super.onViewCreated(view, bundle);
getActivity().getWindow().addFlags(128);
enableTitleDelegate();
initDelegates();
getTitleDelegate().o(0);
getTitleDelegate().a("扫一扫");
getTitleDelegate().f(false);
getTitleDelegate().n(false);
getTitleDelegate().F().setTextColor(-1);
getTitleDelegate().O().setColorFilter(-1);
b.a(getTitleDelegate().E(), getTitleDelegate().F(), getTitleDelegate().O());
com.kugou.common.z.c.a(KGCommonApplication.getContext());
this.f38006d = (RelativeLayout) findViewById(R.id.f4h);
br.a((Space) findViewById(R.id.f4k), getActivity());
this.f38007e = (RelativeLayout) findViewById(R.id.f4j);
this.f = (KGTransPressLinearLayout) findViewById(R.id.f4l);
this.g = (KGTransPressLinearLayout) findViewById(R.id.f4m);
this.l = (SurfaceView) findViewById(R.id.f4i);
this.f.setOnClickListener(this);
this.g.setOnClickListener(this);
ImageView imageView = (ImageView) findViewById(R.id.kd);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 0.0f, 0, 0.0f, 2, 0.0f, 2, 0.98f);
translateAnimation.setDuration(1500L);
translateAnimation.setRepeatCount(-1);
translateAnimation.setRepeatMode(2);
translateAnimation.setInterpolator(new LinearInterpolator());
imageView.setAnimation(translateAnimation);
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.kugou.android.mediatransfer.wifi_connect_success");
intentFilter.addAction("com.kugou.android.mediatransfer.wifi_connect_fail");
a.b(this.p, intentFilter);
}
@Override
public void onResume() {
super.onResume();
if (as.f54365e) {
as.b(f38003a, " qr onResume");
}
SurfaceView surfaceView = this.l;
if (surfaceView == null) {
return;
}
SurfaceHolder holder = surfaceView.getHolder();
if (this.f38005c) {
k();
} else {
holder.addCallback(this);
holder.setType(3);
}
}
@Override
public void onPause() {
super.onPause();
if (as.f54365e) {
as.b(f38003a, " qr onPause");
}
com.kugou.android.qrcodescan.a.c cVar = this.f38004b;
if (cVar != null) {
cVar.a();
this.f38004b = null;
}
com.kugou.common.z.c.a().c();
}
@Override
public void onFragmentPause() {
super.onFragmentPause();
if (as.f54365e) {
as.b(f38003a, " qr onFragmentPause");
}
com.kugou.common.z.c.a().e();
}
@Override
public void onFragmentResumeAfterPause() {
super.onFragmentResumeAfterPause();
if (as.f54365e) {
as.b(f38003a, " qr onFragmentResumeAfterPause");
}
com.kugou.common.z.c.a().d();
}
@Override
public void onDestroy() {
if (!this.f38005c) {
SurfaceView surfaceView = this.l;
if (surfaceView == null) {
return;
} else {
surfaceView.getHolder().removeCallback(this);
}
}
super.onDestroy();
a.b(this.p);
}
public void h() {
com.kugou.android.qrcodescan.a.c cVar = this.f38004b;
if (cVar != null) {
cVar.a();
this.f38004b = null;
}
com.kugou.common.z.c.a().c();
SurfaceView surfaceView = this.l;
if (surfaceView == null) {
return;
}
try {
com.kugou.common.z.c.a().a(surfaceView.getHolder());
Point b2 = com.kugou.common.z.c.a().b();
int i = b2.y;
int i2 = b2.x;
int left = (this.f38007e.getLeft() * i) / this.f38006d.getWidth();
int top = (this.f38007e.getTop() * i2) / this.f38006d.getHeight();
int width = (this.f38007e.getWidth() * i) / this.f38006d.getWidth();
int height = (this.f38007e.getHeight() * i2) / this.f38006d.getHeight();
a(left);
b(top);
c(width);
d(height);
if (this.f38004b == null) {
this.f38004b = new com.kugou.android.qrcodescan.a.c(this);
}
} catch (Exception unused) {
a_("打开相机失败");
}
}
public void g() {
Intent intent = new Intent();
intent.setClass(getActivity(), AlbumMainActivity.class);
intent.putExtra("confirm_text", "确定");
intent.putExtra("is_hide_raw_button", true);
intent.putExtra("select_mode", 1);
startActivityForResult(intent, 116);
}
public com.kugou.android.qrcodescan.a.c a() {
return this.f38004b;
}
public void a(String str) {
if (as.f54365e) {
as.d(f38003a, "handle decode : " + str);
}
if (TextUtils.isEmpty(str)) {
a(500L);
return;
}
if (str.startsWith("kugouscan://")) {
if (!str.contains(ContainerUtils.FIELD_DELIMITER)) {
b();
a(500L);
return;
}
String str2 = str.split(ContainerUtils.FIELD_DELIMITER)[1];
if (str2 != null && !TextUtils.isEmpty(str2)) {
try {
String a2 = com.kugou.framework.mymusic.a.a.a.a.a(Base64.decode(str2.substring(4).replace("\n", ""), 0), StringEncodings.UTF8, "ilovekugou201800", "ilovekugou201800");
if (a2 != null && !TextUtils.isEmpty(a2)) {
Bundle bundle = new Bundle();
bundle.putLong("guest_user_id", Long.parseLong(a2));
bundle.putString(SocialConstants.PARAM_SOURCE, "首页+号/扫一扫");
NavigationUtils.c(this, bundle);
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20202, "click").a("tab", "1").a("type", "2"));
} else {
b();
}
} catch (Exception e2) {
a(500L);
if (as.f54365e) {
as.d(f38003a, "解密失败 : " + str);
}
b();
e2.printStackTrace();
}
} else {
b();
}
} else if (str.startsWith("http://m.kugou.com/pc_download/index.php")) {
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20202, "click").a("tab", "1").a("type", "5"));
com.kugou.common.d.b.a(KGCommonApplication.getContext()).c(com.kugou.common.d.a.TRANSFER);
com.kugou.framework.service.ipc.a.m.c.a();
if (!com.kugou.common.module.mediatransfer.b.a(str)) {
a(500L);
}
} else if (str.contains("lgk=") && (str.contains(".kugou.com") || str.contains(".kglink.cn"))) {
try {
String substring = str.split("\\?")[1].substring(4);
if (substring != null && !TextUtils.isEmpty(substring)) {
long parseLong = Long.parseLong(substring);
if (parseLong <= 0) {
return;
}
Bundle bundle2 = new Bundle();
bundle2.putLong("guest_user_id", parseLong);
bundle2.putString(SocialConstants.PARAM_SOURCE, "首页+号/扫一扫");
NavigationUtils.c(this, bundle2);
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20202, "click").a("tab", "1").a("type", "2"));
}
} catch (Exception e3) {
a(500L);
if (as.f54365e) {
as.d(f38003a, "解密失败 : " + str);
}
b();
e3.printStackTrace();
}
} else if (str.contains("\"type\":\"dlna\"")) {
if (com.kugou.common.module.dlna.a.a(str, true) != null) {
com.kugou.android.app.player.domain.c.b.a();
NavigationUtils.g((AbsFrameworkFragment) this);
Intent intent = new Intent("com.kugou.android.action.qrdlna_result");
intent.putExtra("key_kgpc_qrcode_json", str);
intent.putExtra("key_kgpc_qrcode_compat", true);
a.a(intent, true);
EventBus.getDefault().post(new o.a());
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20202, "click").a("tab", "1").a("type", "4"));
return;
}
a(500L);
} else if (NavigationUtils.a((AbsFrameworkFragment) this, str, "扫一扫", true)) {
ao_();
return;
} else {
a(NavigationUtils.c(str), true);
BackgroundServiceUtil.trace(new d(aN_(), com.kugou.framework.statistics.easytrace.a.akY).setIvar1(String.valueOf(2)));
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20202, "click").a("tab", "1").a("type", "1"));
}
ao_();
}
public void b() {
ao_();
bv.a((Context) aN_(), "未发现二维码");
a(700L);
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20202, "click").a("tab", "0"));
}
private void a(String str, boolean z) {
Bundle bundle = new Bundle();
bundle.putString("web_url", str);
if (z) {
replaceFragment(KGFelxoWebFragment.class, bundle);
} else {
startFragment(KGFelxoWebFragment.class, bundle);
}
}
public void a(long j) {
com.kugou.android.qrcodescan.a.c cVar = this.f38004b;
if (cVar != null) {
cVar.sendEmptyMessageDelayed(R.id.ap3, j);
}
}
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
if (surfaceHolder == null && as.f54365e) {
as.d(f38003a, "*** WARNING *** surfaceCreated() gave us a null surface!");
}
if (this.f38005c) {
return;
}
this.f38005c = true;
k();
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
this.f38005c = false;
}
public int c() {
return this.h;
}
public void a(int i) {
this.h = i;
}
public int d() {
return this.i;
}
public void b(int i) {
this.i = i;
}
public int e() {
return this.j;
}
public void c(int i) {
this.j = i;
}
public int f() {
return this.k;
}
public void d(int i) {
this.k = i;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.f4l:
if (!com.kugou.common.environment.a.u()) {
NavigationUtils.startLoginFragment(this);
return;
}
Bundle bundle = new Bundle();
bundle.putString("fromFo", "扫一扫内二维码");
startFragment(UserQRCodeFragment.class, bundle);
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20203, "click"));
return;
case R.id.f4m:
KGPermission.with(getActivity()).runtime().permission(Permission.Group.STORAGE).rationale(new KGCommonRational.Builder(getActivity()).setTitleResId(R.string.axw).setContentResId(R.string.awv).setLocationResId(R.string.axi).build()).onDenied(new DenyAction<List<String>>() {
@Override
public void onAction(List<String> list) {
}
}).onGranted(new GrantAction<List<String>>() {
@Override
public void onTokenAction(String str, List<String> list) {
QRCodeScanFragment.this.g();
com.kugou.common.statistics.e.a.a(new com.kugou.common.statistics.easytrace.task.b(20206, "click"));
}
}).start();
return;
default:
return;
}
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (intent != null && i2 == 22) {
D_();
List list = (List) intent.getSerializableExtra("key_send_multi_images");
if (com.kugou.ktv.framework.common.b.a.a((Collection) list)) {
return;
}
Iterator it = list.iterator();
while (it.hasNext()) {
Result c2 = al.c(((com.kugou.android.app.msgchat.image.b.c) it.next()).b());
if (c2 != null && c2.getText() != null && !TextUtils.isEmpty(c2.getText())) {
a(c2.getText());
} else {
b();
}
}
}
}
private void i() {
KGPermission.with(this).runtime().permission(m).rationale(new KGCommonRational.Builder(getActivity()).setTitleResId(R.string.axq).setContentResId(R.string.awu).build()).onDenied(new DenyAction<List<String>>() {
@Override
public void onAction(List<String> list) {
QRCodeScanFragment.this.n = false;
if (Build.VERSION.SDK_INT != 21 && Build.VERSION.SDK_INT != 22) {
QRCodeScanFragment.this.j();
} else {
QRCodeScanFragment.this.a_("没有相机权限或者相机被其他程序占用");
}
}
}).onGranted(new GrantAction<List<String>>() {
@Override
public void onTokenAction(String str, List<String> list) {
QRCodeScanFragment.this.n = true;
QRCodeScanFragment.this.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
QRCodeScanFragment.this.h();
}
});
}
}).start();
}
public void j() {
View inflate = LayoutInflater.from(aN_()).inflate(R.layout.hc, (ViewGroup) null);
((TextView) inflate.findViewById(R.id.c85)).setText("酷狗概念版需要获取相机权限\n请在【设置-应用-酷狗概念版-权限】中开启权限,以正常使用酷狗概念版");
f fVar = new f(aN_());
fVar.setTitle("权限申请");
fVar.setBodyView(inflate);
fVar.setPositiveHint("去设置");
fVar.setNegativeHint("我知道了");
fVar.setOnDialogClickListener(new e() {
@Override
public void onNegativeClick() {
}
@Override
public void onOptionClick(i iVar) {
}
@Override
public void onPositiveClick() {
KGPermission.with(QRCodeScanFragment.this.aN_()).runtime().setting().start();
}
});
fVar.setButtonMode(2);
fVar.setCanceledOnTouchOutside(false);
fVar.setCancelable(false);
fVar.show();
}
private void k() {
if (this.n) {
h();
} else {
if (this.o) {
return;
}
i();
this.o = true;
}
}
}