mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-24 05:46:14 +03:00
The single note widget now stores the accountId in the same way as it
does the noteID. Signed-off-by: Daniel Bailey <daniel.bailey@grappleIT.co.uk>
This commit is contained in:
parent
1bd95a9db3
commit
b68362ed4a
3 changed files with 10 additions and 9 deletions
|
@ -66,6 +66,7 @@ public class SelectSingleNoteActivity extends NotesListViewActivity {
|
|||
SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(this).edit();
|
||||
|
||||
sp.putLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, noteID);
|
||||
sp.putLong(SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId, note.getAccountId());
|
||||
sp.putBoolean(SingleNoteWidget.DARK_THEME_KEY + appWidgetId, Notes.getAppTheme(getApplicationContext()));
|
||||
sp.apply();
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ public class SingleNoteWidget extends AppWidgetProvider {
|
|||
|
||||
public static final String DARK_THEME_KEY = "SNW_darkTheme";
|
||||
public static final String WIDGET_KEY = "single_note_widget";
|
||||
public static final String ACCOUNT_ID_KEY = "SNW_accountId";
|
||||
|
||||
static void updateAppWidget(Context context, AppWidgetManager awm, int[] appWidgetIds) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
@ -55,7 +56,6 @@ public class SingleNoteWidget extends AppWidgetProvider {
|
|||
views.setEmptyView(R.id.single_note_widget_lv, R.id.widget_single_note_placeholder_tv);
|
||||
awm.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv);
|
||||
}
|
||||
|
||||
awm.updateAppWidget(appWidgetId, views);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,8 @@ public class SingleNoteWidget extends AppWidgetProvider {
|
|||
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
editor.remove(WIDGET_KEY + appWidgetId);
|
||||
editor.remove(NoteListWidget.DARK_THEME_KEY + appWidgetId);
|
||||
editor.remove(DARK_THEME_KEY + appWidgetId);
|
||||
editor.remove(ACCOUNT_ID_KEY + appWidgetId);
|
||||
}
|
||||
|
||||
editor.apply();
|
||||
|
|
|
@ -27,7 +27,6 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
|
|||
private MarkdownProcessor markdownProcessor;
|
||||
private final Context context;
|
||||
private final int appWidgetId;
|
||||
private long accountId;
|
||||
|
||||
private NoteSQLiteOpenHelper db;
|
||||
private DBNote note;
|
||||
|
@ -50,11 +49,11 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
|
|||
@Override
|
||||
public void onCreate() {
|
||||
db = NoteSQLiteOpenHelper.getInstance(context);
|
||||
try {
|
||||
accountId = db.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(context).name).getId();
|
||||
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// try {
|
||||
// accountId = db.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(context).name).getId();
|
||||
// } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,7 +62,7 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
|
|||
long noteID = sp.getLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, -1);
|
||||
|
||||
if (noteID >= 0) {
|
||||
note = db.getNote(accountId, noteID);
|
||||
note = db.getNote(sp.getLong(SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId, -1), noteID);
|
||||
|
||||
if (note == null) {
|
||||
Log.e(TAG, "Error: note not found");
|
||||
|
|
Loading…
Reference in a new issue