SettingActivity.java 源代码


package activity.setting;

import account.bean.EmptyBean;
import account.bean.LoginUserInfo;
import account.bean.UnbindDevBean;
import activity.FishEye.FishEyeActivity;
import activity.WallMounted.WallMountedActivity;
import activity.cloud.CloudStorageInformationActivity;
import activity.cloud.api.UserApiFactory;
import activity.cloud.re.MyCallBack;
import activity.cloud.utils.DateUtils;
import activity.cloud1.CloudInfoGoogleActivity;
import activity.live.DualLiveViewActivity;
import activity.live.DualLiveViewActivity_ThreeEyes;
import activity.live.LiveViewActivity;
import activity.live.SpliceLiveViewActivity;
import activity.setting.PlanVideo.PlanVideoActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import base.HiActivity;
import bean.GroupBeanSave;
import bean.GroupBeanUse;
import bean.MyCamera;
import com.bumptech.glide.Glide;
import com.hichip.callback.ICameraIOSessionCallback;
import com.hichip.campro.R;
import com.hichip.content.HiChipDefines;
import com.hichip.control.HiCamera;
import com.hichip.tools.Packet;
import common.CamHiDefines;
import common.Constant;
import common.ConstantCommand;
import common.HiDataValue;
import custom.FloatingWindow;
import custom.ObservableScrollView;
import custom.ShadowLayout;
import custom.dialog.NiftyDialogBuilder;
import java.io.ByteArrayOutputStream;
import java.util.Iterator;
import java.util.Locale;
import java.util.regex.Pattern;
import jp.wasabeef.glide.transformations.BlurTransformation;
import liteos.ShareQRDetCodeActivity;
import main.NVR.adapter.NVRListBean;
import utils.DialogUtilsCamHiPro;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
import utils.SharePreUtils;

