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