号簿助手 v4.6.31版本的 MD5 值为:9d7ff98a6bb5cc178eac2df4d1b2f0e0

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


package com.chinatelecom.pim.activity.setting;

import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.Toast;
import com.chinatelecom.pim.R;
import com.chinatelecom.pim.core.CoreManagerFactory;
import com.chinatelecom.pim.core.IConstant;
import com.chinatelecom.pim.core.api.CommandAdapter;
import com.chinatelecom.pim.core.api.GetConfigCommand;
import com.chinatelecom.pim.core.api.QueryClientVersionCommandsMy;
import com.chinatelecom.pim.core.manager.GetconfigUrlManager;
import com.chinatelecom.pim.core.manager.PreferenceKeyManager;
import com.chinatelecom.pim.core.manager.SyncAndroidDeviceManager;
import com.chinatelecom.pim.core.manager.UnlimitedRecoveryManager;
import com.chinatelecom.pim.core.model.PlatformConfig;
import com.chinatelecom.pim.core.threadpool.BackgroundJob;
import com.chinatelecom.pim.core.threadpool.model.Runner;
import com.chinatelecom.pim.core.view.ActivityView;
import com.chinatelecom.pim.foundation.common.model.sync.SyncResponse;
import com.chinatelecom.pim.foundation.lang.model.Notify;
import com.chinatelecom.pim.foundation.lang.model.Packet;
import com.chinatelecom.pim.foundation.lang.model.Theme;
import com.chinatelecom.pim.foundation.lang.net.HttpTemplateFactory;
import com.chinatelecom.pim.foundation.lang.net.impl.DefaultHttpTemplateFactory;
import com.chinatelecom.pim.foundation.lang.utils.DeviceUtils;
import com.chinatelecom.pim.foundation.lang.utils.StringUtils;
import com.chinatelecom.pim.foundation.lang.utils.ToastTool;
import com.chinatelecom.pim.ui.adapter.setting.TimeMachineUnlimitedSubscribeViewAdapter;
import com.chinatelecom.pim.ui.view.dialog.DialogFactory;
import com.ffcs.inapppaylib.PayHelper;
import com.ffcs.inapppaylib.bean.Constants;
import com.ffcs.inapppaylib.bean.response.BaseResponse;
import com.ffcs.inapppaylib.bean.response.PayResponse;
import ctuab.proto.message.GetConfigProto;
import ctuab.proto.message.GetMemberInfoProto;
import ctuab.proto.message.OrderMemberProto;

