导航菜单

页面标题

页面副标题

Vi App v10.18.0 - ActivateDeviceFragment.java 源代码

正在查看: Vi App v10.18.0 应用的 ActivateDeviceFragment.java JAVA 源代码文件

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


package com.yupptv.ott.fragments;

import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.WindowCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
import com.yupptv.ott.OTTApplication;
import com.yupptv.ott.R;
import com.yupptv.ott.adapters.RecyclerViewAdapter;
import com.yupptv.ott.analytics.MyRecoManager;
import com.yupptv.ott.enums.DialogType;
import com.yupptv.ott.enums.ListType;
import com.yupptv.ott.interfaces.DialogListener;
import com.yupptv.ott.utils.APIUtils;
import com.yupptv.ott.utils.CleverTap;
import com.yupptv.ott.utils.Constants;
import com.yupptv.ott.utils.NavigationUtils;
import com.yupptv.ott.views.LineSpinFadeLoaderView;
import com.yupptv.ottsdk.OttSDK;
import com.yupptv.ottsdk.managers.User.UserManager;
import com.yupptv.ottsdk.model.DeviceLimitPopupConfig;
import com.yupptv.ottsdk.model.Error;
import com.yupptv.ottsdk.model.Menu;
import com.yupptv.ottsdk.model.User;
import com.yupptv.ottsdk.model.user.Configs;
import com.yupptv.ottsdk.model.user.UserLinkedDevicesWithVersion;
import java.util.HashMap;
import java.util.List;

public class ActivateDeviceFragment extends AppCompatActivity implements DecoratedBarcodeView.TorchListener, View.OnClickListener {
    private AppCompatButton activateDeviceUsingCode;
    private RelativeLayout activateWithCodeRelativeLayout;
    private AppCompatEditText activationCodeTI;
    public boolean activeScreensVisible;
    private DecoratedBarcodeView barcodeScannerView;
    private CaptureManager capture;
    public Configs configs;
    private TextView connectWithDeviceActivationCode;
    public TextView currentDeviceTV;
    public View divider;
    private ImageView goBackToPreviousScreen;
    private boolean isShowingQRScanner;
    public LinearLayout linkedDeviceLL;
    public RecyclerView linkedDevicesRecyclerView;
    public UserLinkedDevicesWithVersion linkedDevicesV2;
    public RecyclerViewAdapter mAdapter;
    public Toolbar mToolbar;
    public LinearLayout orDivider_layout;
    public OttSDK ottSDK;
    public LineSpinFadeLoaderView progressBar;
    private TextView scanQRCode;
    public String source;
    private Toast toast;
    public ImageView toolbarLogo;
    public TextView toolbarTitle;
    public int userLinkedDeviceSize;
    public String mobileNumber = "";
    public String activationCode = "";
    public int maxDeviceLimit = Integer.MAX_VALUE;
    public boolean popupEvent = false;

    public void activateDeviceAPICall(String str, final boolean z) {
        OttSDK ottSDK = OttSDK.getInstance();
        if (ottSDK == null || ottSDK.getUserManager() == null) {
            return;
        }
        ottSDK.getUserManager().validatePasscode(str, new UserManager.UserCallback<String>() {
            @Override
            public void onEmptySuccess() {
                com.yupptv.ottsdk.managers.User.a.a(this);
            }

            @Override
            public void onFailure(Error error) {
                if (error != null && error.getMessage() != null) {
                    ?? r0 = ActivateDeviceFragment.this;
                    ((ActivateDeviceFragment) r0).toast = Toast.makeText((Context) r0, " " + error.getMessage(), 0);
                    ActivateDeviceFragment.this.toast.setGravity(80, 0, 100);
                    ActivateDeviceFragment.this.toast.show();
                }
                if (z) {
                    ActivateDeviceFragment.this.setResult(53);
                    ActivateDeviceFragment.this.finish();
                }
                NavigationUtils.logKibanaError("ActivateDeviceFragment", "API", "/service/api/auth/validate/passcode", "NA", "NA", "NA", com.yupptv.ott.f.a(error, new StringBuilder("")), error.getMessage());
            }

            @Override
            public void onSuccess(String str2) {
                ?? r0 = ActivateDeviceFragment.this;
                ((ActivateDeviceFragment) r0).toast = Toast.makeText((Context) r0, " " + str2, 0);
                ActivateDeviceFragment.this.toast.setGravity(80, 0, 100);
                ActivateDeviceFragment.this.toast.show();
                ActivateDeviceFragment.this.finish();
            }
        });
    }

