导航菜单

页面标题

页面副标题

MedEd v5.3.6 - PictureAttachmentActivity.java 源代码

正在查看: MedEd v5.3.6 应用的 PictureAttachmentActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.freshchat.consumer.sdk.activity;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.freshchat.consumer.sdk.FreshchatImageLoader;
import com.freshchat.consumer.sdk.FreshchatImageLoaderRequest;
import com.freshchat.consumer.sdk.R;
import com.freshchat.consumer.sdk.beans.ValidateFileTypeTaskRequest;
import com.freshchat.consumer.sdk.util.Cdo;
import com.freshchat.consumer.sdk.util.da;

public class PictureAttachmentActivity extends cr {
    static String gc;
    private int a;
    private View bK;
    private ProgressDialog di;
    private Intent eN;
    private ImageView fW;
    private EditText fX;
    private Uri fY;
    private Uri fZ;
    private TextView gA;
    private com.freshchat.consumer.sdk.l.y gB;
    private ProgressBar gj;
    private boolean gk;
    private LinearLayout go;
    private LinearLayout gv;
    private View gx;
    private ImageView gz;
    private TextWatcher dP = new dx(this);
    private View.OnClickListener gC = new dy(this);

    public static Intent a(Context context, Uri uri, int i, String str, da.b bVar, boolean z) {
        Intent intent = new Intent(context, (Class<?>) PictureAttachmentActivity.class);
        intent.putExtra("FILE_NAME", i == 126 ? "" : com.freshchat.consumer.sdk.util.as.d(context, uri));
        gc = uri.toString();
        intent.putExtra("EXTRA_BOT_ATTACHMENT_ENABLED", z);
        intent.putExtra(bVar == da.b.TYPE_ANY ? "FILE_URL" : "PICTURE_URL", uri);
        intent.putExtra("REQUEST_CODE", i);
        intent.putExtra("MIME_TYPE", bVar.b());
        intent.putExtra("ATTACHMENT_CREATION_MODE", true);
        intent.putExtra("IMAGE_CAPTION", str);
        intent.putExtra("FILE_SIZE", com.freshchat.consumer.sdk.util.as.e(context, uri));
        return intent;
    }

    private void cG() {
        ViewGroup.LayoutParams layoutParams = this.go.getLayoutParams();
        layoutParams.width = getResources().getDimensionPixelSize(R.dimen.freshchat_button_max_width);
        this.go.setLayoutParams(layoutParams);
    }

    private void cH() {
        View view;
        String stringExtra = this.eN.getStringExtra("FILE_NAME");
        long longExtra = this.eN.getLongExtra("FILE_SIZE", 0L);
        boolean booleanExtra = this.eN.getBooleanExtra("EXTRA_BOT_ATTACHMENT_ENABLED", false);
        com.freshchat.consumer.sdk.b.o.d(this.gv);
        if (!this.eN.getBooleanExtra("ATTACHMENT_CREATION_MODE", false)) {
            l(this.eN.getStringExtra("PICTURE_URL"));
            com.freshchat.consumer.sdk.b.o.d(this.gx);
            com.freshchat.consumer.sdk.b.o.d(this.go);
            return;
        }
        Uri uri = (Uri) this.eN.getParcelableExtra("PICTURE_URL");
        this.fZ = uri;
        a(uri, com.freshchat.consumer.sdk.util.as.f(a(), this.fZ));
        if (booleanExtra) {
            if (com.freshchat.consumer.sdk.util.ds.a(stringExtra)) {
                setTitle(stringExtra);
                if (getSupportActionBar() != null) {
                    getSupportActionBar().p(com.freshchat.consumer.sdk.util.as.i(a(), longExtra));
                }
            }
            com.freshchat.consumer.sdk.b.o.d(this.gx);
            view = this.go;
        } else {
            com.freshchat.consumer.sdk.b.o.d(this.go);
            view = this.gx;
        }
        com.freshchat.consumer.sdk.b.o.c(view);
    }

    private void cI() {
        View view;
        this.gz.setVisibility(0);
        String stringExtra = this.eN.getStringExtra("FILE_NAME");
        long longExtra = this.eN.getLongExtra("FILE_SIZE", 0L);
        boolean booleanExtra = this.eN.getBooleanExtra("EXTRA_BOT_ATTACHMENT_ENABLED", false);
        com.freshchat.consumer.sdk.b.o.c(this.gv);
        this.gA.setText(stringExtra);
        if (com.freshchat.consumer.sdk.util.ds.a(stringExtra)) {
            setTitle(stringExtra);
        }
        if (getSupportActionBar() != null) {
            getSupportActionBar().p(com.freshchat.consumer.sdk.util.as.i(a(), longExtra));
        }
        if (booleanExtra) {
            com.freshchat.consumer.sdk.b.o.d(this.gx);
            this.go.setAlpha(1.0f);
            this.go.setEnabled(true);
            view = this.go;
        } else {
            this.bK.setAlpha(1.0f);
            this.bK.setEnabled(true);
            com.freshchat.consumer.sdk.b.o.d(this.go);
            view = this.gx;
        }
        com.freshchat.consumer.sdk.b.o.c(view);
        Uri uri = (Uri) this.eN.getParcelableExtra("FILE_URL");
        String f = com.freshchat.consumer.sdk.util.as.f(a(), uri);
        if (com.freshchat.consumer.sdk.util.ds.a(f) && f.startsWith("image") && !com.freshchat.consumer.sdk.util.cj.xV.contains(f)) {
            this.gz.setVisibility(8);
            this.gA.setVisibility(8);
            a(uri, f);
        }
    }

