SupportActivity.java 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package epson.support;
  2. import android.content.Intent;
  3. import android.net.Uri;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.CompoundButton;
  7. import android.widget.Switch;
  8. import androidx.annotation.NonNull;
  9. import com.epson.mobilephone.common.guide.NoticeGuideActivity;
  10. import com.epson.mobilephone.common.license.InfoDisplayActivity;
  11. import com.epson.mobilephone.common.license.UserSurveyInvitationActivity;
  12. import epson.common.InformationGuide;
  13. import epson.common.IprintLicenseInfo;
  14. import epson.common.IprintUserSurveyInfo;
  15. import epson.print.ActivityIACommon;
  16. import epson.print.R;
  17. import epson.print.CommonDefine;
  18. import epson.print.ThreeButtonDialog;
  19. import epson.print.Util.BuyInkUrl;
  20. public class SupportActivity extends ActivityIACommon implements CommonDefine, View.OnClickListener, ThreeButtonDialog.DialogCallback {
  21. private static final int REQUEST_CODE_USER_SURVEY = 1;
  22. private static final String TUTORIAL_URL = "https://www.epsonconnect.com/iguide/";
  23. private SwitchAdapter mUserSurveySwitch;
  24. public void callback(int i) {
  25. }
  26. protected void onCreate(Bundle bundle) {
  27. super.onCreate(bundle);
  28. setContentView(R.layout.main_support);
  29. setActionBar(R.string.title_support, true);
  30. findViewById(R.id.linearLayoutIprintNews).setOnClickListener(new View.OnClickListener() {
  31. public void onClick(View view) {
  32. InformationGuide informationGuide = new InformationGuide(getApplicationContext());
  33. Intent intent = new Intent(SupportActivity.this, NoticeGuideActivity.class);
  34. intent.putExtra(NoticeGuideActivity.KEY_HTML_PATH, informationGuide.getHtmlPath());
  35. intent.putExtra(NoticeGuideActivity.KEY_GUIDE_VER, InformationGuide.GUIDE_VER);
  36. intent.putExtra(NoticeGuideActivity.KEY_BOOT_MODE, NoticeGuideActivity.MODE_MANUAL);
  37. startActivity(intent);
  38. }
  39. });
  40. final String faqUrlString = BuyInkUrl.getFaqUrlString(this);
  41. findViewById(R.id.linearLayoutFAQ).setOnClickListener(new View.OnClickListener() {
  42. public void onClick(View view) {
  43. startActivity(new Intent("android.intent.action.VIEW", Uri.parse(faqUrlString)));
  44. }
  45. });
  46. findViewById(R.id.linearLayoutTutorial).setOnClickListener(new View.OnClickListener() {
  47. public void onClick(View view) {
  48. startActivity(new Intent("android.intent.action.VIEW", Uri.parse(SupportActivity.TUTORIAL_URL)));
  49. }
  50. });
  51. mUserSurveySwitch = new SwitchAdapter((Switch) findViewById(R.id.tb_send_usageinformation), new CompoundButton.OnCheckedChangeListener() {
  52. public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
  53. onCheckChanged(z);
  54. }
  55. });
  56. updateUserSurveySwitch();
  57. findViewById(R.id.linearLayoutPrivacy).setOnClickListener(new View.OnClickListener() {
  58. public void onClick(View view) {
  59. startDocumentDisplayActivity(2);
  60. }
  61. });
  62. findViewById(R.id.linearLayoutAbout).setOnClickListener(new View.OnClickListener() {
  63. public void onClick(View view) {
  64. startActivity(new Intent(SupportActivity.this, SupportAboutActivity.class));
  65. }
  66. });
  67. findViewById(R.id.linearLayoutLicense).setOnClickListener(this);
  68. findViewById(R.id.ossLicenseLayout).setOnClickListener(this);
  69. findViewById(R.id.linearLayoutDeviceInformation).setOnClickListener(new View.OnClickListener() {
  70. public void onClick(View view) {
  71. startActivity(new Intent(SupportActivity.this, DeviceInformationActivity.class));
  72. }
  73. });
  74. }
  75. private void onCheckChanged(boolean z) {
  76. IprintUserSurveyInfo iprintUserSurveyInfo = new IprintUserSurveyInfo();
  77. if (!z) {
  78. iprintUserSurveyInfo.setUserSurveyAgreement(this, false);
  79. } else {
  80. startUserSurveyInvitationActivity();
  81. }
  82. }
  83. private void startUserSurveyInvitationActivity() {
  84. startActivityForResult(UserSurveyInvitationActivity.getStartIntent(this, new IprintUserSurveyInfo(), new IprintLicenseInfo()), 1);
  85. }
  86. public void onClick(View view) {
  87. if (view.getId() == R.id.linearLayoutLicense) {
  88. startDocumentDisplayActivity(1);
  89. } else if (view.getId() == R.id.ossLicenseLayout) {
  90. startDocumentDisplayActivity(3);
  91. }
  92. }
  93. private void startDocumentDisplayActivity(int i) {
  94. startActivity(InfoDisplayActivity.getStartIntent(this, new IprintLicenseInfo(), i));
  95. }
  96. protected void onActivityResult(int i, int i2, Intent intent) {
  97. super.onActivityResult(i, i2, intent);
  98. if (i == 1) {
  99. updateUserSurveySwitch();
  100. }
  101. }
  102. private void updateUserSurveySwitch() {
  103. mUserSurveySwitch.setCheckWithoutCallback(new IprintUserSurveyInfo().isUserSurveyEnabled(this));
  104. }
  105. protected void onPause() {
  106. super.onPause();
  107. mUserSurveySwitch.setListenerEnabled(false);
  108. }
  109. protected void onResume() {
  110. super.onResume();
  111. mUserSurveySwitch.setListenerEnabled(true);
  112. }
  113. private static class SwitchAdapter implements CompoundButton.OnCheckedChangeListener {
  114. private boolean mOriginalChangeListenerEnabled = false;
  115. private CompoundButton.OnCheckedChangeListener mOriginalListener;
  116. private Switch mSwitch;
  117. public SwitchAdapter(@NonNull Switch switchR, CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
  118. mSwitch = switchR;
  119. mOriginalListener = onCheckedChangeListener;
  120. switchR.setOnCheckedChangeListener(this);
  121. }
  122. public void setListenerEnabled(boolean z) {
  123. mOriginalChangeListenerEnabled = z;
  124. }
  125. public void setCheckWithoutCallback(boolean z) {
  126. boolean z2 = mOriginalChangeListenerEnabled;
  127. mOriginalChangeListenerEnabled = false;
  128. mSwitch.setChecked(z);
  129. mOriginalChangeListenerEnabled = z2;
  130. }
  131. public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
  132. CompoundButton.OnCheckedChangeListener onCheckedChangeListener;
  133. if (mOriginalChangeListenerEnabled && (onCheckedChangeListener = mOriginalListener) != null) {
  134. onCheckedChangeListener.onCheckedChanged(compoundButton, z);
  135. }
  136. }
  137. }
  138. }