public class SettingActivity extends HiActivity implements View.OnClickListener, ICameraIOSessionCallback, ObservableScrollView.ScrollViewListener {
    String autoShare;
    private Bitmap bitmap;
    TextView btn_delete_camera;
    private byte[] bytes;
    EditText et_head_nickname;
    EditText et_nickname;
    private boolean isSupport5G;
    private boolean isSupportCloud;
    private boolean isSupportGoogleCloud;
    TextView iv_auto_share;
    ImageView iv_edit_name;
    ImageView iv_head;
    ImageView iv_head_icon;
    ImageView iv_return;
    TextView iv_share;
    private int lastDis;
    LinearLayout llBuyStorage;
    LinearLayout ll_alarm_setting;
    LinearLayout ll_all_setting;
    LinearLayout ll_cloud;
    LinearLayout ll_floating;
    LinearLayout ll_hand_edit;
    LinearLayout ll_setting_4g;
    LinearLayout ll_setting_device_info;
    LinearLayout ll_setting_floating;
    LinearLayout ll_setting_password;
    LinearLayout ll_setting_plan_video;
    LinearLayout ll_setting_sd_card;
    LinearLayout ll_setting_system;
    LinearLayout ll_setting_time;
    LinearLayout ll_setting_video;
    LinearLayout ll_setting_wifi;
    private FloatingWindow mFloatingWindow;
    private MyCamera mMyCamera;
    private int mTop;
    RelativeLayout rl_head_name;
    RelativeLayout rl_setting_audio;
    ObservableScrollView scrollView;
    ShadowLayout shadowlayout;
    private String str_nick;
    TextView tv_4g;
    TextView tv_current_device_wifi;
    TextView tv_disconnect_1;
    TextView tv_head_uid;
    TextView tv_uid;
    private float alpha = 0.4f;
    MyCamera.OnBindPushResult bindPushResult = new MyCamera.OnBindPushResult() {
        @Override
        public void onBindTokenIsNull(MyCamera myCamera, boolean z) {
        }

        @Override
        public void onBindSuccess(MyCamera myCamera) {
            Log.i("tedu", myCamera.getUid() + " 绑定成功:" + myCamera.getServerData());
            myCamera.setPushDevName(SettingActivity.this.str_nick);
        }

        @Override
        public void onBindFail(MyCamera myCamera) {
            Log.i("tedu", myCamera.getUid() + " 解绑推送失败:" + myCamera.getServerData());
        }

        @Override
        public void onUnBindSuccess(MyCamera myCamera) {
            Log.i("tedu", myCamera.getUid() + " 解绑推送成功:" + myCamera.getServerData());
        }

        @Override
        public void onUnBindFail(MyCamera myCamera) {
            if (myCamera.getPushState() > 0) {
                SharePreUtils.putInt("subId", SettingActivity.this, myCamera.getUid(), myCamera.getPushState());
            }
        }

        @Override
        public void onUpdatePushNameSuccess(MyCamera myCamera) {
            Log.i("tedu", myCamera.getUid() + " onUpdatePushNameSuccess ");
        }

        @Override
        public void onUpdatePushNameFail(MyCamera myCamera) {
            Log.i("tedu", myCamera.getUid() + " onUpdatePushNameFail ");
        }
    };
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            switch (message.what) {
                case HiDataValue.HANDLE_MESSAGE_SESSION_STATE:
                    SettingActivity.this.handMsgSessionState(message);
                    return;
                case HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL:
                    SettingActivity.this.handIOCTRL(message);
                    return;
                case 2456:
                    if (SettingActivity.this.bytes == null || SettingActivity.this.isFinishing()) {
                        return;
                    }
                    Glide.with((FragmentActivity) SettingActivity.this).load(SettingActivity.this.bytes).placeholder(R.mipmap.videoclip).error(R.mipmap.videoclip).bitmapTransform(new BlurTransformation(SettingActivity.this, 23, 5)).into(SettingActivity.this.iv_head);
                    return;
                case 65537:
                    for (int i = 0; i < HiDataValue.mapBeanList.size(); i++) {
                        NVRListBean nVRListBean = HiDataValue.mapBeanList.get(i);
                        HiLogcatUtil.e("HANDLE_MESSAGE_DELETE_FILE " + i + "::" + SettingActivity.this.mMyCamera.mNVRChaildDevNum + "::" + nVRListBean.getMyCamera().getUid() + ":::" + SettingActivity.this.mMyCamera.getUid());
                        if (nVRListBean.getMyCamera().getUid().equalsIgnoreCase(SettingActivity.this.mMyCamera.getUid()) && nVRListBean.getViewType() == 0) {
                            HiDataValue.mapBeanList.indexOf(nVRListBean);
                            if (nVRListBean.getMyCamera() == null) {
                                return;
                            }
                            SettingActivity.this.mMyCamera.disconnect(1);
                            nVRListBean.deleteInCameraList();
                            SettingActivity.this.mMyCamera.deleteInCameraList();
                            SettingActivity.this.mMyCamera.deleteInDatabase(SettingActivity.this);
                            int i2 = 0;
                            while (i2 < HiDataValue.groupList.size()) {
                                int i3 = 0;
                                while (true) {
                                    if (i3 < HiDataValue.groupList.get(i2).getCameraList().length) {
                                        if (HiDataValue.groupList.get(i2).getCameraList()[i3] == null || !HiDataValue.groupList.get(i2).getCameraList()[i3].getUid().equals(SettingActivity.this.mMyCamera.getUid())) {
                                            i3++;
                                        } else {
                                            HiDataValue.groupList.get(i2).getCameraList()[i3] = null;
                                        }
                                    }
                                }
                                if (HiDataValue.groupList.get(i2).getCameraList()[0] != null || HiDataValue.groupList.get(i2).getCameraList()[1] != null || HiDataValue.groupList.get(i2).getCameraList()[2] != null || HiDataValue.groupList.get(i2).getCameraList()[3] != null) {
                                    SettingActivity.this.updateGroup(HiDataValue.groupList.get(i2));
                                } else {
                                    SettingActivity.this.deleteGroup(HiDataValue.groupList.get(i2));
                                    i2--;
                                }
                                i2++;
                            }
                            SettingActivity.this.dismissjuHuaDialog();
                            SharePreUtils.putInt(HiDataValue.CACHE, SettingActivity.this, "pictureSize" + HiDataValue.userAccount + SettingActivity.this.mMyCamera.getUid(), 0);
                            if (HiTools.isNVRDev(SettingActivity.this.mMyCamera.getUid())) {
                                SettingActivity settingActivity = SettingActivity.this;
                                MyToast.showToast(settingActivity, settingActivity.getString(R.string.tips_remove_success_nvr));
                            } else {
                                SettingActivity settingActivity2 = SettingActivity.this;
                                MyToast.showToast(settingActivity2, settingActivity2.getString(R.string.tips_remove_success));
                            }
                            SettingActivity.this.sendBroadcast(new Intent(HiDataValue.ACTION_CAMERA_INIT_END));
                            SettingActivity.this.finish();
                            return;
                        }
                    }
                    return;
                case ConstantCommand.HI_P2P_SET_SCENE_MODE:
                    SettingActivity.this.mFloatingWindow.setTopApp(SettingActivity.this);
                    SettingActivity settingActivity3 = SettingActivity.this;
                    Toast.makeText(settingActivity3, settingActivity3.getString(R.string.tips_open_video_fail), 0).show();
                    return;
                case ConstantCommand.HI_P2P_GET_DEVICE_WORKING_MODE:
                    MyToast.showToast(SettingActivity.this.getApplicationContext(), SettingActivity.this.getString(R.string.netword_abnormal));
                    if (SettingActivity.this.mMyCamera != null) {
                        SettingActivity.this.mMyCamera.stopLiveShow();
                        SettingActivity.this.mMyCamera.stopListening();
                    }
                    HiDataValue.isNeedkillNoMain = false;
                    if (SettingActivity.this.mFloatingWindow != null) {
                        SettingActivity.this.mFloatingWindow.dismiss();
                    }
                    SettingActivity.this.finish();
                    return;
                default:
                    return;
            }
        }
    };
    private boolean canToLive = true;

    @Override
    protected int setLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void init(Bundle bundle) {
        HiTools.setTransStatusBar(this);
        getIntentData();
        if (HiTools.cameraWhetherNull(this.mMyCamera, this)) {
            return;
        }
        initViewAndData();
        setListeners();
    }

    @Override
    public void onResume() {
        super.onResume();
        this.et_nickname.setText(this.mMyCamera.getNikeName());
        this.et_head_nickname.setText(this.mMyCamera.getNikeName());
        if (this.bitmap == null) {
            initHeadView();
        }
        MyCamera myCamera = this.mMyCamera;
        if (myCamera != null) {
            myCamera.registerIOSessionListener(this);
        }
        MyCamera myCamera2 = this.mMyCamera;
        if (myCamera2 != null && myCamera2.getConnectState() != 4) {
            this.ll_cloud.setEnabled(false);
            this.ll_cloud.setAlpha(this.alpha);
            this.ll_setting_4g.setEnabled(false);
            this.ll_setting_4g.setAlpha(this.alpha);
            this.llBuyStorage.setClickable(false);
            this.ll_setting_wifi.setEnabled(false);
            this.ll_setting_wifi.setAlpha(this.alpha);
            this.ll_setting_password.setEnabled(false);
            this.ll_setting_password.setAlpha(this.alpha);
            this.ll_floating.setEnabled(false);
            this.ll_floating.setAlpha(this.alpha);
            this.ll_setting_floating.setEnabled(false);
            this.ll_setting_floating.setAlpha(this.alpha);
            this.ll_setting_system.setEnabled(false);
            this.ll_setting_system.setAlpha(this.alpha);
            this.ll_setting_device_info.setEnabled(false);
            this.ll_setting_device_info.setAlpha(this.alpha);
            this.ll_alarm_setting.setEnabled(false);
            this.ll_alarm_setting.setAlpha(this.alpha);
            this.ll_setting_plan_video.setEnabled(false);
            this.ll_setting_plan_video.setAlpha(this.alpha);
            this.ll_setting_sd_card.setEnabled(false);
            this.ll_setting_sd_card.setAlpha(this.alpha);
            this.ll_setting_video.setEnabled(false);
            this.ll_setting_video.setAlpha(this.alpha);
            this.rl_setting_audio.setEnabled(false);
            this.rl_setting_audio.setAlpha(this.alpha);
            this.ll_setting_time.setEnabled(false);
            this.ll_setting_time.setAlpha(this.alpha);
            this.btn_delete_camera.setEnabled(false);
            this.btn_delete_camera.setAlpha(this.alpha);
            this.iv_share.setVisibility(8);
            if (this.mMyCamera.getConnectState() == 0) {
                this.mFloatingWindow.setReady(false);
                this.ll_all_setting.setVisibility(8);
                this.tv_disconnect_1.setVisibility(0);
            }
        }
        if (!TextUtils.isEmpty(this.autoShare)) {
            this.iv_auto_share.setVisibility(0);
            this.iv_share.setVisibility(8);
        }
        if (HiTools.getAndroidVersion() >= 29) {
            if (this.mMyCamera.isFishEye() || this.mMyCamera.isWallMounted || this.mMyCamera.getdevDual() || this.mMyCamera.getdevSplice()) {
                this.ll_floating.setVisibility(8);
                this.ll_setting_floating.setVisibility(8);
            } else {
                this.ll_floating.setVisibility(0);
                this.ll_setting_floating.setVisibility(0);
            }
        } else {
            this.ll_floating.setVisibility(8);
            this.ll_setting_floating.setVisibility(8);
        }
        HiDataValue.isNeedkillNoMain = false;
    }

    private void setListeners() {
        this.iv_return.setOnClickListener(this);
        this.iv_edit_name.setOnClickListener(this);
        this.ll_setting_wifi.setOnClickListener(this);
        this.ll_setting_password.setOnClickListener(this);
        this.ll_setting_floating.setOnClickListener(this);
        this.ll_setting_device_info.setOnClickListener(this);
        this.ll_setting_system.setOnClickListener(this);
        this.ll_setting_video.setOnClickListener(this);
        this.ll_setting_sd_card.setOnClickListener(this);
        this.ll_setting_plan_video.setOnClickListener(this);
        this.ll_setting_time.setOnClickListener(this);
        this.scrollView.setScrollViewListener(this);
        this.btn_delete_camera.setOnClickListener(this);
        this.iv_head_icon.setOnClickListener(this);
        this.ll_hand_edit.setOnClickListener(this);
        this.rl_setting_audio.setOnClickListener(this);
        this.ll_alarm_setting.setOnClickListener(this);
        this.iv_share.setOnClickListener(this);
        this.iv_auto_share.setOnClickListener(this);
        this.llBuyStorage.setOnClickListener(this);
        this.ll_setting_4g.setOnClickListener(this);
    }

    private void initViewAndData() {
        MyCamera myCamera = this.mMyCamera;
        if (myCamera != null) {
            this.mFloatingWindow = new FloatingWindow(this, myCamera, HiTools.getScreenW(this), false);
        }
        this.mTop = HiTools.dip2px(this, 105.0f);
        this.lastDis = HiTools.dip2px(this, 5.0f);
        this.tv_uid.setText(this.mMyCamera.getUid());
        this.tv_head_uid.setText(this.mMyCamera.getUid());
        if (this.mMyCamera.isBindCurrentAccount() == 1) {
            this.btn_delete_camera.setVisibility(0);
        } else {
            this.btn_delete_camera.setVisibility(8);
        }
        if (this.mMyCamera.getCameraLevel() == 1 && this.mMyCamera.isBindCurrentAccount() == 2) {
            this.iv_share.setVisibility(8);
        } else {
            this.iv_share.setVisibility(0);
        }
    }

    private void initHeadView() {
        this.bitmap = this.mMyCamera.snapshot;
        new Thread() {
            @Override
            public void run() {
                if (SettingActivity.this.mMyCamera.getIs_ThreeEyes()) {
                    if (SettingActivity.this.mMyCamera.snapshot2 != null) {
                        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                        SettingActivity.this.mMyCamera.snapshot2.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
                        SettingActivity.this.bytes = byteArrayOutputStream.toByteArray();
                    }
                } else if (SettingActivity.this.mMyCamera.snapshot != null) {
                    ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
                    SettingActivity.this.mMyCamera.snapshot.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream2);
                    SettingActivity.this.bytes = byteArrayOutputStream2.toByteArray();
                }
                SettingActivity.this.mHandler.sendEmptyMessage(2456);
            }
        }.start();
        if (this.mMyCamera.getIs_ThreeEyes()) {
            if (this.mMyCamera.snapshot2 != null) {
                this.iv_head_icon.setImageBitmap(this.mMyCamera.snapshot2);
                return;
            } else {
                this.iv_head_icon.setImageResource(R.mipmap.videoclip);
                return;
            }
        }
        if (this.mMyCamera.snapshot != null) {
            this.iv_head_icon.setImageBitmap(this.mMyCamera.snapshot);
        } else {
            this.iv_head_icon.setImageResource(R.mipmap.videoclip);
        }
    }

    private void getIntentData() {
        String stringExtra = getIntent().getStringExtra(HiDataValue.EXTRAS_KEY_UID);
        this.autoShare = getIntent().getStringExtra("autoShare");
        if (TextUtils.isEmpty(stringExtra)) {
            MyToast.showToast(this, "UID is Empty");
            finish();
            return;
        }
        Iterator<MyCamera> it = HiDataValue.CameraList.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            MyCamera next = it.next();
            if (stringExtra.equalsIgnoreCase(next.getUid())) {
                this.mMyCamera = next;
                break;
            }
        }
        if (HiTools.cameraWhetherNull(this.mMyCamera, this)) {
            return;
        }
        if (this.mMyCamera.appGetCommandFunction(HiChipDefines.HI_P2P_GET_WIFI_PARAM_NEWPWD255_EXT1)) {
            this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_WIFI_PARAM_NEWPWD255_EXT1, new byte[0]);
        } else {
            this.mMyCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_WIFI_PARAM, null);
        }
        if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_CLOUD_CHECK)) {
            if (this.mMyCamera.getCloudType() == 1) {
                this.ll_cloud.setVisibility(0);
                this.isSupportCloud = true;
            } else if (this.mMyCamera.getCloudType() == 2 && !TextUtils.isEmpty(this.mMyCamera.getEcsIp()) && this.mMyCamera.getEcsPort() != 0) {
                this.ll_cloud.setVisibility(0);
                this.isSupportCloud = true;
            }
        } else if (this.mMyCamera.appGetCommandFunction(16798) && Locale.getDefault().getLanguage().equals("zh") && Locale.getDefault().getCountry().equals("CN")) {
            this.ll_cloud.setVisibility(0);
            this.isSupportCloud = true;
        }
        if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_SUPPORT_4G)) {
            this.ll_setting_4g.setVisibility(0);
            this.ll_setting_wifi.setVisibility(8);
        }
        if (this.mMyCamera.appGetCommandFunction(ConstantCommand.HI_P2P_SUPPORT_5G)) {
            this.isSupport5G = true;
            this.tv_4g.setText(getString(R.string.g5_set));
            this.ll_setting_4g.setVisibility(0);
            this.ll_setting_wifi.setVisibility(8);
        }
    }

    @Override
    public void onClick(View view) {
        Intent intent;
        if (this.et_nickname.hasFocus()) {
            if (view.getId() == R.id.iv_return) {
                finish();
            } else {
                handDown();
                return;
            }
        }
        int id = view.getId();
        switch (id) {
            case R.id.btn_delete_camera:
                if (this.mMyCamera.getConnectState() != 4) {
                    return;
                }
                showDeleteCamera();
                return;
            case R.id.iv_auto_share:
            case R.id.iv_share:
                Intent intent2 = new Intent(this, (Class<?>) ShareQRDetCodeActivity.class);
                intent2.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                startActivity(intent2);
                return;
            case R.id.iv_edit_name:
                handIvEditName();
                return;
            case R.id.iv_head_icon:
                if (this.canToLive) {
                    MyCamera myCamera = this.mMyCamera;
                    if (myCamera != null && myCamera.getConnectState() == 4) {
                        this.mMyCamera.isFirstEnterLive = SharePreUtils.getBoolean(HiDataValue.CACHE, this, this.mMyCamera.getUid() + "isFirstEnterLive", true);
                        if (this.mMyCamera.isWallMounted) {
                            Intent intent3 = new Intent(this, (Class<?>) WallMountedActivity.class);
                            intent3.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                            startActivity(intent3);
                            finish();
                            return;
                        }
                        if (this.mMyCamera.isFishEye()) {
                            int i = SharePreUtils.getInt(Constant.INSTALLMODE, this, this.mMyCamera.getUid());
                            this.mMyCamera.mInstallMode = i != -1 ? i : 0;
                            Intent intent4 = new Intent(this, (Class<?>) FishEyeActivity.class);
                            intent4.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                            startActivity(intent4);
                            finish();
                            return;
                        }
                        if (HiTools.isFastClick()) {
                            return;
                        }
                        HiDataValue.isNeedkillNoMain = false;
                        Intent intent5 = new Intent();
                        if (!this.mMyCamera.getdevDual()) {
                            if (!this.mMyCamera.getdevSplice()) {
                                intent5.setClass(this, LiveViewActivity.class);
                            } else {
                                intent5.setClass(this, SpliceLiveViewActivity.class);
                            }
                        } else if (this.mMyCamera.getIs_ThreeEyes()) {
                            intent5.setClass(this, DualLiveViewActivity_ThreeEyes.class);
                        } else {
                            intent5.setClass(this, DualLiveViewActivity.class);
                        }
                        intent5.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                        startActivity(intent5);
                        finish();
                        return;
                    }
                    MyToast.showToast(this, getString(R.string.current_disconnect));
                    return;
                }
                return;
            case R.id.iv_return:
                finish();
                return;
            case R.id.ll_alarm_setting:
                Intent intent6 = new Intent(this, (Class<?>) AlarmManageAndNotiActivity.class);
                intent6.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                intent6.putExtra("isSupportCloud", this.isSupportCloud);
                startActivity(intent6);
                return;
            case R.id.ll_buy_storage:
                HiLogcatUtil.dTag(HiLogcatUtil.TAG_Google, this.mMyCamera.getUid() + " setting click cloudType: " + this.mMyCamera.getCloudType());
                if (this.mMyCamera.getCloudType() == 2) {
                    intent = new Intent(this, (Class<?>) CloudInfoGoogleActivity.class);
                } else {
                    intent = new Intent(this, (Class<?>) CloudStorageInformationActivity.class);
                }
                intent.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                startActivity(intent);
                return;
            case R.id.ll_setting_4g:
                Intent intent7 = new Intent(this, (Class<?>) FourthGSettingActivity.class);
                intent7.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                intent7.putExtra("isSupport5G", this.isSupport5G);
                startActivity(intent7);
                return;
            case R.id.rl_setting_audio:
                Intent intent8 = new Intent(this, (Class<?>) AudioSettingActivity.class);
                intent8.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                startActivity(intent8);
                return;
            default:
                switch (id) {
                    case R.id.ll_setting_device_info:
                        Intent intent9 = new Intent(this, (Class<?>) DeviceInfoActivity.class);
                        intent9.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                        startActivity(intent9);
                        return;
                    case R.id.ll_setting_floating:
                        MyCamera myCamera2 = this.mMyCamera;
                        if (myCamera2 == null || myCamera2.getConnectState() != 4) {
                            return;
                        }
                        clickFloatingWindow();
                        return;
                    default:
                        switch (id) {
                            case R.id.ll_setting_password:
                                Intent intent10 = new Intent(this, (Class<?>) PasswordSettingActivity.class);
                                intent10.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                                startActivity(intent10);
                                return;
                            case R.id.ll_setting_plan_video:
                                Intent intent11 = new Intent(this, (Class<?>) PlanVideoActivity.class);
                                intent11.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                                startActivity(intent11);
                                return;
                            case R.id.ll_setting_sd_card:
                                Intent intent12 = new Intent(this, (Class<?>) SDCardSettingActivity.class);
                                intent12.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                                startActivity(intent12);
                                return;
                            case R.id.ll_setting_system:
                                Intent intent13 = new Intent(this, (Class<?>) SystemSettingActivity.class);
                                intent13.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                                startActivity(intent13);
                                return;
                            case R.id.ll_setting_time:
                                Intent intent14 = new Intent(this, (Class<?>) TimeSettingActivity.class);
                                intent14.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                                startActivity(intent14);
                                return;
                            case R.id.ll_setting_video:
                                Intent intent15 = new Intent(this, (Class<?>) VideoSettingActivity.class);
                                intent15.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                                startActivity(intent15);
                                return;
                            case R.id.ll_setting_wifi:
                                Intent intent16 = new Intent(this, (Class<?>) WiFiSettingActivity.class);
                                intent16.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
                                startActivity(intent16);
                                return;
                            default:
                                return;
                        }
                }
        }
    }

    private void showDeleteCamera() {
        final NiftyDialogBuilder niftyDialogBuilder = NiftyDialogBuilder.getInstance(this);
        niftyDialogBuilder.withTitle(getString(R.string.confirm_delete)).withMessage(this.mMyCamera.getUid() + getString(R.string.newline_delete)).withButton1Text(getString(R.string.NO)).withButton2Text(getString(R.string.YES));
        niftyDialogBuilder.setButton1Click(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                NiftyDialogBuilder.this.dismiss();
            }
        });
        niftyDialogBuilder.setButton2Click(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                SettingActivity.this.lambda$showDeleteCamera$1$SettingActivity(niftyDialogBuilder, view);
            }
        });
        niftyDialogBuilder.show();
    }

    public void lambda$showDeleteCamera$1$SettingActivity(NiftyDialogBuilder niftyDialogBuilder, View view) {
        niftyDialogBuilder.dismiss();
        showjuHuaDialog();
        if (this.mMyCamera.getPushState() > 0) {
            this.mMyCamera.bindPushState(false, this.bindPushResult);
        }
        HiTools.removeAllShareKey(this, this.mMyCamera);
        handUnbindAccount(this.mMyCamera);
        sendUnRegister(this.mMyCamera, 0);
        Message obtainMessage = this.mHandler.obtainMessage();
        obtainMessage.what = 65537;
        obtainMessage.obj = this.mMyCamera;
        this.mHandler.sendMessageDelayed(obtainMessage, 1000L);
    }

    private void handUnbindAccount(MyCamera myCamera) {
        if (myCamera.getCommandFunction(16826)) {
            myCamera.sendIOCtrl(16825, new byte[256]);
        } else if (myCamera.getCommandFunction(HiChipDefines.HI_P2P_GET_FTP_PARAM_EXT_NEWPWD255_EXT)) {
            byte[] bArr = new byte[732];
            System.arraycopy(Packet.intToByteArray_Little(21), 0, bArr, 68, 4);
            myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_FTP_PARAM_EXT_NEWPWD255_EXT, bArr);
        } else if (myCamera.getCommandFunction(HiChipDefines.HI_P2P_GET_FTP_PARAM_EXT)) {
            byte[] bArr2 = new byte[476];
            System.arraycopy(Packet.intToByteArray_Little(21), 0, bArr2, 68, 4);
            myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_FTP_PARAM_EXT, bArr2);
        } else if (myCamera.getCommandFunction(HiChipDefines.HI_P2P_GET_FTP_PARAM)) {
            byte[] bArr3 = new byte[456];
            System.arraycopy(Packet.intToByteArray_Little(21), 0, bArr3, 68, 4);
            myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_FTP_PARAM, bArr3);
        }
        unBindDevToService(myCamera);
    }

    private void unBindDevToService(MyCamera myCamera) {
        if (myCamera == null || TextUtils.isEmpty(LoginUserInfo.getInstance().getToken(this))) {
            return;
        }
        UserApiFactory.getApi().DvUnBind(new UnbindDevBean(LoginUserInfo.getInstance().getToken(this), this.mMyCamera.getUid(), DateUtils.getDate())).enqueue(new MyCallBack<EmptyBean>() {
            @Override
            public void onError(Throwable th, String str) {
            }

            @Override
            public void onSuccess(EmptyBean emptyBean) {
            }
        });
    }

    private void handIvEditName() {
        this.et_nickname.setFocusable(true);
        this.et_nickname.setFocusableInTouchMode(true);
        this.et_nickname.requestFocus();
        if (!TextUtils.isEmpty(this.et_nickname.getText().toString())) {
            EditText editText = this.et_nickname;
            editText.setSelection(editText.getText().toString().length());
        }
        ((InputMethodManager) getSystemService("input_method")).showSoftInput(this.et_nickname, 2);
    }

    private boolean handDown() {
        this.et_nickname.clearFocus();
        this.et_nickname.setFocusable(false);
        ((InputMethodManager) getSystemService("input_method")).hideSoftInputFromWindow(this.et_nickname.getWindowToken(), 0);
        String trim = this.et_nickname.getText().toString().trim();
        this.str_nick = trim;
        if (trim.length() == 0) {
            showAlert(getText(R.string.tips_null_nike));
            return true;
        }
        if (!this.mMyCamera.getNikeName().equals(this.str_nick)) {
            this.mMyCamera.setNikeName(this.str_nick);
            this.mMyCamera.setPushDevName(this.str_nick);
            this.mMyCamera.updateInDatabase(this);
            this.et_head_nickname.setText(this.str_nick);
        }
        if (this.mMyCamera.getPushState() > 0) {
            this.mMyCamera.bindPushState(true, this.bindPushResult);
        }
        return false;
    }

    protected void sendServer(MyCamera myCamera) {
        if (myCamera.getServerData() == null) {
            myCamera.setServerData("120.24.179.113");
            myCamera.updateServerInDatabase(this);
        }
        if (myCamera.appGetCommandFunction(CamHiDefines.HI_P2P_ALARM_ADDRESS_SET) && myCamera.f987push != null) {
            String[] split = myCamera.f987push.getPushServer().split("\\.");
            if (split.length == 4 && isInteger(split[0]) && isInteger(split[1]) && isInteger(split[2]) && isInteger(split[3])) {
                myCamera.sendIOCtrl(CamHiDefines.HI_P2P_ALARM_ADDRESS_SET, CamHiDefines.HI_P2P_ALARM_ADDRESS.parseContent(myCamera.f987push.getPushServer()));
            }
        }
    }

    public static boolean isInteger(String str) {
        return Pattern.compile("^[-\\+]?[\\d]*$").matcher(str).matches();
    }

    private void sendUnRegister(MyCamera myCamera, int i) {
        if (myCamera.getPushState() != 1 && myCamera.appGetCommandFunction(CamHiDefines.HI_P2P_ALARM_TOKEN_UNREGIST)) {
            myCamera.sendIOCtrl(CamHiDefines.HI_P2P_ALARM_TOKEN_UNREGIST, CamHiDefines.HI_P2P_ALARM_TOKEN_INFO.parseContent(0, myCamera.getPushState(), (int) ((System.currentTimeMillis() / 1000) / 3600), i));
        }
    }

    public void handMsgSessionState(Message message) {
        if (message.arg1 == 0 && HiDataValue.isNeedkillNoMain) {
            this.mHandler.sendEmptyMessageDelayed(ConstantCommand.HI_P2P_GET_DEVICE_WORKING_MODE, 1000L);
        }
    }

    public void updateGroup(GroupBeanUse groupBeanUse) {
        String[] strArr = new String[4];
        for (int i = 0; i < groupBeanUse.getCameraList().length; i++) {
            if (groupBeanUse.getCameraList()[i] != null) {
                strArr[i] = groupBeanUse.getCameraList()[i].getUid();
            }
        }
        GroupBeanSave groupBeanSave = new GroupBeanSave();
        groupBeanSave.setGroupId(groupBeanUse.getGroupId());
        groupBeanSave.setGroupName(groupBeanUse.getGroupName());
        groupBeanSave.setCameraArray(strArr);
        HiTools.updateFourLiveGroup(this, groupBeanSave);
    }

    public void deleteGroup(GroupBeanUse groupBeanUse) {
        HiDataValue.groupList.remove(groupBeanUse);
        GroupBeanSave groupBeanSave = new GroupBeanSave();
        groupBeanSave.setGroupId(groupBeanUse.getGroupId());
        HiTools.deleteFourLiveGroup(this, groupBeanSave);
    }

    public void handIOCTRL(Message message) {
        if (message.arg2 == 0) {
            byte[] byteArray = message.getData().getByteArray("data");
            int i = message.arg1;
            if (i == 12562) {
                dismissjuHuaDialog();
                return;
            }
            if (i == 16643) {
                String encoding = HiTools.getEncoding(new HiChipDefines.HI_P2P_S_WIFI_PARAM(byteArray).strSSID);
                if (TextUtils.isEmpty(encoding)) {
                    return;
                }
                this.tv_current_device_wifi.setText(encoding.trim());
                return;
            }
            if (i != 16762) {
                return;
            }
            String encoding2 = HiTools.getEncoding(new HiChipDefines.HI_P2P_S_WIFI_PARAM_NEWPWD255_EXT1(byteArray).strSSID);
            if (TextUtils.isEmpty(encoding2)) {
                return;
            }
            this.tv_current_device_wifi.setText(encoding2.trim());
            return;
        }
        if (message.arg1 != 4097) {
            return;
        }
        HiLogcatUtil.e("HI_P2P_START_LIVE ERROR ");
        HiLogcatUtil.d("mMyCamera.getVideoQuality(): " + this.mMyCamera.getVideoQuality());
        HiLogcatUtil.e("#########################  APP RECEIVE HI_P2P_START_LIVE ERROR ##############################");
        this.mHandler.sendEmptyMessageDelayed(ConstantCommand.HI_P2P_SET_SCENE_MODE, 1000L);
    }

    protected void sendRegisterToken(MyCamera myCamera) {
        if (myCamera.getPushState() == 1 || myCamera.getPushState() == 0 || !myCamera.appGetCommandFunction(CamHiDefines.HI_P2P_ALARM_TOKEN_REGIST)) {
            return;
        }
        myCamera.sendIOCtrl(CamHiDefines.HI_P2P_ALARM_TOKEN_REGIST, CamHiDefines.HI_P2P_ALARM_TOKEN_INFO.parseContent(0, myCamera.getPushState(), (int) ((System.currentTimeMillis() / 1000) / 3600), 1));
    }

    @Override
    public void onPause() {
        super.onPause();
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService("input_method");
        if (inputMethodManager.isActive()) {
            inputMethodManager.hideSoftInputFromWindow(this.et_nickname.getWindowToken(), 0);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        FloatingWindow floatingWindow = this.mFloatingWindow;
        if (floatingWindow != null) {
            floatingWindow.dismiss();
        }
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        FloatingWindow floatingWindow = this.mFloatingWindow;
        if (floatingWindow != null) {
            floatingWindow.dismiss();
        }
        MyCamera myCamera = this.mMyCamera;
        if (myCamera != null) {
            myCamera.stopListening();
            this.mMyCamera.stopLiveShow();
        }
    }

    @Override
    public void receiveSessionState(HiCamera hiCamera, int i) {
        if (this.mMyCamera != hiCamera) {
            return;
        }
        Message obtainMessage = this.mHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_SESSION_STATE;
        obtainMessage.arg1 = i;
        obtainMessage.obj = hiCamera;
        this.mHandler.sendMessage(obtainMessage);
    }

    @Override
    public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
        if (hiCamera != this.mMyCamera) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putByteArray("data", bArr);
        Message obtainMessage = this.mHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL;
        obtainMessage.obj = hiCamera;
        obtainMessage.arg1 = i;
        obtainMessage.arg2 = i2;
        obtainMessage.setData(bundle);
        this.mHandler.sendMessage(obtainMessage);
    }

    @Override
    public void onScrollChanged(ObservableScrollView observableScrollView, int i, int i2, int i3, int i4) {
        if (i2 <= this.mTop) {
            this.canToLive = false;
            this.rl_head_name.animate().translationY(-i2).setDuration(0L).start();
            float f = 1.0f;
            float f2 = (1.0f - (i2 / this.mTop)) - 0.1f;
            if (i2 < this.lastDis) {
                this.canToLive = true;
            } else {
                f = f2;
            }
            this.shadowlayout.animate().scaleX(f).scaleY(f).setDuration(0L).start();
            this.shadowlayout.animate().alpha(f).setDuration(0L).start();
            return;
        }
        this.canToLive = false;
        this.rl_head_name.animate().translationY(-this.mTop).setDuration(0L).start();
        this.shadowlayout.animate().scaleX(0.0f).scaleY(0.0f).setDuration(0L).start();
        this.shadowlayout.animate().alpha(0.0f).setDuration(0L).start();
    }

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i != 9999 || Build.VERSION.SDK_INT < 23 || Settings.canDrawOverlays(getApplicationContext())) {
            return;
        }
        Toast.makeText(getApplicationContext(), getString(R.string.floating_pfail), 0).show();
    }

    private void clickFloatingWindow() {
        if (!HiTools.commonROMPermissionCheck(this)) {
            new DialogUtilsCamHiPro(this).title(getString(R.string.tip_reminder)).message(getString(R.string.floating_tips)).cancelText(getString(R.string.cancel)).setCancelOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    SharePreUtils.putBoolean(HiDataValue.CACHE, SettingActivity.this.getApplicationContext(), "isShowFloatingPermission", true);
                }
            }).sureText(getString(R.string.open)).setSureOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    SettingActivity.this.startActivityForResult(new Intent("android.settings.action.MANAGE_OVERLAY_PERMISSION", Uri.parse("package:" + SettingActivity.this.getPackageName())), 9999);
                }
            }).build().show();
            return;
        }
        this.mFloatingWindow.setReady(true);
        new Thread() {
            @Override
            public void run() {
                SettingActivity.this.mMyCamera.startLiveShow(SettingActivity.this.mMyCamera.getVideoQuality(), SettingActivity.this.mFloatingWindow.getMonitor());
            }
        }.start();
        this.mFloatingWindow.showFloatingWindowView(false);
        HiDataValue.isNeedkillNoMain = true;
        Intent intent = new Intent();
        intent.setAction("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.HOME");
        startActivity(intent);
    }
}