123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- package epson.scan.activity;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.AdapterView;
- import android.widget.ListView;
- import java.util.ArrayList;
- import java.util.LinkedHashMap;
- import epson.common.Constants;
- import epson.common.CustomListRowAdapter;
- import epson.common.CustomListRowImpl;
- import epson.print.ActivityIACommon;
- import epson.print.R;
- public class InputUnitSettingActivity extends ActivityIACommon {
- public static final int IGNORE_ADF_ALIGNMENT = -1;
- private static final String SCAN_SETTINGS_ADF_ALIGNMENT = "adf-alignment";
- private static final String SCAN_SETTINGS_LAST_VALUE = "SCAN_SETTINGS_LAST_VALUE";
- private boolean displayAdfAlignment;
- private int lastAdfGuide;
- private int lastValue;
- private ListView listSelect;
- private ListView listSelect2;
- private final AdapterView.OnItemClickListener mListOptionClick = new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
- int unused = InputUnitSettingActivity.this.lastValue = ((ScanSettingsDetailAdapter.DetailSettingHolder) view.getTag()).value;
- InputUnitSettingActivity.this.ssdAdapter.setSelected (lastValue);
- InputUnitSettingActivity.this.ssdAdapter.notifyDataSetChanged();
- if (lastValue == 1) {
- InputUnitSettingActivity.this.listSelect2.setVisibility(View.VISIBLE);
- } else {
- InputUnitSettingActivity.this.listSelect2.setVisibility(View.GONE);
- }
- }
- };
- private final AdapterView.OnItemClickListener mListOptionClick2 = new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
- int unused = InputUnitSettingActivity.this.lastAdfGuide = i;
- switch (i) {
- case 0:
- InputUnitSettingActivity.mlAdapter.setList(0, CustomListRowImpl.create (getString(R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_left_adst)).suffixImage(Integer.valueOf(R.drawable.selected)));
- InputUnitSettingActivity.mlAdapter.setList(1, CustomListRowImpl.create (getString(R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_center_adst)));
- break;
- case 1:
- InputUnitSettingActivity.mlAdapter.setList(0, CustomListRowImpl.create (getString(R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_left_adst)));
- InputUnitSettingActivity.mlAdapter.setList(1, CustomListRowImpl.create (getString(R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_center_adst)).suffixImage(Integer.valueOf(R.drawable.selected)));
- break;
- }
- InputUnitSettingActivity.mlAdapter.notifyDataSetChanged();
- }
- };
- private CustomListRowAdapter mlAdapter;
- private ScanSettingsDetailAdapter ssdAdapter;
- protected void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- setContentView(R.layout.scan_settings_detail_2);
- Bundle extras = getIntent().getExtras();
- lastValue = extras.getInt(SCAN_SETTINGS_LAST_VALUE);
- lastAdfGuide = extras.getInt(SCAN_SETTINGS_ADF_ALIGNMENT);
- if (lastAdfGuide >= 0) {
- displayAdfAlignment = true;
- } else {
- displayAdfAlignment = false;
- }
- listSelect = (ListView) findViewById(R.id.lvScannerSettingOptions);
- listSelect2 = (ListView) findViewById(R.id.lvScannerSettingOptions2);
- makeListCorrespondenceOptions();
- setActionBar(getTitle().toString(), true);
- }
- private void makeListCorrespondenceOptions() {
- setTitle(getString(R.string.str_settings_source_title));
- ArrayList arrayList = new ArrayList();
- switch (lastAdfGuide) {
- case 0:
- arrayList.add(CustomListRowImpl.create().addText(getString(R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_left_adst)).suffixImage(Integer.valueOf(R.drawable.selected)));
- arrayList.add(CustomListRowImpl.create().addText(getString(R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_center_adst)));
- break;
- case 1:
- arrayList.add(CustomListRowImpl.create().addText(getString(R.string.str_settings_right_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_left_adst)));
- arrayList.add(CustomListRowImpl.create().addText(getString(R.string.str_settings_center_aligned)).prefixImage(Integer.valueOf(R.drawable.adf_center_adst)).suffixImage(Integer.valueOf(R.drawable.selected)));
- break;
- }
- mlAdapter = new CustomListRowAdapter(this, R.layout.com_customline_row, arrayList);
- listSelect2.setAdapter(mlAdapter);
- listSelect2.setOnItemClickListener(mListOptionClick2);
- if (lastValue == 1) {
- listSelect2.setVisibility(View.VISIBLE);
- } else {
- listSelect2.setVisibility(View.GONE);
- }
- LinkedHashMap linkedHashMap = new LinkedHashMap();
- linkedHashMap.put(getString(R.string.str_settings_source_doctable), 0);
- linkedHashMap.put(getString(R.string.str_settings_source_adf), 1);
- ssdAdapter = new ScanSettingsDetailAdapter(getBaseContext(), linkedHashMap, lastValue);
- listSelect.setAdapter(ssdAdapter);
- listSelect.setOnItemClickListener(mListOptionClick);
- }
- public void onBackPressed() {
- Intent intent = new Intent();
- intent.putExtra(Constants.SCAN_REFS_SETTINGS_SOURCE, lastValue);
- intent.putExtra(SCAN_SETTINGS_ADF_ALIGNMENT, displayAdfAlignment ? lastAdfGuide : -1);
- setResult(-1, intent);
- finish();
- }
- public static Intent getStartIntent(Context context, int i, int i2) {
- Intent intent = new Intent(context, InputUnitSettingActivity.class);
- intent.putExtra(SCAN_SETTINGS_LAST_VALUE, i);
- intent.putExtra(SCAN_SETTINGS_ADF_ALIGNMENT, i2);
- return intent;
- }
- public static int getInputUnit(Intent intent) {
- if (intent == null) {
- return 0;
- }
- return intent.getIntExtra(Constants.SCAN_REFS_SETTINGS_SOURCE, 0);
- }
- public static int getAdfAlignment(Intent intent) {
- if (intent == null) {
- return -1;
- }
- return intent.getIntExtra(SCAN_SETTINGS_ADF_ALIGNMENT, -1);
- }
- }
|