CameraPreviewOptionActivity.java 8.5 KB

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