summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh
diff options
context:
space:
mode:
authorTony Tam <ttam@splunk.com>2020-09-14 11:14:52 -0700
committerTony Tam <ttam@splunk.com>2020-09-14 11:14:52 -0700
commitda14ae58dcfe55a3cec60da182f8750dd17b580c (patch)
treeaf8b7867684912165dea00db7b532570602d475d /app/src/main/java/de/danoeh
parent06315821d52d6b66d4c3c0adeac16ee627bfe782 (diff)
downloadAntennaPod-da14ae58dcfe55a3cec60da182f8750dd17b580c.zip
- better resizing for multiple screen ratios
Diffstat (limited to 'app/src/main/java/de/danoeh')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java
index 79f378249..648fc614a 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java
@@ -45,6 +45,7 @@ import org.greenrobot.eventbus.ThreadMode;
public class CoverFragment extends Fragment {
private static final String TAG = "CoverFragment";
+ static final double SIXTEEN_BY_NINE = 1.7;
private View root;
private TextView txtvPodcastTitle;
@@ -188,20 +189,31 @@ public class CoverFragment extends Fragment {
private void configureForOrientation(Configuration newConfig) {
LinearLayout mainContainer = getView().findViewById(R.id.cover_fragment);
- ViewGroup.LayoutParams params = imgvCover.getLayoutParams();
+ LinearLayout textContainer = getView().findViewById(R.id.cover_fragment_text_container);
+
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) imgvCover.getLayoutParams();
+ LinearLayout.LayoutParams textParams = (LinearLayout.LayoutParams) textContainer.getLayoutParams();
+ double ratio = (float) newConfig.screenHeightDp / (float) newConfig.screenWidthDp;
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
+ double percentageWidth = 0.8;
+ if (ratio <= SIXTEEN_BY_NINE) {
+ percentageWidth = (ratio / SIXTEEN_BY_NINE) * percentageWidth * 0.8;
+ }
mainContainer.setOrientation(LinearLayout.VERTICAL);
if (newConfig.screenWidthDp > 0) {
- params.width = (int) (convertDpToPixel(newConfig.screenWidthDp) * .80);
+ params.width = (int) (convertDpToPixel(newConfig.screenWidthDp) * percentageWidth);
params.height = params.width;
+ textParams.weight = 0;
imgvCover.setLayoutParams(params);
}
} else {
+ double percentageHeight = ratio * 0.8;
mainContainer.setOrientation(LinearLayout.HORIZONTAL);
if (newConfig.screenHeightDp > 0) {
- params.height = (int) (convertDpToPixel(newConfig.screenHeightDp) * .40);
+ params.height = (int) (convertDpToPixel(newConfig.screenHeightDp) * percentageHeight);
params.width = params.height;
+ textParams.weight = 1;
imgvCover.setLayoutParams(params);
}
}