7
7
package it .niedermann .owncloud .notes .main ;
8
8
9
9
import android .content .Context ;
10
+ import android .content .Intent ;
11
+ import android .os .Bundle ;
10
12
import android .util .TypedValue ;
11
13
import android .view .Menu ;
12
14
import android .view .MenuItem ;
31
33
import it .niedermann .owncloud .notes .accountpicker .AccountPickerDialogFragment ;
32
34
import it .niedermann .owncloud .notes .branding .BrandedSnackbar ;
33
35
import it .niedermann .owncloud .notes .edit .category .CategoryDialogFragment ;
36
+ import it .niedermann .owncloud .notes .share .NoteShareActivity ;
34
37
import it .niedermann .owncloud .notes .shared .util .ShareUtil ;
35
38
36
39
public class MultiSelectedActionModeCallback implements Callback {
@@ -53,8 +56,11 @@ public class MultiSelectedActionModeCallback implements Callback {
53
56
private final SelectionTracker <Long > tracker ;
54
57
@ NonNull
55
58
private final FragmentManager fragmentManager ;
59
+ @ NonNull
60
+ private final MainActivity mainActivity ;
56
61
57
62
public MultiSelectedActionModeCallback (
63
+ @ NonNull MainActivity mainActivity ,
58
64
@ NonNull Context context ,
59
65
@ NonNull View view ,
60
66
@ NonNull View anchorView ,
@@ -63,6 +69,7 @@ public MultiSelectedActionModeCallback(
63
69
boolean canMoveNoteToAnotherAccounts ,
64
70
@ NonNull SelectionTracker <Long > tracker ,
65
71
@ NonNull FragmentManager fragmentManager ) {
72
+ this .mainActivity = mainActivity ;
66
73
this .context = context ;
67
74
this .view = view ;
68
75
this .anchorView = anchorView ;
@@ -153,16 +160,26 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
153
160
}
154
161
tracker .clearSelection ();
155
162
156
- executor .submit (() -> {
157
- if (selection .size () == 1 ) {
158
- final var note = mainViewModel .getFullNote (selection .get (0 ));
159
- ShareUtil .openShareDialog (context , note .getTitle (), note .getContent ());
160
- } else {
161
- ShareUtil .openShareDialog (context ,
162
- context .getResources ().getQuantityString (R .plurals .share_multiple , selection .size (), selection .size ()),
163
- mainViewModel .collectNoteContents (selection ));
164
- }
165
- });
163
+ if (selection .size () == 1 ) {
164
+ final var currentAccount$ = mainViewModel .getCurrentAccount ();
165
+ currentAccount$ .observe (lifecycleOwner , account -> {
166
+ currentAccount$ .removeObservers (lifecycleOwner );
167
+ executor .submit (() -> {{
168
+ final var note = mainViewModel .getFullNote (selection .get (0 ));
169
+ Bundle bundle = new Bundle ();
170
+ bundle .putSerializable (NoteShareActivity .ARG_NOTE , note );
171
+ bundle .putSerializable (NoteShareActivity .ARG_ACCOUNT , account );
172
+ Intent intent = new Intent (mainActivity , NoteShareActivity .class );
173
+ intent .putExtras (bundle );
174
+ mainActivity .startActivity (intent );
175
+ }});
176
+ });
177
+ } else {
178
+ ShareUtil .openShareDialog (context ,
179
+ context .getResources ().getQuantityString (R .plurals .share_multiple , selection .size (), selection .size ()),
180
+ mainViewModel .collectNoteContents (selection ));
181
+ }
182
+
166
183
return true ;
167
184
} else if (itemId == R .id .menu_category ) {// TODO detect whether all selected notes do have the same category - in this case preselect it
168
185
final var accountLiveData = mainViewModel .getCurrentAccount ();
0 commit comments