-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[FEATURE REQUEST] Set emoji as space image #4708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,283
−164
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
888ccff
feat: add set icon option in bottom sheet dialog for space manager users
joragua 4098530
feat: add emojipicker dependency to build.gradle
joragua 4ff5e34
docs: SBOM updated
ownclouders df27968
feat: show dialog when set icon option is clicked
joragua 44b9c6a
feat: generate image file from emoji and store it in cache directory
joragua 3086000
feat: upload emoji image to .space directory and update space image
joragua 95387dc
feat: add release note
joragua 4554ed0
feat: add calens file
joragua b206905
docs: calens changelog updated
ownclouders 7679bfc
refactor: use static value for emoji size
joragua File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Enhancement: Set emoji as space image | ||
|
|
||
| A new option to set an emoji as space image has been added to the bottom sheet, available | ||
| only to users with the required permissions when the three-dot menu button is tapped. | ||
|
|
||
| https://github.com/owncloud/android/issues/4707 | ||
| https://github.com/owncloud/android/pull/4708 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
.../java/com/owncloud/android/presentation/spaces/setspaceicon/SetSpaceIconDialogFragment.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /** | ||
| * ownCloud Android client application | ||
| * | ||
| * @author Jorge Aguado Recio | ||
| * | ||
| * Copyright (C) 2025 ownCloud GmbH. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License version 2, | ||
| * as published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.owncloud.android.presentation.spaces.setspaceicon | ||
|
|
||
| import android.graphics.Bitmap | ||
| import android.graphics.Canvas | ||
| import android.graphics.Paint | ||
| import android.graphics.Rect | ||
| import android.os.Bundle | ||
| import android.view.LayoutInflater | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import androidx.fragment.app.DialogFragment | ||
| import com.owncloud.android.databinding.SetSpaceIconDialogBinding | ||
| import java.io.File | ||
|
|
||
| class SetSpaceIconDialogFragment : DialogFragment() { | ||
| private var _binding: SetSpaceIconDialogBinding? = null | ||
| private val binding get() = _binding!! | ||
|
|
||
| private lateinit var setIconListener: SetIconListener | ||
|
|
||
| override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { | ||
| _binding = SetSpaceIconDialogBinding.inflate(inflater, container, false) | ||
| return binding.root | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
| binding.apply { | ||
| cancelSetSpaceIconButton.setOnClickListener { dialog?.dismiss() } | ||
| emojiPicker.setOnEmojiPickedListener { emojiItem -> | ||
| val emojiFile = convertEmojiToImageFile(emojiItem.emoji) | ||
| setIconListener.setSpaceIcon(emojiFile.name, emojiFile.absolutePath) | ||
| dialog?.dismiss() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun convertEmojiToImageFile(emoji: String): File { | ||
| val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { | ||
| textSize = EMOJI_SIZE | ||
| textAlign = Paint.Align.CENTER | ||
| } | ||
| val bitmap = Bitmap.createBitmap(ICON_WIDTH, ICON_HEIGHT, Bitmap.Config.ARGB_8888) | ||
| val canvas = Canvas(bitmap) | ||
|
|
||
| val bounds = Rect() | ||
| paint.getTextBounds(emoji, 0, emoji.length, bounds) | ||
| val baseline = (ICON_HEIGHT / 2f) - bounds.exactCenterY() | ||
|
|
||
| canvas.drawText(emoji, (ICON_WIDTH / 2f), baseline, paint) | ||
|
|
||
| val file = File(requireContext().cacheDir, EMOJI_FILE_NAME) | ||
| file.outputStream().use { output -> | ||
| bitmap.compress(Bitmap.CompressFormat.PNG, 100, output) | ||
| } | ||
| return file | ||
| } | ||
|
|
||
| interface SetIconListener { | ||
| fun setSpaceIcon(fileName: String, localPath: String) | ||
| } | ||
|
|
||
| companion object { | ||
| private const val ICON_HEIGHT = 405 | ||
| private const val ICON_WIDTH = 720 | ||
| private const val EMOJI_SIZE = 250f | ||
| private const val EMOJI_FILE_NAME = "emoji.png" | ||
|
|
||
| fun newInstance( | ||
| listener: SetIconListener | ||
| ): SetSpaceIconDialogFragment = | ||
| SetSpaceIconDialogFragment().apply { | ||
| setIconListener = listener | ||
| arguments = Bundle() | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.