aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-02-19 21:05:12 +0100
committerChristian Schneppe <christian@pix-art.de>2017-02-19 21:05:12 +0100
commit5d281104cd0de281195dbf5bf7c9d9d5f97dbd3e (patch)
treefc6b9ae81ffbe51cc12d812a378987cca5d9703e /src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java
parenta9953ce1079abc7cecd87b3e92ba8ae2e593cbd0 (diff)
reworked rotation in FullScreenViewer fixes #107
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java77
1 files changed, 18 insertions, 59 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java b/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java
index b78dec72a..75c6d8849 100644
--- a/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java
@@ -7,7 +7,6 @@ import android.content.res.Configuration;
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
-import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@@ -138,35 +137,7 @@ public class ShowFullscreenMessageActivity extends Activity {
width = options.outWidth;
rotation = getRotation(Uri.parse("file://" + file.getAbsolutePath()));
Log.d(Config.LOGTAG, "Image height: " + height + ", width: " + width + ", rotation: " + rotation);
- if (width > height) {
- if (rotation == 0 || rotation == 180) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
- }
- } else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- }
- } else if (width <= height) {
- if (rotation == 90 || rotation == 270) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- } else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- }
- }
+ rotateScreen(width, height, rotation);
final PhotoViewAttacher mAttacher = new PhotoViewAttacher(mImage);
mImage.setVisibility(View.VISIBLE);
try {
@@ -192,35 +163,7 @@ public class ShowFullscreenMessageActivity extends Activity {
width = Integer.valueOf(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
rotation = Integer.valueOf(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION));
Log.d(Config.LOGTAG, "Video height: " + height + ", width: " + width + ", rotation: " + rotation);
- if (width > height) {
- if (rotation == 0 || rotation == 180) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
- }
- } else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- }
- } else if (width <= height) {
- if (rotation == 90 || rotation == 270) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- } else {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT);
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- }
- }
- }
+ rotateScreen(width, height, rotation);
try {
mVideo.setVisibility(View.VISIBLE);
mVideo.setVideoURI(uri);
@@ -245,6 +188,22 @@ public class ShowFullscreenMessageActivity extends Activity {
}
}
+ private void rotateScreen(int width, int height, int rotation) {
+ if (width > height) {
+ if (rotation == 0 || rotation == 180) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
+ } else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
+ }
+ } else if (width <= height) {
+ if (rotation == 90 || rotation == 270) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
+ } else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
+ }
+ }
+ }
+
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);