package epson.support;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
import com.epson.mobilephone.common.guide.NoticeGuideActivity;
import com.epson.mobilephone.common.license.InfoDisplayActivity;
import com.epson.mobilephone.common.license.UserSurveyInvitationActivity;
import epson.common.InformationGuide;
import epson.common.IprintLicenseInfo;
import epson.common.IprintUserSurveyInfo;
import epson.print.ActivityIACommon;
import epson.print.C2135R;
import epson.print.CommonDefine;
import epson.print.ThreeButtonDialog;
import epson.print.Util.BuyInkUrl;

public class SupportActivity extends ActivityIACommon implements CommonDefine, View.OnClickListener, ThreeButtonDialog.DialogCallback {
    private static final int REQUEST_CODE_USER_SURVEY = 1;
    private static final String TUTORIAL_URL = "https://www.epsonconnect.com/iguide/";
    private SwitchAdapter mUserSurveySwitch;

    public void callback(int i) {
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) C2135R.layout.main_support);
        setActionBar((int) C2135R.string.title_support, true);
        findViewById(C2135R.C2137id.linearLayoutIprintNews).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                InformationGuide informationGuide = new InformationGuide(SupportActivity.this.getApplicationContext());
                Intent intent = new Intent(SupportActivity.this, NoticeGuideActivity.class);
                intent.putExtra(NoticeGuideActivity.KEY_HTML_PATH, informationGuide.getHtmlPath());
                intent.putExtra(NoticeGuideActivity.KEY_GUIDE_VER, InformationGuide.GUIDE_VER);
                intent.putExtra(NoticeGuideActivity.KEY_BOOT_MODE, NoticeGuideActivity.MODE_MANUAL);
                SupportActivity.this.startActivity(intent);
            }
        });
        final String faqUrlString = BuyInkUrl.getFaqUrlString(this);
        findViewById(C2135R.C2137id.linearLayoutFAQ).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                SupportActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(faqUrlString)));
            }
        });
        findViewById(C2135R.C2137id.linearLayoutTutorial).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                SupportActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(SupportActivity.TUTORIAL_URL)));
            }
        });
        this.mUserSurveySwitch = new SwitchAdapter((Switch) findViewById(C2135R.C2137id.tb_send_usageinformation), new CompoundButton.OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                SupportActivity.this.onCheckChanged(z);
            }
        });
        updateUserSurveySwitch();
        findViewById(C2135R.C2137id.linearLayoutPrivacy).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                SupportActivity.this.startDocumentDisplayActivity(2);
            }
        });
        findViewById(C2135R.C2137id.linearLayoutAbout).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                SupportActivity.this.startActivity(new Intent(SupportActivity.this, SupportAboutActivity.class));
            }
        });
        findViewById(C2135R.C2137id.linearLayoutLicense).setOnClickListener(this);
        findViewById(C2135R.C2137id.ossLicenseLayout).setOnClickListener(this);
        findViewById(C2135R.C2137id.linearLayoutDeviceInformation).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                SupportActivity.this.startActivity(new Intent(SupportActivity.this, DeviceInformationActivity.class));
            }
        });
    }

    /* access modifiers changed from: private */
    public void onCheckChanged(boolean z) {
        IprintUserSurveyInfo iprintUserSurveyInfo = new IprintUserSurveyInfo();
        if (!z) {
            iprintUserSurveyInfo.setUserSurveyAgreement(this, false);
        } else {
            startUserSurveyInvitationActivity();
        }
    }

    private void startUserSurveyInvitationActivity() {
        startActivityForResult(UserSurveyInvitationActivity.getStartIntent(this, new IprintUserSurveyInfo(), new IprintLicenseInfo()), 1);
    }

    public void onClick(View view) {
        if (view.getId() == C2135R.C2137id.linearLayoutLicense) {
            startDocumentDisplayActivity(1);
        } else if (view.getId() == C2135R.C2137id.ossLicenseLayout) {
            startDocumentDisplayActivity(3);
        }
    }

    /* access modifiers changed from: private */
    public void startDocumentDisplayActivity(int i) {
        startActivity(InfoDisplayActivity.getStartIntent(this, new IprintLicenseInfo(), i));
    }

    /* access modifiers changed from: protected */
    public void onActivityResult(int i, int i2, Intent intent) {
        if (i == 1) {
            updateUserSurveySwitch();
        }
    }

    private void updateUserSurveySwitch() {
        this.mUserSurveySwitch.setCheckWithoutCallback(new IprintUserSurveyInfo().isUserSurveyEnabled(this));
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        super.onPause();
        this.mUserSurveySwitch.setListenerEnabled(false);
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        this.mUserSurveySwitch.setListenerEnabled(true);
    }

    private static class SwitchAdapter implements CompoundButton.OnCheckedChangeListener {
        private boolean mOriginalChangeListenerEnabled = false;
        private CompoundButton.OnCheckedChangeListener mOriginalListener;
        private Switch mSwitch;

        public SwitchAdapter(@NonNull Switch switchR, CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
            this.mSwitch = switchR;
            this.mOriginalListener = onCheckedChangeListener;
            switchR.setOnCheckedChangeListener(this);
        }

        public void setListenerEnabled(boolean z) {
            this.mOriginalChangeListenerEnabled = z;
        }

        public void setCheckWithoutCallback(boolean z) {
            boolean z2 = this.mOriginalChangeListenerEnabled;
            this.mOriginalChangeListenerEnabled = false;
            this.mSwitch.setChecked(z);
            this.mOriginalChangeListenerEnabled = z2;
        }

        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
            CompoundButton.OnCheckedChangeListener onCheckedChangeListener;
            if (this.mOriginalChangeListenerEnabled && (onCheckedChangeListener = this.mOriginalListener) != null) {
                onCheckedChangeListener.onCheckedChanged(compoundButton, z);
            }
        }
    }
}
