导航菜单

页面标题

页面副标题

Hyouka private v5.8.9 - ProfileImageActivity.java 源代码

正在查看: Hyouka private v5.8.9 应用的 ProfileImageActivity.java JAVA 源代码文件

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


package com.beint.project.screens;

import android.R;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.appcompat.app.c;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.FileProvider;
import com.beint.project.MainApplication;
import com.beint.project.core.services.impl.ZangiProfileServiceImpl;
import com.beint.project.core.utils.AppUserManager;
import com.beint.project.core.utils.Log;
import com.beint.project.core.utils.ZangiFileUtils;
import com.beint.project.core.utils.ZangiPermissionUtils;
import com.beint.project.core.utils.contactutils.Utils;
import com.beint.project.screens.sms.AppModeNotifierActivity;
import com.beint.project.screens.sms.TouchImageView;
import com.beint.project.screens.sms.gallery.enums.DestinationType;
import com.beint.project.screens.utils.UiUtilKt;
import com.beint.project.utils.AlertDialogUtils;
import com.beint.project.utils.ProjectUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

public class ProfileImageActivity extends AppModeNotifierActivity implements View.OnTouchListener, View.OnClickListener {
    private static final int ANIM_DURATION = 600;
    private FrameLayout bottomBar;
    private ImageView cameraButton;
    private MenuItem cameraMenu;
    private ColorDrawable colorDrawable;
    private ImageView deleteButton;
    private MenuItem deleteMenu;
    public TouchImageView fullScreenImageView;
    private boolean isBarsIsShow;
    private String mCurrentPhotoPath;
    private float mHeightScale;
    private int mLeftDelta;
    private int mTopDelta;
    private float mWidthScale;
    private BroadcastReceiver profileBroadcastReceiver;
    private String profileImage;
    private View rootView;
    private MenuItem shareMenu;
    private int thumbnailHeight;
    private int thumbnailLeft;
    private int thumbnailTop;
    private int thumbnailWidth;
    private Toolbar toolbar;
    private int toolbarHeight;
    private final int PROFILE_PICKER_REQUEST_CODE = 1945;
    private final int PROFILE_PICKER_REQUEST_CODE_FROM_CAMERA = 1954;
    private String TAG = ProfileImageActivity.class.getCanonicalName();
    private int statusBarHeight = Utils.statusBarHeight();
    private float startY = -1.0f;
    private float viewY = -1.0f;
    private float deltaCheck = ProjectUtils.dpToPx(120);
    private float deltaStart = ProjectUtils.dpToPx(20);
    private float deltaTransparent = ProjectUtils.dpToPx(50);
    private boolean isMoveVertical = false;
    private int alpha = 255;

    class AnonymousClass2 implements ViewTreeObserver.OnPreDrawListener {
        AnonymousClass2() {
        }

        @Override
        public boolean onPreDraw() {
            ProfileImageActivity.this.fullScreenImageView.getViewTreeObserver().removeOnPreDrawListener(this);
            int[] iArr = new int[2];
            ProfileImageActivity.this.fullScreenImageView.getLocationOnScreen(iArr);
            ProfileImageActivity profileImageActivity = ProfileImageActivity.this;
            profileImageActivity.mLeftDelta = profileImageActivity.thumbnailLeft - iArr[0];
            ProfileImageActivity profileImageActivity2 = ProfileImageActivity.this;
            profileImageActivity2.mTopDelta = profileImageActivity2.thumbnailTop - iArr[1];
            ProfileImageActivity.this.mWidthScale = r0.thumbnailWidth / ProfileImageActivity.this.fullScreenImageView.getWidth();
            ProfileImageActivity.this.mHeightScale = r0.thumbnailHeight / ProfileImageActivity.this.fullScreenImageView.getHeight();
            ProfileImageActivity.this.enterAnimation();
            return true;
        }
    }

    private void _openCamera() {
        dispatchTakePictureIntent(1954);
    }

