|
3 | 3 | import java.awt.*; |
4 | 4 | import java.io.File; |
5 | 5 | import java.lang.reflect.Field; |
6 | | -import java.util.Arrays; |
7 | 6 |
|
8 | | -import static environment.EnvironmentFactory.*; |
9 | 7 | import static util.validator.Constants.TARGET_AUTOMOTION_JSON; |
10 | 8 |
|
11 | 9 | public class SystemHelper { |
12 | | - |
13 | | - public final static String[] iOS_RETINA_DEVICES = { |
14 | | - "iPhone 4", "iPhone 4s", |
15 | | - "iPhone 5", "iPhone 5s", |
16 | | - "iPhone 6", "iPhone 6s", |
17 | | - "iPad Mini 2", |
18 | | - "iPad Mini 4", |
19 | | - "iPad Air 2", |
20 | | - "iPad Pro" |
21 | | - }; |
22 | | - |
23 | 10 | /** |
24 | 11 | * Verify is display is retina |
25 | 12 | * |
26 | 13 | * @return |
27 | 14 | */ |
28 | 15 | public static boolean isRetinaDisplay() { |
29 | 16 | boolean isRetina = false; |
30 | | - if (isMobile()) { |
31 | | - if (isIOS()) { |
32 | | - if (Arrays.asList(iOS_RETINA_DEVICES).contains(getDevice())) { |
33 | | - isRetina = true; |
34 | | - } |
35 | | - } |
36 | | - } else { |
37 | | - try { |
38 | | - GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); |
| 17 | + try { |
| 18 | + GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); |
39 | 19 |
|
40 | | - try { |
41 | | - Field field = graphicsDevice.getClass().getDeclaredField("scale"); |
42 | | - if (field != null) { |
43 | | - field.setAccessible(true); |
44 | | - Object scale = field.get(graphicsDevice); |
45 | | - if (scale instanceof Integer && (Integer) scale == 2) { |
46 | | - isRetina = true; |
47 | | - } |
| 20 | + try { |
| 21 | + Field field = graphicsDevice.getClass().getDeclaredField("scale"); |
| 22 | + if (field != null) { |
| 23 | + field.setAccessible(true); |
| 24 | + Object scale = field.get(graphicsDevice); |
| 25 | + if (scale instanceof Integer && (Integer) scale == 2) { |
| 26 | + isRetina = true; |
48 | 27 | } |
49 | | - } catch (Exception e) { |
50 | | - e.printStackTrace(); |
51 | 28 | } |
52 | 29 | } catch (Exception e) { |
53 | 30 | e.printStackTrace(); |
54 | 31 | } |
| 32 | + } catch (Exception e) { |
| 33 | + e.printStackTrace(); |
55 | 34 | } |
56 | 35 | return isRetina; |
57 | 36 | } |
|
0 commit comments