BBM Mod v2.11.0.18版本的 MD5 值为:703226e1fbeffec890786daa2e91b856

以下内容为反编译后的 CaptureBarcodeActivity.java 源代码,内容仅作参考


package com.bbken.ui.activities;

import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bbken.Alaska;
import com.bbken.C0003R;
import com.bbken.ui.AvatarView;
import com.google.zxing.client.android.ViewfinderView;
import com.mod.dp.CircleDrawable;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;

public final class CaptureBarcodeActivity extends com.bbken.bali.ui.main.a.e implements SurfaceHolder.Callback, com.bbken.util.g.a {
    private static final String x = CaptureBarcodeActivity.class.getSimpleName();
    private static final String[] y = {"http://zxing.appspot.com/scan", "zxing://scan/"};
    private com.bbken.util.g.b A;
    private com.google.zxing.n B;
    private boolean C;
    private String D;
    private boolean E;
    private Collection<com.google.zxing.a> F;
    private String G;
    private boolean H;
    private com.bbken.ui.f.h I;
    private ImageView M;
    private TextView N;
    private TextView O;
    private TextView P;
    private AvatarView Q;
    private TextView R;
    private TextView S;
    private String T;
    private int U;
    private String V;
    public ViewfinderView n;
    public com.google.zxing.n o;
    public int p;
    public String q;
    public com.google.zxing.client.android.c.c t;
    public com.google.zxing.client.android.p u;
    String v;
    private com.google.zxing.client.android.a.e z;
    private final com.bbken.d.a J = Alaska.h();
    private final com.bbken.f K = Alaska.f();
    private final com.bbken.h.ar L = Alaska.i();
    private final com.bbken.util.dv<String> W = new com.bbken.util.dv<>("");
    private final com.bbken.util.dv<String> X = new com.bbken.util.dv<>("");
    private final com.bbken.util.dv<String> Y = new com.bbken.util.dv<>("");
    private final com.bbken.util.dv<String> Z = new com.bbken.util.dv<>("");
    protected final com.bbken.l.a<String> w = new aw(this);
    private final com.bbken.l.u aa = new ax(this);
    private final com.bbken.l.k ab = new ay(this);
    private final com.bbken.l.k ac = new az(this);

    public static boolean e(CaptureBarcodeActivity captureBarcodeActivity) {
        return captureBarcodeActivity.U == 1000;
    }

    public static String g() {
        String str;
        String str2 = "";
        int i = 0;
        while (true) {
            int i2 = i;
            String str3 = str2;
            if (i2 >= 4) {
                return str3;
            }
            int random = (int) ((Math.random() * 240.0d) + 16.0d);
            if (random == 0) {
                str = "0";
            } else {
                str = "";
                while (random > 0) {
                    str = "0123456789ABCDEF".charAt(random % 16) + str;
                    random /= 16;
                }
            }
            str2 = str3 + str;
            i = i2 + 1;
        }
    }

    public static boolean g(CaptureBarcodeActivity captureBarcodeActivity) {
        return captureBarcodeActivity.U == 1001;
    }

    public static void h(CaptureBarcodeActivity captureBarcodeActivity) {
        if (com.bbken.util.ff.b(captureBarcodeActivity.w.f())) {
            captureBarcodeActivity.i();
        } else {
            captureBarcodeActivity.N.setText(captureBarcodeActivity.w.f().toUpperCase(Locale.US));
        }
    }

    @Override
    public final Handler e() {
        return this.A;
    }

    @Override
    public final com.google.zxing.client.android.a.e f() {
        return this.z;
    }

    public boolean h() {
        return this.U == 10022;
    }

    public CaptureBarcodeActivity() {
        a(new com.bbken.ui.gm());
        a(new com.bbken.ui.voice.a());
    }

