LicenseTopActivity.java 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. package com.epson.mobilephone.common.license;
  2. import android.content.Context;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.annotation.NonNull;
  6. import android.support.annotation.Nullable;
  7. import android.support.p003v7.app.AppCompatActivity;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.widget.Button;
  11. import android.widget.TextView;
  12. import com.epson.mobilephone.common.license.SimpleMessageDialogFragment;
  13. import epson.common.Constants;
  14. public class LicenseTopActivity extends AppCompatActivity implements SimpleMessageDialogFragment.DialogCallback {
  15. private static final String DIALOG_ID = "dialog";
  16. private static final int DIALOG_ID_DISAGREE = 2;
  17. private static final int DIALOG_ID_NEW_LICENSE = 1;
  18. private static final String KEY_LICENSE_INFO = "license_info";
  19. private static final String KEY_USER_SURVEY_INFO = "user_survey_info";
  20. private static final int REQUEST_CODE_USER_SURVEY_INVITATION = 2;
  21. private LicenseInfo mLicenseInfo;
  22. private UserSurveyInfo mUserSurveyInfo;
  23. public void onBackPressed() {
  24. }
  25. protected void onCreate(Bundle bundle) {
  26. super.onCreate(bundle);
  27. setContentView(C1066R.layout.activity_license_top);
  28. ((ViewGroup) findViewById(C1066R.C1068id.licenseViewGroup)).setOnClickListener(new View.OnClickListener() {
  29. public void onClick(View view) {
  30. LicenseTopActivity.this.startDocumentDisplayActivity(1);
  31. }
  32. });
  33. ((ViewGroup) findViewById(C1066R.C1068id.privacyStatementViewGroup)).setOnClickListener(new View.OnClickListener() {
  34. public void onClick(View view) {
  35. LicenseTopActivity.this.startDocumentDisplayActivity(2);
  36. }
  37. });
  38. ((Button) findViewById(C1066R.C1068id.agreeButton)).setOnClickListener(new View.OnClickListener() {
  39. public void onClick(View view) {
  40. LicenseTopActivity.this.onAgree();
  41. }
  42. });
  43. ((Button) findViewById(C1066R.C1068id.disagreeButton)).setOnClickListener(new View.OnClickListener() {
  44. public void onClick(View view) {
  45. LicenseTopActivity.this.onDisagree();
  46. }
  47. });
  48. if (!initField(getIntent())) {
  49. setResult(0);
  50. finish();
  51. return;
  52. }
  53. ((TextView) findViewById(C1066R.C1068id.appNameText)).setText(this.mLicenseInfo.getApplicationName(this));
  54. if (bundle == null) {
  55. showLicenseChangeDialogIfNeeded(this, this.mLicenseInfo, this.mUserSurveyInfo);
  56. }
  57. }
  58. private boolean initField(Intent intent) {
  59. if (intent == null) {
  60. return false;
  61. }
  62. this.mLicenseInfo = (LicenseInfo) intent.getSerializableExtra(KEY_LICENSE_INFO);
  63. if (this.mLicenseInfo == null) {
  64. return false;
  65. }
  66. this.mUserSurveyInfo = (UserSurveyInfo) intent.getSerializableExtra(KEY_USER_SURVEY_INFO);
  67. return true;
  68. }
  69. private void showLicenseChangeDialogIfNeeded(@NonNull Context context, @NonNull LicenseInfo licenseInfo, UserSurveyInfo userSurveyInfo) {
  70. String str;
  71. switch (licenseInfo.getLicenseAgreement(context)) {
  72. case 0:
  73. str = getString(C1066R.string.EULA_Title) + Constants.BREAK_LINE + getString(C1066R.string.Privacy_Statement_Title);
  74. break;
  75. case 1:
  76. str = getString(C1066R.string.EULA_Title);
  77. break;
  78. case 2:
  79. str = getString(C1066R.string.Privacy_Statement_Title);
  80. break;
  81. case 3:
  82. setResult(-1);
  83. if (userSurveyInfo == null || userSurveyInfo.getResponseStatus(context) >= 2) {
  84. finish();
  85. return;
  86. } else {
  87. startUserSurveyInvitationActivity();
  88. return;
  89. }
  90. default:
  91. return;
  92. }
  93. SimpleMessageDialogFragment.newInstance(getString(C1066R.string.Update_Message) + Constants.BREAK_LINE + str, 1).show(getSupportFragmentManager(), DIALOG_ID);
  94. }
  95. /* access modifiers changed from: private */
  96. public void onAgree() {
  97. LicenseInfo licenseInfo = this.mLicenseInfo;
  98. if (licenseInfo == null) {
  99. finish();
  100. return;
  101. }
  102. licenseInfo.setLicenceAgreement(this);
  103. setResult(-1);
  104. startUserSurveyInvitationActivity();
  105. }
  106. private void startUserSurveyInvitationActivity() {
  107. if (this.mLicenseInfo == null) {
  108. finish();
  109. return;
  110. }
  111. UserSurveyInfo userSurveyInfo = this.mUserSurveyInfo;
  112. if (userSurveyInfo == null) {
  113. finish();
  114. } else if (userSurveyInfo.getResponseStatus(this) >= 2) {
  115. finish();
  116. } else {
  117. startActivityForResult(UserSurveyInvitationActivity.getStartWithDialogIntent(this, this.mUserSurveyInfo, this.mLicenseInfo), 2);
  118. }
  119. }
  120. /* access modifiers changed from: private */
  121. public void onDisagree() {
  122. SimpleMessageDialogFragment.newInstance(getString(C1066R.string.Disagree_License_Button_Message), 2).show(getSupportFragmentManager(), DIALOG_ID);
  123. }
  124. /* access modifiers changed from: private */
  125. public void startDocumentDisplayActivity(int i) {
  126. LicenseInfo licenseInfo = this.mLicenseInfo;
  127. if (licenseInfo != null) {
  128. startActivity(InfoDisplayActivity.getStartIntent(this, licenseInfo, i));
  129. }
  130. }
  131. public void onButtonClicked(int i) {
  132. switch (i) {
  133. case 1:
  134. return;
  135. case 2:
  136. setResult(0);
  137. finish();
  138. return;
  139. default:
  140. return;
  141. }
  142. }
  143. protected void onActivityResult(int i, int i2, Intent intent) {
  144. if (i == 2) {
  145. setResult(-1);
  146. finish();
  147. }
  148. }
  149. public static Intent getStartIntent(Context context, @NonNull LicenseInfo licenseInfo, @Nullable UserSurveyInfo userSurveyInfo) {
  150. Intent intent = new Intent(context, LicenseTopActivity.class);
  151. intent.putExtra(KEY_LICENSE_INFO, licenseInfo);
  152. intent.putExtra(KEY_USER_SURVEY_INFO, userSurveyInfo);
  153. return intent;
  154. }
  155. }