CameraPreviewOptionActivity.java 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. package com.epson.cameracopy.p006ui;
  2. import android.content.Intent;
  3. import android.graphics.Point;
  4. import android.os.Bundle;
  5. import android.support.p000v4.app.Fragment;
  6. import android.view.LayoutInflater;
  7. import android.view.Menu;
  8. import android.view.MenuInflater;
  9. import android.view.MenuItem;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.widget.CompoundButton;
  13. import android.widget.LinearLayout;
  14. import android.widget.Switch;
  15. import android.widget.TextView;
  16. import com.epson.cameracopy.device.CameraPreviewControl;
  17. import com.epson.cameracopy.p006ui.PictureResolutionDialogFragment;
  18. import epson.print.ActivityIACommon;
  19. import java.io.File;
  20. /* renamed from: com.epson.cameracopy.ui.CameraPreviewOptionActivity */
  21. public class CameraPreviewOptionActivity extends ActivityIACommon implements PictureResolutionDialogFragment.OnItemSelectedListener {
  22. private static final int CODE_DIRECTORY_SELECT = 1;
  23. PlaceholderFragment mFragment;
  24. protected void onCreate(Bundle bundle) {
  25. super.onCreate(bundle);
  26. setContentView((int) R.layout.activity_camera_preview_option);
  27. setActionBar((int) R.string.camera_option_title, true);
  28. if (bundle == null) {
  29. this.mFragment = new PlaceholderFragment();
  30. getSupportFragmentManager().beginTransaction().add((int) R.id.container, (Fragment) this.mFragment).commit();
  31. }
  32. }
  33. public void onItemSelected(boolean z, int i, Point point) {
  34. PlaceholderFragment placeholderFragment;
  35. if (z && (placeholderFragment = this.mFragment) != null) {
  36. placeholderFragment.changeSelectedCameraPictureResolution(i, point);
  37. }
  38. }
  39. /* renamed from: com.epson.cameracopy.ui.CameraPreviewOptionActivity$PlaceholderFragment */
  40. public static class PlaceholderFragment extends Fragment {
  41. Switch mAutoPhotoToggleButton;
  42. private int mCameraPictureResolutionMode;
  43. private Point mCameraPictureSize;
  44. private CameraPreviewControl mCameraPreviewControl;
  45. Switch mGuideToggleButton;
  46. private TextView mPictureResolutionText;
  47. String mSaveDirectoryName;
  48. private TextView mSaveDirectoryText;
  49. public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
  50. View inflate = layoutInflater.inflate(R.layout.fragment_camera_preview_option, viewGroup, false);
  51. this.mCameraPreviewControl = CameraPreviewControl.getInstance(getActivity());
  52. setHasOptionsMenu(true);
  53. this.mGuideToggleButton = (Switch) inflate.findViewById(R.id.guideToggleButton);
  54. this.mGuideToggleButton.setChecked(this.mCameraPreviewControl.getGuideMode());
  55. this.mGuideToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  56. public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
  57. PlaceholderFragment.this.changeAutoPhotoToggleButtonStatus(z);
  58. }
  59. });
  60. this.mAutoPhotoToggleButton = (Switch) inflate.findViewById(R.id.autoPictureToggleButton);
  61. this.mAutoPhotoToggleButton.setChecked(this.mCameraPreviewControl.getAutoPictureMode());
  62. changeAutoPhotoToggleButtonStatus(this.mGuideToggleButton.isChecked());
  63. ((LinearLayout) inflate.findViewById(R.id.save_directory_layout)).setOnClickListener(new View.OnClickListener() {
  64. public void onClick(View view) {
  65. PlaceholderFragment.this.startSaveDirectoryActivity();
  66. }
  67. });
  68. this.mSaveDirectoryText = (TextView) inflate.findViewById(R.id.saveDirectoryText);
  69. setSaveDirectoryText(this.mCameraPreviewControl.getSaveDirecotry());
  70. inflate.findViewById(R.id.picture_resolution_layout).setOnClickListener(new View.OnClickListener() {
  71. public void onClick(View view) {
  72. PlaceholderFragment.this.openPictureResolutionDialog();
  73. }
  74. });
  75. this.mPictureResolutionText = (TextView) inflate.findViewById(R.id.pictureResolutionText);
  76. setCameraPictureResolutionModeFromCameraPreviewControl();
  77. setPictureResolutionText();
  78. return inflate;
  79. }
  80. public void changeSelectedCameraPictureResolution(int i, Point point) {
  81. this.mCameraPictureResolutionMode = i;
  82. if (this.mCameraPictureResolutionMode == 0) {
  83. this.mCameraPictureSize = null;
  84. } else {
  85. this.mCameraPictureSize = point;
  86. }
  87. setPictureResolutionText();
  88. }
  89. private void setPictureResolutionText() {
  90. if (this.mCameraPictureResolutionMode == 0) {
  91. this.mPictureResolutionText.setText(R.string.picture_size_auto);
  92. return;
  93. }
  94. Point point = this.mCameraPictureSize;
  95. if (point == null || point.x <= 0 || this.mCameraPictureSize.y <= 0) {
  96. this.mPictureResolutionText.setText("");
  97. return;
  98. }
  99. this.mPictureResolutionText.setText(CameraPreviewControl.getPictureSizeString(this.mCameraPictureSize.x, this.mCameraPictureSize.y));
  100. }
  101. private void setCameraPictureResolutionModeFromCameraPreviewControl() {
  102. this.mCameraPictureResolutionMode = this.mCameraPreviewControl.getPictureResolutionMode();
  103. this.mCameraPictureSize = null;
  104. if (this.mCameraPictureResolutionMode == 1) {
  105. this.mCameraPictureSize = this.mCameraPreviewControl.getPictureSize();
  106. }
  107. }
  108. private void openPictureResolutionDialog() {
  109. PictureResolutionDialogFragment.newInstance(this.mCameraPictureResolutionMode, this.mCameraPictureSize).show(getActivity().getSupportFragmentManager(), "picture-resolution");
  110. }
  111. private void changeValueAndFinish() {
  112. this.mCameraPreviewControl.setGuideMode(this.mGuideToggleButton.isChecked());
  113. this.mCameraPreviewControl.setAutoPictureMode(Boolean.valueOf(this.mAutoPhotoToggleButton.isChecked()));
  114. this.mCameraPreviewControl.setSaveDirecotry(this.mSaveDirectoryName);
  115. if (this.mCameraPictureResolutionMode == 0) {
  116. this.mCameraPreviewControl.setPictureResolutionModeAuto();
  117. } else {
  118. this.mCameraPreviewControl.setPictureSize(this.mCameraPictureSize);
  119. }
  120. getActivity().finish();
  121. }
  122. private void changeAutoPhotoToggleButtonStatus(boolean z) {
  123. if (z && this.mCameraPreviewControl.hasAutoPictureHardware(getActivity())) {
  124. this.mAutoPhotoToggleButton.setEnabled(true);
  125. return;
  126. }
  127. this.mAutoPhotoToggleButton.setChecked(false);
  128. this.mAutoPhotoToggleButton.setEnabled(false);
  129. }
  130. private void setSaveDirectoryText(String str) {
  131. this.mSaveDirectoryName = str;
  132. this.mSaveDirectoryText.setText(new File(this.mSaveDirectoryName).getName());
  133. }
  134. public void startSaveDirectoryActivity() {
  135. startActivityForResult(new Intent(getActivity(), FolderSelectActivity.class), 1);
  136. }
  137. public void onActivityResult(int i, int i2, Intent intent) {
  138. if (i == 1) {
  139. if (i2 == -1 && intent != null) {
  140. String stringExtra = intent.getStringExtra("SELECT_Folder");
  141. if (stringExtra != null) {
  142. setSaveDirectoryText(stringExtra);
  143. }
  144. } else if (i2 == 1) {
  145. SimpleMessageDialogFragment.newInstance(R.string.file_save_error_message).show(getFragmentManager(), "error-dialog");
  146. }
  147. }
  148. }
  149. public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
  150. menuInflater.inflate(R.C2138menu.menu_done, menu);
  151. super.onCreateOptionsMenu(menu, menuInflater);
  152. }
  153. public boolean onOptionsItemSelected(MenuItem menuItem) {
  154. if (menuItem.getItemId() != R.id.menuSettingsDone) {
  155. return super.onOptionsItemSelected(menuItem);
  156. }
  157. changeValueAndFinish();
  158. return true;
  159. }
  160. }
  161. }