14
14
import org .appcelerator .titanium .ContextSpecific ;
15
15
import org .appcelerator .titanium .TiApplication ;
16
16
import org .appcelerator .titanium .TiProperties ;
17
+ import org .appcelerator .titanium .util .TiDeviceOrientation ;
17
18
import org .appcelerator .titanium .util .TiSensorHelper ;
18
19
20
+ import android .content .res .Configuration ;
19
21
import android .hardware .Sensor ;
20
22
import android .hardware .SensorEvent ;
21
23
import android .hardware .SensorEventListener ;
@@ -174,12 +176,20 @@ public void onSensorChanged(SensorEvent event)
174
176
@ Kroll .getProperty
175
177
public boolean getPortrait ()
176
178
{
179
+ if (this .deviceOrientationMonitor .getLastReadOrientation () == TiDeviceOrientation .UNKNOWN ) {
180
+ int orientation = TiApplication .getAppCurrentActivity ().getResources ().getConfiguration ().orientation ;
181
+ return orientation == Configuration .ORIENTATION_PORTRAIT ;
182
+ }
177
183
return this .deviceOrientationMonitor .getLastReadOrientation ().isPortrait ();
178
184
}
179
185
180
186
@ Kroll .getProperty
181
187
public boolean getLandscape ()
182
188
{
189
+ if (this .deviceOrientationMonitor .getLastReadOrientation () == TiDeviceOrientation .UNKNOWN ) {
190
+ int orientation = TiApplication .getAppCurrentActivity ().getResources ().getConfiguration ().orientation ;
191
+ return orientation == Configuration .ORIENTATION_LANDSCAPE ;
192
+ }
183
193
return this .deviceOrientationMonitor .getLastReadOrientation ().isLandscape ();
184
194
}
185
195
@@ -189,6 +199,12 @@ public int getOrientation()
189
199
return this .deviceOrientationMonitor .getLastReadOrientation ().toTiIntId ();
190
200
}
191
201
202
+ @ Kroll .method
203
+ public void stopListener ()
204
+ {
205
+ this .deviceOrientationMonitor .stop ();
206
+ }
207
+
192
208
@ Override
193
209
public String getApiName ()
194
210
{
0 commit comments