    @Override
    public final void onCreate(Bundle bundle) {
        boolean z;
        super.onCreate(bundle);
        setContentView(C0003R.layout.activity_capture_barcode);
        this.C = false;
        this.t = new com.google.zxing.client.android.c.c(this);
        this.t.a();
        this.u = new com.google.zxing.client.android.p(this);
        this.H = com.bbken.util.fx.b((Context) this);
        PreferenceManager.setDefaultValues(this, C0003R.xml.preferences, false);
        if (!this.H) {
            View findViewById = findViewById(C0003R.id.upper_frame);
            View findViewById2 = findViewById(C0003R.id.no_cam_textview);
            findViewById.setVisibility(8);
            findViewById2.setVisibility(0);
        }
        if (getIntent().getFlags() == 65536) {
            overridePendingTransition(0, 0);
        } else {
            overridePendingTransition(C0003R.anim.bottom_to_up, C0003R.anim.zoom_out);
        }
        this.U = getIntent().getIntExtra("BARCODE_TYPE", 1000);
        a((Toolbar) findViewById(C0003R.id.main_toolbar), getResources().getString(C0003R.string.invite_to_bbm_scan_barcode));
        this.O = (TextView) findViewById(C0003R.id.capture_info_text_view);
        this.M = (ImageView) findViewById(C0003R.id.barcode_qr);
        this.P = (TextView) findViewById(C0003R.id.barcode_pin_left);
        this.N = (TextView) findViewById(C0003R.id.barcode_pin_right);
        this.P.setText(C0003R.string.profile_pinlabel);
        this.Q = (AvatarView) findViewById(C0003R.id.banner_avatar);
        this.R = (TextView) findViewById(C0003R.id.banner_name);
        this.S = (TextView) findViewById(C0003R.id.banner_description);
        Intent intent = getIntent();
        if (intent.hasExtra("channel_uri")) {
            this.V = intent.getStringExtra("channel_uri");
            if (com.bbken.util.ff.b(this.V) && bundle != null && !bundle.isEmpty()) {
                this.V = bundle.getString("channel_uri");
            }
            if (!(!com.bbken.util.fx.a(this, !com.bbken.util.ff.b(this.V), "Channel uri can not be null or blank"))) {
                return;
            }
        } else if (intent.hasExtra("user_uri")) {
            if (intent.hasExtra("user_uri")) {
                this.T = intent.getStringExtra("user_uri");
                if (com.bbken.util.ff.b(this.T) && bundle != null && !bundle.isEmpty()) {
                    this.T = bundle.getString("user_uri");
                }
                z = !com.bbken.util.fx.a(this, !com.bbken.util.ff.b(this.T), "User uri can not be null or blank");
            } else {
                z = false;
            }
            if (!z) {
                return;
            }
        } else if (intent.hasExtra("groupUri")) {
            this.v = kr.a(this, bundle);
            if (!(!com.bbken.util.fx.a(this, !TextUtils.isEmpty(this.v), "No group URI specified in Intent"))) {
                return;
            }
        }
        if (h()) {
            String uuid = UUID.randomUUID().toString();
            com.bbken.ah.b("request GroupBarCode => QRCode: %s", getClass(), uuid);
            this.I = new com.bbken.ui.f.h(this, uuid);
            this.K.c.a.a.a(this.I);
            this.K.c.a(com.bbken.h.ay.f(this.v).a(uuid));
        }
        if (h()) {
            this.N.setVisibility(8);
            this.P.setVisibility(8);
        }
        if (intent.getFlags() == 65536) {
            overridePendingTransition(0, 0);
        }
        new Handler().postDelayed(new ba(this), 10000L);
    }

