PrintSetting.java 28 KB

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