public class TimeMachineUnlimitedSubscribeActivity extends ActivityView<TimeMachineUnlimitedSubscribeViewAdapter> {
    private static Boolean isFirst = true;
    private String PUserid;
    private String appid;
    private String orderNo;
    private String sign;
    private PreferenceKeyManager preferenceKeyManager = CoreManagerFactory.getInstance().getPreferenceKeyManager();
    private UnlimitedRecoveryManager unlimitedRecoveryManager = CoreManagerFactory.getInstance().getUnlimitedRecoveryManager();
    private SyncAndroidDeviceManager syncAndroidDeviceManager = CoreManagerFactory.getInstance().getSyncAndroidDeviceManager();
    private HttpTemplateFactory httpTemplateFactory = new DefaultHttpTemplateFactory();
    String phoneNum = this.preferenceKeyManager.getAccountSettings().syncAccount().get().tag5.toString();
    String payID = IConstant.Params.PAY_ID;
    private String price = IConstant.SplashUrl.appInnerBrowser;
    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case Constants.RESULT_PAY_SUCCESS:
                    BaseResponse resp = (BaseResponse) msg.obj;
                    if (resp instanceof PayResponse) {
                        PayResponse payResponse = (PayResponse) resp;
                        TimeMachineUnlimitedSubscribeActivity.this.orderNo = payResponse.getOrder_no();
                        if (TimeMachineUnlimitedSubscribeActivity.this.orderNo != null && TimeMachineUnlimitedSubscribeActivity.this.orderNo.length() != 0) {
                            TimeMachineUnlimitedSubscribeActivity.this.getOrderInfos();
                            return;
                        } else {
                            ToastTool.getToast(TimeMachineUnlimitedSubscribeActivity.this).showMessage("购买成功后的订单信息为空");
                            return;
                        }
                    }
                    return;
                case Constants.RESULT_PAY_FAILURE:
                    Boolean unused = TimeMachineUnlimitedSubscribeActivity.isFirst = true;
                    BaseResponse resp2 = (BaseResponse) msg.obj;
                    Toast.makeText(TimeMachineUnlimitedSubscribeActivity.this, resp2.getRes_code() + ":" + resp2.getRes_message(), 0).show();
                    return;
                case Constants.RESULT_VALIDATE_FAILURE:
                    Boolean unused2 = TimeMachineUnlimitedSubscribeActivity.isFirst = true;
                    BaseResponse resp3 = (BaseResponse) msg.obj;
                    Toast.makeText(TimeMachineUnlimitedSubscribeActivity.this, resp3.getRes_code() + ":" + resp3.getRes_message(), 0).show();
                    return;
                default:
                    return;
            }
        }
    };

    @Override
    public TimeMachineUnlimitedSubscribeViewAdapter initializeAdapter() {
        return new TimeMachineUnlimitedSubscribeViewAdapter(this, null);
    }

    @Override
    public void doCreate(Bundle bundle, TimeMachineUnlimitedSubscribeViewAdapter adapter) {
        adapter.setup();
        adapter.setTheme(new Theme());
        initView(adapter);
        setupListner(adapter);
    }

    private void initView(TimeMachineUnlimitedSubscribeViewAdapter adapter) {
        UnlimitedMembershipOpened();
        adapter.getModel().getTvUnlimitedNotes().setText(Html.fromHtml("-云端无限次时光倒流服务依托号簿助手的通讯录自动上传和云存储服务实现,可无限记录用户云端通讯录修改的历史版本;开通此服务后,客户端将手机通讯录的变化即时上传到云端,并记录所有联系人变化的历史版本。<br>-用户可登录<a href='http://pim.189.cn'>号簿助手官网</a>,查看所有通讯录历史版本,并在需要时选择还原。<br>-本服务为号簿助手VIP会员专属权益(仅向中国电信用户开放),需开通VIP会员后方可使用,会员费:5元/月。"));
        adapter.getModel().getTvUnlimitedNotes().setMovementMethod(LinkMovementMethod.getInstance());
    }

    private void UnlimitedMembershipOpened() {
    }

    private void setupListner(TimeMachineUnlimitedSubscribeViewAdapter adapter) {
        adapter.getModel().getHeaderView().getLeftView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TimeMachineUnlimitedSubscribeActivity.this.finish();
            }
        });
        adapter.getModel().getBtUnlimitedRecoverSubscribe().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TimeMachineUnlimitedSubscribeActivity.isFirst.booleanValue()) {
                    Boolean unused = TimeMachineUnlimitedSubscribeActivity.isFirst = false;
                    if (TimeMachineUnlimitedSubscribeActivity.this.needLogin()) {
                        TimeMachineUnlimitedSubscribeActivity.this.createLoginAccountDialog();
                        Boolean unused2 = TimeMachineUnlimitedSubscribeActivity.isFirst = true;
                        return;
                    }
                    boolean hasCard = TimeMachineUnlimitedSubscribeActivity.this.hasSimCard();
                    if (hasCard) {
                        Boolean isDianxin = DeviceUtils.getIsDianxin(TimeMachineUnlimitedSubscribeActivity.this.phoneNum);
                        if (isDianxin.booleanValue()) {
                            TimeMachineUnlimitedSubscribeActivity.this.pays(TimeMachineUnlimitedSubscribeActivity.this.phoneNum, TimeMachineUnlimitedSubscribeActivity.this.payID);
                            return;
                        } else {
                            ToastTool.getToast(TimeMachineUnlimitedSubscribeActivity.this.getApplicationContext()).showMessage("本服务暂时仅支持中国电信用户");
                            Boolean unused3 = TimeMachineUnlimitedSubscribeActivity.isFirst = true;
                            return;
                        }
                    }
                    ToastTool.getToast(TimeMachineUnlimitedSubscribeActivity.this.getApplicationContext()).showMessage("请确认sim卡是否插入或者sim卡暂时不可用!");
                }
            }
        });
    }

    public boolean hasSimCard() {
        boolean result = DeviceUtils.isExistPhoneCard(getApplicationContext());
        return result;
    }

    public boolean needLogin() {
        return this.preferenceKeyManager.getAccountSettings().syncAccount().get() == null || StringUtils.isBlank(this.preferenceKeyManager.getAccountSettings().syncAccount().get().key);
    }

    protected void createLoginAccountDialog() {
        Dialog LoginDialog = DialogFactory.createMessageDialog(this, 0, "登录天翼帐号", getResources().getString(R.string.login_account_dialog_message), "立即登录", "取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
                TimeMachineUnlimitedSubscribeActivity.this.preferenceKeyManager.getAccountSettings().syncAccount().set(null);
                CoreManagerFactory.getInstance().getPimNotifyManager().changed(Notify.Event.ACCOUNT_CHANGED, null);
                TimeMachineUnlimitedSubscribeActivity.this.startActivity(new Intent(TimeMachineUnlimitedSubscribeActivity.this, (Class<?>) AccountLoginActivity.class));
            }
        }, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
            }
        });
        LoginDialog.show();
    }

    public void pays(String phoneNum, String payID) {
        if (TextUtils.isEmpty(phoneNum)) {
            Toast.makeText(this, "手机号码不能为空!", 1).show();
            return;
        }
        PayHelper payHelper = PayHelper.getInstance(this);
        payHelper.init(IConstant.Open189Settings.APPID, IConstant.Open189Settings.APPSecret);
        payHelper.settimeout(120000);
        payHelper.pay(this, payID, phoneNum, this.handler, "hkajsd");
    }

    public void getOrderInfos() {
        Runner runner = new Runner(new BackgroundJob() {
            SyncResponse<OrderMemberProto.MemberOrderResponse> infos;

            @Override
            public void prepare(Runner.Info info) {
            }

            @Override
            public Object run(Runner.Info info) {
                this.infos = TimeMachineUnlimitedSubscribeActivity.this.getinfos();
                return null;
            }

            @Override
            public void onComplete(Runner.Info info, Object result) {
                int resCode = this.infos.getBody().getResCode();
                String message = this.infos.getBody().getResMsg();
                this.infos.getBody().getMemberOrder();
                Boolean unused = TimeMachineUnlimitedSubscribeActivity.isFirst = true;
                if (resCode == 0) {
                    ToastTool.getToast(TimeMachineUnlimitedSubscribeActivity.this).showMessage(message);
                    TimeMachineUnlimitedSubscribeActivity.this.preferenceKeyManager.getContactBackupSetting().openUnlimitedRecoveryMemberShip().set(false);
                    TimeMachineUnlimitedSubscribeActivity.this.startActivity(new Intent(TimeMachineUnlimitedSubscribeActivity.this, (Class<?>) TimeMachineUnlimitedStepsActivity.class));
                    TimeMachineUnlimitedSubscribeActivity.this.finish();
                    return;
                }
                ToastTool.getToast(TimeMachineUnlimitedSubscribeActivity.this).showMessage("服务器返回失败");
            }
        });
        runner.execute();
    }

    public SyncResponse<OrderMemberProto.MemberOrderResponse> getinfos() {
        final SyncResponse<OrderMemberProto.MemberOrderResponse> syncResponse = new SyncResponse<>();
        this.PUserid = this.preferenceKeyManager.getAccountSettings().syncAccount().get().tag4.toString();
        String id = this.preferenceKeyManager.getAccountSettings().syncAccount().get().tag3.toString();
        if (!StringUtils.isNotBlank(id)) {
            id = "0";
        }
        final int userId = Integer.parseInt(id);
        PlatformConfig platformConfig = getGetConfig();
        Packet packet = new Packet(Packet.MethodType.POST, platformConfig.getEnvironment().getGetSubscribeUrl());
        QueryClientVersionCommandsMy command = new QueryClientVersionCommandsMy(this.httpTemplateFactory.getHttpTemplate(), packet);
        command.setAdapter(new CommandAdapter<OrderMemberProto.MemberOrderRequest, OrderMemberProto.MemberOrderResponse>() {
            @Override
            public OrderMemberProto.MemberOrderRequest prepare() {
                OrderMemberProto.PayOrder.Builder builder = OrderMemberProto.PayOrder.newBuilder();
                builder.setOrderNo(TimeMachineUnlimitedSubscribeActivity.this.orderNo).setPayCode(TimeMachineUnlimitedSubscribeActivity.this.payID).setPrice(TimeMachineUnlimitedSubscribeActivity.this.price).setPhone(TimeMachineUnlimitedSubscribeActivity.this.phoneNum).build();
                OrderMemberProto.MemberOrderRequest.Builder builder2 = OrderMemberProto.MemberOrderRequest.newBuilder();
                builder2.setPayOrder(builder).setPuserid(TimeMachineUnlimitedSubscribeActivity.this.PUserid).setType(GetMemberInfoProto.MemberType.BUY).setUserid(userId);
                return builder2.build();
            }

            @Override
            public void onComplete(OrderMemberProto.MemberOrderResponse memberOrderResponse) {
                syncResponse.setBody(memberOrderResponse);
            }

            @Override
            public void onComplete(byte[] bytes) {
            }
        });
        command.execute(null);
        return syncResponse;
    }

    private PlatformConfig getGetConfig() {
        final PlatformConfig syncSession = new PlatformConfig();
        final GetconfigUrlManager getconfigUrlManager = CoreManagerFactory.getInstance().getconfigUrlManager();
        PlatformConfig.Environment environment = getconfigUrlManager.findEnvironment();
        if (environment != null) {
            syncSession.setEnvironment(environment);
        } else {
            GetConfigCommand getConfigCommand = new GetConfigCommand(this.httpTemplateFactory.getHttpTemplate(), new Packet(Packet.MethodType.GET, "http://sync.189.cn/UabSyncService/uabconfig.uab"));
            getConfigCommand.setAdapter(new CommandAdapter<Object, GetConfigProto.GetConfigResponse>() {
                @Override
                public Object prepare() {
                    return null;
                }

                @Override
                public void onComplete(GetConfigProto.GetConfigResponse response) {
                    syncSession.getEnvironment().setAuthUrl(response.getAuthUrl());
                    syncSession.getEnvironment().setClientReportUrl(response.getClientReportUrl());
                    syncSession.getEnvironment().setGetUserCloudSummaryUrl(response.getGetUserCloudSummaryUrl());
                    syncSession.getEnvironment().setQueryClientVersionUrl(response.getQueryClientVersionUrl());
                    syncSession.getEnvironment().setQueryMobileNoUrl(response.getQueryMobileNoUrl());
                    syncSession.getEnvironment().setGetSplashUrl(response.getGetSplashUrl());
                    syncSession.getEnvironment().setGetSysMsgUrl(response.getGetSysMsgUrl());
                    syncSession.getEnvironment().setQueryPublicInfoUrl(response.getQueryPublicInfoUrl());
                    syncSession.getEnvironment().setQueryCommentInfoUrl(response.getQueryCommentsUrl());
                    syncSession.getEnvironment().setNewDeviceSignUrl(response.getNewDeviceSignUrl());
                    syncSession.getEnvironment().setTpnoolUrl(response.getTpnoolUrl());
                    syncSession.getEnvironment().setGetContactAdUrl(response.getGetContactAdUrl());
                    syncSession.getEnvironment().setGetReadAmountUrl(response.getReadAmountUrl());
                    syncSession.getEnvironment().setGetHCodeUrl(response.getGetHcodeUrl());
                    syncSession.getEnvironment().setGetPublicTelephoneUrl(response.getGetPublicTelephoneUrl());
                    syncSession.getEnvironment().setUploadAllEncryptedUrl(response.getUploadAllEncryptedUrl());
                    syncSession.getEnvironment().setDownloadAllEncryptedUrl(response.getDownloadAllEncryptedUrl());
                    syncSession.getEnvironment().setDownloadContactEncryptedUrl(response.getDownloadContactEncryptedUrl());
                    syncSession.getEnvironment().setSyncUploadContactEncryptedUrl(response.getSyncUploadContactEncryptedUrl());
                    syncSession.getEnvironment().setSlowSyncEncryptedUrl(response.getSlowSyncEncryptedUrl());
                    syncSession.getEnvironment().setSyncSmsEncryptedUrl(response.getSyncSmsEncryptedUrl());
                    syncSession.getEnvironment().setUploadSmsEncryptedUrl(response.getUploadSmsEncryptedUrl());
                    syncSession.getEnvironment().setDownloadSmsEncryptedUrl(response.getDownloadSmsEncryptedUrl());
                    syncSession.getEnvironment().setBackupCalllogEncryptedUrl(response.getBackupCalllogEncryptedUrl());
                    syncSession.getEnvironment().setRecoverCalllogEncryptedUrl(response.getRecoverCalllogEncryptedUrl());
                    syncSession.getEnvironment().setGetWebSysUrl(response.getGetWebSysMsgUrl());
                    syncSession.getEnvironment().setBugReportUrl(response.getErrorLogUrl());
                    syncSession.getEnvironment().setContactShareUrl(response.getConatctShareUrl());
                    syncSession.getEnvironment().setMyCardShareUrl(response.getIsopenMycardUrl());
                    syncSession.getEnvironment().setUnlimitedRecoveryMemberUrl(response.getAddGetMemberinfoUrlUrl());
                    syncSession.getEnvironment().setPimPlatformADUrl(response.getCalloffAdUrl());
                    syncSession.getEnvironment().setCuMycardShareUrl(response.getAddupdateMycardUrl());
                    syncSession.getEnvironment().setUploadPortraitUrl(response.getUploadPortraitUrl());
                    syncSession.getEnvironment().setGetMyContactSharedUrl(response.getConatctShareListUrl());
                    syncSession.getEnvironment().setGetDelMyContactShareUrl(response.getDelConatctShareListUrl());
                    syncSession.getEnvironment().setSharedUrl(response.getGetShareUrl());
                    syncSession.getEnvironment().setContactMyCardInfoUrl(response.getGetContactMycardUrl());
                    syncSession.getEnvironment().setGetMemberInfoUrl(response.getGetMemberInfoUrl());
                    syncSession.getEnvironment().setDownloadPortraitUrl(response.getDownloadPortraitUrl());
                    syncSession.getEnvironment().setGetMemberModuleUrl(response.getGetMemberModuleUrl());
                    syncSession.getEnvironment().setGetMyCtpassStatus(response.getGetCtpassStatusUrl());
                    syncSession.getEnvironment().setGetMyCtpassIsSupport(response.getGetCtpassIsSupportUrl());
                    getconfigUrlManager.saveEnvironment(syncSession.getEnvironment());
                }

                @Override
                public void onComplete(byte[] bytes) {
                }
            });
            getConfigCommand.execute(null);
        }
        return syncSession;
    }
}