    public void cJ() {
        ProgressDialog progressDialog = new ProgressDialog(a(), R.style.Widget_Freshchat_ProgressDialog);
        this.di = progressDialog;
        progressDialog.setMessage(a().getString(R.string.freshchat_spinner_text));
        this.di.show();
        this.di.setCancelable(false);
        new ValidateFileTypeTaskRequest(gc, this.fY);
        com.freshchat.consumer.sdk.service.d.h.b(a().getApplicationContext(), new ValidateFileTypeTaskRequest(gc, this.fY));
    }

    public void cK() {
        this.gB.d(this.fZ, this.fX.getText().toString());
        setResult(-1, this.gB.Bx.mo());
        finish();
    }

    private void k(int i) {
        ProgressDialog progressDialog = this.di;
        if (progressDialog != null && progressDialog.isShowing()) {
            this.di.dismiss();
        }
        if (i != 200) {
            com.freshchat.consumer.sdk.util.ba.bO(a());
            com.freshchat.consumer.sdk.b.o.h(a(), a().getString(R.string.freshchat_file_not_supported_message));
        } else {
            setResult(-1, this.gB.Bw.mo());
            finish();
        }
    }

    private void l(String str) {
        String bm = com.freshchat.consumer.sdk.util.ch.bm(str);
        int h = Cdo.h(a(), R.attr.freshchatCarouselCardErrorImage);
        if (!com.freshchat.consumer.sdk.util.ds.a(bm)) {
            com.freshchat.consumer.sdk.b.o.c(this.fW);
            this.fW.setImageResource(h);
            return;
        }
        int width = this.fW.getWidth();
        int height = this.fW.getHeight();
        if (width == 0 || height == 0) {
            this.fW.setImageResource(h);
        }
        dz dzVar = new dz(this);
        FreshchatImageLoaderRequest a = new FreshchatImageLoaderRequest.a(bm).a(width, height).b(h).a();
        FreshchatImageLoader jS = com.freshchat.consumer.sdk.util.cj.jS();
        if (jS != null) {
            jS.loadInto(a, this.fW, dzVar);
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (configuration == null || configuration.orientation != 2) {
            return;
        }
        cG();
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.gB = new com.freshchat.consumer.sdk.l.y(this);
        if (getSupportActionBar() != null) {
            getSupportActionBar().n(true);
        }
        this.gB.ml();
        setContentView(R.layout.freshchat_activity_picture_attachment);
        this.go = (LinearLayout) findViewById(R.id.freshchat_file_attachment_preview_send_btn_background);
        this.fW = (ImageView) findViewById(R.id.freshchat_picture_attachment_imageview);
        this.gA = (TextView) findViewById(R.id.freshchat_file_attachment_preview_text);
        this.gx = findViewById(R.id.freshchat_conv_detail_text_reply_layout);
        this.gj = (ProgressBar) findViewById(R.id.freshchat_picture_attachment_progress_bar);
        this.gv = (LinearLayout) findViewById(R.id.freshchat_file_attachment_preview_container);
        this.gz = (ImageView) findViewById(R.id.freshchat_file_attachment_placeholder);
        this.fX = (EditText) findViewById(R.id.freshchat_conv_detail_reply_text);
        View findViewById = findViewById(R.id.freshchat_conv_detail_attach_image);
        View findViewById2 = findViewById(R.id.freshchat_conv_detail_record_voice_reply_button);
        this.bK = findViewById(R.id.freshchat_conv_detail_send_reply_button);
        this.di = new ProgressDialog(a(), R.style.Widget_Freshchat_ProgressDialog);
        findViewById.setVisibility(8);
        findViewById2.setVisibility(8);
        this.bK.setVisibility(0);
        this.bK.setEnabled(true);
        this.bK.setOnClickListener(this.gC);
        this.go.setEnabled(false);
        this.go.setOnClickListener(this.gC);
        Intent intent = getIntent();
        this.eN = intent;
        String stringExtra = intent.getStringExtra("IMAGE_CAPTION");
        this.gk = da.b.TYPE_ANY.b().equals(this.eN.getStringExtra("MIME_TYPE"));
        boolean hasExtra = this.eN.hasExtra("PICTURE_URL");
        if (com.freshchat.consumer.sdk.util.ds.a(stringExtra)) {
            this.fX.setText(stringExtra);
        }
        if (this.gk) {
            cI();
        } else if (hasExtra) {
            cH();
        }
        EditText editText = this.fX;
        if (editText != null) {
            editText.addTextChangedListener(this.dP);
        }
        cG();
    }

    public static Intent a(Context context, String str) {
        Intent intent = new Intent(context, (Class<?>) PictureAttachmentActivity.class);
        intent.addFlags(67108864);
        intent.putExtra("PICTURE_URL", str);
        return intent;
    }

    @Override
    public String[] b() {
        return new String[]{"com.freshchat.consumer.sdk.actions.TokenWaitTimeout", "FILE_ATTACHMENT_VALIDATION"};
    }

    @Override
    public void a(Context context, Intent intent) {
        if ("FILE_ATTACHMENT_VALIDATION".equals(intent.getAction())) {
            int j = this.gB.j(intent.getExtras());
            this.a = j;
            k(j);
        }
    }

    public void a(Uri uri) {
        this.gB.c(uri, this.fX.getText().toString());
    }

    private void a(Uri uri, String str) {
        new com.freshchat.consumer.sdk.k.a(a().getApplicationContext(), this.fW, this.gB.Bx, new FreshchatImageLoaderRequest.a(uri).a(Math.min(1080, com.freshchat.consumer.sdk.util.af.be(a().getApplicationContext())), Math.min(1080, com.freshchat.consumer.sdk.util.af.be(a().getApplicationContext()))).a(Cdo.h(a(), R.attr.freshchatPictureMessagePlaceholderImage)).a(), com.freshchat.consumer.sdk.util.cj.jS(), new eb(this), str).execute(uri);
    }
}