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

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

1103-Fix_widget_not_updating_on_account_logout_issue

parent 30298b0b
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -227,6 +227,7 @@ public class NotesRepository {
        }
        }


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


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

            if (data == null) {
                return;
            }

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


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

        return dbNotes.size() + 1;
        return dbNotes.size() + 1;
    }
    }


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

        final RemoteViews note_content;
        final RemoteViews note_content;


        if (position == 0) {
        if (position == 0) {
+13 −13
Original line number Original line Diff line number Diff line
@@ -34,6 +34,9 @@ public class SingleNoteWidget extends AppWidgetProvider {
            final var data = repo.getSingleNoteWidgetData(appWidgetId);
            final var data = repo.getSingleNoteWidgetData(appWidgetId);
            if (data != null) {
            if (data != null) {
                templateIntent.putExtra(BaseNoteFragment.PARAM_ACCOUNT_ID, data.getAccountId());
                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);
            final var serviceIntent = new Intent(context, SingleNoteWidgetService.class);
            serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            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.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv);
            awm.updateAppWidget(appWidgetId, views);
            awm.updateAppWidget(appWidgetId, views);
            } else {
                Log.i(TAG, "onUpdate has been triggered before the user finished configuring the widget");
            }
        }
        }
    }
    }


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