Use the right API for the rotation

This commit is contained in:
Sylvain Berfini 2012-06-15 10:15:38 +02:00
parent 1f14ee1dc3
commit d2dc3e1cf9
5 changed files with 42 additions and 2 deletions

View file

@ -22,6 +22,7 @@ package org.linphone;
import static android.content.Intent.ACTION_MAIN; import static android.content.Intent.ACTION_MAIN;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
@ -102,7 +103,7 @@ public class LinphoneActivity extends TabActivity implements ContactPicked
setContentView(R.layout.main); setContentView(R.layout.main);
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
int rotation = getWindowManager().getDefaultDisplay().getOrientation(); int rotation = Compatibility.getRotation(getWindowManager().getDefaultDisplay());
// Inverse landscape rotation to initiate linphoneCore correctly // Inverse landscape rotation to initiate linphoneCore correctly
if (rotation == 270) if (rotation == 270)
rotation = 90; rotation = 90;

View file

@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone; package org.linphone;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.LinphoneCall; import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State; import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCallParams; import org.linphone.core.LinphoneCallParams;
@ -456,7 +457,8 @@ public class VideoCallActivity extends Activity implements
private void resizePreview() { private void resizePreview() {
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)) Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay(); .getDefaultDisplay();
int rotation = display.getOrientation();
int rotation = Compatibility.getRotation(display);
LayoutParams params; LayoutParams params;
int w, h; int w, h;

View file

@ -0,0 +1,10 @@
package org.linphone.compatibility;
import android.view.Display;
public class API4Compatibility {
public static int getRotation(Display display) {
return display.getOrientation();
}
}

View file

@ -0,0 +1,10 @@
package org.linphone.compatibility;
import android.view.Display;
public class API8Compatibility {
public static int getRotation(Display display) {
return display.getRotation();
}
}

View file

@ -0,0 +1,17 @@
package org.linphone.compatibility;
import org.linphone.mediastream.Version;
import android.view.Display;
public class Compatibility {
public static int getRotation(Display display) {
if (Version.sdkStrictlyBelow(8)) {
return API4Compatibility.getRotation(display);
} else {
return API8Compatibility.getRotation(display);
}
}
}