StorageWaitingActivity.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package com.epson.iprint.storage;
  2. import android.app.Activity;
  3. import android.app.AlertDialog;
  4. import android.app.Dialog;
  5. import android.content.BroadcastReceiver;
  6. import android.content.Context;
  7. import android.content.DialogInterface;
  8. import android.content.Intent;
  9. import android.content.IntentFilter;
  10. import android.os.Bundle;
  11. import android.view.View;
  12. import android.widget.Button;
  13. import android.widget.TextView;
  14. import epson.print.R;
  15. public class StorageWaitingActivity extends Activity {
  16. static String CANCEL_REQUEST_ACTION = "StorageProgressActivity.CancelRequestAction";
  17. static String CHANGE_ACTION = "StorageProgressActivity.ChangeAction";
  18. static String DISMISS_ACTION = "StorageProgressActivity.DismissAction";
  19. static String EXTRA_CANCEL_ENABLED = "StorageProgressActivity.ExtraCancelEnabled";
  20. static String EXTRA_MESSAGE = "StorageProgressActivity.ExtraMessage";
  21. static String EXTRA_REQUEST_CODE = "StorageProgressActivity.ExtraRequestCode";
  22. static String REGISTER_ACTION = "StorageProgressActivity.RegisterAction";
  23. public static boolean bShowing = false;
  24. BroadcastReceiver mBroadcastReceiver;
  25. Button mCancelButton;
  26. TextView mMessageText;
  27. int mRequestCode;
  28. public void onBackPressed() {
  29. }
  30. /* access modifiers changed from: protected */
  31. public void onCreate(Bundle bundle) {
  32. super.onCreate(bundle);
  33. setContentView(R.layout.storage_progress);
  34. Intent intent = getIntent();
  35. registerBroadcastReceiver(intent);
  36. setMessage(intent);
  37. setCancelRequest(intent);
  38. }
  39. /* access modifiers changed from: protected */
  40. public void onDestroy() {
  41. unregisterReceiver(this.mBroadcastReceiver);
  42. super.onDestroy();
  43. }
  44. private void registerBroadcastReceiver(Intent intent) {
  45. this.mRequestCode = intent.getIntExtra(EXTRA_REQUEST_CODE, 0);
  46. this.mBroadcastReceiver = new BroadcastReceiver() {
  47. public void onReceive(Context context, Intent intent) {
  48. String action = intent.getAction();
  49. if (StorageWaitingActivity.this.mRequestCode == intent.getIntExtra(StorageWaitingActivity.EXTRA_REQUEST_CODE, 0)) {
  50. if (action.equals(StorageWaitingActivity.DISMISS_ACTION)) {
  51. StorageWaitingActivity.this.finish();
  52. } else if (action.equals(StorageWaitingActivity.CHANGE_ACTION)) {
  53. StorageWaitingActivity.this.setMessage(intent);
  54. } else if (action.equals(StorageWaitingActivity.REGISTER_ACTION)) {
  55. StorageWaitingActivity.this.setCancelRequest(intent);
  56. }
  57. }
  58. }
  59. };
  60. IntentFilter intentFilter = new IntentFilter();
  61. intentFilter.addAction(DISMISS_ACTION);
  62. intentFilter.addAction(CHANGE_ACTION);
  63. intentFilter.addAction(REGISTER_ACTION);
  64. registerReceiver(this.mBroadcastReceiver, intentFilter);
  65. }
  66. private Dialog createCancelDialog() {
  67. AlertDialog.Builder builder = new AlertDialog.Builder(this);
  68. builder.setMessage(getString(R.string.str_msg_scan_cancel));
  69. builder.setCancelable(false);
  70. builder.setPositiveButton(getString(R.string.str_yes), new DialogInterface.OnClickListener() {
  71. public void onClick(DialogInterface dialogInterface, int i) {
  72. StorageWaitingActivity.this.mCancelButton.setEnabled(false);
  73. StorageWaitingActivity.this.mMessageText.setText(StorageWaitingActivity.this.getString(R.string.EPS_PRNST_CANCELLING_MSG));
  74. Intent intent = new Intent(StorageWaitingActivity.CANCEL_REQUEST_ACTION);
  75. intent.putExtra(StorageWaitingActivity.EXTRA_REQUEST_CODE, StorageWaitingActivity.this.mRequestCode);
  76. StorageWaitingActivity.this.sendBroadcast(intent);
  77. dialogInterface.cancel();
  78. }
  79. });
  80. builder.setNegativeButton(getString(R.string.str_no), new DialogInterface.OnClickListener() {
  81. public void onClick(DialogInterface dialogInterface, int i) {
  82. StorageWaitingActivity.this.mCancelButton.setEnabled(true);
  83. dialogInterface.cancel();
  84. }
  85. });
  86. return builder.create();
  87. }
  88. private void setCancelRequest(Intent intent) {
  89. this.mCancelButton = (Button) findViewById(R.id.cancelButton);
  90. this.mCancelButton.setText(getString(R.string.str_cancel));
  91. if (intent.getBooleanExtra(EXTRA_CANCEL_ENABLED, false)) {
  92. this.mCancelButton.setOnClickListener(new View.OnClickListener() {
  93. public void onClick(View view) {
  94. StorageWaitingActivity.this.createCancelDialog().show();
  95. }
  96. });
  97. this.mCancelButton.setVisibility(0);
  98. return;
  99. }
  100. this.mCancelButton.setVisibility(8);
  101. }
  102. private void setMessage(Intent intent) {
  103. this.mMessageText = (TextView) findViewById(R.id.messageText);
  104. String stringExtra = intent.getStringExtra(EXTRA_MESSAGE);
  105. if (stringExtra != null) {
  106. this.mMessageText.setText(stringExtra);
  107. this.mMessageText.setVisibility(0);
  108. return;
  109. }
  110. this.mMessageText.setVisibility(8);
  111. }
  112. /* access modifiers changed from: protected */
  113. public void onResume() {
  114. super.onResume();
  115. bShowing = true;
  116. }
  117. /* access modifiers changed from: protected */
  118. public void onPause() {
  119. super.onPause();
  120. bShowing = false;
  121. }
  122. }