PoC: widget day/night mode (2)

pull/207/head
M66B 3 years ago
parent fc6ba484bc
commit d26e4bfd56

@ -91,7 +91,8 @@ public class WidgetUnified extends AppWidgetProvider {
PendingIntent piCompose = PendingIntentCompat.getActivity(
context, appWidgetId, edit, PendingIntent.FLAG_UPDATE_CURRENT);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_unified);
RemoteViews views = new RemoteViews(context.getPackageName(),
daynight ? R.layout.widget_unified_dn : R.layout.widget_unified);
views.setTextViewTextSize(R.id.title, TypedValue.COMPLEX_UNIT_SP, getFontSizeSp(font));

@ -181,7 +181,9 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
@Override
public RemoteViews getViewAt(int position) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.item_widget_unified);
RemoteViews views = new RemoteViews(context.getPackageName(),
daynight ? R.layout.item_widget_unified_dn : R.layout.item_widget_unified);
int idFrom = (subject_top ? R.id.tvSubject : R.id.tvFrom);
int idTime = (subject_top ? R.id.tvAccount : R.id.tvTime);
int idSubject = (subject_top ? R.id.tvFrom : R.id.tvSubject);

@ -49,7 +49,7 @@
android:maxLines="1"
android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
android:textColor="@color/colorWidgetForeground" />
<TextView
android:id="@+id/tvTime"
@ -59,7 +59,7 @@
android:maxLines="1"
android:text="12:34"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
android:textColor="@color/colorWidgetForeground" />
</LinearLayout>
<LinearLayout
@ -76,7 +76,7 @@
android:maxLines="1"
android:text="Subject"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
android:textColor="@color/colorWidgetForeground" />
<TextView
android:id="@+id/tvAccount"
@ -86,7 +86,7 @@
android:maxLines="1"
android:text="Account"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
android:textColor="@color/colorWidgetForeground" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
@ -95,5 +95,5 @@
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:colorControlNormal" />
android:background="@color/grey" />
</LinearLayout>

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/llMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/stripe"
android:layout_width="3dp"
android:layout_height="match_parent"
android:layout_marginEnd="3dp"
android:background="@color/grey" />
<ImageView
android:id="@+id/avatar"
android:layout_width="36dp"
android:layout_height="match_parent"
android:layout_marginEnd="3dp"
android:adjustViewBounds="true"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="6dp"
android:paddingBottom="6dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvFrom"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
<TextView
android:id="@+id/tvTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:maxLines="1"
android:text="12:34"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tvSubject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="Subject"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
<TextView
android:id="@+id/tvAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:maxLines="1"
android:text="Account"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:colorControlNormal" />
</LinearLayout>

@ -4,8 +4,7 @@
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground"
android:theme="@style/Theme.AppCompat.DayNight">
android:background="@drawable/widget_background">
<LinearLayout
android:id="@+id/content"
@ -29,7 +28,7 @@
android:padding="6dp"
android:text="@string/title_widget_title_list"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:textColorPrimary"
android:textColor="@color/colorWidgetForeground"
android:textStyle="bold" />
<ImageView
@ -39,10 +38,8 @@
android:layout_weight="0"
android:contentDescription="@string/tile_synchronize"
android:padding="6dp"
android:src="@drawable/twotone_sync_24"
android:tint="?android:textColorPrimary"
android:visibility="visible"
app:tint="?android:textColorPrimary" />
android:src="@drawable/twotone_sync_24_white"
android:visibility="gone" />
<ImageView
android:id="@+id/compose"
@ -51,17 +48,15 @@
android:layout_weight="0"
android:contentDescription="@string/title_compose"
android:padding="6dp"
android:src="@drawable/twotone_edit_24"
android:tint="?android:textColorPrimary"
android:visibility="visible"
app:tint="?android:textColorPrimary" />
android:src="@drawable/twotone_edit_24_white"
android:visibility="gone" />
</LinearLayout>
<FrameLayout
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:colorControlNormal" />
android:background="@color/grey" />
<ListView
android:id="@+id/lv"

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground"
android:theme="@style/Theme.AppCompat.DayNight">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="6dp"
android:paddingEnd="6dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="6dp"
android:text="@string/title_widget_title_list"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:textColorPrimary"
android:textStyle="bold" />
<ImageView
android:id="@+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:contentDescription="@string/tile_synchronize"
android:padding="6dp"
android:src="@drawable/twotone_sync_24"
android:tint="?android:textColorPrimary"
android:visibility="visible"
app:tint="?android:textColorPrimary" />
<ImageView
android:id="@+id/compose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:contentDescription="@string/title_compose"
android:padding="6dp"
android:src="@drawable/twotone_edit_24"
android:tint="?android:textColorPrimary"
android:visibility="visible"
app:tint="?android:textColorPrimary" />
</LinearLayout>
<FrameLayout
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:colorControlNormal" />
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:divider="@null" />
</LinearLayout>
</FrameLayout>
Loading…
Cancel
Save