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
add widget on android to make quick note
ammarahm-ed817349af51b0
diff --git a/apps/mobile/NotesnookShare.js b/apps/mobile/NotesnookShare.jsindex c2f33a254..b57ee564c 100644--- a/apps/mobile/NotesnookShare.js+++ b/apps/mobile/NotesnookShare.js@@ -47,6 +47,14 @@ export default class NotesnookShare extends Component {linkPreview = require("link-preview-js")const data = await ShareExtension.data();let text;+ if (!data) {+ this.setState({+ loadingIntent:false,+ text:"",+ title:""+ })+ return;+ }let item = data[0];if (item.type === 'text') {text = item.value;@@ -90,6 +98,11 @@ export default class NotesnookShare extends Component {this.initialText = text;} catch (e) {+ this.setState({+ loadingIntent:false,+ text:"",+ title:""+ })console.log('errrr', e);}}@@ -430,7 +443,9 @@ export default class NotesnookShare extends Component {paddingTop: 0,marginBottom: 10,paddingHorizontal: 12,+ minHeight:100}}+ textAlignVertical="top"placeholderTextColor={this.state.colors.icon}onChangeText={(v) => this.setState({text: v})}multiline={true}diff --git a/apps/mobile/android/app/src/main/AndroidManifest.xml b/apps/mobile/android/app/src/main/AndroidManifest.xmlindex 771edd5a4..5daa689b3 100644--- a/apps/mobile/android/app/src/main/AndroidManifest.xml+++ b/apps/mobile/android/app/src/main/AndroidManifest.xml@@ -8,8 +8,8 @@<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /><uses-permission android:name="android.permission.USE_FINGERPRINT" />- <uses-permission android:name="android.permission.USE_BIOMETRIC" />-+ <uses-permission android:name="android.permission.USE_BIOMETRIC" />+<applicationandroid:name=".MainApplication"android:allowBackup="false"@@ -19,6 +19,15 @@android:roundIcon="@mipmap/ic_launcher_round"android:theme="@style/AppTheme"android:usesCleartextTraffic="true">+ <receiver android:name=".NoteWidget">+ <intent-filter>+ <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />+ </intent-filter>++ <meta-data+ android:name="android.appwidget.provider"+ android:resource="@xml/note_widget_info" />+ </receiver><activityandroid:name=".MainActivity"@@ -28,9 +37,9 @@android:windowSoftInputMode="adjustResize"><intent-filter><action android:name="android.intent.action.MAIN" />+<category android:name="android.intent.category.LAUNCHER" /></intent-filter>-<intent-filter android:label="Notesnook"><action android:name="android.intent.action.VIEW" />@@ -39,14 +48,10 @@<dataandroid:host="app.notesnook.com"- android:scheme="https"></data>-+ android:scheme="https" /></intent-filter>-</activity>-<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />-<activityandroid:name=".ShareActivity"android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"@@ -56,24 +61,26 @@android:theme="@style/AppThemeB"><intent-filter android:label="Make Note"><action android:name="android.intent.action.SEND" />+<category android:name="android.intent.category.DEFAULT" />+<data android:mimeType="text/*" /></intent-filter>-<intent-filter android:label="Make Note"><action android:name="android.intent.action.PROCESS_TEXT" />+<category android:name="android.intent.category.DEFAULT" />+<data android:mimeType="text/*" /></intent-filter>--</activity><service- android:name="com.streetwriters.notesnook.OnClearFromRecentService"+ android:name=".OnClearFromRecentService"android:enabled="true"android:exported="true"android:stopWithTask="false" />+<providerandroid:name="com.vinzscam.reactnativefileviewer.FileProvider"android:authorities="${applicationId}.provider"diff --git a/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/NoteWidget.java b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/NoteWidget.javanew file mode 100644index 000000000..74383bab3--- /dev/null+++ b/apps/mobile/android/app/src/main/java/com/streetwriters/notesnook/NoteWidget.java@@ -0,0 +1,47 @@+package com.streetwriters.notesnook;++import android.app.PendingIntent;+import android.appwidget.AppWidgetManager;+import android.appwidget.AppWidgetProvider;+import android.content.Context;+import android.content.Intent;+import android.widget.RemoteViews;++/**+ * Implementation of App Widget functionality.+ */+public class NoteWidget extends AppWidgetProvider {++ static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,+ int appWidgetId) {++ Intent intent = new Intent(context, ShareActivity.class);+ PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);++ ;+ CharSequence widgetText = context.getString(R.string.appwidget_text);+ // Construct the RemoteViews object+ RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.note_widget);+ views.setOnClickPendingIntent(R.id.widget_button, pendingIntent);+ // Instruct the widget manager to update the widget+ appWidgetManager.updateAppWidget(appWidgetId, views);+ }++ @Override+ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {+ // There may be multiple widgets active, so update all of them+ for (int appWidgetId : appWidgetIds) {+ updateAppWidget(context, appWidgetManager, appWidgetId);+ }+ }++ @Override+ public void onEnabled(Context context) {+ // Enter relevant functionality for when the first widget is created+ }++ @Override+ public void onDisabled(Context context) {+ // Enter relevant functionality for when the last widget is disabled+ }+}\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/res/drawable-anydpi/ic_action_name.xml b/apps/mobile/android/app/src/main/res/drawable-anydpi/ic_action_name.xmlnew file mode 100644index 000000000..dccaf481c--- /dev/null+++ b/apps/mobile/android/app/src/main/res/drawable-anydpi/ic_action_name.xml@@ -0,0 +1,11 @@+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="24dp"+ android:height="24dp"+ android:viewportWidth="24"+ android:viewportHeight="24"+ android:tint="#333333"+ android:alpha="0.6">+ <path+ android:fillColor="@android:color/white"+ android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>+</vector>diff --git a/apps/mobile/android/app/src/main/res/drawable-hdpi/ic_action_name.png b/apps/mobile/android/app/src/main/res/drawable-hdpi/ic_action_name.pngnew file mode 100644index 000000000..f93cc0d90Binary files /dev/null and b/apps/mobile/android/app/src/main/res/drawable-hdpi/ic_action_name.png differdiff --git a/apps/mobile/android/app/src/main/res/drawable-mdpi/ic_action_name.png b/apps/mobile/android/app/src/main/res/drawable-mdpi/ic_action_name.pngnew file mode 100644index 000000000..aa7b716ceBinary files /dev/null and b/apps/mobile/android/app/src/main/res/drawable-mdpi/ic_action_name.png differdiff --git a/apps/mobile/android/app/src/main/res/drawable-nodpi/example_appwidget_preview.png b/apps/mobile/android/app/src/main/res/drawable-nodpi/example_appwidget_preview.pngnew file mode 100644index 000000000..894b069a4Binary files /dev/null and b/apps/mobile/android/app/src/main/res/drawable-nodpi/example_appwidget_preview.png differdiff --git a/apps/mobile/android/app/src/main/res/drawable-xhdpi/ic_action_name.png b/apps/mobile/android/app/src/main/res/drawable-xhdpi/ic_action_name.pngnew file mode 100644index 000000000..a002ff092Binary files /dev/null and b/apps/mobile/android/app/src/main/res/drawable-xhdpi/ic_action_name.png differdiff --git a/apps/mobile/android/app/src/main/res/drawable-xxhdpi/ic_action_name.png b/apps/mobile/android/app/src/main/res/drawable-xxhdpi/ic_action_name.pngnew file mode 100644index 000000000..25da31007Binary files /dev/null and b/apps/mobile/android/app/src/main/res/drawable-xxhdpi/ic_action_name.png differdiff --git a/apps/mobile/android/app/src/main/res/drawable/layout_bg.xml b/apps/mobile/android/app/src/main/res/drawable/layout_bg.xmlnew file mode 100644index 000000000..749c204e5--- /dev/null+++ b/apps/mobile/android/app/src/main/res/drawable/layout_bg.xml@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="UTF-8"?>+<shape xmlns:android="http://schemas.android.com/apk/res/android">+ <solid android:color="#CCFFFFFF"/>+ <stroke android:width="0dp" android:color="#B1BCBE" />+ <corners android:radius="10dp"/>+ <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />+</shape>\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/res/layout/note_widget.xml b/apps/mobile/android/app/src/main/res/layout/note_widget.xmlnew file mode 100644index 000000000..0354870a5--- /dev/null+++ b/apps/mobile/android/app/src/main/res/layout/note_widget.xml@@ -0,0 +1,37 @@+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:app="http://schemas.android.com/apk/res-auto"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:background="@android:color/transparent"+ android:padding="@dimen/widget_margin"+ android:theme="@style/ThemeOverlay.Notesnook.AppWidgetContainer">++ <LinearLayout+ android:layout_width="match_parent"+ android:id="@+id/widget_button"+ android:layout_height="50dp"+ android:layout_centerHorizontal="true"+ android:layout_centerVertical="true"+ android:background="@drawable/layout_bg"+ android:paddingHorizontal="10dp"++ 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>+++ </LinearLayout>++</RelativeLayout>\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/res/values-night/themes.xml b/apps/mobile/android/app/src/main/res/values-night/themes.xmlnew file mode 100644index 000000000..b37dd7b02--- /dev/null+++ b/apps/mobile/android/app/src/main/res/values-night/themes.xml@@ -0,0 +1,7 @@+<resources>++ <style name="ThemeOverlay.Notesnook.AppWidgetContainer" parent="">+ <item name="appWidgetBackgroundColor">@color/light_blue_900</item>+ <item name="appWidgetTextColor">@color/light_blue_200</item>+ </style>+</resources>\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/res/values/attrs.xml b/apps/mobile/android/app/src/main/res/values/attrs.xmlnew file mode 100644index 000000000..97531a256--- /dev/null+++ b/apps/mobile/android/app/src/main/res/values/attrs.xml@@ -0,0 +1,6 @@+<resources>+ <declare-styleable name="AppWidgetAttrs">+ <attr name="appWidgetBackgroundColor" format="color" />+ <attr name="appWidgetTextColor" format="color" />+ </declare-styleable>+</resources>\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/res/values/colors.xml b/apps/mobile/android/app/src/main/res/values/colors.xmlindex a6b3daec9..c966bb4e9 100644--- a/apps/mobile/android/app/src/main/res/values/colors.xml+++ b/apps/mobile/android/app/src/main/res/values/colors.xml@@ -1,2 +1,7 @@<?xml version="1.0" encoding="utf-8"?>-<resources></resources>\ No newline at end of file+<resources>+ <color name="light_blue_50">#FFE1F5FE</color>+ <color name="light_blue_200">#FF81D4FA</color>+ <color name="light_blue_600">#FF039BE5</color>+ <color name="light_blue_900">#FF01579B</color>+</resources>\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/res/values/dimens.xml b/apps/mobile/android/app/src/main/res/values/dimens.xmlnew file mode 100644index 000000000..4db8c5906--- /dev/null+++ b/apps/mobile/android/app/src/main/res/values/dimens.xml@@ -0,0 +1,10 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>++ <!--+Refer to App Widget Documentation for margin information+http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout+ -->+ <dimen name="widget_margin">0dp</dimen>++</resources>\ No newline at end of filediff --git a/apps/mobile/android/app/src/main/res/values/strings.xml b/apps/mobile/android/app/src/main/res/values/strings.xmlindex dee256728..af33e9651 100644--- a/apps/mobile/android/app/src/main/res/values/strings.xml+++ b/apps/mobile/android/app/src/main/res/values/strings.xml@@ -1,5 +1,7 @@<resources><string name="app_name">Notesnook</string><string name="title_activity_share">NotesnookShare</string>+ <string name="appwidget_text">EXAMPLE</string>+ <string name="add_widget">Add widget</string></resources>diff --git a/apps/mobile/android/app/src/main/res/values/themes.xml b/apps/mobile/android/app/src/main/res/values/themes.xmlnew file mode 100644index 000000000..935088e01--- /dev/null+++ b/apps/mobile/android/app/src/main/res/values/themes.xml@@ -0,0 +1,7 @@+<resources>++ <style name="ThemeOverlay.Notesnook.AppWidgetContainer" parent="">+ <item name="appWidgetBackgroundColor">@color/light_blue_600</item>+ <item name="appWidgetTextColor">@color/light_blue_50</item>+ </style>+</resources>\ No newline at end of filediff --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.xmlnew file mode 100644index 000000000..71715aaeb--- /dev/null+++ b/apps/mobile/android/app/src/main/res/xml/note_widget_info.xml@@ -0,0 +1,10 @@+<?xml version="1.0" encoding="utf-8"?>+<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"+ android:initialKeyguardLayout="@layout/note_widget"+ android:initialLayout="@layout/note_widget"+ android:minWidth="110dp"+ android:minHeight="40dp"+ android:previewImage="@drawable/example_appwidget_preview"+ android:resizeMode="horizontal"+ android:updatePeriodMillis="86400000"+ android:widgetCategory="home_screen"></appwidget-provider>\ No newline at end of file