    private void destroyCaptureManager() {
        CaptureManager captureManager = this.capture;
        if (captureManager != null) {
            captureManager.onDestroy();
        }
    }

    private void initViews() {
        this.mToolbar = findViewById(R.id.toolBarLayout);
        this.orDivider_layout = (LinearLayout) findViewById(R.id.orDivider_layout);
        this.toolbarTitle = (TextView) findViewById(R.id.toolbar_title);
        this.toolbarLogo = (ImageView) findViewById(R.id.toolbar_logo);
        this.barcodeScannerView = findViewById(R.id.zxing_barcode_scanner);
        this.goBackToPreviousScreen = (ImageView) findViewById(R.id.goBackToPreviousScreen);
        this.connectWithDeviceActivationCode = (TextView) findViewById(R.id.connectWithDeviceActivationCode);
        this.activateWithCodeRelativeLayout = (RelativeLayout) findViewById(R.id.activateWithCodeRelativeLayout);
        this.scanQRCode = (TextView) findViewById(R.id.scanQRCode);
        this.linkedDevicesRecyclerView = findViewById(R.id.fragment_recycler_view);
        this.currentDeviceTV = (TextView) findViewById(R.id.current_deviceTV);
        this.progressBar = (LineSpinFadeLoaderView) findViewById(R.id.progressBar);
        this.linkedDeviceLL = (LinearLayout) findViewById(R.id.linked_device_ll);
        this.divider = findViewById(R.id.divider_line);
        this.activateDeviceUsingCode = findViewById(R.id.activateDeviceUsingCode);
        this.activationCodeTI = findViewById(R.id.activationCode);
        this.barcodeScannerView.setTorchListener(this);
        this.barcodeScannerView.setStatusText(getResources().getString(R.string.scan_with_app));
        this.goBackToPreviousScreen.setOnClickListener(this);
        this.toolbarLogo.setOnClickListener(this);
        this.connectWithDeviceActivationCode.setOnClickListener(this);
        this.scanQRCode.setOnClickListener(this);
        this.activateDeviceUsingCode.setOnClickListener(this);
        this.linkedDevicesRecyclerView.setHasFixedSize(true);
        this.linkedDevicesRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        this.linkedDevicesRecyclerView.setItemAnimator(new DefaultItemAnimator());
        User loggedUser = APIUtils.getUtilPreferenceManager(this).getLoggedUser();
        if (loggedUser != null && loggedUser.getPhoneNumber() != null) {
            this.mobileNumber = loggedUser.getPhoneNumber();
            this.mobileNumber = "91" + this.mobileNumber;
        }
        this.source = "hamburger menu";
        if (OTTApplication.isFromActivateDeviceFragment || this.popupEvent) {
            OTTApplication.isFromActivateDeviceFragment = false;
            this.popupEvent = false;
        } else {
            ctEventPopup("hamburger menu", "manage devices", "", "popup displayed");
        }
        showLinkedDevices(this.mobileNumber);
        Configs utilAppConfigurations = APIUtils.getUtilAppConfigurations(this);
        this.configs = utilAppConfigurations;
        if (utilAppConfigurations == null || utilAppConfigurations.getMaxSessionCount() == null) {
            return;
        }
        this.maxDeviceLimit = this.configs.getMaxSessionCount().intValue();
    }

    private void initializeScanner(Bundle bundle) {
        CaptureManager captureManager = new CaptureManager(this, this.barcodeScannerView);
        this.capture = captureManager;
        captureManager.initializeFromIntent(getIntent(), bundle);
        this.capture.setShowMissingCameraPermissionDialog(false);
        this.capture.decode();
    }

