123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- package com.epson.mobilephone.common.license;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.annotation.NonNull;
- import android.support.annotation.Nullable;
- import android.support.p003v7.app.AppCompatActivity;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.Button;
- import android.widget.TextView;
- import com.epson.mobilephone.common.license.SimpleMessageDialogFragment;
- import epson.common.Constants;
- public class LicenseTopActivity extends AppCompatActivity implements SimpleMessageDialogFragment.DialogCallback {
- private static final String DIALOG_ID = "dialog";
- private static final int DIALOG_ID_DISAGREE = 2;
- private static final int DIALOG_ID_NEW_LICENSE = 1;
- private static final String KEY_LICENSE_INFO = "license_info";
- private static final String KEY_USER_SURVEY_INFO = "user_survey_info";
- private static final int REQUEST_CODE_USER_SURVEY_INVITATION = 2;
- private LicenseInfo mLicenseInfo;
- private UserSurveyInfo mUserSurveyInfo;
- public void onBackPressed() {
- }
- protected void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- setContentView(C1066R.layout.activity_license_top);
- ((ViewGroup) findViewById(C1066R.C1068id.licenseViewGroup)).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- LicenseTopActivity.this.startDocumentDisplayActivity(1);
- }
- });
- ((ViewGroup) findViewById(C1066R.C1068id.privacyStatementViewGroup)).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- LicenseTopActivity.this.startDocumentDisplayActivity(2);
- }
- });
- ((Button) findViewById(C1066R.C1068id.agreeButton)).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- LicenseTopActivity.this.onAgree();
- }
- });
- ((Button) findViewById(C1066R.C1068id.disagreeButton)).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- LicenseTopActivity.this.onDisagree();
- }
- });
- if (!initField(getIntent())) {
- setResult(0);
- finish();
- return;
- }
- ((TextView) findViewById(C1066R.C1068id.appNameText)).setText(this.mLicenseInfo.getApplicationName(this));
- if (bundle == null) {
- showLicenseChangeDialogIfNeeded(this, this.mLicenseInfo, this.mUserSurveyInfo);
- }
- }
- private boolean initField(Intent intent) {
- if (intent == null) {
- return false;
- }
- this.mLicenseInfo = (LicenseInfo) intent.getSerializableExtra(KEY_LICENSE_INFO);
- if (this.mLicenseInfo == null) {
- return false;
- }
- this.mUserSurveyInfo = (UserSurveyInfo) intent.getSerializableExtra(KEY_USER_SURVEY_INFO);
- return true;
- }
- private void showLicenseChangeDialogIfNeeded(@NonNull Context context, @NonNull LicenseInfo licenseInfo, UserSurveyInfo userSurveyInfo) {
- String str;
- switch (licenseInfo.getLicenseAgreement(context)) {
- case 0:
- str = getString(C1066R.string.EULA_Title) + Constants.BREAK_LINE + getString(C1066R.string.Privacy_Statement_Title);
- break;
- case 1:
- str = getString(C1066R.string.EULA_Title);
- break;
- case 2:
- str = getString(C1066R.string.Privacy_Statement_Title);
- break;
- case 3:
- setResult(-1);
- if (userSurveyInfo == null || userSurveyInfo.getResponseStatus(context) >= 2) {
- finish();
- return;
- } else {
- startUserSurveyInvitationActivity();
- return;
- }
- default:
- return;
- }
- SimpleMessageDialogFragment.newInstance(getString(C1066R.string.Update_Message) + Constants.BREAK_LINE + str, 1).show(getSupportFragmentManager(), DIALOG_ID);
- }
- /* access modifiers changed from: private */
- public void onAgree() {
- LicenseInfo licenseInfo = this.mLicenseInfo;
- if (licenseInfo == null) {
- finish();
- return;
- }
- licenseInfo.setLicenceAgreement(this);
- setResult(-1);
- startUserSurveyInvitationActivity();
- }
- private void startUserSurveyInvitationActivity() {
- if (this.mLicenseInfo == null) {
- finish();
- return;
- }
- UserSurveyInfo userSurveyInfo = this.mUserSurveyInfo;
- if (userSurveyInfo == null) {
- finish();
- } else if (userSurveyInfo.getResponseStatus(this) >= 2) {
- finish();
- } else {
- startActivityForResult(UserSurveyInvitationActivity.getStartWithDialogIntent(this, this.mUserSurveyInfo, this.mLicenseInfo), 2);
- }
- }
- /* access modifiers changed from: private */
- public void onDisagree() {
- SimpleMessageDialogFragment.newInstance(getString(C1066R.string.Disagree_License_Button_Message), 2).show(getSupportFragmentManager(), DIALOG_ID);
- }
- /* access modifiers changed from: private */
- public void startDocumentDisplayActivity(int i) {
- LicenseInfo licenseInfo = this.mLicenseInfo;
- if (licenseInfo != null) {
- startActivity(InfoDisplayActivity.getStartIntent(this, licenseInfo, i));
- }
- }
- public void onButtonClicked(int i) {
- switch (i) {
- case 1:
- return;
- case 2:
- setResult(0);
- finish();
- return;
- default:
- return;
- }
- }
- protected void onActivityResult(int i, int i2, Intent intent) {
- if (i == 2) {
- setResult(-1);
- finish();
- }
- }
- public static Intent getStartIntent(Context context, @NonNull LicenseInfo licenseInfo, @Nullable UserSurveyInfo userSurveyInfo) {
- Intent intent = new Intent(context, LicenseTopActivity.class);
- intent.putExtra(KEY_LICENSE_INFO, licenseInfo);
- intent.putExtra(KEY_USER_SURVEY_INFO, userSurveyInfo);
- return intent;
- }
- }
|