mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-10-25 14:15:48 +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();
|
SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(this).edit();
|
||||||
|
|
||||||
sp.putLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, noteID);
|
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.putBoolean(SingleNoteWidget.DARK_THEME_KEY + appWidgetId, Notes.getAppTheme(getApplicationContext()));
|
||||||
sp.apply();
|
sp.apply();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ public class SingleNoteWidget extends AppWidgetProvider {
|
||||||
|
|
||||||
public static final String DARK_THEME_KEY = "SNW_darkTheme";
|
public static final String DARK_THEME_KEY = "SNW_darkTheme";
|
||||||
public static final String WIDGET_KEY = "single_note_widget";
|
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) {
|
static void updateAppWidget(Context context, AppWidgetManager awm, int[] appWidgetIds) {
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
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);
|
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.notifyAppWidgetViewDataChanged(appWidgetId, R.id.single_note_widget_lv);
|
||||||
}
|
}
|
||||||
|
|
||||||
awm.updateAppWidget(appWidgetId, views);
|
awm.updateAppWidget(appWidgetId, views);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,8 @@ public class SingleNoteWidget extends AppWidgetProvider {
|
||||||
|
|
||||||
for (int appWidgetId : appWidgetIds) {
|
for (int appWidgetId : appWidgetIds) {
|
||||||
editor.remove(WIDGET_KEY + appWidgetId);
|
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();
|
editor.apply();
|
||||||
|
|
|
@ -27,7 +27,6 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
|
||||||
private MarkdownProcessor markdownProcessor;
|
private MarkdownProcessor markdownProcessor;
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final int appWidgetId;
|
private final int appWidgetId;
|
||||||
private long accountId;
|
|
||||||
|
|
||||||
private NoteSQLiteOpenHelper db;
|
private NoteSQLiteOpenHelper db;
|
||||||
private DBNote note;
|
private DBNote note;
|
||||||
|
@ -50,11 +49,11 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
db = NoteSQLiteOpenHelper.getInstance(context);
|
db = NoteSQLiteOpenHelper.getInstance(context);
|
||||||
try {
|
// try {
|
||||||
accountId = db.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(context).name).getId();
|
// accountId = db.getLocalAccountByAccountName(SingleAccountHelper.getCurrentSingleSignOnAccount(context).name).getId();
|
||||||
} catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
// } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ public class SingleNoteWidgetFactory implements RemoteViewsService.RemoteViewsFa
|
||||||
long noteID = sp.getLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, -1);
|
long noteID = sp.getLong(SingleNoteWidget.WIDGET_KEY + appWidgetId, -1);
|
||||||
|
|
||||||
if (noteID >= 0) {
|
if (noteID >= 0) {
|
||||||
note = db.getNote(accountId, noteID);
|
note = db.getNote(sp.getLong(SingleNoteWidget.ACCOUNT_ID_KEY + appWidgetId, -1), noteID);
|
||||||
|
|
||||||
if (note == null) {
|
if (note == null) {
|
||||||
Log.e(TAG, "Error: note not found");
|
Log.e(TAG, "Error: note not found");
|
||||||
|
|
Loading…
Reference in a new issue