* Add serialization of the meta-data and focus objects
These objects are added in some attachments. This commit adds data
classes which are able to serialize these (partially) in preparation
for the ability to honour the focal point information in image
previews.
* Implement correctly honouring the focal point meta-data in previews
This commit adds code which ensures that the image previews of media
attachments to toots are correctly cropped to always show the focal
point of the image (if it is specified). It should not in any way
influence how previews of media without a focal point are shown.
To achieve the correct crop on the image a few components were
needed:
First of all we needed a way to influence how the image is cropped
into the ImageView. It turns out that the preferred way to do this is
by setting the ScaleType to MATRIX and adjusting the matrix of the
image as needed. This matrix allows us to scale and transform the
image in the way we need to make sure that the focal point is visible
within the view. For this purpose we have the FocalPointEnforcer which
can calculate and set the appropriate matrix on an ImageView as soon
as the image is loaded.
However a second problem is that we need to make sure that this matrix
is updated whenever the size of the ImageView changes. The size might
change for example because the orientation of the device changed from
portrait to landscape or vice versas, or for a number of other reasons
such as the screen being split vertically or something like that.
To be able to hook onto this event we need to create a new extended
version of the ImageView class, which we call
MediaPreviewImageView. This class behaves exactly the same as a normal
ImageView, however if the focalPointEnforcer of this view is set, then
it will call this enforcer to update the image matrix any time the
size is changed.
So this commit changes all media previews in the item_status.xml and
item_status_detailled.xml layout files to the new
MediaPreviewImageView class. Additionally in the code for loading the
images into the previews a new case is added which tests if there is a
focus attribute in the meta-data. If so it makes sure to create and
set the FocalPointEnforcer.
* Fix typos in documentation comment
"to" -> "too"
* Use static imports to remove clutter in FocalPointEnforcerTest
Instead of duplication Assert. in front of every assertEquals, simply
statically import it.
* Move the MetaData and Focus classes into the Attachment class
Since they are very strongly linked to the attachment class and are
themselves very small.
* Refactor the focal point handling code
- All the code modifying the actual members of the
MediaPreviewImageView is now in this class itself. This class still
uses the FocalPointUtil to calculate the new Matrix, but it now
handles setting this new Matrix itself.
- The FocalPointEnforcer has been renamed to the FocalPointUtil to
reflect that it only calculates the correct matrix, but doesn't set
anything on the MediaPreviewImageView.
- The Matrix used to control the cropping of the
MediaPreviewImageViews is now only allocated a single time per view
instead of each time the view is resized. This is done by caching
the Matrix and passing it to the FocalPointUtil to update on each
resize.
* Only reallocate focalMatrix if it is not yet initialized
This helps prevent unnecessary allocations in the case where
setFocalPoint is called multiple times.
* Change checking of availability of objects to use != null
As pointed out, the 'is' keyword is meant for checking types, not for
checking non-nullness.
* Make updateFocalPointMatrix() return nothing
This makes it clearer that it actually mutates the matrix it is
given.
* Fix bug with transitions crashing the PhotoView
Due to the android transitions for some reason copying the scaletype
from the MediaPreviewImageView to the PhotoView during the transition,
the PhotoView would crash on pictures with a focal point, since
PhotoView doesn't support ScaleType.MATRIX.
This is solved by the workaround of overriding both the getScaleType
and setScaleType methods to ensure that we use the MATRIX type in the
preview and the center_crop type in the PhotoView.
Additionally this commit also makes sure to remove the focal point
when the MediaPreviewImageView is recycled.
* Fix bug in overriden getScaleType
Instead of simply returning the scaleType we need to return the
super.getScaleType() method, to avoid crashing.
* Merge changes from master
Mainly the migration to androidx.
* move reblog/fav count up in detailed status view and make them clickable
* use status object returned by api when reblogging/faving
* Reblogs -> Boosts
* add support for viewing who faved/reblogged a status
* add onShowReblogs/onShowFavs to listener, fix display bug
* remove unneeded icon from previous revision
* small code improvements
* fix liking/boosting toot with card
* upgrade to AndroidX, upgrade libraries
* move to MaterialComponents theme
* make sure the compose button looks good everywhere
* fix tollbar title/button alignment on tablet
* move to new material color theming, consolidate colors and themes
* fix build, fix imports
* set error on TextInputLayout instead of EditText
* fix imports, TootButton when
* improve snackbar style
* fix task description color
* Add visibility icons to statuses
* Remove visibility icons from timeline statuses
* Dynamically scale visibility icon according to timestamp font size
* Remove visibility icon selection logic from Status model
* Migrate visibility icon logic to StatusDetailedViewHolder
* Simplify/improve performance of visibility icon layout
* Use text size for visibility icon size (instead of view size)
* Remove unnecessary LayoutListener
* Remove unnecessary visibilityIcon check
* Add EmojiCompat
* EmojiCompat doesn' replace all emojis anymore
* This app should be now capable of loading a EmojiCompat-font located in a file somewhere inside the device's storage
* Should now replace all emojis
* Add EmojiCompat support to EditTextTyped
* Provide EmojiCompat fonts
* The app won't crash anymore when no emoji font is available.
Emoji font should now be located at [Private external app directory]/files/EmojiCompat.ttf
* Removed BundledEmojiCompat dependency
Since this EmojiCompat-implementation does not rely on BundledEmojiCompat, there's no reason to have it enabled.
* Update EditTextTyped.kt
Since connection isn't assigned to (I tried doing so), it can be declared final/val again.
* Update README.md
* Add some non-working emoji preferences
* Add a short font list for testing
* Finished implementation
* Add Twemoji to font list
* Update documentation, more comments
* Delete AssetEmojiCompat which is obsolete now
* Update the font list
* Update the font list
* Fix font list & add Exception handling for malformed JSON files (hopefully)
* More fixes. It should work now...
* Removed AssetEmojiCompat (again)
* Add most of the changes
* Improved the EmojiCompat dialog's style
* The font list is now based on a static layout without external files
* Re-add the real font URL for Twemoji
* Emoji-font captions are now translatable
* Removed one unused String (loading)
* Removed emoji fonts from this repo
* Applied changes from the PR change requests
* The correct emoji font will be selected after cancelling a change
* Add details on the EmojiCompat fonts available (not shown yet)
* Add licensing information on Twemoji and Blobmoji
* Reworked some strings
* Moved FileEmojiCompat to its own library
* Update FileEmojiCompat to the latest version (1.0.3)
* EmojiCompat bug should be fixed
* Better handling of failed downloads
* Removed one TODO
Signed-off-by: Constantin A <10349490+C1710@users.noreply.github.com>
* Update emoji attribution strings
Signed-off-by: Constantin A <10349490+C1710@users.noreply.github.com>
* Fixed some misspelled strings
Signed-off-by: Constantin A <10349490+C1710@users.noreply.github.com>
* do not add media urls to status text
* add scrolling to content
* add arrow icon and animation to replying-to toggle
* remove unnecessary compose_button_colors.xml
* improve toot button
* improve bottom bar, add bottom sheet for compose options, dedicated cw button
* fix crash on Android < API 21
* move media picking from dialog to bottom sheet
* add small style tootbutton
* fix colors/button background for light theme
* add icons to media chose bottom sheet
* improve hide media button, delete unused styles
* fix crash on dev build when taking photo
* consolidate drawables
* consolidate strings and ids, add tooltips to buttons
* allow media only toots
* change error message to show max size of upload correctly
* fix button color
* add emoji
* code cleanup
* Merge branch 'master' into compose_activity_refactoring
# Conflicts:
# app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java
* fix hidden snackbar
* improve hint text color
* add SendTootService
* fix timeline refreshing
* toot saving and error handling for sendtootservice
* restructure some code
* convert EditTextTyped to Kotlin
* fixed pick media button disabled color
* force sensitive media when content warning is shown
* add db cache for emojis & fix tests
* reorder buttons to match mastodon web
* add possibility to cancel sending of toot
* correctly delete sent toots
* refresh SavedTootActivity after toot was sent
* remove unused resources
* correct params for toot saving in SendTootService
* consolidate strings
* bugfix
* remove unused resources
* fix notifications on old android for SendTootService
* fix crash
* Use the entire content warning text + button as the hitbox for the "Show more/less" toggle
* Move the content warning toggle button to its own line and give it a little more space
* Move content warning elements into parent layout, remove now-superfluous FlowLayout
* Use marginTop/Bottom instead of Vertical, which is only in sdk 26+
* Update minimum width for content warning toggle button