package epson.scan.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.TextView;
import epson.common.Constants;
import epson.print.ActivityIACommon;
import epson.print.C2135R;

public class ScanSettingsAdvanceDensityActivity extends ActivityIACommon {
    private static final int DEFAULT_DENSITY = 128;
    private static final String PARAM_KEY_DENSITY = "SCAN_SETTINGS_LAST_DENSITY";
    private static final String PARAM_KEY_DENSITY_STATUS = "SCAN_SETTINGS_LAST_DENSITY_STATUS";
    /* access modifiers changed from: private */
    public boolean densityStatus;
    /* access modifiers changed from: private */
    public int densityValue;
    private SeekBar.OnSeekBarChangeListener mSeekDensityChangeListener = new SeekBar.OnSeekBarChangeListener() {
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            int unused = ScanSettingsAdvanceDensityActivity.this.densityValue = 255 - i;
            ScanSettingsAdvanceDensityActivity.this.tvDensityValue.setText(String.format(Constants.DENSITY_VALUE, new Object[]{Integer.valueOf(255 - ScanSettingsAdvanceDensityActivity.this.densityValue)}));
        }
    };
    private View.OnClickListener mToogleDensityListener = new View.OnClickListener() {
        public void onClick(View view) {
            ScanSettingsAdvanceDensityActivity scanSettingsAdvanceDensityActivity = ScanSettingsAdvanceDensityActivity.this;
            boolean unused = scanSettingsAdvanceDensityActivity.densityStatus = scanSettingsAdvanceDensityActivity.toggleDensity.isChecked();
            if (!ScanSettingsAdvanceDensityActivity.this.densityStatus) {
                ScanSettingsAdvanceDensityActivity.this.seekDensity.setProgress(127);
                ScanSettingsAdvanceDensityActivity.this.seekDensity.setEnabled(false);
                return;
            }
            ScanSettingsAdvanceDensityActivity.this.seekDensity.setEnabled(true);
        }
    };
    /* access modifiers changed from: private */
    public SeekBar seekDensity;
    /* access modifiers changed from: private */
    public Switch toggleDensity;
    /* access modifiers changed from: private */
    public TextView tvDensityValue;

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) C2135R.layout.scan_settings_advance_density);
        setActionBar((int) C2135R.string.brightness, true);
        Bundle extras = getIntent().getExtras();
        extras.getInt(Constants.SCAN_SETTINGS_DETAIL_TITLE);
        this.densityValue = extras.getInt(PARAM_KEY_DENSITY);
        this.densityStatus = extras.getBoolean(PARAM_KEY_DENSITY_STATUS);
        this.seekDensity = (SeekBar) findViewById(C2135R.C2137id.seekDensity);
        this.seekDensity.setProgress(this.densityValue);
        this.seekDensity.setOnSeekBarChangeListener(this.mSeekDensityChangeListener);
        this.tvDensityValue = (TextView) findViewById(C2135R.C2137id.tvDensityValue);
        this.tvDensityValue.setText(String.format(Constants.DENSITY_VALUE, new Object[]{String.valueOf(255 - this.densityValue)}));
        this.seekDensity.setProgress(255 - this.densityValue);
        this.toggleDensity = (Switch) findViewById(C2135R.C2137id.toggleDensity);
        this.toggleDensity.setChecked(this.densityStatus);
        this.toggleDensity.setOnClickListener(this.mToogleDensityListener);
        if (!this.toggleDensity.isChecked()) {
            this.seekDensity.setEnabled(false);
        } else {
            this.seekDensity.setEnabled(true);
        }
    }

    public void onBackPressed() {
        Intent intent = getIntent();
        intent.putExtra(PARAM_KEY_DENSITY, this.densityValue);
        intent.putExtra(PARAM_KEY_DENSITY_STATUS, this.densityStatus);
        setResult(-1, intent);
        finish();
        super.onBackPressed();
    }

    @NonNull
    public static Intent getStartIntent(@NonNull Context context, int i, boolean z) {
        Intent intent = new Intent(context, ScanSettingsAdvanceDensityActivity.class);
        intent.putExtra(PARAM_KEY_DENSITY, i);
        intent.putExtra(PARAM_KEY_DENSITY_STATUS, z);
        return intent;
    }

    public static int getDensityFromReturnIntent(@Nullable Intent intent) {
        if (intent == null) {
            return 128;
        }
        return intent.getIntExtra(PARAM_KEY_DENSITY, 128);
    }

    public static boolean getChangeAble(@Nullable Intent intent) {
        if (intent == null) {
            return false;
        }
        return intent.getBooleanExtra(PARAM_KEY_DENSITY_STATUS, false);
    }
}
