123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- package com.epson.cameracopy.ui;
- import android.content.res.Configuration;
- import android.os.Bundle;
- import android.os.SystemClock;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.RadioGroup;
- import android.widget.TextView;
- import com.epson.cameracopy.printlayout.DocumentSizeInfo;
- import com.epson.cameracopy.printlayout.RegistedDocumentSizeList;
- import java.math.BigDecimal;
- import epson.print.ActivityIACommon;
- import epson.print.widgets.LongTapRepeatAdapter;
- /* renamed from: com.epson.cameracopy.ui.DocumentSizeEditActivity */
- public class DocumentSizeEditActivity extends ActivityIACommon implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
- private final double RATIO_INCHTOMM = 25.4d;
- private final double SIZE_INCH_MAX = 39.37d;
- private final double SIZE_INCH_MIN = 0.1d;
- private final int SIZE_MM_MAX = 1000;
- private final int SIZE_MM_MIN = 1;
- DocumentSizeInfo mDocumentSizeInfo;
- private double mHeight;
- private Button mHeightDec;
- private Button mHeightInc;
- private TextView mHeightText;
- private boolean mInch = false;
- int mPosition;
- private RadioGroup mScale;
- private double mWidth;
- private Button mWidthDec;
- private Button mWidthInc;
- private TextView mWidthText;
- protected void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- setContentView(R.layout.activity_document_size_edit);
- setActionBar(R.string.document_size_edit_title, true);
- mScale = (RadioGroup) findViewById(R.id.document_size_scale);
- mScale.setOnCheckedChangeListener(this);
- mWidthText = (TextView) findViewById(R.id.width);
- mWidthDec = (Button) findViewById(R.id.width_dec_button);
- mWidthDec.setOnClickListener(this);
- mWidthInc = (Button) findViewById(R.id.width_inc_button);
- mWidthInc.setOnClickListener(this);
- mHeightText = (TextView) findViewById(R.id.height);
- mHeightDec = (Button) findViewById(R.id.height_dec_button);
- mHeightDec.setOnClickListener(this);
- mHeightInc = (Button) findViewById(R.id.height_inc_button);
- mHeightInc.setOnClickListener(this);
- LongTapRepeatAdapter.bless(mWidthDec);
- LongTapRepeatAdapter.bless(mWidthInc);
- LongTapRepeatAdapter.bless(mHeightDec);
- LongTapRepeatAdapter.bless(mHeightInc);
- setDocumentSize();
- }
- protected void onPause() {
- super.onPause();
- if (isFinishing()) {
- deleteLongTapMessage();
- }
- }
- public void onClick(View view) {
- switch (view.getId()) {
- case R.id.height_dec_button /*2131231100*/:
- decHeight();
- return;
- case R.id.height_inc_button /*2131231101*/:
- incHeight();
- return;
- case R.id.width_dec_button /*2131231633*/:
- decWidth();
- return;
- case R.id.width_inc_button /*2131231634*/:
- incWidth();
- return;
- default:
- return;
- }
- }
- public void onCheckedChanged(RadioGroup radioGroup, int i) {
- if (i != -1) {
- if (i == R.id.inch_button) {
- mInch = true;
- convertDocumentSize();
- } else if (i == R.id.mm_button) {
- mInch = false;
- convertDocumentSize();
- }
- }
- radioGroup.invalidate();
- }
- private void setDocumentSize() {
- mDocumentSizeInfo = (DocumentSizeInfo) getIntent().getParcelableExtra("DocumentSize");
- mPosition = getIntent().getIntExtra("DocumentSizePos", -1);
- ((EditText) findViewById(R.id.et_document_size)).setText(mDocumentSizeInfo.getDocSizeName(this));
- mInch = mDocumentSizeInfo.getScaleId() == 2;
- if (mInch) {
- mScale.check(R.id.inch_button);
- mWidth = mDocumentSizeInfo.getWidth();
- double roundDownValue = getRoundDownValue(mWidth, 1);
- TextView textView = mWidthText;
- textView.setText(String.valueOf(roundDownValue) + " in");
- mHeight = mDocumentSizeInfo.getHeight();
- double roundDownValue2 = getRoundDownValue(mHeight, 1);
- TextView textView2 = mHeightText;
- textView2.setText(String.valueOf(roundDownValue2) + " in");
- return;
- }
- mScale.check(R.id.mm_button);
- mWidth = mDocumentSizeInfo.getWidth();
- TextView textView3 = mWidthText;
- textView3.setText(String.valueOf(getRoundDownValue(mWidth, 0)) + " mm");
- mHeight = mDocumentSizeInfo.getHeight();
- TextView textView4 = mHeightText;
- textView4.setText(String.valueOf(getRoundDownValue(mHeight, 0)) + " mm");
- }
- private void decWidth() {
- if (mInch) {
- mWidth = decDouble(mWidth, 0.1d);
- if (mWidth < 0.1d) {
- mWidth = 0.1d;
- }
- double roundDownValue = getRoundDownValue(mWidth, 1);
- TextView textView = mWidthText;
- textView.setText(String.valueOf(roundDownValue) + " in");
- mWidth = roundDownValue;
- return;
- }
- mWidth = decDouble(mWidth, 1.0d);
- if (mWidth < 1.0d) {
- mWidth = 1.0d;
- }
- int roundDownValue2 = getRoundDownValue(mWidth, 0);
- TextView textView2 = mWidthText;
- textView2.setText(String.valueOf(roundDownValue2) + " mm");
- mWidth = roundDownValue2;
- }
- private void incWidth() {
- if (mInch) {
- mWidth = incDouble(mWidth, 0.1d);
- if (mWidth > 39.37d) {
- mWidth = 39.37d;
- }
- double roundDownValue = getRoundDownValue(mWidth, 1);
- TextView textView = mWidthText;
- textView.setText(String.valueOf(roundDownValue) + " in");
- mWidth = roundDownValue;
- return;
- }
- mWidth = incDouble(mWidth, 1.0d);
- if (mWidth > 1000.0d) {
- mWidth = 1000.0d;
- }
- int roundDownValue2 = getRoundDownValue(mWidth, 0);
- TextView textView2 = mWidthText;
- textView2.setText(String.valueOf(roundDownValue2) + " mm");
- mWidth = roundDownValue2;
- }
- private void decHeight() {
- if (mInch) {
- mHeight = decDouble(mHeight, 0.1d);
- if (mHeight < 0.1d) {
- mHeight = 0.1d;
- }
- double roundDownValue = getRoundDownValue(mHeight, 1);
- TextView textView = mHeightText;
- textView.setText(String.valueOf(roundDownValue) + " in");
- return;
- }
- mHeight = decDouble(mHeight, 1.0d);
- if (mHeight < 1.0d) {
- mHeight = 1.0d;
- }
- int roundDownValue2 = getRoundDownValue(mHeight, 0);
- TextView textView2 = mHeightText;
- textView2.setText(String.valueOf(roundDownValue2) + " mm");
- mHeight = roundDownValue2;
- }
- private void incHeight() {
- if (mInch) {
- mHeight = incDouble(mHeight, 0.1d);
- if (mHeight > 39.37d) {
- mHeight = 39.37d;
- }
- double roundDownValue = getRoundDownValue(mHeight, 1);
- TextView textView = mHeightText;
- textView.setText(String.valueOf(roundDownValue) + " in");
- mHeight = roundDownValue;
- return;
- }
- mHeight = incDouble(mHeight, 1.0d);
- if (mHeight > 1000.0d) {
- mHeight = 1000.0d;
- }
- int roundDownValue2 = getRoundDownValue(mHeight, 0);
- TextView textView2 = mHeightText;
- textView2.setText(String.valueOf(roundDownValue2) + " mm");
- mHeight = roundDownValue2;
- }
- private void convertDocumentSize() {
- if (mInch) {
- mWidth /= 25.4d;
- double d = mWidth;
- if (d < 0.1d) {
- d = 0.1d;
- }
- mWidth = d;
- double roundDownValue = getRoundDownValue(mWidth, 1);
- mWidthText.setText(String.valueOf(roundDownValue) + " in");
- mWidth = roundDownValue;
- mHeight = mHeight / 25.4d;
- double d2 = mHeight;
- if (d2 < 0.1d) {
- d2 = 0.1d;
- }
- mHeight = d2;
- double roundDownValue2 = getRoundDownValue(mHeight, 1);
- mHeightText.setText(String.valueOf(roundDownValue2) + " in");
- mHeight = roundDownValue2;
- return;
- }
- mWidth *= 25.4d;
- double d3 = mWidth;
- if (d3 > 1000.0d) {
- d3 = 1000.0d;
- }
- mWidth = d3;
- int roundDownValue3 = getRoundDownValue(mWidth, 0);
- mWidthText.setText(String.valueOf(roundDownValue3) + " mm");
- mWidth = roundDownValue3;
- mHeight = mHeight * 25.4d;
- double d4 = mHeight;
- if (d4 > 1000.0d) {
- d4 = 1000.0d;
- }
- mHeight = d4;
- int roundDownValue4 = getRoundDownValue(mHeight, 0);
- mHeightText.setText(String.valueOf(roundDownValue4) + " mm");
- mHeight = roundDownValue4;
- }
- private double getRoundDownValue(double d, int i) {
- return new BigDecimal(String.valueOf(d)).setScale(i, 1).doubleValue();
- }
- private void checkDocumentSize() {
- String obj = ((EditText) findViewById(R.id.et_document_size)).getText().toString();
- if (obj.isEmpty()) {
- SimpleMessageDialogFragment.newInstance(R.string.no_name_documentsize_message).show(getSupportFragmentManager(), "error-dialog");
- return;
- }
- mDocumentSizeInfo.setDocSizeName(obj);
- mDocumentSizeInfo.setScaleId(mInch ? 2 : 1);
- mDocumentSizeInfo.setWidth(getRoundDownValue(mWidth, 1));
- mDocumentSizeInfo.setHeight(getRoundDownValue(mHeight, 1));
- RegistedDocumentSizeList instance = RegistedDocumentSizeList.getInstance(this);
- if (instance.isExistDocumentSizeName(obj, mPosition)) {
- SimpleMessageDialogFragment.newInstance(R.string.exist_documentsize_message).show(getSupportFragmentManager(), "error-dialog");
- return;
- }
- int i = mPosition;
- if (i < 0) {
- instance.add(mDocumentSizeInfo);
- finish();
- return;
- }
- instance.update(mDocumentSizeInfo, i);
- finish();
- }
- private double incDouble(double d, double d2) {
- return new BigDecimal(String.valueOf(d)).add(new BigDecimal(String.valueOf(d2))).doubleValue();
- }
- private double decDouble(double d, double d2) {
- return new BigDecimal(String.valueOf(d)).subtract(new BigDecimal(String.valueOf(d2))).doubleValue();
- }
- public boolean onCreateOptionsMenu(Menu menu) {
- if (mDocumentSizeInfo.getPaperId() == -2) {
- getMenuInflater().inflate(R.menu.menu_done, menu);
- }
- return super.onCreateOptionsMenu(menu);
- }
- public boolean onOptionsItemSelected(MenuItem menuItem) {
- if (menuItem.getItemId() != R.id.menuSettingsDone) {
- return super.onOptionsItemSelected(menuItem);
- }
- checkDocumentSize();
- return true;
- }
- protected void deleteLongTapMessage() {
- MotionEvent obtain = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis() + 10, 1, 0.0f, 0.0f, 0);
- mWidthDec.dispatchTouchEvent(obtain);
- mWidthInc.dispatchTouchEvent(obtain);
- mHeightDec.dispatchTouchEvent(obtain);
- mHeightInc.dispatchTouchEvent(obtain);
- }
- public void onConfigurationChanged(Configuration configuration) {
- super.onConfigurationChanged(configuration);
- deleteLongTapMessage();
- }
- }
|