|
1 | 1 | package com.programminghoch10.RotationControl
|
2 | 2 |
|
| 3 | +import android.app.Application |
3 | 4 | import android.content.pm.ActivityInfo
|
4 | 5 |
|
| 6 | +val context = Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null) as Application |
| 7 | + |
5 | 8 | enum class ROTATION_MODE(val key: String, val value: Int, val title: String, val summary: String) {
|
6 | 9 | // yoinked from https://developer.android.com/reference/android/R.attr.html#screenOrientation
|
7 | 10 |
|
8 | 11 | SCREEN_ORIENTATION_UNSET(
|
9 | 12 | "UNSET",
|
10 | 13 | -2,
|
11 |
| - "UNSET", |
12 |
| - "Do not override screen orientation. " + |
13 |
| - "You might as well disable the module instead of using this option.", |
| 14 | + context.getString(R.string.screen_orientation_unset_title), |
| 15 | + context.getString(R.string.screen_orientation_unset_summary), |
14 | 16 | ),
|
15 | 17 | SCREEN_ORIENTATION_UNSPECIFIED(
|
16 | 18 | "UNSPECIFIED",
|
17 | 19 | ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED,
|
18 |
| - "UNSPECIFIED", |
19 |
| - "No preference specified: " + |
20 |
| - "let the system decide the best orientation. " + |
21 |
| - "This will either be the orientation selected by the activity below, " + |
22 |
| - "or the user's preferred orientation if this activity is the bottom of a task. " + |
23 |
| - "If the user explicitly turned off sensor based orientation " + |
24 |
| - "through settings sensor based device rotation will be ignored. " + |
25 |
| - "If not by default sensor based orientation will be taken into account " + |
26 |
| - "and the orientation will changed based on how the user rotates the device.", |
| 20 | + context.getString(R.string.screen_orientation_unspecified_title), |
| 21 | + context.getString(R.string.screen_orientation_unspecified_summary), |
27 | 22 | ),
|
28 | 23 | SCREEN_ORIENTATION_LANDSCAPE(
|
29 | 24 | "LANDSCAPE",
|
30 | 25 | ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
|
31 |
| - "LANDSCAPE", |
32 |
| - "Would like to have the screen in a landscape orientation: " + |
33 |
| - "that is, with the display wider than it is tall, ignoring sensor data.", |
| 26 | + context.getString(R.string.screen_orientation_landscape_title), |
| 27 | + context.getString(R.string.screen_orientation_landscape_summary), |
34 | 28 | ),
|
35 | 29 | SCREEN_ORIENTATION_PORTRAIT(
|
36 | 30 | "PORTRAIT",
|
37 | 31 | ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,
|
38 |
| - "PORTRAIT", |
39 |
| - "Would like to have the screen in a portrait orientation: " + |
40 |
| - "that is, with the display taller than it is wide, ignoring sensor data.", |
| 32 | + context.getString(R.string.screen_orientation_portrait_title), |
| 33 | + context.getString(R.string.screen_orientation_portrait_summary), |
41 | 34 | ),
|
42 | 35 | SCREEN_ORIENTATION_USER(
|
43 | 36 | "USER",
|
44 | 37 | ActivityInfo.SCREEN_ORIENTATION_USER,
|
45 |
| - "USER", |
46 |
| - "Use the user's current preferred orientation of the handset.", |
| 38 | + context.getString(R.string.screen_orientation_user_title), |
| 39 | + context.getString(R.string.screen_orientation_user_summary), |
47 | 40 | ),
|
48 | 41 | SCREEN_ORIENTATION_BEHIND(
|
49 | 42 | "BEHIND",
|
50 | 43 | ActivityInfo.SCREEN_ORIENTATION_BEHIND,
|
51 |
| - "BEHIND", |
52 |
| - "Keep the screen in the same orientation as whatever is behind this activity.", |
| 44 | + context.getString(R.string.screen_orientation_behind_title), |
| 45 | + context.getString(R.string.screen_orientation_behind_summary), |
53 | 46 | ),
|
54 | 47 | SCREEN_ORIENTATION_SENSOR(
|
55 | 48 | "SENSOR",
|
56 | 49 | ActivityInfo.SCREEN_ORIENTATION_SENSOR,
|
57 |
| - "SENSOR", |
58 |
| - "Orientation is determined by a physical orientation sensor: " + |
59 |
| - "the display will rotate based on how the user moves the device. " + |
60 |
| - "Ignores user's setting to turn off sensor-based rotation.", |
| 50 | + context.getString(R.string.screen_orientation_sensor_title), |
| 51 | + context.getString(R.string.screen_orientation_sensor_summary), |
61 | 52 | ),
|
62 | 53 | SCREEN_ORIENTATION_NOSENSOR(
|
63 | 54 | "NOSENSOR",
|
64 | 55 | ActivityInfo.SCREEN_ORIENTATION_NOSENSOR,
|
65 |
| - "NOSENSOR", |
66 |
| - "Always ignore orientation determined by orientation sensor: " + |
67 |
| - "the display will not rotate when the user moves the device.", |
| 56 | + context.getString(R.string.screen_orientation_nosensor_title), |
| 57 | + context.getString(R.string.screen_orientation_nosensor_summary), |
68 | 58 | ),
|
69 | 59 | SCREEN_ORIENTATION_SENSOR_LANDSCAPE(
|
70 | 60 | "SENSOR_LANDSCAPE",
|
71 | 61 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
|
72 |
| - "SENSOR_LANDSCAPE", |
73 |
| - "Would like to have the screen in landscape orientation, " + |
74 |
| - "but can use the sensor to change which direction the screen is facing. ", |
| 62 | + context.getString(R.string.screen_orientation_sensor_landscape_title), |
| 63 | + context.getString(R.string.screen_orientation_sensor_landscape_summary), |
75 | 64 | ),
|
76 | 65 | SCREEN_ORIENTATION_SENSOR_PORTRAIT(
|
77 | 66 | "SENSOR_PORTRAIT",
|
78 | 67 | ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT,
|
79 |
| - "SENSOR_PORTRAIT", |
80 |
| - "Would like to have the screen in portrait orientation, " + |
81 |
| - "but can use the sensor to change which direction the screen is facing.", |
| 68 | + context.getString(R.string.screen_orientation_sensor_portrait_title), |
| 69 | + context.getString(R.string.screen_orientation_sensor_portrait_summary), |
82 | 70 | ),
|
83 | 71 | SCREEN_ORIENTATION_REVERSE_LANDSCAPE(
|
84 | 72 | "REVERSE_LANDSCAPE",
|
85 | 73 | ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
|
86 |
| - "REVERSE_LANDSCAPE", |
87 |
| - "Would like to have the screen in landscape orientation, " + |
88 |
| - "turned in the opposite direction from normal landscape.", |
| 74 | + context.getString(R.string.screen_orientation_reverse_landscape_title), |
| 75 | + context.getString(R.string.screen_orientation_reverse_landscape_summary), |
89 | 76 | ),
|
90 | 77 | SCREEN_ORIENTATION_REVERSE_PORTRAIT(
|
91 | 78 | "REVERSE_PORTRAIT",
|
92 | 79 | ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
|
93 |
| - "REVERSE_PORTRAIT", |
94 |
| - "Would like to have the screen in portrait orientation, " + |
95 |
| - "turned in the opposite direction from normal portrait.", |
| 80 | + context.getString(R.string.screen_orientation_reverse_portrait_title), |
| 81 | + context.getString(R.string.screen_orientation_reverse_portrait_summary), |
96 | 82 | ),
|
97 | 83 | SCREEN_ORIENTATION_FULL_SENSOR(
|
98 | 84 | "FULL_SENSOR",
|
99 | 85 | ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR,
|
100 |
| - "FULL_SENSOR", |
101 |
| - "Orientation is determined by a physical orientation sensor: " + |
102 |
| - "the display will rotate based on how the user moves the device. " + |
103 |
| - "This allows any of the 4 possible rotations, " + |
104 |
| - "regardless of what the device will normally do " + |
105 |
| - "(for example some devices won't normally use 180 degree rotation).", |
| 86 | + context.getString(R.string.screen_orientation_full_sensor_title), |
| 87 | + context.getString(R.string.screen_orientation_full_sensor_summary), |
106 | 88 | ),
|
107 | 89 | SCREEN_ORIENTATION_USER_LANDSCAPE(
|
108 | 90 | "USER_LANDSCAPE",
|
109 | 91 | ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE,
|
110 |
| - "USER_LANDSCAPE", |
111 |
| - "Would like to have the screen in landscape orientation, " + |
112 |
| - "but if the user has enabled sensor-based rotation " + |
113 |
| - "then we can use the sensor to change which direction the screen is facing.", |
| 92 | + context.getString(R.string.screen_orientation_user_landscape), |
| 93 | + context.getString(R.string.screen_orientation_user_landscape_summary), |
114 | 94 | ),
|
115 | 95 | SCREEN_ORIENTATION_USER_PORTRAIT(
|
116 | 96 | "USER_PORTRAIT",
|
117 | 97 | ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT,
|
118 |
| - "USER_PORTRAIT", |
119 |
| - "Would like to have the screen in portrait orientation, " + |
120 |
| - "but if the user has enabled sensor-based rotation " + |
121 |
| - "then we can use the sensor to change which direction the screen is facing.", |
| 98 | + context.getString(R.string.screen_orientation_user_portrait_title), |
| 99 | + context.getString(R.string.screen_orientation_user_portrait_summary), |
122 | 100 | ),
|
123 | 101 | SCREEN_ORIENTATION_FULL_USER(
|
124 | 102 | "FULL_USER",
|
125 | 103 | ActivityInfo.SCREEN_ORIENTATION_FULL_USER,
|
126 |
| - "FULL_USER", |
127 |
| - "Respect the user's sensor-based rotation preference, " + |
128 |
| - "but if sensor-based rotation is enabled " + |
129 |
| - "then allow the screen to rotate in all 4 possible directions " + |
130 |
| - "regardless of what the device will normally do " + |
131 |
| - "(for example some devices won't normally use 180 degree rotation).", |
| 104 | + context.getString(R.string.screen_orientation_full_user_title), |
| 105 | + context.getString(R.string.screen_orientation_full_user_summary), |
132 | 106 | ),
|
133 | 107 | SCREEN_ORIENTATION_LOCKED(
|
134 | 108 | "LOCKED",
|
135 | 109 | ActivityInfo.SCREEN_ORIENTATION_LOCKED,
|
136 |
| - "LOCKED", |
137 |
| - "Screen is locked to its current rotation, whatever that is.", |
| 110 | + context.getString(R.string.screen_orientation_locked_title), |
| 111 | + context.getString(R.string.screen_orientation_locked_summary), |
138 | 112 | ),
|
139 | 113 | }
|
0 commit comments