Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: add previewLayout for all widgets

Ammar Ahmed55b51b81e364
diff --git a/apps/mobile/android/app/src/main/res/layout/note_widget_preview.xml b/apps/mobile/android/app/src/main/res/layout/note_widget_preview.xml
new file mode 100644
index 000000000..710b74aa9
--- /dev/null
+++ b/apps/mobile/android/app/src/main/res/layout/note_widget_preview.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Shown in the widget picker only. Mirrors note_widget.xml, but with sample content, since the
+ real layout has nothing to show until the widget has been configured.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/transparent"
+ android:theme="@style/ThemeOverlay.Notesnook.AppWidgetContainer">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_centerVertical="true"
+ android:background="@drawable/layout_bg"
+ android:elevation="5dp"
+ android:orientation="vertical"
+ android:paddingHorizontal="10dp"
+ android:paddingVertical="10dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="8dp"
+ android:text="@string/widget_preview_note_title"
+ android:textColor="@color/text"
+ android:textSize="16sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginLeft="8dp"
+ android:text="@string/widget_preview_note_body"
+ android:textColor="@color/text"
+ android:textSize="14sp" />
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/apps/mobile/android/app/src/main/res/layout/widget_reminders_preview.xml b/apps/mobile/android/app/src/main/res/layout/widget_reminders_preview.xml
new file mode 100644
index 000000000..2208f51fd
--- /dev/null
+++ b/apps/mobile/android/app/src/main/res/layout/widget_reminders_preview.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Shown in the widget picker only. Mirrors widget_reminders.xml, but with the list replaced by
+ sample rows, since an adapter-backed list renders empty in the picker.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/layout_bg"
+ android:orientation="vertical">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:paddingHorizontal="12dp"
+ android:paddingTop="12dp">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_marginTop="2dp"
+ android:text="Upcoming Reminders"
+ android:textColor="@color/text"
+ android:textSize="16sp"
+ android:textStyle="bold" />
+
+ <ImageButton
+ android:layout_width="35dp"
+ android:layout_height="35dp"
+ android:layout_alignParentRight="true"
+ android:background="@drawable/ic_newnote"
+ android:contentDescription="@string/add_widget" />
+ </RelativeLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:layout_marginTop="2dp"
+ android:layout_marginBottom="8dp"
+ android:background="@color/border" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingHorizontal="12dp"
+ android:paddingBottom="12dp">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/widget_preview_reminder_title"
+ android:textColor="@color/text"
+ android:textSize="16sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="10dp"
+ android:text="@string/widget_preview_reminder_time"
+ android:textColor="@color/text"
+ android:textSize="12sp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/widget_preview_reminder_title_alt"
+ android:textColor="@color/text"
+ android:textSize="16sp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/widget_preview_reminder_time_alt"
+ android:textColor="@color/text"
+ android:textSize="12sp" />
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/apps/mobile/android/app/src/main/res/values/strings.xml b/apps/mobile/android/app/src/main/res/values/strings.xml
index 7a86c8d38..8652b200d 100644
--- a/apps/mobile/android/app/src/main/res/values/strings.xml
+++ b/apps/mobile/android/app/src/main/res/values/strings.xml
@@ -9,6 +9,14 @@
<string name="note">Note</string>
<string name="note_description">Add a note to home screen</string>
<string name="quick_note">Quick note</string>
+ <!-- Sample content, only ever shown in the widget picker's preview. -->
+ <string name="widget_preview_note_title">Meeting notes</string>
+ <string name="widget_preview_note_body">Discuss the roadmap and agree on timelines.</string>
+ <string name="widget_preview_reminder_title">Take a walk</string>
+ <string name="widget_preview_reminder_time">Upcoming: Today, 5:00 PM</string>
+ <string name="widget_preview_reminder_title_alt">Call the dentist</string>
+ <string name="widget_preview_reminder_time_alt">Upcoming: Tomorrow, 9:00 AM</string>
+
<string name="widget_note_unconfigured_title">Tap to choose a note</string>
<string name="widget_note_unconfigured_body">Pick the note you want shown here.</string>
<string name="reminder_ongoing">Ongoing</string>
diff --git a/apps/mobile/android/app/src/main/res/xml/new_note_widget_info.xml b/apps/mobile/android/app/src/main/res/xml/new_note_widget_info.xml
index 086bf7228..c76d158b6 100644
--- a/apps/mobile/android/app/src/main/res/xml/new_note_widget_info.xml
+++ b/apps/mobile/android/app/src/main/res/xml/new_note_widget_info.xml
@@ -10,6 +10,7 @@
android:targetCellWidth="5"
android:targetCellHeight="1"
android:previewImage="@drawable/widget_preview"
+ android:previewLayout="@layout/new_note_widget"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen"/>
\ No newline at end of file
diff --git a/apps/mobile/android/app/src/main/res/xml/note_widget_info.xml b/apps/mobile/android/app/src/main/res/xml/note_widget_info.xml
index 84c936b29..c597dc450 100644
--- a/apps/mobile/android/app/src/main/res/xml/note_widget_info.xml
+++ b/apps/mobile/android/app/src/main/res/xml/note_widget_info.xml
@@ -12,6 +12,7 @@
android:targetCellWidth="5"
android:targetCellHeight="1"
android:previewImage="@drawable/note_widget_preview"
+ android:previewLayout="@layout/note_widget_preview"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen"/>
\ No newline at end of file
diff --git a/apps/mobile/android/app/src/main/res/xml/widget_reminders_info.xml b/apps/mobile/android/app/src/main/res/xml/widget_reminders_info.xml
index d88c14187..0d7068b1c 100644
--- a/apps/mobile/android/app/src/main/res/xml/widget_reminders_info.xml
+++ b/apps/mobile/android/app/src/main/res/xml/widget_reminders_info.xml
@@ -9,6 +9,7 @@
android:targetCellHeight="2"
android:resizeMode="horizontal|vertical"
android:previewImage="@drawable/reminder_preview"
+ android:previewLayout="@layout/widget_reminders_preview"
android:updatePeriodMillis="1800000"
android:widgetCategory="home_screen"
/>
\ No newline at end of file