InternalShareViewHolder.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. *
  3. * Nextcloud Android client application
  4. *
  5. * @author Tobias Kaminsky
  6. * Copyright (C) 2020 Tobias Kaminsky
  7. * Copyright (C) 2020 Nextcloud GmbH
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. package com.owncloud.android.ui.adapter;
  23. import android.content.Context;
  24. import android.graphics.PorterDuff;
  25. import android.view.View;
  26. import com.owncloud.android.R;
  27. import com.owncloud.android.databinding.FileDetailsShareInternalShareLinkBinding;
  28. import com.owncloud.android.lib.resources.shares.OCShare;
  29. import androidx.annotation.NonNull;
  30. import androidx.core.content.res.ResourcesCompat;
  31. import androidx.recyclerview.widget.RecyclerView;
  32. class InternalShareViewHolder extends RecyclerView.ViewHolder {
  33. private FileDetailsShareInternalShareLinkBinding binding;
  34. private Context context;
  35. public InternalShareViewHolder(@NonNull View itemView) {
  36. super(itemView);
  37. }
  38. public InternalShareViewHolder(FileDetailsShareInternalShareLinkBinding binding, Context context) {
  39. this(binding.getRoot());
  40. this.binding = binding;
  41. this.context = context;
  42. }
  43. public void bind(OCShare share, ShareeListAdapterListener listener) {
  44. binding.copyInternalLinkIcon
  45. .getBackground()
  46. .setColorFilter(ResourcesCompat.getColor(context.getResources(),
  47. R.color.grey_db,
  48. null),
  49. PorterDuff.Mode.SRC_IN);
  50. binding.copyInternalLinkIcon
  51. .getDrawable()
  52. .mutate()
  53. .setColorFilter(ResourcesCompat.getColor(context.getResources(),
  54. R.color.black,
  55. null),
  56. PorterDuff.Mode.SRC_IN);
  57. if (share.isFolder()) {
  58. binding.shareInternalLinkText.setText(context.getString(R.string.share_internal_link_to_folder_text));
  59. } else {
  60. binding.shareInternalLinkText.setText(context.getString(R.string.share_internal_link_to_file_text));
  61. }
  62. binding.copyInternalContainer.setOnClickListener(l -> listener.copyInternalLink());
  63. }
  64. }