Skip to content

Commit dcf3376

Browse files
always show sharing tab, but if needed with "reshare not allowed"
Signed-off-by: tobiasKaminsky <[email protected]>
1 parent d24a1b7 commit dcf3376

File tree

7 files changed

+38
-34
lines changed

7 files changed

+38
-34
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ dependencies {
210210
// dependencies for app building
211211
implementation 'androidx.multidex:multidex:2.0.1'
212212
// implementation project('nextcloud-android-library')
213-
genericImplementation 'com.github.nextcloud:android-library:getNote-SNAPSHOT'
214-
gplayImplementation 'com.github.nextcloud:android-library:getNote-SNAPSHOT'
215-
versionDevImplementation 'com.github.nextcloud:android-library:getNote-SNAPSHOT'
213+
genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
214+
gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
215+
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT'
216216
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
217217
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
218218
implementation 'com.google.android.material:material:1.0.0'

src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ Drawable doAvatarInBackground() {
878878
try {
879879
return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
880880
} catch (NoSuchAlgorithmException e) {
881-
e.printStackTrace();
881+
Log_OC.e(this, "Error creating avatar", e);
882882
}
883883
}
884884

src/main/java/com/owncloud/android/ui/adapter/FileDetailTabAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ public FileDetailActivitiesFragment getFileDetailActivitiesFragment() {
7171

7272
@Override
7373
public int getCount() {
74-
return file.canReshare() ? 2 : 1;
74+
return 2;
7575
}
7676
}

src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
311311
OCFileListItemViewHolder itemViewHolder = (OCFileListItemViewHolder) holder;
312312

313313
if (!TextUtils.isEmpty(file.getOwnerId()) && !mAccount.name.split("@")[0].equals(file.getOwnerId())) {
314-
315314
Resources resources = mContext.getResources();
316315
itemViewHolder.sharedAvatar.setTag(file.getOwnerId());
317316
DisplayUtils.setAvatar(mAccount, file.getOwnerId(), this,
@@ -526,25 +525,28 @@ public int getItemViewType(int position) {
526525

527526
private void showShareIcon(OCFileListGridImageViewHolder gridViewHolder, OCFile file) {
528527
ImageView sharedIconView = gridViewHolder.shared;
529-
sharedIconView.setVisibility(View.VISIBLE);
530-
531-
if (file.isSharedWithSharee() || file.isSharedWithMe()) {
532-
sharedIconView.setImageResource(R.drawable.shared_via_users);
533-
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_shared));
534-
} else if (file.isSharedViaLink()) {
535-
sharedIconView.setImageResource(R.drawable.shared_via_link);
536-
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_shared_via_link));
537-
} else {
538-
sharedIconView.setImageResource(R.drawable.ic_unshared);
539-
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_share));
540-
}
541528

542-
if (!TextUtils.isEmpty(file.getOwnerId()) && !mAccount.name.split("@")[0].equals(file.getOwnerId())) { // TODO refactor
543-
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.showShareDetailView(file));
529+
if (gridViewHolder instanceof OCFileListItemViewHolder || file.getUnreadCommentsCount() == 0) {
530+
sharedIconView.setVisibility(View.VISIBLE);
531+
532+
if (file.isSharedWithSharee() || file.isSharedWithMe()) {
533+
sharedIconView.setImageResource(R.drawable.shared_via_users);
534+
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_shared));
535+
} else if (file.isSharedViaLink()) {
536+
sharedIconView.setImageResource(R.drawable.shared_via_link);
537+
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_shared_via_link));
538+
} else {
539+
sharedIconView.setImageResource(R.drawable.ic_unshared);
540+
sharedIconView.setContentDescription(mContext.getString(R.string.shared_icon_share));
541+
}
542+
if (!TextUtils.isEmpty(file.getOwnerId()) && !mAccount.name.split("@")[0].equals(file.getOwnerId())) { // TODO refactor
543+
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.showShareDetailView(file));
544+
} else {
545+
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
546+
}
544547
} else {
545-
sharedIconView.setOnClickListener(view -> ocFileListFragmentInterface.onShareIconClick(file));
548+
sharedIconView.setVisibility(View.GONE);
546549
}
547-
// TODO sharedIconView.setVisibility(View.GONE);
548550
}
549551

550552
/**
@@ -757,7 +759,6 @@ public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
757759

758760
@Override
759761
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
760-
// return ((ImageView) callContext).getTag().equals(tag);
761762
return false;
762763
}
763764

src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,7 @@ private void setupViewPager() {
293293
tabLayout.removeAllTabs();
294294

295295
tabLayout.addTab(tabLayout.newTab().setText(R.string.drawer_item_activities));
296-
297-
if (getFile().canReshare()) {
298-
tabLayout.addTab(tabLayout.newTab().setText(R.string.share_dialog_title));
299-
}
296+
tabLayout.addTab(tabLayout.newTab().setText(R.string.share_dialog_title));
300297

301298
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
302299
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.primaryAccentColor(getContext()));

src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public class FileDetailSharingFragment extends Fragment implements UserListAdapt
7979

8080
private static final String ARG_FILE = "FILE";
8181
private static final String ARG_ACCOUNT = "ACCOUNT";
82-
private static final String TAG = FileDetailSharingFragment.class.getSimpleName();
8382

8483
// to show share with users/groups info
8584
private List<OCShare> shares;
@@ -211,12 +210,18 @@ public void onAttach(Context context) {
211210
}
212211

213212
private void setupView() {
214-
setShareByLinkInfo(file.isSharedViaLink());
215-
setShareWithUserInfo();
216213
setShareWithYou();
217-
FileDetailSharingFragmentHelper.setupSearchView(
218-
(SearchManager) fileDisplayActivity.getSystemService(Context.SEARCH_SERVICE), searchView,
219-
fileDisplayActivity.getComponentName());
214+
215+
if (file.canReshare()) {
216+
setShareByLinkInfo(file.isSharedViaLink());
217+
setShareWithUserInfo();
218+
FileDetailSharingFragmentHelper.setupSearchView(
219+
(SearchManager) fileDisplayActivity.getSystemService(Context.SEARCH_SERVICE), searchView,
220+
fileDisplayActivity.getComponentName());
221+
} else {
222+
searchView.setVisibility(View.GONE);
223+
noList.setText(R.string.reshare_not_allowed);
224+
}
220225
}
221226

222227
/**
@@ -546,7 +551,7 @@ public void refreshCapabilitiesFromDB() {
546551
* Takes into account server capabilities before reading database.
547552
*/
548553
public void refreshPublicShareFromDB() {
549-
if (FileDetailSharingFragmentHelper.isPublicShareDisabled(capabilities)) {
554+
if (FileDetailSharingFragmentHelper.isPublicShareDisabled(capabilities) || !file.canReshare()) {
550555
shareByLinkContainer.setVisibility(View.GONE);
551556
} else {
552557
// Get public share

src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,4 +863,5 @@
863863
<string name="remove_push_notification">Remove</string>
864864
<string name="shared_avatar_desc">Avatar from shared user</string>
865865
<string name="shared_with_you_by">Shared with you by %1$s</string>
866+
<string name="reshare_not_allowed">Resharing is not allowed</string>
866867
</resources>

0 commit comments

Comments
 (0)