    @Override
    public final boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(C0003R.menu.invites_common, menu);
        return true;
    }

    @Override
    public final boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == C0003R.id.copy_pin_menu) {
            this.aa.c();
            return true;
        }
        if (menuItem.getItemId() == C0003R.id.share_pin_menu) {
            if (!TextUtils.isEmpty(this.X.f())) {
                com.bbken.util.ew.a(this);
            } else {
                com.bbken.util.ew.b(this);
            }
            return true;
        }
        return super.onOptionsItemSelected(menuItem);
    }

    @Override
    public final void onBackPressed() {
        super.onBackPressed();
        finish();
    }

    public void i() {
        com.bbken.d.iu e = this.J.e(this.T);
        this.W.b((com.bbken.util.dv<String>) com.bbken.d.b.a.a(e));
        if (e.equals(this.J.o())) {
            String m = this.J.m();
            if (m != null && !m.isEmpty()) {
                this.X.b((com.bbken.util.dv<String>) m);
                this.N.setText(this.X.f());
                return;
            } else {
                this.N.setText(this.W.f().toUpperCase(Locale.US));
                return;
            }
        }
        if (e.A != null && !e.A.isEmpty()) {
            this.X.b((com.bbken.util.dv<String>) e.A);
            this.N.setText(this.X.f());
        } else {
            this.N.setText(this.W.f().toUpperCase(Locale.US));
        }
    }

    @Override
    public final void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putString("user_uri", this.T);
        bundle.putString("channel_uri", this.V);
        bundle.putString("groupUri", this.v);
    }

    @Override
    public final void onPostResume() {
        com.bbken.ah.c("onPostResume", CaptureBarcodeActivity.class);
        com.bbken.l.u.a(new bb(this));
        super.onPostResume();
    }

    public final void b(String str) {
        try {
            new com.google.zxing.g.b();
            com.google.zxing.b.b a = com.google.zxing.g.b.a(str, com.google.zxing.a.QR_CODE, 200, 200);
            int i = a.a;
            int i2 = a.b;
            int[] iArr = new int[i * i2];
            for (int i3 = 0; i3 < i2; i3++) {
                int i4 = i3 * i;
                for (int i5 = 0; i5 < i; i5++) {
                    iArr[i4 + i5] = a.a(i5, i3) ? CircleDrawable.DEFAULT_BORDER_COLOR : -1;
                }
            }
            Bitmap createBitmap = Bitmap.createBitmap(i, i2, Bitmap.Config.RGB_565);
            createBitmap.setPixels(iArr, 0, i, 0, 0, i, i2);
            this.M.setImageBitmap(createBitmap);
            if (!h()) {
                this.J.a(com.bbken.d.ao.a(this.Z.f(), com.bbken.d.bb.Visible));
            }
        } catch (com.google.zxing.r e) {
            com.bbken.ah.a((Throwable) e);
        }
    }

    @Override
    public final void onResume() {
        boolean z;
        super.onResume();
        this.ab.c();
        this.ac.c();
        this.u.c();
        if (this.H) {
            this.z = new com.google.zxing.client.android.a.e(getApplication());
            this.n = (ViewfinderView) findViewById(C0003R.id.viewfinder_view);
            this.n.setCameraManager(this.z);
            this.A = null;
            this.o = null;
            j();
            SurfaceHolder holder = ((SurfaceView) findViewById(C0003R.id.preview_view)).getHolder();
            if (this.C) {
                a(holder);
            } else {
                holder.addCallback(this);
                holder.setType(3);
            }
            Intent intent = getIntent();
            this.p = com.google.zxing.client.android.s.d;
            this.F = null;
            this.G = null;
            if (intent != null) {
                String action = intent.getAction();
                String dataString = intent.getDataString();
                if ("com.google.zxing.client.android.SCAN".equals(action)) {
                    this.p = com.google.zxing.client.android.s.a;
                    this.F = com.google.zxing.client.android.h.a(intent);
                    if (intent.hasExtra("SCAN_WIDTH") && intent.hasExtra("SCAN_HEIGHT")) {
                        int intExtra = intent.getIntExtra("SCAN_WIDTH", 0);
                        int intExtra2 = intent.getIntExtra("SCAN_HEIGHT", 0);
                        if (intExtra > 0 && intExtra2 > 0) {
                            this.z.a(intExtra, intExtra2);
                        }
                    }
                } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) {
                    this.p = com.google.zxing.client.android.s.b;
                    this.D = dataString;
                    this.F = com.google.zxing.client.android.h.a;
                } else {
                    if (dataString != null) {
                        for (String str : y) {
                            if (dataString.startsWith(str)) {
                                z = true;
                                break;
                            }
                        }
                    }
                    z = false;
                    if (z) {
                        this.p = com.google.zxing.client.android.s.c;
                        this.D = dataString;
                        Uri parse = Uri.parse(this.D);
                        this.q = parse.getQueryParameter("ret");
                        this.E = parse.getQueryParameter("raw") != null;
                        this.F = com.google.zxing.client.android.h.a(parse);
                    }
                }
                this.G = intent.getStringExtra("CHARACTER_SET");
            }
        }
    }

    @Override
    public final void onPause() {
        this.ab.d();
        this.ac.d();
        Alaska.i().a(com.bbken.h.ay.a(false));
        try {
            this.J.a(com.bbken.d.ao.a(this.Z.f(), com.bbken.d.bb.Closed));
        } catch (com.bbken.l.z e) {
        }
        if (this.A != null) {
            com.bbken.util.g.b bVar = this.A;
            bVar.b = com.bbken.util.g.c.c;
            bVar.c.d();
            Message.obtain(bVar.a.a(), C0003R.id.quit).sendToTarget();
            try {
                bVar.a.join(500L);
            } catch (InterruptedException e2) {
            }
            bVar.removeMessages(C0003R.id.decode_succeeded);
            bVar.removeMessages(C0003R.id.decode_failed);
            this.A = null;
        }
        if (this.H) {
            this.z.b();
        }
        this.u.b();
        if (!this.C) {
            ((SurfaceView) findViewById(C0003R.id.preview_view)).getHolder().removeCallback(this);
        }
        super.onPause();
    }

    @Override
    public final void onDestroy() {
        this.u.d();
        if (this.I != null) {
            this.K.c.a.a.b(this.I);
            this.I = null;
        }
        super.onDestroy();
    }

    @Override
    public final boolean onKeyDown(int i, KeyEvent keyEvent) {
        switch (i) {
            case 4:
                if (this.p == com.google.zxing.client.android.s.a) {
                    setResult(0);
                    finish();
                    return true;
                }
                if ((this.p == com.google.zxing.client.android.s.d || this.p == com.google.zxing.client.android.s.c) && this.o != null) {
                    a(0L);
                    return true;
                }
                return super.onKeyDown(i, keyEvent);
            case 24:
                this.z.a(true);
                return true;
            case 25:
                this.z.a(false);
                return true;
            case 27:
            case 80:
                return true;
            default:
                return super.onKeyDown(i, keyEvent);
        }
    }

    @Override
    public final void onActivityResult(int i, int i2, Intent intent) {
        int intExtra;
        if (i2 == -1 && i == 47820 && (intExtra = intent.getIntExtra("ITEM_NUMBER", -1)) >= 0) {
            a(this.t.a(intExtra).a);
        }
    }

    private void a(com.google.zxing.n nVar) {
        if (this.A == null) {
            this.B = nVar;
            return;
        }
        if (nVar != null) {
            this.B = nVar;
        }
        if (this.B != null) {
            this.A.sendMessage(Message.obtain(this.A, C0003R.id.decode_succeeded, this.B));
        }
        this.B = null;
    }

    @Override
    public final void surfaceCreated(SurfaceHolder surfaceHolder) {
        if (surfaceHolder == null) {
            Log.e(x, "*** WARNING *** surfaceCreated() gave us a null surface!");
        }
        if (!this.C) {
            this.C = true;
            a(surfaceHolder);
        }
    }

    @Override
    public final void surfaceDestroyed(SurfaceHolder surfaceHolder) {
        this.C = false;
    }

    @Override
    public final void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
    }

    public static void a(Canvas canvas, Paint paint, com.google.zxing.p pVar, com.google.zxing.p pVar2) {
        canvas.drawLine(pVar.a, pVar.b, pVar2.a, pVar2.b, paint);
    }

    public final void a(com.google.zxing.n nVar, com.google.zxing.client.android.d.j jVar, Bitmap bitmap) {
        int i = 0;
        if (bitmap != null) {
            this.n.a(bitmap);
        }
        long longExtra = getIntent() == null ? 0L : getIntent().getLongExtra("RESULT_DISPLAY_DURATION_MS", 0L);
        if (this.p == com.google.zxing.client.android.s.a) {
            Intent intent = (getIntent() == null || getIntent().getAction() == null) ? new Intent("com.google.zxing.client.android.SCAN") : new Intent(getIntent().getAction());
            intent.addFlags(524288);
            intent.putExtra("SCAN_RESULT", nVar.toString());
            intent.putExtra("SCAN_RESULT_FORMAT", nVar.d.toString());
            byte[] bArr = nVar.b;
            if (bArr != null && bArr.length > 0) {
                intent.putExtra("SCAN_RESULT_BYTES", bArr);
            }
            Map<com.google.zxing.o, Object> map = nVar.e;
            if (map != null) {
                if (map.containsKey(com.google.zxing.o.UPC_EAN_EXTENSION)) {
                    intent.putExtra("SCAN_RESULT_UPC_EAN_EXTENSION", map.get(com.google.zxing.o.UPC_EAN_EXTENSION).toString());
                }
                Integer num = (Integer) map.get(com.google.zxing.o.ORIENTATION);
                if (num != null) {
                    intent.putExtra("SCAN_RESULT_ORIENTATION", num.intValue());
                }
                String str = (String) map.get(com.google.zxing.o.ERROR_CORRECTION_LEVEL);
                if (str != null) {
                    intent.putExtra("SCAN_RESULT_ERROR_CORRECTION_LEVEL", str);
                }
                Iterable iterable = (Iterable) map.get(com.google.zxing.o.BYTE_SEGMENTS);
                if (iterable != null) {
                    Iterator it = iterable.iterator();
                    while (it.hasNext()) {
                        intent.putExtra("SCAN_RESULT_BYTE_SEGMENTS_" + i, (byte[]) it.next());
                        i++;
                    }
                }
            }
            a(C0003R.id.return_scan_result, intent, longExtra);
            return;
        }
        if (this.p == com.google.zxing.client.android.s.b) {
            a(C0003R.id.launch_product_query, this.D.substring(0, this.D.lastIndexOf("/scan")) + "?q=" + ((Object) jVar.b()) + "&source=zxing", longExtra);
        } else if (this.p == com.google.zxing.client.android.s.c && this.q != null) {
            CharSequence b = this.E ? nVar.a : jVar.b();
            try {
                b = URLEncoder.encode(b.toString(), "UTF-8");
            } catch (UnsupportedEncodingException e) {
            }
            a(C0003R.id.launch_product_query, this.q.replace("{CODE}", b), longExtra);
        }
    }

    private void a(int i, Object obj, long j) {
        Message obtain = Message.obtain(this.A, i, obj);
        if (j > 0) {
            this.A.sendMessageDelayed(obtain, j);
        } else {
            this.A.sendMessage(obtain);
        }
    }

    private void a(SurfaceHolder surfaceHolder) {
        if (surfaceHolder == null) {
            throw new IllegalStateException("No SurfaceHolder provided");
        }
        if (this.z.a()) {
            Log.w(x, "initCamera() while already open -- late SurfaceView callback?");
            return;
        }
        try {
            this.z.a(surfaceHolder);
            if (this.A == null) {
                this.A = new com.bbken.util.g.b(this, this.F, this.G, this.z);
            }
            a((com.google.zxing.n) null);
        } catch (IOException e) {
            Log.w(x, e);
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(getString(C0003R.string.app_name));
            builder.setMessage(getString(C0003R.string.msg_camera_framework_bug));
            builder.setPositiveButton(C0003R.string.button_ok, new com.google.zxing.client.android.k(this));
            builder.setOnCancelListener(new com.google.zxing.client.android.k(this));
            builder.show();
        } catch (RuntimeException e2) {
            Log.w(x, "Unexpected error initializing camera", e2);
        }
    }

    public final void a(long j) {
        if (this.A != null) {
            this.A.sendEmptyMessageDelayed(C0003R.id.restart_preview, j);
        }
        j();
    }

    private void j() {
        this.n.setVisibility(0);
        this.o = null;
    }
}