From f9ad0f12d005ade0b82bcc436ee81c964897fb57 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 15 Dec 2015 22:53:29 +0100 Subject: [PATCH] Fixed serveral things: * ugly workaround for the details_view_layout problem on older devices * removed "display button on the left side" option since it's not nececeay anymore. --- .../newpipe/VideoItemDetailFragment.java | 47 ++-- .../layout-v18/fragment_videoitem_detail.xml | 219 ++++++++++++++++++ .../res/layout/fragment_videoitem_detail.xml | 34 +-- app/src/main/res/layout/video_item.xml | 8 +- app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fa/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 1 - app/src/main/res/values-hu/strings.xml | 1 - app/src/main/res/values-it/strings.xml | 1 - app/src/main/res/values-ja/strings.xml | 1 - app/src/main/res/values-ko/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 1 - app/src/main/res/values-pl/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 1 - app/src/main/res/values-sr/strings.xml | 1 - app/src/main/res/values/colors.xml | 1 - app/src/main/res/values/settings_keys.xml | 1 - app/src/main/res/values/strings.xml | 1 - app/src/main/res/xml/settings_screen.xml | 5 - 20 files changed, 260 insertions(+), 68 deletions(-) create mode 100644 app/src/main/res/layout-v18/fragment_videoitem_detail.xml diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index a7c80bea6..4290e5c9c 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -8,6 +8,7 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Point; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; @@ -379,20 +380,6 @@ public class VideoItemDetailFragment extends Fragment { e.printStackTrace(); } - if (PreferenceManager.getDefaultSharedPreferences(getActivity()) - .getBoolean(getString(R.string.leftHandLayout), false) && checkIfLandscape()) { - RelativeLayout.LayoutParams oldLayout = - (RelativeLayout.LayoutParams) playVideoButton.getLayoutParams(); - RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( - RelativeLayout.LayoutParams.WRAP_CONTENT, - RelativeLayout.LayoutParams.WRAP_CONTENT); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); - layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); - layoutParams.setMargins(oldLayout.leftMargin, oldLayout.topMargin, - oldLayout.rightMargin, oldLayout.bottomMargin); - playVideoButton.setLayoutParams(layoutParams); - } - playVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -422,22 +409,26 @@ public class VideoItemDetailFragment extends Fragment { } }); - ImageView thumbnailView = (ImageView) activity.findViewById(R.id.detailThumbnailView); - thumbnailView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { - // This is used to synchronize the thumbnailWindowButton and the playVideoButton - // inside the ScrollView with the actual size of the thumbnail. - @Override - public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { - RelativeLayout.LayoutParams newWindowLayoutParams = - (RelativeLayout.LayoutParams) thumbnailWindowLayout.getLayoutParams(); - newWindowLayoutParams.height = bottom - top; - thumbnailWindowLayout.setLayoutParams(newWindowLayoutParams); + // todo: Fix this workaround (probably with a better design), so that older android + // versions don't have problems rendering the thumbnail right. + if(Build.VERSION.SDK_INT >= 18) { + ImageView thumbnailView = (ImageView) activity.findViewById(R.id.detailThumbnailView); + thumbnailView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { + // This is used to synchronize the thumbnailWindowButton and the playVideoButton + // inside the ScrollView with the actual size of the thumbnail. + @Override + public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { + RelativeLayout.LayoutParams newWindowLayoutParams = + (RelativeLayout.LayoutParams) thumbnailWindowLayout.getLayoutParams(); + newWindowLayoutParams.height = bottom - top; + thumbnailWindowLayout.setLayoutParams(newWindowLayoutParams); - //noinspection SuspiciousNameCombination - initialThumbnailPos.set(top, left); + //noinspection SuspiciousNameCombination + initialThumbnailPos.set(top, left); - } - }); + } + }); + } } } diff --git a/app/src/main/res/layout-v18/fragment_videoitem_detail.xml b/app/src/main/res/layout-v18/fragment_videoitem_detail.xml new file mode 100644 index 000000000..91cfea986 --- /dev/null +++ b/app/src/main/res/layout-v18/fragment_videoitem_detail.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + +