package epson.scan.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;


import com.epson.iprint.shared.SharedParamScan;

class SettingActivityParams {
    private static final Class<? extends Activity> ESC_I1_SETTING_ACTIVITY = ScanSettingsActivity.class;
    private static final Class<? extends Activity> ESC_I2_SETTING_ACTIVITY = I2ScanSettingActivity.class;
    static final String PARAM_KEY_EXTERNAL_SCAN_PARAMS = "external-scan-params";
    static final String PARAM_KEY_HIDE_COLOR_MODE = "hide-color-mode";
    static final String PARAM_KEY_HIDE_RESOLUTION = "hide-resolution";
    private static final String PARAM_RETURN_IF_ESC_I_VERSION_CHANGED = "return-if-esc-i-version-changed";
    private static final String PARAM_SCANNER_PROPERTY_WRAPPER = "scanner-property-wrapper";
    static final int RESULT_ESC_I_VERSION_CHANGED = 1;

    SettingActivityParams() {
    }

    static boolean returnIfEscIVersionChanged(Intent intent) {
        return intent.getBooleanExtra(PARAM_RETURN_IF_ESC_I_VERSION_CHANGED, false);
    }

    @NonNull
    static Intent getChangeSettingActivityStartIntent(Context context, ScannerPropertyWrapper scannerPropertyWrapper, boolean z, boolean z2, boolean z3, SharedParamScan sharedParamScan) {
        Intent intent = new Intent(context, getSettingActivityClass(scannerPropertyWrapper.getEscIVersion()));
        intent.putExtra(PARAM_RETURN_IF_ESC_I_VERSION_CHANGED, z);
        intent.putExtra(PARAM_SCANNER_PROPERTY_WRAPPER, scannerPropertyWrapper);
        intent.putExtra("hide-color-mode", z2);
        intent.putExtra("hide-resolution", z3);
        intent.putExtra("external-scan-params", sharedParamScan);
        return intent;
    }

    private static Class<?> getSettingActivityClass(int i) {
        if (i != 2) {
            return ESC_I1_SETTING_ACTIVITY;
        }
        return ESC_I2_SETTING_ACTIVITY;
    }

    @Nullable
    static ScannerPropertyWrapper getScannerPropertyWrapper(Intent intent) {
        if (intent == null) {
            return null;
        }
        return (ScannerPropertyWrapper) intent.getSerializableExtra(PARAM_SCANNER_PROPERTY_WRAPPER);
    }

    @NonNull
    static Intent getSettingReturnIntent(@Nullable ScannerPropertyWrapper scannerPropertyWrapper) {
        Intent intent = new Intent();
        intent.putExtra(PARAM_SCANNER_PROPERTY_WRAPPER, scannerPropertyWrapper);
        return intent;
    }

    static Intent getScanSearchReturnIntent(ScannerPropertyWrapper scannerPropertyWrapper) {
        Intent intent = new Intent();
        intent.putExtra(PARAM_SCANNER_PROPERTY_WRAPPER, scannerPropertyWrapper);
        return intent;
    }
}