    private void showDialog(String str) {
        final String str2;
        ctEventPopup(this.source, "device limit reached", str, "popup displayed");
        DeviceLimitPopupConfig deviceLimitPopupConfig = APIUtils.getUtilPreferenceManager(this).getDeviceLimitPopupConfig();
        HashMap hashMap = new HashMap();
        if (deviceLimitPopupConfig != null) {
            str2 = deviceLimitPopupConfig.getButton();
            hashMap.put(Constants.DIALOG_MSG, deviceLimitPopupConfig.getTitle());
            hashMap.put(Constants.DIALOG_SUBTITLE, deviceLimitPopupConfig.getSubtitle());
            hashMap.put(Constants.DIALOG_BUTTON_LABEL1, deviceLimitPopupConfig.getButton());
        } else {
            str2 = "";
        }
        NavigationUtils.showDialog((FragmentActivity) this, DialogType.LINKED_DEVICE_LIMIT_DIALOG, hashMap, new DialogListener() {
            @Override
            public void itemClicked(boolean z, int i2, int i3) {
            }

            @Override
            public void itemClicked(boolean z, int i2, HashMap hashMap2) {
                ActivateDeviceFragment activateDeviceFragment = ActivateDeviceFragment.this;
                activateDeviceFragment.ctEventPopup(activateDeviceFragment.source, "device limit reached", str2, "button clicked");
            }
        });
    }

    public void ctEventPopup(String str, String str2, String str3, String str4) {
        CleverTap.moviesEventPopUp("", str2, str4, "active screens", str3, "", "", "na", "", "", str, null, MyRecoManager.getInstance().getTAB_NAME(), "", "na", -1, -1, null, "");
    }

    public void hideKeyboard() {
        View currentFocus = getCurrentFocus();
        if (currentFocus != null) {
            ((InputMethodManager) currentFocus.getContext().getSystemService("input_method")).hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
        }
    }

