123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- package com.epson.cameracopy.ui;
- import android.content.Intent;
- import android.graphics.Point;
- import android.os.Bundle;
- import android.view.LayoutInflater;
- import android.view.Menu;
- import android.view.MenuInflater;
- import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.CompoundButton;
- import android.widget.LinearLayout;
- import android.widget.Switch;
- import android.widget.TextView;
- import com.epson.cameracopy.device.CameraPreviewControl;
- import java.io.File;
- import epson.print.ActivityIACommon;
- /* renamed from: com.epson.cameracopy.ui.CameraPreviewOptionActivity */
- public class CameraPreviewOptionActivity extends ActivityIACommon implements PictureResolutionDialogFragment.OnItemSelectedListener {
- private static final int CODE_DIRECTORY_SELECT = 1;
- PlaceholderFragment mFragment;
- protected void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- setContentView(R.layout.activity_camera_preview_option);
- setActionBar(R.string.camera_option_title, true);
- if (bundle == null) {
- mFragment = new PlaceholderFragment();
- getSupportFragmentManager().beginTransaction().add(R.id.container, (Fragment) mFragment).commit();
- }
- }
- public void onItemSelected(boolean z, int i, Point point) {
- PlaceholderFragment placeholderFragment;
- if (z && (placeholderFragment = mFragment) != null) {
- placeholderFragment.changeSelectedCameraPictureResolution(i, point);
- }
- }
- /* renamed from: com.epson.cameracopy.ui.CameraPreviewOptionActivity$PlaceholderFragment */
- public static class PlaceholderFragment extends Fragment {
- Switch mAutoPhotoToggleButton;
- private int mCameraPictureResolutionMode;
- private Point mCameraPictureSize;
- private CameraPreviewControl mCameraPreviewControl;
- Switch mGuideToggleButton;
- private TextView mPictureResolutionText;
- String mSaveDirectoryName;
- private TextView mSaveDirectoryText;
- public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
- View inflate = layoutInflater.inflate(R.layout.fragment_camera_preview_option, viewGroup, false);
- mCameraPreviewControl = CameraPreviewControl.getInstance(getActivity());
- setHasOptionsMenu(true);
- mGuideToggleButton = (Switch) inflate.findViewById(R.id.guideToggleButton);
- mGuideToggleButton.setChecked(mCameraPreviewControl.getGuideMode());
- mGuideToggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
- changeAutoPhotoToggleButtonStatus(z);
- }
- });
- mAutoPhotoToggleButton = (Switch) inflate.findViewById(R.id.autoPictureToggleButton);
- mAutoPhotoToggleButton.setChecked(mCameraPreviewControl.getAutoPictureMode());
- changeAutoPhotoToggleButtonStatus(mGuideToggleButton.isChecked());
- ((LinearLayout) inflate.findViewById(R.id.save_directory_layout)).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- startSaveDirectoryActivity();
- }
- });
- mSaveDirectoryText = (TextView) inflate.findViewById(R.id.saveDirectoryText);
- setSaveDirectoryText(mCameraPreviewControl.getSaveDirecotry());
- inflate.findViewById(R.id.picture_resolution_layout).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- openPictureResolutionDialog();
- }
- });
- mPictureResolutionText = (TextView) inflate.findViewById(R.id.pictureResolutionText);
- setCameraPictureResolutionModeFromCameraPreviewControl();
- setPictureResolutionText();
- return inflate;
- }
- public void changeSelectedCameraPictureResolution(int i, Point point) {
- mCameraPictureResolutionMode = i;
- if (mCameraPictureResolutionMode == 0) {
- mCameraPictureSize = null;
- } else {
- mCameraPictureSize = point;
- }
- setPictureResolutionText();
- }
- private void setPictureResolutionText() {
- if (mCameraPictureResolutionMode == 0) {
- mPictureResolutionText.setText(R.string.picture_size_auto);
- return;
- }
- Point point = mCameraPictureSize;
- if (point == null || point.x <= 0 || mCameraPictureSize.y <= 0) {
- mPictureResolutionText.setText("");
- return;
- }
- mPictureResolutionText.setText(CameraPreviewControl.getPictureSizeString(mCameraPictureSize.x, mCameraPictureSize.y));
- }
- private void setCameraPictureResolutionModeFromCameraPreviewControl() {
- mCameraPictureResolutionMode = mCameraPreviewControl.getPictureResolutionMode();
- mCameraPictureSize = null;
- if (mCameraPictureResolutionMode == 1) {
- mCameraPictureSize = mCameraPreviewControl.getPictureSize();
- }
- }
- private void openPictureResolutionDialog() {
- PictureResolutionDialogFragment.newInstance(mCameraPictureResolutionMode, mCameraPictureSize).show(getActivity().getSupportFragmentManager(), "picture-resolution");
- }
- private void changeValueAndFinish() {
- mCameraPreviewControl.setGuideMode(mGuideToggleButton.isChecked());
- mCameraPreviewControl.setAutoPictureMode(Boolean.valueOf(mAutoPhotoToggleButton.isChecked()));
- mCameraPreviewControl.setSaveDirecotry(mSaveDirectoryName);
- if (mCameraPictureResolutionMode == 0) {
- mCameraPreviewControl.setPictureResolutionModeAuto();
- } else {
- mCameraPreviewControl.setPictureSize(mCameraPictureSize);
- }
- getActivity().finish();
- }
- private void changeAutoPhotoToggleButtonStatus(boolean z) {
- if (z && mCameraPreviewControl.hasAutoPictureHardware(getActivity())) {
- mAutoPhotoToggleButton.setEnabled(true);
- return;
- }
- mAutoPhotoToggleButton.setChecked(false);
- mAutoPhotoToggleButton.setEnabled(false);
- }
- private void setSaveDirectoryText(String str) {
- mSaveDirectoryName = str;
- mSaveDirectoryText.setText(new File(mSaveDirectoryName).getName());
- }
- public void startSaveDirectoryActivity() {
- startActivityForResult(new Intent(getActivity(), FolderSelectActivity.class), 1);
- }
- public void onActivityResult(int i, int i2, Intent intent) {
- if (i == 1) {
- if (i2 == -1 && intent != null) {
- String stringExtra = intent.getStringExtra("SELECT_Folder");
- if (stringExtra != null) {
- setSaveDirectoryText(stringExtra);
- }
- } else if (i2 == 1) {
- SimpleMessageDialogFragment.newInstance(R.string.file_save_error_message).show(getFragmentManager(), "error-dialog");
- }
- }
- }
- public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
- menuInflater.inflate(R.menu.menu_done, menu);
- super.onCreateOptionsMenu(menu, menuInflater);
- }
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- if (menuItem.getItemId() != R.id.menuSettingsDone) {
- return super.onOptionsItemSelected(menuItem);
- }
- changeValueAndFinish();
- return true;
- }
- }
- }
|