From 10a5bf0a823e65b1264aea108e1e0ed587a242bb Mon Sep 17 00:00:00 2001 From: Grishka Date: Fri, 29 Apr 2022 17:38:48 +0300 Subject: [PATCH] Fix notification policy layout for long strings --- mastodon/build.gradle | 4 +- .../ui/views/AutoOrientationLinearLayout.java | 37 +++++++++++++++++++ .../item_settings_notification_policy.xml | 13 +++---- 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 mastodon/src/main/java/org/joinmastodon/android/ui/views/AutoOrientationLinearLayout.java diff --git a/mastodon/build.gradle b/mastodon/build.gradle index 2bcc4692..f01b96d7 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.joinmastodon.android" minSdk 23 targetSdk 31 - versionCode 33 - versionName "1.0.3" + versionCode 34 + versionName "1.0.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/views/AutoOrientationLinearLayout.java b/mastodon/src/main/java/org/joinmastodon/android/ui/views/AutoOrientationLinearLayout.java new file mode 100644 index 00000000..ce4c5bbd --- /dev/null +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/views/AutoOrientationLinearLayout.java @@ -0,0 +1,37 @@ +package org.joinmastodon.android.ui.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.widget.LinearLayout; + +public class AutoOrientationLinearLayout extends LinearLayout{ + public AutoOrientationLinearLayout(Context context){ + this(context, null); + } + + public AutoOrientationLinearLayout(Context context, AttributeSet attrs){ + this(context, attrs, 0); + } + + public AutoOrientationLinearLayout(Context context, AttributeSet attrs, int defStyle){ + super(context, attrs, defStyle); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){ + int hPadding=getPaddingLeft()+getPaddingRight(); + int childrenTotalWidth=0; + for(int i=0;iMeasureSpec.getSize(widthMeasureSpec)-hPadding){ + setOrientation(VERTICAL); + }else{ + setOrientation(HORIZONTAL); + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } +} diff --git a/mastodon/src/main/res/layout/item_settings_notification_policy.xml b/mastodon/src/main/res/layout/item_settings_notification_policy.xml index cc082604..a9f4d864 100644 --- a/mastodon/src/main/res/layout/item_settings_notification_policy.xml +++ b/mastodon/src/main/res/layout/item_settings_notification_policy.xml @@ -1,16 +1,17 @@ - -