Yuito-app-android/app/src/main/res/layout/item_status.xml

477 lines
21 KiB
XML
Raw Normal View History

2017-01-03 00:30:27 +01:00
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2017-10-18 11:08:49 +02:00
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:sparkbutton="http://schemas.android.com/apk/res-auto"
2017-10-18 11:08:49 +02:00
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/status_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:focusable="true"
2017-11-30 20:12:09 +01:00
android:paddingLeft="14dp"
android:paddingRight="14dp">
2017-01-03 00:30:27 +01:00
<androidx.emoji.widget.EmojiTextView
android:id="@+id/status_info"
android:layout_width="match_parent"
2017-01-03 00:30:27 +01:00
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/status_reblogged_bar_padding_top"
android:drawableStart="?attr/status_reblog_small_drawable"
2017-11-30 20:12:09 +01:00
android:drawablePadding="6dp"
2017-10-18 11:08:49 +02:00
android:gravity="center_vertical"
android:importantForAccessibility="no"
2017-11-30 20:12:09 +01:00
android:paddingStart="38dp"
android:textColor="?android:textColorTertiary"
android:textSize="?attr/status_text_medium"
app:layout_constraintLeft_toRightOf="parent"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="RtlSymmetry"
tools:text="ConnyDuck boosted"
tools:visibility="visible" />
2017-01-03 00:30:27 +01:00
<ImageView
2017-10-18 11:08:49 +02:00
android:id="@+id/status_avatar"
android:layout_width="48dp"
android:layout_height="48dp"
2017-11-30 20:12:09 +01:00
android:layout_marginTop="14dp"
android:contentDescription="@string/action_view_profile"
android:importantForAccessibility="no"
android:scaleType="centerCrop"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_info"
tools:src="@drawable/avatar_default" />
<ImageView
android:id="@+id/status_avatar_inset"
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@null"
android:importantForAccessibility="no"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/status_avatar"
app:layout_constraintEnd_toEndOf="@id/status_avatar"
tools:src="@color/accent"
tools:visibility="visible" />
2017-01-03 00:30:27 +01:00
<androidx.emoji.widget.EmojiTextView
android:id="@+id/status_display_name"
android:layout_width="wrap_content"
2017-10-18 11:08:49 +02:00
android:layout_height="wrap_content"
android:layout_marginStart="14dp"
android:layout_marginTop="10dp"
android:ellipsize="end"
android:importantForAccessibility="no"
android:maxLines="1"
android:paddingEnd="@dimen/status_display_name_padding_end"
android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_medium"
android:textStyle="normal|bold"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@id/status_timestamp_info"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/status_avatar"
app:layout_constraintTop_toBottomOf="@id/status_info"
tools:text="Ente r the void you foooooo" />
<TextView
android:id="@+id/status_username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:importantForAccessibility="no"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toStartOf="@id/status_timestamp_info"
app:layout_constraintStart_toEndOf="@id/status_display_name"
app:layout_constraintTop_toTopOf="@id/status_display_name"
tools:text="\@Entenhausen@birbsarecooooooooooool.site" />
2017-11-30 20:12:09 +01:00
<TextView
android:id="@+id/status_timestamp_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:importantForAccessibility="no"
android:textColor="?android:textColorSecondary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/status_display_name"
tools:text="13:37" />
<androidx.emoji.widget.EmojiTextView
android:id="@+id/status_content_warning_description"
2019-01-10 20:41:39 +01:00
android:layout_width="0dp"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_medium"
android:visibility="gone"
2019-01-10 20:41:39 +01:00
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/status_display_name"
2019-01-10 20:41:39 +01:00
tools:text="content warning which is very long and it doesn't fit"
tools:visibility="visible" />
<ToggleButton
android:id="@+id/status_content_warning_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="?attr/content_warning_button"
android:importantForAccessibility="no"
android:minWidth="150dp"
android:minHeight="0dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:textAllCaps="true"
android:textOff="@string/status_content_warning_show_more"
android:textOn="@string/status_content_warning_show_less"
android:textSize="?attr/status_text_medium"
android:visibility="gone"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/status_content_warning_description"
tools:visibility="visible" />
<androidx.emoji.widget.EmojiTextView
2017-01-03 00:30:27 +01:00
android:id="@+id/status_content"
android:layout_width="0dp"
2017-01-03 00:30:27 +01:00
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
2017-10-18 11:08:49 +02:00
android:focusable="true"
android:importantForAccessibility="no"
2017-11-30 20:12:09 +01:00
android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/status_content_warning_button"
app:layout_constraintTop_toBottomOf="@id/status_content_warning_button"
2017-11-30 20:12:09 +01:00
tools:text="This is a status" />
2017-01-03 00:30:27 +01:00
Add support for collapsible statuses when they exceed 500 characters (#825) * Update Gradle plugin to work with Android Studio 3.3 Canary Android Studio 3.1.4 Stable doesn't render layout previews in this project for whatever reason. Switching to the latest 3.3 Canary release fixes the issue without affecting Gradle scripts but requires the new Android Gradle plugin to match the new Android Studio release. This commit will be reverted once development on the feature is done. * Update gradle build script to allow installing debug builds alongside store version This will allow developers, testers, etc to work on Tusky will not having to worry about overwriting, uninstalling, fiddling with a preinstalled application which would mean having to login again every time the development cycle starts/finishes and manually reinstalling the app. * Add UI changes to support collapsing statuses The button uses subtle styling to not be distracting like the CW button on the timeline The button is toggleable, full width to match the status textbox hitbox width and also is shorter to not be too intrusive between the status text and images, or the post below * Update status data model to store whether the message has been collapsed * Update status action listener to notify of collapsed state changing Provide stubs in all implementing classes and mark as TODO the stubs that require a proper implementation for the feature to work. * Add implementation code to handle status collapse/expand in timeline Code has not been added elsewhere to simplify testing. Once the code will be considered stable it will be also included in other status action listener implementers. * Add preferences so that users can toggle the collapsing of long posts This is currently limited to a simple toggle, it would be nice to implement a more advanced UI to offer the user more control over the feature. * Update Gradle plugin to work with latest Android Studio 3.3 Canary 8 Just like the other commit, this will be reverted once the feature is working. I simply don't want to deal with what changes in my installation of Android Studio 3.1.4 Stable which breaks the layout preview rendering. * Update data models and utils for statuses to better handle collapsing I forgot that data isn't available from the API and can't really be built from scratch using existing data due to preferences. A new, extra boolean should fix the issue. * Fix search breaking due to newly introduced variables in utils classes * Fix timeline breaking due to newly introduced variables in utils classes * Fix item status text for collapsed toggle being shown in the wrong state * Update timeline fragment to refresh the list when collapsed settings change * Add support for status content collapse in timeline viewholder * Fix view holder truncating posts using temporary debug settings at 50 chars * Add toggle support to notification layout as well * Add support for collapsed statuses to search results * Add support for expandable content to notifications too * Update codebase with some suggested changes by @charlang * Update more code with more suggestions and move null-safety into view data * Update even more code with even more suggested code changes * Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates) * Add an input filter utility class to reuse code for trimming statuses * Update UI of statuses to show a taller collapsible button * Update notification fragment logging to simplify null checks * Add smartness to SmartLengthInputFilter such as word trimming and runway * Fix posts with show more button even if bad ratio didn't collapse * Fix thread view showing button but not collapsing by implementing the feature * Fix spannable losing spans when collapsed and restore length to 500 characters * Remove debug build suffix as per request * Fix all the merging happened in f66d689, 623cad2 and 7056ba5 * Fix notification button spanning full width rather than content width * Add a way to access a singleton to smart filter and use clearer code * Update view holders using smart input filters to use more singletons * Fix code style lacking spaces before boolean checks in ifs and others * Remove all code related to collapsibility preferences, strings included * Update style to match content warning toggle button * Update strings to give cleaner differentiation between CW and collapse * Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
<ToggleButton
android:id="@+id/button_toggle_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="?attr/content_warning_button"
android:importantForAccessibility="no"
android:minWidth="150dp"
android:minHeight="0dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:textAllCaps="true"
android:textOff="@string/status_content_show_less"
android:textOn="@string/status_content_show_more"
android:textSize="?attr/status_text_medium"
android:visibility="gone"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/status_content"
tools:visibility="visible" />
Add support for collapsible statuses when they exceed 500 characters (#825) * Update Gradle plugin to work with Android Studio 3.3 Canary Android Studio 3.1.4 Stable doesn't render layout previews in this project for whatever reason. Switching to the latest 3.3 Canary release fixes the issue without affecting Gradle scripts but requires the new Android Gradle plugin to match the new Android Studio release. This commit will be reverted once development on the feature is done. * Update gradle build script to allow installing debug builds alongside store version This will allow developers, testers, etc to work on Tusky will not having to worry about overwriting, uninstalling, fiddling with a preinstalled application which would mean having to login again every time the development cycle starts/finishes and manually reinstalling the app. * Add UI changes to support collapsing statuses The button uses subtle styling to not be distracting like the CW button on the timeline The button is toggleable, full width to match the status textbox hitbox width and also is shorter to not be too intrusive between the status text and images, or the post below * Update status data model to store whether the message has been collapsed * Update status action listener to notify of collapsed state changing Provide stubs in all implementing classes and mark as TODO the stubs that require a proper implementation for the feature to work. * Add implementation code to handle status collapse/expand in timeline Code has not been added elsewhere to simplify testing. Once the code will be considered stable it will be also included in other status action listener implementers. * Add preferences so that users can toggle the collapsing of long posts This is currently limited to a simple toggle, it would be nice to implement a more advanced UI to offer the user more control over the feature. * Update Gradle plugin to work with latest Android Studio 3.3 Canary 8 Just like the other commit, this will be reverted once the feature is working. I simply don't want to deal with what changes in my installation of Android Studio 3.1.4 Stable which breaks the layout preview rendering. * Update data models and utils for statuses to better handle collapsing I forgot that data isn't available from the API and can't really be built from scratch using existing data due to preferences. A new, extra boolean should fix the issue. * Fix search breaking due to newly introduced variables in utils classes * Fix timeline breaking due to newly introduced variables in utils classes * Fix item status text for collapsed toggle being shown in the wrong state * Update timeline fragment to refresh the list when collapsed settings change * Add support for status content collapse in timeline viewholder * Fix view holder truncating posts using temporary debug settings at 50 chars * Add toggle support to notification layout as well * Add support for collapsed statuses to search results * Add support for expandable content to notifications too * Update codebase with some suggested changes by @charlang * Update more code with more suggestions and move null-safety into view data * Update even more code with even more suggested code changes * Revert a0a41ca and 0ee004d (Android Studio 3.1 to Android Studio 3.3 updates) * Add an input filter utility class to reuse code for trimming statuses * Update UI of statuses to show a taller collapsible button * Update notification fragment logging to simplify null checks * Add smartness to SmartLengthInputFilter such as word trimming and runway * Fix posts with show more button even if bad ratio didn't collapse * Fix thread view showing button but not collapsing by implementing the feature * Fix spannable losing spans when collapsed and restore length to 500 characters * Remove debug build suffix as per request * Fix all the merging happened in f66d689, 623cad2 and 7056ba5 * Fix notification button spanning full width rather than content width * Add a way to access a singleton to smart filter and use clearer code * Update view holders using smart input filters to use more singletons * Fix code style lacking spaces before boolean checks in ifs and others * Remove all code related to collapsibility preferences, strings included * Update style to match content warning toggle button * Update strings to give cleaner differentiation between CW and collapse * Update smart filter code to use fully qualified names to avoid confusion
2018-09-19 19:51:20 +02:00
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/status_media_preview_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/status_media_preview_margin_top"
android:importantForAccessibility="noHideDescendants"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/button_toggle_content"
tools:visibility="gone">
Set image previews correctly according to their focal points (#899) * 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.
2018-12-28 16:32:07 +01:00
<com.keylesspalace.tusky.view.MediaPreviewImageView
2017-11-30 20:12:09 +01:00
android:id="@+id/status_media_preview_0"
android:layout_width="0dp"
android:layout_height="@dimen/status_media_preview_height"
android:scaleType="centerCrop"
app:layout_constraintEnd_toStartOf="@+id/status_media_preview_1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
Set image previews correctly according to their focal points (#899) * 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.
2018-12-28 16:32:07 +01:00
<com.keylesspalace.tusky.view.MediaPreviewImageView
2017-11-30 20:12:09 +01:00
android:id="@+id/status_media_preview_1"
android:layout_width="0dp"
android:layout_height="@dimen/status_media_preview_height"
android:layout_marginStart="4dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/status_media_preview_0"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
Set image previews correctly according to their focal points (#899) * 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.
2018-12-28 16:32:07 +01:00
<com.keylesspalace.tusky.view.MediaPreviewImageView
2017-11-30 20:12:09 +01:00
android:id="@+id/status_media_preview_2"
android:layout_width="0dp"
android:layout_height="@dimen/status_media_preview_height"
android:layout_marginTop="4dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toStartOf="@+id/status_media_preview_3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/status_media_preview_0"
tools:ignore="ContentDescription" />
Set image previews correctly according to their focal points (#899) * 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.
2018-12-28 16:32:07 +01:00
<com.keylesspalace.tusky.view.MediaPreviewImageView
2017-11-30 20:12:09 +01:00
android:id="@+id/status_media_preview_3"
android:layout_width="0dp"
android:layout_height="@dimen/status_media_preview_height"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/status_media_preview_2"
app:layout_constraintTop_toBottomOf="@+id/status_media_preview_1"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/status_media_overlay_0"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="center"
app:layout_constraintBottom_toBottomOf="@+id/status_media_preview_0"
app:layout_constraintEnd_toEndOf="@+id/status_media_preview_0"
app:layout_constraintStart_toStartOf="@+id/status_media_preview_0"
app:layout_constraintTop_toTopOf="@+id/status_media_preview_0"
app:srcCompat="?attr/play_indicator_drawable"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/status_media_overlay_1"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="center"
app:layout_constraintBottom_toBottomOf="@+id/status_media_preview_1"
app:layout_constraintEnd_toEndOf="@+id/status_media_preview_1"
app:layout_constraintStart_toStartOf="@+id/status_media_preview_1"
app:layout_constraintTop_toTopOf="@+id/status_media_preview_1"
app:srcCompat="?attr/play_indicator_drawable"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/status_media_overlay_2"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="center"
app:layout_constraintBottom_toBottomOf="@+id/status_media_preview_2"
app:layout_constraintEnd_toEndOf="@+id/status_media_preview_2"
app:layout_constraintStart_toStartOf="@+id/status_media_preview_2"
app:layout_constraintTop_toTopOf="@+id/status_media_preview_2"
app:srcCompat="?attr/play_indicator_drawable"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/status_media_overlay_3"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="center"
app:layout_constraintBottom_toBottomOf="@+id/status_media_preview_3"
app:layout_constraintEnd_toEndOf="@+id/status_media_preview_3"
app:layout_constraintStart_toStartOf="@+id/status_media_preview_3"
app:layout_constraintTop_toTopOf="@+id/status_media_preview_3"
app:srcCompat="?attr/play_indicator_drawable"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/status_sensitive_media_button"
android:layout_width="wrap_content"
2017-10-18 11:08:49 +02:00
android:layout_height="wrap_content"
2017-11-30 20:12:09 +01:00
android:alpha="0.7"
android:contentDescription="@null"
android:padding="@dimen/status_sensitive_media_button_padding"
android:tint="@color/white"
2017-11-30 20:12:09 +01:00
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="@+id/status_media_preview_container"
app:layout_constraintTop_toTopOf="@+id/status_media_preview_container"
ComposeActivity improvements (#548) * 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
2018-04-13 22:37:21 +02:00
app:srcCompat="@drawable/ic_eye_24dp" />
2017-11-30 20:12:09 +01:00
<TextView
android:id="@+id/status_sensitive_media_warning"
2017-11-30 20:12:09 +01:00
android:layout_width="0dp"
android:layout_height="0dp"
2017-10-18 11:08:49 +02:00
android:background="?attr/sensitive_media_warning_background_color"
android:gravity="center"
android:importantForAccessibility="no"
2017-11-30 20:12:09 +01:00
android:lineSpacingMultiplier="1.2"
android:orientation="vertical"
2017-10-18 11:08:49 +02:00
android:padding="8dp"
2017-11-30 20:12:09 +01:00
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="?attr/status_text_medium"
2017-11-30 20:12:09 +01:00
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/status_media_label_0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
2017-11-30 20:12:09 +01:00
android:background="?attr/selectableItemBackground"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium"
2019-02-11 16:59:01 +01:00
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/status_media_label_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_media_label_0" />
<TextView
android:id="@+id/status_media_label_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_media_label_1" />
<TextView
android:id="@+id/status_media_label_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:importantForAccessibility="no"
android:textSize="?attr/status_text_medium"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/status_media_label_2" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/status_poll_options"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:nestedScrollingEnabled="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/status_media_preview_container" />
<!-- using AppCompatButton because we don't want the inflater to turn it into a MaterialButton -->
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/status_poll_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:background="?attr/content_warning_button"
android:gravity="center"
android:minWidth="150dp"
android:minHeight="0dp"
android:paddingLeft="16dp"
android:paddingTop="4dp"
android:paddingRight="16dp"
android:paddingBottom="4dp"
android:text="@string/poll_vote"
android:textSize="?attr/status_text_medium"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/status_poll_options" />
<TextView
android:id="@+id/status_poll_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/status_poll_button"
tools:text="7 votes • 7 hours remaining" />
<ImageButton
android:id="@+id/status_reply"
style="?attr/image_button_style"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:contentDescription="@string/action_reply"
android:importantForAccessibility="no"
android:padding="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/status_inset"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="@id/status_display_name"
app:layout_constraintTop_toBottomOf="@id/status_poll_description"
app:srcCompat="@drawable/ic_reply_24dp" />
<at.connyduck.sparkbutton.SparkButton
android:id="@+id/status_inset"
android:layout_width="30dp"
android:layout_height="30dp"
android:clipToPadding="false"
android:contentDescription="@string/action_reblog"
android:importantForAccessibility="no"
android:padding="4dp"
app:layout_constraintEnd_toStartOf="@id/status_favourite"
app:layout_constraintStart_toEndOf="@id/status_reply"
app:layout_constraintTop_toTopOf="@id/status_reply"
2019-10-03 18:55:32 +02:00
sparkbutton:activeImage="@drawable/ic_reblog_active_24dp"
sparkbutton:iconSize="28dp"
sparkbutton:inactiveImage="?attr/status_reblog_inactive_drawable"
sparkbutton:primaryColor="@color/tusky_blue"
sparkbutton:secondaryColor="@color/tusky_blue_light" />
<at.connyduck.sparkbutton.SparkButton
android:id="@+id/status_favourite"
android:layout_width="30dp"
android:layout_height="30dp"
android:clipToPadding="false"
android:contentDescription="@string/action_favourite"
android:importantForAccessibility="no"
android:padding="4dp"
app:layout_constraintEnd_toStartOf="@id/status_more"
app:layout_constraintStart_toEndOf="@id/status_inset"
app:layout_constraintTop_toTopOf="@id/status_inset"
sparkbutton:activeImage="?attr/status_favourite_active_drawable"
sparkbutton:iconSize="28dp"
sparkbutton:inactiveImage="?attr/status_favourite_inactive_drawable"
sparkbutton:primaryColor="@color/tusky_orange"
sparkbutton:secondaryColor="@color/tusky_orange_light" />
<ImageButton
android:id="@+id/status_more"
style="?attr/image_button_style"
android:layout_width="24dp"
android:layout_height="30dp"
android:layout_marginEnd="8dp"
android:contentDescription="@string/action_more"
android:importantForAccessibility="no"
android:padding="4dp"
app:layout_constraintBottom_toBottomOf="@id/status_reply"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/status_favourite"
app:layout_constraintTop_toTopOf="@id/status_reply"
app:srcCompat="@drawable/ic_more_horiz_24dp" />
</androidx.constraintlayout.widget.ConstraintLayout>