Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f33e87bc authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Merge branch '1103-Fix_widget_not_updating_on_account_logout_issue' into 'main'

1103-Fix_widget_not_updating_on_account_logout_issue

See merge request !37
parents 30298b0b 362cff2c
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@ public class NotesRepository {
        }

        db.getAccountDao().deleteAccount(account);
        notifyWidgets();
    }

    public Account getAccountByName(String accountName) {
+13 −0
Original line number Diff line number Diff line
@@ -58,6 +58,11 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact
        dbNotes.clear();
        try {
            data = repo.getNoteListWidgetData(appWidgetId);

            if (data == null) {
                return;
            }

            Log.v(TAG, "--- data - " + data);
            switch (data.getMode()) {
                case MODE_DISPLAY_ALL:
@@ -87,11 +92,19 @@ public class NoteListWidgetFactory implements RemoteViewsService.RemoteViewsFact

    @Override
    public int getCount() {
        if (data == null) {
            return 0;
        }

        return dbNotes.size() + 1;
    }

    @Override
    public RemoteViews getViewAt(int position) {
        if (data == null) {
            return null;
        }

        final RemoteViews note_content;

        if (position == 0) {
+13 −13
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ public class SingleNoteWidget extends AppWidgetProvider {
            final var data = repo.getSingleNoteWidgetData(appWidgetId);
            if (data != null) {
                templateIntent.putExtra(BaseNoteFragment.PARAM_ACCOUNT_ID, data.getAccountId());
            } else {
                Log.i(TAG, "onUpdate has been triggered before the user finished configuring the widget");
            }

            final var serviceIntent = new Intent(context, SingleNoteWidgetService.class);
            serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
@@ -47,9 +50,6 @@ public class SingleNoteWidget extends AppWidgetProvider {

            awm.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv);
            awm.updateAppWidget(appWidgetId, views);
            } else {
                Log.i(TAG, "onUpdate has been triggered before the user finished configuring the widget");
            }
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
                Log.e(TAG, "Error: note not found");
            }
        } else {
            note = null;
            Log.w(TAG, "Widget with ID " + appWidgetId + " seems to be not configured yet.");
        }
    }