Fix notification policy layout for long strings
This commit is contained in:
parent
a58a279e8c
commit
10a5bf0a82
|
@ -9,8 +9,8 @@ android {
|
||||||
applicationId "org.joinmastodon.android"
|
applicationId "org.joinmastodon.android"
|
||||||
minSdk 23
|
minSdk 23
|
||||||
targetSdk 31
|
targetSdk 31
|
||||||
versionCode 33
|
versionCode 34
|
||||||
versionName "1.0.3"
|
versionName "1.0.4"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;i<getChildCount();i++){
|
||||||
|
View child=getChildAt(i);
|
||||||
|
measureChildWithMargins(child, widthMeasureSpec, hPadding, heightMeasureSpec, 0);
|
||||||
|
childrenTotalWidth+=child.getMeasuredWidth();
|
||||||
|
}
|
||||||
|
if(childrenTotalWidth>MeasureSpec.getSize(widthMeasureSpec)-hPadding){
|
||||||
|
setOrientation(VERTICAL);
|
||||||
|
}else{
|
||||||
|
setOrientation(HORIZONTAL);
|
||||||
|
}
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<org.joinmastodon.android.ui.views.AutoOrientationLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="32dp"
|
android:layout_height="wrap_content"
|
||||||
android:layoutDirection="locale"
|
android:layoutDirection="locale"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp">
|
android:paddingRight="16dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="32dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="20dp"
|
android:textSize="20dp"
|
||||||
|
@ -19,12 +20,10 @@
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:text="@string/notify_me_when"/>
|
android:text="@string/notify_me_when"/>
|
||||||
|
|
||||||
<!-- TODO make this LL vertical when the button doesn't fit -->
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button"
|
android:id="@+id/button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="32dp"
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:background="@drawable/bg_inline_button"
|
android:background="@drawable/bg_inline_button"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:textColor="?android:textColorPrimary"
|
||||||
android:textSize="20dp"
|
android:textSize="20dp"
|
||||||
|
@ -37,4 +36,4 @@
|
||||||
android:ellipsize="middle"
|
android:ellipsize="middle"
|
||||||
tools:text="@string/notify_followed"/>
|
tools:text="@string/notify_followed"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</org.joinmastodon.android.ui.views.AutoOrientationLinearLayout>
|
Loading…
Reference in New Issue