Fix camera orientation.

This commit is contained in:
Ghislain MARY 2013-10-30 16:37:47 +01:00
parent 904bc34dbb
commit 0c9c75af60
4 changed files with 14 additions and 20 deletions

View file

@ -68,6 +68,7 @@ import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.OrientationEventListener; import android.view.OrientationEventListener;
import android.view.Surface;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -166,12 +167,21 @@ public class LinphoneActivity extends FragmentActivity implements
int missedCalls = LinphoneManager.getLc().getMissedCallsCount(); int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
displayMissedCalls(missedCalls); displayMissedCalls(missedCalls);
int rotation = Compatibility.getRotation(getWindowManager().getDefaultDisplay()); int rotation = getWindowManager().getDefaultDisplay().getRotation();
// Inverse landscape rotation to initiate linphoneCore correctly switch (rotation) {
if (rotation == 270) case Surface.ROTATION_0:
rotation = 0;
break;
case Surface.ROTATION_90:
rotation = 90; rotation = 90;
else if (rotation == 90) break;
case Surface.ROTATION_180:
rotation = 180;
break;
case Surface.ROTATION_270:
rotation = 270; rotation = 270;
break;
}
LinphoneManager.getLc().setDeviceRotation(rotation); LinphoneManager.getLc().setDeviceRotation(rotation);
mAlwaysChangingPhoneAngle = rotation; mAlwaysChangingPhoneAngle = rotation;

View file

@ -34,10 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@TargetApi(8) @TargetApi(8)
public class ApiEightPlus { public class ApiEightPlus {
public static int getRotation(Display display) {
return display.getRotation();
}
public static void initPushNotificationService(Context context) { public static void initPushNotificationService(Context context) {
try { try {
// Starting the push notification service // Starting the push notification service

View file

@ -332,10 +332,6 @@ public class ApiFivePlus {
return null; return null;
} }
public static int getRotation(Display display) {
return display.getOrientation();
}
public static Notification createMessageNotification(Context context, String title, String msg, PendingIntent intent) { public static Notification createMessageNotification(Context context, String title, String msg, PendingIntent intent) {
Notification notif = new Notification(); Notification notif = new Notification();
notif.icon = R.drawable.chat_icon_over; notif.icon = R.drawable.chat_icon_over;

View file

@ -159,14 +159,6 @@ public class Compatibility {
return null; return null;
} }
public static int getRotation(Display display) {
if (Version.sdkStrictlyBelow(Version.API08_FROYO_22)) {
return ApiFivePlus.getRotation(display);
} else {
return ApiEightPlus.getRotation(display);
}
}
public static void setNotificationLatestEventInfo(Notification notif, Context context, String title, String content, PendingIntent intent) { public static void setNotificationLatestEventInfo(Notification notif, Context context, String title, String content, PendingIntent intent) {
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) { if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
ApiElevenPlus.setNotificationLatestEventInfo(notif, context, title, content, intent); ApiElevenPlus.setNotificationLatestEventInfo(notif, context, title, content, intent);