A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: resizable and themeable android widget
Ammar Ahmed2f8bf191aa5c
diff --git a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/NoteWidget.java b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/NoteWidget.javaindex b8af4ba7b..5c3d4efe7 100644--- a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/NoteWidget.java+++ b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/NoteWidget.java@@ -5,6 +5,7 @@ import android.appwidget.AppWidgetManager;import android.appwidget.AppWidgetProvider;import android.content.Context;import android.content.Intent;+import android.os.Bundle;import android.widget.RemoteViews;/**@@ -24,11 +25,29 @@ public class NoteWidget extends AppWidgetProvider {appWidgetManager.updateAppWidget(appWidgetId, views);}+ @Override+ public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {+ super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);+ updateAppWidget(context, appWidgetManager, appWidgetId, newOptions);+ }++ private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle options) {+ int minWidth = options != null ? options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH) : 0;+// int minHeight = options != null ? options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT) : 0;++ int layoutId = (minWidth < 100) ? R.layout.note_widget_icon : R.layout.note_widget;++ RemoteViews views = new RemoteViews(context.getPackageName(), layoutId);+ appWidgetManager.updateAppWidget(appWidgetId, views);+ }++@Overridepublic void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {// There may be multiple widgets active, so update all of themfor (int appWidgetId : appWidgetIds) {updateAppWidget(context, appWidgetManager, appWidgetId);+ updateAppWidget(context, appWidgetManager, appWidgetId,null);}}diff --git a/apps/mobile/native/android/app/src/main/res/drawable/add_note.xml b/apps/mobile/native/android/app/src/main/res/drawable/add_note.xmlindex 5a64b70d8..253c1fbfd 100644--- a/apps/mobile/native/android/app/src/main/res/drawable/add_note.xml+++ b/apps/mobile/native/android/app/src/main/res/drawable/add_note.xml@@ -1,4 +1,4 @@-<vector android:height="24dp" android:tint="#000000"+<vector android:height="24dp" android:tint="@color/text"android:viewportHeight="24" android:viewportWidth="24"android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"><path android:fillColor="@android:color/white" android:pathData="M14,2L6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6zM16,16h-3v3h-2v-3L8,16v-2h3v-3h2v3h3v2zM13,9L13,3.5L18.5,9L13,9z"/>diff --git a/apps/mobile/native/android/app/src/main/res/drawable/layout_bg.xml b/apps/mobile/native/android/app/src/main/res/drawable/layout_bg.xmlindex 749c204e5..4e9108ff5 100644--- a/apps/mobile/native/android/app/src/main/res/drawable/layout_bg.xml+++ b/apps/mobile/native/android/app/src/main/res/drawable/layout_bg.xml@@ -1,6 +1,6 @@<?xml version="1.0" encoding="UTF-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">- <solid android:color="#CCFFFFFF"/>+ <solid android:color="@color/background"/><stroke android:width="0dp" android:color="#B1BCBE" /><corners android:radius="10dp"/><padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />diff --git a/apps/mobile/native/android/app/src/main/res/layout/note_widget.xml b/apps/mobile/native/android/app/src/main/res/layout/note_widget.xmlindex 70376610b..c4174e974 100644--- a/apps/mobile/native/android/app/src/main/res/layout/note_widget.xml+++ b/apps/mobile/native/android/app/src/main/res/layout/note_widget.xml@@ -6,7 +6,6 @@android:padding="@dimen/widget_margin"android:theme="@style/ThemeOverlay.Notesnook.AppWidgetContainer">-<LinearLayoutandroid:layout_width="match_parent"android:id="@+id/widget_button"@@ -18,21 +17,21 @@android:elevation="5dp"android:orientation="horizontal">- <LinearLayout- android:layout_width="match_parent"- android:layout_height="match_parent"- android:layout_centerVertical="true">-- <TextView- android:layout_width="wrap_content"- android:layout_height="wrap_content"- android:layout_gravity="center_vertical"- android:layout_marginLeft="8dp"- android:textSize="16sp"- android:text="Take a quick note." />- </LinearLayout>-+ <ImageView+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_gravity="center_vertical"+ android:src="@drawable/add_note"+ android:contentDescription="New note icon" />+ <TextView+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_gravity="center_vertical"+ android:layout_marginLeft="8dp"+ android:textColor="@color/text"+ android:textSize="16sp"+ android:text="@string/take_a_quick_note" /></LinearLayout></RelativeLayout>\ No newline at end of filediff --git a/apps/mobile/native/android/app/src/main/res/layout/note_widget_icon.xml b/apps/mobile/native/android/app/src/main/res/layout/note_widget_icon.xmlnew file mode 100644index 000000000..3be10dbef--- /dev/null+++ b/apps/mobile/native/android/app/src/main/res/layout/note_widget_icon.xml@@ -0,0 +1,13 @@+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"+ android:layout_width="match_parent"+ android:layout_height="50dp"+ android:background="@drawable/layout_bg"+ android:padding="@dimen/widget_margin">++ <ImageView+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_gravity="center"+ android:padding="16dp"+ android:src="@drawable/add_note" />+</FrameLayout>\ No newline at end of filediff --git a/apps/mobile/native/android/app/src/main/res/values-night/colors.xml b/apps/mobile/native/android/app/src/main/res/values-night/colors.xmlindex e07d4cd5f..34bb3eeaa 100644--- a/apps/mobile/native/android/app/src/main/res/values-night/colors.xml+++ b/apps/mobile/native/android/app/src/main/res/values-night/colors.xml@@ -5,4 +5,6 @@<color name="light_blue_600">#FF039BE5</color><color name="light_blue_900">#FF01579B</color><color name="bootsplash_background">#1f1f1f</color>+ <color name="background">#1D1D1D</color>+ <color name="text">#B4B4B4</color></resources>\ No newline at end of filediff --git a/apps/mobile/native/android/app/src/main/res/values/colors.xml b/apps/mobile/native/android/app/src/main/res/values/colors.xmlindex eeefb4b76..f3801dfd0 100644--- a/apps/mobile/native/android/app/src/main/res/values/colors.xml+++ b/apps/mobile/native/android/app/src/main/res/values/colors.xml@@ -5,4 +5,6 @@<color name="light_blue_600">#FF039BE5</color><color name="light_blue_900">#FF01579B</color><color name="bootsplash_background">#FFFFFF</color>+ <color name="background">#FFFFFF</color>+ <color name="text">#000000</color></resources>\ No newline at end of filediff --git a/apps/mobile/native/android/app/src/main/res/values/strings.xml b/apps/mobile/native/android/app/src/main/res/values/strings.xmlindex 88a7d1a34..7a0377d17 100644--- a/apps/mobile/native/android/app/src/main/res/values/strings.xml+++ b/apps/mobile/native/android/app/src/main/res/values/strings.xml@@ -3,4 +3,5 @@<string name="title_activity_share">NotesnookShare</string><string name="appwidget_text">EXAMPLE</string><string name="add_widget">Add widget</string>+ <string name="take_a_quick_note">Take a quick note.</string></resources>diff --git a/apps/mobile/native/android/app/src/main/res/xml/note_widget_info.xml b/apps/mobile/native/android/app/src/main/res/xml/note_widget_info.xmlindex 4cbf0dffe..96a3a851d 100644--- a/apps/mobile/native/android/app/src/main/res/xml/note_widget_info.xml+++ b/apps/mobile/native/android/app/src/main/res/xml/note_widget_info.xml@@ -2,9 +2,9 @@<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"android:initialKeyguardLayout="@layout/note_widget"android:initialLayout="@layout/note_widget"- android:minWidth="300dp"+ android:minWidth="50dp"android:minHeight="50dp"android:previewImage="@drawable/widget_preview"- android:resizeMode="horizontal"+ android:resizeMode="horizontal|vertical"android:updatePeriodMillis="86400000"android:widgetCategory="home_screen"></appwidget-provider>\ No newline at end of file