summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Tam <engineer.tonytam@pm.me>2020-05-27 21:07:09 -0700
committerTony Tam <engineer.tonytam@pm.me>2020-05-27 21:07:09 -0700
commit62a6ac90780d8d96bb9ae19f4d95108e446e941f (patch)
tree8bfd4f375fa6241bc49806ee4cddb038d411cbd6
parent5da714ce9a0600f0f0cccbf86a8b2dce57a0f566 (diff)
downloadAntennaPod-62a6ac90780d8d96bb9ae19f4d95108e446e941f.zip
landscape layout
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java48
-rw-r--r--app/src/main/res/layout/cover_fragment.xml52
2 files changed, 72 insertions, 28 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 7593188b7..d01299625 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/CoverFragment.java
@@ -1,5 +1,6 @@
package de.danoeh.antennapod.fragment;
+import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
@@ -8,9 +9,13 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
+
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
+
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.FitCenter;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
@@ -47,6 +52,7 @@ public class CoverFragment extends Fragment {
private Disposable disposable;
private int displayedChapterIndex = -2;
private Playable media;
+ private int orientation = Configuration.ORIENTATION_UNDEFINED;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -60,6 +66,11 @@ public class CoverFragment extends Fragment {
return root;
}
+ @Override
+ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+ configureForOrientation(getResources().getConfiguration().orientation);
+ }
+
private void loadMediaInfo() {
if (disposable != null) {
disposable.dispose();
@@ -72,12 +83,12 @@ public class CoverFragment extends Fragment {
emitter.onComplete();
}
})
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(media -> {
- this.media = media;
- displayMediaInfo(media);
- }, error -> Log.e(TAG, Log.getStackTraceString(error)));
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(media -> {
+ this.media = media;
+ displayMediaInfo(media);
+ }, error -> Log.e(TAG, Log.getStackTraceString(error)));
}
private void displayMediaInfo(@NonNull Playable media) {
@@ -159,6 +170,31 @@ public class CoverFragment extends Fragment {
}
}
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ if (orientation != newConfig.orientation) {
+ orientation = newConfig.orientation;
+ configureForOrientation(orientation);
+ }
+ }
+
+ private void configureForOrientation(int orientation) {
+ View textContainer = getView().findViewById(R.id.cover_fragment_text_container);
+ LinearLayout mainContainer = getView().findViewById(R.id.cover_fragment);
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textContainer.getLayoutParams();
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+ mainContainer.setOrientation(LinearLayout.VERTICAL);
+ params.weight = 0;
+ } else {
+ mainContainer.setOrientation(LinearLayout.HORIZONTAL);
+ params.weight = 1;
+ }
+ textContainer.setLayoutParams(params);
+ }
+
@Override
public void onDestroyView() {
super.onDestroyView();
diff --git a/app/src/main/res/layout/cover_fragment.xml b/app/src/main/res/layout/cover_fragment.xml
index 28321e760..e3ffcc361 100644
--- a/app/src/main/res/layout/cover_fragment.xml
+++ b/app/src/main/res/layout/cover_fragment.xml
@@ -1,49 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:squareImageView="http://schemas.android.com/apk/de.danoeh.antennapod"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
+ android:id="@+id/cover_fragment"
android:padding="8dp"
android:gravity="center">
<de.danoeh.antennapod.view.SquareImageView
android:id="@+id/imgvCover"
android:layout_width="match_parent"
- android:layout_height="0dp"
+ android:layout_height="match_parent"
android:layout_weight="1"
android:scaleType="fitCenter"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
- android:transitionName="coverTransition"
tools:src="@android:drawable/sym_def_app_icon"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:importantForAccessibility="no"
squareImageView:direction="minimum" />
- <TextView
- android:id="@+id/txtvPodcastTitle"
+ <LinearLayout
+ android:id="@+id/cover_fragment_text_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:ellipsize="end"
- android:gravity="center"
- android:maxLines="2"
+ android:orientation="vertical"
android:layout_marginTop="16dp"
- android:textColor="?android:attr/textColorSecondary"
- android:textIsSelectable="true"
- tools:text="Podcast" />
+ android:layout_marginBottom="8dp">
- <TextView
- android:id="@+id/txtvEpisodeTitle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ellipsize="end"
- android:gravity="center"
- android:maxLines="2"
- android:textColor="?android:attr/textColorPrimary"
- android:textIsSelectable="true"
- android:layout_marginBottom="8dp"
- tools:text="Episode" />
+ <TextView
+ android:id="@+id/txtvPodcastTitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:maxLines="2"
+ android:textColor="?android:attr/textColorSecondary"
+ android:textIsSelectable="true"
+ tools:text="Podcast" />
+
+ <TextView
+ android:id="@+id/txtvEpisodeTitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:gravity="center"
+ android:maxLines="2"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textIsSelectable="true"
+ tools:text="Episode" />
+ </LinearLayout>
</LinearLayout>