#174 Allow to share into exiting note

This commit is contained in:
Stefan Niedermann 2020-05-09 20:41:29 +02:00
parent cefb6a9df2
commit f3c49094a9
4 changed files with 64 additions and 3 deletions

View file

@ -47,6 +47,17 @@
android:value=".android.activity.NotesListViewActivity" />
</activity>
<activity
android:name=".android.activity.SelectNoteActivity"
android:label="@string/append_to_note">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>
<activity
android:name=".android.activity.ExceptionActivity"
android:label="@string/app_name" />

View file

@ -97,8 +97,8 @@ public class NotesListViewActivity extends LockedActivity implements ItemAdapter
*/
private boolean notAuthorizedAccountHandled = false;
private SingleSignOnAccount ssoAccount;
private LocalAccount localAccount;
protected SingleSignOnAccount ssoAccount;
protected LocalAccount localAccount;
protected DrawerLayoutBinding binding;
@ -109,6 +109,7 @@ public class NotesListViewActivity extends LockedActivity implements ItemAdapter
protected ItemAdapter adapter = null;
protected NotesDatabase db = null;
private ActionBarDrawerToggle drawerToggle;
private NavigationAdapter adapterCategories;
private NavigationItem itemRecent;
@ -117,7 +118,6 @@ public class NotesListViewActivity extends LockedActivity implements ItemAdapter
private Category navigationSelection = new Category(null, null);
private String navigationOpen = "";
private ActionMode mActionMode;
private NotesDatabase db = null;
private SearchView searchView = null;
private final ISyncCallback syncCallBack = () -> {
adapter.clearSelection(listView);

View file

@ -0,0 +1,47 @@
package it.niedermann.owncloud.notes.android.activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.model.DBNote;
public class SelectNoteActivity extends NotesListViewActivity {
private static final String TAG = SelectNoteActivity.class.getSimpleName();
String receivedText = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Intent receivedIntent = getIntent();
receivedText = receivedIntent.getStringExtra(Intent.EXTRA_TEXT);
}
@Override
public void onNoteClick(int position, View v) {
if(receivedText != null && receivedText.length() > 0) {
final DBNote note = db.getNote(localAccount.getId(), ((DBNote) adapter.getItem(position)).getId());
final String oldContent = note.getContent();
String newContent;
if (oldContent != null && oldContent.length() > 0) {
newContent = oldContent + "\n\n" + receivedText;
} else {
newContent = receivedText;
}
db.updateNoteAndSync(ssoAccount, localAccount.getId(), note, newContent, () -> Toast.makeText(this, getString(R.string.added_content, receivedText), Toast.LENGTH_SHORT).show());
} else {
Toast.makeText(this, R.string.shared_text_empty, Toast.LENGTH_SHORT).show();
}
finish();
}
@Override
public boolean onNoteLongClick(int position, View v) {
return false;
}
}

View file

@ -180,6 +180,9 @@
<string name="error_dialog_contact_us">Please do not hesitate to contact us if the issues persist. You can find our contact information in the about section in the sidebar.</string>
<string name="error_dialog_we_need_info">We need the following technical information to help you:</string>
<string name="error_dialog_redirect">Your server did respond with a HTTP 302 status code, which implies, that you do not have installed the Notes app on your server or something is misconfigured. This can be caused by custom overrides in a .htaccess-file or by Nextcloud apps like OID Client.</string>
<string name="added_content">Added "%1$s"</string>
<string name="shared_text_empty">Shared text was empty</string>
<string name="append_to_note">Append to note</string>
<!-- Array: note modes -->
<string-array name="noteMode_entries">