mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 17:57:16 +00:00
Show attachment icon in unified list widget (Android 12+)
This commit is contained in:
parent
eecc43e89e
commit
0fb820c59f
2 changed files with 36 additions and 0 deletions
|
@ -23,6 +23,7 @@ import android.appwidget.AppWidgetManager;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
|
@ -186,8 +187,10 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
@Override
|
||||
public RemoteViews getViewAt(int position) {
|
||||
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.item_widget_unified);
|
||||
int ivFrom = (subject_top ? R.id.ivSubject : R.id.ivFrom);
|
||||
int idFrom = (subject_top ? R.id.tvSubject : R.id.tvFrom);
|
||||
int idTime = (subject_top ? R.id.tvAccount : R.id.tvTime);
|
||||
int ivSubject = (subject_top ? R.id.ivFrom : R.id.ivSubject);
|
||||
int idSubject = (subject_top ? R.id.tvFrom : R.id.tvSubject);
|
||||
int idAccount = (subject_top ? R.id.tvTime : R.id.tvAccount);
|
||||
|
||||
|
@ -195,8 +198,13 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
font = 1; // Default small
|
||||
|
||||
int sp = WidgetUnified.getFontSizeSp(font);
|
||||
int cpx = (int) (sp * context.getResources().getDisplayMetrics().scaledDensity);
|
||||
views.setViewLayoutHeight(ivFrom, cpx, TypedValue.COMPLEX_UNIT_PX);
|
||||
views.setViewLayoutWidth(ivFrom, cpx, TypedValue.COMPLEX_UNIT_PX);
|
||||
views.setTextViewTextSize(idFrom, TypedValue.COMPLEX_UNIT_SP, sp);
|
||||
views.setTextViewTextSize(idTime, TypedValue.COMPLEX_UNIT_SP, sp);
|
||||
views.setViewLayoutHeight(ivSubject, cpx, TypedValue.COMPLEX_UNIT_PX);
|
||||
views.setViewLayoutWidth(ivSubject, cpx, TypedValue.COMPLEX_UNIT_PX);
|
||||
views.setTextViewTextSize(idSubject, TypedValue.COMPLEX_UNIT_SP, sp);
|
||||
views.setTextViewTextSize(idAccount, TypedValue.COMPLEX_UNIT_SP, sp);
|
||||
|
||||
|
@ -268,6 +276,16 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
|
|||
views.setColorStateListAttr(R.id.separator, "setBackgroundTintList", 0);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
views.setViewVisibility(ivFrom, View.GONE);
|
||||
views.setViewVisibility(ivSubject, message.attachments > 0 ? View.VISIBLE : View.GONE);
|
||||
views.setColorStateList(ivSubject, "setImageTintList",
|
||||
ColorStateList.valueOf(message.ui_seen ? colorWidgetRead : colorWidgetUnread));
|
||||
} else {
|
||||
views.setViewVisibility(ivFrom, View.GONE);
|
||||
views.setViewVisibility(ivSubject, View.GONE);
|
||||
}
|
||||
|
||||
if (daynight && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
int textColorAttr = (message.ui_seen ? android.R.attr.textColorPrimary : android.R.attr.textColorLink);
|
||||
views.setColorStateListAttr(idFrom, "setTextColor", textColorAttr);
|
||||
|
|
|
@ -40,6 +40,15 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivFrom"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:paddingEnd="3dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/twotone_attachment_24"
|
||||
android:tint="?android:textColorPrimary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFrom"
|
||||
android:layout_width="0dp"
|
||||
|
@ -67,6 +76,15 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivSubject"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:paddingEnd="3dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/twotone_attachment_24"
|
||||
android:tint="?android:textColorPrimary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSubject"
|
||||
android:layout_width="0dp"
|
||||
|
|
Loading…
Reference in a new issue