    public void onBackPressed() {
        if (!this.isShowingQRScanner) {
            ctEventPopup(this.source, "manage devices", "na", "popup closed");
            super/*androidx.activity.ComponentActivity*/.onBackPressed();
        } else {
            this.orDivider_layout.setVisibility(0);
            this.isShowingQRScanner = false;
            this.activateWithCodeRelativeLayout.setVisibility(0);
            this.barcodeScannerView.setVisibility(8);
        }
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.toolbar_logo || id == R.id.goBackToPreviousScreen) {
            if (!this.isShowingQRScanner) {
                destroyCaptureManager();
                ctEventPopup(this.source, "manage devices", "na", "popup closed");
                finish();
                return;
            } else {
                this.orDivider_layout.setVisibility(0);
                this.isShowingQRScanner = false;
                this.activateWithCodeRelativeLayout.setVisibility(0);
                this.barcodeScannerView.setVisibility(8);
                return;
            }
        }
        if (id == R.id.connectWithDeviceActivationCode) {
            this.isShowingQRScanner = false;
            this.barcodeScannerView.setVisibility(8);
            this.activateWithCodeRelativeLayout.setVisibility(0);
            return;
        }
        if (id == R.id.scanQRCode) {
            ctEventPopup(this.source, "manage devices", this.scanQRCode.getText().toString(), "button clicked");
            hideKeyboard();
            UserLinkedDevicesWithVersion userLinkedDevicesWithVersion = this.linkedDevicesV2;
            if (userLinkedDevicesWithVersion != null && !userLinkedDevicesWithVersion.getDeviceList().isEmpty() && this.userLinkedDeviceSize >= this.maxDeviceLimit) {
                showDialog(this.scanQRCode.getText().toString());
                return;
            }
            this.orDivider_layout.setVisibility(8);
            this.isShowingQRScanner = true;
            CaptureManager captureManager = this.capture;
            if (captureManager != null) {
                captureManager.onResume();
            }
            this.activateWithCodeRelativeLayout.setVisibility(8);
            this.barcodeScannerView.setVisibility(0);
            return;
        }
        if (id == R.id.activateDeviceUsingCode) {
            if (this.activationCodeTI.getText().toString().trim().length() > 0) {
                ctEventPopup(this.source, "manage devices", this.activateDeviceUsingCode.getText().toString(), "button clicked");
            }
            if (this.userLinkedDeviceSize >= this.maxDeviceLimit) {
                showDialog(this.activateDeviceUsingCode.getText().toString());
                return;
            }
            AppCompatEditText appCompatEditText = this.activationCodeTI;
            if (appCompatEditText != null && appCompatEditText.getText().toString().trim().length() > 0) {
                String obj = this.activationCodeTI.getText().toString();
                this.activationCode = obj;
                activateDeviceAPICall(obj, false);
            } else {
                Toast makeText = Toast.makeText((Context) this, (CharSequence) getResources().getString(R.string.enter_code), 0);
                this.toast = makeText;
                makeText.setGravity(80, 0, 100);
                this.toast.show();
            }
        }
    }

    public void onConfigurationChanged(@NonNull Configuration configuration) {
        super.onConfigurationChanged(configuration);
        setRequestedOrientation(1);
    }

    public void onCreate(Bundle bundle) {
        super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
        setRequestedOrientation(1);
        overridePendingTransition(0, 0);
        setContentView(R.layout.vilite_fragment_activate_device);
        this.ottSDK = APIUtils.getOTTSdkInstance(this);
        if (getIntent() != null && getIntent().hasExtra("activationCode") && getIntent().getStringExtra("activationCode").trim().length() > 0) {
            this.activationCode = getIntent().getStringExtra("activationCode");
        }
        if (getIntent() != null && getIntent().hasExtra("popupEvent")) {
            this.popupEvent = Boolean.parseBoolean(getIntent().getStringExtra("popupEvent"));
        }
        initViews();
        WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
        OttSDK ottSDK = this.ottSDK;
        if (ottSDK != null && ottSDK.getPreferenceManager() != null && this.ottSDK.getPreferenceManager().getHmenus() != null) {
            List<Menu> hmenus = this.ottSDK.getPreferenceManager().getHmenus();
            int i2 = 0;
            while (true) {
                if (i2 >= hmenus.size()) {
                    break;
                }
                if (hmenus.get(i2).getCode().equalsIgnoreCase("activate_device")) {
                    this.toolbarTitle.setText(hmenus.get(i2).getDisplayText());
                    break;
                }
                i2++;
            }
        }
        this.orDivider_layout.setVisibility(0);
        initializeScanner(bundle);
    }

    public void onDestroy() {
        super.onDestroy();
        if (this.activeScreensVisible) {
            this.activeScreensVisible = false;
        }
        destroyCaptureManager();
    }

    public boolean onKeyDown(int i2, KeyEvent keyEvent) {
        return this.barcodeScannerView.onKeyDown(i2, keyEvent) || super.onKeyDown(i2, keyEvent);
    }

    public void onPause() {
        super/*androidx.fragment.app.FragmentActivity*/.onPause();
        CaptureManager captureManager = this.capture;
        if (captureManager == null || !this.isShowingQRScanner) {
            return;
        }
        captureManager.onPause();
    }

    public void onRequestPermissionsResult(int i2, @NonNull String[] strArr, @NonNull int[] iArr) {
        super/*androidx.fragment.app.FragmentActivity*/.onRequestPermissionsResult(i2, strArr, iArr);
        this.capture.onRequestPermissionsResult(i2, strArr, iArr);
    }

    public void onResume() {
        super/*androidx.fragment.app.FragmentActivity*/.onResume();
        CaptureManager captureManager = this.capture;
        if (captureManager == null || !this.isShowingQRScanner) {
            return;
        }
        captureManager.onResume();
    }

    public void onSaveInstanceState(Bundle bundle) {
        super/*androidx.activity.ComponentActivity*/.onSaveInstanceState(bundle);
        CaptureManager captureManager = this.capture;
        if (captureManager == null || !this.isShowingQRScanner) {
            return;
        }
        captureManager.onSaveInstanceState(bundle);
    }

    public void onTorchOff() {
    }

    public void onTorchOn() {
    }

    public void showLinkedDevices(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        showProgress(true);
        this.divider.setVisibility(8);
        this.linkedDeviceLL.setVisibility(8);
        APIUtils.getOTTSdkInstance(getApplicationContext()).getUserManager().getUserLinkedDevicesWithVersion(1, str.trim(), "mobile", new UserManager.UserCallback<UserLinkedDevicesWithVersion>() {
            @Override
            public void onEmptySuccess() {
                com.yupptv.ottsdk.managers.User.a.a(this);
            }

            @Override
            public void onFailure(Error error) {
                ActivateDeviceFragment.this.showProgress(false);
                if (!TextUtils.isEmpty(ActivateDeviceFragment.this.activationCode)) {
                    ActivateDeviceFragment activateDeviceFragment = ActivateDeviceFragment.this;
                    activateDeviceFragment.activateDeviceAPICall(activateDeviceFragment.activationCode, true);
                }
                NavigationUtils.logKibanaError("ActivateDeviceFragment", "API", "/service/api/auth/linked/v3/devices/list", "NA", "NA", "NA", com.yupptv.ott.f.a(error, new StringBuilder("")), error.getMessage());
            }

            @Override
            public void onSuccess(UserLinkedDevicesWithVersion userLinkedDevicesWithVersion) {
                if (userLinkedDevicesWithVersion == null || userLinkedDevicesWithVersion.getDeviceList().size() <= 0) {
                    ActivateDeviceFragment.this.divider.setVisibility(8);
                    ActivateDeviceFragment.this.linkedDeviceLL.setVisibility(8);
                } else {
                    ActivateDeviceFragment.this.userLinkedDeviceSize = userLinkedDevicesWithVersion.getDeviceList().size();
                    if (!TextUtils.isEmpty(ActivateDeviceFragment.this.activationCode)) {
                        ActivateDeviceFragment activateDeviceFragment = ActivateDeviceFragment.this;
                        activateDeviceFragment.activateDeviceAPICall(activateDeviceFragment.activationCode, true);
                    }
                    ActivateDeviceFragment activateDeviceFragment2 = ActivateDeviceFragment.this;
                    activateDeviceFragment2.linkedDevicesV2 = userLinkedDevicesWithVersion;
                    activateDeviceFragment2.divider.setVisibility(0);
                    ActivateDeviceFragment.this.linkedDeviceLL.setVisibility(0);
                    if (userLinkedDevicesWithVersion.getData().getSubtitle() != null) {
                        ActivateDeviceFragment.this.currentDeviceTV.setText(Html.fromHtml(userLinkedDevicesWithVersion.getData().getSubtitle().replace("\\n", "<br>")));
                    }
                    ?? r1 = ActivateDeviceFragment.this;
                    r1.mAdapter = new RecyclerViewAdapter(r1, ListType.LINKED_DEVICES, userLinkedDevicesWithVersion.getDeviceList(), "activate_device", false);
                    ActivateDeviceFragment activateDeviceFragment3 = ActivateDeviceFragment.this;
                    activateDeviceFragment3.linkedDevicesRecyclerView.setAdapter(activateDeviceFragment3.mAdapter);
                    ActivateDeviceFragment.this.activeScreensVisible = true;
                }
                ActivateDeviceFragment.this.showProgress(false);
            }
        });
    }

    public void showProgress(boolean z) {
        LineSpinFadeLoaderView lineSpinFadeLoaderView = this.progressBar;
        if (lineSpinFadeLoaderView != null) {
            lineSpinFadeLoaderView.setVisibility(z ? 0 : 8);
        }
        LineSpinFadeLoaderView lineSpinFadeLoaderView2 = this.progressBar;
        if (lineSpinFadeLoaderView2 instanceof LineSpinFadeLoaderView) {
            if (z) {
                lineSpinFadeLoaderView2.startAnimation();
            } else {
                lineSpinFadeLoaderView2.stopAnimation();
            }
        }
    }

    public void switchFlashlight(View view) {
    }
}