mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 11:39:21 +02:00
Compare commits
1 Commits
v3.3.0
...
fix-androi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d66e0b98e1 |
@@ -103,6 +103,7 @@ import { getGithubVersion } from "../utils/github-version";
|
|||||||
import { tabBarRef } from "../utils/global-refs";
|
import { tabBarRef } from "../utils/global-refs";
|
||||||
import { NotesnookModule } from "../utils/notesnook-module";
|
import { NotesnookModule } from "../utils/notesnook-module";
|
||||||
import { sleep } from "../utils/time";
|
import { sleep } from "../utils/time";
|
||||||
|
import ReminderSheet from "../components/sheets/reminder";
|
||||||
|
|
||||||
const onCheckSyncStatus = async (type: SyncStatusEvent) => {
|
const onCheckSyncStatus = async (type: SyncStatusEvent) => {
|
||||||
const { disableSync, disableAutoSync } = SettingsService.get();
|
const { disableSync, disableAutoSync } = SettingsService.get();
|
||||||
@@ -157,6 +158,8 @@ const onUserSessionExpired = async () => {
|
|||||||
|
|
||||||
const onAppOpenedFromURL = async (event: { url: string }) => {
|
const onAppOpenedFromURL = async (event: { url: string }) => {
|
||||||
const url = event.url;
|
const url = event.url;
|
||||||
|
|
||||||
|
console.log("URL", url);
|
||||||
try {
|
try {
|
||||||
if (url.startsWith("https://app.notesnook.com/account/verified")) {
|
if (url.startsWith("https://app.notesnook.com/account/verified")) {
|
||||||
await onUserEmailVerified();
|
await onUserEmailVerified();
|
||||||
@@ -166,6 +169,25 @@ const onAppOpenedFromURL = async (event: { url: string }) => {
|
|||||||
eSendEvent(eOnLoadNote, { newNote: true });
|
eSendEvent(eOnLoadNote, { newNote: true });
|
||||||
tabBarRef.current?.goToPage(1, false);
|
tabBarRef.current?.goToPage(1, false);
|
||||||
return;
|
return;
|
||||||
|
} else if (url.startsWith("https://notesnook.com/open_note")) {
|
||||||
|
const id = new URL(url).searchParams.get("id");
|
||||||
|
if (id) {
|
||||||
|
const note = await db.notes.note(id);
|
||||||
|
if (note) {
|
||||||
|
eSendEvent(eOnLoadNote, {
|
||||||
|
item: note
|
||||||
|
});
|
||||||
|
tabBarRef.current?.goToPage(1, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (url.startsWith("https://notesnook.com/open_reminder")) {
|
||||||
|
const id = new URL(url).searchParams.get("id");
|
||||||
|
if (id) {
|
||||||
|
const reminder = await db.reminders.reminder(id);
|
||||||
|
if (reminder) ReminderSheet.present(reminder);
|
||||||
|
}
|
||||||
|
} else if (url.startsWith("https://notesnook.com/new_reminder")) {
|
||||||
|
ReminderSheet.present();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -695,10 +717,6 @@ export const useAppEvents = () => {
|
|||||||
// Reset the editor if the app has been in background for more than 10 minutes.
|
// Reset the editor if the app has been in background for more than 10 minutes.
|
||||||
eSendEvent(eEditorReset);
|
eSendEvent(eEditorReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(async () => {
|
|
||||||
IntentService.onAppStateChanged();
|
|
||||||
}, 100);
|
|
||||||
} else {
|
} else {
|
||||||
await saveEditorState();
|
await saveEditorState();
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -31,14 +31,20 @@ public class NotePreviewWidget extends AppWidgetProvider {
|
|||||||
|
|
||||||
Intent intent = new Intent(context, MainActivity.class);
|
Intent intent = new Intent(context, MainActivity.class);
|
||||||
intent.putExtra(OpenNoteId, note.getId());
|
intent.putExtra(OpenNoteId, note.getId());
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.putExtra(RCTNNativeModule.IntentType, "OpenNote");
|
intent.putExtra(RCTNNativeModule.IntentType, "OpenNote");
|
||||||
intent.setData(Uri.parse("https://notesnook.com/open_note"));
|
intent.setData(Uri.parse("https://notesnook.com/open_note?id=" + note.getId()));
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE, getActivityOptionsBundle());
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE, getActivityOptionsBundle());
|
||||||
views.setOnClickPendingIntent(R.id.open_note, pendingIntent);
|
views.setOnClickPendingIntent(R.id.open_note, pendingIntent);
|
||||||
|
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, views);
|
appWidgetManager.updateAppWidget(appWidgetId, views);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
|
||||||
|
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
|
||||||
|
}
|
||||||
|
|
||||||
private static Bundle getActivityOptionsBundle() {
|
private static Bundle getActivityOptionsBundle() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
ActivityOptions activityOptions = ActivityOptions.makeBasic();
|
ActivityOptions activityOptions = ActivityOptions.makeBasic();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.app.ActivityOptions;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -45,6 +46,7 @@ class ReminderRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||||||
SharedPreferences preferences = context.getSharedPreferences("appPreview", Context.MODE_PRIVATE);
|
SharedPreferences preferences = context.getSharedPreferences("appPreview", Context.MODE_PRIVATE);
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
reminders = gson.fromJson(preferences.getString("remindersList","[]"), new TypeToken<List<Reminder>>(){}.getType());
|
reminders = gson.fromJson(preferences.getString("remindersList","[]"), new TypeToken<List<Reminder>>(){}.getType());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,14 +66,16 @@ class ReminderRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||||||
boolean useMiniLayout = reminder.getDescription() == null || reminder.getDescription().isEmpty();
|
boolean useMiniLayout = reminder.getDescription() == null || reminder.getDescription().isEmpty();
|
||||||
|
|
||||||
RemoteViews views = new RemoteViews(context.getPackageName(), useMiniLayout ? R.layout.widget_reminder_layout_small : R.layout.widget_reminder_layout);
|
RemoteViews views = new RemoteViews(context.getPackageName(), useMiniLayout ? R.layout.widget_reminder_layout_small : R.layout.widget_reminder_layout);
|
||||||
|
|
||||||
views.setTextViewText(R.id.reminder_title, reminder.getTitle());
|
views.setTextViewText(R.id.reminder_title, reminder.getTitle());
|
||||||
if (!useMiniLayout) {
|
if (!useMiniLayout) {
|
||||||
views.setTextViewText(R.id.reminder_description, reminder.getDescription());
|
views.setTextViewText(R.id.reminder_description, reminder.getDescription());
|
||||||
}
|
}
|
||||||
views.setTextViewText(R.id.reminder_time, reminder.getFormattedTime());
|
views.setTextViewText(R.id.reminder_time, reminder.getFormattedTime());
|
||||||
final Intent fillInIntent = new Intent();
|
final Intent fillInIntent = new Intent();
|
||||||
final Bundle extras = new Bundle();
|
final Bundle extras = new Bundle();
|
||||||
extras.putString(ReminderViewsService.OpenReminderId, reminder.getId());
|
extras.putString(ReminderViewsService.OpenReminderId, reminder.getId());
|
||||||
|
fillInIntent.setData(Uri.parse("https://notesnook.com/open_reminder?id=" + reminder.getId()));
|
||||||
fillInIntent.putExtra(RCTNNativeModule.IntentType, "OpenReminder");
|
fillInIntent.putExtra(RCTNNativeModule.IntentType, "OpenReminder");
|
||||||
fillInIntent.putExtras(extras);
|
fillInIntent.putExtras(extras);
|
||||||
views.setOnClickFillInIntent(R.id.reminder_item_btn, fillInIntent);
|
views.setOnClickFillInIntent(R.id.reminder_item_btn, fillInIntent);
|
||||||
@@ -86,11 +90,12 @@ class ReminderRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewTypeCount() {
|
public int getViewTypeCount() {
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int position) {
|
public long getItemId(int position) {
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,13 @@ public class ReminderWidgetProvider extends AppWidgetProvider {
|
|||||||
|
|
||||||
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, RemoteViews views) {
|
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, RemoteViews views) {
|
||||||
Intent listview_intent_template = new Intent(context, MainActivity.class);
|
Intent listview_intent_template = new Intent(context, MainActivity.class);
|
||||||
listview_intent_template.setData(Uri.parse("https://notesnook.com/open_reminder"));
|
listview_intent_template.setAction(Intent.ACTION_VIEW);
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, listview_intent_template, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE, getActivityOptionsBundle());
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, appWidgetId, listview_intent_template, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE, getActivityOptionsBundle());
|
||||||
views.setPendingIntentTemplate(R.id.widget_list_view, pendingIntent);
|
views.setPendingIntentTemplate(R.id.widget_list_view, pendingIntent);
|
||||||
|
|
||||||
Intent new_reminder_intent = new Intent(context, MainActivity.class);
|
Intent new_reminder_intent = new Intent(context, MainActivity.class);
|
||||||
new_reminder_intent.putExtra(NewReminder, NewReminder);
|
new_reminder_intent.putExtra(NewReminder, NewReminder);
|
||||||
|
new_reminder_intent.setAction(Intent.ACTION_VIEW);
|
||||||
new_reminder_intent.putExtra(RCTNNativeModule.IntentType, "NewReminder");
|
new_reminder_intent.putExtra(RCTNNativeModule.IntentType, "NewReminder");
|
||||||
new_reminder_intent.setData(Uri.parse("https://notesnook.com/new_reminder"));
|
new_reminder_intent.setData(Uri.parse("https://notesnook.com/new_reminder"));
|
||||||
PendingIntent pendingIntent2 = PendingIntent.getActivity(context, appWidgetId, new_reminder_intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, getActivityOptionsBundle());
|
PendingIntent pendingIntent2 = PendingIntent.getActivity(context, appWidgetId, new_reminder_intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE, getActivityOptionsBundle());
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<color name="light_blue_600">#FF039BE5</color>
|
<color name="light_blue_600">#FF039BE5</color>
|
||||||
<color name="light_blue_900">#FF01579B</color>
|
<color name="light_blue_900">#FF01579B</color>
|
||||||
<color name="bootsplash_background">#FFFFFF</color>
|
<color name="bootsplash_background">#FFFFFF</color>
|
||||||
<color name="background">#D8000000</color>
|
<color name="background">#DCEDEDED</color>
|
||||||
<color name="border">#CCCCCC</color>
|
<color name="border">#BFBFBF</color>
|
||||||
<color name="text">#1D1D1D</color>
|
<color name="text">#1D1D1D</color>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user