    private void _openGallery() {
        getScreenService().openZangiFileGalleryActivityForResult((Activity) this, DestinationType.SELECT_IMAGE_FOR_PROFILE, 1945, (Bundle) null);
    }

    private void askEditPhoto() {
        if (isFinishing()) {
            return;
        }
        AlertDialogUtils.showAlertWithMessage((Context) this, 2131886181, 2131887716, 2131886151, 2131886438, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ProfileImageActivity.this.lambda$askEditPhoto$0(dialogInterface, i);
            }
        }, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
            }
        }, true);
    }

    private void dispatchTakePictureIntent(int i) {
        if (ZangiFileUtils.checkFoldersExisting()) {
            Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
            File file = new File(ZangiProfileServiceImpl.getInstance().getProfileTempDir());
            if (!file.exists()) {
                file.mkdirs();
            }
            File file2 = new File(file.getPath() + "/avatar.png");
            this.mCurrentPhotoPath = file2.getAbsolutePath();
            intent.putExtra("output", Build.VERSION.SDK_INT <= 23 ? Uri.fromFile(file2) : FileProvider.f(this, "com.beint.zangi.provider", file2));
            intent.putExtra("android.intent.extra.sizeLimit", 3568813L);
            intent.putExtra("return-data", true);
            try {
                startActivityForResult(intent, i);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private void hideShowBars(boolean z) {
        if (!z) {
            this.toolbar.animate().translationY(-this.toolbarHeight).withEndAction(new Runnable() {
                @Override
                public final void run() {
                    ProfileImageActivity.this.lambda$hideShowBars$10();
                }
            }).alpha(0.0f).start();
            this.bottomBar.animate().translationY(this.toolbarHeight).withEndAction(new Runnable() {
                @Override
                public final void run() {
                    ProfileImageActivity.this.lambda$hideShowBars$11();
                }
            }).alpha(0.0f).start();
        } else {
            getWindow().clearFlags(1024);
            this.toolbar.animate().translationY(0.0f).alpha(1.0f).start();
            this.bottomBar.animate().translationY(0.0f).alpha(1.0f).withEndAction(new Runnable() {
                @Override
                public final void run() {
                    ProfileImageActivity.this.lambda$hideShowBars$9();
                }
            }).start();
        }
    }

    public void lambda$askEditPhoto$0(DialogInterface dialogInterface, int i) {
        openGalleryOnClickListener();
    }

    public void lambda$hideShowBars$10() {
        getWindow().addFlags(1024);
    }

    public void lambda$hideShowBars$11() {
        this.isBarsIsShow = false;
    }

    public void lambda$hideShowBars$9() {
        this.isBarsIsShow = true;
    }

    private void lambda$onOptionsItemSelected$3() {
        finish();
    }

    public void lambda$onTouch$7(int i, int i7, ValueAnimator valueAnimator) {
        if (i < 255) {
            this.rootView.setBackgroundColor(Color.HSVToColor(i + ((int) (i7 * ((Float) valueAnimator.getAnimatedValue()).floatValue())), new float[]{0.0f, 0.0f, 0.0f}));
        }
    }

    public static void lambda$onTouch$8(View view) {
        ((TouchImageView) view).setViewMoveVertical(false);
    }

    public void lambda$openCamera$6(ArrayList arrayList, boolean z) {
        if (z) {
            _openCamera();
        }
    }

    public void lambda$openGallery$5(ArrayList arrayList, boolean z) {
        if (z) {
            _openGallery();
        }
    }

    public void lambda$openGalleryOnClickListener$4(DialogInterface dialogInterface, int i) {
        if (i == 0) {
            openCamera();
        } else {
            if (i != 1) {
                return;
            }
            openGallery();
        }
    }

    private void lambda$processKeyDown$2() {
        finish();
    }

    private void openCamera() {
        if (ZangiPermissionUtils.hasPermission(this, 1011, true, new ZangiPermissionUtils.OnPermissionResult() {
            public final void onResult(ArrayList arrayList, boolean z) {
                ProfileImageActivity.this.lambda$openCamera$6(arrayList, z);
            }
        })) {
            _openCamera();
        }
    }

    private void openGallery() {
        if (ZangiPermissionUtils.hasPermission(this, 1007, true, new ZangiPermissionUtils.OnPermissionResult() {
            public final void onResult(ArrayList arrayList, boolean z) {
                ProfileImageActivity.this.lambda$openGallery$5(arrayList, z);
            }
        })) {
            _openGallery();
        }
    }

    private void setUserFullPhoto(ImageView imageView) {
        String userNumber = AppUserManager.INSTANCE.getUserNumber();
        File file = new File(ZangiProfileServiceImpl.getInstance().getProfileAvatarImageDir(userNumber));
        if (!file.exists()) {
            file = new File(ZangiProfileServiceImpl.getInstance().getProfileAvatarDir(userNumber));
        }
        if (file.exists()) {
            imageView.setImageURI(Uri.fromFile(file));
        }
    }

    public void enterAnimation() {
        this.fullScreenImageView.setPivotX(0.0f);
        this.fullScreenImageView.setPivotY(0.0f);
        this.fullScreenImageView.setScaleX(this.mWidthScale);
        this.fullScreenImageView.setScaleY(this.mHeightScale);
        this.fullScreenImageView.setTranslationX(this.mLeftDelta);
        this.fullScreenImageView.setTranslationY(this.mTopDelta);
        this.fullScreenImageView.animate().setDuration(600L).scaleX(1.0f).scaleY(1.0f).translationX(0.0f).translationY(0.0f).setInterpolator(new AccelerateInterpolator());
        ObjectAnimator ofInt = ObjectAnimator.ofInt(this.colorDrawable, "alpha", 0, 255);
        ofInt.setDuration(600L);
        ofInt.start();
    }

    public void exitAnimation(Runnable runnable) {
        this.fullScreenImageView.animate().setDuration(600L).scaleX(this.mWidthScale).scaleY(this.mHeightScale).translationX(this.mLeftDelta).translationY(this.mTopDelta).setInterpolator(new AccelerateInterpolator()).withEndAction(runnable);
        ObjectAnimator ofInt = ObjectAnimator.ofInt(this.colorDrawable, "alpha", 0);
        ofInt.setDuration(300L);
        ofInt.start();
    }

    protected void onActivityResult(int i, int i7, Intent intent) {
        super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i, i7, intent);
        try {
            if (i != 1945) {
                if (i != 1954 || i7 != -1) {
                    return;
                }
                Intent intent2 = new Intent();
                intent2.putExtra("take_photo", this.mCurrentPhotoPath);
                setResult(-1, intent2);
                finish();
            } else {
                if (i7 != -1) {
                    return;
                }
                String stringExtra = intent.getStringExtra("com.beint.project.PHOTO_URI");
                Intent intent3 = new Intent();
                intent3.putExtra("com.beint.project.PHOTO_URI", stringExtra);
                setResult(-1, intent3);
                finish();
            }
        } catch (Exception e) {
            Log.e(this.TAG, "Error during capture from camera e = " + e.getMessage());
            Toast.makeText(MainApplication.Companion.getMainContext(), 2131886271, 1).show();
        }
    }

    public void onBackPressed() {
        if (this.fullScreenImageView.setNormalizedScale()) {
            this.fullScreenImageView.setCornerRadius(Float.valueOf(ProjectUtils.dpToPx(70)));
            super.onBackPressed();
        }
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131362114) {
            askEditPhoto();
            return;
        }
        if (id != 2131362347) {
            if (id != 2131362571) {
                return;
            }
            hideShowBars(!this.isBarsIsShow);
        } else {
            Intent intent = new Intent();
            intent.putExtra("delete", "delete");
            setResult(-1, intent);
            finish();
        }
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131558687);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            this.profileImage = extras.getString("profile_image");
        }
        getWindow().getDecorView().setSystemUiVisibility(1280);
        Toolbar findViewById = findViewById(2131363848);
        this.toolbar = findViewById;
        setSupportActionBar(findViewById);
        androidx.appcompat.app.a supportActionBar = getSupportActionBar();
        if (supportActionBar != null) {
            supportActionBar.v(false);
            supportActionBar.q(true);
            supportActionBar.r(true);
            supportActionBar.x("");
        }
        this.rootView = findViewById(2131363474);
        this.bottomBar = (FrameLayout) findViewById(2131362015);
        this.deleteButton = (ImageView) findViewById(2131362347);
        this.cameraButton = (ImageView) findViewById(2131362114);
        this.deleteButton.setOnClickListener(this);
        this.cameraButton.setOnClickListener(this);
        TouchImageView touchImageView = (TouchImageView) findViewById(2131362571);
        this.fullScreenImageView = touchImageView;
        touchImageView.setCornerRadius(Float.valueOf(ProjectUtils.dpToPx(70)));
        this.fullScreenImageView.setRadius(Float.valueOf(ProjectUtils.dpToPx(70)));
        Bundle extras2 = getIntent().getExtras();
        this.thumbnailTop = extras2.getInt("top");
        this.thumbnailLeft = extras2.getInt("left");
        this.thumbnailWidth = extras2.getInt("width");
        this.thumbnailHeight = extras2.getInt("height");
        this.colorDrawable = new ColorDrawable(-16777216);
        final String stringExtra = getIntent().getStringExtra("com.beint.project.PROFILE_IMAGE_KEY");
        setUserFullPhoto(this.fullScreenImageView);
        BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String stringExtra2 = intent.getStringExtra("com.beint.project.PROFILE_FULL_IMAGE_KEY");
                if (stringExtra2.equals(stringExtra)) {
                    try {
                        ProfileImageActivity.this.fullScreenImageView.setImageBitmap(ZangiFileUtils.scaleImageMinimum(Uri.fromFile(new File(ZangiProfileServiceImpl.getInstance().getProfileAvatarImageDir(stringExtra2))).getPath(), ProfileImageActivity.this.fullScreenImageView.getMeasuredWidth()));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        this.profileBroadcastReceiver = broadcastReceiver;
        registerReceiver(broadcastReceiver, new IntentFilter("com.beint.project.UPDATE_PROFILE_FULL_IMAGE"));
        ((FrameLayout.LayoutParams) this.toolbar.getLayoutParams()).topMargin = this.statusBarHeight;
        this.fullScreenImageView.setOnTouchListener(this);
        this.fullScreenImageView.setOnClickListener(this);
        this.toolbarHeight = UiUtilKt.getToolbarHeight(this);
        this.bottomBar.setVisibility(0);
        this.fullScreenImageView.setTransitionName(getResources().getString(2131887219));
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(2131689494, menu);
        this.cameraMenu = menu.findItem(2131363779);
        this.deleteMenu = menu.findItem(2131362355);
        this.shareMenu = menu.findItem(2131363634);
        this.deleteMenu.setVisible(false);
        this.cameraMenu.setVisible(false);
        this.shareMenu.setVisible(true);
        if (this.profileImage == null) {
            this.cameraMenu.setVisible(false);
            this.deleteMenu.setVisible(false);
        }
        return super/*android.app.Activity*/.onCreateOptionsMenu(menu);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(this.profileBroadcastReceiver);
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case R.id.home:
                onBackPressed();
                break;
            case 2131362355:
                Intent intent = new Intent();
                intent.putExtra("delete", "delete");
                setResult(-1, intent);
                finish();
                break;
            case 2131363634:
                shareProfileImage();
                break;
            case 2131363779:
                openGalleryOnClickListener();
                break;
        }
        return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
    }

    @Override
    public boolean onTouch(final View view, MotionEvent motionEvent) {
        if (!this.fullScreenImageView.isImageZoomed()) {
            int action = motionEvent.getAction();
            if (action == 0) {
                this.viewY = view.getY();
                this.startY = motionEvent.getRawY();
                this.alpha = 255;
            } else if (action == 1) {
                if (Math.abs(motionEvent.getRawY() - this.startY) > this.deltaCheck) {
                    onBackPressed();
                } else {
                    final int i = this.alpha;
                    final int i7 = 255 - i;
                    view.animate().cancel();
                    view.animate().translationY(0.0f).withLayer().setUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ProfileImageActivity.this.lambda$onTouch$7(i, i7, valueAnimator);
                        }
                    }).withEndAction(new Runnable() {
                        @Override
                        public final void run() {
                            ProfileImageActivity.lambda$onTouch$8(view);
                        }
                    }).start();
                }
                this.isMoveVertical = false;
            } else if (action == 2) {
                if (!this.isMoveVertical && Math.abs(motionEvent.getRawY() - this.startY) > this.deltaStart) {
                    this.viewY = view.getY();
                    this.startY = motionEvent.getRawY();
                    this.isMoveVertical = true;
                    ((TouchImageView) view).setViewMoveVertical(true);
                    hideShowBars(false);
                }
                if (this.isMoveVertical) {
                    if (this.deltaTransparent < Math.abs(motionEvent.getRawY() - this.startY)) {
                        this.alpha = 100;
                    } else {
                        this.alpha = ((int) ((1.0f - (Math.abs(motionEvent.getRawY() - this.startY) / this.deltaTransparent)) * 155.0f)) + 100;
                    }
                    this.rootView.setBackgroundColor(Color.HSVToColor(this.alpha, new float[]{0.0f, 0.0f, 0.0f}));
                    view.setY(this.viewY + (motionEvent.getRawY() - this.startY));
                }
            }
        }
        return true;
    }

    public void openGalleryOnClickListener() {
        c.a alertDialog = AlertDialogUtils.getAlertDialog(this);
        alertDialog.r(2131887220);
        alertDialog.g(new CharSequence[]{getString(2131887526), getString(2131886311)}, new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                ProfileImageActivity.this.lambda$openGalleryOnClickListener$4(dialogInterface, i);
            }
        });
        androidx.appcompat.app.c a = alertDialog.a();
        a.setCanceledOnTouchOutside(true);
        a.show();
        a.getWindow().setLayout(AlertDialogUtils.getAlertSize(), -2);
        AlertDialogUtils.setCurrentDialog(a);
    }

    public boolean processKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return i == 4;
        }
        onBackPressed();
        return true;
    }

    public void shareProfileImage() {
        ZangiProfileServiceImpl zangiProfileServiceImpl = ZangiProfileServiceImpl.getInstance();
        AppUserManager appUserManager = AppUserManager.INSTANCE;
        String profileAvatarImageDir = zangiProfileServiceImpl.getProfileAvatarImageDir(appUserManager.getUserNumber());
        String profileAvatarDir = ZangiProfileServiceImpl.getInstance().getProfileAvatarDir(appUserManager.getUserNumber());
        File file = new File(profileAvatarImageDir);
        if (!file.exists()) {
            file = new File(profileAvatarDir);
        }
        if (file.exists()) {
            Intent intent = new Intent("android.intent.action.SEND");
            intent.setType("image/*");
            if (Build.VERSION.SDK_INT >= 24) {
                try {
                    intent.putExtra("android.intent.extra.STREAM", FileProvider.f(this, "com.beint.zangi.provider", file));
                    intent.setFlags(1);
                } catch (Exception unused) {
                    intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(file));
                }
            } else {
                intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(file));
            }
            startActivity(Intent.createChooser(intent, "Share images to.."));
        }
    }
}