CameraPreviewOptionActivity.java 7.7 KB

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