PrintSetting.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. package epson.print.screen;
  2. import android.content.ContentValues;
  3. import android.content.Context;
  4. import android.content.SharedPreferences;
  5. import android.database.Cursor;
  6. import android.net.Uri;
  7. import com.box.androidsdk.content.requests.BoxRequestsMetadata;
  8. import com.epson.mobilephone.common.PrintingLib.define.Constants;
  9. import com.epson.mobilephone.common.escpr.MediaInfo;
  10. import java.util.Enumeration;
  11. import java.util.HashMap;
  12. import java.util.Locale;
  13. import java.util.Map;
  14. import epson.print.IprintApplication;
  15. import epson.print.Util.EPLog;
  16. import epson.provider.SharedPreferencesProvider;
  17. public class PrintSetting {
  18. private static final String[] CAMERA_COPY_KEYS = {Constants.PREFS_INFO_SIZETYPESET_CAMERACOPY, Constants.PAPER_SOURCE_CAMERACOPY, Constants.COLOR_CAMERACOPY, Constants.LAYOUT_CAMERACOPY, Constants.PAPER_TYPE_CAMERACOPY, Constants.PAPER_SIZE_CAMERACOPY, Constants.QUALITY_CAMERACOPY, Constants.FEED_DIRECTION_CAMERACOPY};
  19. public static final int EMPTY_PRE_VALUE = -1;
  20. private static final String TAG = "PrintSetting";
  21. Map<String, Object> allValueFromContentProvider = new HashMap();
  22. public int brightnessValue = 0;
  23. public int colorValue;
  24. Context context;
  25. public int contrastValue = 0;
  26. public int copiesValue = 1;
  27. public int duplexValue;
  28. public int endValue = 1;
  29. public int feedDirectionValue;
  30. private Kind kind;
  31. public int layoutMultiPageValue;
  32. public int layoutValue;
  33. public int paperSizeValue;
  34. public int paperSourceValue;
  35. public int paperTypeValue;
  36. public int photoApfValueForLocalPrinter = 0;
  37. public boolean printAll = true;
  38. public int printdate = 0;
  39. public int qualityValue;
  40. public int saturationValue = 0;
  41. SharedPreferences settings = null;
  42. public int sharpnessForPhoto = 0;
  43. public int startValue = 1;
  44. public enum Kind {
  45. document,
  46. photo,
  47. cameracopy,
  48. NotSet
  49. }
  50. public Kind getKind() {
  51. return kind;
  52. }
  53. public PrintSetting(Context context2, Kind kind2) {
  54. if (SharedPreferencesProvider.checkPackageUseSharedPreferencesProvider(context2)) {
  55. context = null;
  56. settings = null;
  57. } else {
  58. context = context2;
  59. settings = context2.getSharedPreferences("PrintSetting", 0);
  60. }
  61. if (kind2 != null) {
  62. kind = kind2;
  63. } else {
  64. kind = Kind.NotSet;
  65. }
  66. }
  67. public static PrintSetting getInstance(Context context2, String str) {
  68. Kind kind2 = Kind.photo;
  69. try {
  70. kind2 = Kind.valueOf(str);
  71. } catch (Exception e) {
  72. EPLog.m306e("Exception " + e);
  73. }
  74. return new PrintSetting(context2, kind2);
  75. }
  76. public void loadSettings() {
  77. preparateSettings();
  78. paperSizeValue = getPaperSize();
  79. paperTypeValue = getPaperType();
  80. layoutValue = getLayout();
  81. layoutMultiPageValue = getLayoutMultiPage();
  82. qualityValue = getQuality();
  83. paperSourceValue = getPaperSorce();
  84. colorValue = getColor();
  85. duplexValue = getDuplex();
  86. feedDirectionValue = getFeedDirection();
  87. switch (kind) {
  88. case document:
  89. SharedPreferences sharedPreferences = settings;
  90. if (sharedPreferences != null) {
  91. printAll = sharedPreferences.getBoolean(Constants.PRINT_ALL, true);
  92. startValue = settings.getInt(Constants.START_PAGE, 1);
  93. endValue = settings.getInt(Constants.END_PAGE, 1);
  94. break;
  95. } else {
  96. printAll = getSettingBoolean(Constants.PRINT_ALL, true);
  97. startValue = getSetting(Constants.START_PAGE, (String) null, 1);
  98. endValue = getSetting(Constants.END_PAGE, (String) null, 1);
  99. break;
  100. }
  101. case photo:
  102. SharedPreferences sharedPreferences2 = settings;
  103. if (sharedPreferences2 != null) {
  104. printdate = sharedPreferences2.getInt(Constants.PRINTDATE, 0);
  105. photoApfValueForLocalPrinter = settings.getInt(Constants.APF_PHOTO, 1);
  106. sharpnessForPhoto = settings.getInt(Constants.SHARPNESS_PHOTO, 1);
  107. break;
  108. } else {
  109. printdate = getSetting(Constants.PRINTDATE, (String) null, 0);
  110. photoApfValueForLocalPrinter = getSetting(Constants.APF_PHOTO, (String) null, 1);
  111. sharpnessForPhoto = getSetting(Constants.SHARPNESS_PHOTO, (String) null, 1);
  112. break;
  113. }
  114. }
  115. SharedPreferences sharedPreferences3 = settings;
  116. if (sharedPreferences3 == null) {
  117. copiesValue = getSetting(Constants.COPIES, (String) null, 1);
  118. } else {
  119. copiesValue = sharedPreferences3.getInt(Constants.COPIES, 1);
  120. }
  121. brightnessValue = 0;
  122. contrastValue = 0;
  123. saturationValue = 0;
  124. }
  125. private void preparateSettings() {
  126. if (settings == null) {
  127. Cursor query = IprintApplication.getInstance().getContentResolver().query(Uri.parse("content://epson.print.provider.SharedPreferences/"), (String[]) null, (String) null, (String[]) null, (String) null);
  128. query.moveToFirst();
  129. allValueFromContentProvider.clear();
  130. EPLog.i();
  131. String str = null;
  132. Object obj = null;
  133. do {
  134. for (int i = 0; i < query.getColumnCount(); i++) {
  135. String columnName = query.getColumnName(i);
  136. if (columnName.equals("key")) {
  137. str = query.getString(i);
  138. } else if (columnName.equals(BoxRequestsMetadata.UpdateItemMetadata.BoxMetadataUpdateTask.VALUE)) {
  139. EPLog.i("さーびす", "PUT key: " + str + " getType: " + query.getType(i));
  140. query.getType(i);
  141. int type = query.getType(i);
  142. if (type == 1) {
  143. obj = Integer.valueOf(query.getInt(i));
  144. } else if (type == 3) {
  145. obj = query.getString(i);
  146. }
  147. } else {
  148. str = null;
  149. }
  150. }
  151. if (str != null) {
  152. if (!(obj instanceof String) || (!obj.equals("true") && !obj.equals("false"))) {
  153. allValueFromContentProvider.put(str, obj);
  154. } else {
  155. allValueFromContentProvider.put(str, Boolean.valueOf((String) obj));
  156. }
  157. str = null;
  158. }
  159. } while (query.moveToNext());
  160. query.close();
  161. }
  162. }
  163. public void saveSettings() {
  164. ContentValues contentValues;
  165. SharedPreferences.Editor editor;
  166. EPLog.d("PrintSetting", "saveSettings() " + kind.name());
  167. SharedPreferences sharedPreferences = settings;
  168. if (sharedPreferences == null) {
  169. contentValues = new ContentValues();
  170. editor = null;
  171. } else {
  172. editor = sharedPreferences.edit();
  173. contentValues = null;
  174. }
  175. switch (kind) {
  176. case document:
  177. if (editor != null) {
  178. editor.putInt(Constants.PAPER_SIZE, paperSizeValue);
  179. editor.putInt(Constants.PAPER_TYPE, paperTypeValue);
  180. editor.putInt(Constants.LAYOUT, layoutValue);
  181. editor.putInt(Constants.LAYOUT_MULTIPAGE, layoutMultiPageValue);
  182. editor.putInt(Constants.QUALITY, qualityValue);
  183. editor.putInt(Constants.PAPER_SOURCE, paperSourceValue);
  184. editor.putInt(Constants.COLOR, colorValue);
  185. editor.putInt(Constants.DUPLEX, duplexValue);
  186. editor.putInt(Constants.FEED_DIRECTION, feedDirectionValue);
  187. editor.putBoolean(Constants.PRINT_ALL, printAll);
  188. editor.putInt(Constants.START_PAGE, startValue);
  189. editor.putInt(Constants.END_PAGE, endValue);
  190. break;
  191. } else {
  192. contentValues.put(Constants.PAPER_SIZE, Integer.valueOf(paperSizeValue));
  193. contentValues.put(Constants.PAPER_TYPE, Integer.valueOf(paperTypeValue));
  194. contentValues.put(Constants.LAYOUT, Integer.valueOf(layoutValue));
  195. contentValues.put(Constants.LAYOUT_MULTIPAGE, Integer.valueOf(layoutMultiPageValue));
  196. contentValues.put(Constants.QUALITY, Integer.valueOf(qualityValue));
  197. contentValues.put(Constants.PAPER_SOURCE, Integer.valueOf(paperSourceValue));
  198. contentValues.put(Constants.COLOR, Integer.valueOf(colorValue));
  199. contentValues.put(Constants.DUPLEX, Integer.valueOf(duplexValue));
  200. contentValues.put(Constants.FEED_DIRECTION, Integer.valueOf(feedDirectionValue));
  201. contentValues.put(Constants.PRINT_ALL, Boolean.valueOf(printAll));
  202. contentValues.put(Constants.START_PAGE, Integer.valueOf(startValue));
  203. contentValues.put(Constants.END_PAGE, Integer.valueOf(endValue));
  204. break;
  205. }
  206. case photo:
  207. if (editor != null) {
  208. editor.putInt(Constants.PAPER_SIZE_PHOTO, paperSizeValue);
  209. editor.putInt(Constants.PAPER_TYPE_PHOTO, paperTypeValue);
  210. editor.putInt(Constants.LAYOUT_PHOTO, layoutValue);
  211. editor.putInt(Constants.LAYOUT_MULTIPAGE_PHOTO, layoutMultiPageValue);
  212. editor.putInt(Constants.QUALITY_PHOTO, qualityValue);
  213. editor.putInt(Constants.PAPER_SOURCE_PHOTO, paperSourceValue);
  214. editor.putInt(Constants.COLOR_PHOTO, colorValue);
  215. editor.putInt(Constants.DUPLEX_PHOTO, duplexValue);
  216. editor.putInt(Constants.FEED_DIRECTION_PHOTO, feedDirectionValue);
  217. editor.putInt(Constants.PRINTDATE, printdate);
  218. editor.putInt(Constants.APF_PHOTO, photoApfValueForLocalPrinter);
  219. editor.putInt(Constants.SHARPNESS_PHOTO, sharpnessForPhoto);
  220. break;
  221. } else {
  222. contentValues.put(Constants.PAPER_SIZE_PHOTO, Integer.valueOf(paperSizeValue));
  223. contentValues.put(Constants.PAPER_TYPE_PHOTO, Integer.valueOf(paperTypeValue));
  224. contentValues.put(Constants.LAYOUT_PHOTO, Integer.valueOf(layoutValue));
  225. contentValues.put(Constants.LAYOUT_MULTIPAGE_PHOTO, Integer.valueOf(layoutMultiPageValue));
  226. contentValues.put(Constants.QUALITY_PHOTO, Integer.valueOf(qualityValue));
  227. contentValues.put(Constants.PAPER_SOURCE_PHOTO, Integer.valueOf(paperSourceValue));
  228. contentValues.put(Constants.COLOR_PHOTO, Integer.valueOf(colorValue));
  229. contentValues.put(Constants.DUPLEX_PHOTO, Integer.valueOf(duplexValue));
  230. contentValues.put(Constants.FEED_DIRECTION_PHOTO, Integer.valueOf(feedDirectionValue));
  231. contentValues.put(Constants.PRINTDATE, Integer.valueOf(printdate));
  232. contentValues.put(Constants.APF_PHOTO, Integer.valueOf(photoApfValueForLocalPrinter));
  233. contentValues.put(Constants.SHARPNESS_PHOTO, Integer.valueOf(sharpnessForPhoto));
  234. break;
  235. }
  236. case cameracopy:
  237. if (editor != null) {
  238. editor.putInt(Constants.PAPER_SIZE_CAMERACOPY, paperSizeValue);
  239. editor.putInt(Constants.PAPER_TYPE_CAMERACOPY, paperTypeValue);
  240. editor.putInt(Constants.LAYOUT_CAMERACOPY, layoutValue);
  241. editor.putInt(Constants.QUALITY_CAMERACOPY, qualityValue);
  242. editor.putInt(Constants.PAPER_SOURCE_CAMERACOPY, paperSourceValue);
  243. editor.putInt(Constants.COLOR_CAMERACOPY, colorValue);
  244. editor.putInt(Constants.FEED_DIRECTION_CAMERACOPY, feedDirectionValue);
  245. break;
  246. } else {
  247. contentValues.put(Constants.PAPER_SIZE_CAMERACOPY, Integer.valueOf(paperSizeValue));
  248. contentValues.put(Constants.PAPER_TYPE_CAMERACOPY, Integer.valueOf(paperTypeValue));
  249. contentValues.put(Constants.LAYOUT_CAMERACOPY, Integer.valueOf(layoutValue));
  250. contentValues.put(Constants.QUALITY_CAMERACOPY, Integer.valueOf(qualityValue));
  251. contentValues.put(Constants.PAPER_SOURCE_CAMERACOPY, Integer.valueOf(paperSourceValue));
  252. contentValues.put(Constants.COLOR_CAMERACOPY, Integer.valueOf(colorValue));
  253. contentValues.put(Constants.FEED_DIRECTION_CAMERACOPY, Integer.valueOf(feedDirectionValue));
  254. break;
  255. }
  256. }
  257. if (editor == null) {
  258. contentValues.put(Constants.COPIES, Integer.valueOf(copiesValue));
  259. contentValues.put(Constants.BRIGHTNESS, Integer.valueOf(brightnessValue));
  260. contentValues.put(Constants.CONTRAST, Integer.valueOf(contrastValue));
  261. contentValues.put(Constants.SATURATION, Integer.valueOf(saturationValue));
  262. } else {
  263. editor.putInt(Constants.COPIES, copiesValue);
  264. editor.putInt(Constants.BRIGHTNESS, brightnessValue);
  265. editor.putInt(Constants.CONTRAST, contrastValue);
  266. editor.putInt(Constants.SATURATION, saturationValue);
  267. }
  268. if (settings == null) {
  269. IprintApplication.getInstance().getContentResolver().update(Uri.parse("content://epson.print.provider.SharedPreferences/"), contentValues, (String) null, (String[]) null);
  270. return;
  271. }
  272. editor.commit();
  273. }
  274. public int getDefaultPaperSize() {
  275. int code = Constants.PaperName.EPS_MSID_A4.getCode();
  276. String country = Locale.getDefault().getCountry();
  277. switch (kind) {
  278. case document:
  279. case cameracopy:
  280. return (country.equals(Locale.US.getCountry()) || country.equals(Locale.CANADA.getCountry())) ? Constants.PaperName.EPS_MSID_LETTER.getCode() : Constants.PaperName.EPS_MSID_A4.getCode();
  281. case photo:
  282. int code2 = Constants.PaperName.EPS_MSID_4X6.getCode();
  283. if (country.equals(Locale.JAPAN.getCountry())) {
  284. return Constants.PaperName.EPS_MSID_L.getCode();
  285. }
  286. return code2;
  287. default:
  288. return code;
  289. }
  290. }
  291. private int getPaperSize() {
  292. int defaultPaperSize = getDefaultPaperSize();
  293. switch (kind) {
  294. case document:
  295. return getSetting(epson.common.Constants.PAPER_SIZE, (String) null, defaultPaperSize);
  296. case photo:
  297. return getSetting(epson.common.Constants.PAPER_SIZE_PHOTO, (String) null, defaultPaperSize);
  298. case cameracopy:
  299. return getSetting(epson.common.Constants.PAPER_SIZE_CAMERACOPY, (String) null, defaultPaperSize);
  300. default:
  301. return defaultPaperSize;
  302. }
  303. }
  304. public int getDefaultPaperType() {
  305. switch (kind) {
  306. case document:
  307. case cameracopy:
  308. return Constants.MediaName.EPS_MTID_PLAIN.getCode();
  309. case photo:
  310. return Constants.MediaName.EPS_MTID_PGPHOTO.getCode();
  311. default:
  312. return 0;
  313. }
  314. }
  315. private int getPaperType() {
  316. int defaultPaperType = getDefaultPaperType();
  317. switch (kind) {
  318. case document:
  319. return getSetting(epson.common.Constants.PAPER_TYPE, (String) null, defaultPaperType);
  320. case photo:
  321. return getSetting(epson.common.Constants.PAPER_TYPE_PHOTO, (String) null, defaultPaperType);
  322. case cameracopy:
  323. return getSetting(epson.common.Constants.PAPER_TYPE_CAMERACOPY, (String) null, defaultPaperType);
  324. default:
  325. return defaultPaperType;
  326. }
  327. }
  328. private int getLayout() {
  329. int i;
  330. switch (kind) {
  331. case photo:
  332. i = getSetting(epson.common.Constants.LAYOUT_PHOTO, (String) null, 1);
  333. break;
  334. case cameracopy:
  335. i = getSetting(epson.common.Constants.LAYOUT_CAMERACOPY, (String) null, 2);
  336. break;
  337. default:
  338. i = 2;
  339. break;
  340. }
  341. if (i == 8) {
  342. return 2;
  343. }
  344. return i;
  345. }
  346. private int getLayoutMultiPage() {
  347. switch (kind) {
  348. case document:
  349. return getSetting(epson.common.Constants.LAYOUT_MULTIPAGE, (String) null, 0);
  350. case photo:
  351. return getSetting(epson.common.Constants.LAYOUT_MULTIPAGE_PHOTO, (String) null, 0);
  352. default:
  353. return 0;
  354. }
  355. }
  356. private int getQuality() {
  357. switch (kind) {
  358. case document:
  359. return getSetting(epson.common.Constants.QUALITY, (String) null, 2);
  360. case photo:
  361. return getSetting(epson.common.Constants.QUALITY_PHOTO, (String) null, 2);
  362. case cameracopy:
  363. return getSetting(epson.common.Constants.QUALITY_CAMERACOPY, (String) null, 2);
  364. default:
  365. return 2;
  366. }
  367. }
  368. private int getPaperSorce() {
  369. int i;
  370. switch (kind) {
  371. case document:
  372. i = getSetting(epson.common.Constants.PAPER_SOURCE, (String) null, 128);
  373. break;
  374. case photo:
  375. i = getSetting(epson.common.Constants.PAPER_SOURCE_PHOTO, (String) null, 128);
  376. break;
  377. case cameracopy:
  378. i = getSetting(epson.common.Constants.PAPER_SOURCE_CAMERACOPY, (String) null, 128);
  379. break;
  380. default:
  381. i = 128;
  382. break;
  383. }
  384. if (i == 0) {
  385. return 128;
  386. }
  387. return i;
  388. }
  389. private int getDuplex() {
  390. switch (kind) {
  391. case document:
  392. return getSetting(epson.common.Constants.DUPLEX, (String) null, 0);
  393. case photo:
  394. return getSetting(epson.common.Constants.DUPLEX_PHOTO, (String) null, 0);
  395. default:
  396. return 0;
  397. }
  398. }
  399. private int getFeedDirection() {
  400. switch (kind) {
  401. case document:
  402. return getSetting(epson.common.Constants.FEED_DIRECTION, (String) null, 0);
  403. case photo:
  404. return getSetting(epson.common.Constants.FEED_DIRECTION_PHOTO, (String) null, 0);
  405. case cameracopy:
  406. return getSetting(epson.common.Constants.FEED_DIRECTION_CAMERACOPY, (String) null, 0);
  407. default:
  408. return 0;
  409. }
  410. }
  411. private int getColor() {
  412. switch (kind) {
  413. case document:
  414. return getSetting(epson.common.Constants.COLOR, (String) null, 0);
  415. case photo:
  416. return getSetting(epson.common.Constants.COLOR_PHOTO, (String) null, 0);
  417. case cameracopy:
  418. return getSetting(epson.common.Constants.COLOR_CAMERACOPY, (String) null, 0);
  419. default:
  420. return 0;
  421. }
  422. }
  423. public String getPrinterName() {
  424. return getSettingString(epson.common.Constants.PRINTER_NAME, (String) null);
  425. }
  426. public String getPrinterID() {
  427. return getSettingString(epson.common.Constants.PRINTER_ID, (String) null);
  428. }
  429. public String getIP() {
  430. return getSettingString(epson.common.Constants.PRINTER_IP, (String) null);
  431. }
  432. public String getSrialNo() {
  433. return getSettingString(epson.common.Constants.PRINTER_SERIAL_NO, (String) null);
  434. }
  435. public String getEmailAddress() {
  436. return getSettingString(epson.common.Constants.PRINTER_EMAIL_ADDRESS, (String) null);
  437. }
  438. public int getLocation() {
  439. return getSetting(epson.common.Constants.PRINTER_LOCATION, (String) null, 0);
  440. }
  441. public int getLang() {
  442. return getSetting(epson.common.Constants.LANG, (String) null, 1);
  443. }
  444. private int getSetting(String str, String str2, int i) {
  445. SharedPreferences sharedPreferences = settings;
  446. if (sharedPreferences == null) {
  447. if (allValueFromContentProvider.containsKey(str)) {
  448. allValueFromContentProvider.get(str);
  449. return ((Integer) allValueFromContentProvider.get(str)).intValue();
  450. } else if (str2 != null && allValueFromContentProvider.containsKey(str2)) {
  451. return ((Integer) allValueFromContentProvider.get(str2)).intValue();
  452. } else {
  453. return i;
  454. }
  455. } else if (sharedPreferences.getAll().containsKey(str) || str2 == null) {
  456. return settings.getInt(str, i);
  457. } else {
  458. return settings.getInt(str2, i);
  459. }
  460. }
  461. private String getSettingString(String str, String str2) {
  462. SharedPreferences sharedPreferences = settings;
  463. if (sharedPreferences != null) {
  464. return sharedPreferences.getAll().containsKey(str) ? settings.getString(str, str2) : str2;
  465. }
  466. if (!allValueFromContentProvider.containsKey(str) || allValueFromContentProvider.get(str) == null) {
  467. return str2;
  468. }
  469. return (String) allValueFromContentProvider.get(str);
  470. }
  471. private boolean getSettingBoolean(String str, boolean z) {
  472. if (settings != null || !this.allValueFromContentProvider.containsKey(str)) {
  473. return z;
  474. }
  475. allValueFromContentProvider.get(str);
  476. return ((Boolean) allValueFromContentProvider.get(str)).booleanValue();
  477. }
  478. public int getEcClientLibSourceType() {
  479. return C23321.$SwitchMap$epson$print$screen$PrintSetting$Kind[this.kind.ordinal()] != 1 ? 2 : 1;
  480. }
  481. private SharedPreferences getPaperSizeTypePreferences() {
  482. String str;
  483. switch (kind) {
  484. case document:
  485. str = epson.common.Constants.PREFS_INFO_SIZETYPESET;
  486. break;
  487. case photo:
  488. str = epson.common.Constants.PREFS_INFO_SIZETYPESET_PHOTO;
  489. break;
  490. case cameracopy:
  491. str = epson.common.Constants.PREFS_INFO_SIZETYPESET_CAMERACOPY;
  492. break;
  493. default:
  494. str = null;
  495. break;
  496. }
  497. return context.getSharedPreferences(str, 0);
  498. }
  499. public MediaInfo.PaperSizeType loadPaperSizeTypePear() {
  500. MediaInfo.PaperSizeType paperSizeType = new MediaInfo.PaperSizeType();
  501. SharedPreferences paperSizeTypePreferences = getPaperSizeTypePreferences();
  502. Enumeration keys = paperSizeType.getKeys();
  503. while (keys.hasMoreElements()) {
  504. int intValue = ((Integer) keys.nextElement()).intValue();
  505. int i = paperSizeTypePreferences.getInt(Integer.toString(intValue), -1);
  506. if (i != -1) {
  507. paperSizeType.putID(intValue, i);
  508. }
  509. }
  510. return paperSizeType;
  511. }
  512. public void savePaperSizeTypePear(MediaInfo.PaperSizeType paperSizeType) {
  513. SharedPreferences.Editor edit = getPaperSizeTypePreferences().edit();
  514. Enumeration keys = paperSizeType.getKeys();
  515. while (keys.hasMoreElements()) {
  516. int intValue = ((Integer) keys.nextElement()).intValue();
  517. edit.putInt(Integer.toString(intValue), paperSizeType.getID(intValue));
  518. }
  519. edit.commit();
  520. }
  521. public void resetPageRange(int i, int i2) {
  522. EPLog.d("PrintSetting", "resetPrintSettings()");
  523. SharedPreferences.Editor edit = settings.edit();
  524. printAll = true;
  525. startValue = i;
  526. endValue = i2;
  527. edit.putBoolean(epson.common.Constants.PRINT_ALL, printAll);
  528. edit.putInt(epson.common.Constants.START_PAGE, startValue);
  529. edit.putInt(epson.common.Constants.END_PAGE, endValue);
  530. edit.commit();
  531. }
  532. public void resetPrintSettings() {
  533. EPLog.d("PrintSetting", "resetPrintSettings()");
  534. SharedPreferences.Editor edit = settings.edit();
  535. edit.putInt(epson.common.Constants.COPIES, 1);
  536. edit.putInt(epson.common.Constants.BRIGHTNESS, 0);
  537. edit.putInt(epson.common.Constants.CONTRAST, 0);
  538. edit.putInt(epson.common.Constants.SATURATION, 0);
  539. edit.commit();
  540. }
  541. public int getUpdateSettingsRemoteSourceType() {
  542. switch (kind) {
  543. case photo:
  544. return 2;
  545. case cameracopy:
  546. return 2;
  547. default:
  548. return 1;
  549. }
  550. }
  551. public void clearSettings() {
  552. EPLog.d("PrintSetting", "clearSettings()");
  553. SharedPreferences.Editor edit = settings.edit();
  554. edit.remove(epson.common.Constants.PAPER_SIZE);
  555. edit.remove(epson.common.Constants.PAPER_TYPE);
  556. edit.remove(epson.common.Constants.LAYOUT);
  557. edit.remove(epson.common.Constants.QUALITY);
  558. edit.remove(epson.common.Constants.PAPER_SOURCE);
  559. edit.remove(epson.common.Constants.COLOR);
  560. edit.remove(epson.common.Constants.DUPLEX);
  561. edit.remove(epson.common.Constants.FEED_DIRECTION);
  562. edit.remove(epson.common.Constants.PAPER_SIZE_PHOTO);
  563. edit.remove(epson.common.Constants.PAPER_TYPE_PHOTO);
  564. edit.remove(epson.common.Constants.LAYOUT_PHOTO);
  565. edit.remove(epson.common.Constants.QUALITY_PHOTO);
  566. edit.remove(epson.common.Constants.PAPER_SOURCE_PHOTO);
  567. edit.remove(epson.common.Constants.COLOR_PHOTO);
  568. edit.remove(epson.common.Constants.DUPLEX_PHOTO);
  569. edit.remove(epson.common.Constants.FEED_DIRECTION_PHOTO);
  570. edit.remove(epson.common.Constants.PRINT_ALL);
  571. edit.remove(epson.common.Constants.START_PAGE);
  572. edit.remove(epson.common.Constants.END_PAGE);
  573. edit.remove(epson.common.Constants.PRINTDATE);
  574. edit.remove(epson.common.Constants.APF_PHOTO);
  575. edit.remove(epson.common.Constants.COPIES);
  576. edit.remove(epson.common.Constants.BRIGHTNESS);
  577. edit.remove(epson.common.Constants.CONTRAST);
  578. edit.remove(epson.common.Constants.SATURATION);
  579. for (String remove : CAMERA_COPY_KEYS) {
  580. edit.remove(remove);
  581. }
  582. edit.commit();
  583. context.getSharedPreferences(epson.common.Constants.PREFS_INFO_SIZETYPESET, 0).edit().clear().commit();
  584. context.getSharedPreferences(epson.common.Constants.PREFS_INFO_SIZETYPESET_PHOTO, 0).edit().clear().commit();
  585. context.getSharedPreferences(epson.common.Constants.PREFS_INFO_SIZETYPESET_CAMERACOPY, 0).edit().clear().commit();
  586. }
  587. }