Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
import it.niedermann.owncloud.notes.persistence.CapabilitiesWorker;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.persistence.entity.Note;
import it.niedermann.owncloud.notes.share.NoteShareActivity;
import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod;
import it.niedermann.owncloud.notes.shared.model.IResponseCallback;
import it.niedermann.owncloud.notes.shared.model.NavigationCategory;
Expand Down Expand Up @@ -913,6 +914,16 @@ public void onNoteFavoriteClick(int position, View view) {
}});
}

@Override
public void openShare(int position) {
if (adapter.getItem(position) instanceof Note note) {
mainViewModel.getCurrentAccount().observe(this, (account) -> {
final Intent intent = NoteShareActivity.getActivityStartIntent(note, account, this);
startActivity(intent);
});
}
}

private void updateToolbars(boolean enableSearch) {
activityBinding.searchBar.searchBarWrapper.setVisibility(enableSearch ? GONE : VISIBLE);
activityBinding.searchToolbar.setVisibility(enableSearch ? VISIBLE : GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
currentAccount$.removeObservers(lifecycleOwner);
executor.submit(() -> {{
final var note = mainViewModel.getFullNote(selection.get(0));
Bundle bundle = new Bundle();
bundle.putSerializable(NoteShareActivity.ARG_NOTE, note);
bundle.putSerializable(NoteShareActivity.ARG_ACCOUNT, account);
Intent intent = new Intent(mainActivity, NoteShareActivity.class);
intent.putExtras(bundle);
final Intent intent = NoteShareActivity.getActivityStartIntent(note, account, mainActivity);
mainActivity.startActivity(intent);
}});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package it.niedermann.owncloud.notes.main.items;

import static android.view.View.GONE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static com.nextcloud.android.common.ui.util.PlatformThemeUtil.isDarkMode;
Expand All @@ -23,6 +24,7 @@
import androidx.recyclerview.selection.ItemDetailsLookup;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.button.MaterialButton;
import com.google.android.material.chip.Chip;
import com.google.android.material.progressindicator.CircularProgressIndicator;
import com.nextcloud.android.common.core.utils.DateFormatter;
Expand Down Expand Up @@ -76,7 +78,7 @@ protected void bindStatus(CircularProgressIndicator noteSyncStatus, DBStatus sta

protected void bindCategory(@NonNull Context context, @NonNull TextView noteCategory, boolean showCategory, @NonNull String category, int color) {
if (!showCategory || category.isEmpty()) {
noteCategory.setVisibility(View.GONE);
noteCategory.setVisibility(GONE);
} else {
noteCategory.setText(category);

Expand Down Expand Up @@ -112,6 +114,18 @@ protected void bindSearchableContent(@NonNull Context context, @NonNull TextView
}
}

protected void bindNoteSharedIcon(@NonNull Context context, boolean shared, @NonNull MaterialButton noteShareIcon, int color) {
if (shared) {
noteShareIcon.setVisibility(VISIBLE);
noteShareIcon.setOnClickListener(view -> noteClickListener.openShare(getLayoutPosition()));
} else {
noteShareIcon.setVisibility(GONE);
}

final var util = BrandingUtil.of(color, context);
util.material.colorMaterialButtonContent(noteShareIcon, ColorRole.PRIMARY);
}

public abstract void showSwipe(float dX);

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
bindModified(binding.noteModified, note.getModified());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), color);
bindNoteSharedIcon(context, note.isShared(), binding.noteShared, color);
binding.noteExcerpt.setVisibility(TextUtils.isEmpty(note.getExcerpt()) ? GONE : VISIBLE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
bindFavorite(binding.noteFavorite, note.getFavorite());
bindModified(binding.noteModified, note.getModified());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindNoteSharedIcon(context, note.isShared(), binding.noteShared, color);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
} else {
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt(), color);
}

bindNoteSharedIcon(context, note.isShared(), binding.noteShared, color);
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
private ActivityResultLauncher<Intent> resultLauncher;
private final List<OCShare> shares = Collections.synchronizedList(new ArrayList<>());

public static Intent getActivityStartIntent(@NonNull Note note, @NonNull Account account, @NonNull Activity activity) {
Bundle bundle = new Bundle();
bundle.putSerializable(NoteShareActivity.ARG_NOTE, note);
bundle.putSerializable(NoteShareActivity.ARG_ACCOUNT, account);

Intent intent = new Intent(activity, NoteShareActivity.class);
intent.putExtras(bundle);
return intent;
}

public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public interface NoteClickListener {
void onNoteClick(int position, View v);

void onNoteFavoriteClick(int position, View v);

void openShare(int position);
}
16 changes: 16 additions & 0 deletions app/src/main/res/layout/item_notes_list_note_item_grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@
android:layout_marginEnd="@dimen/spacer_2x"
tools:text="27.11." />

<com.google.android.material.button.MaterialButton
android:id="@+id/noteShared"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="@dimen/note_shared_icon_size"
android:layout_height="@dimen/note_shared_icon_size"
android:layout_marginEnd="@dimen/spacer_2x"
android:contentDescription="@string/menu_shared_note"
android:visibility="gone"
android:layout_gravity="end"
app:backgroundTint="@android:color/transparent"
app:icon="@drawable/ic_share_white_24dp"
app:iconGravity="textStart"
app:iconSize="@dimen/note_shared_icon_size"
app:iconTint="@color/defaultBrand"
tools:visibility="visible" />

</LinearLayout>
</LinearLayout>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@
android:layout_marginEnd="@dimen/spacer_2x"
tools:text="27.11." />

<com.google.android.material.button.MaterialButton
android:id="@+id/noteShared"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="@dimen/note_shared_icon_size"
android:layout_height="@dimen/note_shared_icon_size"
android:layout_marginEnd="@dimen/spacer_2x"
android:contentDescription="@string/menu_shared_note"
android:visibility="gone"
android:layout_gravity="end"
app:backgroundTint="@android:color/transparent"
app:icon="@drawable/ic_share_white_24dp"
app:iconGravity="textStart"
app:iconSize="@dimen/note_shared_icon_size"
app:iconTint="@color/defaultBrand"
tools:visibility="visible" />

</LinearLayout>
</LinearLayout>
</LinearLayout>
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/res/layout/item_notes_list_note_item_with_excerpt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

<LinearLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content">

<TextView
Expand All @@ -135,8 +136,10 @@

</LinearLayout>


<LinearLayout
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content">

<TextView
Expand Down Expand Up @@ -164,6 +167,22 @@
android:textSize="@dimen/secondary_font_size"
tools:maxLength="15"
tools:text="@tools:sample/lorem/random" />

<com.google.android.material.button.MaterialButton
android:id="@+id/noteShared"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="@dimen/note_shared_icon_size"
android:layout_height="@dimen/note_shared_icon_size"
android:layout_marginStart="@dimen/spacer_1x"
android:contentDescription="@string/menu_shared_note"
android:visibility="gone"
app:backgroundTint="@android:color/transparent"
app:icon="@drawable/ic_share_white_24dp"
app:iconGravity="textStart"
app:iconSize="@dimen/note_shared_icon_size"
app:iconTint="@color/defaultBrand"
tools:visibility="visible" />

</LinearLayout>
</LinearLayout>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<dimen name="button_extra_width">180dp</dimen>
<dimen name="bottom_navigation_view_margin">100dp</dimen>

<dimen name="note_shared_icon_size">18dp</dimen>

<dimen name="avatar_size">40dp</dimen>
<dimen name="user_status_icon_size">16dp</dimen>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<string name="menu_favorite">Favorite</string>
<string name="menu_preview">Preview</string>
<string name="menu_share">Share</string>
<string name="menu_shared_note">Shared note</string>
<string name="common_loading">Loading…</string>


Expand Down
Loading