Skip to content

Commit

Permalink
Add collaborators menu to markdown fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo04 committed Sep 28, 2021
1 parent 98189e5 commit 251e7e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.automattic.simplenote;

import static com.automattic.simplenote.Simplenote.SCROLL_POSITION_PREFERENCES;
import static com.automattic.simplenote.analytics.AnalyticsTracker.CATEGORY_NOTE;
import static com.automattic.simplenote.utils.SimplenoteLinkify.SIMPLENOTE_LINK_PREFIX;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
Expand Down Expand Up @@ -41,9 +46,6 @@
import java.lang.ref.SoftReference;
import java.util.Set;

import static com.automattic.simplenote.Simplenote.SCROLL_POSITION_PREFERENCES;
import static com.automattic.simplenote.utils.SimplenoteLinkify.SIMPLENOTE_LINK_PREFIX;

public class NoteMarkdownFragment extends Fragment implements Bucket.Listener<Note> {
public static final String ARG_ITEM_ID = "item_id";

Expand Down Expand Up @@ -185,6 +187,9 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
case R.id.menu_delete:
NoteUtils.showDialogDeletePermanently(requireActivity(), mNote);
return true;
case R.id.menu_collaborators:
navigateToCollaborators();
return true;
case R.id.menu_trash:
if (!isAdded()) {
return false;
Expand All @@ -194,7 +199,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
return true;
case R.id.menu_copy_internal:
AnalyticsTracker.track(
AnalyticsTracker.Stat.INTERNOTE_LINK_COPIED,
AnalyticsTracker.Stat.INTERNOTE_LINK_COPIED,
AnalyticsTracker.CATEGORY_LINK,
"internote_link_copied_markdown"
);
Expand All @@ -215,6 +220,22 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
}
}

private void navigateToCollaborators() {
if (getActivity() == null || mNote == null) {
return;
}

Intent intent = new Intent(requireActivity(), CollaboratorsActivity.class);
intent.putExtra(CollaboratorsActivity.NOTE_ID_ARG, mNote.getSimperiumKey());
startActivity(intent);

AnalyticsTracker.track(
AnalyticsTracker.Stat.EDITOR_COLLABORATORS_ACCESSED,
CATEGORY_NOTE,
"collaborators_ui_accessed"
);
}

private void deleteNote() {
NoteUtils.deleteNote(mNote, getActivity());
requireActivity().finish();
Expand Down
15 changes: 11 additions & 4 deletions Simplenote/src/main/res/menu/note_markdown.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,23 @@
android:checkable="true"
android:enabled="false"
android:title="@string/publish"
app:showAsAction="never">
</item>
app:showAsAction="never"></item>

<item
android:id="@+id/menu_copy"
android:enabled="false"
android:title="@string/copy_link"
app:showAsAction="never">
</item>
app:showAsAction="never"></item>

</group>

<group android:id="@+id/group_3">

<item
android:id="@+id/menu_collaborators"
android:enabled="true"
android:title="@string/collaborators"
app:showAsAction="never"></item>
</group>

</menu>

0 comments on commit 251e7e1

Please sign in to comment.